-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds support for Keyboard LED (Caps Lock, Scroll Lock, Num Lock) #446
base: master
Are you sure you want to change the base?
Conversation
@facchinm please would you consider for merge? (This change is a dependency for a related pull request I'm about to add to the keyboard library, adding support for caps lock, scroll lock, num lock leds). |
Memory usage change @ dcdb012
Click for full report table
Click for full report CSV
|
@facchinm please see also ... which has dependencies on this code to add LED status handling to the Keyboard API. thanks |
Callback function avoids the need to poll for status changes.
Avoids the need to continuously poll for changes to caps lock scroll lock num lock
Also added a callback feature on LED status reports from the host, so to avoid continuously polling the API to discover if an LED has changed state. Requires programmer to set the callback function as follows; void setup() {
HID().setKeyboardLedsStatusReportCallback( keyboardLedsStatusReportCallback );
}
void loop() {
}
void keyboardLedsStatusReportCallback()
{
// code to set LEDs, respond to caps lock status change, etc etc
} |
Thanks @PJ789! Don't worry about these CI failures:
That error is unrelated to the changes you propose here in your pull request. I have been seeing transient GitHub Actions workflow run failures all day across many repositories and I suspect this is another. One of the repository maintainers can re-run the failing workflow once GitHub gets back to a working state. |
Memory usage change @ 61ea246
Click for full report table
Click for full report CSV
|
@per1234 that's good to hear. I'm using the code on a current HID keyboard project, where it compiles without issue (Leonardo/SS Micro board), and works well. I'd be delighted to see the capability shared with other developers. |
@@ -133,25 +133,48 @@ bool HID_::setup(USBSetup& setup) | |||
} | |||
if (request == HID_SET_REPORT) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is keyboard LEDs the only time this kind of request is being actively used? I'd prefer to add some more generic API as in PluggableUSB framework
The best thing to do, IMO, would be to create a new PluggableHID API where a derived module can register its function (or it's ignored otherwise). Any chance you can try this approach? |
Memory usage change @ fd8d12d
Click for full report table
Click for full report CSV
|
Based on code here, adapted very slightly to improve legibility;-
https://forum.arduino.cc/t/leonardo-keyboard-leds-emulation/169582/23