File tree 6 files changed +15
-30
lines changed
6 files changed +15
-30
lines changed Original file line number Diff line number Diff line change @@ -61,7 +61,7 @@ int HID_GetDescriptor(int8_t t)
61
61
HIDDescriptorListNode* current = rootNode;
62
62
int total = 0 ;
63
63
while (current != NULL ) {
64
- total += USB_SendControl (TRANSFER_PGM,current->cb -> descriptor ,current-> cb ->length );
64
+ total += USB_SendControl (TRANSFER_PGM,current->data ,current->length );
65
65
current = current->next ;
66
66
}
67
67
return total;
@@ -82,7 +82,7 @@ void HID_::AppendDescriptor(HIDDescriptorListNode *node)
82
82
current->next = node;
83
83
}
84
84
modules_count++;
85
- sizeof_hidReportDescriptor += (uint16_t )node->cb -> length ;
85
+ sizeof_hidReportDescriptor += (uint16_t )node->length ;
86
86
}
87
87
88
88
void HID_::SendReport (u8 id, const void * data, int len)
Original file line number Diff line number Diff line change 44
44
#define HID_REPORT_DESCRIPTOR_TYPE 0x22
45
45
#define HID_PHYSICAL_DESCRIPTOR_TYPE 0x23
46
46
47
- typedef struct __attribute__ ((packed)) {
48
- uint16_t length;
49
- const void * descriptor;
50
- } HID_Descriptor;
51
-
52
47
class HIDDescriptorListNode {
53
48
public:
54
49
HIDDescriptorListNode *next = NULL ;
55
- const HID_Descriptor * cb;
56
- HIDDescriptorListNode (const HID_Descriptor *ncb) {cb = ncb;}
50
+ HIDDescriptorListNode (const void *d, uint16_t l) : data(d), length(l) { }
51
+
52
+ const void * data;
53
+ uint16_t length;
57
54
};
58
55
59
56
class HID_
Original file line number Diff line number Diff line change @@ -68,7 +68,7 @@ int HID_GetDescriptor(int8_t t)
68
68
HIDDescriptorListNode* current = rootNode;
69
69
int total = 0 ;
70
70
while (current != NULL ) {
71
- total += USBD_SendControl (0 ,current->cb -> descriptor ,current-> cb ->length );
71
+ total += USBD_SendControl (0 ,current->data ,current->length );
72
72
current = current->next ;
73
73
}
74
74
return total;
@@ -89,7 +89,7 @@ void HID_::AppendDescriptor(HIDDescriptorListNode *node)
89
89
current->next = node;
90
90
}
91
91
modules_count++;
92
- sizeof_hidReportDescriptor += node->cb -> length ;
92
+ sizeof_hidReportDescriptor += node->length ;
93
93
}
94
94
95
95
void HID_::SendReport (uint8_t id, const void * data, int len)
@@ -165,4 +165,4 @@ HID_::HID_(void)
165
165
int HID_::begin (void )
166
166
{
167
167
return 0 ;
168
- }
168
+ }
Original file line number Diff line number Diff line change 42
42
#define HID_REPORT_DESCRIPTOR_TYPE 0x22
43
43
#define HID_PHYSICAL_DESCRIPTOR_TYPE 0x23
44
44
45
- typedef struct __attribute__ ((packed)) {
46
- uint8_t length;
47
- const void * descriptor;
48
- } HID_Descriptor;
49
-
50
45
class HIDDescriptorListNode {
51
46
public:
52
47
HIDDescriptorListNode *next = NULL ;
53
- const HID_Descriptor * cb;
54
- HIDDescriptorListNode (const HID_Descriptor *ncb) {cb = ncb;}
48
+ HIDDescriptorListNode (const void *d, uint16_t l) : data(d), length(l) { }
49
+ uint8_t length;
50
+ const void * data;
55
51
};
56
52
57
53
class HID_
@@ -90,4 +86,4 @@ typedef struct
90
86
91
87
#define WEAK __attribute__ ((weak))
92
88
93
- #endif
89
+ #endif
Original file line number Diff line number Diff line change @@ -62,11 +62,7 @@ static const uint8_t _hidReportDescriptor[] PROGMEM = {
62
62
63
63
Keyboard_::Keyboard_ (void )
64
64
{
65
- static HID_Descriptor cb = {
66
- .length = sizeof (_hidReportDescriptor),
67
- .descriptor = _hidReportDescriptor,
68
- };
69
- static HIDDescriptorListNode node (&cb);
65
+ static HIDDescriptorListNode node (_hidReportDescriptor, sizeof (_hidReportDescriptor));
70
66
HID.AppendDescriptor (&node);
71
67
}
72
68
Original file line number Diff line number Diff line change @@ -62,11 +62,7 @@ static const uint8_t _hidReportDescriptor[] PROGMEM = {
62
62
63
63
Mouse_::Mouse_ (void ) : _buttons(0 )
64
64
{
65
- const static HID_Descriptor cb = {
66
- .length = sizeof (_hidReportDescriptor),
67
- .descriptor = _hidReportDescriptor,
68
- };
69
- static HIDDescriptorListNode node (&cb);
65
+ static HIDDescriptorListNode node (_hidReportDescriptor, sizeof (_hidReportDescriptor));
70
66
HID.AppendDescriptor (&node);
71
67
}
72
68
You can’t perform that action at this time.
0 commit comments