Added SDL_JoystickFromInstanceID() and SDL_GameControllerFromInstanceID().

This commit is contained in:
Ryan C. Gordon 2015-11-14 12:35:45 -05:00
parent 998a54f9c5
commit e6ad29aec8
9 changed files with 67 additions and 0 deletions

View file

@ -291,6 +291,11 @@ main(int argc, char *argv[])
guid, sizeof (guid));
SDL_Log("Attempting to open device %i, guid %s\n", device, guid);
gamecontroller = SDL_GameControllerOpen(device);
if (gamecontroller != NULL) {
SDL_assert(SDL_GameControllerFromInstanceID(SDL_JoystickInstanceID(SDL_GameControllerGetJoystick(gamecontroller))) == gamecontroller);
}
while (keepGoing) {
if (gamecontroller == NULL) {
if (!reportederror) {
@ -316,6 +321,9 @@ main(int argc, char *argv[])
keepGoing = SDL_FALSE;
} else if (event.type == SDL_CONTROLLERDEVICEADDED) {
gamecontroller = SDL_GameControllerOpen(event.cdevice.which);
if (gamecontroller != NULL) {
SDL_assert(SDL_GameControllerFromInstanceID(SDL_JoystickInstanceID(SDL_GameControllerGetJoystick(gamecontroller))) == gamecontroller);
}
break;
}
}