]> git.saurik.com Git - wxWidgets.git/blame - include/wx/mac/corefoundation/hid.h
use proper dllexport declaration with _WX_LIST_HELPER_
[wxWidgets.git] / include / wx / mac / corefoundation / hid.h
CommitLineData
ec8bd392 1/////////////////////////////////////////////////////////////////////////////
78fc4e55 2// Name: wx/mac/corefoundation/hid.h
ec8bd392
RN
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:
78fc4e55
WS
51 wxCFArray(CFTypeRef pData) : pArray((CFArrayRef) pData) {}
52 CFTypeRef operator [] (const int& nIndex) {return CFArrayGetValueAtIndex(pArray, nIndex); }
53 int Count() {return CFArrayGetCount(pArray);}
2a32f173 54private:
78fc4e55 55 CFArrayRef pArray;
2a32f173 56};
52479aef
SC
57
58//
78fc4e55
WS
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!).
52479aef
SC
63class wxHIDDevice
64{
65public:
78fc4e55
WS
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);
70
71 static size_t GetCount(int nClass = -1, int nType = -1);
72
73 void AddCookie(CFTypeRef Data, int i);
74 void AddCookieInQueue(CFTypeRef Data, int i);
75 void InitCookies(size_t dwSize, bool bQueue = false);
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
83 //checks to see whether the cookie at nIndex is active (element value != 0)
84 bool IsActive(int nIndex);
85
4cb1d3da
RN
86 //checks to see whether the cookie at nIndex exists
87 bool HasElement(int nIndex);
78fc4e55
WS
88
89 //closes the device and cleans the queue and cookies
90 virtual ~wxHIDDevice();
91
4cb1d3da 92protected:
78fc4e55
WS
93 IOHIDDeviceInterface** m_ppDevice; //this, essentially
94 IOHIDQueueInterface** m_ppQueue; //queue (if we want one)
95 IOHIDElementCookie* m_pCookies; //cookies
96
97 wxString m_szProductName; //product name
98 int m_nProductId; //product id
99 int m_nManufacturerId; //manufacturer id
100 mach_port_t m_pPort;
52479aef
SC
101};
102
103class wxHIDKeyboard : public wxHIDDevice
104{
105public:
78fc4e55
WS
106 bool Create();
107 virtual void BuildCookies(wxCFArray& Array);
ec8bd392
RN
108};
109
1553abf4
RN
110#endif //__DARWIN__
111
78fc4e55
WS
112#endif
113 //WX_MACCARBONHID_H