qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [RFC PATCH 00/15] input: rewrite qemu input layer
@ 2013-11-28 14:29 Gerd Hoffmann
  2013-11-28 14:29 ` [Qemu-devel] [RFC PATCH 01/15] console: export QemuConsole index, width, height Gerd Hoffmann
                   ` (14 more replies)
  0 siblings, 15 replies; 21+ messages in thread
From: Gerd Hoffmann @ 2013-11-28 14:29 UTC (permalink / raw)
  To: qemu-devel; +Cc: Dave Airlie, Gerd Hoffmann

  Hi,

This patch series is the first draft of a input layer rewrite.
New core code is largely in place.  There is some windup for
the legacy functions, to keep things working while switching
over users one by one.

Some ui code is converted to make clear how the new input layer
should be used.

No work on the device emulation side of things yet.

Main motivation for this is multihead support.  Thats why
QemuConsole is passed everythere, even though the code doesn't
use it (yet).  But some day the input layer has the should
be able to process/route events depending on the source.

Easy monitor integration is on the radar too, even though
none if this is coded up yet.  I wanna test the data structures
more before even thinking about exposing them via qmp.

In general the new way of handling events should more flexible
and be easier to extend than the old code we have right now.
We might want add touch support for example ...

Reviews?  Comments?

cheers,
  Gerd

Gerd Hoffmann (15):
  console: export QemuConsole index,width,height
  input: rename file to legacy
  input: define event types using qapi
  input: add core bits of the new input layer
  input: keyboard: add helper functions to core
  input: keyboard: switch legacy handlers to new core
  input: keyboard: switch qmp_send_key() to new core.
  input: keyboard: switch gtk ui to new core
  input: keyboard: switch sdl ui to new core [wip]
  input: mouse: add helpers functions to core
  input: mouse: add graphic_rotate support
  input: mouse: add qemu_input_is_absolute()
  input: mouse: switch legacy handlers to new core
  input: mouse: switch gtk ui to new core
  input: mouse: switch sdl ui to new core

 include/ui/console.h |   3 +
 include/ui/input.h   |  50 ++++
 qapi-schema.json     |  29 +++
 ui/Makefile.objs     |   2 +-
 ui/console.c         |  24 ++
 ui/gtk.c             |  77 ++----
 ui/input-legacy.c    | 650 +++++++++++++++++++++++++++++++++++++++++++++++++++
 ui/input.c           | 627 +++++++++++--------------------------------------
 ui/sdl.c             |  88 +++----
 9 files changed, 965 insertions(+), 585 deletions(-)
 create mode 100644 include/ui/input.h
 create mode 100644 ui/input-legacy.c

-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [Qemu-devel] [RFC PATCH 01/15] console: export QemuConsole index, width, height
  2013-11-28 14:29 [Qemu-devel] [RFC PATCH 00/15] input: rewrite qemu input layer Gerd Hoffmann
@ 2013-11-28 14:29 ` Gerd Hoffmann
  2013-11-28 14:29 ` [Qemu-devel] [RFC PATCH 02/15] input: rename file to legacy Gerd Hoffmann
                   ` (13 subsequent siblings)
  14 siblings, 0 replies; 21+ messages in thread
From: Gerd Hoffmann @ 2013-11-28 14:29 UTC (permalink / raw)
  To: qemu-devel; +Cc: Dave Airlie, Gerd Hoffmann, Anthony Liguori

Add functions to query QemuConsole properties.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 include/ui/console.h |  3 +++
 ui/console.c         | 24 ++++++++++++++++++++++++
 2 files changed, 27 insertions(+)

diff --git a/include/ui/console.h b/include/ui/console.h
index 98edf41..09138e5 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -290,6 +290,9 @@ QemuConsole *qemu_console_lookup_by_device(DeviceState *dev);
 bool qemu_console_is_visible(QemuConsole *con);
 bool qemu_console_is_graphic(QemuConsole *con);
 bool qemu_console_is_fixedsize(QemuConsole *con);
+int qemu_console_get_index(QemuConsole *con);
+int qemu_console_get_width(QemuConsole *con, int fallback);
+int qemu_console_get_height(QemuConsole *con, int fallback);
 
 void text_consoles_set_display(DisplayState *ds);
 void console_select(unsigned int index);
diff --git a/ui/console.c b/ui/console.c
index 199ba69..8d054cd 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -1645,6 +1645,30 @@ bool qemu_console_is_fixedsize(QemuConsole *con)
     return con && (con->console_type != TEXT_CONSOLE);
 }
 
+int qemu_console_get_index(QemuConsole *con)
+{
+    if (con == NULL) {
+        con = active_console;
+    }
+    return con ? con->index : -1;
+}
+
+int qemu_console_get_width(QemuConsole *con, int fallback)
+{
+    if (con == NULL) {
+        con = active_console;
+    }
+    return con ? surface_width(con->surface) : fallback;
+}
+
+int qemu_console_get_height(QemuConsole *con, int fallback)
+{
+    if (con == NULL) {
+        con = active_console;
+    }
+    return con ? surface_height(con->surface) : fallback;
+}
+
 static void text_console_set_echo(CharDriverState *chr, bool echo)
 {
     QemuConsole *s = chr->opaque;
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [Qemu-devel] [RFC PATCH 02/15] input: rename file to legacy
  2013-11-28 14:29 [Qemu-devel] [RFC PATCH 00/15] input: rewrite qemu input layer Gerd Hoffmann
  2013-11-28 14:29 ` [Qemu-devel] [RFC PATCH 01/15] console: export QemuConsole index, width, height Gerd Hoffmann
@ 2013-11-28 14:29 ` Gerd Hoffmann
  2013-11-28 14:29 ` [Qemu-devel] [RFC PATCH 03/15] input: define event types using qapi Gerd Hoffmann
                   ` (12 subsequent siblings)
  14 siblings, 0 replies; 21+ messages in thread
From: Gerd Hoffmann @ 2013-11-28 14:29 UTC (permalink / raw)
  To: qemu-devel; +Cc: Dave Airlie, Gerd Hoffmann, Anthony Liguori

Rename ui/input.c to ui/input-legacy.c.
We are going to replace it step by step.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 ui/Makefile.objs               | 2 +-
 ui/{input.c => input-legacy.c} | 0
 2 files changed, 1 insertion(+), 1 deletion(-)
 rename ui/{input.c => input-legacy.c} (100%)

diff --git a/ui/Makefile.objs b/ui/Makefile.objs
index f33be47..39ceadc 100644
--- a/ui/Makefile.objs
+++ b/ui/Makefile.objs
@@ -7,7 +7,7 @@ vnc-obj-$(CONFIG_VNC_SASL) += vnc-auth-sasl.o
 vnc-obj-$(CONFIG_VNC_WS) += vnc-ws.o
 vnc-obj-y += vnc-jobs.o
 
-common-obj-y += keymaps.o console.o cursor.o input.o qemu-pixman.o
+common-obj-y += keymaps.o console.o cursor.o input-legacy.o qemu-pixman.o
 common-obj-$(CONFIG_SPICE) += spice-core.o spice-input.o spice-display.o
 common-obj-$(CONFIG_SDL) += sdl.o sdl_zoom.o x_keymap.o
 common-obj-$(CONFIG_COCOA) += cocoa.o
diff --git a/ui/input.c b/ui/input-legacy.c
similarity index 100%
rename from ui/input.c
rename to ui/input-legacy.c
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [Qemu-devel] [RFC PATCH 03/15] input: define event types using qapi
  2013-11-28 14:29 [Qemu-devel] [RFC PATCH 00/15] input: rewrite qemu input layer Gerd Hoffmann
  2013-11-28 14:29 ` [Qemu-devel] [RFC PATCH 01/15] console: export QemuConsole index, width, height Gerd Hoffmann
  2013-11-28 14:29 ` [Qemu-devel] [RFC PATCH 02/15] input: rename file to legacy Gerd Hoffmann
@ 2013-11-28 14:29 ` Gerd Hoffmann
  2013-12-02 19:12   ` Eric Blake
  2013-11-28 14:29 ` [Qemu-devel] [RFC PATCH 04/15] input: add core bits of the new input layer Gerd Hoffmann
                   ` (11 subsequent siblings)
  14 siblings, 1 reply; 21+ messages in thread
From: Gerd Hoffmann @ 2013-11-28 14:29 UTC (permalink / raw)
  To: qemu-devel; +Cc: Dave Airlie, Gerd Hoffmann, Markus Armbruster, Luiz Capitulino

Define input event types, using qapi.  So we get nicely autogenerated
types for our input events.  And when it comes to qmp support some day
things will be alot easier.

Types are modeled after the linux input layer.  There are separate
event types for each value.  There is a sync to indicate the end
of a event group.

Mouse events are splitted into motion events (one for each axis) and
button events, which are grouped by sync.

Keyboard events are using keycodes instead of scancodes, so we can
rid of the keycode->scancode transformation everywhere in the
ui code.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 qapi-schema.json | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/qapi-schema.json b/qapi-schema.json
index 83fa485..c27c49d 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -4213,3 +4213,32 @@
 # Since: 1.7
 ##
 { 'command': 'blockdev-add', 'data': { 'options': 'BlockdevOptions' } }
+
+
+###########################################################
+# WIP - input event data structures
+# not exposed via qmp yet, needs testing first
+
+{ 'enum'  : 'InputButton',
+  'data'  : [ 'Left', 'Middle', 'Right' ] }
+
+{ 'enum'  : 'InputAxis',
+  'data'  : [ 'X', 'Y' ] }
+
+{ 'type'  : 'InputKeyEvent',
+  'data'  : { 'keycode' : 'int',
+              'down'    : 'bool' } }
+
+{ 'type'  : 'InputBtnEvent',
+  'data'  : { 'button'  : 'InputButton',
+              'down'    : 'bool' } }
+
+{ 'type'  : 'InputMoveEvent',
+  'data'  : { 'axis'    : 'InputAxis',
+              'value'   : 'int' } }
+
+{ 'union' : 'InputEvent',
+  'data'  : { 'key'     : 'InputKeyEvent',
+              'btn'     : 'InputBtnEvent',
+              'rel'     : 'InputMoveEvent',
+              'abs'     : 'InputMoveEvent' } }
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [Qemu-devel] [RFC PATCH 04/15] input: add core bits of the new input layer
  2013-11-28 14:29 [Qemu-devel] [RFC PATCH 00/15] input: rewrite qemu input layer Gerd Hoffmann
                   ` (2 preceding siblings ...)
  2013-11-28 14:29 ` [Qemu-devel] [RFC PATCH 03/15] input: define event types using qapi Gerd Hoffmann
@ 2013-11-28 14:29 ` Gerd Hoffmann
  2013-11-28 14:30 ` [Qemu-devel] [RFC PATCH 05/15] input: keyboard: add helper functions to core Gerd Hoffmann
                   ` (10 subsequent siblings)
  14 siblings, 0 replies; 21+ messages in thread
From: Gerd Hoffmann @ 2013-11-28 14:29 UTC (permalink / raw)
  To: qemu-devel; +Cc: Dave Airlie, Gerd Hoffmann, Anthony Liguori

Register and unregister handlers.
Event dispatcher code.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 include/ui/input.h | 32 +++++++++++++++++++++
 ui/Makefile.objs   |  2 +-
 ui/input.c         | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 116 insertions(+), 1 deletion(-)
 create mode 100644 include/ui/input.h
 create mode 100644 ui/input.c

diff --git a/include/ui/input.h b/include/ui/input.h
new file mode 100644
index 0000000..3cf3641
--- /dev/null
+++ b/include/ui/input.h
@@ -0,0 +1,32 @@
+#ifndef INPUT_H
+#define INPUT_H
+
+#include "qapi-types.h"
+
+#define INPUT_EVENT_MASK_KEY   (1<<INPUT_EVENT_KIND_KEY)
+#define INPUT_EVENT_MASK_BTN   (1<<INPUT_EVENT_KIND_BTN)
+#define INPUT_EVENT_MASK_REL   (1<<INPUT_EVENT_KIND_REL)
+#define INPUT_EVENT_MASK_ABS   (1<<INPUT_EVENT_KIND_ABS)
+
+typedef struct QemuInputHandler QemuInputHandler;
+typedef struct QemuInputHandlerState QemuInputHandlerState;
+
+typedef void (*QemuInputHandlerEvent)(DeviceState *dev, QemuConsole *src,
+                                      InputEvent *evt);
+typedef void (*QemuInputHandlerSync)(DeviceState *dev);
+
+struct QemuInputHandler {
+    const char             *name;
+    uint32_t               mask;
+    QemuInputHandlerEvent  event;
+    QemuInputHandlerSync   sync;
+};
+
+QemuInputHandlerState *qemu_input_handler_register(DeviceState *dev,
+                                                   QemuInputHandler *handler);
+void qemu_input_handler_activate(QemuInputHandlerState *s);
+void qemu_input_handler_unregister(QemuInputHandlerState *s);
+void qemu_input_event_send(QemuConsole *src, InputEvent *evt);
+void qemu_input_event_sync(void);
+
+#endif /* INPUT_H */
diff --git a/ui/Makefile.objs b/ui/Makefile.objs
index 39ceadc..27af551 100644
--- a/ui/Makefile.objs
+++ b/ui/Makefile.objs
@@ -7,7 +7,7 @@ vnc-obj-$(CONFIG_VNC_SASL) += vnc-auth-sasl.o
 vnc-obj-$(CONFIG_VNC_WS) += vnc-ws.o
 vnc-obj-y += vnc-jobs.o
 
-common-obj-y += keymaps.o console.o cursor.o input-legacy.o qemu-pixman.o
+common-obj-y += keymaps.o console.o cursor.o input.o input-legacy.o qemu-pixman.o
 common-obj-$(CONFIG_SPICE) += spice-core.o spice-input.o spice-display.o
 common-obj-$(CONFIG_SDL) += sdl.o sdl_zoom.o x_keymap.o
 common-obj-$(CONFIG_COCOA) += cocoa.o
diff --git a/ui/input.c b/ui/input.c
new file mode 100644
index 0000000..23c84f7
--- /dev/null
+++ b/ui/input.c
@@ -0,0 +1,83 @@
+#include "sysemu/sysemu.h"
+#include "qapi-types.h"
+#include "ui/input.h"
+
+struct QemuInputHandlerState {
+    DeviceState       *dev;
+    QemuInputHandler  *handler;
+    int               id;
+    int               events;
+    QTAILQ_ENTRY(QemuInputHandlerState) node;
+};
+static QTAILQ_HEAD(, QemuInputHandlerState) handlers =
+    QTAILQ_HEAD_INITIALIZER(handlers);
+
+QemuInputHandlerState *qemu_input_handler_register(DeviceState *dev,
+                                                   QemuInputHandler *handler)
+{
+    QemuInputHandlerState *s = g_new0(QemuInputHandlerState, 1);
+    static int id = 1;
+
+    s->dev = dev;
+    s->handler = handler;
+    s->id = id++;
+    QTAILQ_INSERT_TAIL(&handlers, s, node);
+    return s;
+}
+
+void qemu_input_handler_activate(QemuInputHandlerState *s)
+{
+    QTAILQ_REMOVE(&handlers, s, node);
+    QTAILQ_INSERT_HEAD(&handlers, s, node);
+}
+
+void qemu_input_handler_unregister(QemuInputHandlerState *s)
+{
+    QTAILQ_REMOVE(&handlers, s, node);
+    g_free(s);
+}
+
+static QemuInputHandlerState*
+qemu_input_find_handler(uint32_t mask)
+{
+    QemuInputHandlerState *s;
+
+    QTAILQ_FOREACH(s, &handlers, node) {
+        if (mask & s->handler->mask) {
+            return s;
+        }
+    }
+    return NULL;
+}
+
+void qemu_input_event_send(QemuConsole *src, InputEvent *evt)
+{
+    QemuInputHandlerState *s;
+
+    if (!runstate_is_running() && !runstate_check(RUN_STATE_SUSPENDED)) {
+        return;
+    }
+
+    s = qemu_input_find_handler(1 << evt->kind);
+    s->handler->event(s->dev, src, evt);
+    s->events++;
+}
+
+void qemu_input_event_sync(void)
+{
+    QemuInputHandlerState *s;
+
+    if (!runstate_is_running() && !runstate_check(RUN_STATE_SUSPENDED)) {
+        return;
+    }
+
+    QTAILQ_FOREACH(s, &handlers, node) {
+        if (!s->events) {
+            continue;
+        }
+        if (s->handler->sync) {
+            s->handler->sync(s->dev);
+        }
+        s->events = 0;
+    }
+}
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [Qemu-devel] [RFC PATCH 05/15] input: keyboard: add helper functions to core
  2013-11-28 14:29 [Qemu-devel] [RFC PATCH 00/15] input: rewrite qemu input layer Gerd Hoffmann
                   ` (3 preceding siblings ...)
  2013-11-28 14:29 ` [Qemu-devel] [RFC PATCH 04/15] input: add core bits of the new input layer Gerd Hoffmann
@ 2013-11-28 14:30 ` Gerd Hoffmann
  2013-11-28 14:30 ` [Qemu-devel] [RFC PATCH 06/15] input: keyboard: switch legacy handlers to new core Gerd Hoffmann
                   ` (9 subsequent siblings)
  14 siblings, 0 replies; 21+ messages in thread
From: Gerd Hoffmann @ 2013-11-28 14:30 UTC (permalink / raw)
  To: qemu-devel; +Cc: Dave Airlie, Gerd Hoffmann, Anthony Liguori

A bunch of helper functions to manage keyboard events,
to make life simpler for the ui code when submitting
keyboard events.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 include/ui/input.h |  3 +++
 ui/input.c         | 19 +++++++++++++++++++
 2 files changed, 22 insertions(+)

diff --git a/include/ui/input.h b/include/ui/input.h
index 3cf3641..12a964c 100644
--- a/include/ui/input.h
+++ b/include/ui/input.h
@@ -29,4 +29,7 @@ void qemu_input_handler_unregister(QemuInputHandlerState *s);
 void qemu_input_event_send(QemuConsole *src, InputEvent *evt);
 void qemu_input_event_sync(void);
 
+InputEvent *qemu_input_event_new_key(int keycode, bool down);
+void qemu_input_event_send_key(QemuConsole *src, int keycode, bool down);
+
 #endif /* INPUT_H */
diff --git a/ui/input.c b/ui/input.c
index 23c84f7..284bd1f 100644
--- a/ui/input.c
+++ b/ui/input.c
@@ -81,3 +81,22 @@ void qemu_input_event_sync(void)
         s->events = 0;
     }
 }
+
+InputEvent *qemu_input_event_new_key(int keycode, bool down)
+{
+    InputEvent *evt = g_new0(InputEvent, 1);
+    evt->key = g_new0(InputKeyEvent, 1);
+    evt->kind = INPUT_EVENT_KIND_KEY;
+    evt->key->keycode = keycode;
+    evt->key->down = down;
+    return evt;
+}
+
+void qemu_input_event_send_key(QemuConsole *src, int keycode, bool down)
+{
+    InputEvent *evt;
+    evt = qemu_input_event_new_key(keycode, down);
+    qemu_input_event_send(src, evt);
+    qemu_input_event_sync();
+    qapi_free_InputEvent(evt);
+}
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [Qemu-devel] [RFC PATCH 06/15] input: keyboard: switch legacy handlers to new core
  2013-11-28 14:29 [Qemu-devel] [RFC PATCH 00/15] input: rewrite qemu input layer Gerd Hoffmann
                   ` (4 preceding siblings ...)
  2013-11-28 14:30 ` [Qemu-devel] [RFC PATCH 05/15] input: keyboard: add helper functions to core Gerd Hoffmann
@ 2013-11-28 14:30 ` Gerd Hoffmann
  2013-11-28 14:30 ` [Qemu-devel] [RFC PATCH 07/15] input: keyboard: switch qmp_send_key() " Gerd Hoffmann
                   ` (8 subsequent siblings)
  14 siblings, 0 replies; 21+ messages in thread
