Getting raw data from the keyboard is trivial (and I note that the recently purchased second hand Dell keyboard that I'm playing with both works at 3.3v and 5v, and takes so little current that it doesn't show on my power supply) but converting the output into something useful is, um, a non-trivial activity...
It probably doesn't help that I don't want to limit myself to the normal typing block - I also want to implement ctrl, alt, and ctrl-alt combinations for letters and ctrl and alt for numbers (though I'm not sure I'll ever use the latter) and definitely want the function keys and caps lock. Oh, and a pound sign '£', what with being English and all. Which isn't an ascii codepoint anyway, but lives on shift-3 on a UK keyboard.
So I've had to redefine (cough, 'extend') the ascii set to use eight bits:
Code: Select all
// control codes including cr, lf, tab etc
#define K_NULL 0x00
#define K_CTL_A 0x01
<...>
#define K_CTL_Z 0x1a
#define K_ESC 0x1b
#define K_POUND 0x1f // £ sign
// standard ascii
#define K_SPACE 0x20
<...>
#define K_DEL 0x7f
// alt letters
// 0x80
#define K_ALT_A 0x81
<...>
#define K_ALT_Z 0x9a
// control numbers
#define K_CTL_0 0xa0
<...>
#define K_CTL_9 0xa9
// alt numbers
#define K_ALT_0 0xb0
<...>
#define K_ALT_9 0xb9
// ctrl-alt letters
// 0xc0
#define K_CTRALT_A 0xc1
<...>
#define K_CTRALT_Z 0xda
// cursor keys
#define K_LEFT 0xe0
#define K_RIGHT 0xe1
#define K_UPARROW 0xe2
#define K_DOWN 0xe3
#define K_PAGEUP 0xe4
#define K_PAGEDOWN 0xe5
#define K_HOME 0xe6
#define K_END 0xe7
#define K_INSERT 0xe8
#define K_DELETE 0xe9
// function keys
// 0xf0
#define K_F1 0xf1
<...>
#define K_F12 0xfc
Neil