How to clear buffer before call libevdev_next_event

Peter Hutterer peter.hutterer at who-t.net
Mon Jan 14 22:53:37 UTC 2019


On Fri, Jan 11, 2019 at 11:52:35AM +0300, Knoppix wrote:
> Hi,
> 
> I set some calibration/settings on input device (*turn device wheel to
> left. I did this with write() function*) while this happens input system
> gathers data. So when I first call libevdev_next_event it gives me old
> garbage data. But I dont want those.
> 
> How can I flush/clear buffered data with libevdev? Is there any way?

If the device continuously sends data at a high frequency, it'll be hard to 
figure out exactly when the new data represents whatever you set the device
to, so you'll need some guessed delay anyway. But the easiest way is to just
discard the data coming out of libevdev until you're convinced it's within
the new calibration range.

libevdev doesn't do anything other than update a few internal states with
the data, so if you take the libevdev_next_event() and not do anything with
it, that event is discarded.

Cheers,
   Peter




More information about the Input-tools mailing list