rust-embedded-community / pc-keyboard

PS/2 Keyboard Decoder in Rust
Apache License 2.0
99 stars 28 forks source link

Num Lock processing is wrong in Scan Code Set 2 #26

Closed thejpster closed 1 year ago

thejpster commented 1 year ago

We thought PrntScr produced a make code of E0 12 E0 7C in Scan Code Set 2. Actually, it's more complicated.

The keys Insert, Delete, Left Arrow, Home, End, Up Arrow, Down Arrow, Page Up, Page Down and Right Arrow should do different things on your computer depending on whether Num Lock is enabled and the state of the shift keys. Blame the IBM PC/AT trying to be compatble with the IBM PC/XT. I think?

If Num Lock is ON and both shift keys are released, the make code is prefixed with E0 12 and the break code is prefixed with E0 F0 12. If you press shift, you don't get the E0 12 prefix. This is because if you do a Shift Insert with Num Lock on

So we should treat E0 12 as an extra modifier key called Unshift and track its state, but probably not allow its state to change anything about the key decoding.

Observations

(the above is regardless of numlock state)

References

http://www.quadibloc.com/comp/scan.htm - refers to unshift "Keyboard Scan Code Specification - Microsoft" - See Note 2 for Scan Code Set 2 and Note 4

thejpster commented 1 year ago

Closed by #27