libinput/quirks/50-system-cyborg.quirks
Peter Hutterer a7e4cbc212 quirks: allow overriding of AttrEventCode and AttrInputProp
This switches the quirk from AttrEventCodeEnable/Disable to just
AttrEventCode with a +/- prefix for each entry.
This switches the quirk from AttrInputPropEnable/Disable to just
AttrInputProp with a +/- prefix for each entry.

Previously, both event codes and input props would only apply the
last-matching section entry for a device. Furthermore, an earlier Disable entry
would take precedence over a later Enable entry. For example, a set of
sections with these lines *should* enable left, right and middle:

  [first]
  AttrEventCodeEnable=BTN_LEFT;BTN_RIGHT;BTN_MIDDLE

  [second]
  AttrEventCodeDisable=BTN_RIGHT

  [third]
  AttrEventCodeEnable=BTN_LEFT;BTN_RIGHT;

Alas: the first line was effectively ignored (quirks only returned the
last-matching one, i.e. the one from "third"). And due to implementation
details in evdev.c, the Disable attribute was processed after Enable,
i.e. the device was enabled for left + right and then disabled for
right. As a result, the device only had BTN_LEFT enabled.

Fix this by changing the attribute to carry both enable/disable
information and merging the commands together.

Internally, all quirks matching a device are simply ref'd into an array
in the struct quirks. The applied value is simply the last entry in the
array corresponding to our quirk.

For AttrEventCode and AttrInputProp instead do this:
- switch them to a tuple with the code as first entry and a boolean
  enable/disable as second entry
- if the struct quirk already has an entry for either, append the more
  recent one to the existing entry (instead of creating a new entry in
  the array). This way we have all entries that match and in-order of
  precedence - i.e. we can process them left-to-right to end up
  with the right state.

Fixes: https://gitlab.freedesktop.org/libinput/libinput/-/issues/821

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-11-28 08:25:41 +10:00

31 lines
1.5 KiB
Text

# Do not edit this file, it will be overwritten on update
# 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.000001 0004 0004 589833 # EV_MSC / MSC_SCAN 589833
# E: 0.000001 0001 0118 0000 # EV_KEY / (null) 0
# E: 0.000001 0004 0004 589834 # EV_MSC / MSC_SCAN 589834
# E: 0.000001 0001 0119 0001 # EV_KEY / (null) 1
# E: 0.000001 0000 0000 0000 # ------------ SYN_REPORT (0) ---------- +0ms
# E: 0.705000 0004 0004 589834 # EV_MSC / MSC_SCAN 589834
# E: 0.705000 0001 0119 0000 # 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 0000 0000 0000 # ------------ 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 0000 # EV_KEY / (null) 0
# E: 1.496995 0000 0000 0000 # ------------ SYN_REPORT (0) ---------- +791ms
#
# https://bugs.freedesktop.org/show_bug.cgi?id=92127
#
# Disable the event codes to avoid stuck buttons.
[Saitek Cyborg RAT5]
MatchUdevType=mouse
MatchBus=usb
MatchVendor=0x06A3
MatchProduct=0x0CD5
# EV_KEY 0x118, 0x119, 0x11a
AttrEventCode=-EV_KEY:0x118;-EV_KEY:0x119;-EV_KEY:0x11a