# HG changeset patch # User Sam Lantinga # Date 1226129661 0 # Node ID caf3d5b2153f7352010702eaf5940748eaf2b374 # Parent 6d7baec327180b23069261951387ce8bb650d9ec Sort by HID usage, which makes more sense and is more cross-platform diff -r 6d7baec32718 -r caf3d5b2153f src/joystick/darwin/SDL_sysjoystick.c --- 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++; } } diff -r 6d7baec32718 -r caf3d5b2153f src/joystick/darwin/SDL_sysjoystick_c.h --- a/src/joystick/darwin/SDL_sysjoystick_c.h Wed Oct 29 05:56:23 2008 +0000 +++ b/src/joystick/darwin/SDL_sysjoystick_c.h Sat Nov 08 07:34:21 2008 +0000 @@ -35,6 +35,7 @@ struct recElement { IOHIDElementCookie cookie; /* unique value which identifies element, will NOT change */ + long usagePage, usage; /* HID usage */ long min; /* reported min value possible */ long max; /* reported max value possible */ #if 0