Skip to content

Commit f6e8c3d

Browse files
committed
HID: merged HID_Descriptor into HIDDescriptorListNode
This simplifies the object model and produce a small gain in code size and performance.
1 parent ef60b5d commit f6e8c3d

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

libraries/HID/HID.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ int HID_GetDescriptor(int8_t t)
6868
HIDDescriptorListNode* current = rootNode;
6969
int total = 0;
7070
while(current != NULL) {
71-
total += USBD_SendControl(0,current->descriptor->data,current->descriptor->length);
71+
total += USBD_SendControl(0,current->data,current->length);
7272
current = current->next;
7373
}
7474
return total;
@@ -89,7 +89,7 @@ void HID_::AppendDescriptor(HIDDescriptorListNode *node)
8989
current->next = node;
9090
}
9191
modules_count++;
92-
sizeof_hidReportDescriptor += node->descriptor->length;
92+
sizeof_hidReportDescriptor += node->length;
9393
}
9494

9595
void HID_::SendReport(uint8_t id, const void* data, int len)

libraries/HID/HID.h

+3-7
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,12 @@
4242
#define HID_REPORT_DESCRIPTOR_TYPE 0x22
4343
#define HID_PHYSICAL_DESCRIPTOR_TYPE 0x23
4444

45-
typedef struct __attribute__((packed)) {
46-
uint8_t length;
47-
const void* data;
48-
} HID_Descriptor;
49-
5045
class HIDDescriptorListNode {
5146
public:
5247
HIDDescriptorListNode *next = NULL;
53-
const HID_Descriptor *descriptor;
54-
HIDDescriptorListNode(const HID_Descriptor *d) : descriptor(d) { }
48+
HIDDescriptorListNode(const void *d, uint16_t l) : data(d), length(l) { }
49+
uint8_t length;
50+
const void* data;
5551
};
5652

5753
class HID_

0 commit comments

Comments
 (0)