'I'm trying to build an app to setup the backlight colors for Lenovo K500 on Linux. Need assistance
So I'm trying to build an app with Qt to setup the backlight colors for the keyboard Lenovo K500 Legion on Linux.
What I know for know: Vendor ID is 0x17ef ; Product ID is 0x60d5 ; Number of interfaces is 4 ; The interrupt out for sending the HID messages for color is on interface 0x03 at the endpoint 0x04.
After creating a VM with M$ Wind7 and installed their software - Legion Accessory Central - I used WireShark to capture the USB packages on this endpoint.
I did a lot of tests, but I'm going to resume with one of them on both apps:
Setting a "dark yellow color" (RGB: 0x60 0x60 0x00) I got the following data:
0000 01 01 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ········ ········
0010 60 60 00 00 ff ff ff 00 00 ff 00 00 00 00 ff 00 ``······ ········
0020 ff 00 ff 00 ff ff 00 00 00 ff ff 00 00 00 00 00 ········ ········
0030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ········ ········
I've learned that the 2 first bytes (0x01 0x01) are set as "vendor data". Actually it sends the effect type:
0x01 0x01 - Static color (all keys)
0x01 0x06 - Custom (on their app it works so badly)
0x01 0x09 - Starlight
...
For now I'm only testing with static color... And the color itself goes on the offsets 16 (red), 17 (green) and 18 (blue). You can find the color #606000 there!
On my app, using libusb-1.0, I can open the device, claim the interface 0x03 and... err... send the package? Well... It seems it is sent but... So... On my app I selected the a "dark cyan color" (#008080) The package was sent and intercepted by WireShark:
0000 01 01 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ········ ········
0010 00 80 80 00 ff ff ff 00 00 ff 00 00 00 00 ff 00 ········ ········
0020 ff 00 ff 00 ff ff 00 00 00 ff ff 00 00 00 00 00 ········ ········
0030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ········ ········
But nothing happened! Ok, you might say... Hey, and the other 0x00 / 0xff out there! Right, but for all the tests I've done with their app, only the RGB data has changed! Trying to set the same color I tried sometime before, won't work too.
Maybe I'm missing something. I'm not an expert on USB protocols, specially HID, but I made some work with it, specially to NFC readers. I got some CONFIGURATION and SET_REPORT packages, but I'm not familiar with them.
BTW, some code! To send the interrupt message I have this method:
int USBMessages::SendHidMessage(uint8_t *hid_message, size_t hid_message_size)
{
int ret, len;
// Send interrupt transfer
printf("SendHidMessage: Sending data to endpoint %02X\n", endpoint_);
ret = libusb_interrupt_transfer(usb_device_handle_, endpoint_, hid_message, hid_message_size, &len, 0);
if (ret != LIBUSB_SUCCESS) {
printf("SendHidMessage: Failed to send interrupt tranfer. Error code: %d\n", ret);
return FALSE;
}
printf("SendHidMessage: %d bytes have been sent\n", len);
return TRUE;
}
The output is:
SendHidMessage: Sending data to endpoint 04
SendHidMessage: 64 bytes have been sent
So... I need some help...
And if anyone here is interested on helping on this project, it would be great!!! I found some people asking for Linux drivers / apps to setup the backlight colors for this keyboard, so sooner or later I want to add my code to GitHub to share the app.
My goal, on a first version, is to setup a static color or customize the color of the keys. Their app for Windows changes the selected keys to the same color, every time you pick a color. However, it should be possible to select different colors for different keys. If I can do this, with or without assistance for anyone interested on this project, with will be a better app than the one Lenovo provides for M$ Wind.
Thank you all for your time!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
