Handle touch events on wayland device
This commit is contained in:
parent
ec91f9d8db
commit
8257d9eeee
@ -74,6 +74,7 @@ public:
|
||||
static const wl_pointer_listener pointer_listener;
|
||||
static const wl_seat_listener seat_listener;
|
||||
static const wl_keyboard_listener keyboard_listener;
|
||||
static const wl_touch_listener touch_listener;
|
||||
static const wl_output_listener output_listener;
|
||||
static const wl_shell_surface_listener shell_surface_listener;
|
||||
static const wl_registry_listener registry_listener;
|
||||
@ -435,6 +436,60 @@ public:
|
||||
device->m_repeat_rate = rate == 0 ? 0 : 1000 / rate;
|
||||
device->m_repeat_delay = delay;
|
||||
}
|
||||
|
||||
static void touch_handle_down(void* data, wl_touch* touch, uint32_t serial,
|
||||
uint32_t time, wl_surface *surface,
|
||||
int32_t id, wl_fixed_t x, wl_fixed_t y)
|
||||
{
|
||||
CIrrDeviceWayland* device = static_cast<CIrrDeviceWayland*>(data);
|
||||
|
||||
SEvent event;
|
||||
event.EventType = EET_TOUCH_INPUT_EVENT;
|
||||
event.TouchInput.Event = ETIE_PRESSED_DOWN;
|
||||
event.TouchInput.ID = id;
|
||||
event.TouchInput.X = wl_fixed_to_int(x);
|
||||
event.TouchInput.Y = wl_fixed_to_int(y);
|
||||
|
||||
device->signalEvent(event);
|
||||
}
|
||||
|
||||
static void touch_handle_up(void* data, wl_touch* touch, uint32_t serial,
|
||||
uint32_t time, int32_t id)
|
||||
{
|
||||
CIrrDeviceWayland* device = static_cast<CIrrDeviceWayland*>(data);
|
||||
|
||||
SEvent event;
|
||||
event.EventType = EET_TOUCH_INPUT_EVENT;
|
||||
event.TouchInput.Event = ETIE_LEFT_UP;
|
||||
event.TouchInput.ID = id;
|
||||
event.TouchInput.X = 0;
|
||||
event.TouchInput.Y = 0;
|
||||
|
||||
device->signalEvent(event);
|
||||
}
|
||||
|
||||
static void touch_handle_motion(void* data, wl_touch* touch, uint32_t time,
|
||||
int32_t id, wl_fixed_t x, wl_fixed_t y)
|
||||
{
|
||||
CIrrDeviceWayland* device = static_cast<CIrrDeviceWayland*>(data);
|
||||
|
||||
SEvent event;
|
||||
event.EventType = EET_TOUCH_INPUT_EVENT;
|
||||
event.TouchInput.Event = ETIE_MOVED;
|
||||
event.TouchInput.ID = id;
|
||||
event.TouchInput.X = wl_fixed_to_int(x);
|
||||
event.TouchInput.Y = wl_fixed_to_int(y);
|
||||
|
||||
device->signalEvent(event);
|
||||
}
|
||||
|
||||
static void touch_handle_frame(void* data, wl_touch* touch)
|
||||
{
|
||||
}
|
||||
|
||||
static void touch_handle_cancel(void* data, wl_touch* touch)
|
||||
{
|
||||
}
|
||||
|
||||
static void seat_capabilities(void* data, wl_seat* seat, uint32_t caps)
|
||||
{
|
||||
@ -462,6 +517,18 @@ public:
|
||||
wl_keyboard_destroy(device->m_keyboard);
|
||||
device->m_keyboard = NULL;
|
||||
}
|
||||
|
||||
if ((caps & WL_SEAT_CAPABILITY_TOUCH) && !device->m_touch)
|
||||
{
|
||||
device->m_touch = wl_seat_get_touch(seat);
|
||||
wl_touch_add_listener(device->m_touch, &touch_listener,
|
||||
device);
|
||||
}
|
||||
else if (!(caps & WL_SEAT_CAPABILITY_TOUCH) && device->m_touch)
|
||||
{
|
||||
wl_touch_destroy(device->m_touch);
|
||||
device->m_touch = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void seat_name(void* data, wl_seat* wl_seat, const char* name)
|
||||
@ -645,6 +712,15 @@ const wl_keyboard_listener WaylandCallbacks::keyboard_listener =
|
||||
WaylandCallbacks::keyboard_repeat_info
|
||||
};
|
||||
|
||||
const wl_touch_listener WaylandCallbacks::touch_listener =
|
||||
{
|
||||
WaylandCallbacks::touch_handle_down,
|
||||
WaylandCallbacks::touch_handle_up,
|
||||
WaylandCallbacks::touch_handle_motion,
|
||||
WaylandCallbacks::touch_handle_frame,
|
||||
WaylandCallbacks::touch_handle_cancel
|
||||
};
|
||||
|
||||
const wl_seat_listener WaylandCallbacks::seat_listener =
|
||||
{
|
||||
WaylandCallbacks::seat_capabilities,
|
||||
|
@ -169,6 +169,7 @@ namespace irr
|
||||
wl_display* m_display;
|
||||
wl_egl_window* m_egl_window;
|
||||
wl_keyboard* m_keyboard;
|
||||
wl_touch* m_touch;
|
||||
wl_output* m_output;
|
||||
wl_pointer* m_pointer;
|
||||
wl_registry* m_registry;
|
||||
|
@ -479,7 +479,7 @@ namespace UserConfigParams
|
||||
"Settings for the multitouch device") );
|
||||
|
||||
PARAM_PREFIX BoolUserConfigParam m_multitouch_enabled
|
||||
PARAM_DEFAULT( BoolUserConfigParam(false, "multitouch_enabled",
|
||||
PARAM_DEFAULT( BoolUserConfigParam(true, "multitouch_enabled",
|
||||
&m_multitouch_group,
|
||||
"Enable multitouch support.") );
|
||||
|
||||
|
@ -1234,29 +1234,29 @@ EventPropagation InputManager::input(const SEvent& event)
|
||||
}
|
||||
|
||||
// Simulate touch event on non-android devices
|
||||
#if !defined(ANDROID)
|
||||
MultitouchDevice* device = m_device_manager->getMultitouchDevice();
|
||||
//~ #if !defined(ANDROID)
|
||||
//~ MultitouchDevice* device = m_device_manager->getMultitouchDevice();
|
||||
|
||||
if (device != NULL && (type == EMIE_LMOUSE_PRESSED_DOWN ||
|
||||
type == EMIE_LMOUSE_LEFT_UP || type == EMIE_MOUSE_MOVED))
|
||||
{
|
||||
device->m_events[0].id = 0;
|
||||
device->m_events[0].x = event.MouseInput.X;
|
||||
device->m_events[0].y = event.MouseInput.Y;
|
||||
//~ if (device != NULL && (type == EMIE_LMOUSE_PRESSED_DOWN ||
|
||||
//~ type == EMIE_LMOUSE_LEFT_UP || type == EMIE_MOUSE_MOVED))
|
||||
//~ {
|
||||
//~ device->m_events[0].id = 0;
|
||||
//~ device->m_events[0].x = event.MouseInput.X;
|
||||
//~ device->m_events[0].y = event.MouseInput.Y;
|
||||
|
||||
if (type == EMIE_LMOUSE_PRESSED_DOWN)
|
||||
{
|
||||
device->m_events[0].touched = true;
|
||||
}
|
||||
else if (type == EMIE_LMOUSE_LEFT_UP)
|
||||
{
|
||||
device->m_events[0].touched = false;
|
||||
}
|
||||
//~ if (type == EMIE_LMOUSE_PRESSED_DOWN)
|
||||
//~ {
|
||||
//~ device->m_events[0].touched = true;
|
||||
//~ }
|
||||
//~ else if (type == EMIE_LMOUSE_LEFT_UP)
|
||||
//~ {
|
||||
//~ device->m_events[0].touched = false;
|
||||
//~ }
|
||||
|
||||
m_device_manager->updateMultitouchDevice();
|
||||
device->updateDeviceState(0);
|
||||
}
|
||||
#endif
|
||||
//~ m_device_manager->updateMultitouchDevice();
|
||||
//~ device->updateDeviceState(0);
|
||||
//~ }
|
||||
//~ #endif
|
||||
|
||||
/*
|
||||
EMIE_LMOUSE_PRESSED_DOWN Left mouse button was pressed down.
|
||||
|
Loading…
Reference in New Issue
Block a user