diff options
author | Gerd Hoffmann <kraxel@redhat.com> | 2010-02-26 17:17:36 +0100 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2010-03-09 08:47:20 -0600 |
commit | 03a23a85f4c2588778d7d58ae49e5521d79d1b06 (patch) | |
tree | 385546624ed9fc33795991574dff6c1791f61b19 /input.c | |
parent | 32bb404a6a4d726dfd691f75704f08257ce65ffe (diff) | |
download | qemu-03a23a85f4c2588778d7d58ae49e5521d79d1b06.tar.gz qemu-03a23a85f4c2588778d7d58ae49e5521d79d1b06.tar.bz2 qemu-03a23a85f4c2588778d7d58ae49e5521d79d1b06.zip |
kbd leds: infrastructure
Adds infrastructure for keyboard led status tracking to qemu.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'input.c')
-rw-r--r-- | input.c | 31 |
1 files changed, 31 insertions, 0 deletions
@@ -33,6 +33,7 @@ static QEMUPutKBDEvent *qemu_put_kbd_event; static void *qemu_put_kbd_event_opaque; static QEMUPutMouseEntry *qemu_put_mouse_event_head; static QEMUPutMouseEntry *qemu_put_mouse_event_current; +static QTAILQ_HEAD(, QEMUPutLEDEntry) led_handlers = QTAILQ_HEAD_INITIALIZER(led_handlers); void qemu_add_kbd_event_handler(QEMUPutKBDEvent *func, void *opaque) { @@ -102,6 +103,27 @@ void qemu_remove_mouse_event_handler(QEMUPutMouseEntry *entry) qemu_free(entry); } +QEMUPutLEDEntry *qemu_add_led_event_handler(QEMUPutLEDEvent *func, + void *opaque) +{ + QEMUPutLEDEntry *s; + + s = qemu_mallocz(sizeof(QEMUPutLEDEntry)); + + s->put_led = func; + s->opaque = opaque; + QTAILQ_INSERT_TAIL(&led_handlers, s, next); + return s; +} + +void qemu_remove_led_event_handler(QEMUPutLEDEntry *entry) +{ + if (entry == NULL) + return; + QTAILQ_REMOVE(&led_handlers, entry, next); + qemu_free(entry); +} + void kbd_put_keycode(int keycode) { if (qemu_put_kbd_event) { @@ -109,6 +131,15 @@ void kbd_put_keycode(int keycode) } } +void kbd_put_ledstate(int ledstate) +{ + QEMUPutLEDEntry *cursor; + + QTAILQ_FOREACH(cursor, &led_handlers, next) { + cursor->put_led(cursor->opaque, ledstate); + } +} + void kbd_mouse_event(int dx, int dy, int dz, int buttons_state) { QEMUPutMouseEvent *mouse_event; |