diff options
| author | Peter Maydell <peter.maydell@linaro.org> | 2014-05-28 10:33:05 +0100 |
|---|---|---|
| committer | Peter Maydell <peter.maydell@linaro.org> | 2014-05-28 10:33:05 +0100 |
| commit | 4aa23452e366790e6c50dea73c8bc5eea44e2f38 (patch) | |
| tree | 7da474230a9909a6f79d3d05f4cdce3532e41051 /ui/input.c | |
| parent | 9474ab1487cc70140099c8500ae4a1947ca966c1 (diff) | |
| parent | 8977bd111f62035b675d41c432eb8b6bf6b86b0f (diff) | |
| download | focaccia-qemu-4aa23452e366790e6c50dea73c8bc5eea44e2f38.tar.gz focaccia-qemu-4aa23452e366790e6c50dea73c8bc5eea44e2f38.zip | |
Merge remote-tracking branch 'remotes/kraxel/tags/pull-input-9' into staging
input: add event routing and multiseat support. input: misc bugfixes and minor improvements. # gpg: Signature made Mon 26 May 2014 07:44:29 BST using RSA key ID D3E87138 # gpg: Can't check signature: public key not found * remotes/kraxel/tags/pull-input-9: docs: add multiseat.txt usb: add input routing support for tablet and keyboard sdl: pass key event source to input layer input: bind devices and input routing input: switch hid mouse and tablet to the new input layer api. input: switch hid keyboard to new input layer api. input: keymap: add meta keys input: add name to input_event_key_number input: add qemu_input_key_number_to_qcode input (curses): mask keycodes to remove modifier bits Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'ui/input.c')
| -rw-r--r-- | ui/input.c | 49 |
1 files changed, 44 insertions, 5 deletions
diff --git a/ui/input.c b/ui/input.c index fc91fba83c..14c9434f5e 100644 --- a/ui/input.c +++ b/ui/input.c @@ -1,3 +1,4 @@ +#include "hw/qdev.h" #include "sysemu/sysemu.h" #include "qapi-types.h" #include "qmp-commands.h" @@ -10,6 +11,7 @@ struct QemuInputHandlerState { QemuInputHandler *handler; int id; int events; + QemuConsole *con; QTAILQ_ENTRY(QemuInputHandlerState) node; }; static QTAILQ_HEAD(, QemuInputHandlerState) handlers = @@ -53,12 +55,46 @@ void qemu_input_handler_unregister(QemuInputHandlerState *s) qemu_input_check_mode_change(); } +void qemu_input_handler_bind(QemuInputHandlerState *s, + const char *device_id, int head, + Error **errp) +{ + DeviceState *dev; + QemuConsole *con; + + dev = qdev_find_recursive(sysbus_get_default(), device_id); + if (dev == NULL) { + error_set(errp, QERR_DEVICE_NOT_FOUND, device_id); + return; + } + + con = qemu_console_lookup_by_device(dev, head); + if (con == NULL) { + error_setg(errp, "Device %s is not bound to a QemuConsole", device_id); + return; + } + + s->con = con; +} + static QemuInputHandlerState* -qemu_input_find_handler(uint32_t mask) +qemu_input_find_handler(uint32_t mask, QemuConsole *con) { QemuInputHandlerState *s; QTAILQ_FOREACH(s, &handlers, node) { + if (s->con == NULL || s->con != con) { + continue; + } + if (mask & s->handler->mask) { + return s; + } + } + + QTAILQ_FOREACH(s, &handlers, node) { + if (s->con != NULL) { + continue; + } if (mask & s->handler->mask) { return s; } @@ -94,7 +130,7 @@ static void qemu_input_transform_abs_rotate(InputEvent *evt) static void qemu_input_event_trace(QemuConsole *src, InputEvent *evt) { const char *name; - int idx = -1; + int qcode, idx = -1; if (src) { idx = qemu_console_get_index(src); @@ -103,8 +139,10 @@ static void qemu_input_event_trace(QemuConsole *src, InputEvent *evt) case INPUT_EVENT_KIND_KEY: switch (evt->key->key->kind) { case KEY_VALUE_KIND_NUMBER: + qcode = qemu_input_key_number_to_qcode(evt->key->key->number); + name = QKeyCode_lookup[qcode]; trace_input_event_key_number(idx, evt->key->key->number, - evt->key->down); + name, evt->key->down); break; case KEY_VALUE_KIND_QCODE: name = QKeyCode_lookup[evt->key->key->qcode]; @@ -149,7 +187,7 @@ void qemu_input_event_send(QemuConsole *src, InputEvent *evt) } /* send event */ - s = qemu_input_find_handler(1 << evt->kind); + s = qemu_input_find_handler(1 << evt->kind, src); if (!s) { return; } @@ -250,7 +288,8 @@ bool qemu_input_is_absolute(void) { QemuInputHandlerState *s; - s = qemu_input_find_handler(INPUT_EVENT_MASK_REL | INPUT_EVENT_MASK_ABS); + s = qemu_input_find_handler(INPUT_EVENT_MASK_REL | INPUT_EVENT_MASK_ABS, + NULL); return (s != NULL) && (s->handler->mask & INPUT_EVENT_MASK_ABS); } |