Commit 63066f4f13b024ac0a45486f06dafbbf944fe4c6

Authored by bellard
1 parent caf9a12e

hid event handling


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@880 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 3 changed files with 93 additions and 11 deletions
hw/pckbd.c
... ... @@ -190,9 +190,9 @@ static void kbd_queue(KBDState *s, int b, int aux)
190 190 kbd_update_irq(s);
191 191 }
192 192  
193   -void kbd_put_keycode(int keycode)
  193 +static void pc_kbd_put_keycode(void *opaque, int keycode)
194 194 {
195   - KBDState *s = &kbd_state;
  195 + KBDState *s = opaque;
196 196 kbd_queue(s, keycode, 0);
197 197 }
198 198  
... ... @@ -434,9 +434,10 @@ static void kbd_mouse_send_packet(KBDState *s)
434 434 s->mouse_dz -= dz1;
435 435 }
436 436  
437   -void kbd_mouse_event(int dx, int dy, int dz, int buttons_state)
  437 +static void pc_kbd_mouse_event(void *opaque,
  438 + int dx, int dy, int dz, int buttons_state)
438 439 {
439   - KBDState *s = &kbd_state;
  440 + KBDState *s = opaque;
440 441  
441 442 /* check if deltas are recorded when disabled */
442 443 if (!(s->mouse_status & MOUSE_STATUS_ENABLED))
... ... @@ -652,4 +653,7 @@ void kbd_init(void)
652 653 register_ioport_write(0x60, 1, 1, kbd_write_data, s);
653 654 register_ioport_read(0x64, 1, 1, kbd_read_status, s);
654 655 register_ioport_write(0x64, 1, 1, kbd_write_command, s);
  656 +
  657 + qemu_add_kbd_event_handler(pc_kbd_put_keycode, s);
  658 + qemu_add_mouse_event_handler(pc_kbd_mouse_event, s);
655 659 }
... ...
... ... @@ -385,6 +385,41 @@ void hw_error(const char *fmt, ...)
385 385 }
386 386  
387 387 /***********************************************************/
  388 +/* keyboard/mouse */
  389 +
  390 +static QEMUPutKBDEvent *qemu_put_kbd_event;
  391 +static void *qemu_put_kbd_event_opaque;
  392 +static QEMUPutMouseEvent *qemu_put_mouse_event;
  393 +static void *qemu_put_mouse_event_opaque;
  394 +
  395 +void qemu_add_kbd_event_handler(QEMUPutKBDEvent *func, void *opaque)
  396 +{
  397 + qemu_put_kbd_event_opaque = opaque;
  398 + qemu_put_kbd_event = func;
  399 +}
  400 +
  401 +void qemu_add_mouse_event_handler(QEMUPutMouseEvent *func, void *opaque)
  402 +{
  403 + qemu_put_mouse_event_opaque = opaque;
  404 + qemu_put_mouse_event = func;
  405 +}
  406 +
  407 +void kbd_put_keycode(int keycode)
  408 +{
  409 + if (qemu_put_kbd_event) {
  410 + qemu_put_kbd_event(qemu_put_kbd_event_opaque, keycode);
  411 + }
  412 +}
  413 +
  414 +void kbd_mouse_event(int dx, int dy, int dz, int buttons_state)
  415 +{
  416 + if (qemu_put_mouse_event) {
  417 + qemu_put_mouse_event(qemu_put_mouse_event_opaque,
  418 + dx, dy, dz, buttons_state);
  419 + }
  420 +}
  421 +
  422 +/***********************************************************/
388 423 /* timers */
389 424  
390 425 #if defined(__powerpc__)
... ...
... ... @@ -179,6 +179,21 @@ extern int rtc_utc;
179 179 #define BIOS_SIZE 0
180 180 #endif
181 181  
  182 +/* keyboard/mouse support */
  183 +
  184 +#define MOUSE_EVENT_LBUTTON 0x01
  185 +#define MOUSE_EVENT_RBUTTON 0x02
  186 +#define MOUSE_EVENT_MBUTTON 0x04
  187 +
  188 +typedef void QEMUPutKBDEvent(void *opaque, int keycode);
  189 +typedef void QEMUPutMouseEvent(void *opaque, int dx, int dy, int dz, int buttons_state);
  190 +
  191 +void qemu_add_kbd_event_handler(QEMUPutKBDEvent *func, void *opaque);
  192 +void qemu_add_mouse_event_handler(QEMUPutMouseEvent *func, void *opaque);
  193 +
  194 +void kbd_put_keycode(int keycode);
  195 +void kbd_mouse_event(int dx, int dy, int dz, int buttons_state);
  196 +
182 197 /* async I/O support */
183 198  
184 199 typedef void IOReadHandler(void *opaque, const uint8_t *buf, int size);
... ... @@ -530,13 +545,6 @@ void pci_ne2000_init(NetDriverState *nd);
530 545  
531 546 /* pckbd.c */
532 547  
533   -void kbd_put_keycode(int keycode);
534   -
535   -#define MOUSE_EVENT_LBUTTON 0x01
536   -#define MOUSE_EVENT_RBUTTON 0x02
537   -#define MOUSE_EVENT_MBUTTON 0x04
538   -void kbd_mouse_event(int dx, int dy, int dz, int buttons_state);
539   -
540 548 void kbd_init(void);
541 549  
542 550 /* mc146818rtc.c */
... ... @@ -627,6 +635,41 @@ int PPC_NVRAM_set_params (m48t59_t *nvram, uint16_t NVRAM_size,
627 635 uint32_t initrd_image, uint32_t initrd_size,
628 636 uint32_t NVRAM_image);
629 637  
  638 +/* adb.c */
  639 +
  640 +#define MAX_ADB_DEVICES 16
  641 +
  642 +typedef struct ADBDevice ADBDevice;
  643 +
  644 +typedef void ADBDeviceReceivePacket(ADBDevice *d, const uint8_t *buf, int len);
  645 +
  646 +struct ADBDevice {
  647 + struct ADBBusState *bus;
  648 + int devaddr;
  649 + int handler;
  650 + ADBDeviceReceivePacket *receive_packet;
  651 + void *opaque;
  652 +};
  653 +
  654 +typedef struct ADBBusState {
  655 + ADBDevice devices[MAX_ADB_DEVICES];
  656 + int nb_devices;
  657 +} ADBBusState;
  658 +
  659 +void adb_receive_packet(ADBBusState *s, const uint8_t *buf, int len);
  660 +void adb_send_packet(ADBBusState *s, const uint8_t *buf, int len);
  661 +
  662 +ADBDevice *adb_register_device(ADBBusState *s, int devaddr,
  663 + ADBDeviceReceivePacket *receive_packet,
  664 + void *opaque);
  665 +void adb_kbd_init(ADBBusState *bus);
  666 +void adb_mouse_init(ADBBusState *bus);
  667 +
  668 +/* cuda.c */
  669 +
  670 +extern ADBBusState adb_bus;
  671 +int cuda_init(void);
  672 +
630 673 /* monitor.c */
631 674 void monitor_init(void);
632 675 void term_printf(const char *fmt, ...) __attribute__ ((__format__ (__printf__, 1, 2)));
... ...