src/joystick/darwin/SDL_sysjoystick.c
changeset 2776 caf3d5b2153f
parent 2735 204be4fc2726
child 2859 99210400e8b9
     1.1 --- a/src/joystick/darwin/SDL_sysjoystick.c	Wed Oct 29 05:56:23 2008 +0000
     1.2 +++ b/src/joystick/darwin/SDL_sysjoystick.c	Sat Nov 08 07:34:21 2008 +0000
     1.3 @@ -331,20 +331,22 @@
     1.4      }
     1.5  
     1.6      if (element && headElement) {       /* add to list */
     1.7 +        recElement *elementPrevious = NULL;
     1.8 +        recElement *elementCurrent = *headElement;
     1.9 +        while (elementCurrent && usage >= elementCurrent->usage) {
    1.10 +            elementPrevious = elementCurrent;
    1.11 +            elementCurrent = elementCurrent->pNext;
    1.12 +        }
    1.13 +        if (elementPrevious) {
    1.14 +            elementPrevious->pNext = element;
    1.15 +        } else {
    1.16 +            *headElement = element;
    1.17 +        }
    1.18 +        element->usagePage = usagePage;
    1.19 +        element->usage = usage;
    1.20 +        element->pNext = elementCurrent;
    1.21 +        HIDGetElementInfo(refElement, element);
    1.22          pDevice->elements++;
    1.23 -        if (NULL == *headElement)
    1.24 -            *headElement = element;
    1.25 -        else {
    1.26 -            recElement *elementPrevious, *elementCurrent;
    1.27 -            elementCurrent = *headElement;
    1.28 -            while (elementCurrent) {
    1.29 -                elementPrevious = elementCurrent;
    1.30 -                elementCurrent = elementPrevious->pNext;
    1.31 -            }
    1.32 -            elementPrevious->pNext = element;
    1.33 -        }
    1.34 -        element->pNext = NULL;
    1.35 -        HIDGetElementInfo(refElement, element);
    1.36      }
    1.37  }
    1.38