houmain / keymapper

A cross-platform context-aware key remapper.
GNU General Public License v3.0
286 stars 24 forks source link

ThinkPad Compact Bluetooth Keyboard gets ignored #163

Closed ristomatti closed 1 month ago

ristomatti commented 1 month ago

I got the idea to do some remaps with my ThinkPad Bluetooth keyboard I use on my media center. It doesn't seem to get grabbed with the config at the end.

I thought I'd try if I can grab it using device-id based context, but this keyboard doesn't get symlinked under /dev/input/by-path.

It does not appear under /dev/input/by-path either, which I guess is currently not supported based on the below line. It only shows up as /dev/input/eventXXX. https://github.com/houmain/keymapper/blob/add223047a141c03e7b20b315167ee8eb25a4185/src/server/unix/GrabbedDevicesLinux.cpp#L87

My laptop's integrated keyboard /dev/event3 does not show up under /dev/input/by-id either but it still gets grabbed. It also does get symlinked as /dev/input/by-path/platform-i8042-serio-0-event-kbd.

I'm guessing this could be worked around with a custom udev rule but I didn't try yet. Any idea if this can be fixed or should I just go ahead and try that?

keymapper.conf

[device = "ThinkPad Compact Bluetooth Keyboard with TrackPoint"]
  F1 >> F 1  # does not trigger

[default]
  F1 >> F 1  # does not trigger

keymapperd output

$ sudo keymapperd -v | grep ThinkPad
  /dev/input/event260 ignored (ThinkPad Compact Bluetooth Keyboard with TrackPoint)
  /dev/input/event22 grabbed (ThinkPad Extra Buttons)
  /dev/input/event260 ignored (ThinkPad Compact Bluetooth Keyboard with TrackPoint)
  /dev/input/event22 already grabbed (ThinkPad Extra Buttons)

udev info

$ udevadm info --attribute-walk --name=/dev/input/event260

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/pci0000:00/0000:00:14.0/usb1/1-14/1-14:1.0/bluetooth/hci0/hci0:256/0005:17EF:6048.0030/input/input99/event260':
    KERNEL=="event260"
    SUBSYSTEM=="input"
    DRIVER==""

  looking at parent device '/devices/pci0000:00/0000:00:14.0/usb1/1-14/1-14:1.0/bluetooth/hci0/hci0:256/0005:17EF:6048.0030/input/input99':
    KERNELS=="input99"
    SUBSYSTEMS=="input"
    DRIVERS==""
    ATTRS{inhibited}=="0"
    ATTRS{properties}=="21"
    ATTRS{name}=="ThinkPad Compact Bluetooth Keyboard with TrackPoint"
    ATTRS{phys}=="fc:44:82:de:12:86"
    ATTRS{uniq}=="90:7f:61:00:8a:27"

  looking at parent device '/devices/pci0000:00/0000:00:14.0/usb1/1-14/1-14:1.0/bluetooth/hci0/hci0:256/0005:17EF:6048.0030':
    KERNELS=="0005:17EF:6048.0030"
    SUBSYSTEMS=="hid"
    DRIVERS=="lenovo"
    ATTRS{middleclick_workaround}=="1"
    ATTRS{country}=="21"
    ATTRS{fn_lock}=="1"
    ATTRS{sensitivity}=="5"

  looking at parent device '/devices/pci0000:00/0000:00:14.0/usb1/1-14/1-14:1.0/bluetooth/hci0/hci0:256':
    KERNELS=="hci0:256"
    SUBSYSTEMS=="bluetooth"
    DRIVERS==""

  looking at parent device '/devices/pci0000:00/0000:00:14.0/usb1/1-14/1-14:1.0/bluetooth/hci0':
    KERNELS=="hci0"
    SUBSYSTEMS=="bluetooth"
    DRIVERS==""

  looking at parent device '/devices/pci0000:00/0000:00:14.0/usb1/1-14/1-14:1.0':
    KERNELS=="1-14:1.0"
    SUBSYSTEMS=="usb"
    DRIVERS=="btusb"
    ATTRS{bInterfaceProtocol}=="01"
    ATTRS{bAlternateSetting}==" 0"
    ATTRS{bInterfaceClass}=="e0"
    ATTRS{bInterfaceSubClass}=="01"
    ATTRS{supports_autosuspend}=="1"
    ATTRS{bNumEndpoints}=="03"
    ATTRS{bInterfaceNumber}=="00"
    ATTRS{authorized}=="1"

  looking at parent device '/devices/pci0000:00/0000:00:14.0/usb1/1-14':
    KERNELS=="1-14"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{devnum}=="5"
    ATTRS{bcdDevice}=="0002"
    ATTRS{authorized}=="1"
    ATTRS{bmAttributes}=="e0"
    ATTRS{urbnum}=="4264877"
    ATTRS{idProduct}=="0026"
    ATTRS{avoid_reset_quirk}=="0"
    ATTRS{idVendor}=="8087"
    ATTRS{rx_lanes}=="1"
    ATTRS{ltm_capable}=="no"
    ATTRS{tx_lanes}=="1"
    ATTRS{bDeviceProtocol}=="01"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{bDeviceSubClass}=="01"
    ATTRS{speed}=="12"
    ATTRS{bNumInterfaces}==" 2"
    ATTRS{bMaxPower}=="100mA"
    ATTRS{configuration}==""
    ATTRS{bMaxPacketSize0}=="64"
    ATTRS{maxchild}=="0"
    ATTRS{removable}=="fixed"
    ATTRS{bDeviceClass}=="e0"
    ATTRS{devpath}=="14"
    ATTRS{busnum}=="1"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{version}==" 2.01"
    ATTRS{quirks}=="0x0"

  looking at parent device '/devices/pci0000:00/0000:00:14.0/usb1':
    KERNELS=="usb1"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{speed}=="480"
    ATTRS{bDeviceProtocol}=="01"
    ATTRS{rx_lanes}=="1"
    ATTRS{avoid_reset_quirk}=="0"
    ATTRS{bmAttributes}=="e0"
    ATTRS{product}=="xHCI Host Controller"
    ATTRS{busnum}=="1"
    ATTRS{tx_lanes}=="1"
    ATTRS{manufacturer}=="Linux 5.15.0-113-generic xhci-hcd"
    ATTRS{idProduct}=="0002"
    ATTRS{authorized}=="1"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{ltm_capable}=="no"
    ATTRS{bDeviceClass}=="09"
    ATTRS{idVendor}=="1d6b"
    ATTRS{devpath}=="0"
    ATTRS{removable}=="unknown"
    ATTRS{authorized_default}=="1"
    ATTRS{bMaxPacketSize0}=="64"
    ATTRS{bMaxPower}=="0mA"
    ATTRS{maxchild}=="16"
    ATTRS{bNumInterfaces}==" 1"
    ATTRS{devnum}=="1"
    ATTRS{bcdDevice}=="0515"
    ATTRS{version}==" 2.00"
    ATTRS{configuration}==""
    ATTRS{bConfigurationValue}=="1"
    ATTRS{serial}=="0000:00:14.0"
    ATTRS{quirks}=="0x0"
    ATTRS{urbnum}=="401"
    ATTRS{interface_authorized_default}=="1"

  looking at parent device '/devices/pci0000:00/0000:00:14.0':
    KERNELS=="0000:00:14.0"
    SUBSYSTEMS=="pci"
    DRIVERS=="xhci_hcd"
    ATTRS{dbc}=="disabled"
    ATTRS{class}=="0x0c0330"
    ATTRS{numa_node}=="-1"
    ATTRS{driver_override}=="(null)"
    ATTRS{enable}=="1"
    ATTRS{device}=="0x06ed"
    ATTRS{local_cpus}=="ffff"
    ATTRS{consistent_dma_mask_bits}=="64"
    ATTRS{d3cold_allowed}=="1"
    ATTRS{subsystem_device}=="0x22c0"
    ATTRS{power_state}=="D0"
    ATTRS{subsystem_vendor}=="0x17aa"
    ATTRS{revision}=="0x00"
    ATTRS{ari_enabled}=="0"
    ATTRS{local_cpulist}=="0-15"
    ATTRS{dma_mask_bits}=="64"
    ATTRS{vendor}=="0x8086"
    ATTRS{broken_parity_status}=="0"
    ATTRS{irq}=="141"
    ATTRS{msi_bus}=="1"

  looking at parent device '/devices/pci0000:00':
    KERNELS=="pci0000:00"
    SUBSYSTEMS==""
    DRIVERS==""
    ATTRS{waiting_for_supplier}=="0"
