libsdl-org / SDL

Simple Directmedia Layer
https://libsdl.org
zlib License
9.97k stars 1.84k forks source link

evdev events from touchpanel not processed #2744

Closed SDLBugzilla closed 1 year ago

SDLBugzilla commented 3 years ago

This bug report was migrated from our old Bugzilla tracker.

Reported in version: HG 2.1 Reported for operating system, platform: Linux, x86_64

Comments on the original bug report:

On 2017-12-04 14:19:00 +0000, Srki wrote:

Tested on two touchpanels

ET&T USB 5WUSB eGalax Inc. eGalaxTouch EXC3188-0510-08.00.00

From SDLs point of view, the difference between these two is in

src/core/linux/SDL_evdev.c

Around line 640

if (udev_class & SDL_UDEV_DEVICE_TOUCHSCREEN) { item->is_touchscreen = 1;

First one does not have SDL_UDEV_DEVICE_TOUCHSCREEN flag.

In function

void SDL_EVDEV_Poll(void)

There are unpromising lines, on few places:

if (!item->is_touchscreen) / FIXME: temp hack / break;

All this results in SDL not sending events from the second touch panel.

ABS_MT_POSITION_X and ABS_MT_POSITION_Y do not send mouse events, there is nof SDL_SendMouseMotion call.

ABS_X and ABS_Y are excluded because of

case ABS_X: if (item->is_touchscreen) / FIXME: temp hack / break;

case ABS_Y: if (item->is_touchscreen) / FIXME: temp hack / break;

Evtest event flow for eGalax touch panel.

Event: time 1512395574.817575, -------------- SYN_REPORT ------------ Event: time 1512395574.823567, type 3 (EV_ABS), code 53 (ABS_MT_POSITION_X), value 1982 Event: time 1512395574.823567, type 3 (EV_ABS), code 54 (ABS_MT_POSITION_Y), value 1760 Event: time 1512395574.823567, type 3 (EV_ABS), code 0 (ABS_X), value 1982 Event: time 1512395574.823567, type 3 (EV_ABS), code 1 (ABS_Y), value 1760 Event: time 1512395574.823567, -------------- SYN_REPORT ------------ Event: time 1512395574.835570, type 3 (EV_ABS), code 54 (ABS_MT_POSITION_Y), value 1747 Event: time 1512395574.835570, type 3 (EV_ABS), code 1 (ABS_Y), value 1747 Event: time 1512395574.835570, -------------- SYN_REPORT ------------ Event: time 1512395574.841574, type 3 (EV_ABS), code 53 (ABS_MT_POSITION_X), value 1981 Event: time 1512395574.841574, type 3 (EV_ABS), code 54 (ABS_MT_POSITION_Y), value 1734 Event: time 1512395574.841574, type 3 (EV_ABS), code 0 (ABS_X), value 1981 Event: time 1512395574.841574, type 3 (EV_ABS), code 1 (ABS_Y), value 1734 Event: time 1512395574.841574, -------------- SYN_REPORT ------------ Event: time 1512395574.853567, type 3 (EV_ABS), code 54 (ABS_MT_POSITION_Y), value 1721 Event: time 1512395574.853567, type 3 (EV_ABS), code 1 (ABS_Y), value 1721 Event: time 1512395574.853567, -------------- SYN_REPORT ------------ Event: time 1512395574.859566, type 3 (EV_ABS), code 54 (ABS_MT_POSITION_Y), value 1709 Event: time 1512395574.859566, type 3 (EV_ABS), code 1 (ABS_Y), value 1709 Event: time 1512395574.859566, -------------- SYN_REPORT ------------ Event: time 1512395574.870571, type 3 (EV_ABS), code 54 (ABS_MT_POSITION_Y), value 1696 Event: time 1512395574.870571, type 3 (EV_ABS), code 1 (ABS_Y), value 1696 Event: time 1512395574.870571, -------------- SYN_REPORT ------------ Event: time 1512395574.876569, type 3 (EV_ABS), code 54 (ABS_MT_POSITION_Y), value 1682 Event: time 1512395574.876569, type 3 (EV_ABS), code 1 (ABS_Y), value 1682 Event: time 1512395574.876569, -------------- SYN_REPORT ------------ Event: time 1512395574.887567, type 3 (EV_ABS), code 54 (ABS_MT_POSITION_Y), value 1668 Event: time 1512395574.887567, type 3 (EV_ABS), code 1 (ABS_Y), value 1668 Event: time 1512395574.887567, -------------- SYN_REPORT ------------ Event: time 1512395574.893567, type 3 (EV_ABS), code 54 (ABS_MT_POSITION_Y), value 1654 Event: time 1512395574.893567, type 3 (EV_ABS), code 1 (ABS_Y), value 1654 Event: time 1512395574.893567, -------------- SYN_REPORT ------------ Event: time 1512395574.904573, type 3 (EV_ABS), code 54 (ABS_MT_POSITION_Y), value 1640 Event: time 1512395574.904573, type 3 (EV_ABS), code 1 (ABS_Y), value 1640 Event: time 1512395574.904573, -------------- SYN_REPORT ------------ Event: time 1512395574.910568, type 3 (EV_ABS), code 54 (ABS_MT_POSITION_Y), value 1626 Event: time 1512395574.910568, type 3 (EV_ABS), code 1 (ABS_Y), value 1626 Event: time 1512395574.910568, -------------- SYN_REPORT ------------ Event: time 1512395574.922568, type 3 (EV_ABS), code 53 (ABS_MT_POSITION_X), value 1980 Event: time 1512395574.922568, type 3 (EV_ABS), code 54 (ABS_MT_POSITION_Y), value 1612 Event: time 1512395574.922568, type 3 (EV_ABS), code 0 (ABS_X), value 1980 Event: time 1512395574.922568, type 3 (EV_ABS), code 1 (ABS_Y), value 1612 Event: time 1512395574.922568, -------------- SYN_REPORT ------------ Event: time 1512395574.928567, type 3 (EV_ABS), code 54 (ABS_MT_POSITION_Y), value 1597 Event: time 1512395574.928567, type 3 (EV_ABS), code 1 (ABS_Y), value 1597 Event: time 1512395574.928567, -------------- SYN_REPORT ------------ Event: time 1512395574.940572, type 3 (EV_ABS), code 54 (ABS_MT_POSITION_Y), value 1583 Event: time 1512395574.940572, type 3 (EV_ABS), code 1 (ABS_Y), value 1583 Event: time 1512395574.940572, -------------- SYN_REPORT ------------ Event: time 1512395574.946568, type 3 (EV_ABS), code 54 (ABS_MT_POSITION_Y), value 1569 Event: time 1512395574.946568, type 3 (EV_ABS), code 1 (ABS_Y), value 1569

slouken commented 1 year ago

I think this is still broken, but I don't have a touchpad to verify this. @cgutman, is this something you can check out?

cgutman commented 1 year ago

I think this should be working now, since 373216ae5be62b710ad68524777ae38ca712c53d and a10c57dfe4de0f015caa8fed49eed70c1e71d6e1. It's very much a "some assembly required" situation for these touchpad events today though.

Applications will receive the raw touch events from the touchpad with SDL_TOUCH_DEVICE_INDIRECT_ABSOLUTE. That's technically all they need to be able to identify and handle touchpad events, however we're leaving each application responsible for putting the all those pieces together into a working mouse implementation.

Getting that right is extremely hard. You have to deal with accidental touches, scroll gestures, button regions, device quirks, and all the other stuff that libinput typically handles behind your back. It's a huge mess. Most desktop apps don't even directly handle touch events, let alone have their own bespoke implementation for turning them into mouse events.

Right now our touch emulation support only handles direct touch events (which are easy to map to mouse events). I don't know if we want to try to take a stab at handling indirect absolute touch events in the SDL core or take a dependency on something like libinput that will do it for us.

slouken commented 1 year ago

Okay, I'll go ahead and close this for now, and if someone who has these touch panels wants to chime in, they can reopen it if things are not working.

Thanks!