The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
Android Physical arrow keys not generating keyboard events
mjspritzer


Joined: 06 Mar 2015
Posts: 10
Location: Southern California
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.
Android Physical arrow keys not generating keyboard events
slvn


Joined: 06 Oct 2012
Posts: 88
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=2948



On Fri, Mar 13, 2015 at 11:40 AM, AntTheAlchemist wrote:
Quote:
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


_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

AntTheAlchemist


Joined: 13 Feb 2015
Posts: 60
Location: UK
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.
AntTheAlchemist


Joined: 13 Feb 2015
Posts: 60
Location: UK
I'm not even getting D-Pad joystick events. Just controller button numbers.
AntTheAlchemist


Joined: 13 Feb 2015
Posts: 60
Location: UK
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?