aboutsummaryrefslogtreecommitdiff
path: root/ui/input.c
diff options
context:
space:
mode:
authorSergio Lopez <slp@redhat.com>2023-05-26 13:29:24 +0200
committerMarc-André Lureau <marcandre.lureau@redhat.com>2023-05-28 13:08:25 +0400
commitf6157392d4e4047c56bc81da0de0e64617bf2785 (patch)
treeef2955236044897a940ab635b43dd6a79f55419b /ui/input.c
parent4b2321c96638bb4ed401c448d7f5b475ff7b341d (diff)
ui: add helpers for virtio-multitouch events
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> Message-Id: <20230526112925.38794-6-slp@redhat.com>
Diffstat (limited to 'ui/input.c')
-rw-r--r--ui/input.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/ui/input.c b/ui/input.c
index fc75f1353c..1aad64b07c 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_MULTI_TOUCH_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;