1

Situation

I have a Microsoft Sculpt Mobile Keyboard, which is connected via Bluetooth. On my laptop a xUbuntu 16.04 is running.

The F1 to F12 keys of the Sculpt Mobile Keyboard work as function keys Play/Pause, Mute, ... . To use the F1 to F12 keys as intended, one needs the press the Fn keys, which is on the right. This is quite uncomfortable if you want to press ALT+F4 ... . I would like to switch permanently to the Fx keys (or lock the Fn key). Additionally, I would like to switch PageUp and PageDown keys against Home and End.

Windows Solution

Use AutoHotKey as described in

Not-working Solution

Answer applies to another keyboard

Linux Solution for other Keyboards (not working)

It should be possible to change or switch keys with the command line tools xkbcomp or setxkbmap as described here:

Based on these questions and answers, I used xev to find the key names (XKB identifiers) of the keys in question. I wanted to create the following mapping:

# F1 to F5 (F5 probably does not work)
I172 -> FK01
MUTE -> FK02
VOL- -> FK03
VOL+ -> FK04
FIND -> FK05

# F11 and F12
FK22 -> FK11
FK23 -> FK12

# switch Page Up and Page Down with Home and End
PGUP -> HOME
HOME -> PGUP
PGDN -> END
END  -> PGDN

Thus, I created the appropriate code:

xkb_symbols "remote" {
    key <I172> {
            type= "CTRL+ALT",
            symbols[Group1]= [              F1,              F1,              F1,              F1, XF86Switch_VT_1 ]
    };
    key <MUTE> {
            type= "CTRL+ALT",
            symbols[Group1]= [              F2,              F2,              F2,              F2, XF86Switch_VT_2 ]
    };
    key <VOL-> {
            type= "CTRL+ALT",
            symbols[Group1]= [              F3,              F3,              F3,              F3, XF86Switch_VT_3 ]
    };
    key <VOL+> {
            type= "CTRL+ALT",
            symbols[Group1]= [              F4,              F4,              F4,              F4, XF86Switch_VT_4 ]
    };
    key <FIND> {
            type= "CTRL+ALT",
            symbols[Group1]= [              F5,              F5,              F5,              F5, XF86Switch_VT_5 ]
    };
    key <FK22> {
            type= "CTRL+ALT",
            symbols[Group1]= [             F11,             F11,             F11,             F11, XF86Switch_VT_11 ]
    };
    key <FK23> {
            type= "CTRL+ALT",
            symbols[Group1]= [             F12,             F12,             F12,             F12, XF86Switch_VT_12 ]
    };
    key <PGDN> { [ End ] };
    key <END> { [ Next ] };
    key <PGUP> { [ Home ] };
    key <HOME> { [ Prior ] };
};

And added it to the existing key map definition with xkbcomp and added +custom(remote) to the xkb_symbols variable of the key mapping of the device respective device. It did not work.

I think that they maybe do not work because the keyboard is recognized as pointer and not as keyboard. The xinput list output says:

⎡ Virtual core pointer                      id=2    [master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer                id=4    [slave  pointer  (2)]
⎜   ↳ Logitech USB Mouse                        id=11   [slave  pointer  (2)]
⎜   ↳ AlpsPS/2 ALPS DualPoint TouchPad          id=14   [slave  pointer  (2)]
⎜   ↳ AlpsPS/2 ALPS DualPoint Stick             id=15   [slave  pointer  (2)]
⎜   ↳ Microsoft Sculpt Mobile Keyboard          id=17   [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)]
    ↳ Video Bus                                 id=8    [slave  keyboard (3)]
    ↳ Power Button                              id=9    [slave  keyboard (3)]
    ↳ Sleep Button                              id=10   [slave  keyboard (3)]
    ↳ Laptop_Integrated_Webcam_E4HD             id=12   [slave  keyboard (3)]
    ↳ AT Translated Set 2 keyboard              id=13   [slave  keyboard (3)]
    ↳ Dell WMI hotkeys                          id=16   [slave  keyboard (3)]

Alternative Solutions (not tried)

I read about some mice that were recognized as keyboard and not as pointer. Modifying the Linux Kernel code + recompiling it was one of the solutions. I don't want to recompile the Kernel just to get my keyboard properly working ... .

Hardware solution (working)

enter image description here

Question

  • Is my assumption in "Linux Solution for other Keyboards" wrong?
  • If the answer to the first question is no: How do I solve the described issue software-based (switch and replace keys) without recompiling my Kernel?
Run5k
  • 15,723
  • 24
  • 49
  • 63
  • Randomly applying other solutions without understanding the details rarely works. First step is to actually find out what events are generated for F1-F12, both with and without the Fn key. Use `evtest` on the kernel input layer and `xev` on the X layer for that, and edit question accordingly. *After* this is known, one can come up with the correct key mapping (and you can also do this yourself, googling for tutorials/explanations) Recompiling the kernel is never needed for a keyboard mapping. – dirkt Jun 12 '18 at 04:59
  • @dirkt Thank you for the comment. I edited the question and added the modified key mapping, which I tried yesterday. I also extracted the current key mapping with `xkbcomp -xkb $DISPLAY my_xkbmap`, modified it manually and loaded the modified mapping with xkbcomp (I forgot the command). The new key mapping did not work. However, extracting the key mapping again with `xkbcomp` returned me the new modified mapping (thus, the new key mapping was saved but did not work for some reason). Because my keyboard is recognized as pointer and not as keyboard, I though that it might only work for keyboards – daniel.heydebreck Jun 12 '18 at 07:03
  • I will try evtest later on. – daniel.heydebreck Jun 12 '18 at 07:04
  • Even if your keyboard is classified as pointer by default, it still can generate key events, so this is not the problem. Definitely look also at evtest and the input layer, because the first decision to make is whether to use the input layer or the X layer to change the mapping. – dirkt Jun 12 '18 at 07:23
  • @dirkt `evtest` yields similar results than `xev`. The function key at 'F1' is 'Play/Pause', 'F2' is 'Mute' etc. The functions keys at 'F5' to 'F12' trigger key combinations (e.g. pressing 'F10' yields the events 'CTRL_L + Windows_L + Tab') -- `xev` and `evtest` are consistent in this case. – daniel.heydebreck Jun 12 '18 at 07:37
  • @dirkt OK. Since I did not get it working via the x layer (what ever I did wrong), I will try it via the input layer. I did a quick search on "input layer keyboard mapping" and find it difficult to find a starting point ... . Can you give me some key words or the name of a command line tool? – daniel.heydebreck Jun 12 '18 at 07:41

0 Answers0