src/joystick/darwin/SDL_sysjoystick.c
branchSDL-1.3
changeset 1668 4da1ee79c9af
parent 1662 782fd950bd46
     1.1 --- a/src/joystick/darwin/SDL_sysjoystick.c	Mon May 29 03:53:21 2006 +0000
     1.2 +++ b/src/joystick/darwin/SDL_sysjoystick.c	Mon May 29 04:04:35 2006 +0000
     1.3 @@ -104,20 +104,20 @@
     1.4  
     1.5  
     1.6  static void
     1.7 -HIDReportErrorNum (char *strError, long numError)
     1.8 +HIDReportErrorNum(char *strError, long numError)
     1.9  {
    1.10 -    SDL_SetError (strError);
    1.11 +    SDL_SetError(strError);
    1.12  }
    1.13  
    1.14 -static void HIDGetCollectionElements (CFMutableDictionaryRef deviceProperties,
    1.15 -                                      recDevice * pDevice);
    1.16 +static void HIDGetCollectionElements(CFMutableDictionaryRef deviceProperties,
    1.17 +                                     recDevice * pDevice);
    1.18  
    1.19  /* returns current value for element, polling element
    1.20   * will return 0 on error conditions which should be accounted for by application
    1.21   */
    1.22  
    1.23  static SInt32
    1.24 -HIDGetElementValue (recDevice * pDevice, recElement * pElement)
    1.25 +HIDGetElementValue(recDevice * pDevice, recElement * pElement)
    1.26  {
    1.27      IOReturn result = kIOReturnSuccess;
    1.28      IOHIDEventStruct hidEvent;
    1.29 @@ -125,9 +125,9 @@
    1.30  
    1.31      if (NULL != pDevice && NULL != pElement && NULL != pDevice->interface) {
    1.32          result =
    1.33 -            (*(pDevice->interface))->getElementValue (pDevice->interface,
    1.34 -                                                      pElement->cookie,
    1.35 -                                                      &hidEvent);
    1.36 +            (*(pDevice->interface))->getElementValue(pDevice->interface,
    1.37 +                                                     pElement->cookie,
    1.38 +                                                     &hidEvent);
    1.39          if (kIOReturnSuccess == result) {
    1.40              /* record min and max for auto calibration */
    1.41              if (hidEvent.value < pElement->minReport)
    1.42 @@ -142,12 +142,12 @@
    1.43  }
    1.44  
    1.45  static SInt32
    1.46 -HIDScaledCalibratedValue (recDevice * pDevice, recElement * pElement,
    1.47 -                          long min, long max)
    1.48 +HIDScaledCalibratedValue(recDevice * pDevice, recElement * pElement,
    1.49 +                         long min, long max)
    1.50  {
    1.51      float deviceScale = max - min;
    1.52      float readScale = pElement->maxReport - pElement->minReport;
    1.53 -    SInt32 value = HIDGetElementValue (pDevice, pElement);
    1.54 +    SInt32 value = HIDGetElementValue(pDevice, pElement);
    1.55      if (readScale == 0)
    1.56          return value;           /* no scaling at all */
    1.57      else
    1.58 @@ -157,7 +157,7 @@
    1.59  
    1.60  
    1.61  static void
    1.62 -HIDRemovalCallback (void *target, IOReturn result, void *refcon, void *sender)
    1.63 +HIDRemovalCallback(void *target, IOReturn result, void *refcon, void *sender)
    1.64  {
    1.65      recDevice *device = (recDevice *) refcon;
    1.66      device->removed = 1;
    1.67 @@ -171,7 +171,7 @@
    1.68   */
    1.69  
    1.70  static IOReturn
    1.71 -HIDCreateOpenDeviceInterface (io_object_t hidDevice, recDevice * pDevice)
    1.72 +HIDCreateOpenDeviceInterface(io_object_t hidDevice, recDevice * pDevice)
    1.73  {
    1.74      IOReturn result = kIOReturnSuccess;
    1.75      HRESULT plugInResult = S_OK;
    1.76 @@ -180,37 +180,37 @@
    1.77  
    1.78      if (NULL == pDevice->interface) {
    1.79          result =
    1.80 -            IOCreatePlugInInterfaceForService (hidDevice,
    1.81 -                                               kIOHIDDeviceUserClientTypeID,
    1.82 -                                               kIOCFPlugInInterfaceID,
    1.83 -                                               &ppPlugInInterface, &score);
    1.84 +            IOCreatePlugInInterfaceForService(hidDevice,
    1.85 +                                              kIOHIDDeviceUserClientTypeID,
    1.86 +                                              kIOCFPlugInInterfaceID,
    1.87 +                                              &ppPlugInInterface, &score);
    1.88          if (kIOReturnSuccess == result) {
    1.89              /* Call a method of the intermediate plug-in to create the device interface */
    1.90              plugInResult =
    1.91 -                (*ppPlugInInterface)->QueryInterface (ppPlugInInterface,
    1.92 -                                                      CFUUIDGetUUIDBytes
    1.93 -                                                      (kIOHIDDeviceInterfaceID),
    1.94 -                                                      (void *) &(pDevice->
    1.95 -                                                                 interface));
    1.96 +                (*ppPlugInInterface)->QueryInterface(ppPlugInInterface,
    1.97 +                                                     CFUUIDGetUUIDBytes
    1.98 +                                                     (kIOHIDDeviceInterfaceID),
    1.99 +                                                     (void *) &(pDevice->
   1.100 +                                                                interface));
   1.101              if (S_OK != plugInResult)
   1.102                  HIDReportErrorNum
   1.103                      ("CouldnŐt query HID class device interface from plugInInterface",
   1.104                       plugInResult);
   1.105 -            (*ppPlugInInterface)->Release (ppPlugInInterface);
   1.106 +            (*ppPlugInInterface)->Release(ppPlugInInterface);
   1.107          } else
   1.108              HIDReportErrorNum
   1.109                  ("Failed to create **plugInInterface via IOCreatePlugInInterfaceForService.",
   1.110                   result);
   1.111      }
   1.112      if (NULL != pDevice->interface) {
   1.113 -        result = (*(pDevice->interface))->open (pDevice->interface, 0);
   1.114 +        result = (*(pDevice->interface))->open(pDevice->interface, 0);
   1.115          if (kIOReturnSuccess != result)
   1.116              HIDReportErrorNum
   1.117                  ("Failed to open pDevice->interface via open.", result);
   1.118          else
   1.119 -            (*(pDevice->interface))->setRemovalCallback (pDevice->interface,
   1.120 -                                                         HIDRemovalCallback,
   1.121 -                                                         pDevice, pDevice);
   1.122 +            (*(pDevice->interface))->setRemovalCallback(pDevice->interface,
   1.123 +                                                        HIDRemovalCallback,
   1.124 +                                                        pDevice, pDevice);
   1.125  
   1.126      }
   1.127      return result;
   1.128 @@ -223,23 +223,23 @@
   1.129   */
   1.130  
   1.131  static IOReturn
   1.132 -HIDCloseReleaseInterface (recDevice * pDevice)
   1.133 +HIDCloseReleaseInterface(recDevice * pDevice)
   1.134  {
   1.135      IOReturn result = kIOReturnSuccess;
   1.136  
   1.137      if ((NULL != pDevice) && (NULL != pDevice->interface)) {
   1.138          /* close the interface */
   1.139 -        result = (*(pDevice->interface))->close (pDevice->interface);
   1.140 +        result = (*(pDevice->interface))->close(pDevice->interface);
   1.141          if (kIOReturnNotOpen == result) {
   1.142              /* do nothing as device was not opened, thus can't be closed */
   1.143          } else if (kIOReturnSuccess != result)
   1.144 -            HIDReportErrorNum ("Failed to close IOHIDDeviceInterface.",
   1.145 -                               result);
   1.146 +            HIDReportErrorNum("Failed to close IOHIDDeviceInterface.",
   1.147 +                              result);
   1.148          /* release the interface */
   1.149 -        result = (*(pDevice->interface))->Release (pDevice->interface);
   1.150 +        result = (*(pDevice->interface))->Release(pDevice->interface);
   1.151          if (kIOReturnSuccess != result)
   1.152 -            HIDReportErrorNum ("Failed to release IOHIDDeviceInterface.",
   1.153 -                               result);
   1.154 +            HIDReportErrorNum("Failed to release IOHIDDeviceInterface.",
   1.155 +                              result);
   1.156          pDevice->interface = NULL;
   1.157      }
   1.158      return result;
   1.159 @@ -248,21 +248,20 @@
   1.160  /* extracts actual specific element information from each element CF dictionary entry */
   1.161  
   1.162  static void
   1.163 -HIDGetElementInfo (CFTypeRef refElement, recElement * pElement)
   1.164 +HIDGetElementInfo(CFTypeRef refElement, recElement * pElement)
   1.165  {
   1.166      long number;
   1.167      CFTypeRef refType;
   1.168  
   1.169 -    refType =
   1.170 -        CFDictionaryGetValue (refElement, CFSTR (kIOHIDElementCookieKey));
   1.171 -    if (refType && CFNumberGetValue (refType, kCFNumberLongType, &number))
   1.172 +    refType = CFDictionaryGetValue(refElement, CFSTR(kIOHIDElementCookieKey));
   1.173 +    if (refType && CFNumberGetValue(refType, kCFNumberLongType, &number))
   1.174          pElement->cookie = (IOHIDElementCookie) number;
   1.175 -    refType = CFDictionaryGetValue (refElement, CFSTR (kIOHIDElementMinKey));
   1.176 -    if (refType && CFNumberGetValue (refType, kCFNumberLongType, &number))
   1.177 +    refType = CFDictionaryGetValue(refElement, CFSTR(kIOHIDElementMinKey));
   1.178 +    if (refType && CFNumberGetValue(refType, kCFNumberLongType, &number))
   1.179          pElement->min = number;
   1.180      pElement->maxReport = pElement->min;
   1.181 -    refType = CFDictionaryGetValue (refElement, CFSTR (kIOHIDElementMaxKey));
   1.182 -    if (refType && CFNumberGetValue (refType, kCFNumberLongType, &number))
   1.183 +    refType = CFDictionaryGetValue(refElement, CFSTR(kIOHIDElementMaxKey));
   1.184 +    if (refType && CFNumberGetValue(refType, kCFNumberLongType, &number))
   1.185          pElement->max = number;
   1.186      pElement->minReport = pElement->max;
   1.187  /*
   1.188 @@ -301,31 +300,30 @@
   1.189   */
   1.190  
   1.191  static void
   1.192 -HIDAddElement (CFTypeRef refElement, recDevice * pDevice)
   1.193 +HIDAddElement(CFTypeRef refElement, recDevice * pDevice)
   1.194  {
   1.195      recElement *element = NULL;
   1.196      recElement **headElement = NULL;
   1.197      long elementType, usagePage, usage;
   1.198      CFTypeRef refElementType =
   1.199 -        CFDictionaryGetValue (refElement, CFSTR (kIOHIDElementTypeKey));
   1.200 +        CFDictionaryGetValue(refElement, CFSTR(kIOHIDElementTypeKey));
   1.201      CFTypeRef refUsagePage =
   1.202 -        CFDictionaryGetValue (refElement, CFSTR (kIOHIDElementUsagePageKey));
   1.203 +        CFDictionaryGetValue(refElement, CFSTR(kIOHIDElementUsagePageKey));
   1.204      CFTypeRef refUsage =
   1.205 -        CFDictionaryGetValue (refElement, CFSTR (kIOHIDElementUsageKey));
   1.206 +        CFDictionaryGetValue(refElement, CFSTR(kIOHIDElementUsageKey));
   1.207  
   1.208  
   1.209      if ((refElementType)
   1.210          &&
   1.211 -        (CFNumberGetValue (refElementType, kCFNumberLongType, &elementType)))
   1.212 -    {
   1.213 +        (CFNumberGetValue(refElementType, kCFNumberLongType, &elementType))) {
   1.214          /* look at types of interest */
   1.215          if ((elementType == kIOHIDElementTypeInput_Misc)
   1.216              || (elementType == kIOHIDElementTypeInput_Button)
   1.217              || (elementType == kIOHIDElementTypeInput_Axis)) {
   1.218              if (refUsagePage
   1.219 -                && CFNumberGetValue (refUsagePage, kCFNumberLongType,
   1.220 -                                     &usagePage) && refUsage
   1.221 -                && CFNumberGetValue (refUsage, kCFNumberLongType, &usage)) {
   1.222 +                && CFNumberGetValue(refUsagePage, kCFNumberLongType,
   1.223 +                                    &usagePage) && refUsage
   1.224 +                && CFNumberGetValue(refUsage, kCFNumberLongType, &usage)) {
   1.225                  switch (usagePage) {    /* only interested in kHIDPage_GenericDesktop and kHIDPage_Button */
   1.226                  case kHIDPage_GenericDesktop:
   1.227                      {
   1.228 @@ -340,7 +338,7 @@
   1.229                          case kHIDUsage_GD_Dial:
   1.230                          case kHIDUsage_GD_Wheel:
   1.231                              element = (recElement *)
   1.232 -                                NewPtrClear (sizeof (recElement));
   1.233 +                                NewPtrClear(sizeof(recElement));
   1.234                              if (element) {
   1.235                                  pDevice->axes++;
   1.236                                  headElement = &(pDevice->firstAxis);
   1.237 @@ -348,7 +346,7 @@
   1.238                              break;
   1.239                          case kHIDUsage_GD_Hatswitch:
   1.240                              element = (recElement *)
   1.241 -                                NewPtrClear (sizeof (recElement));
   1.242 +                                NewPtrClear(sizeof(recElement));
   1.243                              if (element) {
   1.244                                  pDevice->hats++;
   1.245                                  headElement = &(pDevice->firstHat);
   1.246 @@ -359,7 +357,7 @@
   1.247                      break;
   1.248                  case kHIDPage_Button:
   1.249                      element = (recElement *)
   1.250 -                        NewPtrClear (sizeof (recElement));
   1.251 +                        NewPtrClear(sizeof(recElement));
   1.252                      if (element) {
   1.253                          pDevice->buttons++;
   1.254                          headElement = &(pDevice->firstButton);
   1.255 @@ -370,8 +368,8 @@
   1.256                  }
   1.257              }
   1.258          } else if (kIOHIDElementTypeCollection == elementType)
   1.259 -            HIDGetCollectionElements ((CFMutableDictionaryRef) refElement,
   1.260 -                                      pDevice);
   1.261 +            HIDGetCollectionElements((CFMutableDictionaryRef) refElement,
   1.262 +                                     pDevice);
   1.263      }
   1.264  
   1.265      if (element && headElement) {       /* add to list */
   1.266 @@ -388,30 +386,30 @@
   1.267              elementPrevious->pNext = element;
   1.268          }
   1.269          element->pNext = NULL;
   1.270 -        HIDGetElementInfo (refElement, element);
   1.271 +        HIDGetElementInfo(refElement, element);
   1.272      }
   1.273  }
   1.274  
   1.275  /* collects information from each array member in device element list (each array memeber = element) */
   1.276  
   1.277  static void
   1.278 -HIDGetElementsCFArrayHandler (const void *value, void *parameter)
   1.279 +HIDGetElementsCFArrayHandler(const void *value, void *parameter)
   1.280  {
   1.281 -    if (CFGetTypeID (value) == CFDictionaryGetTypeID ())
   1.282 -        HIDAddElement ((CFTypeRef) value, (recDevice *) parameter);
   1.283 +    if (CFGetTypeID(value) == CFDictionaryGetTypeID())
   1.284 +        HIDAddElement((CFTypeRef) value, (recDevice *) parameter);
   1.285  }
   1.286  
   1.287  /* handles retrieval of element information from arrays of elements in device IO registry information */
   1.288  
   1.289  static void
   1.290 -HIDGetElements (CFTypeRef refElementCurrent, recDevice * pDevice)
   1.291 +HIDGetElements(CFTypeRef refElementCurrent, recDevice * pDevice)
   1.292  {
   1.293 -    CFTypeID type = CFGetTypeID (refElementCurrent);
   1.294 -    if (type == CFArrayGetTypeID ()) {  /* if element is an array */
   1.295 -        CFRange range = { 0, CFArrayGetCount (refElementCurrent) };
   1.296 +    CFTypeID type = CFGetTypeID(refElementCurrent);
   1.297 +    if (type == CFArrayGetTypeID()) {   /* if element is an array */
   1.298 +        CFRange range = { 0, CFArrayGetCount(refElementCurrent) };
   1.299          /* CountElementsCFArrayHandler called for each array member */
   1.300 -        CFArrayApplyFunction (refElementCurrent, range,
   1.301 -                              HIDGetElementsCFArrayHandler, pDevice);
   1.302 +        CFArrayApplyFunction(refElementCurrent, range,
   1.303 +                             HIDGetElementsCFArrayHandler, pDevice);
   1.304      }
   1.305  }
   1.306  
   1.307 @@ -420,39 +418,38 @@
   1.308   */
   1.309  
   1.310  static void
   1.311 -HIDGetCollectionElements (CFMutableDictionaryRef deviceProperties,
   1.312 -                          recDevice * pDevice)
   1.313 +HIDGetCollectionElements(CFMutableDictionaryRef deviceProperties,
   1.314 +                         recDevice * pDevice)
   1.315  {
   1.316      CFTypeRef refElementTop =
   1.317 -        CFDictionaryGetValue (deviceProperties, CFSTR (kIOHIDElementKey));
   1.318 +        CFDictionaryGetValue(deviceProperties, CFSTR(kIOHIDElementKey));
   1.319      if (refElementTop)
   1.320 -        HIDGetElements (refElementTop, pDevice);
   1.321 +        HIDGetElements(refElementTop, pDevice);
   1.322  }
   1.323  
   1.324  /* use top level element usage page and usage to discern device usage page and usage setting appropriate vlaues in device record */
   1.325  
   1.326  static void
   1.327 -HIDTopLevelElementHandler (const void *value, void *parameter)
   1.328 +HIDTopLevelElementHandler(const void *value, void *parameter)
   1.329  {
   1.330      CFTypeRef refCF = 0;
   1.331 -    if (CFGetTypeID (value) != CFDictionaryGetTypeID ())
   1.332 +    if (CFGetTypeID(value) != CFDictionaryGetTypeID())
   1.333          return;
   1.334 -    refCF = CFDictionaryGetValue (value, CFSTR (kIOHIDElementUsagePageKey));
   1.335 +    refCF = CFDictionaryGetValue(value, CFSTR(kIOHIDElementUsagePageKey));
   1.336      if (!CFNumberGetValue
   1.337          (refCF, kCFNumberLongType, &((recDevice *) parameter)->usagePage))
   1.338 -        SDL_SetError
   1.339 -            ("CFNumberGetValue error retrieving pDevice->usagePage.");
   1.340 -    refCF = CFDictionaryGetValue (value, CFSTR (kIOHIDElementUsageKey));
   1.341 +        SDL_SetError("CFNumberGetValue error retrieving pDevice->usagePage.");
   1.342 +    refCF = CFDictionaryGetValue(value, CFSTR(kIOHIDElementUsageKey));
   1.343      if (!CFNumberGetValue
   1.344          (refCF, kCFNumberLongType, &((recDevice *) parameter)->usage))
   1.345 -        SDL_SetError ("CFNumberGetValue error retrieving pDevice->usage.");
   1.346 +        SDL_SetError("CFNumberGetValue error retrieving pDevice->usage.");
   1.347  }
   1.348  
   1.349  /* extracts device info from CF dictionary records in IO registry */
   1.350  
   1.351  static void
   1.352 -HIDGetDeviceInfo (io_object_t hidDevice, CFMutableDictionaryRef hidProperties,
   1.353 -                  recDevice * pDevice)
   1.354 +HIDGetDeviceInfo(io_object_t hidDevice, CFMutableDictionaryRef hidProperties,
   1.355 +                 recDevice * pDevice)
   1.356  {
   1.357      CFMutableDictionaryRef usbProperties = 0;
   1.358      io_registry_entry_t parent1, parent2;
   1.359 @@ -461,14 +458,13 @@
   1.360       * get dictionary for usb properties: step up two levels and get CF dictionary for USB properties
   1.361       */
   1.362      if ((KERN_SUCCESS ==
   1.363 -         IORegistryEntryGetParentEntry (hidDevice, kIOServicePlane, &parent1))
   1.364 +         IORegistryEntryGetParentEntry(hidDevice, kIOServicePlane, &parent1))
   1.365          && (KERN_SUCCESS ==
   1.366 -            IORegistryEntryGetParentEntry (parent1, kIOServicePlane,
   1.367 -                                           &parent2))
   1.368 +            IORegistryEntryGetParentEntry(parent1, kIOServicePlane, &parent2))
   1.369          && (KERN_SUCCESS ==
   1.370 -            IORegistryEntryCreateCFProperties (parent2, &usbProperties,
   1.371 -                                               kCFAllocatorDefault,
   1.372 -                                               kNilOptions))) {
   1.373 +            IORegistryEntryCreateCFProperties(parent2, &usbProperties,
   1.374 +                                              kCFAllocatorDefault,
   1.375 +                                              kNilOptions))) {
   1.376          if (usbProperties) {
   1.377              CFTypeRef refCF = 0;
   1.378              /* get device info
   1.379 @@ -478,32 +474,31 @@
   1.380  
   1.381              /* get product name */
   1.382              refCF =
   1.383 -                CFDictionaryGetValue (hidProperties,
   1.384 -                                      CFSTR (kIOHIDProductKey));
   1.385 +                CFDictionaryGetValue(hidProperties, CFSTR(kIOHIDProductKey));
   1.386              if (!refCF)
   1.387                  refCF =
   1.388 -                    CFDictionaryGetValue (usbProperties,
   1.389 -                                          CFSTR ("USB Product Name"));
   1.390 +                    CFDictionaryGetValue(usbProperties,
   1.391 +                                         CFSTR("USB Product Name"));
   1.392              if (refCF) {
   1.393                  if (!CFStringGetCString
   1.394                      (refCF, pDevice->product, 256,
   1.395 -                     CFStringGetSystemEncoding ()))
   1.396 +                     CFStringGetSystemEncoding()))
   1.397                      SDL_SetError
   1.398                          ("CFStringGetCString error retrieving pDevice->product.");
   1.399              }
   1.400  
   1.401              /* get usage page and usage */
   1.402              refCF =
   1.403 -                CFDictionaryGetValue (hidProperties,
   1.404 -                                      CFSTR (kIOHIDPrimaryUsagePageKey));
   1.405 +                CFDictionaryGetValue(hidProperties,
   1.406 +                                     CFSTR(kIOHIDPrimaryUsagePageKey));
   1.407              if (refCF) {
   1.408                  if (!CFNumberGetValue
   1.409                      (refCF, kCFNumberLongType, &pDevice->usagePage))
   1.410                      SDL_SetError
   1.411                          ("CFNumberGetValue error retrieving pDevice->usagePage.");
   1.412                  refCF =
   1.413 -                    CFDictionaryGetValue (hidProperties,
   1.414 -                                          CFSTR (kIOHIDPrimaryUsageKey));
   1.415 +                    CFDictionaryGetValue(hidProperties,
   1.416 +                                         CFSTR(kIOHIDPrimaryUsageKey));
   1.417                  if (refCF)
   1.418                      if (!CFNumberGetValue
   1.419                          (refCF, kCFNumberLongType, &pDevice->usage))
   1.420 @@ -515,53 +510,53 @@
   1.421                  /* use top level element instead */
   1.422                  CFTypeRef refCFTopElement = 0;
   1.423                  refCFTopElement =
   1.424 -                    CFDictionaryGetValue (hidProperties,
   1.425 -                                          CFSTR (kIOHIDElementKey));
   1.426 +                    CFDictionaryGetValue(hidProperties,
   1.427 +                                         CFSTR(kIOHIDElementKey));
   1.428                  {
   1.429                      /* refCFTopElement points to an array of element dictionaries */
   1.430 -                    CFRange range = { 0, CFArrayGetCount (refCFTopElement) };
   1.431 -                    CFArrayApplyFunction (refCFTopElement, range,
   1.432 -                                          HIDTopLevelElementHandler, pDevice);
   1.433 +                    CFRange range = { 0, CFArrayGetCount(refCFTopElement) };
   1.434 +                    CFArrayApplyFunction(refCFTopElement, range,
   1.435 +                                         HIDTopLevelElementHandler, pDevice);
   1.436                  }
   1.437              }
   1.438  
   1.439 -            CFRelease (usbProperties);
   1.440 +            CFRelease(usbProperties);
   1.441          } else
   1.442              SDL_SetError
   1.443                  ("IORegistryEntryCreateCFProperties failed to create usbProperties.");
   1.444  
   1.445 -        if (kIOReturnSuccess != IOObjectRelease (parent2))
   1.446 -            SDL_SetError ("IOObjectRelease error with parent2.");
   1.447 -        if (kIOReturnSuccess != IOObjectRelease (parent1))
   1.448 -            SDL_SetError ("IOObjectRelease error with parent1.");
   1.449 +        if (kIOReturnSuccess != IOObjectRelease(parent2))
   1.450 +            SDL_SetError("IOObjectRelease error with parent2.");
   1.451 +        if (kIOReturnSuccess != IOObjectRelease(parent1))
   1.452 +            SDL_SetError("IOObjectRelease error with parent1.");
   1.453      }
   1.454  }
   1.455  
   1.456  
   1.457  static recDevice *
   1.458 -HIDBuildDevice (io_object_t hidDevice)
   1.459 +HIDBuildDevice(io_object_t hidDevice)
   1.460  {
   1.461 -    recDevice *pDevice = (recDevice *) NewPtrClear (sizeof (recDevice));
   1.462 +    recDevice *pDevice = (recDevice *) NewPtrClear(sizeof(recDevice));
   1.463      if (pDevice) {
   1.464          /* get dictionary for HID properties */
   1.465          CFMutableDictionaryRef hidProperties = 0;
   1.466          kern_return_t result =
   1.467 -            IORegistryEntryCreateCFProperties (hidDevice, &hidProperties,
   1.468 -                                               kCFAllocatorDefault,
   1.469 -                                               kNilOptions);
   1.470 +            IORegistryEntryCreateCFProperties(hidDevice, &hidProperties,
   1.471 +                                              kCFAllocatorDefault,
   1.472 +                                              kNilOptions);
   1.473          if ((result == KERN_SUCCESS) && hidProperties) {
   1.474              /* create device interface */
   1.475 -            result = HIDCreateOpenDeviceInterface (hidDevice, pDevice);
   1.476 +            result = HIDCreateOpenDeviceInterface(hidDevice, pDevice);
   1.477              if (kIOReturnSuccess == result) {
   1.478 -                HIDGetDeviceInfo (hidDevice, hidProperties, pDevice);   /* hidDevice used to find parents in registry tree */
   1.479 -                HIDGetCollectionElements (hidProperties, pDevice);
   1.480 +                HIDGetDeviceInfo(hidDevice, hidProperties, pDevice);    /* hidDevice used to find parents in registry tree */
   1.481 +                HIDGetCollectionElements(hidProperties, pDevice);
   1.482              } else {
   1.483 -                DisposePtr ((Ptr) pDevice);
   1.484 +                DisposePtr((Ptr) pDevice);
   1.485                  pDevice = NULL;
   1.486              }
   1.487 -            CFRelease (hidProperties);
   1.488 +            CFRelease(hidProperties);
   1.489          } else {
   1.490 -            DisposePtr ((Ptr) pDevice);
   1.491 +            DisposePtr((Ptr) pDevice);
   1.492              pDevice = NULL;
   1.493          }
   1.494      }
   1.495 @@ -572,12 +567,12 @@
   1.496   */
   1.497  
   1.498  static void
   1.499 -HIDDisposeElementList (recElement ** elementList)
   1.500 +HIDDisposeElementList(recElement ** elementList)
   1.501  {
   1.502      recElement *pElement = *elementList;
   1.503      while (pElement) {
   1.504          recElement *pElementNext = pElement->pNext;
   1.505 -        DisposePtr ((Ptr) pElement);
   1.506 +        DisposePtr((Ptr) pElement);
   1.507          pElement = pElementNext;
   1.508      }
   1.509      *elementList = NULL;
   1.510 @@ -588,7 +583,7 @@
   1.511   */
   1.512  
   1.513  static recDevice *
   1.514 -HIDDisposeDevice (recDevice ** ppDevice)
   1.515 +HIDDisposeDevice(recDevice ** ppDevice)
   1.516  {
   1.517      kern_return_t result = KERN_SUCCESS;
   1.518      recDevice *pDeviceNext = NULL;
   1.519 @@ -597,16 +592,16 @@
   1.520          pDeviceNext = (*ppDevice)->pNext;
   1.521  
   1.522          /* free element lists */
   1.523 -        HIDDisposeElementList (&(*ppDevice)->firstAxis);
   1.524 -        HIDDisposeElementList (&(*ppDevice)->firstButton);
   1.525 -        HIDDisposeElementList (&(*ppDevice)->firstHat);
   1.526 +        HIDDisposeElementList(&(*ppDevice)->firstAxis);
   1.527 +        HIDDisposeElementList(&(*ppDevice)->firstButton);
   1.528 +        HIDDisposeElementList(&(*ppDevice)->firstHat);
   1.529  
   1.530 -        result = HIDCloseReleaseInterface (*ppDevice);  /* function sanity checks interface value (now application does not own device) */
   1.531 +        result = HIDCloseReleaseInterface(*ppDevice);   /* function sanity checks interface value (now application does not own device) */
   1.532          if (kIOReturnSuccess != result)
   1.533              HIDReportErrorNum
   1.534                  ("HIDCloseReleaseInterface failed when trying to dipose device.",
   1.535                   result);
   1.536 -        DisposePtr ((Ptr) * ppDevice);
   1.537 +        DisposePtr((Ptr) * ppDevice);
   1.538          *ppDevice = NULL;
   1.539      }
   1.540      return pDeviceNext;
   1.541 @@ -619,7 +614,7 @@
   1.542   * on an unrecoverable fatal error.
   1.543   */
   1.544  int
   1.545 -SDL_SYS_JoystickInit (void)
   1.546 +SDL_SYS_JoystickInit(void)
   1.547  {
   1.548      IOReturn result = kIOReturnSuccess;
   1.549      mach_port_t masterPort = 0;
   1.550 @@ -631,18 +626,18 @@
   1.551      SDL_numjoysticks = 0;
   1.552  
   1.553      if (gpDeviceList) {
   1.554 -        SDL_SetError ("Joystick: Device list already inited.");
   1.555 +        SDL_SetError("Joystick: Device list already inited.");
   1.556          return -1;
   1.557      }
   1.558  
   1.559 -    result = IOMasterPort (bootstrap_port, &masterPort);
   1.560 +    result = IOMasterPort(bootstrap_port, &masterPort);
   1.561      if (kIOReturnSuccess != result) {
   1.562 -        SDL_SetError ("Joystick: IOMasterPort error with bootstrap_port.");
   1.563 +        SDL_SetError("Joystick: IOMasterPort error with bootstrap_port.");
   1.564          return -1;
   1.565      }
   1.566  
   1.567      /* Set up a matching dictionary to search I/O Registry by class name for all HID class devices. */
   1.568 -    hidMatchDictionary = IOServiceMatching (kIOHIDDeviceKey);
   1.569 +    hidMatchDictionary = IOServiceMatching(kIOHIDDeviceKey);
   1.570      if (hidMatchDictionary) {
   1.571          /* Add key for device type (joystick, in this case) to refine the matching dictionary. */
   1.572  
   1.573 @@ -664,11 +659,11 @@
   1.574  
   1.575      /*/ Now search I/O Registry for matching devices. */
   1.576      result =
   1.577 -        IOServiceGetMatchingServices (masterPort, hidMatchDictionary,
   1.578 -                                      &hidObjectIterator);
   1.579 +        IOServiceGetMatchingServices(masterPort, hidMatchDictionary,
   1.580 +                                     &hidObjectIterator);
   1.581      /* Check for errors */
   1.582      if (kIOReturnSuccess != result) {
   1.583 -        SDL_SetError ("Joystick: Couldn't create a HID object iterator.");
   1.584 +        SDL_SetError("Joystick: Couldn't create a HID object iterator.");
   1.585          return -1;
   1.586      }
   1.587      if (!hidObjectIterator) {   /* there are no joysticks */
   1.588 @@ -682,14 +677,14 @@
   1.589  
   1.590      gpDeviceList = lastDevice = NULL;
   1.591  
   1.592 -    while ((ioHIDDeviceObject = IOIteratorNext (hidObjectIterator))) {
   1.593 +    while ((ioHIDDeviceObject = IOIteratorNext(hidObjectIterator))) {
   1.594          /* build a device record */
   1.595 -        device = HIDBuildDevice (ioHIDDeviceObject);
   1.596 +        device = HIDBuildDevice(ioHIDDeviceObject);
   1.597          if (!device)
   1.598              continue;
   1.599  
   1.600          /* dump device object, it is no longer needed */
   1.601 -        result = IOObjectRelease (ioHIDDeviceObject);
   1.602 +        result = IOObjectRelease(ioHIDDeviceObject);
   1.603  /*		if (KERN_SUCCESS != result)
   1.604  			HIDReportErrorNum ("IOObjectRelease error with ioHIDDeviceObject.", result);
   1.605  */
   1.606 @@ -700,8 +695,8 @@
   1.607                device->usage != kHIDUsage_GD_GamePad))) {
   1.608  
   1.609              /* release memory for the device */
   1.610 -            HIDDisposeDevice (&device);
   1.611 -            DisposePtr ((Ptr) device);
   1.612 +            HIDDisposeDevice(&device);
   1.613 +            DisposePtr((Ptr) device);
   1.614              continue;
   1.615          }
   1.616  
   1.617 @@ -712,7 +707,7 @@
   1.618              gpDeviceList = device;
   1.619          lastDevice = device;
   1.620      }
   1.621 -    result = IOObjectRelease (hidObjectIterator);       /* release the iterator */
   1.622 +    result = IOObjectRelease(hidObjectIterator);        /* release the iterator */
   1.623  
   1.624      /* Count the total number of devices we found */
   1.625      device = gpDeviceList;
   1.626 @@ -726,7 +721,7 @@
   1.627  
   1.628  /* Function to get the device-dependent name of a joystick */
   1.629  const char *
   1.630 -SDL_SYS_JoystickName (int index)
   1.631 +SDL_SYS_JoystickName(int index)
   1.632  {
   1.633      recDevice *device = gpDeviceList;
   1.634  
   1.635 @@ -742,7 +737,7 @@
   1.636   * It returns 0, or -1 if there is an error.
   1.637   */
   1.638  int
   1.639 -SDL_SYS_JoystickOpen (SDL_Joystick * joystick)
   1.640 +SDL_SYS_JoystickOpen(SDL_Joystick * joystick)
   1.641  {
   1.642      recDevice *device = gpDeviceList;
   1.643      int index;
   1.644 @@ -767,7 +762,7 @@
   1.645   * and update joystick device state.
   1.646   */
   1.647  void
   1.648 -SDL_SYS_JoystickUpdate (SDL_Joystick * joystick)
   1.649 +SDL_SYS_JoystickUpdate(SDL_Joystick * joystick)
   1.650  {
   1.651      recDevice *device = joystick->hwdata;
   1.652      recElement *element;
   1.653 @@ -780,13 +775,13 @@
   1.654  
   1.655              /* Tell the app that everything is centered/unpressed... */
   1.656              for (i = 0; i < device->axes; i++)
   1.657 -                SDL_PrivateJoystickAxis (joystick, i, 0);
   1.658 +                SDL_PrivateJoystickAxis(joystick, i, 0);
   1.659  
   1.660              for (i = 0; i < device->buttons; i++)
   1.661 -                SDL_PrivateJoystickButton (joystick, i, 0);
   1.662 +                SDL_PrivateJoystickButton(joystick, i, 0);
   1.663  
   1.664              for (i = 0; i < device->hats; i++)
   1.665 -                SDL_PrivateJoystickHat (joystick, i, SDL_HAT_CENTERED);
   1.666 +                SDL_PrivateJoystickHat(joystick, i, SDL_HAT_CENTERED);
   1.667          }
   1.668  
   1.669          return;
   1.670 @@ -795,9 +790,9 @@
   1.671      element = device->firstAxis;
   1.672      i = 0;
   1.673      while (element) {
   1.674 -        value = HIDScaledCalibratedValue (device, element, -32768, 32767);
   1.675 +        value = HIDScaledCalibratedValue(device, element, -32768, 32767);
   1.676          if (value != joystick->axes[i])
   1.677 -            SDL_PrivateJoystickAxis (joystick, i, value);
   1.678 +            SDL_PrivateJoystickAxis(joystick, i, value);
   1.679          element = element->pNext;
   1.680          ++i;
   1.681      }
   1.682 @@ -805,11 +800,11 @@
   1.683      element = device->firstButton;
   1.684      i = 0;
   1.685      while (element) {
   1.686 -        value = HIDGetElementValue (device, element);
   1.687 +        value = HIDGetElementValue(device, element);
   1.688          if (value > 1)          /* handle pressure-sensitive buttons */
   1.689              value = 1;
   1.690          if (value != joystick->buttons[i])
   1.691 -            SDL_PrivateJoystickButton (joystick, i, value);
   1.692 +            SDL_PrivateJoystickButton(joystick, i, value);
   1.693          element = element->pNext;
   1.694          ++i;
   1.695      }
   1.696 @@ -819,7 +814,7 @@
   1.697      while (element) {
   1.698          Uint8 pos = 0;
   1.699  
   1.700 -        value = HIDGetElementValue (device, element);
   1.701 +        value = HIDGetElementValue(device, element);
   1.702          if (element->max == 3)  /* 4 position hatswitch - scale up value */
   1.703              value *= 2;
   1.704          else if (element->max != 7)     /* Neither a 4 nor 8 positions - fall back to default position (centered) */
   1.705 @@ -858,7 +853,7 @@
   1.706              break;
   1.707          }
   1.708          if (pos != joystick->hats[i])
   1.709 -            SDL_PrivateJoystickHat (joystick, i, pos);
   1.710 +            SDL_PrivateJoystickHat(joystick, i, pos);
   1.711          element = element->pNext;
   1.712          ++i;
   1.713      }
   1.714 @@ -868,7 +863,7 @@
   1.715  
   1.716  /* Function to close a joystick after use */
   1.717  void
   1.718 -SDL_SYS_JoystickClose (SDL_Joystick * joystick)
   1.719 +SDL_SYS_JoystickClose(SDL_Joystick * joystick)
   1.720  {
   1.721      /* Should we do anything here? */
   1.722      return;
   1.723 @@ -876,10 +871,10 @@
   1.724  
   1.725  /* Function to perform any system-specific joystick related cleanup */
   1.726  void
   1.727 -SDL_SYS_JoystickQuit (void)
   1.728 +SDL_SYS_JoystickQuit(void)
   1.729  {
   1.730      while (NULL != gpDeviceList)
   1.731 -        gpDeviceList = HIDDisposeDevice (&gpDeviceList);
   1.732 +        gpDeviceList = HIDDisposeDevice(&gpDeviceList);
   1.733  }
   1.734  
   1.735  #endif /* SDL_JOYSTICK_IOKIT */