Skip to content

Commit a369626

Browse files
committed
HID: enable descriptors bigger than 256 bytes
1 parent 96df9ac commit a369626

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

Diff for: hardware/arduino/avr/libraries/HID/HID.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ static u8 HID_INTERFACE;
4343
HIDDescriptor _hidInterface;
4444

4545
static HIDDescriptorListNode* rootNode = NULL;
46-
static uint8_t sizeof_hidReportDescriptor = 0;
46+
static uint16_t sizeof_hidReportDescriptor = 0;
4747
static uint8_t modules_count = 0;
4848
//================================================================================
4949
//================================================================================
@@ -91,7 +91,7 @@ void HID_::AppendDescriptor(HIDDescriptorListNode *node)
9191
current->next = node;
9292
}
9393
modules_count++;
94-
sizeof_hidReportDescriptor += node->cb->length;
94+
sizeof_hidReportDescriptor += (uint16_t)node->cb->length;
9595
}
9696

9797
void HID_::SendReport(u8 id, const void* data, int len)

Diff for: hardware/arduino/avr/libraries/HID/HID.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
#define HID_PHYSICAL_DESCRIPTOR_TYPE 0x23
4646

4747
typedef struct __attribute__((packed)) {
48-
u8 length;
48+
uint16_t length;
4949
const void* descriptor;
5050
} HID_Descriptor;
5151

@@ -88,7 +88,7 @@ typedef struct
8888
#define HID_TX HID_ENDPOINT_INT
8989

9090
#define D_HIDREPORT(_descriptorLength) \
91-
{ 9, 0x21, 0x1, 0x1, 0, 1, 0x22, _descriptorLength, _descriptorLength >> 8 }
91+
{ 9, 0x21, 0x1, 0x1, 0, 1, 0x22, _descriptorLength & 0xFF, _descriptorLength >> 8 }
9292

9393
#define WEAK __attribute__ ((weak))
9494

0 commit comments

Comments
 (0)