]> git.saurik.com Git - wxWidgets.git/blobdiff - src/mac/corefoundation/hidjoystick.cpp
bringing wxmac in line using cflocale
[wxWidgets.git] / src / mac / corefoundation / hidjoystick.cpp
index 7b42508e18b65e06f10844ab9a19a81e5933b72d..637546c41458c247a4a867e0c3b5380e2c698c73 100644 (file)
@@ -1,12 +1,12 @@
 /////////////////////////////////////////////////////////////////////////////
 /////////////////////////////////////////////////////////////////////////////
-// Name:        joystick.cpp
+// Name:        src/mac/corefoundation/joystick.cpp
 // Purpose:     wxJoystick class
 // Author:      Ryan Norton
 // Modified by:
 // Created:     2/13/2005
 // RCS-ID:      $Id$
 // Copyright:   (c) Ryan Norton
 // Purpose:     wxJoystick class
 // Author:      Ryan Norton
 // Modified by:
 // Created:     2/13/2005
 // RCS-ID:      $Id$
 // Copyright:   (c) Ryan Norton
-// Licence:       wxWindows licence
+// Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
 //===========================================================================
 /////////////////////////////////////////////////////////////////////////////
 
 //===========================================================================
 //---------------------------------------------------------------------------
 
 //we only support HID on OSX (DARWIN), since it requires DARWIN...
 //---------------------------------------------------------------------------
 
 //we only support HID on OSX (DARWIN), since it requires DARWIN...
-#if wxUSE_JOYSTICK && defined(__DARWIN__)
+#if wxUSE_JOYSTICK && wxUSE_THREADS
 
 //---------------------------------------------------------------------------
 // Includes
 //---------------------------------------------------------------------------
 
 //---------------------------------------------------------------------------
 // Includes
 //---------------------------------------------------------------------------
-#include "wx/event.h"       //joystick wxEvents
-#include "wx/log.h"         //logging...
+
+#ifndef WX_PRECOMP
+    #include "wx/log.h"
+    #include "wx/event.h"   //joystick wxEvents
+    #include "wx/window.h"  //for wxWindow to "capture" joystick
+#endif
+
 #include "wx/joystick.h"    //...
 #include "wx/thread.h"      //wxThread for polling thread/ wxCriticalSection
 #include "wx/joystick.h"    //...
 #include "wx/thread.h"      //wxThread for polling thread/ wxCriticalSection
-#include "wx/window.h"      //for wxWindow to "capture" joystick
 
 //private headers
 #include "wx/mac/corefoundation/hid.h" //private mac hid stuff
 
 //private headers
 #include "wx/mac/corefoundation/hid.h" //private mac hid stuff
@@ -52,7 +56,7 @@
 #define wxJS_MAX_AXES       10 /*max number of axes*/
 #define wxJS_MAX_BUTTONS    40 /*max number of buttons*/
 
 #define wxJS_MAX_AXES       10 /*max number of axes*/
 #define wxJS_MAX_BUTTONS    40 /*max number of buttons*/
 
