mirror of
https://github.com/Relintai/sdl2_frt.git
synced 2025-01-31 00:09:19 +01:00
Don't overwrite the default binding when changing the binding for a controller that was using the default.
This commit is contained in:
parent
963e74d68c
commit
96259f1f85
@ -422,7 +422,7 @@ static int SDLCALL SDL_GameControllerEventWatcher(void *userdata, SDL_Event * ev
|
|||||||
/*
|
/*
|
||||||
* Helper function to scan the mappings database for a controller with the specified GUID
|
* Helper function to scan the mappings database for a controller with the specified GUID
|
||||||
*/
|
*/
|
||||||
static ControllerMapping_t *SDL_PrivateGetControllerMappingForGUID(SDL_JoystickGUID *guid)
|
static ControllerMapping_t *SDL_PrivateGetControllerMappingForGUID(SDL_JoystickGUID *guid, SDL_bool exact_match)
|
||||||
{
|
{
|
||||||
ControllerMapping_t *pSupportedController = s_pSupportedControllers;
|
ControllerMapping_t *pSupportedController = s_pSupportedControllers;
|
||||||
while (pSupportedController) {
|
while (pSupportedController) {
|
||||||
@ -431,6 +431,7 @@ static ControllerMapping_t *SDL_PrivateGetControllerMappingForGUID(SDL_JoystickG
|
|||||||
}
|
}
|
||||||
pSupportedController = pSupportedController->next;
|
pSupportedController = pSupportedController->next;
|
||||||
}
|
}
|
||||||
|
if (!exact_match) {
|
||||||
if (guid->data[14] == 'h') {
|
if (guid->data[14] == 'h') {
|
||||||
/* This is a HIDAPI device */
|
/* This is a HIDAPI device */
|
||||||
return s_pHIDAPIMapping;
|
return s_pHIDAPIMapping;
|
||||||
@ -441,6 +442,7 @@ static ControllerMapping_t *SDL_PrivateGetControllerMappingForGUID(SDL_JoystickG
|
|||||||
return s_pXInputMapping;
|
return s_pXInputMapping;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -836,7 +838,7 @@ SDL_PrivateAddMappingForGUID(SDL_JoystickGUID jGUID, const char *mappingString,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
pControllerMapping = SDL_PrivateGetControllerMappingForGUID(&jGUID);
|
pControllerMapping = SDL_PrivateGetControllerMappingForGUID(&jGUID, SDL_TRUE);
|
||||||
if (pControllerMapping) {
|
if (pControllerMapping) {
|
||||||
/* Only overwrite the mapping if the priority is the same or higher. */
|
/* Only overwrite the mapping if the priority is the same or higher. */
|
||||||
if (pControllerMapping->priority <= priority) {
|
if (pControllerMapping->priority <= priority) {
|
||||||
@ -1005,7 +1007,7 @@ static ControllerMapping_t *SDL_PrivateGetControllerMappingForNameAndGUID(const
|
|||||||
{
|
{
|
||||||
ControllerMapping_t *mapping;
|
ControllerMapping_t *mapping;
|
||||||
|
|
||||||
mapping = SDL_PrivateGetControllerMappingForGUID(&guid);
|
mapping = SDL_PrivateGetControllerMappingForGUID(&guid, SDL_FALSE);
|
||||||
#ifdef __LINUX__
|
#ifdef __LINUX__
|
||||||
if (!mapping && name) {
|
if (!mapping && name) {
|
||||||
if (SDL_strstr(name, "Xbox 360 Wireless Receiver")) {
|
if (SDL_strstr(name, "Xbox 360 Wireless Receiver")) {
|
||||||
@ -1244,7 +1246,7 @@ char *
|
|||||||
SDL_GameControllerMappingForGUID(SDL_JoystickGUID guid)
|
SDL_GameControllerMappingForGUID(SDL_JoystickGUID guid)
|
||||||
{
|
{
|
||||||
char *pMappingString = NULL;
|
char *pMappingString = NULL;
|
||||||
ControllerMapping_t *mapping = SDL_PrivateGetControllerMappingForGUID(&guid);
|
ControllerMapping_t *mapping = SDL_PrivateGetControllerMappingForGUID(&guid, SDL_FALSE);
|
||||||
if (mapping) {
|
if (mapping) {
|
||||||
char pchGUID[33];
|
char pchGUID[33];
|
||||||
size_t needed;
|
size_t needed;
|
||||||
|
Loading…
Reference in New Issue
Block a user