We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 2213

Summary: Tell that SDL_JoystickNumButtons is unsupported
Product: SDL Reporter: ny00
Component: joystickAssignee: Gabriel Jacobo <gabomdq>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: major    
Priority: P2    
Version: HG 2.1   
Hardware: All   
OS: Android (All)   

Description ny00 2013-11-06 16:12:23 UTC
With the recent inclusion of joystick support for Android (for actual controllers, not an accelerometer), SDL_JoystickNumButtons does not do its job.

Currently it always returns the value of 36 for an actual controller. This is basically the total amount of possible Android keycodes that SDL currently recognizes as controller buttons.

Since there are great chances it simply cannot be implemented on that platform in a reliable manner (which is not an issue if the SDL_GameController API is used, I believe), some documentation should probably be added.

Possible places for telling about this: SDL_joystick.h, README-android.txt.
Comment 1 ny00 2013-11-06 16:30:30 UTC
I shall add that it still returns 0 for the accelerometer, as expected.
Comment 2 Gabriel Jacobo 2013-11-10 23:14:11 UTC
This takes care of it: http://hg.libsdl.org/SDL/rev/f19c0aca56aa
Comment 3 ny00 2013-11-11 11:48:42 UTC
Thanks for this post (and the rest)!

One comment that it may be worthy to add, at least for the information, now that I've thought about it:

Technically, it seems like the d-pad keycodes are not defined to be gamepad keycodes, even if they do come from the buttons of many gamepads in practice.

Besides the keycode names, the fact that the d-pad keycodes existed before "true" gamepad support was introduced (in fact, since API level 1), and furthermore the observation that the arrow keys of a standard USB/Bluetooth keyboard seem to get mapped to the directional d-pad keycodes, isGamepadButton seems to return "false" for the d-pad keycodes.

See here for reference about isGamepadButton:

http://cpeterso.com/blog/02012/10/firefox-18-for-android-adds-dom_key_location_joystick-support-for-game-controllers/

However, it is the case that actual game controllers seem to report true gamepad button presses, as well as d-pad presses. The OUYA controller is an example of such a controller, at least according to this:

http://forums.ouya.tv/discussion/665/android-button-mappings