aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--hw/pckbd.c12
-rw-r--r--vl.c35
-rw-r--r--vl.h57
3 files changed, 93 insertions, 11 deletions
diff --git a/hw/pckbd.c b/hw/pckbd.c
index ee83e0f770..8b809bd820 100644
--- a/hw/pckbd.c
+++ b/hw/pckbd.c
@@ -190,9 +190,9 @@ static void kbd_queue(KBDState *s, int b, int aux)
kbd_update_irq(s);
}
-void kbd_put_keycode(int keycode)
+static void pc_kbd_put_keycode(void *opaque, int keycode)
{
- KBDState *s = &kbd_state;
+ KBDState *s = opaque;
kbd_queue(s, keycode, 0);
}
@@ -434,9 +434,10 @@ static void kbd_mouse_send_packet(KBDState *s)
s->mouse_dz -= dz1;
}
-void kbd_mouse_event(int dx, int dy, int dz, int buttons_state)
+static void pc_kbd_mouse_event(void *opaque,
+ int dx, int dy, int dz, int buttons_state)
{
- KBDState *s = &kbd_state;
+ KBDState *s = opaque;
/* check if deltas are recorded when disabled */
if (!(s->mouse_status & MOUSE_STATUS_ENABLED))
@@ -652,4 +653,7 @@ void kbd_init(void)
register_ioport_write(0x60, 1, 1, kbd_write_data, s);
register_ioport_read(0x64, 1, 1, kbd_read_status, s);
register_ioport_write(0x64, 1, 1, kbd_write_command, s);
+
+ qemu_add_kbd_event_handler(pc_kbd_put_keycode, s);
+ qemu_add_mouse_event_handler(pc_kbd_mouse_event, s);
}
diff --git a/vl.c b/vl.c
index 52f300f64b..b424ed11ef 100644
--- a/vl.c
+++ b/vl.c
@@ -385,6 +385,41 @@ void hw_error(const char *fmt, ...)
}
/***********************************************************/
+/* keyboard/mouse */
+
+static QEMUPutKBDEvent *qemu_put_kbd_event;
+static void *qemu_put_kbd_event_opaque;
+static QEMUPutMouseEvent *qemu_put_mouse_event;
+static void *qemu_put_mouse_event_opaque;
+
+void qemu_add_kbd_event_handler(QEMUPutKBDEvent *func, void *opaque)
+{
+ qemu_put_kbd_event_opaque = opaque;
+ qemu_put_kbd_event = func;
+}
+
+void qemu_add_mouse_event_handler(QEMUPutMouseEvent *func, void *opaque)
+{
+ qemu_put_mouse_event_opaque = opaque;
+ qemu_put_mouse_event = func;
+}
+
+void kbd_put_keycode(int keycode)
+{
+ if (qemu_put_kbd_event) {
+ qemu_put_kbd_event(qemu_put_kbd_event_opaque, keycode);
+ }
+}
+
+void kbd_mouse_event(int dx, int dy, int dz, int buttons_state)
+{
+ if (qemu_put_mouse_event) {
+ qemu_put_mouse_event(qemu_put_mouse_event_opaque,
+ dx, dy, dz, buttons_state);
+ }
+}
+
+/***********************************************************/
/* timers */
#if defined(__powerpc__)
diff --git a/vl.h b/vl.h
index e8f8a30a75..9dbb5b41a3 100644
--- a/vl.h
+++ b/vl.h
@@ -179,6 +179,21 @@ extern int rtc_utc;
#define BIOS_SIZE 0
#endif
+/* keyboard/mouse support */
+
+#define MOUSE_EVENT_LBUTTON 0x01
+#define MOUSE_EVENT_RBUTTON 0x02
+#define MOUSE_EVENT_MBUTTON 0x04
+
+typedef void QEMUPutKBDEvent(void *opaque, int keycode);
+typedef void QEMUPutMouseEvent(void *opaque, int dx, int dy, int dz, int buttons_state);
+
+void qemu_add_kbd_event_handler(QEMUPutKBDEvent *func, void *opaque);
+void qemu_add_mouse_event_handler(QEMUPutMouseEvent *func, void *opaque);
+
+void kbd_put_keycode(int keycode);
+void kbd_mouse_event(int dx, int dy, int dz, int buttons_state);
+
/* async I/O support */
typedef void IOReadHandler(void *opaque, const uint8_t *buf, int size);
@@ -530,13 +545,6 @@ void pci_ne2000_init(NetDriverState *nd);
/* pckbd.c */
-void kbd_put_keycode(int keycode);
-
-#define MOUSE_EVENT_LBUTTON 0x01
-#define MOUSE_EVENT_RBUTTON 0x02
-#define MOUSE_EVENT_MBUTTON 0x04
-void kbd_mouse_event(int dx, int dy, int dz, int buttons_state);
-
void kbd_init(void);
/* mc146818rtc.c */
@@ -627,6 +635,41 @@ int PPC_NVRAM_set_params (m48t59_t *nvram, uint16_t NVRAM_size,
uint32_t initrd_image, uint32_t initrd_size,
uint32_t NVRAM_image);
+/* adb.c */
+
+#define MAX_ADB_DEVICES 16
+
+typedef struct ADBDevice ADBDevice;
+
+typedef void ADBDeviceReceivePacket(ADBDevice *d, const uint8_t *buf, int len);
+
+struct ADBDevice {
+ struct ADBBusState *bus;
+ int devaddr;
+ int handler;
+ ADBDeviceReceivePacket *receive_packet;
+ void *opaque;
+};
+
+typedef struct ADBBusState {
+ ADBDevice devices[MAX_ADB_DEVICES];
+ int nb_devices;
+} ADBBusState;
+
+void adb_receive_packet(ADBBusState *s, const uint8_t *buf, int len);
+void adb_send_packet(ADBBusState *s, const uint8_t *buf, int len);
+
+ADBDevice *adb_register_device(ADBBusState *s, int devaddr,
+ ADBDeviceReceivePacket *receive_packet,
+ void *opaque);
+void adb_kbd_init(ADBBusState *bus);
+void adb_mouse_init(ADBBusState *bus);
+
+/* cuda.c */
+
+extern ADBBusState adb_bus;
+int cuda_init(void);
+
/* monitor.c */
void monitor_init(void);
void term_printf(const char *fmt, ...) __attribute__ ((__format__ (__printf__, 1, 2)));