diff options
author | Miika S <miika9764@gmail.com> | 2017-12-22 17:25:31 +0200 |
---|---|---|
committer | Gerd Hoffmann <kraxel@redhat.com> | 2018-01-29 09:30:25 +0100 |
commit | a5f99be41ee8d874ab63c4abf733c91a483a28d4 (patch) | |
tree | 9cee7db09da10693b08f67207c6eff71a36dd11b | |
parent | 2416760fa6728813e1446736e9be55e07b5030b0 (diff) |
input: virtio: don't send mouse wheel event twice
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>
Message-Id: <20171222152531.1849-4-miika9764@gmail.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
-rw-r--r-- | hw/input/virtio-input-hid.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/hw/input/virtio-input-hid.c b/hw/input/virtio-input-hid.c index a5917c2754..be054fd272 100644 --- a/hw/input/virtio-input-hid.c +++ b/hw/input/virtio-input-hid.c @@ -218,8 +218,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 |