[core] Fix mouse/touch/gestures for PLATFORM_DRM
#3515
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changes
Fixes the gesture system for
PLATFORM_DRM
. Does that by:Moving the mouse/touch/gesture handling from
EventThread()
(R1741-R1923) to end ofPollInputEvents()
(R608-R783). Similar to how it's done onSDL
(L1001).Changing the
ConfigureEvdevDevice()
to no longer call theEventThread()
(R1635-R1641) and instead use the newly addedplatform.mouseFd
(R126, R1628). Similar to how it's done forplatform.keyboardFd
(L1455).Adding
absRange
andtouchSlot
required for the touch handling to thePlatformData
struct (R127-R128). That were previously provided by theInputEventWorker *worker
(e.g.: R1743, L1630-L1631, L1647).Adding a check/break to prevent double
TOUCH_ACTION_DOWN
events causing the gesture detection to malfuction (R779).Due to the changes above, re-fixes the
relative cursor
handling. Does that by:Reworking the
PollInputEvents()
register previous mouse position (R566-R567).Reworking the
PollInputEvents()
evdev
's event handling forrelative cursor
(R627-R633, R641-R647). Similar to how it's done forSDL
(L1104-L1121).Fixing the
DisableCursor()
start position so it matches theevdev
's0, 0
"neutral" position (R449).Notes
It looks like a lot of changes, but it's mostly moving code around.
@raysan5 I know you mentioned "[...] only mouse should be in a second thread. [...]" (3335#issuecomment-1795689019), but I don't think we can decouple the gesture system from the mouse/touch
evdev
events. So to make it work reliably, the only way I found was moving it to the main thread (which is really similar to theSDL
version). Also, I tested it a lot on myRaspberry Pi 3 Model B
, which is fairly weak in terms of hardware spec, and I couldn't notice any downside of handling the entire mouse on the main thread.@michaelfiber I've appended most of this change to the very end of
PollInputEvents()
insidecurly brackets
(R610-R783), so hopefully it doesn't interfere too much with yourDRM
input rework and can be easily removed when necessary.The
EventThread
was just commented (R1741-R1923) instead of removed to keep it there (temporarily) as a reference. It can safely be removed later if, after theDRM
input rework, it's no longer necessary.This PR reverts/reworks (L173-L176, L603-L610, L1734-R1903, L1745-R1914) the previous partial fix for the gesture system on
PLATFORM_DRM
from [core] Partial fix gestures forPLATFORM_DRM
#3502.References
PLATFORM_DRM
#3502PLATFORM_DRM
#3492Environment
Edits