mirror of
https://github.com/Relintai/sdl2_frt.git
synced 2024-12-25 09:17:12 +01:00
Fixed updating bindings for controllers using the wildcard mappings
This commit is contained in:
parent
b60e5b82fb
commit
41ee51b9a8
@ -111,7 +111,6 @@ struct _SDL_GameController
|
|||||||
SDL_Joystick *joystick; /* underlying joystick device */
|
SDL_Joystick *joystick; /* underlying joystick device */
|
||||||
int ref_count;
|
int ref_count;
|
||||||
|
|
||||||
SDL_JoystickGUID guid;
|
|
||||||
const char *name;
|
const char *name;
|
||||||
int num_bindings;
|
int num_bindings;
|
||||||
SDL_ExtendedGameControllerBind *bindings;
|
SDL_ExtendedGameControllerBind *bindings;
|
||||||
@ -683,11 +682,10 @@ SDL_PrivateGameControllerParseControllerConfigString(SDL_GameController *gamecon
|
|||||||
/*
|
/*
|
||||||
* Make a new button mapping struct
|
* Make a new button mapping struct
|
||||||
*/
|
*/
|
||||||
static void SDL_PrivateLoadButtonMapping(SDL_GameController *gamecontroller, SDL_JoystickGUID guid, const char *pchName, const char *pchMapping)
|
static void SDL_PrivateLoadButtonMapping(SDL_GameController *gamecontroller, const char *pchName, const char *pchMapping)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
gamecontroller->guid = guid;
|
|
||||||
gamecontroller->name = pchName;
|
gamecontroller->name = pchName;
|
||||||
gamecontroller->num_bindings = 0;
|
gamecontroller->num_bindings = 0;
|
||||||
SDL_memset(gamecontroller->last_match_axis, 0, gamecontroller->joystick->naxes * sizeof(*gamecontroller->last_match_axis));
|
SDL_memset(gamecontroller->last_match_axis, 0, gamecontroller->joystick->naxes * sizeof(*gamecontroller->last_match_axis));
|
||||||
@ -801,14 +799,16 @@ static void SDL_PrivateGameControllerRefreshMapping(ControllerMapping_t *pContro
|
|||||||
{
|
{
|
||||||
SDL_GameController *gamecontrollerlist = SDL_gamecontrollers;
|
SDL_GameController *gamecontrollerlist = SDL_gamecontrollers;
|
||||||
while (gamecontrollerlist) {
|
while (gamecontrollerlist) {
|
||||||
if (!SDL_memcmp(&gamecontrollerlist->guid, &pControllerMapping->guid, sizeof(pControllerMapping->guid))) {
|
if (!SDL_memcmp(&gamecontrollerlist->joystick->guid, &pControllerMapping->guid, sizeof(pControllerMapping->guid))) {
|
||||||
SDL_Event event;
|
|
||||||
event.type = SDL_CONTROLLERDEVICEREMAPPED;
|
|
||||||
event.cdevice.which = gamecontrollerlist->joystick->instance_id;
|
|
||||||
SDL_PushEvent(&event);
|
|
||||||
|
|
||||||
/* Not really threadsafe. Should this lock access within SDL_GameControllerEventWatcher? */
|
/* Not really threadsafe. Should this lock access within SDL_GameControllerEventWatcher? */
|
||||||
SDL_PrivateLoadButtonMapping(gamecontrollerlist, pControllerMapping->guid, pControllerMapping->name, pControllerMapping->mapping);
|
SDL_PrivateLoadButtonMapping(gamecontrollerlist, pControllerMapping->name, pControllerMapping->mapping);
|
||||||
|
|
||||||
|
{
|
||||||
|
SDL_Event event;
|
||||||
|
event.type = SDL_CONTROLLERDEVICEREMAPPED;
|
||||||
|
event.cdevice.which = gamecontrollerlist->joystick->instance_id;
|
||||||
|
SDL_PushEvent(&event);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gamecontrollerlist = gamecontrollerlist->next;
|
gamecontrollerlist = gamecontrollerlist->next;
|
||||||
@ -1273,7 +1273,7 @@ SDL_GameControllerMapping(SDL_GameController * gamecontroller)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return SDL_GameControllerMappingForGUID(gamecontroller->guid);
|
return SDL_GameControllerMappingForGUID(gamecontroller->joystick->guid);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -1582,7 +1582,7 @@ SDL_GameControllerOpen(int device_index)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_PrivateLoadButtonMapping(gamecontroller, pSupportedController->guid, pSupportedController->name, pSupportedController->mapping);
|
SDL_PrivateLoadButtonMapping(gamecontroller, pSupportedController->name, pSupportedController->mapping);
|
||||||
|
|
||||||
/* Add the controller to list */
|
/* Add the controller to list */
|
||||||
++gamecontroller->ref_count;
|
++gamecontroller->ref_count;
|
||||||
|
Loading…
Reference in New Issue
Block a user