[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 20/42] input: mouse: add graphic_rotate support
From: |
Paolo Bonzini |
Subject: |
Re: [Qemu-devel] [PATCH 20/42] input: mouse: add graphic_rotate support |
Date: |
Fri, 31 Jan 2014 23:23:12 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 |
Il 28/01/2014 10:57, Gerd Hoffmann ha scritto:
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 <address@hidden>
---
ui/input.c | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/ui/input.c b/ui/input.c
index a02172e..2c4d4d6 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) {
Need else here, same for "case 270".
+ evt->abs->axis = INPUT_AXIS_X;
+ evt->abs->axis = INPUT_EVENT_ABS_SIZE - 1 - evt->abs->axis;
->value here, not ->axis.
It looks like doing it right for relative is easy:
if (graphic_rotate == 0) {
return;
}
if (move->axis != INPUT_AXIS_X && move->axis != INPUT_AXIS_Y) {
return;
}
if ((graphic_rotate <= 180 && move->axis == INPUT_AXIS_X) ||
(graphic_rotate >= 180 && move->axis == INPUT_AXIS_Y)) {
if (kind == INPUT_EVENT_KIND_ABS) {
move->value = INPUT_EVENT_ABS_SIZE - 1 - move->value;
} else {
move->value = -move->value;
}
}
if (graphic_rotate == 90 || graphic_rotate == 270) {
move->axis ^= INPUT_AXIS_X ^ INPUT_AXIS_Y;
}
...
if (evt->kind == INPUT_EVENT_KIND_ABS) {
qemu_input_transform_rotate(evt->kind, &evt->abs);
} else if (evt->kind == INPUT_EVENT_KIND_REL) {
qemu_input_transform_rotate(evt->kind, &evt->rel);
}
Paolo
+ }
+ 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++;
- [Qemu-devel] [PATCH 27/42] input: mouse: switch spice ui to new core, (continued)
- [Qemu-devel] [PATCH 27/42] input: mouse: switch spice ui to new core, Gerd Hoffmann, 2014/01/28
- [Qemu-devel] [PATCH 15/42] sdl2: switch keyboard handling to new core, Gerd Hoffmann, 2014/01/28
- [Qemu-devel] [PATCH 06/42] input: qapi: define event types, Gerd Hoffmann, 2014/01/28
- [Qemu-devel] [PATCH 26/42] input: mouse: switch vnc ui to new core, Gerd Hoffmann, 2014/01/28
- [Qemu-devel] [PATCH 22/42] input: mouse: switch legacy handlers to new core, Gerd Hoffmann, 2014/01/28
- [Qemu-devel] [PATCH 35/42] input-legacy: remove kbd_mouse_event, Gerd Hoffmann, 2014/01/28
- [Qemu-devel] [PATCH 31/42] input: trace events, Gerd Hoffmann, 2014/01/28
- [Qemu-devel] [PATCH 33/42] input-legacy: remove kbd_mouse_has_absolute, Gerd Hoffmann, 2014/01/28
- [Qemu-devel] [PATCH 20/42] input: mouse: add graphic_rotate support, Gerd Hoffmann, 2014/01/28
- Re: [Qemu-devel] [PATCH 20/42] input: mouse: add graphic_rotate support,
Paolo Bonzini <=
- [Qemu-devel] [PATCH 34/42] input-legacy: remove kbd_mouse_is_absolute, Gerd Hoffmann, 2014/01/28
- [Qemu-devel] [PATCH 40/42] input: move qmp_query_mice to new core, Gerd Hoffmann, 2014/01/28
- [Qemu-devel] [PATCH 36/42] input: move mouse mode notifier to new core, Gerd Hoffmann, 2014/01/28
- [Qemu-devel] [PATCH 32/42] input-legacy: remove kbd_put_keycode, Gerd Hoffmann, 2014/01/28
- [Qemu-devel] [PATCH 37/42] input: add input_mouse_mode tracepoint, Gerd Hoffmann, 2014/01/28
- [Qemu-devel] [PATCH 41/42] input: move do_mouse_set to new core, Gerd Hoffmann, 2014/01/28
- [Qemu-devel] [PATCH 07/42] input: qapi: add unmapped key, Gerd Hoffmann, 2014/01/28
- [Qemu-devel] [PATCH 29/42] input: keyboard: switch cocoa ui to new core, Gerd Hoffmann, 2014/01/28
- [Qemu-devel] [PATCH 19/42] input: mouse: add helpers functions to core, Gerd Hoffmann, 2014/01/28