From: Gerd Hoffmann @ 2013-11-28 14:30 UTC (permalink / raw)
  To: qemu-devel; +Cc: Dave Airlie, Gerd Hoffmann, Anthony Liguori

legacy kbd event handlers are registered in the new core,
so they receive events from the new input core code.
keycode -> scancode translation needed here.

legacy kbd_put_keycode() sends events to the new core.
scancode -> keycode translation needed here.

So with this patch the new input core is fully functional
for keyboard events.  New + legacy interfaces can be mixed
in any way.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 ui/input-legacy.c | 54 ++++++++++++++++++++++++++++++++++++++++++++----------
 1 file changed, 44 insertions(+), 10 deletions(-)

diff --git a/ui/input-legacy.c b/ui/input-legacy.c
index 10d8c05..0163a46 100644
--- a/ui/input-legacy.c
+++ b/ui/input-legacy.c
@@ -29,6 +29,7 @@
 #include "qmp-commands.h"
 #include "qapi-types.h"
 #include "ui/keymaps.h"
+#include "ui/input.h"
 
 struct QEMUPutMouseEntry {
     QEMUPutMouseEvent *qemu_put_mouse_event;
@@ -45,7 +46,7 @@ struct QEMUPutMouseEntry {
 struct QEMUPutKbdEntry {
     QEMUPutKBDEvent *put_kbd;
     void *opaque;
-    QTAILQ_ENTRY(QEMUPutKbdEntry) next;
+    QemuInputHandlerState *s;
 };
 
 struct QEMUPutLEDEntry {
@@ -56,8 +57,6 @@ struct QEMUPutLEDEntry {
 
 static QTAILQ_HEAD(, QEMUPutLEDEntry) led_handlers =
     QTAILQ_HEAD_INITIALIZER(led_handlers);
-static QTAILQ_HEAD(, QEMUPutKbdEntry) kbd_handlers =
-    QTAILQ_HEAD_INITIALIZER(kbd_handlers);
 static QTAILQ_HEAD(, QEMUPutMouseEntry) mouse_handlers =
     QTAILQ_HEAD_INITIALIZER(mouse_handlers);
 static NotifierList mouse_mode_notifiers =
@@ -312,20 +311,44 @@ void qmp_send_key(KeyValueList *keys, bool has_hold_time, int64_t hold_time,
                    muldiv64(get_ticks_per_sec(), hold_time, 1000));
 }
 
+static void legacy_kbd_event(DeviceState *dev, QemuConsole *src,
+                             InputEvent *evt)
+{
+    QEMUPutKbdEntry *entry = (QEMUPutKbdEntry *)dev;
+    int keycode = evt->key->keycode;
+
+    if (keycode & SCANCODE_GREY) {
+        entry->put_kbd(entry->opaque, SCANCODE_EMUL0);
+        keycode &= ~SCANCODE_GREY;
+    }
+    if (!evt->key->down) {
+        keycode |= SCANCODE_UP;
+    }
+    entry->put_kbd(entry->opaque, keycode);
+}
+
+static QemuInputHandler legacy_kbd_handler = {
+    .name  = "legacy-kbd",
+    .mask  = INPUT_EVENT_MASK_KEY,
+    .event = legacy_kbd_event,
+};
+
 QEMUPutKbdEntry *qemu_add_kbd_event_handler(QEMUPutKBDEvent *func, void *opaque)
 {
     QEMUPutKbdEntry *entry;
 
-    entry = g_malloc0(sizeof(QEMUPutKbdEntry));
+    entry = g_new0(QEMUPutKbdEntry, 1);
     entry->put_kbd = func;
     entry->opaque = opaque;
-    QTAILQ_INSERT_HEAD(&kbd_handlers, entry, next);
+    entry->s = qemu_input_handler_register((DeviceState *)entry,
+                                           &legacy_kbd_handler);
     return entry;
 }
 
 void qemu_remove_kbd_event_handler(QEMUPutKbdEntry *entry)
 {
-    QTAILQ_REMOVE(&kbd_handlers, entry, next);
+    qemu_input_handler_unregister(entry->s);
+    g_free(entry);
 }
 
 static void check_mode_change(void)
@@ -409,14 +432,25 @@ void qemu_remove_led_event_handler(QEMUPutLEDEntry *entry)
 
 void kbd_put_keycode(int keycode)
 {
-    QEMUPutKbdEntry *entry = QTAILQ_FIRST(&kbd_handlers);
+    static bool emul0;
+    bool up;
 
-    if (!runstate_is_running() && !runstate_check(RUN_STATE_SUSPENDED)) {
+    if (keycode == SCANCODE_EMUL0) {
+        emul0 = true;
         return;
     }
-    if (entry) {
-        entry->put_kbd(entry->opaque, keycode);
+    if (keycode & SCANCODE_UP) {
+        keycode &= ~SCANCODE_UP;
+        up = true;
+    } else {
+        up = false;
+    }
+    if (emul0) {
+        keycode |= SCANCODE_GREY;
+        emul0 = false;
     }
+
+    qemu_input_event_send_key(NULL, keycode, !up);
 }
 
 void kbd_put_ledstate(int ledstate)
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [Qemu-devel] [RFC PATCH 07/15] input: keyboard: switch qmp_send_key() to new core.
  2013-11-28 14:29 [Qemu-devel] [RFC PATCH 00/15] input: rewrite qemu input layer Gerd Hoffmann
                   ` (5 preceding siblings ...)
  2013-11-28 14:30 ` [Qemu-devel] [RFC PATCH 06/15] input: keyboard: switch legacy handlers to new core Gerd Hoffmann
@ 2013-11-28 14:30 ` Gerd Hoffmann
  2013-11-28 14:30 ` [Qemu-devel] [RFC PATCH 08/15] input: keyboard: switch gtk ui " Gerd Hoffmann
                   ` (7 subsequent siblings)
  14 siblings, 0 replies; 21+ messages in thread
From: Gerd Hoffmann @ 2013-11-28 14:30 UTC (permalink / raw)
  To: qemu-devel; +Cc: Dave Airlie, Gerd Hoffmann, Anthony Liguori

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 ui/input-legacy.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/ui/input-legacy.c b/ui/input-legacy.c
index 0163a46..d7dd880 100644
--- a/ui/input-legacy.c
+++ b/ui/input-legacy.c
@@ -260,10 +260,7 @@ static void free_keycodes(void)
 static void release_keys(void *opaque)
 {
     while (keycodes_size > 0) {
-        if (keycodes[--keycodes_size] & SCANCODE_GREY) {
-            kbd_put_keycode(SCANCODE_EMUL0);
-        }
-        kbd_put_keycode(keycodes[keycodes_size] | SCANCODE_UP);
+        qemu_input_event_send_key(NULL, keycodes[--keycodes_size], false);
     }
 
     free_keycodes();
@@ -297,10 +294,7 @@ void qmp_send_key(KeyValueList *keys, bool has_hold_time, int64_t hold_time,
             return;
         }
 
-        if (keycode & SCANCODE_GREY) {
-            kbd_put_keycode(SCANCODE_EMUL0);
-        }
-        kbd_put_keycode(keycode & SCANCODE_KEYCODEMASK);
+        qemu_input_event_send_key(NULL, keycode, true);
 
         keycodes = g_realloc(keycodes, sizeof(int) * (keycodes_size + 1));
         keycodes[keycodes_size++] = keycode;
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [Qemu-devel] [RFC PATCH 08/15] input: keyboard: switch gtk ui to new core
  2013-11-28 14:29 [Qemu-devel] [RFC PATCH 00/15] input: rewrite qemu input layer Gerd Hoffmann
                   ` (6 preceding siblings ...)
  2013-11-28 14:30 ` [Qemu-devel] [RFC PATCH 07/15] input: keyboard: switch qmp_send_key() " Gerd Hoffmann
@ 2013-11-28 14:30 ` Gerd Hoffmann
  2013-11-28 14:30 ` [Qemu-devel] [RFC PATCH 09/15] input: keyboard: switch sdl ui to new core [wip] Gerd Hoffmann
                   ` (6 subsequent siblings)
  14 siblings, 0 replies; 21+ messages in thread
From: Gerd Hoffmann @ 2013-11-28 14:30 UTC (permalink / raw)
  To: qemu-devel; +Cc: Dave Airlie, Gerd Hoffmann, Anthony Liguori

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 ui/gtk.c | 19 ++++---------------
 1 file changed, 4 insertions(+), 15 deletions(-)

diff --git a/ui/gtk.c b/ui/gtk.c
index b5f4f0b..3a97b36 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -54,6 +54,7 @@
 #include <math.h>
 
 #include "ui/console.h"
+#include "ui/input.h"
 #include "sysemu/sysemu.h"
 #include "qmp-commands.h"
 #include "x_keymap.h"
@@ -283,10 +284,7 @@ static void gtk_release_modifiers(GtkDisplayState *s)
         if (!s->modifier_pressed[i]) {
             continue;
         }
-        if (keycode & SCANCODE_GREY) {
-            kbd_put_keycode(SCANCODE_EMUL0);
-        }
-        kbd_put_keycode(keycode | SCANCODE_UP);
+        qemu_input_event_send_key(s->dcl.con, keycode, false);
         s->modifier_pressed[i] = false;
     }
 }
@@ -742,17 +740,8 @@ static gboolean gd_key_event(GtkWidget *widget, GdkEventKey *key, void *opaque)
         }
     }
 
-    if (qemu_keycode & SCANCODE_GREY) {
-        kbd_put_keycode(SCANCODE_EMUL0);
-    }
-
-    if (key->type == GDK_KEY_PRESS) {
-        kbd_put_keycode(qemu_keycode & SCANCODE_KEYCODEMASK);
-    } else if (key->type == GDK_KEY_RELEASE) {
-        kbd_put_keycode(qemu_keycode | SCANCODE_UP);
-    } else {
-        g_assert_not_reached();
-    }
+    qemu_input_event_send_key(s->dcl.con, qemu_keycode,
+                              key->type == GDK_KEY_PRESS);
 
     return TRUE;
 }
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [Qemu-devel] [RFC PATCH 09/15] input: keyboard: switch sdl ui to new core [wip]
  2013-11-28 14:29 [Qemu-devel] [RFC PATCH 00/15] input: rewrite qemu input layer Gerd Hoffmann
                   ` (7 preceding siblings ...)
  2013-11-28 14:30 ` [Qemu-devel] [RFC PATCH 08/15] input: keyboard: switch gtk ui " Gerd Hoffmann
@ 2013-11-28 14:30 ` Gerd Hoffmann
  2013-11-28 14:30 ` [Qemu-devel] [RFC PATCH 10/15] input: mouse: add helpers functions to core Gerd Hoffmann
                   ` (5 subsequent siblings)
  14 siblings, 0 replies; 21+ messages in thread
From: Gerd Hoffmann @ 2013-11-28 14:30 UTC (permalink / raw)
  To: qemu-devel; +Cc: Dave Airlie, Gerd Hoffmann, Anthony Liguori

FIXME: pause key not handled yet.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 ui/sdl.c | 23 ++++++++++-------------
 1 file changed, 10 insertions(+), 13 deletions(-)

diff --git a/ui/sdl.c b/ui/sdl.c
index 9d8583c..1b1224a 100644
--- a/ui/sdl.c
+++ b/ui/sdl.c
@@ -30,6 +30,7 @@
 
 #include "qemu-common.h"
 #include "ui/console.h"
+#include "ui/input.h"
 #include "sysemu/sysemu.h"
 #include "x_keymap.h"
 #include "sdl_zoom.h"
@@ -261,9 +262,7 @@ static void reset_keys(void)
     int i;
     for(i = 0; i < 256; i++) {
         if (modifiers_state[i]) {
-            if (i & SCANCODE_GREY)
-                kbd_put_keycode(SCANCODE_EMUL0);
-            kbd_put_keycode(i | SCANCODE_UP);
+            qemu_input_event_send_key(dcl->con, i, false);
             modifiers_state[i] = 0;
         }
     }
@@ -271,11 +270,12 @@ static void reset_keys(void)
 
 static void sdl_process_key(SDL_KeyboardEvent *ev)
 {
-    int keycode, v;
+    int keycode;
 
+#if 0
     if (ev->keysym.sym == SDLK_PAUSE) {
         /* specific case */
-        v = 0;
+        int v = 0;
         if (ev->type == SDL_KEYUP)
             v |= SCANCODE_UP;
         kbd_put_keycode(0xe1);
@@ -283,6 +283,7 @@ static void sdl_process_key(SDL_KeyboardEvent *ev)
         kbd_put_keycode(0x45 | v);
         return;
     }
+#endif
 
     if (kbd_layout) {
         keycode = sdl_keyevent_to_keycode_generic(ev);
@@ -312,19 +313,15 @@ static void sdl_process_key(SDL_KeyboardEvent *ev)
     case 0x45: /* num lock */
     case 0x3a: /* caps lock */
         /* SDL does not send the key up event, so we generate it */
-        kbd_put_keycode(keycode);
-        kbd_put_keycode(keycode | SCANCODE_UP);
+        qemu_input_event_send_key(dcl->con, keycode, true);
+        qemu_input_event_send_key(dcl->con, keycode, false);
         return;
 #endif
     }
 
     /* now send the key code */
-    if (keycode & SCANCODE_GREY)
-        kbd_put_keycode(SCANCODE_EMUL0);
-    if (ev->type == SDL_KEYUP)
-        kbd_put_keycode(keycode | SCANCODE_UP);
-    else
-        kbd_put_keycode(keycode & SCANCODE_KEYCODEMASK);
+    qemu_input_event_send_key(dcl->con, keycode,
+                              ev->type == SDL_KEYDOWN);
 }
 
 static void sdl_update_caption(void)
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [Qemu-devel] [RFC PATCH 10/15] input: mouse: add helpers functions to core
  2013-11-28 14:29 [Qemu-devel] [RFC PATCH 00/15] input: rewrite qemu input layer Gerd Hoffmann
                   ` (8 preceding siblings ...)
  2013-11-28 14:30 ` [Qemu-devel] [RFC PATCH 09/15] input: keyboard: switch sdl ui to new core [wip] Gerd Hoffmann
@ 2013-11-28 14:30 ` Gerd Hoffmann
  2013-11-28 14:30 ` [Qemu-devel] [RFC PATCH 11/15] input: mouse: add graphic_rotate support Gerd Hoffmann
                   ` (4 subsequent siblings)
  14 siblings, 0 replies; 21+ messages in thread
From: Gerd Hoffmann @ 2013-11-28 14:30 UTC (permalink / raw)
  To: qemu-devel; +Cc: Dave Airlie, Gerd Hoffmann, Anthony Liguori

Likewise a bunch of helper functions to manage mouse button
and movement events, again to make life easier for the ui code.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 include/ui/input.h | 14 +++++++++++
 ui/input.c         | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 85 insertions(+)

diff --git a/include/ui/input.h b/include/ui/input.h
index 12a964c..0d79342 100644
--- a/include/ui/input.h
+++ b/include/ui/input.h
@@ -8,6 +8,8 @@
 #define INPUT_EVENT_MASK_REL   (1<<INPUT_EVENT_KIND_REL)
 #define INPUT_EVENT_MASK_ABS   (1<<INPUT_EVENT_KIND_ABS)
 
+#define INPUT_EVENT_ABS_SIZE   0x8000
+
 typedef struct QemuInputHandler QemuInputHandler;
 typedef struct QemuInputHandlerState QemuInputHandlerState;
 
@@ -32,4 +34,16 @@ void qemu_input_event_sync(void);
 InputEvent *qemu_input_event_new_key(int keycode, bool down);
 void qemu_input_event_send_key(QemuConsole *src, int keycode, bool down);
 
+InputEvent *qemu_input_event_new_btn(InputButton btn, bool down);
+void qemu_input_queue_btn(QemuConsole *src, InputButton btn, bool down);
+void qemu_input_update_buttons(QemuConsole *src, uint32_t *button_map,
+                               uint32_t button_old, uint32_t button_new);
+
+int qemu_input_scale_axis(int value, int size_in, int size_out);
+InputEvent *qemu_input_event_new_move(InputEventKind kind,
+                                      InputAxis axis, int value);
+void qemu_input_queue_rel(QemuConsole *src, InputAxis axis, int value);
+void qemu_input_queue_abs(QemuConsole *src, InputAxis axis,
+                          int value, int size);
+
 #endif /* INPUT_H */
diff --git a/ui/input.c b/ui/input.c
index 284bd1f..fa6d677 100644
--- a/ui/input.c
+++ b/ui/input.c
@@ -100,3 +100,74 @@ void qemu_input_event_send_key(QemuConsole *src, int keycode, bool down)
     qemu_input_event_sync();
     qapi_free_InputEvent(evt);
 }
+
+InputEvent *qemu_input_event_new_btn(InputButton btn, bool down)
+{
+    InputEvent *evt = g_new0(InputEvent, 1);
+    evt->btn = g_new0(InputBtnEvent, 1);
+    evt->kind = INPUT_EVENT_KIND_BTN;
+    evt->btn->button = btn;
+    evt->btn->down = down;
+    return evt;
+}
+
+void qemu_input_queue_btn(QemuConsole *src, InputButton btn, bool down)
+{
+    InputEvent *evt;
+    evt = qemu_input_event_new_btn(btn, down);
+    qemu_input_event_send(src, evt);
+    qapi_free_InputEvent(evt);
+}
+
+void qemu_input_update_buttons(QemuConsole *src, uint32_t *button_map,
+                               uint32_t button_old, uint32_t button_new)
+{
+    InputButton btn;
+    uint32_t mask;
+
+    for (btn = 0; btn < INPUT_BUTTON_MAX; btn++) {
+        mask = button_map[btn];
+        if ((button_old & mask) == (button_new & mask)) {
+            continue;
+        }
+        qemu_input_queue_btn(src, btn, button_new & mask);
+    }
+}
+
+int qemu_input_scale_axis(int value, int size_in, int size_out)
+{
+    if (size_in < 2) {
+        return size_out / 2;
+    }
+    return (int64_t)value * (size_out - 1) / (size_in - 1);
+}
+
+InputEvent *qemu_input_event_new_move(InputEventKind kind,
+                                      InputAxis axis, int value)
+{
+    InputEvent *evt = g_new0(InputEvent, 1);
+    InputMoveEvent *move = g_new0(InputMoveEvent, 1);
+
+    evt->kind = kind;
+    evt->data = move;
+    move->axis = axis;
+    move->value = value;
+    return evt;
+}
+
+void qemu_input_queue_rel(QemuConsole *src, InputAxis axis, int value)
+{
+    InputEvent *evt;
+    evt = qemu_input_event_new_move(INPUT_EVENT_KIND_REL, axis, value);
+    qemu_input_event_send(src, evt);
+    qapi_free_InputEvent(evt);
+}
+
+void qemu_input_queue_abs(QemuConsole *src, InputAxis axis, int value, int size)
+{
+    InputEvent *evt;
+    int scaled = qemu_input_scale_axis(value, size, INPUT_EVENT_ABS_SIZE);
+    evt = qemu_input_event_new_move(INPUT_EVENT_KIND_ABS, axis, scaled);
+    qemu_input_event_send(src, evt);
+    qapi_free_InputEvent(evt);
+}
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [Qemu-devel] [RFC PATCH 11/15] input: mouse: add graphic_rotate support
  2013-11-28 14:29 [Qemu-devel] [RFC PATCH 00/15] input: rewrite qemu input layer Gerd Hoffmann
                   ` (9 preceding siblings ...)
  2013-11-28 14:30 ` [Qemu-devel] [RFC PATCH 10/15] input: mouse: add helpers functions to core Gerd Hoffmann
