houmain / keymapper

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

Mapping Custom Keys that have keycode 0 #85

Closed YMan84 closed 7 months ago

YMan84 commented 7 months ago

I have a dell precision laptop that has a dedicated calculator key in the numpad area.

I get the following values when i trigger it on https://www.toptal.com/developers/keycode

event.key: LaunchCalculator event.code:LaunchApp2 event.which: 0 JavaScript Key Code: 0

Keymapper does not recognize {LaunchCalculator} nor {LaunchApp2} as triggers. Any ideas about how i could use this key as a trigger?

houmain commented 7 months ago

Hi, thanks for reporting. Keys without scancode are now supported on Windows. I added the missing key (LaunchApp2). It is available in the 3.2.0 release.

ristomatti commented 5 months ago

@houmain Should these work on Linux as well or only on Windows? I tested various keys available on QMK to find more descriptive but non-conflicting keys to use on application specific mappings.

Below keys that do trigger an event at https://www.toptal.com/developers/keycode seem to be missing on Linux:

These I don't know if they're missing or not. They don't trigger an event on the JS test site but do on xev (X11 captures the events?):

$ xev -rv -event keyboard -event button | grep XF86
    state 0x2010, keycode 148 (keysym 0x1008ff1d, XF86Calculator), same_screen YES,
    state 0x2010, keycode 163 (keysym 0x1008ff19, XF86Mail), same_screen YES,
    state 0x2010, keycode 152 (keysym 0x1008ff5d, XF86Explorer), same_screen YES,
    state 0x2010, keycode 164 (keysym 0x1008ff30, XF86Favorites), same_screen YES,
ristomatti commented 5 months ago

@houmain I noticed the keycodes can be found in Key.h but commented out. A couple I tested seemed to work for me. I assume that has not always been the case?

This is not a an issue for me though. I finally found a simple way to find the scan codes, so I solved this with aliases:

Stop      = 128
Menu      = 130
Undo      = 131
Select    = 132
Copy      = 133
Open      = 134
Paste     = 135
Find      = 136
Cut       = 137
Help      = 138
File      = 144
Bookmarks = 156
Back      = 158
Forward   = 159
Refresh   = 173
Search    = 217

As a bonus, I also found the scan code of the side/thumb button of my mouse:

# Logitech G502 X
ButtonSide      = 277

The trick to avoid having to run evtest without having to switch away fom X11:

$ sudo evtest /dev/input/keymapper | rg --line-buffered -v '(REL_|SYN_REPORT)' | rg 'value 1'

$ ls -l /dev/keymapper 
lrwxrwxrwx root root 13 B Thu Jan 18 22:55:41 2024  /dev/keymapper ⇒ input/event29

$ cat /etc/udev/rules.d/99-keyboard.rules
#
# Create symlink for Keymapper's virtual input device
#
SUBSYSTEM=="input", ATTRS{name}=="Keymapper", SYMLINK+="keymapper"
houmain commented 5 months ago

Thank you, I will add them. I think they were commented out from the start just because I could not find them here.