]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/mac/corefoundation/hid.h
077a4c44359d528a08602e1f82ac44f2ca80d654
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/mac/corefoundation/hid.h
3 // Purpose: DARWIN HID layer for WX
8 // Copyright: (c) Ryan Norton
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // ===========================================================================
14 // ===========================================================================
16 // ---------------------------------------------------------------------------
18 // ---------------------------------------------------------------------------
20 #ifndef _WX_MACCARBONHID_H_
21 #define _WX_MACCARBONHID_H_
24 #include "wx/string.h"
29 #include <IOKit/IOKitLib.h>
30 #include <IOKit/IOCFPlugIn.h>
31 #include <IOKit/hid/IOHIDLib.h>
32 #include <IOKit/hid/IOHIDKeys.h>
33 #include <Kernel/IOKit/hidsystem/IOHIDUsageTables.h>
35 //Darn apple - doesn't properly wrap their headers in extern "C"!
36 //http://www.macosx.com/forums/archive/index.php/t-68069.html
37 //Needed for codewarrior link error with mach_port_deallocate()
39 #include <mach/mach_port.h>
42 #include <mach/mach.h> //this actually includes mach_port.h (see above)
44 // ===========================================================================
46 // ===========================================================================
49 // ---------------------------------------------------------------------------
52 // A wrapper around OS X HID Manager procedures.
53 // The tutorial "Working With HID Class Device Interfaces" Is
54 // Quite good, as is the sample program associated with it
55 // (Depite the author's protests!).
56 // ---------------------------------------------------------------------------
60 wxHIDDevice() : m_ppDevice(NULL
), m_ppQueue(NULL
), m_pCookies(NULL
) {}
62 bool Create (int nClass
= -1, int nType
= -1, int nDev
= 1);
64 static size_t GetCount(int nClass
= -1, int nType
= -1);
66 void AddCookie(CFTypeRef Data
, int i
);
67 void AddCookieInQueue(CFTypeRef Data
, int i
);
68 void InitCookies(size_t dwSize
, bool bQueue
= false);
70 //Must be implemented by derived classes
71 //builds the cookie array -
72 //first call InitCookies to initialize the cookie
73 //array, then AddCookie to add a cookie at a certain point in an array
74 virtual void BuildCookies(CFArrayRef Array
) = 0;
76 //checks to see whether the cookie at nIndex is active (element value != 0)
77 bool IsActive(int nIndex
);
79 //checks to see whether an element in the internal cookie array
81 bool HasElement(int nIndex
);
83 //closes the device and cleans the queue and cookies
84 virtual ~wxHIDDevice();
87 IOHIDDeviceInterface
** m_ppDevice
; //this, essentially
88 IOHIDQueueInterface
** m_ppQueue
; //queue (if we want one)
89 IOHIDElementCookie
* m_pCookies
; //cookies
91 wxString m_szProductName
; //product name
92 int m_nProductId
; //product id
93 int m_nManufacturerId
; //manufacturer id
94 mach_port_t m_pPort
; //mach port to use
97 // ---------------------------------------------------------------------------
100 // Semi-simple implementation that opens a connection to the first
101 // keyboard of the machine. Used in wxGetKeyState.
102 // ---------------------------------------------------------------------------
103 class wxHIDKeyboard
: public wxHIDDevice
106 static int GetCount();
107 bool Create(int nDev
= 1);
108 void AddCookie(CFTypeRef Data
, int i
);
109 virtual void BuildCookies(CFArrayRef Array
);
110 void DoBuildCookies(CFArrayRef Array
);
115 #endif //WX_MACCARBONHID_H