mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-05-19 11:18:27 +00:00
Added SDL_JoystickFromInstanceID() and SDL_GameControllerFromInstanceID().
This commit is contained in:
parent
998a54f9c5
commit
e6ad29aec8
9 changed files with 67 additions and 0 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue