aboutsummaryrefslogtreecommitdiff
path: root/ui
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2014-05-28 10:33:05 +0100
committerPeter Maydell <peter.maydell@linaro.org>2014-05-28 10:33:05 +0100
commit4aa23452e366790e6c50dea73c8bc5eea44e2f38 (patch)
tree7da474230a9909a6f79d3d05f4cdce3532e41051 /ui
parent9474ab1487cc70140099c8500ae4a1947ca966c1 (diff)
parent8977bd111f62035b675d41c432eb8b6bf6b86b0f (diff)
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')
-rw-r--r--ui/curses.c4
-rw-r--r--ui/input-keymap.c13
-rw-r--r--ui/input.c49
-rw-r--r--ui/sdl2.c21
4 files changed, 68 insertions, 19 deletions
diff --git a/ui/curses.c b/ui/curses.c
index b044790e43..de85f7610f 100644
--- a/ui/curses.c
+++ b/ui/curses.c
@@ -288,8 +288,8 @@ static void curses_refresh(DisplayChangeListener *dcl)
qemu_input_event_send_key_number(NULL, GREY | ALT_CODE, true);
}
- qemu_input_event_send_key_number(NULL, keycode, true);
- qemu_input_event_send_key_number(NULL, keycode, false);
+ qemu_input_event_send_key_number(NULL, keycode & KEY_MASK, true);
+ qemu_input_event_send_key_number(NULL, keycode & KEY_MASK, false);
if (keycode & ALTGR) {
qemu_input_event_send_key_number(NULL, GREY | ALT_CODE, false);
diff --git a/ui/input-keymap.c b/ui/input-keymap.c
index 6da4495103..5d299353a8 100644
--- a/ui/input-keymap.c
+++ b/ui/input-keymap.c
@@ -13,6 +13,8 @@ static const int qcode_to_number[] = {
[Q_KEY_CODE_CTRL] = 0x1d,
[Q_KEY_CODE_CTRL_R] = 0x9d,
+ [Q_KEY_CODE_META_L] = 0xdb,
+ [Q_KEY_CODE_META_R] = 0xdc,
[Q_KEY_CODE_MENU] = 0xdd,
[Q_KEY_CODE_ESC] = 0x01,
@@ -129,7 +131,7 @@ static const int qcode_to_number[] = {
[Q_KEY_CODE_MAX] = 0,
};
-static int number_to_qcode[0xff];
+static int number_to_qcode[0x100];
int qemu_input_key_value_to_number(const KeyValue *value)
{
@@ -141,7 +143,7 @@ int qemu_input_key_value_to_number(const KeyValue *value)
}
}
-int qemu_input_key_value_to_qcode(const KeyValue *value)
+int qemu_input_key_number_to_qcode(uint8_t nr)
{
static int first = true;
@@ -155,11 +157,16 @@ int qemu_input_key_value_to_qcode(const KeyValue *value)
}
}
+ return number_to_qcode[nr];
+}
+
+int qemu_input_key_value_to_qcode(const KeyValue *value)
+{
if (value->kind == KEY_VALUE_KIND_QCODE) {
return value->qcode;
} else {
assert(value->kind == KEY_VALUE_KIND_NUMBER);
- return number_to_qcode[value->number];
+ return qemu_input_key_number_to_qcode(value->number);
}
}
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);
}
diff --git a/ui/sdl2.c b/ui/sdl2.c
index 361de619fa..0e884f96fd 100644
--- a/ui/sdl2.c
+++ b/ui/sdl2.c
@@ -190,30 +190,33 @@ static void sdl_switch(DisplayChangeListener *dcl,
}
}
-static void reset_keys(void)
+static void reset_keys(struct sdl2_state *scon)
{
+ QemuConsole *con = scon ? scon->dcl.con : NULL;
int i;
for (i = 0; i < 256; i++) {
if (modifiers_state[i]) {
int qcode = sdl2_scancode_to_qcode[i];
- qemu_input_event_send_key_qcode(NULL, qcode, false);
+ qemu_input_event_send_key_qcode(con, qcode, false);
modifiers_state[i] = 0;
}
}
}
-static void sdl_process_key(SDL_KeyboardEvent *ev)
+static void sdl_process_key(struct sdl2_state *scon,
+ SDL_KeyboardEvent *ev)
{
int qcode = sdl2_scancode_to_qcode[ev->keysym.scancode];
+ QemuConsole *con = scon ? scon->dcl.con : NULL;
switch (ev->keysym.scancode) {
#if 0
case SDL_SCANCODE_NUMLOCKCLEAR:
case SDL_SCANCODE_CAPSLOCK:
/* SDL does not send the key up event, so we generate it */
- qemu_input_event_send_key_qcode(NULL, qcode, true);
- qemu_input_event_send_key_qcode(NULL, qcode, false);
+ qemu_input_event_send_key_qcode(con, qcode, true);
+ qemu_input_event_send_key_qcode(con, qcode, false);
return;
#endif
case SDL_SCANCODE_LCTRL:
@@ -231,7 +234,7 @@ static void sdl_process_key(SDL_KeyboardEvent *ev)
}
/* fall though */
default:
- qemu_input_event_send_key_qcode(NULL, qcode,
+ qemu_input_event_send_key_qcode(con, qcode,
ev->type == SDL_KEYDOWN);
}
}
@@ -506,7 +509,7 @@ static void handle_keydown(SDL_Event *ev)
}
}
if (!gui_keysym) {
- sdl_process_key(&ev->key);
+ sdl_process_key(scon, &ev->key);
}
}
@@ -531,13 +534,13 @@ static void handle_keyup(SDL_Event *ev)
}
/* SDL does not send back all the modifiers key, so we must
* correct it. */
- reset_keys();
+ reset_keys(scon);
return;
}
gui_keysym = 0;
}
if (!gui_keysym) {
- sdl_process_key(&ev->key);
+ sdl_process_key(scon, &ev->key);
}
}