]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/mac/corefoundation/hid.h
6ea4535f3a084ab085f43d2c13957dc3e9ffb51c
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 #include "wx/mac/corefoundation/cfwrappers.h"
47 // A wrapper around OS X HID Manager procedures.
48 // The tutorial "Working With HID Class Device Interfaces" Is
49 // Quite good, as is the sample program associated with it
50 // (Depite the author's protests!).
54 wxHIDDevice() : m_ppDevice(NULL
), m_ppQueue(NULL
), m_pCookies(NULL
) {}
55 //kHIDPage_GenericDesktop
56 //kHIDUsage_GD_Joystick,kHIDUsage_GD_Mouse,kHIDUsage_GD_Keyboard
57 bool Create (int nClass
= -1, int nType
= -1, int nDev
= 1);
59 static int GetCount(int nClass
= -1, int nType
= -1);
61 void AddCookie(CFTypeRef Data
, int i
);
62 void AddCookieInQueue(CFTypeRef Data
, int i
);
63 void InitCookies(size_t dwSize
, bool bQueue
= false);
65 //Must be implemented by derived classes
66 //builds the cookie array -
67 //first call InitCookies to initialize the cookie
68 //array, then AddCookie to add a cookie at a certain point in an array
69 virtual void BuildCookies(wxCFArray
& Array
) = 0;
71 //checks to see whether the cookie at nIndex is active (element value != 0)
72 bool IsActive(int nIndex
);
74 //checks to see whether the cookie at nIndex exists
75 bool HasElement(int nIndex
);
77 //closes the device and cleans the queue and cookies
78 virtual ~wxHIDDevice();
81 IOHIDDeviceInterface
** m_ppDevice
; //this, essentially
82 IOHIDQueueInterface
** m_ppQueue
; //queue (if we want one)
83 IOHIDElementCookie
* m_pCookies
; //cookies
85 wxString m_szProductName
; //product name
86 int m_nProductId
; //product id
87 int m_nManufacturerId
; //manufacturer id
91 class wxHIDKeyboard
: public wxHIDDevice
95 virtual void BuildCookies(wxCFArray
& Array
);