• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /netgear-R7000-V1.0.7.12_1.2.5/ap/gpl/amule/wxWidgets-2.8.12/include/wx/mac/corefoundation/
1/////////////////////////////////////////////////////////////////////////////
2// Name:        wx/mac/corefoundation/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: hid.h 42077 2006-10-17 14:44:52Z ABX $
8// Copyright:   (c) Ryan Norton
9// Licence:     wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12// ===========================================================================
13// declarations
14// ===========================================================================
15
16// ---------------------------------------------------------------------------
17// headers
18// ---------------------------------------------------------------------------
19
20#ifndef _WX_MACCARBONHID_H_
21#define _WX_MACCARBONHID_H_
22
23#include "wx/defs.h"
24#include "wx/string.h"
25
26//Mac OSX only
27#ifdef __DARWIN__
28
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
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)
43
44// ===========================================================================
45// definitions
46// ===========================================================================
47
48
49// ---------------------------------------------------------------------------
50// wxHIDDevice
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!).
56// ---------------------------------------------------------------------------
57class wxHIDDevice
58{
59public:
60    wxHIDDevice() : m_ppDevice(NULL), m_ppQueue(NULL), m_pCookies(NULL) {}
61
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
74    virtual void BuildCookies(CFArrayRef Array) = 0;
75
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 an element in the internal cookie array
80    //exists
81    bool HasElement(int nIndex);
82
83    //closes the device and cleans the queue and cookies
84    virtual ~wxHIDDevice();
85
86protected:
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
94    mach_port_t m_pPort;            //mach port to use
95};
96
97// ---------------------------------------------------------------------------
98// wxHIDKeyboard
99//
100// Semi-simple implementation that opens a connection to the first
101// keyboard of the machine. Used in wxGetKeyState.
102// ---------------------------------------------------------------------------
103class wxHIDKeyboard : public wxHIDDevice
104{
105public:
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);
111};
112
113#endif //__DARWIN__
114
115#endif
116    // _WX_MACCARBONHID_H_
117