HID: bpf: Fix Rapoo M50 Plus Silent side buttons
The Rapoo M50 Plus Silent mouse has 2 side buttons in addition to the left, right and middles buttons. However, its original HID descriptor has a Usage Maximum of 3, preventing the side buttons to work.
This HID-BPF driver changes that usage to 5.
Link: libinput/libinput#1015 (closed)
@jussi.lahtinen here is the fix for your mouse. Following the tutorial: https://libevdev.pages.freedesktop.org/udev-hid-bpf/getting-started.html
You should be able to install the HID-BPF program for your device executing these commands:
$ git clone --branch rapoo-m50 https://gitlab.freedesktop.org/JoseExposito/udev-hid-bpf.git
$ cd udev-hid-bpf
$ meson setup builddir
$ meson compile -C builddir
$ meson install -C builddir
Disconnect and connect your mouse and the side buttons should work.
I couldn't test it properly because the program refuses to load:
$ ninja -C builddir && \
sudo ./builddir/udev-hid-bpf --verbose add --replace \
/sys/bus/hid/devices/0003:24AE:2015.* - \
$(pwd)/builddir/src/bpf/10-Rapoo__M50-Plus-Silent.bpf.o
ninja: Entering directory `builddir'
ninja: no work to do.
[sudo] password for jexposit:
DEBUG - loading BPF object at "/home/jexposit/Devel/udev-hid-bpf/builddir/src/bpf/10-Rapoo__M50-Plus-Silent.bpf.o"
DEBUG - libbpf: elf: skipping unrecognized data section(7) .hid_bpf_config
DEBUG - Using HID_BPF_STRUCT_OPS
WARN - libbpf: struct_ops init_kern: struct bpf_struct_ops_hid_bpf_ops is not found in kernel BTF
WARN - libbpf: failed to load object '/home/jexposit/Devel/udev-hid-bpf/builddir/src/bpf/10-Rapoo__M50-Plus-Silent.bpf.o'
WARN - Failed to load "/home/jexposit/Devel/udev-hid-bpf/builddir/src/bpf/10-Rapoo__M50-Plus-Silent.bpf.o": No such file or directory (os error 2)
$ ls /home/jexposit/Devel/udev-hid-bpf/builddir/src/bpf/10-Rapoo__M50-Plus-Silent.bpf.o
/home/jexposit/Devel/udev-hid-bpf/builddir/src/bpf/10-Rapoo__M50-Plus-Silent.bpf.o
Maybe @bentiss knows why I'm getting a no such file or directory error when the file is present?
Merge request reports
Activity
mentioned in issue libinput/libinput#1015 (closed)
- Resolved by Peter Hutterer
WARN - libbpf: struct_ops init_kern: struct bpf_struct_ops_hid_bpf_ops is not found in kernel BTF
If you are running on a kernel not supporting struct_ops (only on unreleased kernel, so 99% of the time) you need to manually load the
09-Rapoo__M50-Plus-Silent.bpf.o
file. Once installed, you don't notice the difference, but for manual loading, you need to rely on that different file
added 1 commit
- fa5a3c0d - HID: bpf: Fix Rapoo M50 Plus Silent side buttons
The compilation fails with
libbpf: failed to find BTF info for global/extern symbol 'memcmp'
$ clang --version Ubuntu clang version 14.0.0-1ubuntu1.1 Target: x86_64-pc-linux-gnu Thread model: posix InstalledDir: /usr/bin
Maybe this is issue only with Huion files, but I'm not familiar with meson... how I make it ignore this? Or any suggestions to fix the issue?
- Resolved by Benjamin Tissoires
Maybe this is issue only with Huion files, but I'm not familiar with meson... how I make it ignore this? Or any suggestions to fix the issue?
This looks like a not recent enough LLVM version.
The simplest is to download the artifacts of the last job of the last pipeline (currently https://gitlab.freedesktop.org/JoseExposito/udev-hid-bpf/-/jobs/60965628/artifacts/file/udev-hid-bpf_1.0.1-20240515-63-gfa5a3c0.tar.xz) -> download the artifacts, extract them and then run
./bin/udev-hid-bpf --version
. If you don't get any error, you can run theinstall.sh
script, then unplug replug the mouse.If you get some issues with libc not recent enough, you could comment out all the problematic files in
src/bpf/testing/meson.build
,src/bpf/stable/meson.build
, andsrc/bpf/userhacks/meson.build
because you don't really need them, all you need is the bpf object @jexposit made for you. And if you can not even compile it, you can still take the one from the archive I mentioned above, it should work fine on your kernel.
OK, I tried to change to clang version 15.0.7 (that was newest in the repo), but it didn't help. So I disabled the offending targets and now things go much further... Now compiling stops with these:
../src/bpf/hid_bpf_helpers.h:167:15: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘#pragma’ 167 | } _device_ids SEC(".hid_bpf_config") | ^~~
Still clang version issue? Looks kinda it, when it cannot understand the syntax. I guess the dependency should be at least for clang version 16.
However, I'm happy to tell that using the binaries you wrote and compiled for me work perfectly! Thank you very much for both of you!
- Resolved by José Expósito
- Resolved by José Expósito
- Resolved by Benjamin Tissoires
lgtm with two minor nitpicks
mentioned in merge request !119 (merged)
added 1 commit
- 716cd111 - HID: bpf: Fix Rapoo M50 Plus Silent side buttons
added 10 commits
-
716cd111...a32ec802 - 9 commits from branch
libevdev:main
- e9bad3c3 - HID: bpf: Fix Rapoo M50 Plus Silent side buttons
-
716cd111...a32ec802 - 9 commits from branch
enabled an automatic merge when the pipeline for e9bad3c3 succeeds
mentioned in commit bentiss/udev-hid-bpf@90f4bba6
mentioned in commit bentiss/hid@cee9faff