houmain commented 1 month ago

Hi, thanks for reporting.

/dev/input/event260 ignored (ThinkPad Compact Bluetooth Keyboard with TrackPoint)

Is this a keyboard with mouse axes? This looks more to me like being a victim of 23f427f0b5e0b0902e22fa352bb7b921a77a0877. This was added because mice with keys were grabbed unintendendly (#152). I will improve the detection to also consider the number of keys.

I still need to add the directives for explicitly grabbing/skipping devices.

ristomatti commented 1 month ago

Ah, that seems like a very likely reason. It's got the red TrackPoint mouse knob and buttons.

Explicit exclusion/inclusion rules would be a good idea.

  1. Have you given any thought on what the syntax would look like? It could an opportunity to relocate the config under $XDG_CONFIG_HOME/keymapper/keymapper.conf (~/.config/keymapper/keymapper.conf)? It would allow configuring the matchers in separate files to avoid cluttering the config (especially with exclusions rules)

  2. Or would it need to be system level config (e.g. for keymapperd) and therefore under /etc?

houmain commented 1 month ago

Hi, this is fixed now in 4.5.0. Also directives can be added now directly in the configuration file to exclude/include devices. FYI there is also an @include directive.

ristomatti commented 1 month ago

Promising release! However, this ThinkPad keyboard seems to be stubborn. I'm not sure if you meant it should now be handled even without or by using the new @grab-device directive. Either way, it's still skipped. In fact, neither of the directives seem to have any effect even on devices that otherwise do work.

Connected devices:

$ xinput list
⎡ Virtual core pointer                      id=2    [master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer                id=4    [slave  pointer  (2)]
⎜   ↳ SINO WEALTH Gaming KB  Consumer Control   id=10   [slave  pointer  (2)]
⎜   ↳ SINO WEALTH Gaming KB  Mouse              id=12   [slave  pointer  (2)]
⎜   ↳ Logitech USB Receiver                     id=14   [slave  pointer  (2)]
⎜   ↳ Logitech USB Receiver Keyboard            id=15   [slave  pointer  (2)]
⎜   ↳ SynPS/2 Synaptics TouchPad                id=29   [slave  pointer  (2)]
⎜   ↳ TPPS/2 Elan TrackPoint                    id=30   [slave  pointer  (2)]
⎜   ↳ Logitech USB Trackball                    id=25   [slave  pointer  (2)]
⎜   ↳ Logitech MX Anywhere 2S                   id=26   [slave  pointer  (2)]
⎜   ↳ Generic Blue Microphones Consumer Control id=34   [slave  pointer  (2)]
⎜   ↳ Keychron Keychron K15 Pro Consumer Control    id=19   [slave  pointer  (2)]
⎜   ↳ Keychron Keychron K15 Pro Mouse           id=23   [slave  pointer  (2)]
⎜   ↳ ThinkPad Compact Bluetooth Keyboard with TrackPoint   id=39   [slave  pointer  (2)]
⎜   ↳ Keymapper                                 id=36   [slave  pointer  (2)]
⎣ Virtual core keyboard                     id=3    [master keyboard (2)]
    ↳ Virtual core XTEST keyboard               id=5    [slave  keyboard (3)]
    ↳ Power Button                              id=6    [slave  keyboard (3)]
    ↳ Video Bus                                 id=7    [slave  keyboard (3)]
    ↳ Sleep Button                              id=8    [slave  keyboard (3)]
    ↳ SINO WEALTH Gaming KB                     id=9    [slave  keyboard (3)]
    ↳ SINO WEALTH Gaming KB  Keyboard           id=11   [slave  keyboard (3)]
    ↳ SINO WEALTH Gaming KB  System Control     id=13   [slave  keyboard (3)]
    ↳ Integrated Camera: Integrated C           id=16   [slave  keyboard (3)]
    ↳ Integrated Camera: Integrated I           id=17   [slave  keyboard (3)]
    ↳ AT Translated Set 2 keyboard              id=28   [slave  keyboard (3)]
    ↳ ThinkPad Extra Buttons                    id=31   [slave  keyboard (3)]
    ↳ SINO WEALTH Gaming KB  Consumer Control   id=32   [slave  keyboard (3)]
    ↳ Logitech USB Receiver Keyboard            id=33   [slave  keyboard (3)]
    ↳ Logitech Webcam C925e                     id=24   [slave  keyboard (3)]
    ↳ Logitech MX Anywhere 2S                   id=27   [slave  keyboard (3)]
    ↳ Generic Blue Microphones Consumer Control id=35   [slave  keyboard (3)]
    ↳ Generic Blue Microphones                  id=38   [slave  keyboard (3)]
    ↳ Keychron Keychron K15 Pro System Control  id=18   [slave  keyboard (3)]
    ↳ Keychron Keychron K15 Pro Consumer Control    id=20   [slave  keyboard (3)]
    ↳ Keychron Keychron K15 Pro                 id=21   [slave  keyboard (3)]
    ↳ Keychron Keychron K15 Pro Keyboard        id=22   [slave  keyboard (3)]
    ↳ ThinkPad Compact Bluetooth Keyboard with TrackPoint   id=40   [slave  keyboard (3)]
    ↳ Keymapper                                 id=37   [slave  keyboard (3)]

Test config:

@skip-device /.*/
@grab-device "ThinkPad Compact Bluetooth Keyboard with TrackPoint"

ArrowUp >> ArrowDown
ArrowDown >> ArrowUp

Output from keymapperd:

Waiting for keymapper to connect
Resetting configuration
Evaluating device filters
Active contexts received (39)
Updating device list
  /dev/input/event260 skipped (ThinkPad Compact Bluetooth Keyboard with TrackPoint)
  /dev/input/event18 grabbed (Keychron Keychron K15 Pro Keyboard)
  /dev/input/event17 grabbed (Keychron Keychron K15 Pro Consumer Control)
  /dev/input/event16 grabbed (Keychron Keychron K15 Pro System Control)
  /dev/input/event15 grabbed (Keychron Keychron K15 Pro Mouse)
  /dev/input/event14 grabbed (Keychron Keychron K15 Pro)
  /dev/input/event259 grabbed (Generic Blue Microphones)
  /dev/input/event25 grabbed (Generic Blue Microphones Consumer Control)
  /dev/input/event19 grabbed (Logitech MX Anywhere 2S)
  /dev/input/event21 grabbed (Logitech USB Trackball)
  /dev/input/event20 grabbed (Logitech Webcam C925e)
  /dev/input/event257 grabbed (Integrated Camera: Integrated I)
  /dev/input/event256 grabbed (Integrated Camera: Integrated C)
  /dev/input/event31 ignored (sof-hda-dsp Headphone)
  /dev/input/event30 ignored (sof-hda-dsp Mic)
  /dev/input/event29 ignored (HDA NVidia HDMI/DP,pcm=11)
  /dev/input/event28 ignored (HDA NVidia HDMI/DP,pcm=10)
  /dev/input/event27 ignored (HDA NVidia HDMI/DP,pcm=9)
  /dev/input/event26 ignored (HDA NVidia HDMI/DP,pcm=8)
  /dev/input/event24 ignored (HDA NVidia HDMI/DP,pcm=7)
  /dev/input/event23 ignored (HDA NVidia HDMI/DP,pcm=3)
  /dev/input/event22 grabbed (ThinkPad Extra Buttons)
  /dev/input/event13 grabbed (TPPS/2 Elan TrackPoint)
  /dev/input/event12 grabbed (Logitech USB Receiver Keyboard)
  /dev/input/event11 grabbed (Logitech USB Receiver)
  /dev/input/event10 grabbed (SINO WEALTH Gaming KB  Mouse)
  /dev/input/event9 grabbed (SINO WEALTH Gaming KB  Keyboard)
  /dev/input/event8 grabbed (SINO WEALTH Gaming KB  Consumer Control)
  /dev/input/event7 grabbed (SINO WEALTH Gaming KB  System Control)
  /dev/input/event6 grabbed (SINO WEALTH Gaming KB )
  /dev/input/event5 skipped (SynPS/2 Synaptics TouchPad)
  /dev/input/event4 grabbed (Video Bus)
  /dev/input/event3 grabbed (AT Translated Set 2 keyboard)
  /dev/input/event2 grabbed (Power Button)
  /dev/input/event1 ignored (Lid Switch)
  /dev/input/event0 grabbed (Sleep Button)
Creating virtual device 'Keymapper'
Entering update loop
Updating device list
  /dev/input/event258 ignored (Keymapper)
  /dev/input/event260 skipped (ThinkPad Compact Bluetooth Keyboard with TrackPoint)
  /dev/input/event18 already grabbed (Keychron Keychron K15 Pro Keyboard)
  /dev/input/event17 already grabbed (Keychron Keychron K15 Pro Consumer Control)
  /dev/input/event16 already grabbed (Keychron Keychron K15 Pro System Control)
  /dev/input/event15 already grabbed (Keychron Keychron K15 Pro Mouse)
  /dev/input/event14 already grabbed (Keychron Keychron K15 Pro)
  /dev/input/event259 already grabbed (Generic Blue Microphones)
  /dev/input/event25 already grabbed (Generic Blue Microphones Consumer Control)
  /dev/input/event19 already grabbed (Logitech MX Anywhere 2S)
  /dev/input/event21 already grabbed (Logitech USB Trackball)
  /dev/input/event20 already grabbed (Logitech Webcam C925e)
  /dev/input/event257 already grabbed (Integrated Camera: Integrated I)
  /dev/input/event256 already grabbed (Integrated Camera: Integrated C)
  /dev/input/event31 ignored (sof-hda-dsp Headphone)
  /dev/input/event30 ignored (sof-hda-dsp Mic)
  /dev/input/event29 ignored (HDA NVidia HDMI/DP,pcm=11)
  /dev/input/event28 ignored (HDA NVidia HDMI/DP,pcm=10)
  /dev/input/event27 ignored (HDA NVidia HDMI/DP,pcm=9)
  /dev/input/event26 ignored (HDA NVidia HDMI/DP,pcm=8)
  /dev/input/event24 ignored (HDA NVidia HDMI/DP,pcm=7)
  /dev/input/event23 ignored (HDA NVidia HDMI/DP,pcm=3)
  /dev/input/event22 already grabbed (ThinkPad Extra Buttons)
  /dev/input/event13 already grabbed (TPPS/2 Elan TrackPoint)
  /dev/input/event12 already grabbed (Logitech USB Receiver Keyboard)
  /dev/input/event11 already grabbed (Logitech USB Receiver)
  /dev/input/event10 already grabbed (SINO WEALTH Gaming KB  Mouse)
  /dev/input/event9 already grabbed (SINO WEALTH Gaming KB  Keyboard)
  /dev/input/event8 already grabbed (SINO WEALTH Gaming KB  Consumer Control)
  /dev/input/event7 already grabbed (SINO WEALTH Gaming KB  System Control)
  /dev/input/event6 already grabbed (SINO WEALTH Gaming KB )
  /dev/input/event5 skipped (SynPS/2 Synaptics TouchPad)
  /dev/input/event4 already grabbed (Video Bus)
  /dev/input/event3 already grabbed (AT Translated Set 2 keyboard)
  /dev/input/event2 already grabbed (Power Button)
  /dev/input/event1 ignored (Lid Switch)
  /dev/input/event0 already grabbed (Sleep Button)
Evaluating device filters

I've yet to test @include, will do that tomorrow!

ristomatti commented 1 month ago

...and yes, I've double checked no old instances are running, the correct version is reported with both keymapperd --version and keymapper --version. The directive handling seems to be there as well, I first typed just @grab "..." and got the "unknown directive" errror.

ristomatti commented 1 month ago

I quickly tested @include as well. It seems to be a bit picky with the include path handling but otherwise it appears to work. :rocket:

I got failed to open with these:

@include "~/.config/keymapper/f-keys.conf"
@include "$HOME/.config/keymapper/f-keys.conf"
@include "./keymapper/f-keys.conf"  # relative to `keymapper.conf`

Absolute path and path relative to home directory it accepted:

@include "/home/ristomatti/.config/keymapper/f-keys.conf"
@include ".config/keymapper/f-keys.conf"
ristomatti commented 1 month ago

For completeness sake, I also checked the build output. No signs of missing libs this time:

$ mise run build 
[clean] $ rm -rf .cache .clangd ./build ./_CPack_Packages ./CMakeLists.txt.user
[configure] $ cmake -B ./build
-- The C compiler identification is GNU 9.4.0
-- The CXX compiler identification is GNU 9.4.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Git: /usr/bin/git (found version "2.45.2")
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.1")
-- Checking for module 'dbus-1'
--   Found dbus-1, version 1.12.16
-- Checking for module 'xkbcommon'
--   Found xkbcommon, version 0.10.0
-- Checking for module 'ayatana-appindicator3-0.1'
--   Found ayatana-appindicator3-0.1, version 0.5.4
-- Checking for module 'gtk+-3.0'
--   Found gtk+-3.0, version 3.24.20
-- Configuring done (0.4s)
-- Generating done (0.0s)
-- Build files have been written to: /home/ristomatti/src/keymapper/build
[build] $ cmake --build ./build --config Release
[  2%] Building CXX object CMakeFiles/keymapper.dir/src/client/ConfigFile.cpp.o
[  4%] Building CXX object CMakeFiles/keymapper.dir/src/client/Settings.cpp.o
[  6%] Building CXX object CMakeFiles/keymapper.dir/src/client/ServerPort.cpp.o
[  9%] Building CXX object CMakeFiles/keymapper.dir/src/client/ControlPort.cpp.o
[ 11%] Building CXX object CMakeFiles/keymapper.dir/src/client/ClientState.cpp.o
[ 13%] Building CXX object CMakeFiles/keymapper.dir/src/client/unix/FocusedWindowImpl.cpp.o
[ 16%] Building CXX object CMakeFiles/keymapper.dir/src/client/unix/FocusedWindowX11.cpp.o
[ 18%] Building CXX object CMakeFiles/keymapper.dir/src/client/unix/FocusedWindowWlroots.cpp.o
[ 20%] Building CXX object CMakeFiles/keymapper.dir/src/client/unix/FocusedWindowDBus.cpp.o
[ 23%] Building CXX object CMakeFiles/keymapper.dir/src/client/unix/TrayIcon.cpp.o
[ 25%] Building CXX object CMakeFiles/keymapper.dir/src/client/unix/TrayIconGtk.cpp.o
[ 27%] Building CXX object CMakeFiles/keymapper.dir/src/client/unix/StringTyperImpl.cpp.o
[ 30%] Building CXX object CMakeFiles/keymapper.dir/src/client/unix/StringTyperGeneric.cpp.o
[ 32%] Building CXX object CMakeFiles/keymapper.dir/src/client/unix/StringTyperWayland.cpp.o
[ 34%] Building CXX object CMakeFiles/keymapper.dir/src/client/unix/StringTyperX11.cpp.o
[ 37%] Building CXX object CMakeFiles/keymapper.dir/src/client/unix/main.cpp.o
[ 39%] Building CXX object CMakeFiles/keymapper.dir/src/common/Connection.cpp.o
[ 41%] Building CXX object CMakeFiles/keymapper.dir/src/common/Host.cpp.o
[ 44%] Building CXX object CMakeFiles/keymapper.dir/src/common/output.cpp.o
[ 46%] Building CXX object CMakeFiles/keymapper.dir/src/config/ParseConfig.cpp.o
[ 48%] Building CXX object CMakeFiles/keymapper.dir/src/config/ParseKeySequence.cpp.o
[ 51%] Building CXX object CMakeFiles/keymapper.dir/src/config/get_key_name.cpp.o
[ 53%] Linking CXX executable keymapper
[ 53%] Built target keymapper
[ 55%] Building CXX object CMakeFiles/keymapperd.dir/src/server/ClientPort.cpp.o
[ 58%] Building CXX object CMakeFiles/keymapperd.dir/src/server/Settings.cpp.o
[ 60%] Building CXX object CMakeFiles/keymapperd.dir/src/server/ServerState.cpp.o
[ 62%] Building CXX object CMakeFiles/keymapperd.dir/src/server/unix/GrabbedDevicesLinux.cpp.o
[ 65%] Building CXX object CMakeFiles/keymapperd.dir/src/server/unix/main.cpp.o
[ 67%] Building CXX object CMakeFiles/keymapperd.dir/src/server/unix/VirtualDeviceLinux.cpp.o
[ 69%] Building CXX object CMakeFiles/keymapperd.dir/src/common/Connection.cpp.o
[ 72%] Building CXX object CMakeFiles/keymapperd.dir/src/common/Host.cpp.o
[ 74%] Building CXX object CMakeFiles/keymapperd.dir/src/common/output.cpp.o
[ 76%] Building CXX object CMakeFiles/keymapperd.dir/src/runtime/MatchKeySequence.cpp.o
[ 79%] Building CXX object CMakeFiles/keymapperd.dir/src/runtime/Stage.cpp.o
[ 81%] Building CXX object CMakeFiles/keymapperd.dir/src/runtime/MultiStage.cpp.o
[ 83%] Linking CXX executable keymapperd
[ 83%] Built target keymapperd
[ 86%] Building CXX object CMakeFiles/keymapperctl.dir/src/control/ClientPort.cpp.o
[ 88%] Building CXX object CMakeFiles/keymapperctl.dir/src/control/Settings.cpp.o
[ 90%] Building CXX object CMakeFiles/keymapperctl.dir/src/control/main.cpp.o
[ 93%] Building CXX object CMakeFiles/keymapperctl.dir/src/common/Connection.cpp.o
[ 95%] Building CXX object CMakeFiles/keymapperctl.dir/src/common/Host.cpp.o
[ 97%] Building CXX object CMakeFiles/keymapperctl.dir/src/common/output.cpp.o
[100%] Linking CXX executable keymapperctl
[100%] Built target keymapperctl
houmain commented 1 month ago

Thank you very much for the quick and thorough testing!

I'm not sure if you meant it should now be handled even without or by using the new @grab-device directive.

Yes, it should be grabbed automatically again. Could you please post the device's evtest output.

Sorry!!! The last commit to fix the Ubuntu-20.04 build broke it. Even the unit test would have detected it... This is fixed now in 4.5.1.

I quickly tested @include as well. It seems to be a bit picky with the include path handling

I would not call not expanding variables like a shell picky, but this is also done now. :)

ristomatti commented 1 month ago

Happy to report, that did the trick! Now both @grab-device and @skip-device work flawlessly. @grab-device "ThinkPad Compact Bluetooth Keyboard with TrackPoint" now grabs it and the bindings work. Awesome work again!

It's also great to be able to filter out a bunch of obscure input devices that were automatically grabbed before. I've felt uncomfortable with Keymapper unnecessarily grabbing these:

I also noticed now that SynPS/2 Synaptics TouchPad got skipped. I'm don't know if it has anything that can be remapped but definitely might want to if it d

I would not call not expanding variables like a shell picky, but this is also done now. :)

