Skip to content

Commit

Permalink
toypad: workaround for bug in hid library
Browse files Browse the repository at this point in the history
Workaround for bug in github.com/karalabe/hid where Write report one
more byte written on Windows.
See karalabe/hid#36
  • Loading branch information
dolmen committed Jan 12, 2022
1 parent 8caa00c commit 3a4ad3a
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions toypad/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,14 @@ func (c *Command) Send(w io.Writer, msgId uint8) error {
if err != nil {
return fmt.Errorf("Write: %w", err)
}
if n == len(f)+1 {
// This happens on Windows with github.com/karalabe/hid
// See https://github.com/karalabe/hid/issues/36
n--
}
if n < len(f) {
return fmt.Errorf("Write %d/%d: %w", n, len(f), io.ErrShortWrite)
}
if n > len(f) {
// This happens on Windows
log.Printf("Sent %d bytes, %d written. WTF??", len(f), n)
}
return nil
}

Expand Down

0 comments on commit 3a4ad3a

Please sign in to comment.