From d961aa95214d74326da8c45797488daa3ba1a3d8 Mon Sep 17 00:00:00 2001 From: deve Date: Wed, 9 Jan 2019 10:57:39 +0100 Subject: [PATCH] Simulate mouse for single touch events on wayland --- .../source/Irrlicht/CIrrDeviceWayland.cpp | 27 ++++++++++++++++++- .../source/Irrlicht/CIrrDeviceWayland.h | 2 +- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/lib/irrlicht/source/Irrlicht/CIrrDeviceWayland.cpp b/lib/irrlicht/source/Irrlicht/CIrrDeviceWayland.cpp index 721c89402..741c46a14 100644 --- a/lib/irrlicht/source/Irrlicht/CIrrDeviceWayland.cpp +++ b/lib/irrlicht/source/Irrlicht/CIrrDeviceWayland.cpp @@ -442,7 +442,7 @@ public: int32_t id, wl_fixed_t x, wl_fixed_t y) { CIrrDeviceWayland* device = static_cast(data); - + SEvent event; event.EventType = EET_TOUCH_INPUT_EVENT; event.TouchInput.Event = ETIE_PRESSED_DOWN; @@ -451,6 +451,14 @@ public: event.TouchInput.Y = wl_fixed_to_int(y); device->signalEvent(event); + + if (device->m_touches_count == 0) + { + pointer_button(data, NULL, 0, 0, BTN_LEFT, + WL_POINTER_BUTTON_STATE_PRESSED); + } + + device->m_touches_count++; } static void touch_handle_up(void* data, wl_touch* touch, uint32_t serial, @@ -466,6 +474,14 @@ public: event.TouchInput.Y = 0; device->signalEvent(event); + + if (device->m_touches_count == 1) + { + pointer_button(data, NULL, 0, 0, BTN_LEFT, + WL_POINTER_BUTTON_STATE_RELEASED); + } + + device->m_touches_count--; } static void touch_handle_motion(void* data, wl_touch* touch, uint32_t time, @@ -481,6 +497,11 @@ public: event.TouchInput.Y = wl_fixed_to_int(y); device->signalEvent(event); + + if (device->m_touches_count == 1) + { + pointer_motion(data, NULL, 0, x, y); + } } static void touch_handle_frame(void* data, wl_touch* touch) @@ -489,6 +510,9 @@ public: static void touch_handle_cancel(void* data, wl_touch* touch) { + CIrrDeviceWayland* device = static_cast(data); + + device->m_touches_count = 0; } static void seat_capabilities(void* data, wl_seat* seat, uint32_t caps) @@ -837,6 +861,7 @@ CIrrDeviceWayland::CIrrDeviceWayland(const SIrrlichtCreationParameters& params) m_mouse_button_states = 0; m_width = params.WindowSize.Width; m_height = params.WindowSize.Height; + m_touches_count = 0; m_window_has_focus = false; m_window_minimized = false; diff --git a/lib/irrlicht/source/Irrlicht/CIrrDeviceWayland.h b/lib/irrlicht/source/Irrlicht/CIrrDeviceWayland.h index 93881bc84..7c0cb92f4 100644 --- a/lib/irrlicht/source/Irrlicht/CIrrDeviceWayland.h +++ b/lib/irrlicht/source/Irrlicht/CIrrDeviceWayland.h @@ -215,7 +215,7 @@ namespace irr uint32_t m_mouse_button_states; unsigned int m_width; unsigned int m_height; - + unsigned int m_touches_count; bool m_window_has_focus; bool m_window_minimized; mutable core::stringc m_clipboard;