aboutsummaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorpbrook <pbrook@c046a42c-6fe2-441c-8c8c-71466251a162>2006-02-08 04:42:17 +0000
committerpbrook <pbrook@c046a42c-6fe2-441c-8c8c-71466251a162>2006-02-08 04:42:17 +0000
commitf94f5d717c14d18e0a4af2b157ca5a231d7bcc38 (patch)
tree913c87d3c17e1c57bc90149e9e1e7fb0efefbd7b /hw
parent3aa22b4b53d4a8f5ae6b073c7c267b6ec9aabf63 (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')
-rw-r--r--hw/pckbd.c1
-rw-r--r--hw/ps2.c34
2 files changed, 34 insertions, 1 deletions
diff --git a/hw/pckbd.c b/hw/pckbd.c
index 61f8a63a82..7d0f49b762 100644
--- a/hw/pckbd.c
+++ b/hw/pckbd.c
@@ -295,6 +295,7 @@ void kbd_write_data(void *opaque, uint32_t addr, uint32_t val)
break;
case KBD_CCMD_WRITE_MODE:
s->mode = val;
+ ps2_keyboard_set_translation(s->kbd, (s->mode & KBD_MODE_KCC) != 0);
/* ??? */
kbd_update_irq(s);
break;
diff --git a/hw/ps2.c b/hw/ps2.c
index e7c66f648f..be6b31ce7c 100644
--- a/hw/ps2.c
+++ b/hw/ps2.c
@@ -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;