Commit 35c4d671ebfa9509ba915188836070717088bd13
1 parent
3bee8bd0
Fix keyboard emulation for ARM versatile board:
- 0xab is actually a keyboard reply. It should not be escaped. - Because of translated value 0x41, translated to raw conversion is not a bijection. Instead of creating two translation tables, test for s->translate before writing this value. git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4209 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
11 additions
and
3 deletions
hw/ps2.c
@@ -44,6 +44,7 @@ | @@ -44,6 +44,7 @@ | ||
44 | 44 | ||
45 | /* Keyboard Replies */ | 45 | /* Keyboard Replies */ |
46 | #define KBD_REPLY_POR 0xAA /* Power on reset */ | 46 | #define KBD_REPLY_POR 0xAA /* Power on reset */ |
47 | +#define KBD_REPLY_ID 0xAB /* Keyboard ID */ | ||
47 | #define KBD_REPLY_ACK 0xFA /* Command ACK */ | 48 | #define KBD_REPLY_ACK 0xFA /* Command ACK */ |
48 | #define KBD_REPLY_RESEND 0xFE /* Command NACK, send the cmd again */ | 49 | #define KBD_REPLY_RESEND 0xFE /* Command NACK, send the cmd again */ |
49 | 50 | ||
@@ -133,7 +134,11 @@ void ps2_queue(void *opaque, int b) | @@ -133,7 +134,11 @@ void ps2_queue(void *opaque, int b) | ||
133 | s->update_irq(s->update_arg, 1); | 134 | s->update_irq(s->update_arg, 1); |
134 | } | 135 | } |
135 | 136 | ||
136 | -/* keycode is expressed in scancode set 2 */ | 137 | +/* |
138 | + keycode is expressed as follow: | ||
139 | + bit 7 - 0 key pressed, 1 = key released | ||
140 | + bits 6-0 - translated scancode set 2 | ||
141 | + */ | ||
137 | static void ps2_put_keycode(void *opaque, int keycode) | 142 | static void ps2_put_keycode(void *opaque, int keycode) |
138 | { | 143 | { |
139 | PS2KbdState *s = opaque; | 144 | PS2KbdState *s = opaque; |
@@ -199,8 +204,11 @@ void ps2_write_keyboard(void *opaque, int val) | @@ -199,8 +204,11 @@ void ps2_write_keyboard(void *opaque, int val) | ||
199 | case KBD_CMD_GET_ID: | 204 | case KBD_CMD_GET_ID: |
200 | ps2_queue(&s->common, KBD_REPLY_ACK); | 205 | ps2_queue(&s->common, KBD_REPLY_ACK); |
201 | /* We emulate a MF2 AT keyboard here */ | 206 | /* We emulate a MF2 AT keyboard here */ |
202 | - ps2_put_keycode(s, 0xab); | ||
203 | - ps2_put_keycode(s, 0x83); | 207 | + ps2_queue(&s->common, KBD_REPLY_ID); |
208 | + if (s->translate) | ||
209 | + ps2_queue(&s->common, 0x41); | ||
210 | + else | ||
211 | + ps2_queue(&s->common, 0x83); | ||
204 | break; | 212 | break; |
205 | case KBD_CMD_ECHO: | 213 | case KBD_CMD_ECHO: |
206 | ps2_queue(&s->common, KBD_CMD_ECHO); | 214 | ps2_queue(&s->common, KBD_CMD_ECHO); |