There are a few special considerations for running on android
The on-screen gamepad buttons should be disabled and hidden on OUYA. We have freebasic function for toggling them, but need to be able to detect whether or not the currently running Android device is an OUYA.
From upstream, sdl-android just re-uses the scancodes from RedefinedKeysScreenKb (plus 2 from RedefinedKeys) and applies them to the real gamepad. Unfortunately this makes it impossible to get a good mapping for both the virtual gamepad and the real gamepad at the same time via this method
|Generic Java Gamepad||OUYA Controller||Key||key in AndroidAppSettings.cfg||index|
|Left Analog Stick||Left Analog Stick||Arrow Keys|
|Right Analog Stick||Right Analog Stick|
Since this scheme is not suitable for our needs, the plan is to use the RedefinedKeysScreenKb and RedefinedKeys only to set up reasonable defaults for the virtual gamepad, and to add a new function to sdl-android for remapping the gamepad buttons. That function is SDL_ANDROID_set_java_gamepad_keymap()
# Suitable for standard OHRRPGCE games with touch-screen virtual keyboard RedefinedKeysScreenKb="RETURN ESCAPE" RedefinedKeysScreenKbNames="Confirm Cancel" RedefinedKeys="NO_REMAP RETURN NO_REMAP NO_REMAP ESCAPE ESCAPE"
I added a function to sdl-android that remaps the gamepad buttons without having any effect on the virtual gamepad. The arguments are SDL scancodes in the following order:
A, B, C, X, Y, Z, L1, R1, L2, R2
Here are the defaults I am using
SDL_ANDROID_set_java_gamepad_keymap(SDLK_RETURN, SDLK_ESCAPE, 0, SDLK_ESCAPE, SDLK_ESCAPE, 0, SDLK_PAGEUP, SDLK_PAGEDOWN, SDLK_HOME, SDLK_END)
SDLK_ESCAPE appears more than once because it makes sense for both "menu" and "cancel". PAGEUP and PAGEDOWN are useful when scrolling through the inventory or long menus. HOME and END are arbitrary. I left C and Z alone, because it seems few controllers even have them. the OUYA does not.
I also added SDL_ANDROID_set_ouya_gamepad_keymap() for mapping buttons for the second, third and fourth players. This is tested and working in Don't Eat Soap
Moved to Plan for In-App-Purchase Support