]>
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_
23 #include "wx/string.h"
25 // ---------------------------------------------------------------------------
27 // ---------------------------------------------------------------------------
32 #include <IOKit/IOKitLib.h>
33 #include <IOKit/IOCFPlugIn.h>
34 #include <IOKit/hid/IOHIDLib.h>
35 #include <IOKit/hid/IOHIDKeys.h>
36 #include <Kernel/IOKit/hidsystem/IOHIDUsageTables.h>
38 //Darn apple - doesn't properly wrap their headers in extern "C"!
39 //http://www.macosx.com/forums/archive/index.php/t-68069.html
40 //Needed for codewarrior link error with mach_port_deallocate()
42 #include <mach/mach_port.h>
45 #include <mach/mach.h> //this actually includes mach_port.h (see above)
47 //Utility wrapper around CFArray
51 wxCFArray(CFTypeRef pData
) : pArray((CFArrayRef
) pData
) {}
52 CFTypeRef
operator [] (const int& nIndex
) {return CFArrayGetValueAtIndex(pArray
, nIndex
); }
53 int Count() {return CFArrayGetCount(pArray
);}
59 // A wrapper around OS X HID Manager procedures.
60 // The tutorial "Working With HID Class Device Interfaces" Is
61 // Quite good, as is the sample program associated with it
62 // (Depite the author's protests!).
66 wxHIDDevice() : m_ppDevice(NULL
), m_ppQueue(NULL
), m_pCookies(NULL
) {}
67 //kHIDPage_GenericDesktop
68 //kHIDUsage_GD_Joystick,kHIDUsage_GD_Mouse,kHIDUsage_GD_Keyboard
69 bool Create (int nClass
= -1, int nType
= -1, int nDev
= 1);
71 static int GetCount(int nClass
= -1, int nType
= -1);
73 void AddCookie(CFTypeRef Data
, int i
);
74 void AddCookieInQueue(CFTypeRef Data
, int i
);
75 void InitCookies(size_t dwSize
, bool bQueue
= false);
77 //Must be implemented by derived classes
78 //builds the cookie array -
79 //first call InitCookies to initialize the cookie
80 //array, then AddCookie to add a cookie at a certain point in an array
81 virtual void BuildCookies(wxCFArray
& Array
) = 0;
83 //checks to see whether the cookie at nIndex is active (element value != 0)
84 bool IsActive(int nIndex
);
86 //checks to see whether the cookie at nIndex exists
87 bool HasElement(int nIndex
);
89 //closes the device and cleans the queue and cookies
90 virtual ~wxHIDDevice();
93 IOHIDDeviceInterface
** m_ppDevice
; //this, essentially
94 IOHIDQueueInterface
** m_ppQueue
; //queue (if we want one)
95 IOHIDElementCookie
* m_pCookies
; //cookies
97 wxString m_szProductName
; //product name
98 int m_nProductId
; //product id
99 int m_nManufacturerId
; //manufacturer id
103 class wxHIDKeyboard
: public wxHIDDevice
107 virtual void BuildCookies(wxCFArray
& Array
);