Skip to content

Commit

Permalink
Fix for incorrect reported written bytes on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
dolmen authored and pennam committed Jun 29, 2023
1 parent 9c14560 commit 9d82ac7
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions hid_enabled.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,10 @@ func (dev *Device) Write(b []byte) (int, error) {
}
// Prepend a HID report ID on Windows, other OSes don't need it
var report []byte
fixlen := 0
if runtime.GOOS == "windows" {
report = append([]byte{0x00}, b...)
fixlen = -1
} else {
report = b
}
Expand All @@ -188,6 +190,9 @@ func (dev *Device) Write(b []byte) (int, error) {
failure, _ := wcharTToString(message)
return 0, errors.New("hidapi: " + failure)
}
if written > 0 {
written += fixlen
}
return written, nil
}

Expand Down

0 comments on commit 9d82ac7

Please sign in to comment.