Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]bluetooth HID remotes not being passed to eventlircd due to faulty udev rules #9586

Open
Dashinginthe90s opened this issue Dec 17, 2024 · 0 comments

Comments

@Dashinginthe90s
Copy link

Describe the bug

My ps3 bd remote control connected via bluetooth is being treated as a keyboard. This is undesirable as kodi is unable to recognize and map the majority of buttons due to the scancode >255 issue. See kodi issue 16834
eventlircd should address this issue and already has support for this remote, but it is not functioning properly for bluetooth devices in this release.

The root cause appears to be the udev rules included with the eventlircd package.
Below is the relevant sections from /lib/udev/rules.d/98-eventlircd.rules

#-------------------------------------------------------------------------------
# Ask eventlircd to handle Bluetooth HID devices that show up as event devices
# and are known to be remote controls. For simplicity, the event map file names
# have the format <BUSTYPE>_<VENDOR>_<PRODUCT>.evmap.
#-------------------------------------------------------------------------------
SUBSYSTEMS=="bluetooth", GOTO="begin-bluetooth"
GOTO="end-bluetooth"
LABEL="begin-bluetooth"

ATTRS{name}=="Nintendo Wii Remote", \
  ENV{eventlircd_enable}="true", \
  ENV{eventlircd_evmap}="wiimote.evmap"

ATTRS{name}=="BD Remote Control", \
  ENV{eventlircd_enable}="true", \
  ENV{eventlircd_evmap}="ps3remote.evmap"

#PS3 BD Remote Version 2 (Bluetooth AND infrared 3 in 1 remote)
ATTRS{name}=="Sony Computer Entertainment Inc BD Remote Control", \
  ENV{eventlircd_enable}="true", \
  ENV{eventlircd_evmap}="ps3remote.evmap"

# Amazon Fire TV stick remote
ATTRS{name}=="Amazon Fire TV Remote", \
  ENV{eventlircd_enable}="true", \
  ENV{eventlircd_evmap}="aftvsremote.evmap"

LABEL="end-bluetooth"

# tell libinput to ignore devices handled by eventlircd
ENV{eventlircd_enable}=="true", ENV{LIBINPUT_IGNORE_DEVICE}="1"

These rules are skipped over unless udev detects the bluetooth subsystem but querying my remote only shows an input subsystem.

udevadm info --attribute-walk --no-pager /dev/input/event3

Udevadm info starts with the device specified by the devpath and then
walks up the chain of parent devices. It prints for every device
found, all possible attributes in the udev rules key format.
A rule to match, can be composed by the attributes of the device
and the attributes from one single parent device.

  looking at device '/devices/virtual/misc/uhid/0005:054C:0306.0001/input/input3/event3':
    KERNEL=="event3"
    SUBSYSTEM=="input"
    DRIVER==""
    ATTR{power/control}=="auto"
    ATTR{power/runtime_active_time}=="0"
    ATTR{power/runtime_status}=="unsupported"
    ATTR{power/runtime_suspended_time}=="0"

  looking at parent device '/devices/virtual/misc/uhid/0005:054C:0306.0001/input/input3':
    KERNELS=="input3"
    SUBSYSTEMS=="input"
    DRIVERS==""
    ATTRS{capabilities/abs}=="0"
    ATTRS{capabilities/ev}=="100013"
    ATTRS{capabilities/ff}=="0"
    ATTRS{capabilities/key}=="7000001083c100 8c00ea00000000 6bc0000000000001 8000 1102c0000801 80168000000000 10000ffe"
    ATTRS{capabilities/led}=="0"
    ATTRS{capabilities/msc}=="10"
    ATTRS{capabilities/rel}=="0"
    ATTRS{capabilities/snd}=="0"
    ATTRS{capabilities/sw}=="0"
    ATTRS{id/bustype}=="0005"
    ATTRS{id/product}=="0306"
    ATTRS{id/vendor}=="054c"
    ATTRS{id/version}=="0100"
    ATTRS{inhibited}=="0"
    ATTRS{name}=="BD Remote Control"
    ATTRS{phys}=="d8:3a:dd:aa:41:f2"
    ATTRS{power/control}=="auto"
    ATTRS{power/runtime_active_time}=="0"
    ATTRS{power/runtime_status}=="unsupported"
    ATTRS{power/runtime_suspended_time}=="0"
    ATTRS{properties}=="0"
    ATTRS{uniq}=="00:1e:3d:b5:fc:77"

  looking at parent device '/devices/virtual/misc/uhid/0005:054C:0306.0001':
    KERNELS=="0005:054C:0306.0001"
    SUBSYSTEMS=="hid"
    DRIVERS=="sony"
    ATTRS{country}=="21"
    ATTRS{power/control}=="auto"
    ATTRS{power/runtime_active_time}=="0"
    ATTRS{power/runtime_status}=="unsupported"
    ATTRS{power/runtime_suspended_time}=="0"

  looking at parent device '/devices/virtual/misc/uhid':
    KERNELS=="uhid"
    SUBSYSTEMS=="misc"
    DRIVERS==""
    ATTRS{power/control}=="auto"
    ATTRS{power/runtime_active_time}=="0"
    ATTRS{power/runtime_status}=="unsupported"
    ATTRS{power/runtime_suspended_time}=="0"