That's a fair point. But since the README did not specify where it expects to find the files, I kind of would have expected expansion of ~ or $HOME to work as I was already using them within the config (e.g. $(echo foo >> ~/tmp/keymapper.log).

Now after reading your reply, I figured it was likely silly me just assuming there's already code for handling the expansion. With a bit of thought, was this just a side effect of internally handling $(foo) by callling e.g. /bin/sh -c 'foo' (in which case the shell does the expansion)?. :slightly_smiling_face:.

My suggestion (= wish) going forward would be to by default trying to resolve the paths based on $XDG_CONFIG_HOME/keymapper. This would allow neatly keeping them in a predefined place, while at the same time allowing short includes like @includealiases.conf,@include device/keyboard-xyx.conf, application/firefox.conf. If this resonates with you, it would make sense to also support putting keymapper.conf under the same path.

Could you please post the device's evtest output.

This output?

# evtest /dev/input/event260
Input driver version is 1.0.1
Input device ID: bus 0x5 vendor 0x17ef product 0x6048 version 0x312
Input device name: "ThinkPad Compact Bluetooth Keyboard with TrackPoint"
Supported events:
  Event type 0 (EV_SYN)
  Event type 1 (EV_KEY)
    Event code 1 (KEY_ESC)
    Event code 2 (KEY_1)
    Event code 3 (KEY_2)
    Event code 4 (KEY_3)
    Event code 5 (KEY_4)
    Event code 6 (KEY_5)
    Event code 7 (KEY_6)
    Event code 8 (KEY_7)
    Event code 9 (KEY_8)
    Event code 10 (KEY_9)
    Event code 11 (KEY_0)
    Event code 12 (KEY_MINUS)
    Event code 13 (KEY_EQUAL)
    Event code 14 (KEY_BACKSPACE)
    Event code 15 (KEY_TAB)
    Event code 16 (KEY_Q)
    Event code 17 (KEY_W)
    Event code 18 (KEY_E)
    Event code 19 (KEY_R)
    Event code 20 (KEY_T)
    Event code 21 (KEY_Y)
    Event code 22 (KEY_U)
    Event code 23 (KEY_I)
    Event code 24 (KEY_O)
    Event code 25 (KEY_P)
    Event code 26 (KEY_LEFTBRACE)
    Event code 27 (KEY_RIGHTBRACE)
    Event code 28 (KEY_ENTER)
    Event code 29 (KEY_LEFTCTRL)
    Event code 30 (KEY_A)
    Event code 31 (KEY_S)
    Event code 32 (KEY_D)
    Event code 33 (KEY_F)
    Event code 34 (KEY_G)
    Event code 35 (KEY_H)
    Event code 36 (KEY_J)
    Event code 37 (KEY_K)
    Event code 38 (KEY_L)
    Event code 39 (KEY_SEMICOLON)
    Event code 40 (KEY_APOSTROPHE)
    Event code 41 (KEY_GRAVE)
    Event code 42 (KEY_LEFTSHIFT)
    Event code 43 (KEY_BACKSLASH)
    Event code 44 (KEY_Z)
    Event code 45 (KEY_X)
    Event code 46 (KEY_C)
    Event code 47 (KEY_V)
    Event code 48 (KEY_B)
    Event code 49 (KEY_N)
    Event code 50 (KEY_M)
    Event code 51 (KEY_COMMA)
    Event code 52 (KEY_DOT)
    Event code 53 (KEY_SLASH)
    Event code 54 (KEY_RIGHTSHIFT)
    Event code 55 (KEY_KPASTERISK)
    Event code 56 (KEY_LEFTALT)
    Event code 57 (KEY_SPACE)
    Event code 58 (KEY_CAPSLOCK)
    Event code 59 (KEY_F1)
    Event code 60 (KEY_F2)
    Event code 61 (KEY_F3)
    Event code 62 (KEY_F4)
    Event code 63 (KEY_F5)
    Event code 64 (KEY_F6)
    Event code 65 (KEY_F7)
    Event code 66 (KEY_F8)
    Event code 67 (KEY_F9)
    Event code 68 (KEY_F10)
    Event code 69 (KEY_NUMLOCK)
    Event code 70 (KEY_SCROLLLOCK)
    Event code 71 (KEY_KP7)
    Event code 72 (KEY_KP8)
    Event code 73 (KEY_KP9)
    Event code 74 (KEY_KPMINUS)
    Event code 75 (KEY_KP4)
    Event code 76 (KEY_KP5)
    Event code 77 (KEY_KP6)
    Event code 78 (KEY_KPPLUS)
    Event code 79 (KEY_KP1)
    Event code 80 (KEY_KP2)
    Event code 81 (KEY_KP3)
    Event code 82 (KEY_KP0)
    Event code 83 (KEY_KPDOT)
    Event code 85 (KEY_ZENKAKUHANKAKU)
    Event code 86 (KEY_102ND)
    Event code 87 (KEY_F11)
    Event code 88 (KEY_F12)
    Event code 89 (KEY_RO)
    Event code 90 (KEY_KATAKANA)
    Event code 91 (KEY_HIRAGANA)
    Event code 92 (KEY_HENKAN)
    Event code 93 (KEY_KATAKANAHIRAGANA)
    Event code 94 (KEY_MUHENKAN)
    Event code 95 (KEY_KPJPCOMMA)
    Event code 96 (KEY_KPENTER)
    Event code 97 (KEY_RIGHTCTRL)
    Event code 98 (KEY_KPSLASH)
    Event code 99 (KEY_SYSRQ)
    Event code 100 (KEY_RIGHTALT)
    Event code 102 (KEY_HOME)
    Event code 103 (KEY_UP)
    Event code 104 (KEY_PAGEUP)
    Event code 105 (KEY_LEFT)
    Event code 106 (KEY_RIGHT)
    Event code 107 (KEY_END)
    Event code 108 (KEY_DOWN)
    Event code 109 (KEY_PAGEDOWN)
    Event code 110 (KEY_INSERT)
    Event code 111 (KEY_DELETE)
    Event code 113 (KEY_MUTE)
    Event code 114 (KEY_VOLUMEDOWN)
    Event code 115 (KEY_VOLUMEUP)
    Event code 116 (KEY_POWER)
    Event code 117 (KEY_KPEQUAL)
    Event code 119 (KEY_PAUSE)
    Event code 120 (KEY_SCALE)
    Event code 121 (KEY_KPCOMMA)
    Event code 122 (KEY_HANGUEL)
    Event code 123 (KEY_HANJA)
    Event code 124 (KEY_YEN)
    Event code 125 (KEY_LEFTMETA)
    Event code 126 (KEY_RIGHTMETA)
    Event code 127 (KEY_COMPOSE)
    Event code 128 (KEY_STOP)
    Event code 129 (KEY_AGAIN)
    Event code 130 (KEY_PROPS)
    Event code 131 (KEY_UNDO)
    Event code 132 (KEY_FRONT)
    Event code 133 (KEY_COPY)
    Event code 134 (KEY_OPEN)
    Event code 135 (KEY_PASTE)
    Event code 136 (KEY_FIND)
    Event code 137 (KEY_CUT)
    Event code 138 (KEY_HELP)
    Event code 139 (KEY_MENU)
    Event code 140 (KEY_CALC)
    Event code 142 (KEY_SLEEP)
    Event code 143 (KEY_WAKEUP)
    Event code 144 (KEY_FILE)
    Event code 148 (KEY_PROG1)
    Event code 150 (KEY_WWW)
    Event code 152 (KEY_SCREENLOCK)
    Event code 155 (KEY_MAIL)
    Event code 156 (KEY_BOOKMARKS)
    Event code 158 (KEY_BACK)
    Event code 159 (KEY_FORWARD)
    Event code 161 (KEY_EJECTCD)
    Event code 163 (KEY_NEXTSONG)
    Event code 164 (KEY_PLAYPAUSE)
    Event code 165 (KEY_PREVIOUSSONG)
    Event code 166 (KEY_STOPCD)
    Event code 167 (KEY_RECORD)
    Event code 168 (KEY_REWIND)
    Event code 169 (KEY_PHONE)
    Event code 171 (KEY_CONFIG)
    Event code 172 (KEY_HOMEPAGE)
    Event code 173 (KEY_REFRESH)
    Event code 174 (KEY_EXIT)
    Event code 176 (KEY_EDIT)
    Event code 177 (KEY_SCROLLUP)
    Event code 178 (KEY_SCROLLDOWN)
    Event code 179 (KEY_KPLEFTPAREN)
    Event code 180 (KEY_KPRIGHTPAREN)
    Event code 181 (KEY_NEW)
    Event code 182 (KEY_REDO)
    Event code 183 (KEY_F13)
    Event code 184 (KEY_F14)
    Event code 185 (KEY_F15)
    Event code 186 (KEY_F16)
    Event code 187 (KEY_F17)
    Event code 188 (KEY_F18)
    Event code 189 (KEY_F19)
    Event code 190 (KEY_F20)
    Event code 191 (KEY_F21)
    Event code 192 (KEY_F22)
    Event code 193 (KEY_F23)
    Event code 194 (KEY_F24)
    Event code 204 (KEY_DASHBOARD)
    Event code 206 (KEY_CLOSE)
    Event code 207 (KEY_PLAY)
    Event code 208 (KEY_FASTFORWARD)
    Event code 209 (KEY_BASSBOOST)
    Event code 210 (KEY_PRINT)
    Event code 212 (KEY_CAMERA)
    Event code 216 (KEY_CHAT)
    Event code 217 (KEY_SEARCH)
    Event code 219 (KEY_FINANCE)
    Event code 223 (KEY_CANCEL)
    Event code 224 (KEY_BRIGHTNESSDOWN)
    Event code 225 (KEY_BRIGHTNESSUP)
    Event code 227 (KEY_SWITCHVIDEOMODE)
    Event code 228 (KEY_KBDILLUMTOGGLE)
    Event code 229 (KEY_KBDILLUMDOWN)
    Event code 230 (KEY_KBDILLUMUP)
    Event code 231 (KEY_SEND)
    Event code 232 (KEY_REPLY)
    Event code 233 (KEY_FORWARDMAIL)
    Event code 234 (KEY_SAVE)
    Event code 235 (KEY_DOCUMENTS)
    Event code 238 (KEY_WLAN)
    Event code 240 (KEY_UNKNOWN)
    Event code 241 (KEY_VIDEO_NEXT)
    Event code 244 (KEY_BRIGHTNESS_ZERO)
    Event code 247 (KEY_RFKILL)
    Event code 248 (KEY_MICMUTE)
    Event code 256 (BTN_0)
    Event code 272 (BTN_LEFT)
    Event code 273 (BTN_RIGHT)
    Event code 274 (BTN_MIDDLE)
    Event code 314 (BTN_SELECT)
    Event code 315 (BTN_START)
    Event code 353 (KEY_SELECT)
    Event code 354 (KEY_GOTO)
    Event code 356 (KEY_POWER2)
    Event code 358 (KEY_INFO)
    Event code 362 (KEY_PROGRAM)
    Event code 366 (KEY_PVR)
    Event code 370 (KEY_SUBTITLE)
    Event code 372 (KEY_ZOOM)
    Event code 374 (KEY_KEYBOARD)
    Event code 375 (KEY_SCREEN)
    Event code 376 (KEY_PC)
    Event code 377 (KEY_TV)
    Event code 378 (KEY_TV2)
    Event code 379 (KEY_VCR)
    Event code 380 (KEY_VCR2)
    Event code 381 (KEY_SAT)
    Event code 383 (KEY_CD)
    Event code 384 (KEY_TAPE)
    Event code 386 (KEY_TUNER)
    Event code 387 (KEY_PLAYER)
    Event code 389 (KEY_DVD)
    Event code 392 (KEY_AUDIO)
    Event code 393 (KEY_VIDEO)
    Event code 396 (KEY_MEMO)
    Event code 397 (KEY_CALENDAR)
    Event code 398 (KEY_RED)
    Event code 399 (KEY_GREEN)
    Event code 400 (KEY_YELLOW)
    Event code 401 (KEY_BLUE)
    Event code 402 (KEY_CHANNELUP)
    Event code 403 (KEY_CHANNELDOWN)
    Event code 405 (KEY_LAST)
    Event code 407 (KEY_NEXT)
    Event code 408 (KEY_RESTART)
    Event code 409 (KEY_SLOW)
    Event code 410 (KEY_SHUFFLE)
    Event code 412 (KEY_PREVIOUS)
    Event code 416 (KEY_VIDEOPHONE)
    Event code 417 (KEY_GAMES)
    Event code 418 (KEY_ZOOMIN)
    Event code 419 (KEY_ZOOMOUT)
    Event code 420 (KEY_ZOOMRESET)
    Event code 421 (KEY_WORDPROCESSOR)
    Event code 422 (KEY_EDITOR)
    Event code 423 (KEY_SPREADSHEET)
    Event code 424 (KEY_GRAPHICSEDITOR)
    Event code 425 (KEY_PRESENTATION)
    Event code 426 (KEY_DATABASE)
    Event code 427 (KEY_NEWS)
    Event code 428 (KEY_VOICEMAIL)
    Event code 429 (KEY_ADDRESSBOOK)
    Event code 430 (KEY_MESSENGER)
    Event code 431 (KEY_DISPLAYTOGGLE)
    Event code 432 (KEY_SPELLCHECK)
    Event code 433 (KEY_LOGOFF)
    Event code 438 (KEY_CONTEXT_MENU)
    Event code 439 (KEY_MEDIA_REPEAT)
    Event code 442 (KEY_IMAGES)
    Event code 465 (KEY_FN_ESC)
    Event code 576 (KEY_BUTTONCONFIG)
    Event code 577 (KEY_TASKMANAGER)
    Event code 578 (KEY_JOURNAL)
    Event code 579 (KEY_CONTROLPANEL)
    Event code 580 (KEY_APPSELECT)
    Event code 581 (KEY_SCREENSAVER)
    Event code 582 (KEY_VOICECOMMAND)
    Event code 583 (KEY_ASSISTANT)
    Event code 584 (?)
    Event code 585 (?)
    Event code 586 (?)
    Event code 592 (KEY_BRIGHTNESS_MIN)
    Event code 593 (KEY_BRIGHTNESS_MAX)
    Event code 608 (KEY_KBDINPUTASSIST_PREV)
    Event code 609 (KEY_KBDINPUTASSIST_NEXT)
    Event code 610 (KEY_KBDINPUTASSIST_PREVGROUP)
    Event code 611 (KEY_KBDINPUTASSIST_NEXTGROUP)
    Event code 612 (KEY_KBDINPUTASSIST_ACCEPT)
    Event code 613 (KEY_KBDINPUTASSIST_CANCEL)
  Event type 2 (EV_REL)
    Event code 0 (REL_X)
    Event code 1 (REL_Y)
    Event code 6 (REL_HWHEEL)
    Event code 8 (REL_WHEEL)
    Event code 9 (REL_MISC)
  Event type 3 (EV_ABS)
    Event code 0 (ABS_X)
      Value      0
      Min        0
      Max      255
    Event code 1 (ABS_Y)
      Value      0
      Min        0
      Max      255
    Event code 2 (ABS_Z)
      Value      0
      Min        0
      Max      255
    Event code 3 (ABS_RX)
      Value      0
      Min        0
      Max      255
    Event code 4 (ABS_RY)
      Value      0
      Min        0
      Max      255
    Event code 5 (ABS_RZ)
      Value      0
      Min        0
      Max      255
    Event code 6 (ABS_THROTTLE)
      Value      0
      Min        0
      Max      255
    Event code 7 (ABS_RUDDER)
      Value      0
      Min        0
      Max      255
    Event code 16 (ABS_HAT0X)
      Value      0
      Min        0
      Max      255
    Event code 32 (ABS_VOLUME)
      Value      0
      Min        0
      Max     1023
    Event code 40 (ABS_MISC)
      Value      0
      Min        0
      Max      255
  Event type 4 (EV_MSC)
    Event code 4 (MSC_SCAN)
  Event type 17 (EV_LED)
    Event code 0 (LED_NUML) state 0
    Event code 1 (LED_CAPSL) state 0
    Event code 2 (LED_SCROLLL) state 0
    Event code 3 (LED_COMPOSE) state 0
    Event code 4 (LED_KANA) state 0
