]>
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 #include <mach/mach.h>
40 //Utility wrapper around CFArray
44 wxCFArray(CFTypeRef pData
) : pArray((CFArrayRef
) pData
) {}
45 CFTypeRef
operator [] (const int& nIndex
) {return CFArrayGetValueAtIndex(pArray
, nIndex
); }
46 int Count() {return CFArrayGetCount(pArray
);}
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!).
59 wxHIDDevice() : m_ppDevice(NULL
), m_ppQueue(NULL
), m_pCookies(NULL
) {}
60 //kHIDPage_GenericDesktop
61 //kHIDUsage_GD_Joystick,kHIDUsage_GD_Mouse,kHIDUsage_GD_Keyboard
62 bool Create (int nClass
= -1, int nType
= -1, int nDev
= 1);
64 static int 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(wxCFArray
& 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 the cookie at nIndex exists
80 bool HasElement(int nIndex
);
82 //closes the device and cleans the queue and cookies
83 virtual ~wxHIDDevice();
86 IOHIDDeviceInterface
** m_ppDevice
; //this, essentially
87 IOHIDQueueInterface
** m_ppQueue
; //queue (if we want one)
88 IOHIDElementCookie
* m_pCookies
; //cookies
90 wxString m_szProductName
; //product name
91 int m_nProductId
; //product id
92 int m_nManufacturerId
; //manufacturer id
96 class wxHIDKeyboard
: public wxHIDDevice
100 virtual void BuildCookies(wxCFArray
& Array
);