| summaryrefslogtreecommitdiff | 
diff options
| author | Nathanael Sensfelder <SpamShield0@MultiAgentSystems.org> | 2019-12-27 20:14:49 +0100 | 
|---|---|---|
| committer | Nathanael Sensfelder <SpamShield0@MultiAgentSystems.org> | 2019-12-27 20:14:49 +0100 | 
| commit | b9952b4938da95de07bff748cfd6d2c7e8471796 (patch) | |
| tree | 3c34b7d8327f41515ec939e3e188767d5d641cca /src/device/physical | |
| parent | 60283fb1407fcd1de0586c960ed8d106f59483e9 (diff) | |
Remembering what was happening in this program...
*Maybe* I should document it more. Who knows... I do seem to get one
feature request every two years, and pretty much forget all about it
inbetween.
Diffstat (limited to 'src/device/physical')
| -rw-r--r-- | src/device/physical/physical_device.c | 40 | 
1 files changed, 35 insertions, 5 deletions
| diff --git a/src/device/physical/physical_device.c b/src/device/physical/physical_device.c index 7023791..4582c2d 100644 --- a/src/device/physical/physical_device.c +++ b/src/device/physical/physical_device.c @@ -187,12 +187,28 @@ int relabsd_physical_device_read        libevdev_next_event        (           device->libevdev, -         device->is_late ? LIBEVDEV_READ_FLAG_SYNC : LIBEVDEV_READ_FLAG_NORMAL, +         ( +            ( +               /* +                * If we were already late, reading in NORMAL mode discards all +                * the outdated input events, whereas reading in SYNC mode goes +                * through them in order. +                * TODO: add an option to allow users to drop events when late. +                */ +               device->is_late ? +               LIBEVDEV_READ_FLAG_SYNC +               : LIBEVDEV_READ_FLAG_NORMAL +            ) +            /* "The fd is not in O_NONBLOCK and a read may block." */ +            | LIBEVDEV_READ_FLAG_BLOCKING +         ) +         ,           &event        );     switch (returned_code)     { +      /* Read an actual input. */        case LIBEVDEV_READ_STATUS_SUCCESS:           RELABSD_DEBUG           ( @@ -207,14 +223,28 @@ int relabsd_physical_device_read           *input_code = event.code;           *input_value = event.value; -         return 1; +         return 0; +      /* Code indicating that we are late. */        case LIBEVDEV_READ_STATUS_SYNC: -         /* There are old events waiting to be read. */ +         /* There are old input events waiting to be read. */           device->is_late = 1; +         /* +          * From the documentation, the event we just read was an EV_SYN one, +          * so we don't actually have any input event in hand. +          */ + +         /* FIXME: Really make sure this cannot recurse a second time. */ +         return +            relabsd_physical_device_read +            ( +               device, +               input_type, +               input_code, +               input_value +            ); -         return 0; - +      /* No event to read. */        case -EAGAIN:           device->is_late = 0; | 


