sezanzeb / input-remapper

🎮 ⌨ An easy to use tool to change the behaviour of your input devices.
GNU General Public License v3.0
3.89k stars 161 forks source link

The autoload fails to load from time to time incosistently #815

Open Felixoid opened 11 months ago

Felixoid commented 11 months ago

Please install the newest version from source to see if the problem has already been solved.

System Information and logs

  1. input-remapper-control --version
    input-remapper 2.0.1 d55c6d4eeb376e62fba10205b50752636034afe3 https://github.com/sezanzeb/input-remapper
    python-evdev 1.6.1
  2. which linux distro (ubuntu 20.04, manjaro, etc.): Arch Linux
  3. which desktop environment (gnome, plasma, xfce4, etc.): plasma
  4. sudo ls -l /proc/1/exe to check if you are using systemd: lrwxrwxrwx 1 root root 0 Nov 29 00:55 /proc/1/exe -> /usr/lib/systemd/systemd
  5. cat ~/.config/input-remapper-2/config.json to see if the "autoload" config is written correctly
    {
    "version": "2.0.1",
    "autoload": {
        "ProtoArc EM03 Mouse": "Trackball buttons"
    }
    }
  6. systemctl status input-remapper -n 50 the service has to be running
    
    ● input-remapper.service - Service to inject keycodes without the GUI application
     Loaded: loaded (/usr/lib/systemd/system/input-remapper.service; enabled; preset: disabled)
     Active: active (running) since Wed 2023-11-29 14:56:11 CET; 1min 13s ago
    Main PID: 95212 (input-remapper-)
      Tasks: 5 (limit: 76365)
     Memory: 31.6M
        CPU: 229ms
     CGroup: /system.slice/input-remapper.service
             ├─95212 /usr/bin/python3 /usr/bin/input-remapper-service
             └─95319 /usr/bin/python3 /usr/bin/input-remapper-service

Nov 29 14:56:11 slim-click systemd[1]: Starting Service to inject keycodes without the GUI application... Nov 29 14:56:11 slim-click input-remapper-service[95212]: input-remapper-service 2.0.1 d55c6d4eeb376e62fba10205b50752636034afe3 https://github.com/sezanzeb/input-remapper Nov 29 14:56:11 slim-click input-remapper-service[95212]: python-evdev 1.6.1 Nov 29 14:56:11 slim-click systemd[1]: Started Service to inject keycodes without the GUI application. Nov 29 14:56:22 slim-click input-remapper-service[95212]: Request to autoload for "ProtoArc EM03 Mouse" Nov 29 14:56:22 slim-click input-remapper-service[95212]: ERROR: Request to autoload "ProtoArc EM03 Mouse" before a user told the service about their session using set_config_dir Nov 29 14:56:22 slim-click input-remapper-service[95212]: Request to autoload for "ProtoArc EM03 Mouse" Nov 29 14:56:22 slim-click input-remapper-service[95212]: ERROR: Request to autoload "ProtoArc EM03 Mouse" before a user told the service about their session using set_config_dir Nov 29 14:56:32 slim-click input-remapper-service[95212]: Request to autoload for "ProtoArc EM03 Mouse" Nov 29 14:56:32 slim-click input-remapper-service[95212]: ERROR: Request to autoload "ProtoArc EM03 Mouse" before a user told the service about their session using set_config_dir Nov 29 14:56:32 slim-click input-remapper-service[95212]: Request to autoload for "ProtoArc EM03 Mouse" Nov 29 14:56:32 slim-click input-remapper-service[95212]: ERROR: Request to autoload "ProtoArc EM03 Mouse" before a user told the service about their session using set_config_dir Nov 29 14:57:09 slim-click input-remapper-service[95212]: Request to autoload for "ProtoArc EM03 Mouse" Nov 29 14:57:09 slim-click input-remapper-service[95212]: ERROR: Request to autoload "ProtoArc EM03 Mouse" before a user told the service about their session using set_config_dir Nov 29 14:57:10 slim-click input-remapper-service[95212]: Request to autoload for "ProtoArc EM03 Mouse" Nov 29 14:57:10 slim-click input-remapper-service[95212]: ERROR: Request to autoload "ProtoArc EM03 Mouse" before a user told the service about their session using set_config_dir


**Testing the setup**

1. `input-remapper-control --command hello`

Connected to the service Daemon answered with "hello" Done

