Skip to content
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] Fix mouse/touch/gestures for PLATFORM_DRM #3515

Merged
merged 1 commit into from Nov 7, 2023
Merged

[core] Fix mouse/touch/gestures for PLATFORM_DRM #3515

merged 1 commit into from Nov 7, 2023

Conversation

ghost
Copy link

@ghost ghost commented Nov 7, 2023

Changes

  1. Fixes the gesture system for PLATFORM_DRM. Does that by:

    1. Moving the mouse/touch/gesture handling from EventThread() (R1741-R1923) to end of PollInputEvents() (R608-R783). Similar to how it's done on SDL (L1001).

    2. Changing the ConfigureEvdevDevice() to no longer call the EventThread() (R1635-R1641) and instead use the newly added platform.mouseFd (R126, R1628). Similar to how it's done for platform.keyboardFd (L1455).

    3. Adding absRange and touchSlot required for the touch handling to the PlatformData struct (R127-R128). That were previously provided by the InputEventWorker *worker (e.g.: R1743, L1630-L1631, L1647).

    4. Adding a check/break to prevent double TOUCH_ACTION_DOWN events causing the gesture detection to malfuction (R779).

  2. Due to the changes above, re-fixes the relative cursor handling. Does that by:

    1. Reworking the PollInputEvents() register previous mouse position (R566-R567).

    2. Reworking the PollInputEvents() evdev's event handling for relative cursor (R627-R633, R641-R647). Similar to how it's done for SDL (L1104-L1121).

    3. Fixing the DisableCursor() start position so it matches the evdev's 0, 0 "neutral" position (R449).

Notes

  1. It looks like a lot of changes, but it's mostly moving code around.

  2. @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 the SDL version). Also, I tested it a lot on my Raspberry 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.

  3. @michaelfiber I've appended most of this change to the very end of PollInputEvents() inside curly brackets (R610-R783), so hopefully it doesn't interfere too much with your DRM input rework and can be easily removed when necessary.

  4. 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 the DRM input rework, it's no longer necessary.

  5. 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 for PLATFORM_DRM #3502.

References

Environment

  • Tested on Raspberry Pi 3 Model B 1.2 with Linux (Raspberry Pi OS 11 Bullseye 32-bit armhf).

Edits

  • 1: added line marks, editing.
  • 2, 3: editing.

@raysan5 raysan5 merged commit 9a2b735 into raysan5:master Nov 7, 2023
14 checks passed
@raysan5
Copy link
Owner

raysan5 commented Nov 7, 2023

@ubkp thank you very much for the review! We can keep this implementation until @michaelfiber review.

@ghost ghost deleted the fix/drm-gestures branch November 7, 2023 18:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant