File tree 2 files changed +19
-3
lines changed 2 files changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -54,11 +54,11 @@ int HID_::getDescriptor(USBSetup& setup)
54
54
return -1 ;
55
55
total += res;
56
56
}
57
-
57
+
58
58
// Reset the protocol on reenumeration. Normally the host should not assume the state of the protocol
59
59
// due to the USB specs, but Windows and Linux just assumes its in report mode.
60
60
protocol = HID_REPORT_PROTOCOL;
61
-
61
+
62
62
return total;
63
63
}
64
64
@@ -86,6 +86,11 @@ void HID_::AppendDescriptor(HIDSubDescriptor *node)
86
86
descriptorSize += node->length ;
87
87
}
88
88
89
+ uint8_t HID_::getKeyboardLedsStatus (void )
90
+ {
91
+ return _keyboardLedsStatus;
92
+ }
93
+
89
94
int HID_::SendReport (uint8_t id, const void * data, int len)
90
95
{
91
96
auto ret = USB_Send (pluggedEndpoint, &id, 1 );
@@ -133,6 +138,15 @@ bool HID_::setup(USBSetup& setup)
133
138
}
134
139
if (request == HID_SET_REPORT)
135
140
{
141
+ if (setup.wLength == 2 )
142
+ {
143
+ uint8_t data[2 ];
144
+ if (2 == USB_RecvControl (data, 2 ))
145
+ {
146
+ _keyboardLedsStatus = data[1 ];
147
+ return true ;
148
+ }
149
+ }
136
150
// uint8_t reportID = setup.wValueL;
137
151
// uint16_t length = setup.wLength;
138
152
// uint8_t data[length];
Original file line number Diff line number Diff line change @@ -72,7 +72,7 @@ typedef struct
72
72
uint8_t descLenH;
73
73
} HIDDescDescriptor;
74
74
75
- typedef struct
75
+ typedef struct
76
76
{
77
77
InterfaceDescriptor hid;
78
78
HIDDescDescriptor desc;
@@ -95,6 +95,7 @@ class HID_ : public PluggableUSBModule
95
95
int begin (void );
96
96
int SendReport (uint8_t id, const void * data, int len);
97
97
void AppendDescriptor (HIDSubDescriptor* node);
98
+ uint8_t getKeyboardLedsStatus (void );
98
99
99
100
protected:
100
101
// Implementation of the PluggableUSBModule
@@ -111,6 +112,7 @@ class HID_ : public PluggableUSBModule
111
112
112
113
uint8_t protocol;
113
114
uint8_t idle;
115
+ uint8_t _keyboardLedsStatus;
114
116
};
115
117
116
118
// Replacement for global singleton.
You can’t perform that action at this time.
0 commit comments