Key repeat handling:
  Repeat type 20 (EV_REP)
    Repeat code 0 (REP_DELAY)
      Value    250
    Repeat code 1 (REP_PERIOD)
      Value     33
Properties:
  Property type 0 (INPUT_PROP_POINTER)
  Property type 5 (INPUT_PROP_POINTING_STICK)

Next up: splitting up my config and thoroughly testing @include. :fire:

ristomatti commented 1 month ago

Hmm. interesting. While I was writing the last sentence, a slightly odd thing occurred. Suddenly my backspace went into repeat and deleted ~10 lines before stoppipng.

I looked at the log and this was apparently caused by a slight pause in accepting input due to Keymapper updating the device list. It in turn was causeed by the ThinkPad Bluetooth keyboard going into sleep mode.

I likely happened to hit backspace right at the time it occurred?

houmain commented 1 month ago

Now I got it. That was indeed picky. Now in 4.5.2 it is looking up the include files relative to the configuration file, not the working directory.

It is also looking for the keymapper.conf in the $HOME/.config/keymapper folder now. Yeah, I should also replace $HOME/.config with $XDG_CONFIG_HOME.

Oh, this device pretends to have sliders like a joystick, that's why it is not grabbed by default:

...
Event code 6 (ABS_THROTTLE)
      Value      0
      Min        0
      Max      255
    Event code 7 (ABS_RUDDER)
      Value      0
      Min        0
      Max      255
    Event code 16 (ABS_HAT0X)
      Value      0
      Min        0
      Max      255
