Compare commits

..

3 Commits

Author SHA1 Message Date
Adam Shiervani b4b1b56fff fix: update auto-release keyboard interval to 225 2025-09-16 14:35:14 +02:00
Adam Shiervani b925dcf061 fix: log warning on keypress report failure 2025-09-16 14:34:43 +02:00
Adam Shiervani da3e951394 fix: handle error in key release process and log warnings 2025-09-16 14:34:02 +02:00
1 changed files with 8 additions and 2 deletions

View File

@ -29,7 +29,7 @@ var keyboardConfig = gadgetConfigItem{
// macOS default: 15 * 15 = 225ms https://discussions.apple.com/thread/1316947?sortBy=rank
// Linux default: 250ms https://man.archlinux.org/man/kbdrate.8.en
// Windows default: 1s `HKEY_CURRENT_USER\Control Panel\Accessibility\Keyboard Response\AutoRepeatDelay`
const autoReleaseKeyboardInterval = time.Millisecond * 100
const autoReleaseKeyboardInterval = time.Millisecond * 225
// Source: https://www.kernel.org/doc/Documentation/usb/gadget_hid.txt
var keyboardReportDesc = []byte{
@ -226,7 +226,10 @@ func (u *UsbGadget) performAutoRelease(key byte) {
return
}
u.keypressReport(key, false)
_, err := u.keypressReport(key, false)
if err != nil {
u.log.Warn().Uint8("key", key).Msg("failed to release key")
}
}
func (u *UsbGadget) listenKeyboardEvents() {
@ -478,6 +481,9 @@ func (u *UsbGadget) keypressReport(key byte, press bool) (KeysDownState, error)
func (u *UsbGadget) KeypressReport(key byte, press bool) error {
state, err := u.keypressReport(key, press)
if err != nil {
u.log.Warn().Uint8("key", key).Bool("press", press).Msg("failed to report key")
}
isRolledOver := state.Keys[0] == hidErrorRollOver
if isRolledOver {