Added SDL_GameControllerTypeForIndex() and SDL_GameControllerGetType() to return the type of controller attached.

This commit is contained in:
Sam Lantinga 2019-11-22 13:12:12 -08:00
parent c0650aca21
commit b5aff9d7c3
11 changed files with 227 additions and 145 deletions

View file

@ -1412,6 +1412,17 @@ SDL_GameControllerNameForIndex(int device_index)
}
/**
* Get the type of a game controller.
*/
SDL_GameControllerType
SDL_GameControllerTypeForIndex(int joystick_index)
{
SDL_JoystickGUID guid = SDL_JoystickGetDeviceGUID(joystick_index);
return SDL_GetGameControllerTypeFromGUID(guid);
}
/**
* Get the mapping of a game controller.
* This can be called before any controllers are opened.
@ -1743,6 +1754,15 @@ SDL_GameControllerName(SDL_GameController * gamecontroller)
}
}
SDL_GameControllerType
SDL_GameControllerGetType(SDL_GameController *gamecontroller)
{
if (!gamecontroller) {
return SDL_CONTROLLER_TYPE_UNKNOWN;
}
return SDL_GetGameControllerTypeFromGUID(gamecontroller->joystick->guid);
}
int
SDL_GameControllerGetPlayerIndex(SDL_GameController *gamecontroller)
{