Keyboard scancode sets?
Posted: Fri Jun 13, 2008 4:53 pm
Hi all. I've been following the tutorials and wiki on this site for a little while (it's a truly *FANTASTIC* resource, by the way!). I've put a kernel structure together and got as far as getting keyboard interrupts working and being sent to the ISR (yeay! ), and I've set up a few other experimental kernel routines on hotkeys to make them easy to test. It also prints out the scancode of each key and whether it was a press or release to the screen.
Then I set about mapping the scancodes to key names -- so it can also tell me a textual name of each key. I mapped every key for the four keyboards I have here and made separate keymaps for US and UK keyboards. It seems to work really well.
But then I did a bit of web searching to see if the special keys on some keyboards (e.g., Sleep, Wake up, Play/Pause, Mute, Vol up/down, Internet, etc.) had standard codes, and I came across *this* page: http://www.win.tue.nl/~aeb/linux/kbd/scancodes-10.html. If I've understood this right, there are three scancode sets, and sets 1 and 3 are sometimes buggy.
To my horror, my keymaps seem to be set 1. But they also seem to be the same as the "X (Set 2)" column in that table, and I don't know what that is. Now I'm just really confused. Can anyone tell me, for best compatibility should I switch the keyboard to another set and redo the maps? Is there a set which is always supported by keyboards or do I need to write code to handle all of them?
Is it also a good idea to set up an enum of virtual key constants so I can refer to them in the rest of the OS instead of hardware-locked scancodes? I reckon that's what I should do next, but I'd like to hear advice from the more experienced first.
(Honestly, I never realized keyboards were so complicated!)
Then I set about mapping the scancodes to key names -- so it can also tell me a textual name of each key. I mapped every key for the four keyboards I have here and made separate keymaps for US and UK keyboards. It seems to work really well.
But then I did a bit of web searching to see if the special keys on some keyboards (e.g., Sleep, Wake up, Play/Pause, Mute, Vol up/down, Internet, etc.) had standard codes, and I came across *this* page: http://www.win.tue.nl/~aeb/linux/kbd/scancodes-10.html. If I've understood this right, there are three scancode sets, and sets 1 and 3 are sometimes buggy.
To my horror, my keymaps seem to be set 1. But they also seem to be the same as the "X (Set 2)" column in that table, and I don't know what that is. Now I'm just really confused. Can anyone tell me, for best compatibility should I switch the keyboard to another set and redo the maps? Is there a set which is always supported by keyboards or do I need to write code to handle all of them?
Is it also a good idea to set up an enum of virtual key constants so I can refer to them in the rest of the OS instead of hardware-locked scancodes? I reckon that's what I should do next, but I'd like to hear advice from the more experienced first.
(Honestly, I never realized keyboards were so complicated!)