]> git.saurik.com Git - wxWidgets.git/blame - include/wx/mac/carbon/private/hid.h
added stock buttons support
[wxWidgets.git] / include / wx / mac / carbon / private / hid.h
CommitLineData
52479aef
SC
1#include <wx/wx.h>
2#include <IOKit/IOKitLib.h>
3#include <IOKit/IOCFPlugIn.h>
4#include <IOKit/hid/IOHIDLib.h>
5#include <IOKit/hid/IOHIDKeys.h>
6#include <Kernel/IOKit/hidsystem/IOHIDUsageTables.h>
7
8#include <mach/mach.h>
9
10//Utility wrapper around CFArray
11class wxCFArray
12{
13public:
14 wxCFArray(CFTypeRef pData) : pArray((CFArrayRef) pData) {}
15 CFTypeRef operator [] (const int& nIndex) {return CFArrayGetValueAtIndex(pArray, nIndex); }
16 int Count() {return CFArrayGetCount(pArray);}
17private:
18 CFArrayRef pArray;
19};
20
21//
22// A wrapper around OS X HID Manager procedures.
23// The tutorial "Working With HID Class Device Interfaces" Is
24// Quite good, as is the sample program associated with it
25// (Depite the author's protests!).
26class wxHIDDevice
27{
28public:
29 wxHIDDevice() : m_ppDevice(NULL), m_ppQueue(NULL), m_pCookies(NULL) {}
30 //kHIDPage_GenericDesktop
31 //kHIDUsage_GD_Joystick,kHIDUsage_GD_Mouse,kHIDUsage_GD_Keyboard
32 bool Create (const int& nClass = -1, const int& nType = -1);
33
34 inline void AddCookie(CFTypeRef Data, const int& i);
35 inline void AddCookieInQueue(CFTypeRef Data, const int& i);
36 inline void InitCookies(const size_t& dwSize, bool bQueue = false);
37
38 //Must be implemented by derived classes
39 //builds the cookie array -
40 //first call InitCookies to initialize the cookie
41 //array, then AddCookie to add a cookie at a certain point in an array
42 virtual void BuildCookies(wxCFArray& Array) = 0;
43
44 //checks to see whether the cookie at index nIndex is active (element value != 0)
45 bool IsActive(const int& nIndex);
46
47 //closes the device and cleans the queue and cookies
48 virtual ~wxHIDDevice();
49private:
50 IOHIDDeviceInterface** m_ppDevice; //this, essentially
51 IOHIDQueueInterface** m_ppQueue; //queue (if we want one)
52 IOHIDElementCookie* m_pCookies; //cookies
53
54 const char* m_szName; //(product) name
55 mach_port_t m_pPort;
56};
57
58class wxHIDKeyboard : public wxHIDDevice
59{
60public:
61 bool Create();
62 virtual void BuildCookies(wxCFArray& Array);
63};