[PATCH evemu] Print the state of SW/SND/LED in the evemu describe comments

Benjamin Tissoires benjamin.tissoires at gmail.com
Mon Jul 20 07:43:56 PDT 2015


On Sun, Jul 19, 2015 at 7:56 PM, Peter Hutterer
<peter.hutterer at who-t.net> wrote:
> We merely print the state of the device in the comment section but don't
> record that state in the actual description file. There is no evdev ioctl to
> set the state of a device without sending an event through the device, so we
> can't replicate the state without altering the recorded event sequence.
>
> For this reason, we use the libevdev shortcut to query the state rather than
> adding an evemu-specific API to get the state.
>
> EV_KEY can give us the state but we don't print it, unlike the others a key
> state is too transient.

I can definitively see the value of adding the comment with the state.
However, I think we should also add a tag for that and record it
properly in the evemu event file. Not having the ioctl to set it
should not be a reason to not record it. We can always add this ioctl
in the kernel if this is useful.

Cheers,
Benjamin

>
> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
> ---
>  src/evemu.c | 12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/src/evemu.c b/src/evemu.c
> index 642597b..5a7f7d0 100644
> --- a/src/evemu.c
> +++ b/src/evemu.c
> @@ -300,6 +300,7 @@ static void write_abs(FILE *fp, int index, const struct input_absinfo *abs)
>  static void write_desc(const struct evemu_device *dev, FILE *fp)
>  {
>         int i, j;
> +       int state;
>         fprintf(fp, "# Input device name: \"%s\"\n", evemu_get_name(dev));
>         fprintf(fp, "# Input device ID: bus %#04x vendor %#04x product %#04x version %#04x\n",
>                 evemu_get_id_bustype(dev), evemu_get_id_vendor(dev),
> @@ -316,7 +317,8 @@ static void write_desc(const struct evemu_device *dev, FILE *fp)
>
>                         fprintf(fp, "#     Event code %d (%s)\n",
>                                     j, libevdev_event_code_get_name(i, j));
> -                       if (i == EV_ABS) {
> +                       switch(i) {
> +                               case EV_ABS:
>                                 fprintf(fp, "#       Value %6d\n"
>                                             "#       Min   %6d\n"
>                                             "#       Max   %6d\n"
> @@ -329,6 +331,14 @@ static void write_desc(const struct evemu_device *dev, FILE *fp)
>                                             evemu_get_abs_fuzz(dev, j),
>                                             evemu_get_abs_flat(dev, j),
>                                             evemu_get_abs_resolution(dev, j));
> +                               case EV_LED:
> +                               case EV_SND:
> +                               case EV_SW:
> +                                       state = libevdev_get_event_value(dev->evdev, i, j);
> +                                       fprintf(fp, "#        State %d\n", state);
> +                                       break;
> +                               default:
> +                                       break;
>                         }
>                 }
>         }
> --
> 2.4.3
>


More information about the Input-tools mailing list