adb: change handler only when recognized
PATCH 1/1 adb: change handler only when recognized
ADB devices must take new handler into account only when they recognize it. This lets operating systems probe for valid/invalid handles, to know device capabilities.
Add a FIXME in keyboard handler, which should use a different translation table depending of the selected handler.
Signed-off-by Hervé Poussineau <[email protected]>
--- hw/input/adb.c | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-)
hw/input/adb.c +23 -3
@@ -396,9 +396,15 @@ static int adb_kbd_request(ADBDevice *d, uint8_t *obuf, d->devaddr = buf[1 ] &0xf ;break ;default : -/* XXX: check this */ d->devaddr = buf[1 ] &0xf ; - d->handler = buf[2 ]; +/* we support handlers: +* 1: Apple Standard Keyboard +* 2: Apple Extended Keyboard (LShift = RShift) +* 3: Apple Extended Keyboard (LShift != RShift) +*/ +if (buf[2 ] ==1 || buf[2 ] ==2 || buf[2 ] ==3 ) { + d->handler = buf[2 ]; + }break ; } }
@@ -437,6 +443,7 @@ static void adb_keyboard_event(DeviceState *dev, QemuConsole *src,if (qcode >=ARRAY_SIZE (qcode_to_adb_keycode)) {return ; } +/* FIXME: take handler into account when translating qcode */ keycode = qcode_to_adb_keycode[qcode];if (keycode ==NO_KEY ) {/* We don't want to send this to the guest */ ADB_DPRINTF ("Ignoring NO_KEY\n" );
@@ -631,8 +638,21 @@ static int adb_mouse_request(ADBDevice *d, uint8_t *obuf, d->devaddr = buf[1 ] &0xf ;break ;default : -/* XXX: check this */ d->devaddr = buf[1 ] &0xf ; +/* we support handlers: +* 0x01: Classic Apple Mouse Protocol / 100 cpi operations +* 0x02: Classic Apple Mouse Protocol / 200 cpi operations +* we don't support handlers (at least): +* 0x03: Mouse systems A3 trackball +* 0x04: Extended Apple Mouse Protocol +* 0x2f: Microspeed mouse +* 0x42: Macally +* 0x5f: Microspeed mouse +* 0x66: Microspeed mouse +*/ +if (buf[2 ] ==1 || buf[2 ] ==2 ) { + d->handler = buf[2 ]; + }break ; } }
Signature · 1 line
2.1.4
David Gibson
AppliedQuoted 7 lines · Hervé Poussineau
ADB devices must take new handler into account only when they recognize it. This lets operating systems probe for valid/invalid handles, to know device capabilities.
Add a FIXME in keyboard handler, which should use a different translation table depending of the selected handler.
Signed-off-by Hervé Poussineau <[email protected]>
Applied to ppc-for-2.8, thanks.
Quoted 57 lines
--- hw/input/adb.c | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-)hw/input/adb.c +23
-3@@ -396,9 +396,15 @@ static int adb_kbd_request(ADBDevice *d, uint8_t *obuf, d->devaddr = buf[1 ] &0xf ;break ;default : -/* XXX: check this */ d->devaddr = buf[1 ] &0xf ; - d->handler = buf[2 ]; +/* we support handlers: +* 1: Apple Standard Keyboard +* 2: Apple Extended Keyboard (LShift = RShift) +* 3: Apple Extended Keyboard (LShift != RShift) +*/ +if (buf[2 ] ==1 || buf[2 ] ==2 || buf[2 ] ==3 ) { + d->handler = buf[2 ]; + }break ; } }@@ -437,6 +443,7 @@ static void adb_keyboard_event(DeviceState *dev, QemuConsole *src,if (qcode >=ARRAY_SIZE (qcode_to_adb_keycode)) {return ; } +/* FIXME: take handler into account when translating qcode */ keycode = qcode_to_adb_keycode[qcode];if (keycode ==NO_KEY ) {/* We don't want to send this to the guest */ ADB_DPRINTF ("Ignoring NO_KEY\n" );@@ -631,8 +638,21 @@ static int adb_mouse_request(ADBDevice *d, uint8_t *obuf, d->devaddr = buf[1 ] &0xf ;break ;default : -/* XXX: check this */ d->devaddr = buf[1 ] &0xf ; +/* we support handlers: +* 0x01: Classic Apple Mouse Protocol / 100 cpi operations +* 0x02: Classic Apple Mouse Protocol / 200 cpi operations +* we don't support handlers (at least): +* 0x03: Mouse systems A3 trackball +* 0x04: Extended Apple Mouse Protocol +* 0x2f: Microspeed mouse +* 0x42: Macally +* 0x5f: Microspeed mouse +* 0x66: Microspeed mouse +*/ +if (buf[2 ] ==1 || buf[2 ] ==2 ) { + d->handler = buf[2 ]; + }break ; } }
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson