mirror of
https://github.com/encounter/SDL.git
synced 2025-12-09 13:37:56 +00:00
Added SDL_JoystickFromInstanceID() and SDL_GameControllerFromInstanceID().
This commit is contained in:
@@ -1046,6 +1046,25 @@ SDL_Joystick *SDL_GameControllerGetJoystick(SDL_GameController * gamecontroller)
|
||||
return gamecontroller->joystick;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Find the SDL_GameController that owns this instance id
|
||||
*/
|
||||
SDL_GameController *
|
||||
SDL_GameControllerFromInstanceID(SDL_JoystickID joyid)
|
||||
{
|
||||
SDL_GameController *gamecontroller = SDL_gamecontrollers;
|
||||
while (gamecontroller) {
|
||||
if (gamecontroller->joystick->instance_id == joyid) {
|
||||
return gamecontroller;
|
||||
}
|
||||
gamecontroller = gamecontroller->next;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the SDL joystick layer binding for this controller axis mapping
|
||||
*/
|
||||
|
||||
@@ -373,6 +373,23 @@ SDL_JoystickInstanceID(SDL_Joystick * joystick)
|
||||
return (joystick->instance_id);
|
||||
}
|
||||
|
||||
/*
|
||||
* Find the SDL_Joystick that owns this instance id
|
||||
*/
|
||||
SDL_Joystick *
|
||||
SDL_JoystickFromInstanceID(SDL_JoystickID joyid)
|
||||
{
|
||||
SDL_Joystick *joystick = SDL_joysticks;
|
||||
while (joystick) {
|
||||
if (joystick->instance_id == joyid) {
|
||||
return joystick;
|
||||
}
|
||||
joystick = joystick->next;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the friendly name of this joystick
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user