7

I got a Logitech Bluetooth Multi-Device Keyboard K480 and after installing it just by following the bluetooth pairing, the default settings will leave the function keys mapped as multimedia keys, so I have to hold fn to access F1,F2,F3, etc.

That is very counter-intuitive for me, and I'd like to remap it so I can access Functions directly and access the multimedia keys with fn

Logitech Bluetooth Multi-Device Keyboard K480

This is F1 without holding fn and then holding it.

KeyPress event, serial 37, synthetic NO, window 0x4e00001,
root 0xd6, subw 0x0, time 63445847, (-438,408), root:(284,460),
state 0x10, keycode 180 (keysym 0x1008ff18, XF86HomePage), same_screen YES,
XLookupString gives 0 bytes: 
XmbLookupString gives 0 bytes: 
XFilterEvent returns: False

KeyRelease event, serial 37, synthetic NO, window 0x4e00001,
root 0xd6, subw 0x0, time 63445922, (-438,408), root:(284,460),
state 0x10, keycode 180 (keysym 0x1008ff18, XF86HomePage), same_screen YES,
XLookupString gives 0 bytes: 
XFilterEvent returns: False

KeyPress event, serial 37, synthetic NO, window 0x4e00001,
root 0xd6, subw 0x0, time 63446510, (-438,408), root:(284,460),
state 0x10, keycode 67 (keysym 0xffbe, F1), same_screen YES,
XLookupString gives 0 bytes: 
XmbLookupString gives 0 bytes: 
XFilterEvent returns: False

KeyRelease event, serial 37, synthetic NO, window 0x4e00001,
root 0xd6, subw 0x0, time 63446597, (-438,408), root:(284,460),
state 0x10, keycode 67 (keysym 0xffbe, F1), same_screen YES,
XLookupString gives 0 bytes: 
XFilterEvent returns: False
peem
  • 73
  • Run the command xev in a terminal. When you press a key, you should see lines like KeyPress event … and two lines below keysym 0xffbe, F1. Is that the case both with and without the fn key? Do you see F1 with fn and something else (what?) without it? – Gilles 'SO- stop being evil' Mar 07 '16 at 23:02
  • Thanks for the attention Gilles, I updated the question to show the info obtained from your suggestions. – peem Mar 08 '16 at 06:06

3 Answers3

4

It seems that logitech provides a special driver on various OS's other than Linux that does exactly this swap by sending an undocumented magic command to the keyboard.

Some people have monitored the communication to find the codes sent to some other similar logitech keyboards such as the 760 and the 810. You might try one of those.

Failing that, you can use xmodmap to swap the key assignments. We see that your keyboard sends 2 different keycodes depending on whether Fn is pressed or not. Use xmodmap -pke to list all the key mappings in a file, then keep just the ones referring to the wanted keycodes. For example you would have

keycode  67 = F1 F1 F1 F1 F1 F1 XF86Switch_VT_1
keycode 180 = XF86HomePage NoSymbol XF86HomePage

and so on. Simply invert the numbers:

keycode 180 = F1 F1 F1 F1 F1 F1 XF86Switch_VT_1
keycode  67 = XF86HomePage NoSymbol XF86HomePage

Then pass this filename as argument to xmodmap to have it update the mapping.

meuh
  • 51,383
1

You can put this code into a script named: "/home/youruser/k480" and run it. Will remap your logitech keys.

xmodmap -e "keycode 180 = F1 F1 F1 F1 F1 F1"
xmodmap -e "keycode  23 = F2 F2 F2 F2 F2 F2"
xmodmap -e "keycode 135 = F3 F3 F3 F3 F3 F3"
xmodmap -e "keycode 166 = F4 F4 F4 F4 F4 F4"
xmodmap -e "keycode 225 = F5 F5 F5 F5 F5 F5"
xmodmap -e "keycode 173 = F6 F6 F6 F6 F6 F6"
xmodmap -e "keycode 172 = F7 F7 F7 F7 F7 F7"
xmodmap -e "keycode 171 = F8 F8 F8 F8 F8 F8"
xmodmap -e "keycode 121 = F9 F9 F9 F9 F9 F9"
xmodmap -e "keycode 122 = F10 F10 F10 F10 F10 F10"
xmodmap -e "keycode 123 = F11 F11 F11 F11 F11 F11"
xmodmap -e "keycode 118 = F12 F12 F12 F12 F12 F12"
christian
  • 131
0

I found this blog, Logitech K480 on Ubuntu and ‘fn buttons’ default behaviour, which appears to solve the same issue as you describe:

By default this keyboard (and as of my understanding similar keyboards from logitech) have ‘media buttons’ enabled by default i.e. f1-f12 will act as media buttons and function buttons are accessed by pressing fn buttons + f1-f12. For work this is really not acceptable. I made this fix for Logitech K480 based on work of Mario Scholz for K810. Source code is here:

K480 fix on github

What I did was to re-trace his step, in a virtual machine running win7 I installed SetPoint software from logitech and debugged the output to the bluetooth device. For K480 I got:

on (bingo!)
> to keyboard
ffff8801d2173000 2960870190 S Bo:2:013:2 -115 16 = 0c200c00 08004200 a210ff08 1c000000
< from keyboard ffff8801ed13b000
1204929370 C Bi:2:013:2 0 29 = 0c201900 15004200 a111ff08 1b000100 00000000 00000000 00000000 00

off > to keyboard ffff88062b7db0c0 3001832891 S Bo:2:013:2 -115 16 = 0c200c00 08004200 a210ff08 1c010000 < from keyboard ffff8801ed368b40 1227979618 C Bi:2:013:2 0 29 = 0c201900 15004200 a111ff08 1b010100 00000000 00000000 00000000 00

Note that messages to keyboard start with hex: ‘a2’ and from keyboard with ‘a1’ bytes. All in all, it works fine, I updated device ID as well to 0xb330 while K810 is 0x319. On a personal note, I like this keyboard, it has nice ‘drop’ for keys and spacing is just right – works really well for fast code writing :).

Greenonline
  • 1,851
  • 7
  • 17
  • 23