From: "Michael S. Tsirkin" <mst@redhat.com>
To: "Marc-André Lureau" <marcandre.lureau@redhat.com>
Cc: qemu-devel@nongnu.org, Gerd Hoffmann <kraxel@redhat.com>
Subject: Re: [Qemu-devel] [PATCH] virtio-input: send rel-wheel events for wheel buttons
Date: Wed, 9 Aug 2017 05:33:33 +0300 [thread overview]
Message-ID: <20170809050846-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <20170808224750.23904-1-marcandre.lureau@redhat.com>
On Wed, Aug 09, 2017 at 12:47:50AM +0200, Marc-André Lureau wrote:
> qemu uses wheel-up/down button events for mouse wheel input, however
> linux applications typically want REL_WHEEL events.
>
> This fixes wheel with linux guests. Tested with X11/wayland, and
> windows virtio-input driver.
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
> hw/input/virtio-input-hid.c | 15 +++++++++++----
> 1 file changed, 11 insertions(+), 4 deletions(-)
>
> diff --git a/hw/input/virtio-input-hid.c b/hw/input/virtio-input-hid.c
> index 46c038110c..f46857f0e4 100644
> --- a/hw/input/virtio-input-hid.c
> +++ b/hw/input/virtio-input-hid.c
> @@ -196,6 +196,7 @@ static void virtio_input_handle_event(DeviceState *dev, QemuConsole *src,
> InputKeyEvent *key;
> InputMoveEvent *move;
> InputBtnEvent *btn;
> + unsigned int map;
>
> switch (evt->type) {
> case INPUT_EVENT_KIND_KEY:
> @@ -215,9 +216,15 @@ static void virtio_input_handle_event(DeviceState *dev, QemuConsole *src,
> break;
> case INPUT_EVENT_KIND_BTN:
> btn = evt->u.btn.data;
> - if (keymap_button[btn->button]) {
> + map = keymap_button[btn->button];
> + if (map == BTN_GEAR_DOWN || map == BTN_GEAR_UP) {
> + event.type = cpu_to_le16(EV_REL);
> + event.code = cpu_to_le16(REL_WHEEL);
> + event.value = cpu_to_le32(map == BTN_GEAR_DOWN ? -1 : 1);
I realize now that value is actually a signed integer in 2's complement
format. Unfortunate that it's not documented.
> + virtio_input_send(vinput, &event);
> + } else if (map) {
> event.type = cpu_to_le16(EV_KEY);
> - event.code = cpu_to_le16(keymap_button[btn->button]);
> + event.code = cpu_to_le16(map);
> event.value = cpu_to_le32(btn->down ? 1 : 0);
> virtio_input_send(vinput, &event);
> } else {
> @@ -424,9 +431,9 @@ static struct virtio_input_config virtio_mouse_config[] = {
> },{
> .select = VIRTIO_INPUT_CFG_EV_BITS,
> .subsel = EV_REL,
> - .size = 1,
> + .size = 2,
> .u.bitmap = {
> - (1 << REL_X) | (1 << REL_Y),
> + (1 << REL_X) | (1 << REL_Y), (1 << (REL_WHEEL - 8))
Works only when REL_WHEEL is between 8 and 15.
Add BUILD_BUG_ON?
> },
> },
> { /* end of list */ },
Is it problematic e.g. if you migrate from a host with REL_WHEEL
to one without? Should we maintain a version without REL_WHEEL
for old machine types?
> --
> 2.14.0.1.geff633fa0
next prev parent reply other threads:[~2017-08-09 2:33 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-08 22:47 [Qemu-devel] [PATCH] virtio-input: send rel-wheel events for wheel buttons Marc-André Lureau
2017-08-09 2:33 ` Michael S. Tsirkin [this message]
2017-08-21 13:27 ` Gerd Hoffmann
2017-08-21 13:23 ` Gerd Hoffmann
2017-08-21 13:51 ` Marc-André Lureau
-- strict thread matches above, loose matches on Subject: below --
2017-08-23 13:51 Gerd Hoffmann
2017-08-23 14:38 ` Marc-André Lureau
2017-08-23 14:49 ` Gerd Hoffmann
2017-08-29 7:48 ` Ladi Prosek
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=20170809050846-mutt-send-email-mst@kernel.org \
--to=mst@redhat.com \
--cc=kraxel@redhat.com \
--cc=marcandre.lureau@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).