On 11/10/2014 02:59 AM, Hans de Goede wrote: > + if (libevdev_has_event_code(device->evdev, EV_KEY, button) && > + hw_is_key_down(device, button)) Should hw_is_key_down do this test instead? (ie it returns false if libevdev_has_event_code would return false). It seems like you repeat this a lot.