2. `sudo pkill -f input-remapper-service && sudo input-remapper-service -d & sleep 2 && input-remapper-control --command autoload`, are your keys mapped now? `No, it fails to remap it 2/3 times, see logs` [input-remapper.log](https://github.com/sezanzeb/input-remapper/files/13501363/input-remapper.log)
3. (while the previous command is still running) `sudo evtest` and search for a device suffixed by "mapped". Select it, does it report any events? Share the output.

it has two devices: /dev/input/event20: input-remapper mouse /dev/input/event21: input-remapper ProtoArc EM03 Mouse forwarded

When remapper fails to autoload, 20 reports nothing. When it succeeds, it reports remapped input like

Event: time 1701266889.483849, -------------- SYN_REPORT ------------ Event: time 1701266889.633832, type 1 (EV_KEY), code 272 (BTN_LEFT), value 0 Event: time 1701266889.633832, -------------- SYN_REPORT ------------ Event: time 1701266893.047303, type 1 (EV_KEY), code 274 (BTN_MIDDLE), value 1

4. `sudo udevadm control --log-priority=debug && sudo udevadm control --reload-rules && journalctl -f | grep input-remapper`, now plug in the device that should autoload: 15:11:30 failed to autoload, 15:11:46 succeeded [udevadm.log](https://github.com/sezanzeb/input-remapper/files/13501450/udevadm.log)

## Notes

It suddenly stopped working, and I can't find why

the systemd service reports in the same time

Nov 29 15:49:40 slim-click input-remapper-service[108770]: Request to autoload for "ProtoArc EM03 Mouse" Nov 29 15:49:40 slim-click input-remapper-service[108770]: ERROR: Request to autoload "ProtoArc EM03 Mouse" before a user told the service about their session using set_config_dir



*update*: which is solved by running and adding /usr/share/input-remapper/input-remapper-autoload.desktop to autoload. But still, `FileNotFoundError: [Errno 2] No such file or directory: '/dev/input/event21'` is presented in the service logs
christopherseaman commented 7 months ago

Having a similar issue here. Bluetooth device reconnecting sometimes fails to load with a similar FileNotFoundError: [Errno 2] No such file or directory: '/dev/input/eventX error.

@Felixoid - It sounds like adding input-remapper-autoload.desktop to autoload fixed the issue for you, but the error remains. Does this mean you're setting input-remapper-autoload.desktop to run on GUI login and disconnect/reconnect cycles now work for you? I tried adding input-remapper-autoload.desktop to ~/.config/lxsession/LXDE-pi/autostart, but still have the issue upon bluetooth reconnect.

My workaround has been to define an action on my phone to send input-remapper-control --command stop-all && input-remapper-control --command autoload via ssh. (Shout out to ServerCat for making that a single tap).

System Information and logs

  1. input-remapper-control --version

input-remapper 2.0.1 568f56cdb438f4ad6db9e96b2900d1228ea736ee https://github.com/sezanzeb/input-remapper python-evdev 1.6.1

  1. which linux distro (ubuntu 20.04, manjaro, etc.)

Raspberry Pi 5 running default, up-to-date Raspberry Pi / Debian OS ❯ cat /etc/os-release PRETTY_NAME="Debian GNU/Linux 12 (bookworm)" ... ❯ uname -r 6.6.20+rpt-rpi-2712

  1. which desktop environment (gnome, plasma, xfce4, etc.)

LXDE (stock Raspberry Pi install)

  1. sudo ls -l /proc/1/exe to check if you are using systemd

❯ sudo ls -l /proc/1/exe lrwxrwxrwx 1 root root 0 Mar 20 16:43 /proc/1/exe -> /usr/lib/systemd/systemd

  1. cat ~/.config/input-remapper-2/config.json to see if the "autoload" config is written correctly

❯ cat ~/.config/input-remapper-2/config.json { "version": "2.0.1", "autoload": { "8BitDo Micro gamepad Keyboard": "Remote", "8BitDo Micro gamepad": "8BitDo-D" } }

  1. systemctl status input-remapper -n 50 the service has to be running

input-remapper.service - Service to inject keycodes without the GUI application Loaded: loaded (/lib/systemd/system/input-remapper.service; enabled; preset: enabled) Active: active (running) since Wed 2024-03-20 16:43:43 PDT; 16h ago Main PID: 829 (input-remapper-) Tasks: 6 (limit: 9248) CPU: 872ms CGroup: /system.slice/input-remapper.service ├─829 /usr/bin/python3 /usr/bin/input-remapper-service └─947 /usr/bin/python3 /usr/bin/input-remapper-service

Mar 20 16:46:07 schmaspberry input-remapper-service[2889]: Starting injecting the preset for "8BitDo Micro gamepad" Mar 20 16:47:40 schmaspberry input-remapper-service[829]: Loaded config from "/home/christopher/.config/input-remapper-2/config.json" Mar 20 16:47:40 schmaspberry input-remapper-service[829]: Loaded config from "/home/christopher/.config/input-remapper-2/config.json" Mar 20 16:47:40 schmaspberry input-remapper-service[829]: Stopping all injections Mar 20 16:47:40 schmaspberry input-remapper-service[829]: Stopping injecting keycodes for group "8BitDo Micro gamepad" Mar 20 16:47:40 schmaspberry input-remapper-service[2889]: read loop for /dev/input/event5 stopped Mar 20 16:47:40 schmaspberry input-remapper-service[829]: Loaded config from "/home/christopher/.config/input-remapper-2/config.json" Mar 20 16:47:40 schmaspberry input-remapper-service[829]: Loaded config from "/home/christopher/.config/input-remapper-2/config.json" Mar 20 16:47:40 schmaspberry input-remapper-service[829]: Autoloading for all devices Mar 20 16:47:40 schmaspberry input-remapper-service[829]: Found "pwr_button", "vc4-hdmi-0", "vc4-hdmi-1", "8BitDo Micro gamepad", "input-remapper mouse" Mar 20 16:47:40 schmaspberry input-remapper-service[829]: Autoloading for "8BitDo Micro gamepad" Mar 20 16:47:40 schmaspberry input-remapper-service[829]: Request to start injecting for "8BitDo Micro gamepad" Mar 20 16:47:40 schmaspberry input-remapper-service[829]: Loading preset from "/home/christopher/.config/input-remapper-2/presets/8BitDo Micro gamepad/8BitDo-D.json" Mar 20 16:47:40 schmaspberry input-remapper-service[829]: Stopping injecting keycodes for group "8BitDo Micro gamepad" Mar 20 16:47:40 schmaspberry input-remapper-service[3484]: Starting injecting the preset for "8BitDo Micro gamepad" Mar 20 16:52:55 schmaspberry input-remapper-service[3484]: ERROR: fd broke, was the device unplugged? Mar 20 16:52:55 schmaspberry input-remapper-service[3484]: read loop for /dev/input/event5 stopped Mar 21 09:19:00 schmaspberry input-remapper-service[829]: Request to autoload for "8BitDo Micro gamepad" Mar 21 09:19:00 schmaspberry input-remapper-service[829]: Found "pwr_button", "vc4-hdmi-0", "vc4-hdmi-1", "input-remapper mouse", "input-remapper 8BitDo Micro gamepad forwarded", "8BitDo Micro gamepad" Mar 21 09:19:00 schmaspberry input-remapper-service[829]: Autoloading for "8BitDo Micro gamepad" Mar 21 09:19:00 schmaspberry input-remapper-service[829]: Request to start injecting for "8BitDo Micro gamepad" Mar 21 09:19:00 schmaspberry input-remapper-service[829]: Loading preset from "/home/christopher/.config/input-remapper-2/presets/8BitDo Micro gamepad/8BitDo-D.json" Mar 21 09:19:00 schmaspberry input-remapper-service[829]: Stopping injecting keycodes for group "8BitDo Micro gamepad" Mar 21 09:19:00 schmaspberry input-remapper-service[21210]: Starting injecting the preset for "8BitDo Micro gamepad" Mar 21 09:19:00 schmaspberry input-remapper-service[21210]: Process 8BitDo Micro gamepad: Mar 21 09:19:00 schmaspberry input-remapper-service[21210]: Traceback (most recent call last): Mar 21 09:19:00 schmaspberry input-remapper-service[21210]: File "/usr/lib/python3/dist-packages/evdev/device.py", line 125, in init Mar 21 09:19:00 schmaspberry input-remapper-service[21210]: fd = os.open(dev, os.O_RDWR | os.O_NONBLOCK) Mar 21 09:19:00 schmaspberry input-remapper-service[21210]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Mar 21 09:19:00 schmaspberry input-remapper-service[21210]: FileNotFoundError: [Errno 2] No such file or directory: '/dev/input/event8' Mar 21 09:19:00 schmaspberry input-remapper-service[21210]: During handling of the above exception, another exception occurred: Mar 21 09:19:00 schmaspberry input-remapper-service[21210]: Traceback (most recent call last): Mar 21 09:19:00 schmaspberry input-remapper-service[21210]: File "/usr/lib/python3.11/multiprocessing/process.py", line 314, in _bootstrap Mar 21 09:19:00 schmaspberry input-remapper-service[21210]: self.run() Mar 21 09:19:00 schmaspberry input-remapper-service[21210]: File "/usr/lib/python3/dist-packages/inputremapper/injection/injector.py", line 414, in run Mar 21 09:19:00 schmaspberry input-remapper-service[21210]: forward_devices[device_hash] = self._create_forwarding_device(device) Mar 21 09:19:00 schmaspberry input-remapper-service[21210]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Mar 21 09:19:00 schmaspberry input-remapper-service[21210]: File "/usr/lib/python3/dist-packages/inputremapper/injection/injector.py", line 361, in _create_forwarding_device Mar 21 09:19:00 schmaspberry input-remapper-service[21210]: forward_to = evdev.UInput( Mar 21 09:19:00 schmaspberry input-remapper-service[21210]: ^^^^^^^^^^^^^ Mar 21 09:19:00 schmaspberry input-remapper-service[21210]: File "/usr/lib/python3/dist-packages/evdev/uinput.py", line 155, in init Mar 21 09:19:00 schmaspberry input-remapper-service[21210]: self.device = self._find_device() Mar 21 09:19:00 schmaspberry input-remapper-service[21210]: ^^^^^^^^^^^^^^^^^^^ Mar 21 09:19:00 schmaspberry input-remapper-service[21210]: File "/usr/lib/python3/dist-packages/evdev/uinput.py", line 282, in _find_device Mar 21 09:19:00 schmaspberry input-remapper-service[21210]: d = device.InputDevice(path) Mar 21 09:19:00 schmaspberry input-remapper-service[21210]: ^^^^^^^^^^^^^^^^^^^^^^^^ Mar 21 09:19:00 schmaspberry input-remapper-service[21210]: File "/usr/lib/python3/dist-packages/evdev/device.py", line 127, in init

Testing the setup

  1. input-remapper-control --command hello

❯ input-remapper-control --command hello Connected to the service Daemon answered with "hello" Done

  1. sudo pkill -f input-remapper-service && sudo input-remapper-service -d & sleep 2 && input-remapper-control --command autoload, are your keys mapped now?

Yes

  1. (while the previous command is still running) sudo evtest and search for a device suffixed by "mapped". Select it, does it report any events? Share the output.

Command does not seem to terminate after 10 minutes

No device specified, trying to scan all of /dev/input/event* Not running as root, no devices may be available. Available devices: /dev/input/event0: pwr_button /dev/input/event1: vc4-hdmi-0 /dev/input/event2: vc4-hdmi-0 HDMI Jack /dev/input/event3: vc4-hdmi-1 /dev/input/event4: vc4-hdmi-1 HDMI Jack /dev/input/event5: 8BitDo Micro gamepad /dev/input/event6: input-remapper mouse /dev/input/event7: input-remapper keyboard /dev/input/event8: input-remapper 8BitDo Micro gamepad forwarded Select the device event number [0-8]: 8 Input driver version is 1.0.1 Input device ID: bus 0x5 vendor 0x2dc8 product 0x9020 version 0x100 Input device name: "input-remapper 8BitDo Micro gamepad forwarded" Supported events: Event type 0 (EV_SYN) Event type 1 (EV_KEY) Event code 304 (BTN_SOUTH) Event code 305 (BTN_EAST) Event code 306 (BTN_C) Event code 307 (BTN_NORTH) Event code 308 (BTN_WEST) Event code 309 (BTN_Z) Event code 310 (BTN_TL) Event code 311 (BTN_TR) Event code 312 (BTN_TL2) Event code 313 (BTN_TR2) Event code 314 (BTN_SELECT) Event code 315 (BTN_START) Event code 316 (BTN_MODE) Event code 317 (BTN_THUMBL) Event code 318 (BTN_THUMBR) Event code 319 (?) Event code 704 (BTN_TRIGGER_HAPPY1) Event code 705 (BTN_TRIGGER_HAPPY2) Event code 706 (BTN_TRIGGER_HAPPY3) Event code 707 (BTN_TRIGGER_HAPPY4) Event type 3 (EV_ABS) Event code 0 (ABS_X) Value 127 Min 0 Max 255 Flat 15 Event code 1 (ABS_Y) Value 127 Min 0 Max 255 Flat 15 Event code 2 (ABS_Z) Value 127 Min 0 Max 255 Flat 15 Event code 5 (ABS_RZ) Value 127 Min 0 Max 255 Flat 15 Resolution 57 Event code 9 (ABS_GAS) Value 0 Min 0 Max 255 Flat 15 Event code 10 (ABS_BRAKE) Value 0 Min 0 Max 255 Flat 15 Event code 16 (ABS_HAT0X) Value 0 Min -1 Max 1 Event code 17 (ABS_HAT0Y) Value 0 Min -1 Max 1 Event type 4 (EV_MSC) Event code 4 (MSC_SCAN) Event type 21 (EV_FF) Properties: Testing ... (interrupt to exit)

  1. sudo udevadm control --log-priority=debug && sudo udevadm control --reload-rules && journalctl -f | grep input-remapper, now plug in the device that should autoload

❯ sudo udevadm control --log-priority=debug && sudo udevadm control --reload-rules && journalctl -f | grep input-remapper Mar 21 09:26:56 schmaspberry systemd-udevd[335]: Reading rules file: /usr/lib/udev/rules.d/99-input-remapper.rules Mar 21 09:27:21 schmaspberry systemd-udevd[335]: Reading rules file: /usr/lib/udev/rules.d/99-input-remapper.rules Mar 21 09:27:29 schmaspberry systemd-udevd[335]: Reading rules file: /usr/lib/udev/rules.d/99-input-remapper.rules Mar 21 09:27:29 schmaspberry (udev-worker)[23034]: input16: /usr/lib/udev/rules.d/99-input-remapper.rules:10 RUN '/bin/input-remapper-control --command autoload --device $env{DEVNAME}' Mar 21 09:27:29 schmaspberry (udev-worker)[23034]: input16: Running command "/bin/input-remapper-control --command autoload --device " Mar 21 09:27:29 schmaspberry (udev-worker)[23034]: input16: Starting '/bin/input-remapper-control --command autoload --device ' Mar 21 09:27:29 schmaspberry (udev-worker)[23034]: input16: '/bin/input-remapper-control --command autoload --device '(err) 'usage: input-remapper-control [-h] [--command NAME] [--config-dir PATH]' Mar 21 09:27:29 schmaspberry (udev-worker)[23034]: input16: '/bin/input-remapper-control --command autoload --device '(err) ' [--preset NAME] [--device NAME] [--list-devices]' Mar 21 09:27:29 schmaspberry (udev-worker)[23034]: input16: '/bin/input-remapper-control --command autoload --device '(err) ' [--symbol-names] [-d] [-v]' Mar 21 09:27:29 schmaspberry (udev-worker)[23034]: input16: '/bin/input-remapper-control --command autoload --device '(err) 'input-remapper-control: error: argument --device: expected one argument' Mar 21 09:27:30 schmaspberry (udev-worker)[23034]: input16: Process '/bin/input-remapper-control --command autoload --device ' failed with exit code 2. Mar 21 09:27:30 schmaspberry (udev-worker)[23034]: input16: Command "/bin/input-remapper-control --command autoload --device " returned 2 (error), ignoring. Mar 21 09:27:30 schmaspberry (udev-worker)[23034]: js0: /usr/lib/udev/rules.d/99-input-remapper.rules:10 RUN '/bin/input-remapper-control --command autoload --device $env{DEVNAME}' Mar 21 09:27:30 schmaspberry (udev-worker)[23036]: event5: /usr/lib/udev/rules.d/99-input-remapper.rules:10 RUN '/bin/input-remapper-control --command autoload --device $env{DEVNAME}' Mar 21 09:27:30 schmaspberry (udev-worker)[23034]: js0: Running command "/bin/input-remapper-control --command autoload --device /dev/input/js0" Mar 21 09:27:30 schmaspberry (udev-worker)[23034]: js0: Starting '/bin/input-remapper-control --command autoload --device /dev/input/js0' Mar 21 09:27:30 schmaspberry (udev-worker)[23036]: event5: Running command "/bin/input-remapper-control --command autoload --device /dev/input/event5" Mar 21 09:27:30 schmaspberry (udev-worker)[23036]: event5: Starting '/bin/input-remapper-control --command autoload --device /dev/input/event5' Mar 21 09:27:30 schmaspberry (udev-worker)[23034]: js0: '/bin/input-remapper-control --command autoload --device /dev/input/js0'(err) 'Connected to the service' Mar 21 09:27:30 schmaspberry (udev-worker)[23036]: event5: '/bin/input-remapper-control --command autoload --device /dev/input/event5'(err) 'Connected to the service' Mar 21 09:27:30 schmaspberry (udev-worker)[23034]: js0: '/bin/input-remapper-control --command autoload --device /dev/input/js0'(err) 'Found "pwr_button", "vc4-hdmi-0", "vc4-hdmi-1", "input-remapper mouse", "input-remapper 8BitDo Micro gamepad forwarded", "8BitDo Micro gamepad"' Mar 21 09:27:30 schmaspberry (udev-worker)[23034]: js0: '/bin/input-remapper-control --command autoload --device /dev/input/js0'(err) 'ERROR: Device "/dev/input/js0" is unknown or not an appropriate input device' Mar 21 09:27:30 schmaspberry (udev-worker)[23036]: event5: '/bin/input-remapper-control --command autoload --device /dev/input/event5'(err) 'Found "pwr_button", "vc4-hdmi-0", "vc4-hdmi-1", "input-remappe mouse", "input-remapper 8BitDo Micro gamepad forwarded", "8BitDo Micro gamepad"' Mar 21 09:27:30 schmaspberry (udev-worker)[23036]: event5: '/bin/input-remapper-control --command autoload --device /dev/input/event5'(err) 'Asking daemon to autoload for /dev/input/event5' Mar 21 09:27:30 schmaspberry (udev-worker)[23034]: js0: Process '/bin/input-remapper-control --command autoload --device /dev/input/js0' failed with exit code 4. Mar 21 09:27:30 schmaspberry (udev-worker)[23034]: js0: Command "/bin/input-remapper-control --command autoload --device /dev/input/js0" returned 4 (error), ignoring. Mar 21 09:27:30 schmaspberry (udev-worker)[23036]: event5: '/bin/input-remapper-control --command autoload --device /dev/input/event5'(err) 'Done' Mar 21 09:27:30 schmaspberry (udev-worker)[23034]: input17: /usr/lib/udev/rules.d/99-input-remapper.rules:10 RUN '/bin/input-remapper-control --command autoload --device $env{DEVNAME}' Mar 21 09:27:30 schmaspberry kernel: input: input-remapper 8BitDo Micro gamepad forwarded as /devices/virtual/input/input17 Mar 21 09:27:30 schmaspberry (udev-worker)[23034]: input17: Running command "/bin/input-remapper-control --command autoload --device " Mar 21 09:27:30 schmaspberry (udev-worker)[23034]: input17: Starting '/bin/input-remapper-control --command autoload --device ' Mar 21 09:27:31 schmaspberry (udev-worker)[23036]: event5: Process '/bin/input-remapper-control --command autoload --device /dev/input/event5' succeeded. Mar 21 09:27:31 schmaspberry (udev-worker)[23034]: input17: '/bin/input-remapper-control --command autoload --device '(err) 'usage: input-remapper-control [-h] [--command NAME] [--config-dir PATH]' Mar 21 09:27:31 schmaspberry (udev-worker)[23034]: input17: '/bin/input-remapper-control --command autoload --device '(err) ' [--preset NAME] [--device NAME] [--list-devices]' Mar 21 09:27:31 schmaspberry (udev-worker)[23034]: input17: '/bin/input-remapper-control --command autoload --device '(err) ' [--symbol-names] [-d] [-v]' Mar 21 09:27:31 schmaspberry (udev-worker)[23034]: input17: '/bin/input-remapper-control --command autoload --device '(err) 'input-remapper-control: error: argument --device: expected one argument' Mar 21 09:27:31 schmaspberry (udev-worker)[23034]: input17: Process '/bin/input-remapper-control --command autoload --device ' failed with exit code 2. Mar 21 09:27:31 schmaspberry (udev-worker)[23034]: input17: Command "/bin/input-remapper-control --command autoload --device " returned 2 (error), ignoring. Mar 21 09:27:31 schmaspberry (udev-worker)[23034]: js2: /usr/lib/udev/rules.d/99-input-remapper.rules:10 RUN '/bin/input-remapper-control --command autoload --device $env{DEVNAME}' Mar 21 09:27:31 schmaspberry (udev-worker)[23034]: js2: Running command "/bin/input-remapper-control --command autoload --device /dev/input/js2" Mar 21 09:27:31 schmaspberry (udev-worker)[23034]: js2: Starting '/bin/input-remapper-control --command autoload --device /dev/input/js2' Mar 21 09:27:31 schmaspberry (udev-worker)[23036]: event9: /usr/lib/udev/rules.d/99-input-remapper.rules:10 RUN '/bin/input-remapper-control --command autoload --device $env{DEVNAME}' Mar 21 09:27:31 schmaspberry (udev-worker)[23036]: event9: Running command "/bin/input-remapper-control --command autoload --device /dev/input/event9" Mar 21 09:27:31 schmaspberry (udev-worker)[23036]: event9: Starting '/bin/input-remapper-control --command autoload --device /dev/input/event9' Mar 21 09:27:31 schmaspberry (udev-worker)[23034]: js2: '/bin/input-remapper-control --command autoload --device /dev/input/js2'(err) 'Connected to the service' Mar 21 09:27:31 schmaspberry (udev-worker)[23036]: event9: '/bin/input-remapper-control --command autoload --device /dev/input/event9'(err) 'Connected to the service' Mar 21 09:27:31 schmaspberry (udev-worker)[23036]: event9: '/bin/input-remapper-control --command autoload --device /dev/input/event9'(err) 'Found "pwr_button", "vc4-hdmi-0", "vc4-hdmi-1", "input-remappe mouse", "8BitDo Micro gamepad"' Mar 21 09:27:31 schmaspberry (udev-worker)[23034]: js2: '/bin/input-remapper-control --command autoload --device /dev/input/js2'(err) 'Found "pwr_button", "vc4-hdmi-0", "vc4-hdmi-1", "input-remapper mouse", "8BitDo Micro gamepad"' Mar 21 09:27:31 schmaspberry (udev-worker)[23034]: js2: '/bin/input-remapper-control --command autoload --device /dev/input/js2'(err) 'ERROR: Device "/dev/input/js2" is unknown or not an appropriate input device' Mar 21 09:27:31 schmaspberry (udev-worker)[23036]: event9: '/bin/input-remapper-control --command autoload --device /dev/input/event9'(err) 'ERROR: Device "/dev/input/event9" is unknown or not an appropriate input device' Mar 21 09:27:32 schmaspberry (udev-worker)[23036]: event9: Process '/bin/input-remapper-control --command autoload --device /dev/input/event9' failed with exit code 4. Mar 21 09:27:32 schmaspberry (udev-worker)[23036]: event9: Command "/bin/input-remapper-control --command autoload --device /dev/input/event9" returned 4 (error), ignoring. Mar 21 09:27:32 schmaspberry (udev-worker)[23034]: js2: Process '/bin/input-remapper-control --command autoload --device /dev/input/js2' failed with exit code 4. Mar 21 09:27:32 schmaspberry (udev-worker)[23034]: js2: Command "/bin/input-remapper-control --command autoload --device /dev/input/js2" returned 4 (error), ignoring.

christopherseaman commented 7 months ago

This is definitely not the Right Way (tm) to do this, but it works for my use case with a single bluetooth device being remapped and input-remapper sometimes failing on reconnect. If you have multiple devices being remapped, this will cause an interruption whenever a device disconnects. Also, it's quite hacky as I didn't spend a lot of time learning the codebase ¯\_(ツ)_/¯

I updated inputremapper/injection/event_reader.py to send stop_all and autoload commands to the daemon upon device disconnect. Here's the diff with added lines identified with +'s, surrounding lines (without "+") are provided for context:

# Added lines for inputremapper/injection/event_reader.py

# ---------------- import daemon methods ----------------
from inputremapper.input_event import InputEvent
from inputremapper.logger import logger

+# Load daemon methods to send commands upon device disconnect
+import inputremapper.daemon as ir_daemon
+

class Context(Protocol):

# ---------------- send `stop_all` and `autoload` to daemon ----------------
                loop.remove_reader(self._source.fileno())
                logger.debug("read loop stopped")
+                # Connect to daemon and send "stop_all" and "autoload" commands
+                daemon = ir_daemon.Daemon.connect()
+                await daemon.send_stop_all()
+                await daemon.send_autoload()
                return

            events_ready.clear()

Modified event_reader.py attached, had to rename to event_reader.py.txt because GH restricts attachment file types.