-
Notifications
You must be signed in to change notification settings - Fork 1
/
hid.h
207 lines (165 loc) · 5.41 KB
/
hid.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
/*++
Copyright (c) Microsoft 1998, All Rights Reserved
Module Name:
hid.h
Abstract:
This module contains the declarations and definitions for use with the
hid user mode client sample driver.
Environment:
Kernel & user mode
--*/
#ifndef HID_H
#define HID_H
#if _MSC_VER >= 1200
#pragma warning(push)
#endif
#pragma warning(disable:4201) // nameless struct/union
#include "hidsdi.h"
#include "setupapi.h"
typedef struct _SP_FNCLASS_DEVICE_DATA {
DWORD cbSize;
GUID FunctionClassGuid;
TCHAR DevicePath [ANYSIZE_ARRAY];
} SP_FNCLASS_DEVICE_DATA, *PSP_FNCLASS_DEVICE_DATA;
BOOLEAN
SetupDiGetFunctionClassDeviceInfo (
IN HDEVINFO DeviceInfoSet,
IN PSP_DEVINFO_DATA DeviceInfoData,
OUT PSP_FNCLASS_DEVICE_DATA FunctionClassDeviceData,
IN DWORD FunctionClassDeviceDataSize,
OUT PDWORD RequiredSize
);
#define ASSERT(x)
//
// A structure to hold the steady state data received from the hid device.
// Each time a read packet is received we fill in this structure.
// Each time we wish to write to a hid device we fill in this structure.
// This structure is here only for convenience. Most real applications will
// have a more efficient way of moving the hid data to the read, write, and
// feature routines.
//
typedef struct _HID_DATA {
BOOLEAN IsButtonData;
UCHAR Reserved;
USAGE UsagePage; // The usage page for which we are looking.
ULONG Status; // The last status returned from the accessor function
// when updating this field.
ULONG ReportID; // ReportID for this given data structure
BOOLEAN IsDataSet; // Variable to track whether a given data structure
// has already been added to a report structure
union {
struct {
ULONG UsageMin; // Variables to track the usage minimum and max
ULONG UsageMax; // If equal, then only a single usage
ULONG MaxUsageLength; // Usages buffer length.
PUSAGE Usages; // list of usages (buttons ``down'' on the device.
} ButtonData;
struct {
USAGE Usage; // The usage describing this value;
USHORT Reserved;
ULONG Value;
LONG ScaledValue;
} ValueData;
};
} HID_DATA, *PHID_DATA;
typedef struct _HID_DEVICE {
PCHAR DevicePath;
HANDLE HidDevice; // A file handle to the hid device.
BOOL OpenedForRead;
BOOL OpenedForWrite;
BOOL OpenedOverlapped;
BOOL OpenedExclusive;
PHIDP_PREPARSED_DATA Ppd; // The opaque parser info describing this device
HIDP_CAPS Caps; // The Capabilities of this hid device.
HIDD_ATTRIBUTES Attributes;
PCHAR InputReportBuffer;
_Field_size_(InputDataLength)
PHID_DATA InputData; // array of hid data structures
ULONG InputDataLength; // Num elements in this array.
PHIDP_BUTTON_CAPS InputButtonCaps;
PHIDP_VALUE_CAPS InputValueCaps;
PCHAR OutputReportBuffer;
_Field_size_(OutputDataLength)
PHID_DATA OutputData;
ULONG OutputDataLength;
PHIDP_BUTTON_CAPS OutputButtonCaps;
PHIDP_VALUE_CAPS OutputValueCaps;
PCHAR FeatureReportBuffer;
_Field_size_(FeatureDataLength) PHID_DATA FeatureData;
ULONG FeatureDataLength;
PHIDP_BUTTON_CAPS FeatureButtonCaps;
PHIDP_VALUE_CAPS FeatureValueCaps;
} HID_DEVICE, *PHID_DEVICE;
BOOLEAN
OpenHidDevice (
_In_ LPSTR DevicePath,
_In_ BOOL HasReadAccess,
_In_ BOOL HasWriteAccess,
_In_ BOOL IsOverlapped,
_In_ BOOL IsExclusive,
_Out_ PHID_DEVICE HidDevice
);
BOOLEAN
FindKnownHidDevices (
OUT PHID_DEVICE * HidDevices, // A array of struct _HID_DEVICE
OUT PULONG NumberDevices // the length of this array.
);
BOOLEAN
FillDeviceInfo(
IN PHID_DEVICE HidDevice
);
VOID
CloseHidDevices (
OUT PHID_DEVICE HidDevices, // A array of struct _HID_DEVICE
OUT ULONG NumberDevices // the length of this array.
);
VOID
CloseHidDevice (
IN PHID_DEVICE HidDevice
);
BOOLEAN
Read (
PHID_DEVICE HidDevice
);
BOOLEAN
ReadOverlapped (
PHID_DEVICE HidDevice,
HANDLE CompletionEvent,
LPOVERLAPPED Overlap
);
BOOLEAN
Write (
PHID_DEVICE HidDevice
);
BOOLEAN
UnpackReport (
_In_reads_bytes_(ReportBufferLength)PCHAR ReportBuffer,
IN USHORT ReportBufferLength,
IN HIDP_REPORT_TYPE ReportType,
IN OUT PHID_DATA Data,
IN ULONG DataLength,
IN PHIDP_PREPARSED_DATA Ppd
);
BOOLEAN
PackReport (
_Out_writes_bytes_(ReportBufferLength)PCHAR ReportBuffer,
IN USHORT ReportBufferLength,
IN HIDP_REPORT_TYPE ReportType,
IN PHID_DATA Data,
IN ULONG DataLength,
IN PHIDP_PREPARSED_DATA Ppd
);
BOOLEAN
SetFeature (
PHID_DEVICE HidDevice
);
BOOLEAN
GetFeature (
PHID_DEVICE HidDevice
);
#if _MSC_VER >= 1200
#pragma warning(pop)
#else
#pragma warning(default:4201)
#endif
#endif