Skip to content

Commit 60e6c34

Browse files
nospam2000obra
authored andcommitted
Use defines to identify the USB HID pages we support, instead of integers
1 parent f27857d commit 60e6c34

File tree

1 file changed

+8
-5
lines changed
  • hardware/arduino/avr/cores/arduino

1 file changed

+8
-5
lines changed

hardware/arduino/avr/cores/arduino/HID.cpp

+8-5
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ Keyboard_ Keyboard;
4141
#define RAWHID_TX_SIZE 64
4242
#define RAWHID_RX_SIZE 64
4343

44+
#define HID_REPORTID_MOUSE (1)
45+
#define HID_REPORTID_KEYBOARD (2)
46+
#define HID_REPORTID_RAWHID (3)
4447
extern const u8 _hidReportDescriptor[] PROGMEM;
4548
const u8 _hidReportDescriptor[] = {
4649

@@ -50,7 +53,7 @@ const u8 _hidReportDescriptor[] = {
5053
0xa1, 0x01, // COLLECTION (Application)
5154
0x09, 0x01, // USAGE (Pointer)
5255
0xa1, 0x00, // COLLECTION (Physical)
53-
0x85, 0x01, // REPORT_ID (1)
56+
0x85, HID_REPORTID_MOUSE, // REPORT_ID (1)
5457
0x05, 0x09, // USAGE_PAGE (Button)
5558
0x19, 0x01, // USAGE_MINIMUM (Button 1)
5659
0x29, 0x03, // USAGE_MAXIMUM (Button 3)
@@ -78,7 +81,7 @@ const u8 _hidReportDescriptor[] = {
7881
0x05, 0x01, // USAGE_PAGE (Generic Desktop) // 47
7982
0x09, 0x06, // USAGE (Keyboard)
8083
0xa1, 0x01, // COLLECTION (Application)
81-
0x85, 0x02, // REPORT_ID (2)
84+
0x85, HID_REPORTID_KEYBOARD, // REPORT_ID (2)
8285
0x05, 0x07, // USAGE_PAGE (Keyboard)
8386

8487
0x19, 0xe0, // USAGE_MINIMUM (Keyboard LeftControl)
@@ -110,7 +113,7 @@ const u8 _hidReportDescriptor[] = {
110113
0x0A, LSB(RAWHID_USAGE), MSB(RAWHID_USAGE),
111114

112115
0xA1, 0x01, // Collection 0x01
113-
0x85, 0x03, // REPORT_ID (3)
116+
0x85, HID_REPORTID_RAWHID, // REPORT_ID (3)
114117
0x75, 0x08, // report size = 8 bits
115118
0x15, 0x00, // logical minimum = 0
116119
0x26, 0xFF, 0x00, // logical maximum = 255
@@ -226,7 +229,7 @@ void Mouse_::move(signed char x, signed char y, signed char wheel)
226229
m[1] = x;
227230
m[2] = y;
228231
m[3] = wheel;
229-
HID_SendReport(1,m,4);
232+
HID_SendReport(HID_REPORTID_MOUSE,m,sizeof(m));
230233
}
231234

232235
void Mouse_::buttons(uint8_t b)
@@ -273,7 +276,7 @@ void Keyboard_::end(void)
273276

274277
void Keyboard_::sendReport(KeyReport* keys)
275278
{
276-
HID_SendReport(2,keys,sizeof(KeyReport));
279+
HID_SendReport(HID_REPORTID_KEYBOARD,keys,sizeof(*keys));
277280
}
278281

279282
extern

0 commit comments

Comments
 (0)