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

@ -265,6 +265,7 @@ main(int argc, char *argv[])
SDL_GetError());
} else {
char guid[64];
SDL_assert(SDL_JoystickFromInstanceID(SDL_JoystickInstanceID(joystick)) == joystick);
SDL_JoystickGetGUIDString(SDL_JoystickGetGUID(joystick),
guid, sizeof (guid));
SDL_Log(" axes: %d\n", SDL_JoystickNumAxes(joystick));
@ -292,6 +293,9 @@ main(int argc, char *argv[])
device = atoi(argv[1]);
#endif
joystick = SDL_JoystickOpen(device);
if (joystick != NULL) {
SDL_assert(SDL_JoystickFromInstanceID(SDL_JoystickInstanceID(joystick)) == joystick);
}
while ( keepGoing ) {
if (joystick == NULL) {
@ -317,6 +321,9 @@ main(int argc, char *argv[])
keepGoing = SDL_FALSE;
} else if (event.type == SDL_JOYDEVICEADDED) {
joystick = SDL_JoystickOpen(device);
if (joystick != NULL) {
SDL_assert(SDL_JoystickFromInstanceID(SDL_JoystickInstanceID(joystick)) == joystick);
}
break;
}
}