aboutsummaryrefslogtreecommitdiff
path: root/hw/ps2.c
diff options
context:
space:
mode:
authoraurel32 <aurel32@c046a42c-6fe2-441c-8c8c-71466251a162>2008-04-13 16:08:44 +0000
committeraurel32 <aurel32@c046a42c-6fe2-441c-8c8c-71466251a162>2008-04-13 16:08:44 +0000
commit35c4d671ebfa9509ba915188836070717088bd13 (patch)
tree0b1560f348cdd8f6aa6300f0b1eddbea1d8b1d4b /hw/ps2.c
parent3bee8bd013bf92f81f5826f75e72f48b6a017150 (diff)
downloadqemu-35c4d671ebfa9509ba915188836070717088bd13.zip
qemu-35c4d671ebfa9509ba915188836070717088bd13.tar.gz
qemu-35c4d671ebfa9509ba915188836070717088bd13.tar.bz2
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
Diffstat (limited to 'hw/ps2.c')
-rw-r--r--hw/ps2.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/hw/ps2.c b/hw/ps2.c
index 666e7b8..054b92f 100644
--- a/hw/ps2.c
+++ b/hw/ps2.c
@@ -44,6 +44,7 @@
/* Keyboard Replies */
#define KBD_REPLY_POR 0xAA /* Power on reset */
+#define KBD_REPLY_ID 0xAB /* Keyboard ID */
#define KBD_REPLY_ACK 0xFA /* Command ACK */
#define KBD_REPLY_RESEND 0xFE /* Command NACK, send the cmd again */
@@ -133,7 +134,11 @@ void ps2_queue(void *opaque, int b)
s->update_irq(s->update_arg, 1);
}
-/* keycode is expressed in scancode set 2 */
+/*
+ keycode is expressed as follow:
+ bit 7 - 0 key pressed, 1 = key released
+ bits 6-0 - translated scancode set 2
+ */
static void ps2_put_keycode(void *opaque, int keycode)
{
PS2KbdState *s = opaque;
@@ -199,8 +204,11 @@ void ps2_write_keyboard(void *opaque, int val)
case KBD_CMD_GET_ID:
ps2_queue(&s->common, KBD_REPLY_ACK);
/* We emulate a MF2 AT keyboard here */
- ps2_put_keycode(s, 0xab);
- ps2_put_keycode(s, 0x83);
+ ps2_queue(&s->common, KBD_REPLY_ID);
+ if (s->translate)
+ ps2_queue(&s->common, 0x41);
+ else
+ ps2_queue(&s->common, 0x83);
break;
case KBD_CMD_ECHO:
ps2_queue(&s->common, KBD_CMD_ECHO);