No0ne / ps2x2pico

USB keyboard/mouse to PS/2 interface converter using a Raspberry Pi Pico
MIT License
196 stars 35 forks source link

update keyboard prev_rpt atomically #10

Closed updateing closed 11 months ago

updateing commented 1 year ago

Modifying previous HID report during parsing of current HID report may lead to spurious PS/2 key presses: some HID devices report 2nd key in a combo by shifting the report to the right and saving that key in the 1st report slot, essentially overwriting the 1st key in prev_rpt. The 1st key in the 2nd slot will be reported once more, as it is missing from prev_rpt.

For example, if I hold T then press P on such a keyboard, it may produce the following HID reports:

00 00 17 00 00 00 00 00 // press P
00 00 13 17 00 00 00 00 // press T

And here is how prev_rpt changes:

00 00 17 00 00 00 00 00 // after first report
00 00 13 00 00 00 00 00 // after parsing 0x13 in second report
// when parsing 0x17 in second report, we could not find 0x17 in prev_rpt so another make code for P is sent
00 00 13 17 00 00 00 00 // after parsing 0x17 in second report
No0ne commented 11 months ago

Thanks for that! Its already in the 1.0 release of ps2pico and will be here soon too.