Headache is mostly gone, but I've got my first brand new super duper DSO/MSO so...
In the meantime, I've thought a little about the PS/2 keyboard protocol. And it's weirdnesses.
It's not as insane as USB, but it
was created by the same people that came up with EBCDIC (and FUD) so it's still nuts.
As one
guy put it...
This would be a very nice serial protocol if it wasn't for the computer, which occasionally wants to send information to the keyboard.
<describes pulling CLK low etc.>
This would still be a nice protocol if it wasn't for some special keys present on the standard PC keyboard, like Home, End, the arrows, etc
<goes on to explain the special extended modifier 0xE0 thing...>
To make [this] story a bit more complicated, two super-special keys exist, Print Screen and Pause, which cause a whole sequence of scancodes to be transmitted. For a keyboard interfacer, it's best to pretend these keys do not exist.
For anyone who wants to pretend that these keys
do exist...
... a sane person might think that the protocol was "designed" by several different humanoids, who didn't talk to each other. Two of these guys had only one key each to do. The result being a cock-eyed mess.
The extended scancode keys are basically that bunch in the middle: the INS/DEL, HOME/END, PgUp/PgDn. And the cursor (aka arrow) keys. These are all simply E0 versions of their counterparts on the keypad. Then keypad-Enter and keypad-/ are E0 versions of normal Enter and '/'. Keypad-<+- and *> have normal codes (*shrug*), while R-ALT and R-CTRL were an afterthought. So they're E0 of the left version.
This is all clear. The two weird keys seem crazy though.
However, if we imagine (in a process a little bit like unifying the laws of electricity and magnetism and then even the weak nuclear force) that there's a special alternative shift key above the keypad, said shift key generating scan code 0xE012 (instead of 0x12 for the normal (left) SHIFT key) then pressing/releasing PrtScr is equivalent to
press WEIRDSHIFT, press PRINT, release PRINT, release WEIRDSHIFT.
The PRINT key doesn't exist. It generates 0xE07C. Scancode 0x7C does exist – it's keypad-*.
The Pause/Brk guy thought of something else...
He didn't know about the secret WEIRDSHIFT key. Actually, maybe he
did know about WEIRDSHIFT and thought it was stupid – so he generated an entirely new set of extended scancodes prefaced with E1 instead of E0 (needed for
his SUPERWEIRD-CTRL key). So, instead of WEIRDSHIFT extendedNUMLOCK we have
Press SUPERWEIRD-CTRL, press NUMLOCK, release SUPERWEIRD-CTRL, release NUMLOCK.
Why release the super-extended L-CTRL before the NUMLOCK? I don't know. In any case, he thought that users wouldn't be able to release the key on their own, and so he coded that weird release sequence into the key-press sequence.
Maybe Pause/Brk used to be on NUMLOCK (the way CURSOR-LEFT is on keypad-4) and PrtScr used to be on keypad-*. Maybe they thought that having a special extended L-SHIFT key only for PrtScr and a special super-extended L-CTRL key only for Pause/Brk was a bit stupid and so they rationalised them, by replacing them with two different keys...
Anyway, as you see, it all makes perfect sense after all.