libinput list-devices confirms the rule wasn't applied. If it had, the device would not be visible to libinput.

libinput list-devices
Device:           BD Remote Control
Kernel:           /dev/input/event3
Group:            1
Seat:             seat0, default
Capabilities:     keyboard
Tap-to-click:     n/a
Tap-and-drag:     n/a
Tap drag lock:    n/a
Left-handed:      n/a
Nat.scrolling:    n/a
Middle emulation: n/a
Calibration:      n/a
Scroll methods:   none
Click methods:    none
Disable-w-typing: n/a
Disable-w-trackpointing: n/a
Accel profiles:   n/a
Rotation:         0.0

I modified the rules as follows

#-------------------------------------------------------------------------------
# Ask eventlircd to handle Bluetooth HID devices that show up as event devices
# and are known to be remote controls. For simplicity, the event map file names
# have the format <BUSTYPE>_<VENDOR>_<PRODUCT>.evmap.
#-------------------------------------------------------------------------------
SUBSYSTEMS=="input", ATTRS{name}=="Nintendo Wii Remote", \
  ENV{eventlircd_enable}="true", \
  ENV{eventlircd_evmap}="wiimote.evmap"

SUBSYSTEMS=="input", ATTRS{name}=="BD Remote Control", \
  ENV{eventlircd_enable}="true", \
  ENV{eventlircd_evmap}="ps3remote.evmap"

#PS3 BD Remote Version 2 (Bluetooth AND infrared 3 in 1 remote)
SUBSYSTEMS=="input", ATTRS{name}=="Sony Computer Entertainment Inc BD Remote Control", \
  ENV{eventlircd_enable}="true", \
  ENV{eventlircd_evmap}="ps3remote.evmap"

# Amazon Fire TV stick remote
SUBSYSTEMS=="input", ATTRS{name}=="Amazon Fire TV Remote", \
  ENV{eventlircd_enable}="true", \
  ENV{eventlircd_evmap}="aftvsremote.evmap"

# tell libinput to ignore devices handled by eventlircd
ENV{eventlircd_enable}=="true", ENV{LIBINPUT_IGNORE_DEVICE}="1"

The modified file was placed in
/storage/.config/udev.rules.d/98-eventlircd.rules
After a reboot kodi now detects the remote as a LIRC device. The remote also no longer appears in the output of libinput list-devices

I was able to reproduce the same behavior using a wii remote and confirmed the fix works for it as well. Below is the udev info showing the same subsystem behavior as the sony remote.
I do not have any of the other supported devices to test with.

udevadm info --attribute-walk --no-pager /dev/input/event6

