]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/mac/corefoundation/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"
27 #include "wx/string.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 (int nClass
= -1, int nType
= -1, int nDev
= 1);
68 static int GetCount(int nClass
= -1, int nType
= -1);
70 void AddCookie(CFTypeRef Data
, int i
);
71 void AddCookieInQueue(CFTypeRef Data
, int i
);
72 void InitCookies(size_t dwSize
, bool bQueue
= false);
74 //Must be implemented by derived classes
75 //builds the cookie array -
76 //first call InitCookies to initialize the cookie
77 //array, then AddCookie to add a cookie at a certain point in an array
78 virtual void BuildCookies(wxCFArray
& Array
) = 0;
80 //checks to see whether the cookie at nIndex is active (element value != 0)
81 bool IsActive(int nIndex
);
83 //checks to see whether the cookie at nIndex exists
84 bool HasElement(int nIndex
);
86 //closes the device and cleans the queue and cookies
87 virtual ~wxHIDDevice();
90 IOHIDDeviceInterface
** m_ppDevice
; //this, essentially
91 IOHIDQueueInterface
** m_ppQueue
; //queue (if we want one)
92 IOHIDElementCookie
* m_pCookies
; //cookies
94 wxString m_szProductName
; //product name
95 int m_nProductId
; //product id
96 int m_nManufacturerId
; //manufacturer id
100 class wxHIDKeyboard
: public wxHIDDevice
104 virtual void BuildCookies(wxCFArray
& Array
);