I am using Ubuntu 12.04 and i need to control my customized USB keyboard keys & LEDs. The Keys are working well. When I tried with a standard keyboard(having NUM, SCROLL, CAPS lock LEDs), i couldnt succeed with writing LED status bits.
I dont want to use console based kb ioctl calls to control LEDs. Is there any way to control directly using ioctl or write function at driver space.
Below is the code i tried:
kb = open(/dev/input/event2, O_RDWR ); char kbname  = "key-x123"; char LedStatus = 0; ioctl (kb, EVIOCGNAME (sizeof (kbname)), kbname); ioctl (kb, EVIOCGBIT (EV_LED,sizeof (LedStatus)), &LedStatus); ioctl (kb, EVIOCGLED (sizeof (LedStatus)), &LedStatus);
All these calls are working well and i could reak keys. But unable to set any LEDs. Do not find any macros like EVIOCGLED to set LEDs through ioctl(2).
I tried below code as well which throws "invalid parameter" error.
struct input_event event; event.type = EV_LED; event.code = LED_NUML | LED_CAPSL | LED_SCROLLL; event.value = 7; if (write (kb, &event, sizeof (struct input_event)) < 0)