]> git.saurik.com Git - wxWidgets.git/blame - include/wx/mac/carbon/private/hid.h
Fix centering of top-level children of wxMDIParentFrame on Mac
[wxWidgets.git] / include / wx / mac / carbon / private / 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
22#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
23 #pragma interface "hid.h"
24#endif
ec8bd392
RN
25
26#include "wx/defs.h"
27
1553abf4
RN
28
29// ---------------------------------------------------------------------------
30// definitions
31// ---------------------------------------------------------------------------
32
33//Mac OSX only
ec8bd392
RN
34#ifdef __DARWIN__
35
52479aef
SC
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>
41
42#include <mach/mach.h>
43
44//Utility wrapper around CFArray
45class wxCFArray
46{
47public:
48 wxCFArray(CFTypeRef pData) : pArray((CFArrayRef) pData) {}
49 CFTypeRef operator [] (const int& nIndex) {return CFArrayGetValueAtIndex(pArray, nIndex); }
50 int Count() {return CFArrayGetCount(pArray);}
51private:
52 CFArrayRef pArray;
53};
54
55//
56// A wrapper around OS X HID Manager procedures.
57// The tutorial "Working With HID Class Device Interfaces" Is
58// Quite good, as is the sample program associated with it
59// (Depite the author's protests!).
60class wxHIDDevice
61{
62public:
63 wxHIDDevice() : m_ppDevice(NULL), m_ppQueue(NULL), m_pCookies(NULL) {}
64 //kHIDPage_GenericDesktop
65 //kHIDUsage_GD_Joystick,kHIDUsage_GD_Mouse,kHIDUsage_GD_Keyboard
66 bool Create (const int& nClass = -1, const int& nType = -1);
67
68 inline void AddCookie(CFTypeRef Data, const int& i);
69 inline void AddCookieInQueue(CFTypeRef Data, const int& i);
70 inline void InitCookies(const size_t& dwSize, bool bQueue = false);
71
72 //Must be implemented by derived classes
73 //builds the cookie array -
74 //first call InitCookies to initialize the cookie
75 //array, then AddCookie to add a cookie at a certain point in an array
76 virtual void BuildCookies(wxCFArray& Array) = 0;
77
78 //checks to see whether the cookie at index nIndex is active (element value != 0)
79 bool IsActive(const int& nIndex);
80
81 //closes the device and cleans the queue and cookies
82 virtual ~wxHIDDevice();
83private:
84 IOHIDDeviceInterface** m_ppDevice; //this, essentially
85 IOHIDQueueInterface** m_ppQueue; //queue (if we want one)
86 IOHIDElementCookie* m_pCookies; //cookies
87
88 const char* m_szName; //(product) name
89 mach_port_t m_pPort;
90};
91
92class wxHIDKeyboard : public wxHIDDevice
93{
94public:
95 bool Create();
96 virtual void BuildCookies(wxCFArray& Array);
ec8bd392
RN
97};
98
1553abf4
RN
99#endif //__DARWIN__
100
101#endif
102 //WX_MACCARBONHID_H