qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Miika S <miika9764@gmail.com>
To: qemu-devel@nongnu.org
Cc: kraxel@redhat.com, berrange@redhat.com, Miika S <miika9764@gmail.com>
Subject: [Qemu-devel] [PATCH 3/3] input: virtio: don't send mouse wheel event twice
Date: Fri, 22 Dec 2017 17:25:31 +0200	[thread overview]
Message-ID: <20171222152531.1849-4-miika9764@gmail.com> (raw)
In-Reply-To: <20171222152531.1849-1-miika9764@gmail.com>

On Linux, a mouse event is generated for both down and up when mouse
wheel is used. This caused virtio_input_send() to be called twice each
time the wheel was used.

This commit adds a check for the button down state and only calls
virtio_input_send() when it is true.

Signed-off-by: Miika S <miika9764@gmail.com>
---
 hw/input/virtio-input-hid.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/hw/input/virtio-input-hid.c b/hw/input/virtio-input-hid.c
index 2cac659469..587616a932 100644
--- a/hw/input/virtio-input-hid.c
+++ b/hw/input/virtio-input-hid.c
@@ -225,8 +225,10 @@ static void virtio_input_handle_event(DeviceState *dev, QemuConsole *src,
         break;
     case INPUT_EVENT_KIND_BTN:
         btn = evt->u.btn.data;
-        if (vhid->wheel_axis && (btn->button == INPUT_BUTTON_WHEEL_UP ||
-                                 btn->button == INPUT_BUTTON_WHEEL_DOWN)) {
+        if (vhid->wheel_axis &&
+            (btn->button == INPUT_BUTTON_WHEEL_UP ||
+             btn->button == INPUT_BUTTON_WHEEL_DOWN) &&
+            btn->down) {
             event.type  = cpu_to_le16(EV_REL);
             event.code  = cpu_to_le16(REL_WHEEL);
             event.value = cpu_to_le32(btn->button == INPUT_BUTTON_WHEEL_UP
-- 
2.15.1

  parent reply	other threads:[~2017-12-22 15:26 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-22 15:25 [Qemu-devel] [PATCH 0/3] input: add keys and mouse buttons to virtio input Miika S
2017-12-22 15:25 ` [Qemu-devel] [PATCH 1/3] input: add missing JIS keys " Miika S
2018-01-15 10:40   ` Daniel P. Berrange
2017-12-22 15:25 ` [Qemu-devel] [PATCH 2/3] input: add mouse side buttons " Miika S
2017-12-22 15:25 ` Miika S [this message]
2018-01-15 15:18 ` [Qemu-devel] [PATCH 0/3] input: add keys and mouse " Gerd Hoffmann
2018-01-15 15:32   ` Daniel P. Berrange
2018-01-25 15:29     ` Gerd Hoffmann
2018-01-25 15:33       ` Daniel P. Berrangé
  -- strict thread matches above, loose matches on Subject: below --
2017-12-18 13:24 [Qemu-devel] [PATCH 1/3] input: add missing JIS keys " Miika S
2017-12-18 13:24 ` [Qemu-devel] [PATCH 3/3] input: virtio: don't send mouse wheel event twice Miika S

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=20171222152531.1849-4-miika9764@gmail.com \
    --to=miika9764@gmail.com \
    --cc=berrange@redhat.com \
    --cc=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).