-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[core] Partial fix gestures for PLATFORM_DRM
#3502
Conversation
@ubkp thank you very much for the review and the so detailed explanation! Reading inputs in separate threads has that kind of downsizes, there should be some synchronization at a fixed rate to get the current state and process it per-frame, similar to other platforms... or just simplify the input and let some inputs run in the main thread. In any case, that solution looks good to me, but maybe @michaelfiber can take a look before merging, he has more experience than me with |
IMHO, if possible, this would be the best scenario. By the way, now that Edit: Looks possible: https://wiki.libsdl.org/SDL2/README/raspberrypi. |
Sorry for my quietness recently. I'm following these but haven't had a chance to chime in. This fix is very much in line with what I've been working on. I've been trying to find a down side to moving more input processing into the main thread but so far performance has been fantastic. |
@ubkp Yes, it's possible and it also applies to all the other supported platforms... but it's a path I prefer to avoid. SDL is a great library with support for many platforms, including Android, iOS, Web and even consoles BUT it's a big external dependency. Since the beginning I tried to keep raylib as minimal and self-contained as possible, minimizing external dependencies (and reinventing the wheel when required). I really like that some platforms are completely dependency-free at a platform-level (Android, DRM) and if I got enough resources and time I would implement more custom platform layers but unfortunately resources are limited and GLFW/SDL do an excelent work at that level. GLFW is quite small and really focused on its task (window and input management), it was easy to integrate and ship with raylib code... but its development has slowdown in the last two years. SDL is bigger and more featured but afaik, more difficult to integrate seamlessly into raylib codebase, it should be shipped as an external dependency. So, I decided to add the SDL backend as a possible alternative to GLFW, targeting advance users that feel confortable with it and want to target more platform or have some advance needs... BUT I like to keep the custom low-level dependency-free implementations for users that prefer the full raylib self-contained experience. In any case, it could change in the future, SDL3 is in the works at the moment. @michaelfiber Ok, I understand is aligned with the new input direction so I'm merging it. |
@raysan5 Got it! That's very good reasoning. Thank you very much for the explanation! 👍 |
Changes
The issue with the gesture system on
PLATFORM_DRM
is thatProcessGestureEvent(gestureEvent)
is called byEventThread()
(L1729) that runs on its own thread. By the timePollInputEvents()
callsUpdateGestures()
(L539) theGESTURE.current
has been overwritten. That causes the meaningful gestures to not be detected when callingGetGestureDetected()
(L431) orIsGestureDetected()
(L258).This partial fix attempts to address that by moving the
ProcessGestureEvent(gestureEvent)
call fromEventThread()
(L1729) toPollInputEvents()
(R607), where it runs consistently and in a predictable manner.It does that by making
GestureEvent gestureEvent
a global variable (R174) that will hold the data from the gesture generated duringEventThread()
. ThatgestureEvent
will then be used insidePollInputEvents()
when callingProcessGestureEvent(gestureEvent)
(R607).To only run
ProcessGestureEvent(gestureEvent)
when there's a new gesture (R605), a new control varnewGesture
was added (R175) and is reseted after theProcessGestureEvent(gestureEvent)
call (R608).This fixes the gestures detection for
GESTURE_TAP
,GESTURE_DOUBLETAP
andGESTURE_HOLD
.The
GESTURE_DRAG
andGESTURE_SWIPE_*
work, but are not reliable. There's some other issue with the touch position or reset that is causing them to not be precise as on other platforms. I believe that's related to the way they are pulled from evdev insideEventThread()
(L1569-L1706), but I was not able to finish debugging it yet.Note
GESTURE_DRAG
andGESTURE_SWIPE_*
to malfunction, so I don't think I'll be able to get this fully fixed fast enough for the5.0
release. This PR, however, should at least restore basic gesture operation forPLATFORM_DRM
in the meantime.Reference
Environment
Edits