]> git.saurik.com Git - wxWidgets.git/blame - include/wx/mac/corefoundation/hid.h
moving UniChar code to one place
[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/////////////////////////////////////////////////////////////////////////////
32efab35 11
1553abf4
RN
12// ===========================================================================
13// declarations
14// ===========================================================================
15
16// ---------------------------------------------------------------------------
17// headers
18// ---------------------------------------------------------------------------
19
20#ifndef _WX_MACCARBONHID_H_
21#define _WX_MACCARBONHID_H_
22
ec8bd392 23#include "wx/defs.h"
65442ab6 24#include "wx/string.h"
1553abf4 25
1553abf4 26//Mac OSX only
ec8bd392
RN
27#ifdef __DARWIN__
28
52479aef
SC
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>
34
ce0d1032
SC
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()
38extern "C" {
39#include <mach/mach_port.h>
40}
41
42#include <mach/mach.h> //this actually includes mach_port.h (see above)
52479aef 43
32efab35
SC
44// ===========================================================================
45// definitions
46// ===========================================================================
47
52479aef 48
32efab35
SC
49// ---------------------------------------------------------------------------
50// wxHIDDevice
52479aef 51//
78fc4e55
WS
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!).
32efab35 56// ---------------------------------------------------------------------------
52479aef
SC
57class wxHIDDevice
58{
59public:
78fc4e55 60 wxHIDDevice() : m_ppDevice(NULL), m_ppQueue(NULL), m_pCookies(NULL) {}
32efab35 61
78fc4e55
WS
62 bool Create (int nClass = -1, int nType = -1, int nDev = 1);
63
64 static size_t GetCount(int nClass = -1, int nType = -1);
65
66 void AddCookie(CFTypeRef Data, int i);
67 void AddCookieInQueue(CFTypeRef Data, int i);
68 void InitCookies(size_t dwSize, bool bQueue = false);
69
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
32efab35 74 virtual void BuildCookies(CFArrayRef Array) = 0;
78fc4e55
WS
75
76 //checks to see whether the cookie at nIndex is active (element value != 0)
77 bool IsActive(int nIndex);
78
32efab35
SC
79 //checks to see whether an element in the internal cookie array
80 //exists
4cb1d3da 81 bool HasElement(int nIndex);
78fc4e55
WS
82
83 //closes the device and cleans the queue and cookies
84 virtual ~wxHIDDevice();
85
4cb1d3da 86protected:
78fc4e55
WS
87 IOHIDDeviceInterface** m_ppDevice; //this, essentially
88 IOHIDQueueInterface** m_ppQueue; //queue (if we want one)
89 IOHIDElementCookie* m_pCookies; //cookies
90
91 wxString m_szProductName; //product name
92 int m_nProductId; //product id
93 int m_nManufacturerId; //manufacturer id
32efab35 94 mach_port_t m_pPort; //mach port to use
52479aef
SC
95};
96
32efab35
SC
97// ---------------------------------------------------------------------------
98// wxHIDKeyboard
99//
100// Semi-simple implementation that opens a connection to the first
101// keyboard of the machine. Used in wxGetKeyState.
102// ---------------------------------------------------------------------------
52479aef
SC
103class wxHIDKeyboard : public wxHIDDevice
104{
105public:
32efab35
SC
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);
ec8bd392
RN
111};
112
1553abf4
RN
113#endif //__DARWIN__
114
32efab35 115#endif //WX_MACCARBONHID_H