From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: Gerd Hoffmann <kraxel@redhat.com>
Subject: [Qemu-devel] [PULL v2 8/9] input-linux: refine mouse detection
Date: Wed, 13 Apr 2016 17:45:02 +0200 [thread overview]
Message-ID: <1460562303-17079-9-git-send-email-kraxel@redhat.com> (raw)
In-Reply-To: <1460562303-17079-1-git-send-email-kraxel@redhat.com>
Read absolute and relative axis information, only classify
devices as mouse/tablet in case the x axis is present.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
ui/input-linux.c | 30 +++++++++++++++++++++++++-----
1 file changed, 25 insertions(+), 5 deletions(-)
diff --git a/ui/input-linux.c b/ui/input-linux.c
index 9c921cc..1d33b5c 100644
--- a/ui/input-linux.c
+++ b/ui/input-linux.c
@@ -337,7 +337,7 @@ static void input_linux_event_mouse(void *opaque)
static void input_linux_complete(UserCreatable *uc, Error **errp)
{
InputLinux *il = INPUT_LINUX(uc);
- uint32_t evtmap;
+ uint32_t evtmap, relmap, absmap;
int rc, ver;
if (!il->evdev) {
@@ -359,16 +359,36 @@ static void input_linux_complete(UserCreatable *uc, Error **errp)
}
rc = ioctl(il->fd, EVIOCGBIT(0, sizeof(evtmap)), &evtmap);
+ if (rc < 0) {
+ error_setg(errp, "%s: failed to read event bits", il->evdev);
+ goto err_close;
+ }
if (evtmap & (1 << EV_REL)) {
- /* has relative axis -> assume mouse */
+ rc = ioctl(il->fd, EVIOCGBIT(EV_REL, sizeof(relmap)), &relmap);
+ if (rc < 0) {
+ relmap = 0;
+ }
+ }
+
+ if (evtmap & (1 << EV_ABS)) {
+ ioctl(il->fd, EVIOCGBIT(EV_ABS, sizeof(absmap)), &absmap);
+ if (rc < 0) {
+ absmap = 0;
+ }
+ }
+
+ if ((evtmap & (1 << EV_REL)) &&
+ (relmap & (1 << REL_X))) {
+ /* has relative x axis -> assume mouse */
qemu_set_fd_handler(il->fd, input_linux_event_mouse, NULL, il);
- } else if (evtmap & (1 << EV_ABS)) {
- /* has absolute axis -> not supported */
+ } else if ((evtmap & (1 << EV_ABS)) &&
+ (absmap & (1 << ABS_X))) {
+ /* has absolute x axis -> not supported */
error_setg(errp, "tablet/touchscreen not supported");
goto err_close;
} else if (evtmap & (1 << EV_KEY)) {
- /* has keys/buttons (and no axis) -> assume keyboard */
+ /* has keys/buttons (and no x axis) -> assume keyboard */
qemu_set_fd_handler(il->fd, input_linux_event_keyboard, NULL, il);
} else {
/* Huh? What is this? */
--
1.8.3.1
next prev parent reply other threads:[~2016-04-13 15:45 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-13 15:44 [Qemu-devel] [PULL v2 0/9] virtio-input; live migration support, various bugfixes Gerd Hoffmann
2016-04-13 15:44 ` [Qemu-devel] [PULL v2 1/9] virtio-input: add parenthesis to const_le{16, 32} Gerd Hoffmann
2016-04-13 15:44 ` [Qemu-devel] [PULL v2 2/9] move const_le{16, 23} to qemu/bswap.h, add comment Gerd Hoffmann
2016-04-13 15:44 ` [Qemu-devel] [PULL v2 3/9] virtio-input: add missing key mappings Gerd Hoffmann
2016-04-13 15:44 ` [Qemu-devel] [PULL v2 4/9] virtio-input: retrieve EV_LED host config bits Gerd Hoffmann
2016-04-13 15:44 ` [Qemu-devel] [PULL v2 5/9] virtio-input: implement pass-through evdev writes Gerd Hoffmann
2016-04-13 15:45 ` [Qemu-devel] [PULL v2 6/9] virtio-input: add live migration support Gerd Hoffmann
2016-04-13 15:45 ` [Qemu-devel] [PULL v2 7/9] virtio-input: fix emulated tablet axis ranges Gerd Hoffmann
2016-04-13 15:45 ` Gerd Hoffmann [this message]
2016-04-14 7:42 ` [Qemu-devel] [PULL v2 8/9] input-linux: refine mouse detection Ladi Prosek
2016-04-14 8:07 ` Gerd Hoffmann
2016-04-13 15:45 ` [Qemu-devel] [PULL v2 9/9] virtio-input: support absolute axis config in pass-through Gerd Hoffmann
2016-04-14 9:06 ` [Qemu-devel] [PULL v2 0/9] virtio-input; live migration support, various bugfixes Peter Maydell
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=1460562303-17079-9-git-send-email-kraxel@redhat.com \
--to=kraxel@redhat.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).