Android Physical arrow keys not generating keyboard events

Has anyone tried a physical keyboard on the Android platform yet? I’ve got various Android TV dongles and a phone with a slide out keyboard. They all generate key events as expected with exception of the arrow keys, which generate no events, or SDL_GetKeyboardState.

Any idea if this is a bug, or are the arrow keys special on Android?

SDL2.0.3

I’m still stuck on this problem. Surely I’m not the only one with a physical keyboard on Android? Is anyone able to use the arrow keys in SDL2 android?

I’m a commercial indie games developer and am keen to get this working :slight_smile:

I actually have, and I was using a Microsoft universal Bluetooth keyboard. It definitely worked, but I was using the C4Droid compilers built in SDL2 support rather than deploying my own app on the device.

I have seen the same issue.

Keyboard arrows are sent to “joystick” module, where they are translated as
D-PAD keys, but they are not consumed and are not sent to the “keyboard
module”.
Normal key are also sent to “joystick” module, but they are not
translated, so they are then sent to the “keyboard” module.

I have filled a bug + pseudo-patch there:
https://bugzilla.libsdl.org/show_bug.cgi?id=2948On Fri, Mar 13, 2015 at 11:40 AM, AntTheAlchemist wrote:

I’m still stuck on this problem. Surely I’m not the only one with a
physical keyboard on Android? Is anyone able to use the arrow keys in SDL2
android?

I’m a commercial indie games developer and am keen to get this working [image:
Smile]


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

slvn & sam, thank-you for applying a patch to fix this.

However, I’m still not getting keyboard events. I’m now getting joystick button events instead. This not the desired result. I’d like to receive keyboard events the same way the other platforms work.

I’m not even getting D-Pad joystick events. Just controller button numbers.

Right, I’ve done some digging. Physical keyboard arrow keys work as normal keyboard events if I don’t handle any joysticks or controllers.

That is to say, if I support joysticks and open all the joysticks detected by the system, physical keys become joystick buttons instead of keyboard key presses.

On every Android device I have, there are at least 1 (sometimes 3) strange joysticks detected by SDL, even though no gamepads or joysticks are plugged into the system. They’re named things such as “2.4G Wireless Device”, “1 rk29-keypad”, “Virtual”. None of which are joysticks. The only way I know how to fix this is to filter out these non-joystick notifications and don’t add them based on what they’re called? They serve no use whatsoever and don’t produce any axis or button events other than when I’m pressing physical arrow keys.

This isn’t the desired effect. I only want to see actual real game controllers and joysticks being reported by SDL, otherwise I’m offering the end-user spurious game-controllers that aren’t game controllers. Not to mention, it breaks the physical keyboard arrow keys.

Any suggestions?