@ 2013-11-28 14:30 ` Gerd Hoffmann
  2013-12-02 19:00   ` John Baboval
  2013-11-28 14:30 ` [Qemu-devel] [RFC PATCH 12/15] input: mouse: add qemu_input_is_absolute() Gerd Hoffmann
                   ` (3 subsequent siblings)
  14 siblings, 1 reply; 21+ messages in thread
From: Gerd Hoffmann @ 2013-11-28 14:30 UTC (permalink / raw)
  To: qemu-devel; +Cc: Dave Airlie, Gerd Hoffmann, Anthony Liguori

Transform absolute mouse events according to graphic_rotate.

Legacy input code does it for both absolute and relative events,
but the logic is broken for relative coordinates, so this is
most likely not used anyway.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 ui/input.c | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/ui/input.c b/ui/input.c
index fa6d677..abfe3a3 100644
--- a/ui/input.c
+++ b/ui/input.c
@@ -50,6 +50,33 @@ qemu_input_find_handler(uint32_t mask)
     return NULL;
 }
 
+static void qemu_input_transform_abs_rotate(InputEvent *evt)
+{
+    switch (graphic_rotate) {
+    case 90:
+        if (evt->abs->axis == INPUT_AXIS_X) {
+            evt->abs->axis = INPUT_AXIS_Y;
+        }
+        if (evt->abs->axis == INPUT_AXIS_Y) {
+            evt->abs->axis = INPUT_AXIS_X;
+            evt->abs->axis = INPUT_EVENT_ABS_SIZE - 1 - evt->abs->axis;
+        }
+        break;
+    case 180:
+        evt->abs->axis = INPUT_EVENT_ABS_SIZE - 1 - evt->abs->axis;
+        break;
+    case 270:
+        if (evt->abs->axis == INPUT_AXIS_X) {
+            evt->abs->axis = INPUT_AXIS_Y;
+            evt->abs->axis = INPUT_EVENT_ABS_SIZE - 1 - evt->abs->axis;
+        }
+        if (evt->abs->axis == INPUT_AXIS_Y) {
+            evt->abs->axis = INPUT_AXIS_X;
+        }
+        break;
+    }
+}
+
 void qemu_input_event_send(QemuConsole *src, InputEvent *evt)
 {
     QemuInputHandlerState *s;
@@ -58,6 +85,12 @@ void qemu_input_event_send(QemuConsole *src, InputEvent *evt)
         return;
     }
 
+    /* pre processing */
+    if (graphic_rotate && (evt->kind == INPUT_EVENT_KIND_ABS)) {
+            qemu_input_transform_abs_rotate(evt);
+    }
+
+    /* send event */
     s = qemu_input_find_handler(1 << evt->kind);
     s->handler->event(s->dev, src, evt);
     s->events++;
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [Qemu-devel] [RFC PATCH 12/15] input: mouse: add qemu_input_is_absolute()
  2013-11-28 14:29 [Qemu-devel] [RFC PATCH 00/15] input: rewrite qemu input layer Gerd Hoffmann
                   ` (10 preceding siblings ...)
  2013-11-28 14:30 ` [Qemu-devel] [RFC PATCH 11/15] input: mouse: add graphic_rotate support Gerd Hoffmann
@ 2013-11-28 14:30 ` Gerd Hoffmann
  2013-12-02 19:05   ` John Baboval
  2013-11-28 14:30 ` [Qemu-devel] [RFC PATCH 13/15] input: mouse: switch legacy handlers to new core Gerd Hoffmann
                   ` (2 subsequent siblings)
  14 siblings, 1 reply; 21+ messages in thread
From: Gerd Hoffmann @ 2013-11-28 14:30 UTC (permalink / raw)
  To: qemu-devel; +Cc: Dave Airlie, Gerd Hoffmann, Anthony Liguori

Same as kbd_mouse_is_absolute(), but using new input core.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 include/ui/input.h | 1 +
 ui/input.c         | 8 ++++++++
 2 files changed, 9 insertions(+)

diff --git a/include/ui/input.h b/include/ui/input.h
index 0d79342..43b9afc 100644
--- a/include/ui/input.h
+++ b/include/ui/input.h
@@ -39,6 +39,7 @@ void qemu_input_queue_btn(QemuConsole *src, InputButton btn, bool down);
 void qemu_input_update_buttons(QemuConsole *src, uint32_t *button_map,
                                uint32_t button_old, uint32_t button_new);
 
+bool qemu_input_is_absolute(void);
 int qemu_input_scale_axis(int value, int size_in, int size_out);
 InputEvent *qemu_input_event_new_move(InputEventKind kind,
                                       InputAxis axis, int value);
diff --git a/ui/input.c b/ui/input.c
index abfe3a3..719c427 100644
--- a/ui/input.c
+++ b/ui/input.c
@@ -167,6 +167,14 @@ void qemu_input_update_buttons(QemuConsole *src, uint32_t *button_map,
     }
 }
 
