]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/mac/carbon/private/hid.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: DARWIN HID layer for WX
8 // Copyright: (c) Ryan Norton
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
16 #include <IOKit/IOKitLib.h>
17 #include <IOKit/IOCFPlugIn.h>
18 #include <IOKit/hid/IOHIDLib.h>
19 #include <IOKit/hid/IOHIDKeys.h>
20 #include <Kernel/IOKit/hidsystem/IOHIDUsageTables.h>
22 #include <mach/mach.h>
24 //Utility wrapper around CFArray
28 wxCFArray(CFTypeRef pData
) : pArray((CFArrayRef
) pData
) {}
29 CFTypeRef
operator [] (const int& nIndex
) {return CFArrayGetValueAtIndex(pArray
, nIndex
); }
30 int Count() {return CFArrayGetCount(pArray
);}
36 // A wrapper around OS X HID Manager procedures.
37 // The tutorial "Working With HID Class Device Interfaces" Is
38 // Quite good, as is the sample program associated with it
39 // (Depite the author's protests!).
43 wxHIDDevice() : m_ppDevice(NULL
), m_ppQueue(NULL
), m_pCookies(NULL
) {}
44 //kHIDPage_GenericDesktop
45 //kHIDUsage_GD_Joystick,kHIDUsage_GD_Mouse,kHIDUsage_GD_Keyboard
46 bool Create (const int& nClass
= -1, const int& nType
= -1);
48 inline void AddCookie(CFTypeRef Data
, const int& i
);
49 inline void AddCookieInQueue(CFTypeRef Data
, const int& i
);
50 inline void InitCookies(const size_t& dwSize
, bool bQueue
= false);
52 //Must be implemented by derived classes
53 //builds the cookie array -
54 //first call InitCookies to initialize the cookie
55 //array, then AddCookie to add a cookie at a certain point in an array
56 virtual void BuildCookies(wxCFArray
& Array
) = 0;
58 //checks to see whether the cookie at index nIndex is active (element value != 0)
59 bool IsActive(const int& nIndex
);
61 //closes the device and cleans the queue and cookies
62 virtual ~wxHIDDevice();
64 IOHIDDeviceInterface
** m_ppDevice
; //this, essentially
65 IOHIDQueueInterface
** m_ppQueue
; //queue (if we want one)
66 IOHIDElementCookie
* m_pCookies
; //cookies
68 const char* m_szName
; //(product) name
72 class wxHIDKeyboard
: public wxHIDDevice
76 virtual void BuildCookies(wxCFArray
& Array
);