]> git.saurik.com Git - wxWidgets.git/blame - include/wx/mac/corefoundation/hid.h
add missing header to allow ../src/common/docview.cpp to compile
[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
38#include <mach/mach.h>
39
2a32f173
RN
40//Utility wrapper around CFArray
41class wxCFArray
42{
43public:
44 wxCFArray(CFTypeRef pData) : pArray((CFArrayRef) pData) {}
45 CFTypeRef operator [] (const int& nIndex) {return CFArrayGetValueAtIndex(pArray, nIndex); }
46 int Count() {return CFArrayGetCount(pArray);}
47private:
48 CFArrayRef pArray;
49};
52479aef
SC
50
51//
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!).
56class wxHIDDevice
57{
58public:
59 wxHIDDevice() : m_ppDevice(NULL), m_ppQueue(NULL), m_pCookies(NULL) {}
60 //kHIDPage_GenericDesktop
61 //kHIDUsage_GD_Joystick,kHIDUsage_GD_Mouse,kHIDUsage_GD_Keyboard
4cb1d3da
RN
62 bool Create (int nClass = -1, int nType = -1, int nDev = 1);
63
64 static int GetCount(int nClass = -1, int nType = -1);
52479aef 65
4cb1d3da
RN
66 void AddCookie(CFTypeRef Data, int i);
67 void AddCookieInQueue(CFTypeRef Data, int i);
68 void InitCookies(size_t dwSize, bool bQueue = false);
52479aef
SC
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
74 virtual void BuildCookies(wxCFArray& Array) = 0;
75
4cb1d3da
RN
76 //checks to see whether the cookie at nIndex is active (element value != 0)
77 bool IsActive(int nIndex);
78
79 //checks to see whether the cookie at nIndex exists
80 bool HasElement(int nIndex);
52479aef
SC
81
82 //closes the device and cleans the queue and cookies
83 virtual ~wxHIDDevice();
4cb1d3da
RN
84
85protected:
52479aef
SC
86 IOHIDDeviceInterface** m_ppDevice; //this, essentially
87 IOHIDQueueInterface** m_ppQueue; //queue (if we want one)
88 IOHIDElementCookie* m_pCookies; //cookies
89
65442ab6
RN
90 wxString m_szProductName; //product name
91 int m_nProductId; //product id
92 int m_nManufacturerId; //manufacturer id
52479aef
SC
93 mach_port_t m_pPort;
94};
95
96class wxHIDKeyboard : public wxHIDDevice
97{
98public:
99 bool Create();
100 virtual void BuildCookies(wxCFArray& Array);
ec8bd392
RN
101};
102
1553abf4
RN
103#endif //__DARWIN__
104
105#endif
106 //WX_MACCARBONHID_H