Added controller mapping for Android TV remotes

Also fixed the back button on the remote exiting the application
This commit is contained in:
Sam Lantinga 2017-11-01 10:06:58 -07:00
parent e9bd005f5d
commit 7565396bf0
4 changed files with 29 additions and 1 deletions

View file

@ -143,7 +143,13 @@ keycode_to_SDL(int keycode)
button = SDL_CONTROLLER_BUTTON_DPAD_RIGHT;
break;
case AKEYCODE_DPAD_CENTER:
button = SDL_CONTROLLER_BUTTON_MAX+4; /* Not supported by GameController */
/* This is handled better by applications as the A button */
/*button = SDL_CONTROLLER_BUTTON_MAX+4; /* Not supported by GameController */
button = SDL_CONTROLLER_BUTTON_A;
break;
case AKEYCODE_BACK:
button = SDL_CONTROLLER_BUTTON_B;
break;
/* More gamepad buttons (API 12), these get mapped to 20...35*/
@ -640,6 +646,11 @@ SDL_JoystickGUID SDL_SYS_JoystickGetGUID(SDL_Joystick * joystick)
return guid;
}
SDL_bool SDL_SYS_IsDPAD_DeviceIndex(int device_index)
{
return JoystickByDevIndex(device_index)->naxes == 0;
}
#endif /* SDL_JOYSTICK_ANDROID */
/* vi: set ts=4 sw=4 expandtab: */