+ else
+ {
+ CFNumberGetValue(
+ (CFNumberRef)
+ CFDictionaryGetValue(
+ (CFDictionaryRef) CFArrayGetValueAtIndex(Array, i),
+ CFSTR(kIOHIDElementUsageKey)
+ ),
+ kCFNumberIntType,
+ &nUsage );
+
+ CFNumberGetValue(
+ (CFNumberRef)
+ CFDictionaryGetValue(
+ (CFDictionaryRef) CFArrayGetValueAtIndex(Array, i),
+ CFSTR(kIOHIDElementUsagePageKey)
+ ),
+ kCFNumberIntType,
+ &nPage );
+
+#if 0
+ wxLogSysError(wxT("[%i][%i]"), nUsage, nPage);
+#endif
+ if (nPage == kHIDPage_Button && nUsage <= 40)
+ AddCookieInQueue(CFArrayGetValueAtIndex(Array, i), nUsage-1 );
+ else if (nPage == kHIDPage_GenericDesktop)
+ {
+ //axis...
+ switch(nUsage)
+ {
+ case kHIDUsage_GD_X:
+ AddCookieInQueue(CFArrayGetValueAtIndex(Array, i), wxJS_AXIS_X);
+ wxGetIntFromCFDictionary(CFArrayGetValueAtIndex(Array, i),
+ CFSTR(kIOHIDElementMaxKey),
+ &m_nXMax);
+ wxGetIntFromCFDictionary(CFArrayGetValueAtIndex(Array, i),
+ CFSTR(kIOHIDElementMinKey),
+ &m_nXMin);
+ break;
+ case kHIDUsage_GD_Y:
+ AddCookieInQueue(CFArrayGetValueAtIndex(Array, i), wxJS_AXIS_Y);
+ wxGetIntFromCFDictionary(CFArrayGetValueAtIndex(Array, i),
+ CFSTR(kIOHIDElementMaxKey),
+ &m_nYMax);
+ wxGetIntFromCFDictionary(CFArrayGetValueAtIndex(Array, i),
+ CFSTR(kIOHIDElementMinKey),
+ &m_nYMin);
+ break;
+ case kHIDUsage_GD_Z:
+ AddCookieInQueue(CFArrayGetValueAtIndex(Array, i), wxJS_AXIS_Z);
+ wxGetIntFromCFDictionary(CFArrayGetValueAtIndex(Array, i),
+ CFSTR(kIOHIDElementMaxKey),
+ &m_nZMax);
+ wxGetIntFromCFDictionary(CFArrayGetValueAtIndex(Array, i),
+ CFSTR(kIOHIDElementMinKey),
+ &m_nZMin);
+ break;
+ default:
+ break;
+ }
+ }
+ else if (nPage == kHIDPage_Simulation && nUsage == kHIDUsage_Sim_Rudder)
+ {
+ //rudder...
+ AddCookieInQueue(CFArrayGetValueAtIndex(Array, i), wxJS_AXIS_RUDDER );
+ wxGetIntFromCFDictionary(CFArrayGetValueAtIndex(Array, i),
+ CFSTR(kIOHIDElementMaxKey),
+ &m_nRudderMax);
+ wxGetIntFromCFDictionary(CFArrayGetValueAtIndex(Array, i),
+ CFSTR(kIOHIDElementMinKey),
+ &m_nRudderMin);
+ }
+ }
+ }
+}
+
+//---------------------------------------------------------------------------
+// wxHIDJoystick::Get[XXX]
+//
+// Simple accessors so that the HID callback and the thread procedure
+// can access members from wxHIDDevice (our parent here).
+//---------------------------------------------------------------------------
+IOHIDElementCookie* wxHIDJoystick::GetCookies()
+{ return m_pCookies; }
+IOHIDQueueInterface** wxHIDJoystick::GetQueue()
+{ return m_ppQueue; }
+
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// wxJoystickThread
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// wxJoystickThread Constructor
+//
+// Just initializes members
+//---------------------------------------------------------------------------
+wxJoystickThread::wxJoystickThread(wxHIDJoystick* hid, int joystick)
+ : m_hid(hid),
+ m_joystick(joystick),
+ m_lastposition(127,127),
+ m_buttons(0),
+ m_catchwin(NULL),
+ m_polling(0)
+{
+ memset(m_axe, 0, sizeof(int) * wxJS_MAX_AXES);