write EV_SYN input_event along with led events to device

Other clients of an evdev device need to have the events they receive
be separated, in moment in time, from other events by an EV_SYN/
SYN_REPORT. This is the responsibility of the client who writes events
into the stream.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
This commit is contained in:
polyphemus 2013-08-09 17:38:51 +02:00 committed by Peter Hutterer
parent 4d4293a65b
commit f29e4118fc

View file

@ -1189,7 +1189,7 @@ libevdev_kernel_set_led_value(struct libevdev *dev, unsigned int code, enum Evde
int
libevdev_kernel_set_led_values(struct libevdev *dev, ...)
{
struct input_event ev[LED_MAX];
struct input_event ev[LED_MAX + 1];
enum EvdevLEDValues val;
va_list args;
int code;
@ -1228,8 +1228,12 @@ libevdev_kernel_set_led_values(struct libevdev *dev, ...)
va_end(args);
if (rc == 0 && nleds > 0) {
ev[nleds].type = EV_SYN;
ev[nleds++].code = SYN_REPORT;
rc = write(libevdev_get_fd(dev), ev, nleds * sizeof(ev[0]));
if (rc > 0) {
nleds--; /* last is EV_SYN */
while (nleds--)
update_led_state(dev, &ev[nleds]);
}