#5387 - Fix keyboard input detected as gamepad on some Android devices (#5439)

* [rcore][android] Fix keyboard input detected as gamepad on some devices (#5387)

* [core] Add keyboard vs gamepad input test example (#5387)
This commit is contained in:
Alvin De Cruz
2025-12-27 03:42:32 +08:00
committed by GitHub
parent 101502103a
commit 5e14ac5a2e
2 changed files with 178 additions and 2 deletions

View File

@ -1238,8 +1238,11 @@ static int32_t AndroidInputCallback(struct android_app *app, AInputEvent *event)
//int32_t AKeyEvent_getMetaState(event);
// Handle gamepad button presses and releases
if (FLAG_IS_SET(source, AINPUT_SOURCE_JOYSTICK) ||
FLAG_IS_SET(source, AINPUT_SOURCE_GAMEPAD))
// NOTE: Skip gamepad handling if this is a keyboard event, as some devices
// report both AINPUT_SOURCE_KEYBOARD and AINPUT_SOURCE_GAMEPAD flags
if ((FLAG_IS_SET(source, AINPUT_SOURCE_JOYSTICK) ||
FLAG_IS_SET(source, AINPUT_SOURCE_GAMEPAD)) &&
!FLAG_IS_SET(source, AINPUT_SOURCE_KEYBOARD))
{
// For now we'll assume a single gamepad which we "detect" on its input event
CORE.Input.Gamepad.ready[0] = true;