SDL  2.0
SDL_hid.h
Go to the documentation of this file.
1 /*
2  Simple DirectMedia Layer
3  Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
4 
5  This software is provided 'as-is', without any express or implied
6  warranty. In no event will the authors be held liable for any damages
7  arising from the use of this software.
8 
9  Permission is granted to anyone to use this software for any purpose,
10  including commercial applications, and to alter it and redistribute it
11  freely, subject to the following restrictions:
12 
13  1. The origin of this software must not be misrepresented; you must not
14  claim that you wrote the original software. If you use this software
15  in a product, an acknowledgment in the product documentation would be
16  appreciated but is not required.
17  2. Altered source versions must be plainly marked as such, and must not be
18  misrepresented as being the original software.
19  3. This notice may not be removed or altered from any source distribution.
20 */
21 #include "../../SDL_internal.h"
22 
23 #ifndef SDL_hid_h_
24 #define SDL_hid_h_
25 
26 #include "SDL_windows.h"
27 
28 #ifndef __WINRT__
29 
30 typedef LONG NTSTATUS;
31 typedef USHORT USAGE;
32 typedef struct _HIDP_PREPARSED_DATA *PHIDP_PREPARSED_DATA;
33 
34 typedef struct _HIDD_ATTRIBUTES
35 {
36  ULONG Size;
37  USHORT VendorID;
38  USHORT ProductID;
39  USHORT VersionNumber;
40 } HIDD_ATTRIBUTES, *PHIDD_ATTRIBUTES;
41 
42 typedef enum {
45  HidP_Feature = 2
47 
48 typedef struct {
50  UCHAR ReportID;
51  BOOLEAN IsAlias;
52  USHORT BitField;
56  BOOLEAN IsRange;
57  BOOLEAN IsStringRange;
59  BOOLEAN IsAbsolute;
60  ULONG Reserved[ 10 ];
61  union {
62  struct {
65  USHORT StringMin;
66  USHORT StringMax;
67  USHORT DesignatorMin;
68  USHORT DesignatorMax;
69  USHORT DataIndexMin;
70  USHORT DataIndexMax;
71  } Range;
72  struct {
75  USHORT StringIndex;
76  USHORT Reserved2;
78  USHORT Reserved3;
79  USHORT DataIndex;
80  USHORT Reserved4;
81  } NotRange;
82  };
84 
85 typedef struct {
87  UCHAR ReportID;
88  BOOLEAN IsAlias;
89  USHORT BitField;
93  BOOLEAN IsRange;
94  BOOLEAN IsStringRange;
96  BOOLEAN IsAbsolute;
97  BOOLEAN HasNull;
98  UCHAR Reserved;
99  USHORT BitSize;
100  USHORT ReportCount;
101  USHORT Reserved2[ 5 ];
102  ULONG UnitsExp;
103  ULONG Units;
108  union {
109  struct {
112  USHORT StringMin;
113  USHORT StringMax;
116  USHORT DataIndexMin;
117  USHORT DataIndexMax;
118  } Range;
119  struct {
122  USHORT StringIndex;
123  USHORT Reserved2;
125  USHORT Reserved3;
126  USHORT DataIndex;
127  USHORT Reserved4;
128  } NotRange;
129  };
131 
132 typedef struct {
138  USHORT Reserved[ 17 ];
150 
151 typedef struct {
152  USHORT DataIndex;
153  USHORT Reserved;
154  union {
155  ULONG RawValue;
156  BOOLEAN On;
157  };
159 
160 #define HIDP_ERROR_CODES( p1, p2 ) ((NTSTATUS)(((p1) << 28) | (0x11 << 16) | (p2)))
161 #define HIDP_STATUS_SUCCESS HIDP_ERROR_CODES( 0x0, 0x0000 )
162 #define HIDP_STATUS_NULL HIDP_ERROR_CODES( 0x8, 0x0001 )
163 #define HIDP_STATUS_INVALID_PREPARSED_DATA HIDP_ERROR_CODES( 0xC, 0x0001 )
164 #define HIDP_STATUS_INVALID_REPORT_TYPE HIDP_ERROR_CODES( 0xC, 0x0002 )
165 #define HIDP_STATUS_INVALID_REPORT_LENGTH HIDP_ERROR_CODES( 0xC, 0x0003 )
166 #define HIDP_STATUS_USAGE_NOT_FOUND HIDP_ERROR_CODES( 0xC, 0x0004 )
167 #define HIDP_STATUS_VALUE_OUT_OF_RANGE HIDP_ERROR_CODES( 0xC, 0x0005 )
168 #define HIDP_STATUS_BAD_LOG_PHY_VALUES HIDP_ERROR_CODES( 0xC, 0x0006 )
169 #define HIDP_STATUS_BUFFER_TOO_SMALL HIDP_ERROR_CODES( 0xC, 0x0007 )
170 #define HIDP_STATUS_INTERNAL_ERROR HIDP_ERROR_CODES( 0xC, 0x0008 )
171 #define HIDP_STATUS_I8042_TRANS_UNKNOWN HIDP_ERROR_CODES( 0xC, 0x0009 )
172 #define HIDP_STATUS_INCOMPATIBLE_REPORT_ID HIDP_ERROR_CODES( 0xC, 0x000A )
173 #define HIDP_STATUS_NOT_VALUE_ARRAY HIDP_ERROR_CODES( 0xC, 0x000B )
174 #define HIDP_STATUS_IS_VALUE_ARRAY HIDP_ERROR_CODES( 0xC, 0x000C )
175 #define HIDP_STATUS_DATA_INDEX_NOT_FOUND HIDP_ERROR_CODES( 0xC, 0x000D )
176 #define HIDP_STATUS_DATA_INDEX_OUT_OF_RANGE HIDP_ERROR_CODES( 0xC, 0x000E )
177 #define HIDP_STATUS_BUTTON_NOT_PRESSED HIDP_ERROR_CODES( 0xC, 0x000F )
178 #define HIDP_STATUS_REPORT_DOES_NOT_EXIST HIDP_ERROR_CODES( 0xC, 0x0010 )
179 #define HIDP_STATUS_NOT_IMPLEMENTED HIDP_ERROR_CODES( 0xC, 0x0020 )
180 
181 
182 extern int WIN_LoadHIDDLL(void);
183 extern void WIN_UnloadHIDDLL(void);
184 
185 typedef BOOLEAN (WINAPI *HidD_GetString_t)(HANDLE HidDeviceObject, PVOID Buffer, ULONG BufferLength);
186 typedef BOOLEAN (WINAPI *HidD_GetPreparsedData_t)(HANDLE HidDeviceObject, PHIDP_PREPARSED_DATA *PreparsedData);
187 typedef BOOLEAN (WINAPI *HidD_FreePreparsedData_t)(PHIDP_PREPARSED_DATA PreparsedData);
188 typedef NTSTATUS (WINAPI *HidP_GetCaps_t)(PHIDP_PREPARSED_DATA PreparsedData, PHIDP_CAPS Capabilities);
189 typedef NTSTATUS (WINAPI *HidP_GetButtonCaps_t)(HIDP_REPORT_TYPE ReportType, PHIDP_BUTTON_CAPS ButtonCaps, PUSHORT ButtonCapsLength, PHIDP_PREPARSED_DATA PreparsedData);
190 typedef NTSTATUS (WINAPI *HidP_GetValueCaps_t)(HIDP_REPORT_TYPE ReportType, PHIDP_VALUE_CAPS ValueCaps, PUSHORT ValueCapsLength, PHIDP_PREPARSED_DATA PreparsedData);
191 typedef ULONG (WINAPI *HidP_MaxDataListLength_t)(HIDP_REPORT_TYPE ReportType, PHIDP_PREPARSED_DATA PreparsedData);
192 typedef NTSTATUS (WINAPI *HidP_GetData_t)(HIDP_REPORT_TYPE ReportType, PHIDP_DATA DataList, PULONG DataLength, PHIDP_PREPARSED_DATA PreparsedData, PCHAR Report, ULONG ReportLength);
193 
203 
204 #endif /* !__WINRT__ */
205 
206 #endif /* SDL_hid_h_ */
207 
208 /* vi: set ts=4 sw=4 expandtab: */
BOOLEAN(WINAPI * HidD_GetString_t)(HANDLE HidDeviceObject, PVOID Buffer, ULONG BufferLength)
Definition: SDL_hid.h:185
USHORT USAGE
Definition: SDL_hid.h:31
struct HIDP_CAPS * PHIDP_CAPS
struct HIDP_VALUE_CAPS * PHIDP_VALUE_CAPS
HidD_FreePreparsedData_t SDL_HidD_FreePreparsedData
Definition: SDL_hid.c:31
HidP_GetCaps_t SDL_HidP_GetCaps
Definition: SDL_hid.c:32
NTSTATUS(WINAPI * HidP_GetValueCaps_t)(HIDP_REPORT_TYPE ReportType, PHIDP_VALUE_CAPS ValueCaps, PUSHORT ValueCapsLength, PHIDP_PREPARSED_DATA PreparsedData)
Definition: SDL_hid.h:190
HidP_GetButtonCaps_t SDL_HidP_GetButtonCaps
Definition: SDL_hid.c:33
HidD_GetString_t SDL_HidD_GetManufacturerString
Definition: SDL_hid.c:28
HidD_GetPreparsedData_t SDL_HidD_GetPreparsedData
Definition: SDL_hid.c:30
void WIN_UnloadHIDDLL(void)
Definition: SDL_hid.c:79
NTSTATUS(WINAPI * HidP_GetCaps_t)(PHIDP_PREPARSED_DATA PreparsedData, PHIDP_CAPS Capabilities)
Definition: SDL_hid.h:188
struct HIDP_BUTTON_CAPS * PHIDP_BUTTON_CAPS
LONG NTSTATUS
Definition: SDL_hid.h:30
BOOLEAN(WINAPI * HidD_GetPreparsedData_t)(HANDLE HidDeviceObject, PHIDP_PREPARSED_DATA *PreparsedData)
Definition: SDL_hid.h:186
HidP_MaxDataListLength_t SDL_HidP_MaxDataListLength
Definition: SDL_hid.c:35
NTSTATUS(WINAPI * HidP_GetData_t)(HIDP_REPORT_TYPE ReportType, PHIDP_DATA DataList, PULONG DataLength, PHIDP_PREPARSED_DATA PreparsedData, PCHAR Report, ULONG ReportLength)
Definition: SDL_hid.h:192
HidP_GetValueCaps_t SDL_HidP_GetValueCaps
Definition: SDL_hid.c:34
struct _HIDP_PREPARSED_DATA * PHIDP_PREPARSED_DATA
Definition: SDL_hid.h:32
BOOLEAN(WINAPI * HidD_FreePreparsedData_t)(PHIDP_PREPARSED_DATA PreparsedData)
Definition: SDL_hid.h:187
NTSTATUS(WINAPI * HidP_GetButtonCaps_t)(HIDP_REPORT_TYPE ReportType, PHIDP_BUTTON_CAPS ButtonCaps, PUSHORT ButtonCapsLength, PHIDP_PREPARSED_DATA PreparsedData)
Definition: SDL_hid.h:189
struct HIDP_DATA * PHIDP_DATA
HidP_GetData_t SDL_HidP_GetData
Definition: SDL_hid.c:36
ULONG(WINAPI * HidP_MaxDataListLength_t)(HIDP_REPORT_TYPE ReportType, PHIDP_PREPARSED_DATA PreparsedData)
Definition: SDL_hid.h:191
int WIN_LoadHIDDLL(void)
Definition: SDL_hid.c:43
HIDP_REPORT_TYPE
Definition: SDL_hid.h:42
@ HidP_Input
Definition: SDL_hid.h:43
@ HidP_Feature
Definition: SDL_hid.h:45
@ HidP_Output
Definition: SDL_hid.h:44
HidD_GetString_t SDL_HidD_GetProductString
Definition: SDL_hid.c:29
USHORT VendorID
Definition: SDL_hid.h:37
USHORT ProductID
Definition: SDL_hid.h:38
USHORT VersionNumber
Definition: SDL_hid.h:39
ULONG Size
Definition: SDL_hid.h:36
USHORT StringIndex
Definition: SDL_hid.h:75
USHORT StringMin
Definition: SDL_hid.h:65
USHORT Reserved4
Definition: SDL_hid.h:80
USHORT DataIndexMax
Definition: SDL_hid.h:70
BOOLEAN IsStringRange
Definition: SDL_hid.h:57
USHORT DataIndex
Definition: SDL_hid.h:79
BOOLEAN IsRange
Definition: SDL_hid.h:56
USAGE LinkUsage
Definition: SDL_hid.h:54
USHORT DataIndexMin
Definition: SDL_hid.h:69
UCHAR ReportID
Definition: SDL_hid.h:50
USAGE UsageMin
Definition: SDL_hid.h:63
BOOLEAN IsAbsolute
Definition: SDL_hid.h:59
USHORT DesignatorMax
Definition: SDL_hid.h:68
USAGE UsagePage
Definition: SDL_hid.h:49
USHORT LinkCollection
Definition: SDL_hid.h:53
USHORT DesignatorMin
Definition: SDL_hid.h:67
USHORT StringMax
Definition: SDL_hid.h:66
USHORT DesignatorIndex
Definition: SDL_hid.h:77
USHORT BitField
Definition: SDL_hid.h:52
BOOLEAN IsDesignatorRange
Definition: SDL_hid.h:58
BOOLEAN IsAlias
Definition: SDL_hid.h:51
USAGE Reserved1
Definition: SDL_hid.h:74
USHORT Reserved2
Definition: SDL_hid.h:76
USAGE LinkUsagePage
Definition: SDL_hid.h:55
USAGE UsageMax
Definition: SDL_hid.h:64
USHORT Reserved3
Definition: SDL_hid.h:78
USHORT NumberFeatureButtonCaps
Definition: SDL_hid.h:146
USAGE Usage
Definition: SDL_hid.h:133
USHORT NumberOutputValueCaps
Definition: SDL_hid.h:144
USAGE UsagePage
Definition: SDL_hid.h:134
USHORT NumberFeatureDataIndices
Definition: SDL_hid.h:148
USHORT FeatureReportByteLength
Definition: SDL_hid.h:137
USHORT NumberInputValueCaps
Definition: SDL_hid.h:141
USHORT OutputReportByteLength
Definition: SDL_hid.h:136
USHORT NumberOutputButtonCaps
Definition: SDL_hid.h:143
USHORT NumberInputDataIndices
Definition: SDL_hid.h:142
USHORT InputReportByteLength
Definition: SDL_hid.h:135
USHORT NumberLinkCollectionNodes
Definition: SDL_hid.h:139
USHORT NumberOutputDataIndices
Definition: SDL_hid.h:145
USHORT NumberInputButtonCaps
Definition: SDL_hid.h:140
USHORT NumberFeatureValueCaps
Definition: SDL_hid.h:147
ULONG RawValue
Definition: SDL_hid.h:155
USHORT Reserved
Definition: SDL_hid.h:153
BOOLEAN On
Definition: SDL_hid.h:156
USHORT DataIndex
Definition: SDL_hid.h:152
USHORT ReportCount
Definition: SDL_hid.h:100
UCHAR Reserved
Definition: SDL_hid.h:98
USAGE UsageMax
Definition: SDL_hid.h:111
USHORT DesignatorIndex
Definition: SDL_hid.h:124
LONG PhysicalMax
Definition: SDL_hid.h:107
USHORT DataIndexMax
Definition: SDL_hid.h:117
USAGE LinkUsagePage
Definition: SDL_hid.h:92
USHORT StringIndex
Definition: SDL_hid.h:122
USAGE UsagePage
Definition: SDL_hid.h:86
USHORT BitSize
Definition: SDL_hid.h:99
USHORT BitField
Definition: SDL_hid.h:89
BOOLEAN IsRange
Definition: SDL_hid.h:93
ULONG UnitsExp
Definition: SDL_hid.h:102
LONG PhysicalMin
Definition: SDL_hid.h:106
USHORT DesignatorMax
Definition: SDL_hid.h:115
USAGE LinkUsage
Definition: SDL_hid.h:91
USHORT StringMax
Definition: SDL_hid.h:113
USHORT StringMin
Definition: SDL_hid.h:112
LONG LogicalMax
Definition: SDL_hid.h:105
USHORT Reserved4
Definition: SDL_hid.h:127
BOOLEAN IsAbsolute
Definition: SDL_hid.h:96
USHORT DataIndexMin
Definition: SDL_hid.h:116
USAGE UsageMin
Definition: SDL_hid.h:110
BOOLEAN IsStringRange
Definition: SDL_hid.h:94
USHORT DesignatorMin
Definition: SDL_hid.h:114
BOOLEAN HasNull
Definition: SDL_hid.h:97
USHORT Reserved3
Definition: SDL_hid.h:125
BOOLEAN IsAlias
Definition: SDL_hid.h:88
UCHAR ReportID
Definition: SDL_hid.h:87
USHORT LinkCollection
Definition: SDL_hid.h:90
USAGE Reserved1
Definition: SDL_hid.h:121
USHORT DataIndex
Definition: SDL_hid.h:126
LONG LogicalMin
Definition: SDL_hid.h:104
BOOLEAN IsDesignatorRange
Definition: SDL_hid.h:95