Skip to content

[rcore] Fixed bug in hovering and input for android #4947

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

Merged
merged 2 commits into from
May 19, 2025

Conversation

padmadevd
Copy link
Contributor

raylib treats both touch and hover events as same in android platform. This causes problem with android devices with pen or stylus support.

IsMouseButtonPressed() and IsMouseButtonDown() are triggered just for hovering above the screen with stylus. And IsMouseButtonReleased() is not triggered. meaning, the mouse is always down. Because, raylib not check AMOTION_EVENT_ACTION_HOVER_EXIT to release the input.

So this PR adds code to ignore the Hovering Input completely.

The Code is Tested in my samsung A13 phone. It does not have pen or stylus support. But i used Genymobile/scrcpy to emulate hovering input.
The hovering is ignored successfully and in my phone it works perfectly without any side effects to other inputs.
I already tested another version of the code in my own game in a samsung tablet with stylus. But this new version is not tested in real device.

Bug Fix Update
Code to Ignore Hovering Inputs Completely
@raysan5
Copy link
Owner

raysan5 commented May 19, 2025

@padmadevd Mmmh... I was not aware of that possible input state...

Please, first of all, could you review code conventions: https://github.com/raysan5/raylib/blob/master/CONVENTIONS.md

@raysan5 raysan5 changed the title Fixed bug in hovering and input for android [rcore] Fixed bug in hovering and input for android May 19, 2025
@raysan5 raysan5 added the platform: Android Android platform label May 19, 2025
corrected coding conventions.
@padmadevd
Copy link
Contributor Author

i really apologize for the mistake.
Now, i corrected the code to meet the coding conventions.

@raysan5 raysan5 merged commit e3b9dbe into raysan5:master May 19, 2025
@raysan5
Copy link
Owner

raysan5 commented May 19, 2025

@padmadevd thanks! It looks good to me. Merging.

@padmadevd
Copy link
Contributor Author

i previously implemented a bool array of size 32 to store the hover state of the pointers. Because, chat GPT told me that the pointer ID returned by AMotionEvent_getPointerId(event, i) will be in the range of 0 to 31. Is it true?
If it is true, then i can directly get hover state using the pointer ID as the index to the hover states array.
This can avoid looping to check the state in the current code (But MAX_TOUCH_POINTS iterations only).
I m not sure about the fact chat GPT told. Because i can't find any official documentation stating that. But the previous code worked correctly. But i changed that for PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform: Android Android platform
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants