Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Sort by HID usage, which makes more sense and is more cross-platform
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed Nov 8, 2008
1 parent e0f134e commit 4a714b0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
24 changes: 13 additions & 11 deletions src/joystick/darwin/SDL_sysjoystick.c
Expand Up @@ -331,20 +331,22 @@ HIDAddElement(CFTypeRef refElement, recDevice * pDevice)
}

if (element && headElement) { /* add to list */
pDevice->elements++;
if (NULL == *headElement)
*headElement = element;
else {
recElement *elementPrevious, *elementCurrent;
elementCurrent = *headElement;
while (elementCurrent) {
elementPrevious = elementCurrent;
elementCurrent = elementPrevious->pNext;
}
recElement *elementPrevious = NULL;
recElement *elementCurrent = *headElement;
while (elementCurrent && usage >= elementCurrent->usage) {
elementPrevious = elementCurrent;
elementCurrent = elementCurrent->pNext;
}
if (elementPrevious) {
elementPrevious->pNext = element;
} else {
*headElement = element;
}
element->pNext = NULL;
element->usagePage = usagePage;
element->usage = usage;
element->pNext = elementCurrent;
HIDGetElementInfo(refElement, element);
pDevice->elements++;
}
}

Expand Down
1 change: 1 addition & 0 deletions src/joystick/darwin/SDL_sysjoystick_c.h
Expand Up @@ -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
Expand Down

0 comments on commit 4a714b0

Please sign in to comment.