Detect keyboard LED status

Hi All,

I have a project I am working on that requires my Leonardo to detect the Keyboard LED status. My code uses the LED status to detect when the driver has been fully loaded so it can begin typing, as well as which OS it has been plugged into.

I found this library GitHub - NicoHood/HID: Bring enhanced HID functions to your Arduino! , which does have LED status detection (here is his sample code: HID/KeyboardLed.ino at master · NicoHood/HID · GitHub), but the problem is when I use this library, the layout of the emulated Keyboard is not detected by OSX, and I get prompted by Keyboard Assistant to "press the button next to the left Shift button", which is useless for my project.

I have spent hours looking at how NicoHood implements the LED detection and tried to get it working with the default Keyboard.h library that comes with Arduino, but to be honest it is beyond me.

I have found this thread where someone got it working, but it is from back in 2013, and the .diff file no longer works, and again, it is beyond my technical skills. Leonardo keyboard leds emulation? - Programming Questions - Arduino Forum

If anyone has any insight or can help me, it would be greatly appreciated.