...

I likely happened to hit backspace right at the time it occurred?

That is imaginable. I could not reproduce it.

ristomatti commented 1 month ago

Now I got it. That was indeed picky. Now in 4.5.2 it is looking up the include files relative to the configuration file, not the working directory.

Excellent timing! I didn't event yet start splitting up the config. Instead, I lost track of time while trying to figure out why Escape to exit Helix insert mode is frustratingly laggy, while it doesn't lag if I use any of the other keybindings I've configured in it's settings. Eventually I figured out most of the lag was due to some modifier mappings. Interestingly enough, it lagged even without Keymapper running... and the same thing in Vim. I just narrowed it down to being from running in Tmux of all things!

Oh, this device pretends to have sliders like a joystick, that's why it is not grabbed by default:

My initial reaction was WTF, but I guess it makes sense. It has the trackpoint mouse which is essentially a joystick. I still would've expected it to show up as a mouse though. I assume this explains why the laptop's Synaptics TouchPad was also skipped by default. It checked it's evdev output, it appears to send similar looking (although different) events:

Input driver version is 1.0.1
Input device ID: bus 0x11 vendor 0x2 product 0x7 version 0x1a1
Input device name: "SynPS/2 Synaptics TouchPad"
Supported events:
  Event type 0 (EV_SYN)
  Event type 1 (EV_KEY)
    Event code 272 (BTN_LEFT)
    Event code 325 (BTN_TOOL_FINGER)
    Event code 328 (BTN_TOOL_QUINTTAP)
    Event code 330 (BTN_TOUCH)
    Event code 333 (BTN_TOOL_DOUBLETAP)
    Event code 334 (BTN_TOOL_TRIPLETAP)
    Event code 335 (BTN_TOOL_QUADTAP)
  Event type 3 (EV_ABS)
    Event code 0 (ABS_X)
      Value      0
      Min     1266
      Max     5678
    Event code 1 (ABS_Y)
      Value      0
      Min     1160
      Max     4690
    Event code 24 (ABS_PRESSURE)
      Value      0
      Min        0
      Max      255
    Event code 28 (ABS_TOOL_WIDTH)
      Value      0
      Min        0
      Max       15
    Event code 47 (ABS_MT_SLOT)
      Value      0
      Min        0
      Max        1
    Event code 53 (ABS_MT_POSITION_X)
      Value      0
      Min     1266
      Max     5678
    Event code 54 (ABS_MT_POSITION_Y)
      Value      0
      Min     1160
      Max     4690
    Event code 57 (ABS_MT_TRACKING_ID)
      Value      0
      Min        0
      Max    65535
    Event code 58 (ABS_MT_PRESSURE)
      Value      0
      Min        0
      Max      255
Properties:
  Property type 0 (INPUT_PROP_POINTER)
  Property type 2 (INPUT_PROP_BUTTONPAD)

It might be worth trying to handle this as a special case. All ThinkPad laptops have this mouse. I've seen it on some HP business models as well.. (at least in the past they did).

I guess this also explains the need for a driver, and the fact it was sometimes a bit of work to get working on Linux >10 years ago. A fascinating finding to a life long ThinkPad fan like myself! :slightly_smiling_face: