Re: [PATCH libinput] evdev: disable the mode button on the Cyborg RAT 5

2016-02-04 Thread Joel Duncan
​​
Hi guys,

Not being a libinput dev I was looking for advice on using this patch.
I noticed that a lot of the RAT config was in /test. After compiling the
driver
and installing it the problem still persists.

I'm assuming it's due to needing a flag when compiling to include /test
components?

Any advice would be great!

Thanks,

Joel

On Fri, Jan 29, 2016 at 12:48 AM, Peter Hutterer 
wrote:

> This button sends a release N, press N+1 on each press, cycling through the
> three event codes supported. This causes a stuck button since the current
> mode
> is never released.
>
> Long-term this better served by a set of switches that toggle accordingly,
> for
> now disable the button codes.
>
> https://bugs.freedesktop.org/show_bug.cgi?id=92127
>
> Signed-off-by: Peter Hutterer 
> ---
>  src/evdev.c| 36 +
>  src/evdev.h|  1 +
>  test/Makefile.am   |  1 +
>  test/device.c  | 33 
>  test/litest-device-cyborg-rat-5.c  | 71
> ++
>  test/litest.c  |  2 +
>  test/litest.h  |  1 +
>  udev/90-libinput-model-quirks.hwdb |  7 
>  udev/90-libinput-model-quirks.rules.in |  4 ++
>  9 files changed, 156 insertions(+)
>  create mode 100644 test/litest-device-cyborg-rat-5.c
>
> diff --git a/src/evdev.c b/src/evdev.c
> index 8f0a607..66673a8 100644
> --- a/src/evdev.c
> +++ b/src/evdev.c
> @@ -1677,6 +1677,7 @@ evdev_read_model_flags(struct evdev_device *device)
> { "LIBINPUT_MODEL_JUMPING_SEMI_MT",
> EVDEV_MODEL_JUMPING_SEMI_MT },
> { "LIBINPUT_MODEL_ELANTECH_TOUCHPAD",
> EVDEV_MODEL_ELANTECH_TOUCHPAD },
> { "LIBINPUT_MODEL_APPLE_INTERNAL_KEYBOARD",
> EVDEV_MODEL_APPLE_INTERNAL_KEYBOARD },
> +   { "LIBINPUT_MODEL_CYBORG_RAT", EVDEV_MODEL_CYBORG_RAT },
> { NULL, EVDEV_MODEL_DEFAULT },
> };
> const struct model_map *m = model_map;
> @@ -2249,6 +2250,39 @@ evdev_drain_fd(int fd)
> }
>  }
>
> +static inline void
> +evdev_pre_configure_model_quirks(struct evdev_device *device)
> +{
> +   /* The Cyborg RAT has a mode button that cycles through event
> codes.
> +* On press, we get a release for the current mode and a press for
> the
> +* next mode:
> +* E: 0.01 0004 0004 589833 # EV_MSC / MSC_SCAN
>  589833
> +* E: 0.01 0001 0118    # EV_KEY / (null)   0
> +* E: 0.01 0004 0004 589834 # EV_MSC / MSC_SCAN
>  589834
> +* E: 0.01 0001 0119 0001   # EV_KEY / (null)   1
> +* E: 0.01      #  SYN_REPORT (0)
> -- +0ms
> +* E: 0.705000 0004 0004 589834 # EV_MSC / MSC_SCAN
>  589834
> +* E: 0.705000 0001 0119    # EV_KEY / (null)   0
> +* E: 0.705000 0004 0004 589835 # EV_MSC / MSC_SCAN
>  589835
> +* E: 0.705000 0001 011a 0001   # EV_KEY / (null)   1
> +* E: 0.705000      #  SYN_REPORT (0)
> -- +705ms
> +* E: 1.496995 0004 0004 589833 # EV_MSC / MSC_SCAN
>  589833
> +* E: 1.496995 0001 0118 0001   # EV_KEY / (null)   1
> +* E: 1.496995 0004 0004 589835 # EV_MSC / MSC_SCAN
>  589835
> +* E: 1.496995 0001 011a    # EV_KEY / (null)   0
> +* E: 1.496995      #  SYN_REPORT (0)
> -- +791ms
> +*
> +* https://bugs.freedesktop.org/show_bug.cgi?id=92127
> +*
> +* Disable the event codes to avoid stuck buttons.
> +*/
> +   if(device->model_flags & EVDEV_MODEL_CYBORG_RAT) {
> +   libevdev_disable_event_code(device->evdev, EV_KEY, 0x118);
> +   libevdev_disable_event_code(device->evdev, EV_KEY, 0x119);
> +   libevdev_disable_event_code(device->evdev, EV_KEY, 0x11a);
> +   }
> +}
> +
>  struct evdev_device *
>  evdev_device_create(struct libinput_seat *seat,
> struct udev_device *udev_device)
> @@ -2318,6 +2352,8 @@ evdev_device_create(struct libinput_seat *seat,
> matrix_init_identity(&device->abs.usermatrix);
> matrix_init_identity(&device->abs.default_calibration);
>
> +   evdev_pre_configure_model_quirks(device);
> +
> if (evdev_configure_device(device) == -1)
> goto err;
>
> diff --git a/src/evdev.h b/src/evdev.h
> index 02b5112..8b567a8 100644
> --- a/src/evdev.h
> +++ b/src/evdev.h
> @@ -110,6 +110,7 @@ enum evdev_device_model {
> EVDEV_MODEL_ELANTECH_TOUCHPAD = (1 << 11),
> EVDEV_MODEL_LENOVO_X220_TOUCHPAD_FW81 = (1 << 12),
> EVDEV_MODEL_APPLE_INTERNAL_KEYBOARD = (1 << 13),
> +   EVDEV_MODEL_CYBORG_RAT = (1 << 14),
>  };
>
>  struct mt_slot {
> diff --git a/test/Makefile.am b/test/Makefile.am
> index 885d9c6..27a2a36 100644

Re: [PATCH libinput] evdev: disable the mode button on the Cyborg RAT 5

2016-02-04 Thread Joel Duncan
Thanks for clearing that up, Can confirm the patch works.

udev rules were put in /usr/local/lib/udev by make command, moved to
/usr/lib/udev then devadm hwdb --update.

Looking forward to seeing this in upstream Fedora one day.

Thanks,

Joel


On Wed, Feb 3, 2016 at 9:30 PM, Peter Hutterer 
wrote:
>
> On Wed, Feb 03, 2016 at 06:47:01PM +, Joel Duncan wrote:
> >
> > Hi guys,
> >
> > Not being a libinput dev I was looking for advice on using this patch.
> > I noticed that a lot of the RAT config was in /test. After compiling the
> > driver
> > and installing it the problem still persists.
> >
> > I'm assuming it's due to needing a flag when compiling to include /test
> > components?
>
> anything in test are libinput-internal tests, you don't need them to use
> libinput.
>
> This fix relies on a udev tag applied to the mouse. So my best guess is
> that you either didn't install the udev rule/hwdb entry correctly, or that
> you didn't run sudo udevadm hwdb --update afterwards.
>
> run udevadm info /sys/class/input/eventX for whatever event node your
mouse
> has and check if the LIBINPUT_MODEL_CYBORG_RAT variable is set on the
> device. I not, then you need to check the udev rule/hwdb install.
> if it's set and it still doesn't work, the patch is buggy.
>
> Cheers,
>Peter
>
> > Any advice would be great!
> >
> > Thanks,
> >
> > Joel
> >
> > On Fri, Jan 29, 2016 at 12:48 AM, Peter Hutterer <
peter.hutte...@who-t.net>
> > wrote:
> >
> > > This button sends a release N, press N+1 on each press, cycling
through the
> > > three event codes supported. This causes a stuck button since the
current
> > > mode
> > > is never released.
> > >
> > > Long-term this better served by a set of switches that toggle
accordingly,
> > > for
> > > now disable the button codes.
> > >
> > > https://bugs.freedesktop.org/show_bug.cgi?id=92127
> > >
> > > Signed-off-by: Peter Hutterer 
> > > ---
> > >  src/evdev.c| 36 +
> > >  src/evdev.h|  1 +
> > >  test/Makefile.am   |  1 +
> > >  test/device.c  | 33 
> > >  test/litest-device-cyborg-rat-5.c  | 71
> > > ++
> > >  test/litest.c  |  2 +
> > >  test/litest.h  |  1 +
> > >  udev/90-libinput-model-quirks.hwdb |  7 
> > >  udev/90-libinput-model-quirks.rules.in |  4 ++
> > >  9 files changed, 156 insertions(+)
> > >  create mode 100644 test/litest-device-cyborg-rat-5.c
> > >
> > > diff --git a/src/evdev.c b/src/evdev.c
> > > index 8f0a607..66673a8 100644
> > > --- a/src/evdev.c
> > > +++ b/src/evdev.c
> > > @@ -1677,6 +1677,7 @@ evdev_read_model_flags(struct evdev_device
*device)
> > > { "LIBINPUT_MODEL_JUMPING_SEMI_MT",
> > > EVDEV_MODEL_JUMPING_SEMI_MT },
> > > { "LIBINPUT_MODEL_ELANTECH_TOUCHPAD",
> > > EVDEV_MODEL_ELANTECH_TOUCHPAD },
> > > { "LIBINPUT_MODEL_APPLE_INTERNAL_KEYBOARD",
> > > EVDEV_MODEL_APPLE_INTERNAL_KEYBOARD },
> > > +   { "LIBINPUT_MODEL_CYBORG_RAT", EVDEV_MODEL_CYBORG_RAT
},
> > > { NULL, EVDEV_MODEL_DEFAULT },
> > > };
> > > const struct model_map *m = model_map;
> > > @@ -2249,6 +2250,39 @@ evdev_drain_fd(int fd)
> > > }
> > >  }
> > >
> > > +static inline void
> > > +evdev_pre_configure_model_quirks(struct evdev_device *device)
> > > +{
> > > +   /* The Cyborg RAT has a mode button that cycles through event
> > > codes.
> > > +* On press, we get a release for the current mode and a
press for
> > > the
> > > +* next mode:
> > > +* E: 0.01 0004 0004 589833 # EV_MSC / MSC_SCAN
> > >  589833
> > > +* E: 0.01 0001 0118    # EV_KEY / (null)
  0
> > > +* E: 0.01 0004 0004 589834 # EV_MSC / MSC_SCAN
> > >  589834
> > > +* E: 0.01 0001 0119 0001   # EV_KEY / (null)
  1
> > > +* E: 0.01      #  SYN_REPORT (0)
> > > -- +0ms
> > > +* E: 0.705000 0004 0004 589834 # EV_MSC / MSC_SCAN
> > >  589834
> > > +*