diff options
author | pbrook <pbrook@c046a42c-6fe2-441c-8c8c-71466251a162> | 2006-02-08 04:42:17 +0000 |
---|---|---|
committer | pbrook <pbrook@c046a42c-6fe2-441c-8c8c-71466251a162> | 2006-02-08 04:42:17 +0000 |
commit | f94f5d717c14d18e0a4af2b157ca5a231d7bcc38 (patch) | |
tree | 913c87d3c17e1c57bc90149e9e1e7fb0efefbd7b /hw/ps2.c | |
parent | 3aa22b4b53d4a8f5ae6b073c7c267b6ec9aabf63 (diff) |
Add support for raw AT keyboard scancodes.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1749 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'hw/ps2.c')
-rw-r--r-- | hw/ps2.c | 34 |
1 files changed, 33 insertions, 1 deletions
@@ -83,6 +83,10 @@ typedef struct { typedef struct { PS2State common; int scan_enabled; + /* Qemu uses translated PC scancodes internally. To avoid multiple + conversions we do the translation (if any) in the PS/2 emulation + not the keyboard controller. */ + int translate; } PS2KbdState; typedef struct { @@ -99,6 +103,18 @@ typedef struct { uint8_t mouse_buttons; } PS2MouseState; +/* Table to convert from PC scancodes to raw scancodes. */ +static const unsigned char ps2_raw_keycode[128] = { + 0,118, 22, 30, 38, 37, 46, 54, 61, 62, 70, 69, 78, 85,102, 13, + 21, 29, 36, 45, 44, 53, 60, 67, 68, 77, 84, 91, 90, 20, 28, 27, + 35, 43, 52, 51, 59, 66, 75, 76, 82, 14, 18, 93, 26, 34, 33, 42, + 50, 49, 58, 65, 73, 74, 89,124, 17, 41, 88, 5, 6, 4, 12, 3, + 11, 2, 10, 1, 9,119,126,108,117,125,123,107,115,116,121,105, + 114,122,112,113,127, 96, 97,120, 7, 15, 23, 31, 39, 47, 55, 63, + 71, 79, 86, 94, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 87,111, + 19, 25, 57, 81, 83, 92, 95, 98, 99,100,101,103,104,106,109,110 +}; + void ps2_queue(void *opaque, int b) { PS2State *s = (PS2State *)opaque; @@ -115,7 +131,13 @@ void ps2_queue(void *opaque, int b) static void ps2_put_keycode(void *opaque, int keycode) { - PS2MouseState *s = opaque; + PS2KbdState *s = opaque; + if (!s->translate && keycode < 0xe0) + { + if (keycode & 0x80) + ps2_queue(&s->common, 0xf0); + keycode = ps2_raw_keycode[keycode & 0x7f]; + } ps2_queue(&s->common, keycode); } @@ -214,6 +236,16 @@ void ps2_write_keyboard(void *opaque, int val) } } +/* Set the scancode translation mode. + 0 = raw scancodes. + 1 = translated scancodes (used by qemu internally). */ + +void ps2_keyboard_set_translation(void *opaque, int mode) +{ + PS2KbdState *s = (PS2KbdState *)opaque; + s->translate = mode; +} + static void ps2_mouse_send_packet(PS2MouseState *s) { unsigned int b; |