Skip to content

Commit

Permalink
Add the controller mappings to the linked list in order
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed Nov 30, 2016
1 parent dd5d85a commit d834c08
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/joystick/SDL_gamecontroller.c
Expand Up @@ -692,9 +692,22 @@ SDL_PrivateAddMappingForGUID(SDL_JoystickGUID jGUID, const char *mappingString,
pControllerMapping->guid = jGUID;
pControllerMapping->name = pchName;
pControllerMapping->mapping = pchMapping;
pControllerMapping->next = s_pSupportedControllers;
pControllerMapping->next = NULL;
pControllerMapping->priority = priority;
s_pSupportedControllers = pControllerMapping;

if (s_pSupportedControllers) {
/* Add the mapping to the end of the list */
ControllerMapping_t *pCurrMapping, *pPrevMapping;

for ( pPrevMapping = s_pSupportedControllers, pCurrMapping = pPrevMapping->next;
pCurrMapping;
pPrevMapping = pCurrMapping, pCurrMapping = pCurrMapping->next ) {
continue;
}
pPrevMapping->next = pControllerMapping;
} else {
s_pSupportedControllers = pControllerMapping;
}
*existing = SDL_FALSE;
}
return pControllerMapping;
Expand Down

0 comments on commit d834c08

Please sign in to comment.