[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 14/19] virtio-input: generalize virtio_input_key_config()
|
From: |
marcandre . lureau |
|
Subject: |
[PULL 14/19] virtio-input: generalize virtio_input_key_config() |
|
Date: |
Sun, 28 May 2023 17:20:11 +0400 |
From: Sergio Lopez <slp@redhat.com>
As there are other bitmap-based config properties that need to be dealt in a
similar fashion as VIRTIO_INPUT_CFG_EV_BITS, generalize the function to
receive select and subsel as arguments, and rename it to
virtio_input_extend_config()
Signed-off-by: Sergio Lopez <slp@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20230526112925.38794-2-slp@redhat.com>
---
hw/input/virtio-input-hid.c | 38 ++++++++++++++++++++-----------------
1 file changed, 21 insertions(+), 17 deletions(-)
diff --git a/hw/input/virtio-input-hid.c b/hw/input/virtio-input-hid.c
index a7a244a95d..d28dab69ba 100644
--- a/hw/input/virtio-input-hid.c
+++ b/hw/input/virtio-input-hid.c
@@ -44,30 +44,31 @@ static const unsigned short axismap_abs[INPUT_AXIS__MAX] = {
/* ----------------------------------------------------------------- */
-static void virtio_input_key_config(VirtIOInput *vinput,
- const unsigned short *keymap,
- size_t mapsize)
+static void virtio_input_extend_config(VirtIOInput *vinput,
+ const unsigned short *map,
+ size_t mapsize,
+ uint8_t select, uint8_t subsel)
{
- virtio_input_config keys;
+ virtio_input_config ext;
int i, bit, byte, bmax = 0;
- memset(&keys, 0, sizeof(keys));
+ memset(&ext, 0, sizeof(ext));
for (i = 0; i < mapsize; i++) {
- bit = keymap[i];
+ bit = map[i];
if (!bit) {
continue;
}
byte = bit / 8;
bit = bit % 8;
- keys.u.bitmap[byte] |= (1 << bit);
+ ext.u.bitmap[byte] |= (1 << bit);
if (bmax < byte+1) {
bmax = byte+1;
}
}
- keys.select = VIRTIO_INPUT_CFG_EV_BITS;
- keys.subsel = EV_KEY;
- keys.size = bmax;
- virtio_input_add_config(vinput, &keys);
+ ext.select = select;
+ ext.subsel = subsel;
+ ext.size = bmax;
+ virtio_input_add_config(vinput, &ext);
}
static void virtio_input_handle_event(DeviceState *dev, QemuConsole *src,
@@ -281,8 +282,9 @@ static void virtio_keyboard_init(Object *obj)
vhid->handler = &virtio_keyboard_handler;
virtio_input_init_config(vinput, virtio_keyboard_config);
- virtio_input_key_config(vinput, qemu_input_map_qcode_to_linux,
- qemu_input_map_qcode_to_linux_len);
+ virtio_input_extend_config(vinput, qemu_input_map_qcode_to_linux,
+ qemu_input_map_qcode_to_linux_len,
+ VIRTIO_INPUT_CFG_EV_BITS, EV_KEY);
}
static const TypeInfo virtio_keyboard_info = {
@@ -373,8 +375,9 @@ static void virtio_mouse_init(Object *obj)
virtio_input_init_config(vinput, vhid->wheel_axis
? virtio_mouse_config_v2
: virtio_mouse_config_v1);
- virtio_input_key_config(vinput, keymap_button,
- ARRAY_SIZE(keymap_button));
+ virtio_input_extend_config(vinput, keymap_button,
+ ARRAY_SIZE(keymap_button),
+ VIRTIO_INPUT_CFG_EV_BITS, EV_KEY);
}
static const TypeInfo virtio_mouse_info = {
@@ -497,8 +500,9 @@ static void virtio_tablet_init(Object *obj)
virtio_input_init_config(vinput, vhid->wheel_axis
? virtio_tablet_config_v2
: virtio_tablet_config_v1);
- virtio_input_key_config(vinput, keymap_button,
- ARRAY_SIZE(keymap_button));
+ virtio_input_extend_config(vinput, keymap_button,
+ ARRAY_SIZE(keymap_button),
+ VIRTIO_INPUT_CFG_EV_BITS, EV_KEY);
}
static const TypeInfo virtio_tablet_info = {
--
2.40.1
- [PULL 04/19] ui/sdl2: fix surface_gl_update_texture: Assertion 'gls' failed, (continued)
- [PULL 04/19] ui/sdl2: fix surface_gl_update_texture: Assertion 'gls' failed, marcandre . lureau, 2023/05/28
- [PULL 05/19] ui/dbus: fix compilation when GBM && !OPENGL, marcandre . lureau, 2023/05/28
- [PULL 06/19] win32: wrap socket close() with an exception handler, marcandre . lureau, 2023/05/28
- [PULL 07/19] virtio-gpu: add a FIXME for virtio_gpu_load(), marcandre . lureau, 2023/05/28
- [PULL 08/19] gtk: add gl-area support on win32, marcandre . lureau, 2023/05/28
- [PULL 09/19] ui/dbus: add a FIXME about texture/dmabuf scanout handling, marcandre . lureau, 2023/05/28
- [PULL 10/19] ui/sdl2: Grab Alt+Tab also in fullscreen mode, marcandre . lureau, 2023/05/28
- [PULL 11/19] ui/sdl2: Grab Alt+F4 also under Windows, marcandre . lureau, 2023/05/28
- [PULL 12/19] ui/sdl2: disable SDL_HINT_GRAB_KEYBOARD on Windows, marcandre . lureau, 2023/05/28
- [PULL 13/19] ui/cursor: make width/height unsigned 16-bit integer, marcandre . lureau, 2023/05/28
- [PULL 14/19] virtio-input: generalize virtio_input_key_config(),
marcandre . lureau <=
- [PULL 15/19] ui: add the infrastructure to support MT events, marcandre . lureau, 2023/05/28
- [PULL 16/19] virtio-input: add a virtio-mulitouch device, marcandre . lureau, 2023/05/28
- [PULL 17/19] virtio-input-pci: add virtio-multitouch-pci, marcandre . lureau, 2023/05/28
- [PULL 18/19] ui: add helpers for virtio-multitouch events, marcandre . lureau, 2023/05/28
- [PULL 19/19] ui/gtk: enable backend to send multi-touch events, marcandre . lureau, 2023/05/28
- Re: [PULL 00/19] Ui patches, Michael Tokarev, 2023/05/28
- Re: [PULL 00/19] Ui patches, Richard Henderson, 2023/05/29