forked from NicoHood/Hoodloader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHID_Reports.h
208 lines (169 loc) · 5.58 KB
/
HID_Reports.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
207
208
/*
Copyright (c) 2014 NicoHood
See the readme for credit to other people.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef HID_REPORTS_H
#define HID_REPORTS_H
//================================================================================
//Definitions
//================================================================================
#define LSB(_x) ((_x) & 0xFF)
#define MSB(_x) ((_x) >> 8)
#define RAWHID_USAGE_PAGE 0xFFC0 // recommended: 0xFF00 to 0xFFFF
#define RAWHID_USAGE 0x0C00 // recommended: 0x0100 to 0xFFFF
#define RAWHID_TX_SIZE 63 // 1 byte for report ID
#define RAWHID_RX_SIZE 63 // 1 byte for report ID
//================================================================================
//Report Typedefinitions
//================================================================================
typedef union{
// mouse report: 5 buttons, position, wheel
uint8_t whole8[4];
uint16_t whole16[4/2];
uint32_t whole32[4/4];
struct{
uint8_t buttons:5;
uint8_t reserved:3;
int8_t xAxis;
int8_t yAxis;
int8_t wheel;
};
} HID_MouseReport_Data_t;
typedef union{
// Low level key report: up to 6 keys and shift, ctrl etc at once
uint8_t whole8[8];
uint16_t whole16[8/2];
uint32_t whole32[8/4];
struct{
uint8_t modifiers;
uint8_t reserved;
uint8_t keys[6];
};
} HID_KeyboardReport_Data_t;
typedef union{
// a 32 byte buffer for rx or tx
uint8_t whole8[RAWHID_TX_SIZE];
uint16_t whole16[RAWHID_TX_SIZE / 2];
uint32_t whole32[RAWHID_TX_SIZE / 4];
uint8_t buff[RAWHID_TX_SIZE];
} HID_RawKeyboardReport_Data_t;
typedef union{
// every usable media key possible. Only one at the same time.
uint8_t whole8[8];
uint16_t whole16[8/2];
uint32_t whole32[8/4];
struct{
uint16_t key1;
uint16_t key2;
uint16_t key3;
uint16_t key4;
};
} HID_MediaReport_Data_t;
typedef union{
// every usable system control key possible. Only one at the same time.
uint8_t whole8[1];
uint8_t key;
} HID_SystemReport_Data_t;
typedef union {
// 32 Buttons, 6 Axis, 2 D-Pads
uint8_t whole8[17];
uint16_t whole16[17/2];
uint32_t whole32[17/4];
uint32_t buttons;
struct{
uint8_t button1 :1;
uint8_t button2 :1;
uint8_t button3 :1;
uint8_t button4 :1;
uint8_t button5 :1;
uint8_t button6 :1;
uint8_t button7 :1;
uint8_t button8 :1;
uint8_t button9 :1;
uint8_t button10 :1;
uint8_t button11 :1;
uint8_t button12 :1;
uint8_t button13 :1;
uint8_t button14 :1;
uint8_t button15 :1;
uint8_t button16 :1;
uint8_t button17 :1;
uint8_t button18 :1;
uint8_t button19 :1;
uint8_t button20 :1;
uint8_t button21 :1;
uint8_t button22 :1;
uint8_t button23 :1;
uint8_t button24 :1;
uint8_t button25 :1;
uint8_t button26 :1;
uint8_t button27 :1;
uint8_t button28 :1;
uint8_t button29 :1;
uint8_t button30 :1;
uint8_t button31 :1;
uint8_t button32 :1;
uint16_t xAxis;
uint16_t yAxis;
uint16_t zAxis;
uint16_t rxAxis;
uint16_t ryAxis;
uint16_t rzAxis;
uint8_t dPad1: 4;
uint8_t dPad2: 4;
// deactivated because windows only supports 7 axis. should be enough.
//uint8_t throttle;
//uint8_t rudder;
};
} HID_GamepadReport_Data_t;
typedef union{
// 2 Buttons, 2 Axis
uint8_t whole8[3];
uint16_t whole16[3/2];
uint8_t buttons :2;
struct{
uint16_t button1 :1;
uint16_t button2 :1;
uint16_t xAxis :10;
uint16_t yAxis :10;
uint16_t reserved :2;
};
} HID_JoystickReport_Data_t;
typedef union{
HID_MouseReport_Data_t Mouse;
HID_KeyboardReport_Data_t Keyboard;
HID_RawKeyboardReport_Data_t RawKeyboard;
HID_MediaReport_Data_t Media;
HID_GamepadReport_Data_t Gamepad1;
HID_GamepadReport_Data_t Gamepad2;
HID_JoystickReport_Data_t Joystick1;
HID_JoystickReport_Data_t Joystick2;
} HID_HIDReport_Data_t;
/** Enum for the HID report IDs used in the device. */
typedef enum{
HID_REPORTID_MouseReport = 0x01, /**< Report ID for the Mouse report within the device. */
HID_REPORTID_KeyboardReport = 0x02, /**< Report ID for the Keyboard report within the device. */
HID_REPORTID_RawKeyboardReport = 0x03, /**< Report ID for the Raw Keyboard report within the device. */
HID_REPORTID_MediaReport = 0x04, /**< Report ID for the Media report within the device. */
HID_REPORTID_SystemReport = 0x05, /**< Report ID for the Power report within the device. */
HID_REPORTID_Gamepad1Report = 0x06, /**< Report ID for the Gamepad1 report within the device. */
HID_REPORTID_Gamepad2Report = 0x07, /**< Report ID for the Gamepad2 report within the device. */
HID_REPORTID_Joystick1Report = 0x08, /**< Report ID for the Joystick1 report within the device. */
HID_REPORTID_Joystick2Report = 0x09, /**< Report ID for the Joystick2 report within the device. */
} HID_Report_IDs;
#endif