Fix HID timeout/EINTR errors and relative icon paths
- Treat "timeout" and "interrupted system call" from ReadWithTimeout as non-fatal — hidraw on Linux returns errors instead of (0, nil) for both, causing false device-dead detection and reconnect loops - Resolve icons_dir relative to the config file when the path is not absolute, so the service finds icons regardless of working directory - Installer now copies bundled icons to the config dir on first install
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"image"
|
||||
"image/jpeg"
|
||||
_ "image/png"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/sstallion/go-hid"
|
||||
@@ -152,6 +153,12 @@ func (sd *StreamDeck) ReadButtons() ([]bool, error) {
|
||||
data := make([]byte, readReportSize)
|
||||
n, err := sd.dev.ReadWithTimeout(data, 250)
|
||||
if err != nil {
|
||||
// hidraw on Linux returns errors rather than (0, nil) for non-fatal
|
||||
// conditions: timeout waiting for data, or EINTR (signal interrupted).
|
||||
msg := strings.ToLower(err.Error())
|
||||
if strings.Contains(msg, "timeout") || strings.Contains(msg, "interrupted") {
|
||||
return nil, nil
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
if n == 0 {
|
||||
|
||||
Reference in New Issue
Block a user