+bool qemu_input_is_absolute(void)
+{
+    QemuInputHandlerState *s;
+
+    s = qemu_input_find_handler(INPUT_EVENT_MASK_REL | INPUT_EVENT_MASK_ABS);
+    return (s != NULL) && (s->handler->mask & INPUT_EVENT_MASK_ABS);
+}
+
 int qemu_input_scale_axis(int value, int size_in, int size_out)
 {
     if (size_in < 2) {
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [Qemu-devel] [RFC PATCH 13/15] input: mouse: switch legacy handlers to new core
  2013-11-28 14:29 [Qemu-devel] [RFC PATCH 00/15] input: rewrite qemu input layer Gerd Hoffmann
                   ` (11 preceding siblings ...)
  2013-11-28 14:30 ` [Qemu-devel] [RFC PATCH 12/15] input: mouse: add qemu_input_is_absolute() Gerd Hoffmann
@ 2013-11-28 14:30 ` Gerd Hoffmann
  2013-11-28 14:30 ` [Qemu-devel] [RFC PATCH 14/15] input: mouse: switch gtk ui " Gerd Hoffmann
  2013-11-28 14:30 ` [Qemu-devel] [RFC PATCH 15/15] input: mouse: switch sdl " Gerd Hoffmann
  14 siblings, 0 replies; 21+ messages in thread
From: Gerd Hoffmann @ 2013-11-28 14:30 UTC (permalink / raw)
  To: qemu-devel; +Cc: Dave Airlie, Gerd Hoffmann, Anthony Liguori

legacy mouse event handlers are registered in the new core,
so they receive events submitted to the new input core.

legacy kbd_mouse_event() continues to use the old code paths.
So new-core event handlers wouldn't see events submitted via
kbd_mouse_event.

This leads to the constrain that we we must transition all
kbd_mouse_event() users first to keep things working.  But
that is easier to handle than translating legacy mouse events
into new-core mouse events ;)

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 ui/input-legacy.c | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 63 insertions(+)

diff --git a/ui/input-legacy.c b/ui/input-legacy.c
index d7dd880..323a66c 100644
--- a/ui/input-legacy.c
+++ b/ui/input-legacy.c
@@ -41,6 +41,12 @@ struct QEMUPutMouseEntry {
 
     /* used internally by qemu for handling mice */
     QTAILQ_ENTRY(QEMUPutMouseEntry) node;
+
+    /* new input core */
+    QemuInputHandler h;
+    QemuInputHandlerState *s;
+    int axis[INPUT_AXIS_MAX];
+    int buttons;
 };
 
 struct QEMUPutKbdEntry {
@@ -363,6 +369,51 @@ static void check_mode_change(void)
     current_has_absolute = has_absolute;
 }
 
+static void legacy_mouse_event(DeviceState *dev, QemuConsole *src,
+                               InputEvent *evt)
+{
+    static const int bmap[INPUT_BUTTON_MAX] = {
+        [INPUT_BUTTON_LEFT]   = MOUSE_EVENT_LBUTTON,
+        [INPUT_BUTTON_MIDDLE] = MOUSE_EVENT_MBUTTON,
+        [INPUT_BUTTON_RIGHT]  = MOUSE_EVENT_RBUTTON,
+    };
+    QEMUPutMouseEntry *s = (QEMUPutMouseEntry *)dev;
+
+    switch (evt->kind) {
+    case INPUT_EVENT_KIND_BTN:
+        if (evt->btn->down) {
+            s->buttons |= bmap[evt->btn->button];
+        } else {
+            s->buttons &= ~bmap[evt->btn->button];
+        }
+        break;
+    case INPUT_EVENT_KIND_ABS:
+        s->axis[evt->abs->axis] = evt->abs->value;
+        break;
+    case INPUT_EVENT_KIND_REL:
+        s->axis[evt->rel->axis] += evt->rel->value;
+        break;
+    default:
+        break;
+    }
+}
+
+static void legacy_mouse_sync(DeviceState *dev)
+{
+    QEMUPutMouseEntry *s = (QEMUPutMouseEntry *)dev;
+
+    s->qemu_put_mouse_event(s->qemu_put_mouse_event_opaque,
+                            s->axis[INPUT_AXIS_X],
+                            s->axis[INPUT_AXIS_Y],
+                            0,
+                            s->buttons);
+
+    if (!s->qemu_put_mouse_event_absolute) {
+        s->axis[INPUT_AXIS_X] = 0;
+        s->axis[INPUT_AXIS_Y] = 0;
+    }
+}
+
 QEMUPutMouseEntry *qemu_add_mouse_event_handler(QEMUPutMouseEvent *func,
                                                 void *opaque, int absolute,
                                                 const char *name)
@@ -380,6 +431,14 @@ QEMUPutMouseEntry *qemu_add_mouse_event_handler(QEMUPutMouseEvent *func,
 
     QTAILQ_INSERT_TAIL(&mouse_handlers, s, node);
 
+    s->h.name = name;
+    s->h.mask = INPUT_EVENT_MASK_BTN |
+        (absolute ? INPUT_EVENT_MASK_ABS : INPUT_EVENT_MASK_REL);
+    s->h.event = legacy_mouse_event;
+    s->h.sync = legacy_mouse_sync;
+    s->s = qemu_input_handler_register((DeviceState *)s,
+                                       &s->h);
+
     check_mode_change();
 
     return s;
@@ -390,6 +449,8 @@ void qemu_activate_mouse_event_handler(QEMUPutMouseEntry *entry)
     QTAILQ_REMOVE(&mouse_handlers, entry, node);
     QTAILQ_INSERT_HEAD(&mouse_handlers, entry, node);
 
+    qemu_input_handler_activate(entry->s);
+
     check_mode_change();
 }
 
@@ -397,6 +458,8 @@ void qemu_remove_mouse_event_handler(QEMUPutMouseEntry *entry)
 {
     QTAILQ_REMOVE(&mouse_handlers, entry, node);
 
+    qemu_input_handler_unregister(entry->s);
+
     g_free(entry->qemu_put_mouse_event_name);
     g_free(entry);
 
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [Qemu-devel] [RFC PATCH 14/15] input: mouse: switch gtk ui to new core
  2013-11-28 14:29 [Qemu-devel] [RFC PATCH 00/15] input: rewrite qemu input layer Gerd Hoffmann
                   ` (12 preceding siblings ...)
  2013-11-28 14:30 ` [Qemu-devel] [RFC PATCH 13/15] input: mouse: switch legacy handlers to new core Gerd Hoffmann
@ 2013-11-28 14:30 ` Gerd Hoffmann
  2013-11-28 14:30 ` [Qemu-devel] [RFC PATCH 15/15] input: mouse: switch sdl " Gerd Hoffmann
  14 siblings, 0 replies; 21+ messages in thread
From: Gerd Hoffmann @ 2013-11-28 14:30 UTC (permalink / raw)
  To: qemu-devel; +Cc: Dave Airlie, Gerd Hoffmann, Anthony Liguori

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 ui/gtk.c | 58 +++++++++++++++++++---------------------------------------
 1 file changed, 19 insertions(+), 39 deletions(-)

diff --git a/ui/gtk.c b/ui/gtk.c
index 3a97b36..3c37d2e 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -197,7 +197,7 @@ static void gd_update_cursor(GtkDisplayState *s, gboolean override)
     on_vga = gd_on_vga(s);
 
     if ((override || on_vga) &&
-        (s->full_screen || kbd_mouse_is_absolute() || gd_is_grab_active(s))) {
+        (s->full_screen || qemu_input_is_absolute() || gd_is_grab_active(s))) {
         gdk_window_set_cursor(window, s->null_cursor);
     } else {
         gdk_window_set_cursor(window, NULL);
@@ -584,7 +584,6 @@ static gboolean gd_motion_event(GtkWidget *widget, GdkEventMotion *motion,
                                 void *opaque)
 {
     GtkDisplayState *s = opaque;
-    int dx, dy;
     int x, y;
     int mx, my;
     int fbh, fbw;
@@ -612,25 +611,21 @@ static gboolean gd_motion_event(GtkWidget *widget, GdkEventMotion *motion,
         return TRUE;
     }
 
-    if (kbd_mouse_is_absolute()) {
-        dx = x * 0x7FFF / (surface_width(s->ds) - 1);
-        dy = y * 0x7FFF / (surface_height(s->ds) - 1);
-    } else if (s->last_x == -1 || s->last_y == -1) {
-        dx = 0;
-        dy = 0;
-    } else {
-        dx = x - s->last_x;
-        dy = y - s->last_y;
+    if (qemu_input_is_absolute()) {
+        qemu_input_queue_abs(s->dcl.con, INPUT_AXIS_X, x,
+                             surface_width(s->ds));
+        qemu_input_queue_abs(s->dcl.con, INPUT_AXIS_Y, y,
+                             surface_height(s->ds));
+        qemu_input_event_sync();
+    } else if (s->last_x != -1 && s->last_y != -1 && gd_is_grab_active(s)) {
+        qemu_input_queue_rel(s->dcl.con, INPUT_AXIS_X, x - s->last_x);
+        qemu_input_queue_rel(s->dcl.con, INPUT_AXIS_Y, y - s->last_y);
+        qemu_input_event_sync();
     }
-
     s->last_x = x;
     s->last_y = y;
 
-    if (kbd_mouse_is_absolute() || gd_is_grab_active(s)) {
-        kbd_mouse_event(dx, dy, 0, s->button_mask);
-    }
-
-    if (!kbd_mouse_is_absolute() && gd_is_grab_active(s)) {
+    if (!qemu_input_is_absolute() && gd_is_grab_active(s)) {
         GdkScreen *screen = gtk_widget_get_screen(s->drawing_area);
         int x = (int)motion->x_root;
         int y = (int)motion->y_root;
@@ -675,35 +670,20 @@ static gboolean gd_button_event(GtkWidget *widget, GdkEventButton *button,
                                 void *opaque)
 {
     GtkDisplayState *s = opaque;
-    int dx, dy;
-    int n;
+    InputButton btn;
 
     if (button->button == 1) {
-        n = 0x01;
+        btn = INPUT_BUTTON_LEFT;
     } else if (button->button == 2) {
-        n = 0x04;
+        btn = INPUT_BUTTON_MIDDLE;
     } else if (button->button == 3) {
-        n = 0x02;
-    } else {
-        n = 0x00;
-    }
-
-    if (button->type == GDK_BUTTON_PRESS) {
-        s->button_mask |= n;
-    } else if (button->type == GDK_BUTTON_RELEASE) {
-        s->button_mask &= ~n;
-    }
-
-    if (kbd_mouse_is_absolute()) {
-        dx = s->last_x * 0x7FFF / (surface_width(s->ds) - 1);
-        dy = s->last_y * 0x7FFF / (surface_height(s->ds) - 1);
+        btn = INPUT_BUTTON_RIGHT;
     } else {
-        dx = 0;
-        dy = 0;
+        return TRUE;
     }
 
-    kbd_mouse_event(dx, dy, 0, s->button_mask);
-        
+    qemu_input_queue_btn(s->dcl.con, btn, button->type == GDK_BUTTON_PRESS);
+    qemu_input_event_sync();
     return TRUE;
 }
 
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [Qemu-devel] [RFC PATCH 15/15] input: mouse: switch sdl ui to new core
  2013-11-28 14:29 [Qemu-devel] [RFC PATCH 00/15] input: rewrite qemu input layer Gerd Hoffmann
                   ` (13 preceding siblings ...)
  2013-11-28 14:30 ` [Qemu-devel] [RFC PATCH 14/15] input: mouse: switch gtk ui " Gerd Hoffmann
@ 2013-11-28 14:30 ` Gerd Hoffmann
  14 siblings, 0 replies; 21+ messages in thread
From: Gerd Hoffmann @ 2013-11-28 14:30 UTC (permalink / raw)
  To: qemu-devel; +Cc: Dave Airlie, Gerd Hoffmann, Anthony Liguori

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 ui/sdl.c | 65 +++++++++++++++++++++++++++++++++-------------------------------
 1 file changed, 34 insertions(+), 31 deletions(-)

diff --git a/ui/sdl.c b/ui/sdl.c
index 1b1224a..13076e3 100644
--- a/ui/sdl.c
+++ b/ui/sdl.c
@@ -357,7 +357,7 @@ static void sdl_hide_cursor(void)
     if (!cursor_hide)
         return;
 
-    if (kbd_mouse_is_absolute()) {
+    if (qemu_input_is_absolute()) {
         SDL_ShowCursor(1);
         SDL_SetCursor(sdl_cursor_hidden);
     } else {
@@ -370,10 +370,10 @@ static void sdl_show_cursor(void)
     if (!cursor_hide)
         return;
 
-    if (!kbd_mouse_is_absolute() || !qemu_console_is_graphic(NULL)) {
+    if (!qemu_input_is_absolute() || !qemu_console_is_graphic(NULL)) {
         SDL_ShowCursor(1);
         if (guest_cursor &&
-                (gui_grab || kbd_mouse_is_absolute() || absolute_enabled))
+                (gui_grab || qemu_input_is_absolute() || absolute_enabled))
             SDL_SetCursor(guest_sprite);
         else
             SDL_SetCursor(sdl_cursor_normal);
@@ -392,8 +392,9 @@ static void sdl_grab_start(void)
     }
     if (guest_cursor) {
         SDL_SetCursor(guest_sprite);
-        if (!kbd_mouse_is_absolute() && !absolute_enabled)
+        if (!qemu_input_is_absolute() && !absolute_enabled) {
             SDL_WarpMouse(guest_x, guest_y);
+        }
     } else
         sdl_hide_cursor();
     SDL_WM_GrabInput(SDL_GRAB_ON);
@@ -422,7 +423,7 @@ static void absolute_mouse_grab(void)
 
 static void sdl_mouse_mode_change(Notifier *notify, void *data)
 {
-    if (kbd_mouse_is_absolute()) {
+    if (qemu_input_is_absolute()) {
         if (!absolute_enabled) {
             absolute_enabled = 1;
             if (qemu_console_is_graphic(NULL)) {
@@ -439,31 +440,32 @@ static void sdl_mouse_mode_change(Notifier *notify, void *data)
 
 static void sdl_send_mouse_event(int dx, int dy, int dz, int x, int y, int state)
 {
-    int buttons = 0;
-
-    if (state & SDL_BUTTON(SDL_BUTTON_LEFT)) {
-        buttons |= MOUSE_EVENT_LBUTTON;
-    }
-    if (state & SDL_BUTTON(SDL_BUTTON_RIGHT)) {
-        buttons |= MOUSE_EVENT_RBUTTON;
-    }
-    if (state & SDL_BUTTON(SDL_BUTTON_MIDDLE)) {
-        buttons |= MOUSE_EVENT_MBUTTON;
-    }
-
-    if (kbd_mouse_is_absolute()) {
-        dx = x * 0x7FFF / (real_screen->w - 1);
-        dy = y * 0x7FFF / (real_screen->h - 1);
+    static uint32_t bmap[INPUT_BUTTON_MAX] = {
+        [INPUT_BUTTON_LEFT]   = SDL_BUTTON(SDL_BUTTON_LEFT),
+        [INPUT_BUTTON_MIDDLE] = SDL_BUTTON(SDL_BUTTON_MIDDLE),
+        [INPUT_BUTTON_RIGHT]  = SDL_BUTTON(SDL_BUTTON_RIGHT),
+    };
+    static uint32_t prev_state;
+
+    if (prev_state != state) {
+        qemu_input_update_buttons(dcl->con, bmap, prev_state, state);
+        prev_state = state;
+    }
+
+    if (qemu_input_is_absolute()) {
+        qemu_input_queue_abs(dcl->con, INPUT_AXIS_X, x,
+                             real_screen->w);
+        qemu_input_queue_abs(dcl->con, INPUT_AXIS_Y, y,
+                             real_screen->h);
     } else if (guest_cursor) {
         x -= guest_x;
         y -= guest_y;
         guest_x += x;
         guest_y += y;
-        dx = x;
-        dy = y;
+        qemu_input_queue_rel(dcl->con, INPUT_AXIS_X, x);
+        qemu_input_queue_rel(dcl->con, INPUT_AXIS_Y, y);
     }
-
-    kbd_mouse_event(dx, dy, dz, buttons);
+    qemu_input_event_sync();
 }
 
 static void sdl_scale(int width, int height)
@@ -691,7 +693,7 @@ static void handle_mousemotion(SDL_Event *ev)
     int max_x, max_y;
 
     if (qemu_console_is_graphic(NULL) &&
-        (kbd_mouse_is_absolute() || absolute_enabled)) {
+        (qemu_input_is_absolute() || absolute_enabled)) {
         max_x = real_screen->w - 1;
         max_y = real_screen->h - 1;
         if (gui_grab && (ev->motion.x == 0 || ev->motion.y == 0 ||
@@ -704,7 +706,7 @@ static void handle_mousemotion(SDL_Event *ev)
             sdl_grab_start();
         }
     }
-    if (gui_grab || kbd_mouse_is_absolute() || absolute_enabled) {
+    if (gui_grab || qemu_input_is_absolute() || absolute_enabled) {
         sdl_send_mouse_event(ev->motion.xrel, ev->motion.yrel, 0,
                              ev->motion.x, ev->motion.y, ev->motion.state);
     }
@@ -721,7 +723,7 @@ static void handle_mousebutton(SDL_Event *ev)
     }
 
     bev = &ev->button;
-    if (!gui_grab && !kbd_mouse_is_absolute()) {
+    if (!gui_grab && !qemu_input_is_absolute()) {
         if (ev->type == SDL_MOUSEBUTTONUP && bev->button == SDL_BUTTON_LEFT) {
             /* start grabbing all events */
             sdl_grab_start();
@@ -757,7 +759,7 @@ static void handle_activation(SDL_Event *ev)
     }
 #endif
     if (!gui_grab && ev->active.gain && qemu_console_is_graphic(NULL) &&
-        (kbd_mouse_is_absolute() || absolute_enabled)) {
+        (qemu_input_is_absolute() || absolute_enabled)) {
         absolute_mouse_grab();
     }
     if (ev->active.state & SDL_APPACTIVE) {
@@ -829,10 +831,11 @@ static void sdl_mouse_warp(DisplayChangeListener *dcl,
     if (on) {
         if (!guest_cursor)
             sdl_show_cursor();
-        if (gui_grab || kbd_mouse_is_absolute() || absolute_enabled) {
+        if (gui_grab || qemu_input_is_absolute() || absolute_enabled) {
             SDL_SetCursor(guest_sprite);
-            if (!kbd_mouse_is_absolute() && !absolute_enabled)
+            if (!qemu_input_is_absolute() && !absolute_enabled) {
                 SDL_WarpMouse(x, y);
+            }
         }
     } else if (gui_grab)
         sdl_hide_cursor();
@@ -860,7 +863,7 @@ static void sdl_mouse_define(DisplayChangeListener *dcl,
     g_free(mask);
 
     if (guest_cursor &&
-            (gui_grab || kbd_mouse_is_absolute() || absolute_enabled))
+            (gui_grab || qemu_input_is_absolute() || absolute_enabled))
         SDL_SetCursor(guest_sprite);
 }
 
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* Re: [Qemu-devel] [RFC PATCH 11/15] input: mouse: add graphic_rotate support
  2013-11-28 14:30 ` [Qemu-devel] [RFC PATCH 11/15] input: mouse: add graphic_rotate support Gerd Hoffmann
@ 2013-12-02 19:00   ` John Baboval
  2013-12-03  8:58     ` Gerd Hoffmann
  0 siblings, 1 reply; 21+ messages in thread
From: John Baboval @ 2013-12-02 19:00 UTC (permalink / raw)
  To: qemu-devel

I'm not sure this is correct. Generally when the display gets rotated, 
the input device coordinates do not, and the in-guest code handles the math.

On 11/28/2013 09:30 AM, Gerd Hoffmann wrote:
> Transform absolute mouse events according to graphic_rotate.
>
> Legacy input code does it for both absolute and relative events,
> but the logic is broken for relative coordinates, so this is
> most likely not used anyway.
>
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
>   ui/input.c | 33 +++++++++++++++++++++++++++++++++
>   1 file changed, 33 insertions(+)
>
> diff --git a/ui/input.c b/ui/input.c
> index fa6d677..abfe3a3 100644
> --- a/ui/input.c
> +++ b/ui/input.c
> @@ -50,6 +50,33 @@ qemu_input_find_handler(uint32_t mask)
>       return NULL;
>   }
>   
> +static void qemu_input_transform_abs_rotate(InputEvent *evt)
> +{
> +    switch (graphic_rotate) {
> +    case 90:
> +        if (evt->abs->axis == INPUT_AXIS_X) {
> +            evt->abs->axis = INPUT_AXIS_Y;
> +        }
> +        if (evt->abs->axis == INPUT_AXIS_Y) {
> +            evt->abs->axis = INPUT_AXIS_X;
> +            evt->abs->axis = INPUT_EVENT_ABS_SIZE - 1 - evt->abs->axis;
> +        }
> +        break;
> +    case 180:
> +        evt->abs->axis = INPUT_EVENT_ABS_SIZE - 1 - evt->abs->axis;
> +        break;
> +    case 270:
> +        if (evt->abs->axis == INPUT_AXIS_X) {
> +            evt->abs->axis = INPUT_AXIS_Y;
> +            evt->abs->axis = INPUT_EVENT_ABS_SIZE - 1 - evt->abs->axis;
> +        }
> +        if (evt->abs->axis == INPUT_AXIS_Y) {
> +            evt->abs->axis = INPUT_AXIS_X;
> +        }
> +        break;
> +    }
> +}
> +
>   void qemu_input_event_send(QemuConsole *src, InputEvent *evt)
>   {
>       QemuInputHandlerState *s;
> @@ -58,6 +85,12 @@ void qemu_input_event_send(QemuConsole *src, InputEvent *evt)
>           return;
>       }
>   
> +    /* pre processing */
> +    if (graphic_rotate && (evt->kind == INPUT_EVENT_KIND_ABS)) {
> +            qemu_input_transform_abs_rotate(evt);
> +    }
> +
> +    /* send event */
>       s = qemu_input_find_handler(1 << evt->kind);
>       s->handler->event(s->dev, src, evt);
>       s->events++;

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [Qemu-devel] [RFC PATCH 12/15] input: mouse: add qemu_input_is_absolute()
  2013-11-28 14:30 ` [Qemu-devel] [RFC PATCH 12/15] input: mouse: add qemu_input_is_absolute() Gerd Hoffmann
@ 2013-12-02 19:05   ` John Baboval
  0 siblings, 0 replies; 21+ messages in thread
From: John Baboval @ 2013-12-02 19:05 UTC (permalink / raw)
  To: qemu-devel

Perhaps this should just return the mask instead of a boolean? It would 
be nice at some point to handle a USB HID style device that can send 
both relative and absolute events, for example.

Though perhaps that would be better as future work, since this is a nice 
drop-in replacement for the old call.

On 11/28/2013 09:30 AM, Gerd Hoffmann wrote:
> Same as kbd_mouse_is_absolute(), but using new input core.
>
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
>   include/ui/input.h | 1 +
>   ui/input.c         | 8 ++++++++
>   2 files changed, 9 insertions(+)
>
> diff --git a/include/ui/input.h b/include/ui/input.h
> index 0d79342..43b9afc 100644
> --- a/include/ui/input.h
> +++ b/include/ui/input.h
> @@ -39,6 +39,7 @@ void qemu_input_queue_btn(QemuConsole *src, InputButton btn, bool down);
>   void qemu_input_update_buttons(QemuConsole *src, uint32_t *button_map,
>                                  uint32_t button_old, uint32_t button_new);
>   
> +bool qemu_input_is_absolute(void);
>   int qemu_input_scale_axis(int value, int size_in, int size_out);
>   InputEvent *qemu_input_event_new_move(InputEventKind kind,
>                                         InputAxis axis, int value);
> diff --git a/ui/input.c b/ui/input.c
> index abfe3a3..719c427 100644
> --- a/ui/input.c
> +++ b/ui/input.c
> @@ -167,6 +167,14 @@ void qemu_input_update_buttons(QemuConsole *src, uint32_t *button_map,
>       }
>   }
>   
> +bool qemu_input_is_absolute(void)
> +{
> +    QemuInputHandlerState *s;
> +
> +    s = qemu_input_find_handler(INPUT_EVENT_MASK_REL | INPUT_EVENT_MASK_ABS);
> +    return (s != NULL) && (s->handler->mask & INPUT_EVENT_MASK_ABS);
> +}
> +
>   int qemu_input_scale_axis(int value, int size_in, int size_out)
>   {
>       if (size_in < 2) {

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [Qemu-devel] [RFC PATCH 03/15] input: define event types using qapi
  2013-11-28 14:29 ` [Qemu-devel] [RFC PATCH 03/15] input: define event types using qapi Gerd Hoffmann
@ 2013-12-02 19:12   ` Eric Blake
  2013-12-03  8:11     ` Gerd Hoffmann
  0 siblings, 1 reply; 21+ messages in thread
From: Eric Blake @ 2013-12-02 19:12 UTC (permalink / raw)
  To: Gerd Hoffmann, qemu-devel; +Cc: Dave Airlie, Markus Armbruster, Luiz Capitulino

[-- Attachment #1: Type: text/plain, Size: 2055 bytes --]

On 11/28/2013 07:29 AM, Gerd Hoffmann wrote:
> Define input event types, using qapi.  So we get nicely autogenerated
> types for our input events.  And when it comes to qmp support some day
> things will be alot easier.
> 
> Types are modeled after the linux input layer.  There are separate
> event types for each value.  There is a sync to indicate the end
> of a event group.
> 
> Mouse events are splitted into motion events (one for each axis) and

s/splitted/split/ (yes, one of those stupid English words whose
past-tense spelling is the same as its present tense)

> button events, which are grouped by sync.
> 
> Keyboard events are using keycodes instead of scancodes, so we can
> rid of the keycode->scancode transformation everywhere in the
> ui code.
> 
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
>  qapi-schema.json | 29 +++++++++++++++++++++++++++++
>  1 file changed, 29 insertions(+)

> +
> +
> +###########################################################
> +# WIP - input event data structures
> +# not exposed via qmp yet, needs testing first

But still worth documenting, and adding "Since 2.0" annotations to each
enum and struct.

> +
> +{ 'enum'  : 'InputButton',
> +  'data'  : [ 'Left', 'Middle', 'Right' ] }
> +
> +{ 'enum'  : 'InputAxis',
> +  'data'  : [ 'X', 'Y' ] }
> +
> +{ 'type'  : 'InputKeyEvent',
> +  'data'  : { 'keycode' : 'int',
> +              'down'    : 'bool' } }
> +
> +{ 'type'  : 'InputBtnEvent',
> +  'data'  : { 'button'  : 'InputButton',
> +              'down'    : 'bool' } }
> +
> +{ 'type'  : 'InputMoveEvent',
> +  'data'  : { 'axis'    : 'InputAxis',
> +              'value'   : 'int' } }
> +
> +{ 'union' : 'InputEvent',
> +  'data'  : { 'key'     : 'InputKeyEvent',
> +              'btn'     : 'InputBtnEvent',
> +              'rel'     : 'InputMoveEvent',
> +              'abs'     : 'InputMoveEvent' } }
> 

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 621 bytes --]

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [Qemu-devel] [RFC PATCH 03/15] input: define event types using qapi
  2013-12-02 19:12   ` Eric Blake
@ 2013-12-03  8:11     ` Gerd Hoffmann
  0 siblings, 0 replies; 21+ messages in thread
From: Gerd Hoffmann @ 2013-12-03  8:11 UTC (permalink / raw)
  To: Eric Blake; +Cc: Markus Armbruster, Dave Airlie, qemu-devel, Luiz Capitulino

On Mo, 2013-12-02 at 12:12 -0700, Eric Blake wrote:
> On 11/28/2013 07:29 AM, Gerd Hoffmann wrote:
> > Define input event types, using qapi.  So we get nicely autogenerated
> > types for our input events.  And when it comes to qmp support some day
> > things will be alot easier.
> > 
> > Types are modeled after the linux input layer.  There are separate
> > event types for each value.  There is a sync to indicate the end
> > of a event group.
> > 
> > Mouse events are splitted into motion events (one for each axis) and
> 
> s/splitted/split/ (yes, one of those stupid English words whose
> past-tense spelling is the same as its present tense)

Thanks for the explanation.  That hopefully makes it a bit easier to
remember.

> > +###########################################################
> > +# WIP - input event data structures
> > +# not exposed via qmp yet, needs testing first
> 
> But still worth documenting, and adding "Since 2.0" annotations to each
> enum and struct.

Sure, already on the todo list for the final patch version.

cheers,
  Gerd

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [Qemu-devel] [RFC PATCH 11/15] input: mouse: add graphic_rotate support
  2013-12-02 19:00   ` John Baboval
@ 2013-12-03  8:58     ` Gerd Hoffmann
  0 siblings, 0 replies; 21+ messages in thread
From: Gerd Hoffmann @ 2013-12-03  8:58 UTC (permalink / raw)
  To: John Baboval; +Cc: qemu-devel

On Mo, 2013-12-02 at 14:00 -0500, John Baboval wrote:
> I'm not sure this is correct. Generally when the display gets rotated, 
> the input device coordinates do not, and the in-guest code handles the math.

This just mimics what kbd_mouse_event() does today.  I guess there is a
reason this code was added.

I suspect it's some embedded target which depend on this stuff.
Anyone knows?

cheers,
  Gerd

^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2013-12-03  8:58 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-28 14:29 [Qemu-devel] [RFC PATCH 00/15] input: rewrite qemu input layer Gerd Hoffmann
2013-11-28 14:29 ` [Qemu-devel] [RFC PATCH 01/15] console: export QemuConsole index, width, height Gerd Hoffmann
2013-11-28 14:29 ` [Qemu-devel] [RFC PATCH 02/15] input: rename file to legacy Gerd Hoffmann
2013-11-28 14:29 ` [Qemu-devel] [RFC PATCH 03/15] input: define event types using qapi Gerd Hoffmann
2013-12-02 19:12   ` Eric Blake
2013-12-03  8:11     ` Gerd Hoffmann
2013-11-28 14:29 ` [Qemu-devel] [RFC PATCH 04/15] input: add core bits of the new input layer Gerd Hoffmann
2013-11-28 14:30 ` [Qemu-devel] [RFC PATCH 05/15] input: keyboard: add helper functions to core Gerd Hoffmann
2013-11-28 14:30 ` [Qemu-devel] [RFC PATCH 06/15] input: keyboard: switch legacy handlers to new core Gerd Hoffmann
2013-11-28 14:30 ` [Qemu-devel] [RFC PATCH 07/15] input: keyboard: switch qmp_send_key() " Gerd Hoffmann
2013-11-28 14:30 ` [Qemu-devel] [RFC PATCH 08/15] input: keyboard: switch gtk ui " Gerd Hoffmann
2013-11-28 14:30 ` [Qemu-devel] [RFC PATCH 09/15] input: keyboard: switch sdl ui to new core [wip] Gerd Hoffmann
2013-11-28 14:30 ` [Qemu-devel] [RFC PATCH 10/15] input: mouse: add helpers functions to core Gerd Hoffmann
2013-11-28 14:30 ` [Qemu-devel] [RFC PATCH 11/15] input: mouse: add graphic_rotate support Gerd Hoffmann
2013-12-02 19:00   ` John Baboval
2013-12-03  8:58     ` Gerd Hoffmann
2013-11-28 14:30 ` [Qemu-devel] [RFC PATCH 12/15] input: mouse: add qemu_input_is_absolute() Gerd Hoffmann
2013-12-02 19:05   ` John Baboval
2013-11-28 14:30 ` [Qemu-devel] [RFC PATCH 13/15] input: mouse: switch legacy handlers to new core Gerd Hoffmann
2013-11-28 14:30 ` [Qemu-devel] [RFC PATCH 14/15] input: mouse: switch gtk ui " Gerd Hoffmann
2013-11-28 14:30 ` [Qemu-devel] [RFC PATCH 15/15] input: mouse: switch sdl " Gerd Hoffmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).