I'm trying to set the keyboard LEDs of a USB keyboard. I already tried / know the following:
To set PS/2 keyboard LEDs you can use the CreateFile("\\.\Keybd", GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0); DeviceIoControl(hKeybd, IOCTL_KEYBOARD_SET_INDICATORS...
To set the LEDs of a truly HID compliant keyboard you can use DirectInput, SendDeviceData with the usage page 8.
You can use SendInput / keybd_event. But this will also changes the state. So when you change CAPS LOCK with this method while the user is typing, he/she will get upper and lower case letters :-)
When I investigated method 2 with two keyboards, the SendDeviceData function always returns E_NOTIMPL. It seems a lot of USB keyboard manufacturers rely on the build-in HID driver. In this case the HID driver reports that keyboard as a PC enhanced keyboard ans says it's an "emulation". But the Windows HID emulation doesn't support SendDeviceData.
So I suspect there must be another way to set the keyboards LEDs. Windows must be talking to the USB keyboard to set the LEDs :-)
How can I change the keyboard LEDs without changing the keyboard state?