From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: Philippe Voinov <philippevoinov@gmail.com>,
Gerd Hoffmann <kraxel@redhat.com>
Subject: [Qemu-devel] [PULL 02/10] ui: input-linux: Add absolute event support
Date: Fri, 12 May 2017 13:51:27 +0200 [thread overview]
Message-ID: <20170512115135.17379-3-kraxel@redhat.com> (raw)
In-Reply-To: <20170512115135.17379-1-kraxel@redhat.com>
From: Philippe Voinov <philippevoinov@gmail.com>
This patch adds support for absolute pointer events to the input-linux
subsystem. This support was omitted from the original input-linux patch,
however most of the code required for it is already in place.
Support for absolute events is especially useful for guests with vga
passthrough. Since they have a physical monitor, none of normal channels
for sending video output (vnc, etc) are used, meaning they also can't be
used to send absolute input events. This leaves QMP as the only option
to send absolute input into vga passthrough guests, which is not its
intended use and is not efficient.
This patch allows, for example, uinput to be used to create virtual
absolute input devices. This lets you build external systems which share
physical input devices between guests. Without absolute input
capability, such external systems can't seamlessly share pointer devices
between guests.
Signed-off-by: Philippe Voinov <philippevoinov@gmail.com>
Message-id: 20170505134231.30210-1-philippevoinov@gmail.com
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
ui/input-linux.c | 25 ++++++++++++++++++++++++-
1 file changed, 24 insertions(+), 1 deletion(-)
diff --git a/ui/input-linux.c b/ui/input-linux.c
index dc0613ca1f..49d52a69cc 100644
--- a/ui/input-linux.c
+++ b/ui/input-linux.c
@@ -169,6 +169,10 @@ struct InputLinux {
bool has_abs_x;
int num_keys;
int num_btns;
+ int abs_x_min;
+ int abs_x_max;
+ int abs_y_min;
+ int abs_y_max;
struct input_event event;
int read_offset;
@@ -314,6 +318,18 @@ static void input_linux_handle_mouse(InputLinux *il, struct input_event *event)
break;
}
break;
+ case EV_ABS:
+ switch (event->code) {
+ case ABS_X:
+ qemu_input_queue_abs(NULL, INPUT_AXIS_X, event->value,
+ il->abs_x_min, il->abs_x_max);
+ break;
+ case ABS_Y:
+ qemu_input_queue_abs(NULL, INPUT_AXIS_Y, event->value,
+ il->abs_y_min, il->abs_y_max);
+ break;
+ }
+ break;
case EV_SYN:
qemu_input_event_sync();
if (il->wheel != 0) {
@@ -351,7 +367,7 @@ static void input_linux_event(void *opaque)
if (il->num_keys) {
input_linux_handle_keyboard(il, &il->event);
}
- if (il->has_rel_x && il->num_btns) {
+ if ((il->has_rel_x || il->has_abs_x) && il->num_btns) {
input_linux_handle_mouse(il, &il->event);
}
}
@@ -364,6 +380,7 @@ static void input_linux_complete(UserCreatable *uc, Error **errp)
uint8_t keymap[KEY_CNT / 8], keystate[KEY_CNT / 8];
unsigned int i;
int rc, ver;
+ struct input_absinfo absinfo;
if (!il->evdev) {
error_setg(errp, "no input device specified");
@@ -402,6 +419,12 @@ static void input_linux_complete(UserCreatable *uc, Error **errp)
rc = ioctl(il->fd, EVIOCGBIT(EV_ABS, sizeof(absmap)), &absmap);
if (absmap & (1 << ABS_X)) {
il->has_abs_x = true;
+ rc = ioctl(il->fd, EVIOCGABS(ABS_X), &absinfo);
+ il->abs_x_min = absinfo.minimum;
+ il->abs_x_max = absinfo.maximum;
+ rc = ioctl(il->fd, EVIOCGABS(ABS_Y), &absinfo);
+ il->abs_y_min = absinfo.minimum;
+ il->abs_y_max = absinfo.maximum;
}
}
--
2.9.3
next prev parent reply other threads:[~2017-05-12 11:51 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-12 11:51 [Qemu-devel] [PULL 00/10] ui patch queue Gerd Hoffmann
2017-05-12 11:51 ` [Qemu-devel] [PULL 01/10] ui: Support non-zero minimum values for absolute input axes Gerd Hoffmann
2017-05-12 11:51 ` Gerd Hoffmann [this message]
2017-05-12 11:51 ` [Qemu-devel] [PULL 03/10] virtio-gpu: move virtio_gpu_gl_block Gerd Hoffmann
2017-05-12 11:51 ` [Qemu-devel] [PULL 04/10] egl-helpers: drop support for gles and debug logging Gerd Hoffmann
2017-05-12 11:51 ` [Qemu-devel] [PULL 05/10] egl-helpers: fix display init for x11 Gerd Hoffmann
2017-05-12 11:51 ` [Qemu-devel] [PULL 06/10] egl-helpers: add missing error check Gerd Hoffmann
2017-05-12 11:51 ` [Qemu-devel] [PULL 07/10] egl: explicitly ask for core context Gerd Hoffmann
2017-05-12 11:51 ` [Qemu-devel] [PULL 08/10] opengl: add egl-headless display Gerd Hoffmann
2017-05-12 11:51 ` [Qemu-devel] [PULL 09/10] vnc: simple clean up Gerd Hoffmann
2017-05-12 11:51 ` [Qemu-devel] [PULL 10/10] vnc: replace hweight_long() with ctpopl() Gerd Hoffmann
2017-05-15 13:29 ` [Qemu-devel] [PULL 00/10] ui patch queue Stefan Hajnoczi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170512115135.17379-3-kraxel@redhat.com \
--to=kraxel@redhat.com \
--cc=philippevoinov@gmail.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).