[PATCH 3/4] ui: add helpers for virtio-multitouch events

Sergio Lopez posted 4 patches 2 years, 11 months ago
Maintainers: "Michael S. Tsirkin" <mst@redhat.com>, Gerd Hoffmann <kraxel@redhat.com>, Eric Blake <eblake@redhat.com>, Markus Armbruster <armbru@redhat.com>, Pavel Dovgalyuk <pavel.dovgaluk@ispras.ru>, Paolo Bonzini <pbonzini@redhat.com>
There is a newer version of this series
[PATCH 3/4] ui: add helpers for virtio-multitouch events
Posted by Sergio Lopez 2 years, 11 months ago
Add helpers for generating Multi-touch events from the UI backends that
can be sent to the guest through a virtio-multitouch device.

Signed-off-by: Sergio Lopez <slp@redhat.com>
---
 include/ui/input.h |  5 +++++
 ui/input.c         | 36 ++++++++++++++++++++++++++++++++++++
 2 files changed, 41 insertions(+)

diff --git a/include/ui/input.h b/include/ui/input.h
index 2a3dffd417..c37251e1e9 100644
--- a/include/ui/input.h
+++ b/include/ui/input.h
@@ -64,6 +64,11 @@ int qemu_input_scale_axis(int value,
 void qemu_input_queue_rel(QemuConsole *src, InputAxis axis, int value);
 void qemu_input_queue_abs(QemuConsole *src, InputAxis axis, int value,
                           int min_in, int max_in);
+void qemu_input_queue_mtt(QemuConsole *src, InputMultitouchType type, int slot,
+                          int tracking_id);
+void qemu_input_queue_mtt_abs(QemuConsole *src, InputAxis axis, int value,
+                              int min_in, int max_in,
+                              int slot, int tracking_id);
 
 void qemu_input_check_mode_change(void);
 void qemu_add_mouse_mode_change_notifier(Notifier *notify);
diff --git a/ui/input.c b/ui/input.c
index f788db20f7..34331b7b0b 100644
--- a/ui/input.c
+++ b/ui/input.c
@@ -547,6 +547,42 @@ void qemu_input_queue_abs(QemuConsole *src, InputAxis axis, int value,
     qemu_input_event_send(src, &evt);
 }
 
+void qemu_input_queue_mtt(QemuConsole *src, InputMultitouchType type,
+                          int slot, int tracking_id)
+{
+    InputMultitouchEvent mtt = {
+        .type = type,
+        .slot = slot,
+        .tracking_id = tracking_id,
+    };
+    InputEvent evt = {
+        .type = INPUT_EVENT_KIND_MTT,
+        .u.mtt.data = &mtt,
+    };
+
+    qemu_input_event_send(src, &evt);
+}
+
+void qemu_input_queue_mtt_abs(QemuConsole *src, InputAxis axis, int value,
+                              int min_in, int max_in, int slot, int tracking_id)
+{
+    InputMultitouchEvent mtt = {
+        .type = INPUT_MULTITOUCH_TYPE_DATA,
+        .slot = slot,
+        .tracking_id = tracking_id,
+        .axis = axis,
+        .value = qemu_input_scale_axis(value, min_in, max_in,
+                                       INPUT_EVENT_ABS_MIN,
+                                       INPUT_EVENT_ABS_MAX),
+    };
+    InputEvent evt = {
+        .type = INPUT_EVENT_KIND_MTT,
+        .u.mtt.data = &mtt,
+    };
+
+    qemu_input_event_send(src, &evt);
+}
+
 void qemu_input_check_mode_change(void)
 {
     static int current_is_absolute;
-- 
2.38.1
Re: [PATCH 3/4] ui: add helpers for virtio-multitouch events
Posted by Marc-André Lureau 2 years, 11 months ago
On Sat, Feb 18, 2023 at 8:23 PM Sergio Lopez <slp@redhat.com> wrote:
>
> Add helpers for generating Multi-touch events from the UI backends that
> can be sent to the guest through a virtio-multitouch device.
>
> Signed-off-by: Sergio Lopez <slp@redhat.com>

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>


> ---
>  include/ui/input.h |  5 +++++
>  ui/input.c         | 36 ++++++++++++++++++++++++++++++++++++
>  2 files changed, 41 insertions(+)
>
> diff --git a/include/ui/input.h b/include/ui/input.h
> index 2a3dffd417..c37251e1e9 100644
> --- a/include/ui/input.h
> +++ b/include/ui/input.h
> @@ -64,6 +64,11 @@ int qemu_input_scale_axis(int value,
>  void qemu_input_queue_rel(QemuConsole *src, InputAxis axis, int value);
>  void qemu_input_queue_abs(QemuConsole *src, InputAxis axis, int value,
>                            int min_in, int max_in);
> +void qemu_input_queue_mtt(QemuConsole *src, InputMultitouchType type, int slot,
> +                          int tracking_id);
> +void qemu_input_queue_mtt_abs(QemuConsole *src, InputAxis axis, int value,
> +                              int min_in, int max_in,
> +                              int slot, int tracking_id);
>
>  void qemu_input_check_mode_change(void);
>  void qemu_add_mouse_mode_change_notifier(Notifier *notify);
> diff --git a/ui/input.c b/ui/input.c
> index f788db20f7..34331b7b0b 100644
> --- a/ui/input.c
> +++ b/ui/input.c
> @@ -547,6 +547,42 @@ void qemu_input_queue_abs(QemuConsole *src, InputAxis axis, int value,
>      qemu_input_event_send(src, &evt);
>  }
>
> +void qemu_input_queue_mtt(QemuConsole *src, InputMultitouchType type,
> +                          int slot, int tracking_id)
> +{
> +    InputMultitouchEvent mtt = {
> +        .type = type,
> +        .slot = slot,
> +        .tracking_id = tracking_id,
> +    };
> +    InputEvent evt = {
> +        .type = INPUT_EVENT_KIND_MTT,
> +        .u.mtt.data = &mtt,
> +    };
> +
> +    qemu_input_event_send(src, &evt);
> +}
> +
> +void qemu_input_queue_mtt_abs(QemuConsole *src, InputAxis axis, int value,
> +                              int min_in, int max_in, int slot, int tracking_id)
> +{
> +    InputMultitouchEvent mtt = {
> +        .type = INPUT_MULTITOUCH_TYPE_DATA,
> +        .slot = slot,
> +        .tracking_id = tracking_id,
> +        .axis = axis,
> +        .value = qemu_input_scale_axis(value, min_in, max_in,
> +                                       INPUT_EVENT_ABS_MIN,
> +                                       INPUT_EVENT_ABS_MAX),
> +    };
> +    InputEvent evt = {
> +        .type = INPUT_EVENT_KIND_MTT,
> +        .u.mtt.data = &mtt,
> +    };
> +
> +    qemu_input_event_send(src, &evt);
> +}
> +
>  void qemu_input_check_mode_change(void)
>  {
>      static int current_is_absolute;
> --
> 2.38.1
>
>


-- 
Marc-André Lureau