arduino-libraries / Keyboard

GNU Lesser General Public License v3.0
223 stars 157 forks source link

Added support for Keyboard Led status codes #61

Open PJ789 opened 2 years ago

PJ789 commented 2 years ago

This pull request adds support for LED status reports from the host, based on code here, with some minor enhancements for legibility sake;- https://forum.arduino.cc/t/leonardo-keyboard-leds-emulation/169582/23

PJ789 commented 2 years ago

Note this pull request has dependencies on another pull request in the ArduinoCore-avr HID library;-

ArduinoCore-avr pull request 446

... and will not compile unless & until that dependency is approved.

PJ789 commented 2 years ago

Usage example;-

`

  if (Keyboard.getLedStatus(LED_CAPS_LOCK))
  {
    Serial.print("Cap Lock on ");
  }
  if (Keyboard.getLedStatus(LED_SCROLL_LOCK))
  {
    Serial.print("Scroll Lock on ");
  }
    if (Keyboard.getLedStatus(LED_NUM_LOCK))
  {
    Serial.print("Num Lock on ");
  }
  Serial.println();    

`

60999 commented 2 years ago

Excuse me, what's the progress now? Has the problem been solved?

PJ789 commented 2 years ago

@60999 ... the code does work (I have a keyboard based on the changed code I use daily) but requires you to patch the Keyboard library AND ArduinoCore-avr HID library too (and I suspect that is why it is marked blocked, because the dependency on the core library code).

Applying the two patches is easy enough to do, assuming you're confident about overwriting the two affected libraries with the submitted code.

AllCheeks commented 2 years ago

@60999 ... the code does work (I have a keyboard based on the changed code I use daily) but requires you to patch the Keyboard library AND ArduinoCore-avr HID library too (and I suspect that is why it is marked blocked, because the dependency on the core library code).

Applying the two patches is easy enough to do, assuming you're confident about overwriting the two affected libraries with the submitted code.

It turns out that you also noticed this small detail awesome!