]> git.saurik.com Git - wxWidgets.git/blame - include/wx/mac/corefoundation/hid.h
Spelling fixes from Andreas Mohr (patch #1360064)
[wxWidgets.git] / include / wx / mac / corefoundation / hid.h
CommitLineData
ec8bd392
RN
1/////////////////////////////////////////////////////////////////////////////
2// Name: hid.h
3// Purpose: DARWIN HID layer for WX
4// Author: Ryan Norton
5// Modified by:
6// Created: 11/11/2003
7// RCS-ID: $Id$
8// Copyright: (c) Ryan Norton
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
1553abf4
RN
11// ===========================================================================
12// declarations
13// ===========================================================================
14
15// ---------------------------------------------------------------------------
16// headers
17// ---------------------------------------------------------------------------
18
19#ifndef _WX_MACCARBONHID_H_
20#define _WX_MACCARBONHID_H_
21
ec8bd392 22#include "wx/defs.h"
65442ab6 23#include "wx/string.h"
1553abf4
RN
24
25// ---------------------------------------------------------------------------
26// definitions
27// ---------------------------------------------------------------------------
28
29//Mac OSX only
ec8bd392
RN
30#ifdef __DARWIN__
31
52479aef
SC
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>
37
ce0d1032
SC
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()
41extern "C" {
42#include <mach/mach_port.h>
43}
44
45#include <mach/mach.h> //this actually includes mach_port.h (see above)
52479aef 46
2a32f173
RN
47//Utility wrapper around CFArray
48class wxCFArray
49{
50public:
51 wxCFArray(CFTypeRef pData) : pArray((CFArrayRef) pData) {}
52 CFTypeRef operator [] (const int& nIndex) {return CFArrayGetValueAtIndex(pArray, nIndex); }
53 int Count() {return CFArrayGetCount(pArray);}
54private:
55 CFArrayRef pArray;
56};
52479aef
SC
57
58//
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!).
63class wxHIDDevice
64{
65public:
66 wxHIDDevice() : m_ppDevice(NULL), m_ppQueue(NULL), m_pCookies(NULL) {}
67 //kHIDPage_GenericDesktop
68 //kHIDUsage_GD_Joystick,kHIDUsage_GD_Mouse,kHIDUsage_GD_Keyboard
4cb1d3da
RN
69 bool Create (int nClass = -1, int nType = -1, int nDev = 1);
70
71 static int GetCount(int nClass = -1, int nType = -1);
52479aef 72
4cb1d3da
RN
73 void AddCookie(CFTypeRef Data, int i);
74 void AddCookieInQueue(CFTypeRef Data, int i);
75 void InitCookies(size_t dwSize, bool bQueue = false);
52479aef
SC
76
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;
82
4cb1d3da
RN
83 //checks to see whether the cookie at nIndex is active (element value != 0)
84 bool IsActive(int nIndex);
85
86 //checks to see whether the cookie at nIndex exists
87 bool HasElement(int nIndex);
52479aef
SC
88
89 //closes the device and cleans the queue and cookies
90 virtual ~wxHIDDevice();
4cb1d3da
RN
91
92protected:
52479aef
SC
93 IOHIDDeviceInterface** m_ppDevice; //this, essentially
94 IOHIDQueueInterface** m_ppQueue; //queue (if we want one)
95 IOHIDElementCookie* m_pCookies; //cookies
96
65442ab6
RN
97 wxString m_szProductName; //product name
98 int m_nProductId; //product id
99 int m_nManufacturerId; //manufacturer id
52479aef
SC
100 mach_port_t m_pPort;
101};
102
103class wxHIDKeyboard : public wxHIDDevice
104{
105public:
106 bool Create();
107 virtual void BuildCookies(wxCFArray& Array);
ec8bd392
RN
108};
109
1553abf4
RN
110#endif //__DARWIN__
111
112#endif
113 //WX_MACCARBONHID_H