This should decrease keypress latency as much as possible, as well as catch shorter key presses for more accuracy (theoretically). Tested on Linux and seems to work pretty well. I tried to keep the code as simple and readable as possible (couldn't help myself with trying out const generics though, which are a little "type noisy" still, so... my b).
Changes
[x] Use USB interrupt handling to report keyboard state to host
[x] Add an "eager"-type key debouncer to suppress unintended re-presses
[x] Decrease poll rate from 8ms to 1ms
[x] Refactor the initialization code to scan keys first, so that the firmware can immediately respond to an interrupt after the USB handshake happens
[x] Refactor the key scanning logic and conversion to KeyboardReport to its own module, so that the main.rs initialization and loop are a bit easier to read.
This should decrease keypress latency as much as possible, as well as catch shorter key presses for more accuracy (theoretically). Tested on Linux and seems to work pretty well. I tried to keep the code as simple and readable as possible (couldn't help myself with trying out const generics though, which are a little "type noisy" still, so... my b).
Changes
KeyboardReport
to its own module, so that themain.rs
initialization and loop are a bit easier to read.