Mercurial > sdl-ios-xcode
diff src/joystick/darwin/SDL_sysjoystick.c @ 2776:caf3d5b2153f
Sort by HID usage, which makes more sense and is more cross-platform
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sat, 08 Nov 2008 07:34:21 +0000 |
parents | 204be4fc2726 |
children | 99210400e8b9 |
line wrap: on
line diff
--- a/src/joystick/darwin/SDL_sysjoystick.c Wed Oct 29 05:56:23 2008 +0000 +++ b/src/joystick/darwin/SDL_sysjoystick.c Sat Nov 08 07:34:21 2008 +0000 @@ -331,20 +331,22 @@ } if (element && headElement) { /* add to list */ - pDevice->elements++; - if (NULL == *headElement) + recElement *elementPrevious = NULL; + recElement *elementCurrent = *headElement; + while (elementCurrent && usage >= elementCurrent->usage) { + elementPrevious = elementCurrent; + elementCurrent = elementCurrent->pNext; + } + if (elementPrevious) { + elementPrevious->pNext = element; + } else { *headElement = element; - else { - recElement *elementPrevious, *elementCurrent; - elementCurrent = *headElement; - while (elementCurrent) { - elementPrevious = elementCurrent; - elementCurrent = elementPrevious->pNext; - } - elementPrevious->pNext = element; } - element->pNext = NULL; + element->usagePage = usagePage; + element->usage = usage; + element->pNext = elementCurrent; HIDGetElementInfo(refElement, element); + pDevice->elements++; } }