Sdl@lists.libsdl.org

2013/02/01, Sik the hedgehog

Is deviceHasKey(s) reliable? I wouldn’t be surprised if it just ends
up returning an entire keyboard instead of only the keys relevant to
the controller.

Guess what? Unfortunately, it’s worse than being unreliable for the
purpose I’ve hoped it can be used for; The function has a similar but
quite different meaning.

I really wonder how have I missed that. It has been hinted in the above
post on stackoverflow.com where I’ve originally read about the
deviceHasKey workaround!

Basically, it is a static function which, given a specific key code, is
expected to return true if any connected input device has the key.
deviceHasKeys behaves in such a way, too. So, that sums it up.

What this implies is that, if one does want to add actual controller
support to SDL for the Android platform, something must change. Now,
question is why/how can applications (well, games) on the Android and more
get away from enumerating the buttons:

  • Several known, specific controller layouts are often supported these
    days.
  • If some customization is desired, one should better map controller
    actions to in-game actions, rather than the opposite. In the former
    approach, no enumeration is required. In the latter, though, if no
    enumeration is done then one may simply not be able to take advantage of
    some controller features (like buttons) within the game.
    It can make one wonder if functions like SDL_JoystickNumButtons are really
    necessary. Truly, I’ve mainly thought of the original SDL Joystick API so
    far, rather than SDL_GameController.

Remember the absolute majority of Android games lack controller
support at all. Of the few that do, many seem to rely on some library
that accesses controllers directly instead of using the Android API,
making stuff like this a non-issue (sadly, Android 4.2 seems to have
broken that library, although work is underway to fix it).

And SDL_JoystickNumButtons is probably necessary when you end up with
a controller that’s even remotely different to the current "standard"
controllers (e.g. one with 6 face buttons instead of 4).

2013/2/1, NY00123 :> 2013/02/01, Sik the hedgehog

Is deviceHasKey(s) reliable? I wouldn’t be surprised if it just ends
up returning an entire keyboard instead of only the keys relevant to
the controller.

Guess what? Unfortunately, it’s worse than being unreliable for the purpose
I’ve hoped it can be used for; The function has a similar but quite
different meaning.

I really wonder how have I missed that. It has been hinted in the above post
on stackoverflow.com where I’ve originally read about the deviceHasKey
workaround!

Basically, it is a static function which, given a specific key code, is
expected to return true if any connected input device has the key.
deviceHasKeys behaves in such a way, too. So, that sums it up.

What this implies is that, if one does want to add actual controller support
to SDL for the Android platform, something must change. Now, question is
why/how can applications (well, games) on the Android and more get away from
enumerating the buttons:

  • Several known, specific controller layouts are often supported these days.
  • If some customization is desired, one should better map controller actions
    to in-game actions, rather than the opposite. In the former approach, no
    enumeration is required. In the latter, though, if no enumeration is done
    then one may simply not be able to take advantage of some controller
    features (like buttons) within the game.
    It can make one wonder if functions like SDL_JoystickNumButtons are really
    necessary. Truly, I’ve mainly thought of the original SDL Joystick API so
    far, rather than SDL_GameController.