-enum 
+enum
 {
     //These are positions within the cookie array
     //in wxHIDJoystick that the cookies that store the axis' are
 {
     //These are positions within the cookie array
     //in wxHIDJoystick that the cookies that store the axis' are
@@ -71,14 +75,14 @@ class wxHIDJoystick : public wxHIDDevice
 {
 public:
     wxHIDJoystick();
 {
 public:
     wxHIDJoystick();
-    ~wxHIDJoystick();
-    
-       bool Create(int nWhich);
-       virtual void BuildCookies(CFArrayRef Array);
-       void MakeCookies(CFArrayRef Array);
+    virtual ~wxHIDJoystick();
+
+    bool Create(int nWhich);
+    virtual void BuildCookies(CFArrayRef Array);
+    void MakeCookies(CFArrayRef Array);
     IOHIDElementCookie* GetCookies();
     IOHIDQueueInterface** GetQueue();
     IOHIDElementCookie* GetCookies();
     IOHIDQueueInterface** GetQueue();
-    
+
     int  m_nXMax, m_nYMax, m_nZMax, m_nRudderMax, m_nUMax, m_nVMax,
          m_nXMin, m_nYMin, m_nZMin, m_nRudderMin, m_nUMin, m_nVMin;
 
     int  m_nXMax, m_nYMax, m_nZMax, m_nRudderMax, m_nUMax, m_nVMax,
          m_nXMin, m_nYMin, m_nZMin, m_nRudderMin, m_nUMin, m_nVMin;
 
@@ -94,7 +98,7 @@ public:
     wxJoystickThread(wxHIDJoystick* hid, int joystick);
     void* Entry();
     static void HIDCallback(void* target, IOReturn res, void* context, void* sender);
     wxJoystickThread(wxHIDJoystick* hid, int joystick);
     void* Entry();
     static void HIDCallback(void* target, IOReturn res, void* context, void* sender);
-    
+
 private:
     wxHIDJoystick*       m_hid;
     int       m_joystick;
 private:
     wxHIDJoystick*       m_hid;
     int       m_joystick;
@@ -119,9 +123,9 @@ private:
 void wxGetIntFromCFDictionary(CFTypeRef cfDict, CFStringRef key, int* pOut)
 {
         CFNumberGetValue(
 void wxGetIntFromCFDictionary(CFTypeRef cfDict, CFStringRef key, int* pOut)
 {
         CFNumberGetValue(
-          (CFNumberRef) CFDictionaryGetValue((CFDictionaryRef) cfDict, 
-                                              key), 
-                               kCFNumberIntType, pOut);
+          (CFNumberRef) CFDictionaryGetValue((CFDictionaryRef) cfDict,
+                                              key),
+                        kCFNumberIntType, pOut);
 }
 
 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 }
 
 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
@@ -161,7 +165,7 @@ wxJoystick::wxJoystick(int joystick)
 //---------------------------------------------------------------------------
 // wxJoystick Destructor
 //
 //---------------------------------------------------------------------------
 // wxJoystick Destructor
 //
-// Releases the capture of the thread, deletes it, and deletes 
+// Releases the capture of the thread, deletes it, and deletes
 // the native implementation.
 //---------------------------------------------------------------------------
 wxJoystick::~wxJoystick()
 // the native implementation.
 //---------------------------------------------------------------------------
 wxJoystick::~wxJoystick()
@@ -169,7 +173,7 @@ wxJoystick::~wxJoystick()
     ReleaseCapture();
     if (m_thread)
         m_thread->Delete();  // It's detached so it will delete itself
     ReleaseCapture();
     if (m_thread)
         m_thread->Delete();  // It's detached so it will delete itself
-        
+
     if (m_hid)
         delete m_hid;
 }
     if (m_hid)
         delete m_hid;
 }
@@ -178,7 +182,7 @@ wxJoystick::~wxJoystick()
 // wxJoystick::Get[XXX]Position
 //
 // Returns the value of an axis that was polled from the thread. In the
 // wxJoystick::Get[XXX]Position
 //
 // Returns the value of an axis that was polled from the thread. In the
-// case of GetPosition returns the X and Y values in a wxPoint 
+// case of GetPosition returns the X and Y values in a wxPoint
 //---------------------------------------------------------------------------
 wxPoint wxJoystick::GetPosition() const
 {
 //---------------------------------------------------------------------------
 wxPoint wxJoystick::GetPosition() const
 {
@@ -193,7 +197,7 @@ int wxJoystick::GetZPosition() const
     return 0;
 }
 int wxJoystick::GetRudderPosition() const
     return 0;
 }
 int wxJoystick::GetRudderPosition() const
-{      
+{
     if (m_thread)
         return m_thread->m_axe[wxJS_AXIS_RUDDER];
     return 0;
     if (m_thread)
         return m_thread->m_axe[wxJS_AXIS_RUDDER];
     return 0;
@@ -231,27 +235,35 @@ int wxJoystick::GetButtonState() const
 // if the native implementation doesn't exist (in constructor)
 //---------------------------------------------------------------------------
 bool wxJoystick::IsOk() const
 // if the native implementation doesn't exist (in constructor)
 //---------------------------------------------------------------------------
 bool wxJoystick::IsOk() const
-{      
-    return m_hid != NULL;      
+{
+    return m_hid != NULL;
 }
 }
-    
+
 //---------------------------------------------------------------------------
 // wxJoystick::Get[XXX](Id/Name)
 //
 // Simple accessors to the native HID implementation
 //---------------------------------------------------------------------------
 int wxJoystick::GetManufacturerId() const
 //---------------------------------------------------------------------------
 // wxJoystick::Get[XXX](Id/Name)
 //
 // Simple accessors to the native HID implementation
 //---------------------------------------------------------------------------
 int wxJoystick::GetManufacturerId() const
-{      return m_hid->m_nManufacturerId;                                }
+{
+    return m_hid->m_nManufacturerId;
+}
+
 int wxJoystick::GetProductId() const
 int wxJoystick::GetProductId() const
-{      return m_hid->m_nProductId;                             }
+{
+    return m_hid->m_nProductId;
+}
+
 wxString wxJoystick::GetProductName() const
 wxString wxJoystick::GetProductName() const
-{      return m_hid->m_szProductName;                          }
+{
+    return m_hid->m_szProductName;
+}
 
 //---------------------------------------------------------------------------
 // wxJoystick::GetNumberButtons
 // wxJoystick::GetNumberAxes
 //
 
 //---------------------------------------------------------------------------
 // wxJoystick::GetNumberButtons
 // wxJoystick::GetNumberAxes
 //
-// Queries the joystick for an active number of buttons/axes. 
+// Queries the joystick for an active number of buttons/axes.
 //
 // In the native HID implementation, the cookies:
 // 0-40     are the buttons of the joystick
 //
 // In the native HID implementation, the cookies:
 // 0-40     are the buttons of the joystick
@@ -262,25 +274,25 @@ wxString wxJoystick::GetProductName() const
 int wxJoystick::GetNumberButtons() const
 {
     int nCount = 0;
 int wxJoystick::GetNumberButtons() const
 {
     int nCount = 0;
-    
+
     for(int nIndex = 0; nIndex < 40; ++nIndex)
     {
         if(m_hid->HasElement(nIndex))
             ++nCount;
     }
     for(int nIndex = 0; nIndex < 40; ++nIndex)
     {
         if(m_hid->HasElement(nIndex))
             ++nCount;
     }
-    
+
     return nCount;
 }
 int wxJoystick::GetNumberAxes() const
 {
     int nCount = 0;
     return nCount;
 }
 int wxJoystick::GetNumberAxes() const
 {
     int nCount = 0;
-    
+
     for(int nIndex = 40; nIndex < 50; ++nIndex)
     {
         if(m_hid->HasElement(nIndex))
             ++nCount;
     }
     for(int nIndex = 40; nIndex < 50; ++nIndex)
     {
         if(m_hid->HasElement(nIndex))
             ++nCount;
     }
-    
+
     return nCount;
 }
 
     return nCount;
 }
 
@@ -292,10 +304,10 @@ int wxJoystick::GetNumberAxes() const
 // identifiers.
 //---------------------------------------------------------------------------
 int wxJoystick::GetNumberJoysticks()
 // identifiers.
 //---------------------------------------------------------------------------
 int wxJoystick::GetNumberJoysticks()
-{    
-    return 
+{
+    return
         wxHIDDevice::GetCount(kHIDPage_GenericDesktop, kHIDUsage_GD_Joystick) +
         wxHIDDevice::GetCount(kHIDPage_GenericDesktop, kHIDUsage_GD_Joystick) +
-        wxHIDDevice::GetCount(kHIDPage_GenericDesktop, kHIDUsage_GD_GamePad);   
+        wxHIDDevice::GetCount(kHIDPage_GenericDesktop, kHIDUsage_GD_GamePad);
 }
 
 //---------------------------------------------------------------------------
 }
 
 //---------------------------------------------------------------------------
@@ -339,30 +351,64 @@ bool wxJoystick::ReleaseCapture()
 // axis doesn't exist.
 //---------------------------------------------------------------------------
 int wxJoystick::GetXMin() const
 // axis doesn't exist.
 //---------------------------------------------------------------------------
 int wxJoystick::GetXMin() const
-{      return m_hid->m_nXMin;  }
+{
+    return m_hid->m_nXMin;
+}
+
 int wxJoystick::GetYMin() const
 int wxJoystick::GetYMin() const
-{      return m_hid->m_nYMin;  }
+{
+    return m_hid->m_nYMin;
+}
+
 int wxJoystick::GetZMin() const
 int wxJoystick::GetZMin() const
-{      return m_hid->m_nZMin;  }
+{
+    return m_hid->m_nZMin;
+}
+
 int wxJoystick::GetRudderMin() const
 int wxJoystick::GetRudderMin() const
-{      return m_hid->m_nRudderMin;     }
+{
+    return m_hid->m_nRudderMin;
+}
+
 int wxJoystick::GetUMin() const
 int wxJoystick::GetUMin() const
-{      return m_hid->m_nUMin;  }
+{
+    return m_hid->m_nUMin;
+}
+
 int wxJoystick::GetVMin() const
 int wxJoystick::GetVMin() const
-{      return m_hid->m_nVMin;  }
+{
+    return m_hid->m_nVMin;
+}
 
 int wxJoystick::GetXMax() const
 
 int wxJoystick::GetXMax() const
-{      return m_hid->m_nXMax;  }
+{
+    return m_hid->m_nXMax;
+}
+
 int wxJoystick::GetYMax() const
 int wxJoystick::GetYMax() const
-{      return m_hid->m_nYMax;  }
+{
+    return m_hid->m_nYMax;
+}
+
 int wxJoystick::GetZMax() const
 int wxJoystick::GetZMax() const
-{      return m_hid->m_nZMax;  }
+{
+    return m_hid->m_nZMax;
+}
+
 int wxJoystick::GetRudderMax() const
 int wxJoystick::GetRudderMax() const
-{      return m_hid->m_nRudderMax;     }
+{
+    return m_hid->m_nRudderMax;
+}
+
 int wxJoystick::GetUMax() const
 int wxJoystick::GetUMax() const
-{      return m_hid->m_nUMax;  }
+{
+    return m_hid->m_nUMax;
+}
+
 int wxJoystick::GetVMax() const
 int wxJoystick::GetVMax() const
-{      return m_hid->m_nVMax;  }
+{
+    return m_hid->m_nVMax;
+}
 
 //---------------------------------------------------------------------------
 // wxJoystick::Get[XXX]
 
 //---------------------------------------------------------------------------
 // wxJoystick::Get[XXX]
@@ -371,13 +417,24 @@ int wxJoystick::GetVMax() const
 // what the linux port has.
 //---------------------------------------------------------------------------
 int wxJoystick::GetMaxButtons() const
 // what the linux port has.
 //---------------------------------------------------------------------------
 int wxJoystick::GetMaxButtons() const
-{      return wxJS_MAX_BUTTONS;        }
+{
+    return wxJS_MAX_BUTTONS;
+}
+
 int wxJoystick::GetMaxAxes() const
 int wxJoystick::GetMaxAxes() const
-{      return wxJS_MAX_AXES;   }
+{
+    return wxJS_MAX_AXES;
+}
+
 int wxJoystick::GetPollingMin() const
 int wxJoystick::GetPollingMin() const
-{      return 10;      }
+{
+    return 10;
+}
+
 int wxJoystick::GetPollingMax() const
 int wxJoystick::GetPollingMax() const
-{      return 1000;    }
+{
+    return 1000;
+}
 
 //---------------------------------------------------------------------------
 // wxJoystick::Has[XXX]
 
 //---------------------------------------------------------------------------
 // wxJoystick::Has[XXX]
@@ -386,31 +443,61 @@ int wxJoystick::GetPollingMax() const
 // when enumerating the cookies of the joystick device
 //---------------------------------------------------------------------------
 bool wxJoystick::HasZ() const
 // when enumerating the cookies of the joystick device
 //---------------------------------------------------------------------------
 bool wxJoystick::HasZ() const
-{      return m_hid->HasElement(wxJS_AXIS_Z);  }
+{
+    return m_hid->HasElement(wxJS_AXIS_Z);
+}
+
 bool wxJoystick::HasRudder() const
 bool wxJoystick::HasRudder() const
-{      return m_hid->HasElement(wxJS_AXIS_RUDDER);     }
+{
+    return m_hid->HasElement(wxJS_AXIS_RUDDER);
+}
+
 bool wxJoystick::HasU() const
 bool wxJoystick::HasU() const
-{      return m_hid->HasElement(wxJS_AXIS_U);  }
+{
+    return m_hid->HasElement(wxJS_AXIS_U);
+}
+
 bool wxJoystick::HasV() const
 bool wxJoystick::HasV() const
-{      return m_hid->HasElement(wxJS_AXIS_V);  }
+{
+    return m_hid->HasElement(wxJS_AXIS_V);
+}
 
 //---------------------------------------------------------------------------
 // UNSUPPORTED
 //---------------------------------------------------------------------------
 int wxJoystick::GetPOVPosition() const
 
 //---------------------------------------------------------------------------
 // UNSUPPORTED
 //---------------------------------------------------------------------------
 int wxJoystick::GetPOVPosition() const
-{      return -1;                              }
+{
+    return -1;
+}
+
 int wxJoystick::GetPOVCTSPosition() const
 int wxJoystick::GetPOVCTSPosition() const
-{      return -1;                              }
+{
+    return -1;
+}
+
 int wxJoystick::GetMovementThreshold() const
 int wxJoystick::GetMovementThreshold() const
-{      return 0;                               }
-void wxJoystick::SetMovementThreshold(int threshold)
-{                                                      }
+{
+    return 0;
+}
+
+void wxJoystick::SetMovementThreshold(int WXUNUSED(threshold))
+{
+}
+
 bool wxJoystick::HasPOV() const
 bool wxJoystick::HasPOV() const
-{      return false;   }
+{
+    return false;
+}
+
 bool wxJoystick::HasPOV4Dir() const
 bool wxJoystick::HasPOV4Dir() const
-{      return false;   }
+{
+    return false;
+}
+
 bool wxJoystick::HasPOVCTS() const
 bool wxJoystick::HasPOVCTS() const
-{      return false;   }
+{
+    return false;
+}
 
 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 //
 
 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 //
@@ -420,7 +507,7 @@ bool wxJoystick::HasPOVCTS() const
 
 //---------------------------------------------------------------------------
 // wxHIDJoystick ctor
 
 //---------------------------------------------------------------------------
 // wxHIDJoystick ctor
-// 
+//
 // Initializes the min/max members
 //---------------------------------------------------------------------------
 wxHIDJoystick::wxHIDJoystick() :
 // Initializes the min/max members
 //---------------------------------------------------------------------------
 wxHIDJoystick::wxHIDJoystick() :
@@ -447,19 +534,19 @@ wxHIDJoystick::~wxHIDJoystick()
 bool wxHIDJoystick::Create(int nWhich)
 {
     int nJoysticks = GetCount(kHIDPage_GenericDesktop, kHIDUsage_GD_Joystick);
 bool wxHIDJoystick::Create(int nWhich)
 {
     int nJoysticks = GetCount(kHIDPage_GenericDesktop, kHIDUsage_GD_Joystick);
-    
+
     if (nWhich <= nJoysticks)
     if (nWhich <= nJoysticks)
-        return wxHIDDevice::Create(kHIDPage_GenericDesktop, 
-                                   kHIDUsage_GD_Joystick, 
+        return wxHIDDevice::Create(kHIDPage_GenericDesktop,
+                                   kHIDUsage_GD_Joystick,
                                    nWhich);
     else
         nWhich -= nJoysticks;
                                    nWhich);
     else
         nWhich -= nJoysticks;
-    
+
     int nGamePads = GetCount(kHIDPage_GenericDesktop, kHIDUsage_GD_GamePad);
     int nGamePads = GetCount(kHIDPage_GenericDesktop, kHIDUsage_GD_GamePad);
-    
+
     if (nWhich <= nGamePads)
     if (nWhich <= nGamePads)
-        return wxHIDDevice::Create(kHIDPage_GenericDesktop, 
-                                   kHIDUsage_GD_GamePad, 
+        return wxHIDDevice::Create(kHIDPage_GenericDesktop,
+                                   kHIDUsage_GD_GamePad,
                                    nWhich);
     else
     return false;
                                    nWhich);
     else
     return false;
@@ -472,20 +559,20 @@ bool wxHIDJoystick::Create(int nWhich)
 // Sets up the cookies for the HID device (called from Create) - as
 // mentioned 0-40 are the buttons and 40-50 are the axes.
 //
 // Sets up the cookies for the HID device (called from Create) - as
 // mentioned 0-40 are the buttons and 40-50 are the axes.
 //
-// MakeCookies is just a recursive function for each array within 
+// MakeCookies is just a recursive function for each array within
 // BuildCookies.
 //---------------------------------------------------------------------------
 void wxHIDJoystick::BuildCookies(CFArrayRef Array)
 {
 // BuildCookies.
 //---------------------------------------------------------------------------
 void wxHIDJoystick::BuildCookies(CFArrayRef Array)
 {
-       InitCookies(50, true);
+    InitCookies(50, true);
 
     //
     // I wasted two hours of my life on this line :(
     // accidently removed it during some source cleaning...
     //
     MakeCookies(Array);
 
     //
     // I wasted two hours of my life on this line :(
     // accidently removed it during some source cleaning...
     //
     MakeCookies(Array);
-    
-    //paranoid debugging stuff    
+
+    //paranoid debugging stuff
 #if 0
     for(int i = 0; i < 50; ++i)
         wxPrintf(wxT("\nVAL #%i:[%i]"), i, m_pCookies[i]);
 #if 0
     for(int i = 0; i < 50; ++i)
         wxPrintf(wxT("\nVAL #%i:[%i]"), i, m_pCookies[i]);
@@ -494,12 +581,12 @@ void wxHIDJoystick::BuildCookies(CFArrayRef Array)
 
 void wxHIDJoystick::MakeCookies(CFArrayRef Array)
 {
 
 void wxHIDJoystick::MakeCookies(CFArrayRef Array)
 {
-       int i, nUsage, nPage;
+    int i, nUsage, nPage;
 
 
-       for (i = 0; i < CFArrayGetCount(Array); ++i)
+    for (i = 0; i < CFArrayGetCount(Array); ++i)
     {
         const void* ref = CFDictionaryGetValue(
     {
         const void* ref = CFDictionaryGetValue(
-                (CFDictionaryRef)CFArrayGetValueAtIndex(Array, i), 
+                (CFDictionaryRef)CFArrayGetValueAtIndex(Array, i),
                 CFSTR(kIOHIDElementKey)
                                               );
 
                 CFSTR(kIOHIDElementKey)
                                               );
 
@@ -510,22 +597,22 @@ void wxHIDJoystick::MakeCookies(CFArrayRef Array)
         else
         {
             CFNumberGetValue(
         else
         {
             CFNumberGetValue(
-                           (CFNumberRef) 
-                               CFDictionaryGetValue( 
-                                   (CFDictionaryRef) CFArrayGetValueAtIndex(Array, i),
-                                   CFSTR(kIOHIDElementUsageKey)
-                                                   ), 
-                       kCFNumberIntType, 
-                               &nUsage    );
-                       
+                (CFNumberRef)
+                    CFDictionaryGetValue(
+                        (CFDictionaryRef) CFArrayGetValueAtIndex(Array, i),
+                        CFSTR(kIOHIDElementUsageKey)
+                                        ),
+                kCFNumberIntType,
+                &nUsage    );
+
             CFNumberGetValue(
             CFNumberGetValue(
-                           (CFNumberRef) 
-                               CFDictionaryGetValue(
-                                   (CFDictionaryRef) CFArrayGetValueAtIndex(Array, i), 
-                                   CFSTR(kIOHIDElementUsagePageKey)
-                                                   ), 
-                               kCFNumberIntType, 
-                               &nPage     );
+                (CFNumberRef)
+                    CFDictionaryGetValue(
+                        (CFDictionaryRef) CFArrayGetValueAtIndex(Array, i),
+                        CFSTR(kIOHIDElementUsagePageKey)
+                                        ),
+                kCFNumberIntType,
+                &nPage     );
 
 #if 0
             wxLogSysError(wxT("[%i][%i]"), nUsage, nPage);
 
 #if 0
             wxLogSysError(wxT("[%i][%i]"), nUsage, nPage);
@@ -539,28 +626,28 @@ void wxHIDJoystick::MakeCookies(CFArrayRef Array)
                 {
                     case kHIDUsage_GD_X:
                         AddCookieInQueue(CFArrayGetValueAtIndex(Array, i), wxJS_AXIS_X);
                 {
                     case kHIDUsage_GD_X:
                         AddCookieInQueue(CFArrayGetValueAtIndex(Array, i), wxJS_AXIS_X);
-                        wxGetIntFromCFDictionary(CFArrayGetValueAtIndex(Array, i), 
+                        wxGetIntFromCFDictionary(CFArrayGetValueAtIndex(Array, i),
                                                  CFSTR(kIOHIDElementMaxKey),
                                                  &m_nXMax);
                                                  CFSTR(kIOHIDElementMaxKey),
                                                  &m_nXMax);
-                        wxGetIntFromCFDictionary(CFArrayGetValueAtIndex(Array, i), 
+                        wxGetIntFromCFDictionary(CFArrayGetValueAtIndex(Array, i),
                                                  CFSTR(kIOHIDElementMinKey),
                                                  &m_nXMin);
                                                  CFSTR(kIOHIDElementMinKey),
                                                  &m_nXMin);
-                        break;                    
+                        break;
                     case kHIDUsage_GD_Y:
                         AddCookieInQueue(CFArrayGetValueAtIndex(Array, i), wxJS_AXIS_Y);
                     case kHIDUsage_GD_Y:
                         AddCookieInQueue(CFArrayGetValueAtIndex(Array, i), wxJS_AXIS_Y);
-                        wxGetIntFromCFDictionary(CFArrayGetValueAtIndex(Array, i), 
+                        wxGetIntFromCFDictionary(CFArrayGetValueAtIndex(Array, i),
                                                  CFSTR(kIOHIDElementMaxKey),
                                                  &m_nYMax);
                                                  CFSTR(kIOHIDElementMaxKey),
                                                  &m_nYMax);
-                        wxGetIntFromCFDictionary(CFArrayGetValueAtIndex(Array, i), 
+                        wxGetIntFromCFDictionary(CFArrayGetValueAtIndex(Array, i),
                                                  CFSTR(kIOHIDElementMinKey),
                                                  &m_nYMin);
                         break;
                     case kHIDUsage_GD_Z:
                         AddCookieInQueue(CFArrayGetValueAtIndex(Array, i), wxJS_AXIS_Z);
                                                  CFSTR(kIOHIDElementMinKey),
                                                  &m_nYMin);
                         break;
                     case kHIDUsage_GD_Z:
                         AddCookieInQueue(CFArrayGetValueAtIndex(Array, i), wxJS_AXIS_Z);
-                        wxGetIntFromCFDictionary(CFArrayGetValueAtIndex(Array, i), 
+                        wxGetIntFromCFDictionary(CFArrayGetValueAtIndex(Array, i),
                                                  CFSTR(kIOHIDElementMaxKey),
                                                  &m_nZMax);
                                                  CFSTR(kIOHIDElementMaxKey),
                                                  &m_nZMax);
-                        wxGetIntFromCFDictionary(CFArrayGetValueAtIndex(Array, i), 
+                        wxGetIntFromCFDictionary(CFArrayGetValueAtIndex(Array, i),
                                                  CFSTR(kIOHIDElementMinKey),
                                                  &m_nZMin);
                         break;
                                                  CFSTR(kIOHIDElementMinKey),
                                                  &m_nZMin);
                         break;
@@ -572,15 +659,15 @@ void wxHIDJoystick::MakeCookies(CFArrayRef Array)
             {
                 //rudder...
                 AddCookieInQueue(CFArrayGetValueAtIndex(Array, i), wxJS_AXIS_RUDDER );
             {
                 //rudder...
                 AddCookieInQueue(CFArrayGetValueAtIndex(Array, i), wxJS_AXIS_RUDDER );
-                wxGetIntFromCFDictionary(CFArrayGetValueAtIndex(Array, i), 
+                wxGetIntFromCFDictionary(CFArrayGetValueAtIndex(Array, i),
                                          CFSTR(kIOHIDElementMaxKey),
                                          &m_nRudderMax);
                                          CFSTR(kIOHIDElementMaxKey),
                                          &m_nRudderMax);
-                wxGetIntFromCFDictionary(CFArrayGetValueAtIndex(Array, i), 
+                wxGetIntFromCFDictionary(CFArrayGetValueAtIndex(Array, i),
                                          CFSTR(kIOHIDElementMinKey),
                                          &m_nRudderMin);
             }
         }
                                          CFSTR(kIOHIDElementMinKey),
                                          &m_nRudderMin);
             }
         }
-       }
+    }
 }
 
 //---------------------------------------------------------------------------
 }
 
 //---------------------------------------------------------------------------
@@ -589,9 +676,9 @@ void wxHIDJoystick::MakeCookies(CFArrayRef Array)
 // Simple accessors so that the HID callback and the thread procedure
 // can access members from wxHIDDevice (our parent here).
 //---------------------------------------------------------------------------
 // Simple accessors so that the HID callback and the thread procedure
 // can access members from wxHIDDevice (our parent here).
 //---------------------------------------------------------------------------
-IOHIDElementCookie* wxHIDJoystick::GetCookies() 
+IOHIDElementCookie* wxHIDJoystick::GetCookies()
 {   return m_pCookies;  }
 {   return m_pCookies;  }
-IOHIDQueueInterface** wxHIDJoystick::GetQueue() 
+IOHIDQueueInterface** wxHIDJoystick::GetQueue()
 {   return m_ppQueue;   }
 
 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 {   return m_ppQueue;   }
 
 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
@@ -637,16 +724,16 @@ void* wxJoystickThread::Entry()
         wxLogSysError(wxT("Couldn't create async event source"));
         return NULL;
     }
         wxLogSysError(wxT("Couldn't create async event source"));
         return NULL;
     }
-    
+
     wxASSERT(pRLSource != NULL);
 
     //attach runloop source to main run loop in thread
     CFRunLoopRef pRL = CFRunLoopGetCurrent();
     CFRunLoopAddSource(pRL, pRLSource, kCFRunLoopDefaultMode);
     wxASSERT( CFRunLoopContainsSource(pRL, pRLSource, kCFRunLoopDefaultMode) );
     wxASSERT(pRLSource != NULL);
 
     //attach runloop source to main run loop in thread
     CFRunLoopRef pRL = CFRunLoopGetCurrent();
     CFRunLoopAddSource(pRL, pRLSource, kCFRunLoopDefaultMode);
     wxASSERT( CFRunLoopContainsSource(pRL, pRLSource, kCFRunLoopDefaultMode) );
-          
 
 
-    if( (*m_hid->GetQueue())->setEventCallout(m_hid->GetQueue(), 
+
+    if( (*m_hid->GetQueue())->setEventCallout(m_hid->GetQueue(),
           wxJoystickThread::HIDCallback, this, this) != kIOReturnSuccess )
     {
         wxLogSysError(wxT("Could not set event callout for queue"));
           wxJoystickThread::HIDCallback, this, this) != kIOReturnSuccess )
     {
         wxLogSysError(wxT("Could not set event callout for queue"));
@@ -660,7 +747,7 @@ void* wxJoystickThread::Entry()
     }
 
     double dTime;
     }
 
     double dTime;
-    
+
     while(true)
     {
         if (TestDestroy())
     while(true)
     {
         if (TestDestroy())
@@ -674,16 +761,16 @@ void* wxJoystickThread::Entry()
         //true just "handles and returns" - false forces it to stay the time
         //amount
 #if 1
         //true just "handles and returns" - false forces it to stay the time
         //amount
 #if 1
-        CFRunLoopRunInMode(kCFRunLoopDefaultMode, dTime, true);          
+        CFRunLoopRunInMode(kCFRunLoopDefaultMode, dTime, true);
 #else
         IOReturn ret = NULL;
         HIDCallback(this, ret, this, this);
         Sleep(3000);
 #endif
     }
 #else
         IOReturn ret = NULL;
         HIDCallback(this, ret, this, this);
         Sleep(3000);
 #endif
     }
-    
+
     wxASSERT( CFRunLoopContainsSource(pRL, pRLSource, kCFRunLoopDefaultMode) );
     wxASSERT( CFRunLoopContainsSource(pRL, pRLSource, kCFRunLoopDefaultMode) );
-    
+
     CFRunLoopRemoveSource(pRL, pRLSource, kCFRunLoopDefaultMode);
     CFRelease(pRLSource);
 
     CFRunLoopRemoveSource(pRL, pRLSource, kCFRunLoopDefaultMode);
     CFRelease(pRLSource);
 
@@ -698,7 +785,7 @@ void* wxJoystickThread::Entry()
 // This is where the REAL dirty work gets done.
 //
 // 1) Loops through each event the queue has recieved
 // This is where the REAL dirty work gets done.
 //
 // 1) Loops through each event the queue has recieved
-// 2) First, checks if the thread that is running the loop for 
+// 2) First, checks if the thread that is running the loop for
 //    the polling has ended - if so it breaks out
 // 3) Next, it checks if there was an error getting this event from
 //    the HID queue, if there was, it logs an error and returns
 //    the polling has ended - if so it breaks out
 // 3) Next, it checks if there was an error getting this event from
 //    the HID queue, if there was, it logs an error and returns
@@ -708,21 +795,23 @@ void* wxJoystickThread::Entry()
 // 5) Sends the event to the polling window (if any)
 // 6) Gets the next event and goes back to (1)
 //---------------------------------------------------------------------------
 // 5) Sends the event to the polling window (if any)
 // 6) Gets the next event and goes back to (1)
 //---------------------------------------------------------------------------
-/*static*/ void wxJoystickThread::HIDCallback(void* target, IOReturn res, 
-                                              void* context, void* sender)
+/*static*/ void wxJoystickThread::HIDCallback(void* WXUNUSED(target),
+                                              IOReturn WXUNUSED(res),
+                                              void* context,
+                                              void* WXUNUSED(sender))
 {
     IOHIDEventStruct hidevent;
     AbsoluteTime bogustime = {0,0};
     IOReturn ret;
     wxJoystickThread* pThis = (wxJoystickThread*) context;
     wxHIDJoystick* m_hid = pThis->m_hid;
 {
     IOHIDEventStruct hidevent;
     AbsoluteTime bogustime = {0,0};
     IOReturn ret;
     wxJoystickThread* pThis = (wxJoystickThread*) context;
     wxHIDJoystick* m_hid = pThis->m_hid;
-    
+
     //Get the "first" event from the queue
     //bogustime tells it we don't care at what time to start
     //where it gets the next from
     //Get the "first" event from the queue
     //bogustime tells it we don't care at what time to start
     //where it gets the next from
-    ret = (*m_hid->GetQueue())->getNextEvent(m_hid->GetQueue(), 
+    ret = (*m_hid->GetQueue())->getNextEvent(m_hid->GetQueue(),
                     &hidevent, bogustime, 0);
                     &hidevent, bogustime, 0);
-    
+
     while (ret != kIOReturnUnderrun)
     {
         if (pThis->TestDestroy())
     while (ret != kIOReturnUnderrun)
     {
         if (pThis->TestDestroy())
@@ -732,10 +821,10 @@ void* wxJoystickThread::Entry()
         {
             wxLogSysError(wxString::Format(wxT("wxJoystick Error:[%i]"), ret));
             return;
         {
             wxLogSysError(wxString::Format(wxT("wxJoystick Error:[%i]"), ret));
             return;
-        }      
-            
+        }
+
         wxJoystickEvent wxevent;
         wxJoystickEvent wxevent;
-        
+
         //Find the cookie that changed
         int nIndex = 0;
         IOHIDElementCookie* pCookies = m_hid->GetCookies();
         //Find the cookie that changed
         int nIndex = 0;
         IOHIDElementCookie* pCookies = m_hid->GetCookies();
@@ -743,20 +832,20 @@ void* wxJoystickThread::Entry()
         {
             if(hidevent.elementCookie == pCookies[nIndex])
                 break;
         {
             if(hidevent.elementCookie == pCookies[nIndex])
                 break;
-                
+
             ++nIndex;
             ++nIndex;
-        } 
-        
+        }
+
         //debugging stuff
 #if 0
         //debugging stuff
 #if 0
-        if(nIndex == 50) 
+        if(nIndex == 50)
         {
             wxLogSysError(wxString::Format(wxT("wxJoystick Out Of Bounds Error")));
             break;
         {
             wxLogSysError(wxString::Format(wxT("wxJoystick Out Of Bounds Error")));
             break;
-        }      
+        }
 #endif
 
 #endif
 
-        //is the cookie a button?    
+        //is the cookie a button?
         if (nIndex < 40)
         {
             if (hidevent.value)
         if (nIndex < 40)
         {
             if (hidevent.value)
@@ -790,14 +879,14 @@ void* wxJoystickThread::Entry()
             pThis->m_axe[2] = hidevent.value;
         }
         else
             pThis->m_axe[2] = hidevent.value;
         }
         else
-            wxevent.SetEventType(wxEVT_JOY_MOVE);            
+            wxevent.SetEventType(wxEVT_JOY_MOVE);
 
         Nanoseconds timestamp = AbsoluteToNanoseconds(hidevent.timestamp);
 
         Nanoseconds timestamp = AbsoluteToNanoseconds(hidevent.timestamp);
-        
+
         wxULongLong llTime(timestamp.hi, timestamp.lo);
         wxULongLong llTime(timestamp.hi, timestamp.lo);
-        
+
         llTime /= 1000000;
         llTime /= 1000000;
-        
+
         wxevent.SetTimestamp(llTime.GetValue());
         wxevent.SetJoystick(pThis->m_joystick);
         wxevent.SetButtonState(pThis->m_buttons);
         wxevent.SetTimestamp(llTime.GetValue());
         wxevent.SetJoystick(pThis->m_joystick);
         wxevent.SetButtonState(pThis->m_buttons);
@@ -806,12 +895,11 @@ void* wxJoystickThread::Entry()
         wxevent.SetEventObject(pThis->m_catchwin);
 
         if (pThis->m_catchwin)
         wxevent.SetEventObject(pThis->m_catchwin);
 
         if (pThis->m_catchwin)
-            pThis->m_catchwin->AddPendingEvent(wxevent);            
+            pThis->m_catchwin->AddPendingEvent(wxevent);
 
 
-        ret = (*m_hid->GetQueue())->getNextEvent(m_hid->GetQueue(), 
+        ret = (*m_hid->GetQueue())->getNextEvent(m_hid->GetQueue(),
                     &hidevent, bogustime, 0);
     }
 }
 
                     &hidevent, bogustime, 0);
     }
 }
 
-#endif // wxUSE_JOYSTICK && defined(__DARWIN__)
-
+#endif // wxUSE_JOYSTICK