Udevadm info starts with the device specified by the devpath and then
walks up the chain of parent devices. It prints for every device
found, all possible attributes in the udev rules key format.
A rule to match, can be composed by the attributes of the device
and the attributes from one single parent device.

  looking at device '/devices/virtual/misc/uhid/0005:057E:0306.0003/input/input8/event6':
    KERNEL=="event6"
    SUBSYSTEM=="input"
    DRIVER==""
    ATTR{power/control}=="auto"
    ATTR{power/runtime_active_time}=="0"
    ATTR{power/runtime_status}=="unsupported"
    ATTR{power/runtime_suspended_time}=="0"

  looking at parent device '/devices/virtual/misc/uhid/0005:057E:0306.0003/input/input8':
    KERNELS=="input8"
    SUBSYSTEMS=="input"
    DRIVERS==""
    ATTRS{capabilities/abs}=="0"
    ATTRS{capabilities/ev}=="200003"
    ATTRS{capabilities/ff}=="107030000 0"
    ATTRS{capabilities/key}=="10800000 0 1003000000000006 0 0 168000000000 0"
    ATTRS{capabilities/led}=="0"
    ATTRS{capabilities/msc}=="0"
    ATTRS{capabilities/rel}=="0"
    ATTRS{capabilities/snd}=="0"
    ATTRS{capabilities/sw}=="0"
    ATTRS{id/bustype}=="0005"
    ATTRS{id/product}=="0306"
    ATTRS{id/vendor}=="057e"
    ATTRS{id/version}=="8614"
    ATTRS{inhibited}=="0"
    ATTRS{name}=="Nintendo Wii Remote"
    ATTRS{phys}==""
    ATTRS{power/control}=="auto"
    ATTRS{power/runtime_active_time}=="0"
    ATTRS{power/runtime_status}=="unsupported"
    ATTRS{power/runtime_suspended_time}=="0"
    ATTRS{properties}=="0"
    ATTRS{uniq}==""

  looking at parent device '/devices/virtual/misc/uhid/0005:057E:0306.0003':
    KERNELS=="0005:057E:0306.0003"
    SUBSYSTEMS=="hid"
    DRIVERS=="wiimote"
    ATTRS{country}=="33"
    ATTRS{devtype}=="gen10"
    ATTRS{extension}=="none"
    ATTRS{power/control}=="auto"
    ATTRS{power/runtime_active_time}=="0"
    ATTRS{power/runtime_status}=="unsupported"
    ATTRS{power/runtime_suspended_time}=="0"

  looking at parent device '/devices/virtual/misc/uhid':
    KERNELS=="uhid"
    SUBSYSTEMS=="misc"
    DRIVERS==""
    ATTRS{power/control}=="auto"
    ATTRS{power/runtime_active_time}=="0"
    ATTRS{power/runtime_status}=="unsupported"
    ATTRS{power/runtime_suspended_time}=="0"

How to reproduce

Steps to reproduce the behavior:

  1. Connect a eventlircd supported bluetooth remote to kodi
  2. Enable debug logging and press a key.
  3. kodi.log file will show a keyboard keypress instead of a lirc event

Information

  • LibreELEC Version: 12.0.1
  • Hardware Platform: RPi5

Log file

Example of kodi.log before udev rules change

ps3 bd remote

2024-12-16 19:06:07.550 T:874     debug <general>: Keyboard: scancode: 0x6c, sym: 0x112, unicode: 0x00, modifier: 0x0
2024-12-16 19:06:07.550 T:874     debug <general>: HandleKey: down (0xf081) pressed, window 10016, action is Down
2024-12-16 19:06:07.718 T:1418    debug <general>: Thread Timer 140732344987392 terminating
2024-12-16 19:06:07.719 T:874     debug <general>: Keyboard: scancode: 0x6c, sym: 0x112, unicode: 0x00, modifier: 0x0

wii remote

2024-12-16 19:06:45.899 T:893     debug <general>: BUTTON [ 0 ] on "Nintendo Wii Remote" pressed
2024-12-16 19:06:45.899 T:893     debug <general>: Empty button map detected for game.controller.default
2024-12-16 19:06:45.992 T:893      info <general>: Skipped 1 duplicate messages..
2024-12-16 19:06:45.992 T:893     debug <general>: BUTTON [ 0 ] on "Nintendo Wii Remote" released

Example after the udev rules change

2024-12-16 19:16:28.941 T:884     debug <general>: LIRC: - NEW 6c 0 KEY_DOWN devinput (KEY_DOWN)
2024-12-16 19:16:28.948 T:880     debug <general>: HandleKey: 167 (0xa7, obc88) pressed, window 10016, action is Down
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant