fix: should cancelAutorelease when pressed is true

This commit is contained in:
Siyuan Miao 2025-09-12 12:33:43 +02:00
parent 4501b96237
commit edd8137ed0
1 changed files with 3 additions and 3 deletions

View File

@ -25,7 +25,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: 1ms `HKEY_CURRENT_USER\Control Panel\Accessibility\Keyboard Response\AutoRepeatDelay`
const autoReleaseKeyboardInterval = time.Millisecond * 225
const autoReleaseKeyboardInterval = time.Millisecond * 100
// Source: https://www.kernel.org/doc/Documentation/usb/gadget_hid.txt
var keyboardReportDesc = []byte{
@ -473,11 +473,11 @@ func (u *UsbGadget) keypressReport(key byte, press bool, autoRelease bool) (Keys
}
if autoRelease {
u.scheduleAutoRelease(key)
u.cancelAutoRelease()
}
} else {
if autoRelease {
u.cancelAutoRelease()
u.scheduleAutoRelease(key)
}
}