Added mappings for popular controllers on Chromebooks

This commit is contained in:
Sam Lantinga
2021-02-21 11:03:26 -08:00
parent f5e9c5b7e0
commit 1a17ab30e1
2 changed files with 16 additions and 0 deletions

View File

@@ -470,6 +470,10 @@ static int SDLCALL SDL_GameControllerEventWatcher(void *userdata, SDL_Event * ev
*/
static ControllerMapping_t *SDL_CreateMappingForAndroidController(SDL_JoystickGUID guid)
{
const int face_button_mask = ((1 << SDL_CONTROLLER_BUTTON_A) |
(1 << SDL_CONTROLLER_BUTTON_B) |
(1 << SDL_CONTROLLER_BUTTON_X) |
(1 << SDL_CONTROLLER_BUTTON_Y));
SDL_bool existing;
char mapping_string[1024];
int button_mask;
@@ -481,6 +485,10 @@ static ControllerMapping_t *SDL_CreateMappingForAndroidController(SDL_JoystickGU
/* Accelerometer, shouldn't have a game controller mapping */
return NULL;
}
if (!(button_mask & face_button_mask) || !axis_mask) {
/* We don't know what buttons or axes are supported, don't make up a mapping */
return NULL;
}
SDL_strlcpy(mapping_string, "none,*,", sizeof(mapping_string));