4

I need to remap the key with scancode 070037 to left ctrl + enter. So far I succeeded in remapping it to enter by creating a file 90-custom-presenter.hwdb with the following content.

# Logitech Presenter
keyboard:usb:b0003v046DpC515*
 KEYBOARD_KEY_070037=enter

I assume this is correct because lsusb gives me

Bus 003 Device 018: ID 046d:c515 Logitech, Inc. Cordless 2.4 GHz Presenter Presentation remote control

and evtest confirms that the scancode I am looking for is 70037

Event: time 1521756520.173637, type 4 (EV_MSC), code 4 (MSC_SCAN), value 70037
Event: time 1521756520.173637, type 1 (EV_KEY), code 52 (KEY_DOT), value 1
Event: time 1521756520.173637, -------------- SYN_REPORT ------------
Event: time 1521756520.277633, type 4 (EV_MSC), code 4 (MSC_SCAN), value 70037
Event: time 1521756520.277633, type 1 (EV_KEY), code 52 (KEY_DOT), value 0
Event: time 1521756520.277633, -------------- SYN_REPORT ------------

After running udevadm hwdb --update as root I would have expected that this maps the former "dot" key to enter but it does not. This raises two questions:

  1. Why does this not map as expected?
  2. Once it works as expected, how could I map this to ctrl-enter?

I am running Ubuntu 14.04 LTS.

  • If this thing is in fact just a keyboard, then xmodmap would probably be the place to start. It is specifically designed for such things. – Joe Mar 23 '18 at 22:21
2

You did not identify your Linux distribution, which may or may not use the same version of udev as my Debian 9 does, so this may or may not apply to your system.

On my system, /lib/udev/hwdb.d/60-keyboard.hwdb has some informative comments:

# Note: The format of the "evdev:" prefix match key is a
# contract between the rules file and the hardware data, it might
# change in later revisions to support more or better matches, it
# is not necessarily expected to be a stable ABI.
#
# Supported hardware matches are:
#  - Generic input devices match:
#      evdev:input:bZZZZvYYYYpXXXXeWWWW-VVVV
...

There is no mention of a keyboard:usb hardware match in the list.

So, unless you have documentation specific to your Linux distribution and version to tell you otherwise, or your actual system default .hwdb files use the keyboard:usb syntax, try replacing your keyboard:usb:b0003v046DpC515* with:

evdev:input:b0003v046DpC515*

The problem with making the presenter's "dot" key to Control+Enter is that the .hwdb file can only map a scancode to a (single) keycode. It cannot insert a sequence of key codes. To map a key to Control+Enter at this stage, you would have to insert an extra event in addition to modifying the actual key event, and do the same thing with the corresponding key release event.

Your desktop environment might include a more versatile keyboard mapping/shortcut feature, which might serve your needs better. You might have to first use the hwdb rules to map the presenter's key to some otherwise unused key code, and then the desktop environment's feature to map that key code to Control+Enter.

  • 1
    agree, udev is the wrong tool for this job. xkb might do it (but ugly and hacky); a macro program would be more suitable. it might be reasonable to use udev to map the key to something like F20 that will absolutely positively not be recognized as ., if desired, before using a macro program to turn that keystroke into the final result. – quixotic Mar 23 '18 at 6:48
  • also note that in /lib/udev/hwdb.d/60-keyboard.hwdb, the keymapping lines are indented with a single space, which the questioner's example is missing. – quixotic Mar 23 '18 at 6:50
  • I fixed the question, it now gives the version I am running. – Udo Klein Mar 23 '18 at 17:15
  • I added the extra space. Nothing. Also in my 60-keyboard.hwdb it states # Supported hardware matches are: # - USB keyboards identified by the usb kernel modalias: # keyboard:usb:vXXXXpYYYY* – Udo Klein Mar 23 '18 at 18:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.