whot/libevdev — pull request #1 by polyphemus (2013-08-09 16:13:11+00:00)
Title: 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.

Without the EV_SYN reading evdev clients get the EV_LED events, but they are
directly prepended to the next event without being separated from it. The led events
have the timecode of the new events and it is not possible to find out the actual
time they occurred at.

Here is some `evtest` data to illustrate:

$ evtest /dev/input/event7
Input driver version is 1.0.1
Input device ID: bus 0x3 vendor 0x46d product 0xc626 version 0x110
Input device name: "3Dconnexion SpaceNavigator"
Supported events:
Event type 0 (EV_SYN)
Event type 1 (EV_KEY)
Event code 256 (BTN_0)
...
Event type 4 (EV_MSC)
Event code 4 (MSC_SCAN)
Event type 17 (EV_LED)
Event code 8 (LED_MISC)
Properties:
Testing ... (interrupt to exit)
Event: time 1374507104.352812, type 4 (EV_MSC), code 4 (MSC_SCAN), value 90001
Event: time 1374507104.352812, type 1 (EV_KEY), code 256 (BTN_0), value 1
Event: time 1374507104.352812, -------------- SYN_REPORT ------------
Event: time 1374507104.504809, type 4 (EV_MSC), code 4 (MSC_SCAN), value 90001
Event: time 1374507104.504809, type 1 (EV_KEY), code 256 (BTN_0), value 0
Event: time 1374507104.504809, -------------- SYN_REPORT ------------
...
Run program which sets LED using evdev and wait 5 seconds before pressing the button.
...
Event: time 1374507117.496465, type 17 (EV_LED), code 8 (LED_MISC), value 1
Event: time 1374507117.496465, type 4 (EV_MSC), code 4 (MSC_SCAN), value 90001
Event: time 1374507117.496465, type 1 (EV_KEY), code 256 (BTN_0), value 1
Event: time 1374507117.496465, -------------- SYN_REPORT ------------
Event: time 1374507117.616560, type 4 (EV_MSC), code 4 (MSC_SCAN), value 90001
Event: time 1374507117.616560, type 1 (EV_KEY), code 256 (BTN_0), value 0
Event: time 1374507117.616560, -------------- SYN_REPORT ------------

If you want you could make the EV_SYN optional, but it should be at least be encouraged as it is the right thing to do.

P.S.
Had to mail to the input-subsystem mailing-list for this problem and the maintainer, Dmitry Torokhov, informed me of the responsibility of the clients to write the EV_SYN.
P.P.S.
I have submitted a similar patch to `weston`.