]>
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 /////////////////////////////////////////////////////////////////////////////
11 // ===========================================================================
13 // ===========================================================================
15 // ---------------------------------------------------------------------------
17 // ---------------------------------------------------------------------------
19 #ifndef _WX_MACCARBONHID_H_
20 #define _WX_MACCARBONHID_H_
22 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
23 #pragma interface "hid.h"
29 // ---------------------------------------------------------------------------
31 // ---------------------------------------------------------------------------
36 #include <IOKit/IOKitLib.h>
37 #include <IOKit/IOCFPlugIn.h>
38 #include <IOKit/hid/IOHIDLib.h>
39 #include <IOKit/hid/IOHIDKeys.h>
40 #include <Kernel/IOKit/hidsystem/IOHIDUsageTables.h>
42 #include <mach/mach.h>
44 //Utility wrapper around CFArray
48 wxCFArray(CFTypeRef pData
) : pArray((CFArrayRef
) pData
) {}
49 CFTypeRef
operator [] (const int& nIndex
) {return CFArrayGetValueAtIndex(pArray
, nIndex
); }
50 int Count() {return CFArrayGetCount(pArray
);}
56 // A wrapper around OS X HID Manager procedures.
57 // The tutorial "Working With HID Class Device Interfaces" Is
58 // Quite good, as is the sample program associated with it
59 // (Depite the author's protests!).
63 wxHIDDevice() : m_ppDevice(NULL
), m_ppQueue(NULL
), m_pCookies(NULL
) {}
64 //kHIDPage_GenericDesktop
65 //kHIDUsage_GD_Joystick,kHIDUsage_GD_Mouse,kHIDUsage_GD_Keyboard
66 bool Create (const int& nClass
= -1, const int& nType
= -1);
68 inline void AddCookie(CFTypeRef Data
, const int& i
);
69 inline void AddCookieInQueue(CFTypeRef Data
, const int& i
);
70 inline void InitCookies(const size_t& dwSize
, bool bQueue
= false);
72 //Must be implemented by derived classes
73 //builds the cookie array -
74 //first call InitCookies to initialize the cookie
75 //array, then AddCookie to add a cookie at a certain point in an array
76 virtual void BuildCookies(wxCFArray
& Array
) = 0;
78 //checks to see whether the cookie at index nIndex is active (element value != 0)
79 bool IsActive(const int& nIndex
);
81 //closes the device and cleans the queue and cookies
82 virtual ~wxHIDDevice();
84 IOHIDDeviceInterface
** m_ppDevice
; //this, essentially
85 IOHIDQueueInterface
** m_ppQueue
; //queue (if we want one)
86 IOHIDElementCookie
* m_pCookies
; //cookies
88 const char* m_szName
; //(product) name
92 class wxHIDKeyboard
: public wxHIDDevice
96 virtual void BuildCookies(wxCFArray
& Array
);