Skip to content

Commit 26a9808

Browse files
authored
Added keybboard led status report callback
Callback function avoids the need to poll for status changes.
1 parent dcdb012 commit 26a9808

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

libraries/HID/src/HID.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,10 @@ bool HID_::setup(USBSetup& setup)
145145
if (2 == USB_RecvControl(data, length))
146146
{
147147
_keyboardLedsStatus = data[1];
148+
if (keyboardLedsStatusReportCallback != 0)
149+
{
150+
keyboardLedsStatusReportCallback();
151+
}
148152
return true;
149153
}
150154
}
@@ -159,12 +163,18 @@ uint8_t HID_::getKeyboardLedsStatus(void)
159163
return _keyboardLedsStatus;
160164
}
161165

166+
void HID_::setKeyboardLedsStatusReportCallback(void (*callback) (void) )
167+
{
168+
keyboardLedsStatusReportCallback = callback;
169+
}
170+
162171
HID_::HID_(void) : PluggableUSBModule(1, 1, epType),
163172
rootNode(NULL), descriptorSize(0),
164173
protocol(HID_REPORT_PROTOCOL), idle(1)
165174
{
166175
epType[0] = EP_TYPE_INTERRUPT_IN;
167176
PluggableUSB().plug(this);
177+
setKeyboardLedsStatusReportCallback( 0 );
168178
}
169179

170180
int HID_::begin(void)

0 commit comments

Comments
 (0)