Logitech Cordless Desktop LX700

LX700
I was getting tired of my old keyboard and decided to buy a new on. The choice fell on a “Logitech Cordless Desktop LX700”, with a “Logitech Cordless Click! Plus” mouse included.
The keyboard has a gazillion extra keys, including a roller on the left side, doubling for the arrow keys on the right, and some mouse buttons on the keyboard. It also has a bunch of keys for controlling a media player, and for other applications.
Basic functionality is there and the keyboard works out of the box with Linux. The problem lies with all the extra keys.
Some of the extra keys are known to the Linux keyboard driver and to to XFree86, and they can be configured in Gnome or your window manager without any problems. In my case this happened for several of the media player keys and the Email key. All I had to do was select “Logitech Desktop Pro” as the keyboard type in the Gnome preferences.
Many of the extra keys did not work, however.
It took quite an effort to get everything to work, but in the end each and every key on the keyboard is usable under Linux.

Scancodes, keycodes x 2 and keysyms

There are several layers of interpretation involved in a keypress. First the keyboard generates a scancode which is mapped to a Linux keycode by the kernel. When running under XFree86 the scancode or the linux keycode is mapped by the X keyboard driver to an X11 keycode (which still indicates a physical key on the keyboard), and later again to an X keysym (which is a more symbolic representation of a logical key).
So to make everything work we need to make sure all scancodes have Linux keycodes (i.e., that the keys are known to the kernel), and then find the corresponding X11 keycodes and map those to X11 keysyms which applications can use.

Keyboard scancodes

Keyboard scancodes are either a seven bit number (0x00-0x7f) or an extended scancode made up of the number 0xe0 followed by a seven bit number. This allows for at most 256 scancodes.
When an unknown key is pressed, the kernel prints a message giving the scancode:

atkbd.c: Unknown key pressed (translated set 2, code 0x6e on isa0060/serio0).
Use 'setkeycodes 6e ' to make it known.

This is the basic tool for discovering scancodes for the extra keys on this keyboard.

The Linux keycode table

The Linux kernel maintains a table mapping keyboard scancodes to linux keycodes. The table can be printed with the program getkeycodes:

# getkeycodes
Plain scancodes xx (hex) versus keycodes (dec)
for 1-83 (0x01-0x53) scancode equals keycode
 0x50:   80  81  82  83  84   0  86  87
 0x58:   88 117   0   0  95 183 184 185
 0x60:    0   0   0   0   0   0   0   0
 0x68:    0   0   0   0   0   0   0   0
 0x70:   93   0   0  89   0   0  85  91
 0x78:   90  92   0  94   0 124 121   0
Escaped scancodes e0 xx (hex)
e0 00:    0   0   0   0   0   0   0   0
e0 08:    0   0   0   0   0   0   0   0
e0 10:  165   0   0   0   0   0   0   0
e0 18:    0 163   0   0  96  97   0   0
e0 20:  113 140 164   0 166   0   0   0
e0 28:    0   0 255   0   0   0 114   0
e0 30:  115   0 150   0   0  98 255  99
e0 38:  100   0   0   0   0   0   0   0
e0 40:    0   0   0   0   0 119 119 102
e0 48:  103 104   0 105 112 106 118 107
e0 50:  108 109 110 111   0   0   0   0
e0 58:    0   0   0 125 126 127 116 142
e0 60:    0   0   0 143   0 217 156 173
e0 68:  128 159 158 157 155 226   0 112
e0 70:    0   0   0   0   0   0   0   0
e0 78:    0   0   0   0   0   0   0   0

The zeroes indicates keys with no mapping.
To set a mapping for an unknown scancode, use the program setkeycodes:

setkeycodes e03b 227

Linux keycodes have symbolic names in the file /usr/include/linux/input.h, but any unused number between 1-255 can be used.
All keys must have a linux keycode, otherwise they will be dead and unusable.
Having tested all the keys, I ended up with this command to initialise the linux keycode table:

setkeycodes e011 216 e075 148 e074 212 6c 105
6e 106 e001 154 6d 206 e004 202 6a 203 6b 219
e014 181 e013 182 e015 188 e055 187 e031 152
e078 167 e02d 168 e02f 162 e02c 192 e025 195
e026 194 e03b 227 e03c 228 e03d 229 e03e 230
e03f 231 e040 232 e041 233 e042 234 e043 235
e044 236 e057 237 e058 238

After initialisation the keycode table looks like this:

# getkeycodes
Plain scancodes xx (hex) versus keycodes (dec)
for 1-83 (0x01-0x53) scancode equals keycode
 0x50:   80  81  82  83  84   0  86  87
 0x58:   88 117   0   0  95 183 184 185
 0x60:    0   0   0   0   0   0   0   0
 0x68:    0   0 203 219 105 206 106   0
 0x70:   93   0   0  89   0   0  85  91
 0x78:   90  92   0  94   0 124 121   0
Escaped scancodes e0 xx (hex)
e0 00:    0 154   0   0 202   0   0   0
e0 08:    0   0   0   0   0   0   0   0
e0 10:  165 216   0 182 181 188   0   0
e0 18:    0 163   0   0  96  97   0   0
e0 20:  113 140 164   0 166 195 194   0
e0 28:    0   0 255   0 192 168 114 162
e0 30:  115 152 150   0   0  98 255  99
e0 38:  100   0   0 227 228 229 230 231
e0 40: 232 233 234 235 236 119 119 102
e0 48:  103 104   0 105 112 106 118 107
e0 50:  108 109 110 111   0 187   0 237
e0 58:  238   0   0 125 126 127 116 142
e0 60:    0   0   0 143   0 217 156 173
e0 68:  128 159 158 157 155 226   0 112
e0 70:    0   0   0   0 212 148   0   0
e0 78:  167   0   0   0   0   0   0   0

X11 keycodes and keysyms

Once the keys are known to the linux kernel, X11 should report on the keys. There is no need to restart anything. All changes are made immediately. Run the command xev in a terminal window and press some of the keys. In the copious output there should be entries like:

KeyPress event, serial 22, synthetic NO, window 0x1a00001,
    root 0x3f, subw 0x0, time 182843678, (117,117), root:(188,165),
    state 0x0, keycode 9 (keysym 0xff1b, Escape), same_screen YES,
    XLookupString gives 1 bytes: ""

We’re looking for KeyPress events. The interesting parts are in the third line. The X11 keycode is there (“9” in the example, it is normally different from the linux keycode) and the assigned X11 keysym is there (0xff1b in the example). The name of the keysym is there too (“Escape”).
All keys should give a X11 keycode in the output of xev, but some keys will probably give a keysym of 0 with the name NoSymbol. These keys are known to Linux but no configured in XFree86.
The mapping of X11 keycodes to keysyms is set with the xmodmap program, e.g.,:

xmodmap -e "keycode 121 = XF86Messenger"

The names of X11 keysyms for special keys are listed in the file /usr/X11R6/lib/X11/XKeysymDB.
Many keys on the Logitech Cordless Desktop LX700 keyboard were known and defined by XFree86, but several were missing. These xmodmap commands will define the missing keys:

keycode 121 = XF86Messenger
keycode 159 = XF86Calendar
keycode 187 = XF86WebCam
keycode 166 = XF86RotateWindows
keycode 175 = XF86Close
keycode 171 = XF86ZoomOut
keycode 172 = XF86ZoomIn
keycode 195 = XF86Finance
keycode 137 = XF86Video
keycode 138 = XF86Music
keycode 247 = XF86Pictures
keycode 131 = XF86Documents
keycode 146 = XF86CD
keycode 177 = XF86AudioRecord
keycode 152 = XF86AudioRewind
keycode 253 = XF86Eject
keycode 249 = XF86Launch0
keycode 149 = XF86Launch1
keycode 119 = XF86Launch2
keycode 214 = XF86Support
keycode 215 = XF86Word
keycode 216 = XF86Excel
keycode 217 = XF86Calculater
keycode 218 = Undo
keycode 228 = Redo
keycode 142 = Print
keycode 213 = XF86Save
keycode 240 = XF86Copy
keycode 241 = XF86Cut
keycode 242 = XF86Paste
keycode 243 = XF86Clear

With this in place the keys should be functional. You will have to bind something to these keys, in your window manager or in your applications.
In sawfish you can middle-click on the desktop, and select “Customise | Bindings” where you can setup some of the special keys to do window manager functions. For example, I have bound XF86RotateWindows to the Sawfish function “Next workspace window”. I can now cycle through the open windows in the current workspace with just one key press.
In Gnome you can go to the menu entry “Applications | Desktop Preferences | Keyboard Shortcuts” where you can setup various media player shortcuts and other keys. Not all of these settings work in my setup, maybe because I’m not using the default Gnome window manager metacity.

Automatic setup

The setkeycodes command has to be run once at system start. How it is done depends on you choice of distribution. On Debian Linux you must create an init.d file, e.g., /etc/init.d/logitechkbd which has to be linked to the system startup directories. This is done with the command

update-rc.d -n logitechkbd start 75 S .

The file /etc/init.d/logitechkbd can be downloaded below.
Next, you need to run the above xmodmap commands whenever you start X-windows. The easiest is to have the commands in a file, say ~/.Xmodmap_logitech which is then run from whatever scripts starts your X-session. The command is:

xmodmap ~/.Xmodmap_logitech

Files for download

/etc/init.d/logitechkbd
~/.Xmodmap_logitech

Problems with scancodes

I have received several mails about problems using scancodes above 127. I have myself had no such problems, using Debian Testing, but apparently there’s a bug in some versions of setkeycodes.


Comments

25 responses to “Logitech Cordless Desktop LX700”

  1. Wow !!!!

    Excelent write up, and clear, concise instructions. I have searched for two days for something like this and this is the first helpful write-up I have been able to understand and follow.

    Here is the good news. I am using an MX3100 keyboard and have function of every key. Good on ya mate!!!!

  2. Slight change to the setkeycodes for MX3100 thanks to Sheldon from lineak for his help.

    setkeycodes e014 189 e013 221 e015 202 e055 157 e011 203 e075 217 e074 212
    6a 179 e004 180 6b 140 e003 177 e002 178 6c 189 6e 190 6d 183 e001 184
    e03b 59 e03c 60 e03d 61 e03e 62 e03f 63 e040 64 e041 65 e042 66 e043 67
    e044 68 e057 87 e058 88 e02d 170 e02f 161 e031 185 e078 167 e02c 186 e025 187 e026 188

  3. Slight change to the setkeycodes for MX3100 thanks to Sheldon from lineak for his help.

    setkeycodes e014 189 e013 221 e015 202 e055 157 e011 203 e075 217 e074 212
    6a 179 e004 180 6b 140 e003 177 e002 178 6c 189 6e 190 6d 183 e001 184
    e03b 59 e03c 60 e03d 61 e03e 62 e03f 63 e040 64 e041 65 e042 66 e043 67
    e044 68 e057 87 e058 88 e02d 170 e02f 161 e031 185 e078 167 e02c 186 e025 187 e026 188

  4. Awesome article. Thank you very much!

  5. Doesn’t work for my mx3100. xev still shows no output pressing the keys. Also the kernel doesn’t show messages like this:
    “atkbd.c: Unknown key pressed (translated set 2, code 0x6e on isa0060/serio0).
    Use ‘setkeycodes 6e ‘ to make it known.”
    Whats wrong here?
    thx in advance

  6. Anyone know how to use extended keycodes in the range of 0x160 to 0x1ff? (from linux/input.h). None of the keycodes below 255 are a good match to my notebook’s keys, but some of the extended ones are logical. setkeycodes won’t take a number higher than 255, and giving it in hex (like input.h) just gets parsed as 0.

  7. almarma avatar
    almarma

    Why not all of us ask to Logitech to do any driver or software for our Logitech keyboard and mouses? I think that in year 2005, almost any famous hardware manufacturer MUST do drivers for Linux.

    I am a Linux newbie and this is very dificult for me, and for the 95% of the people, and some “stupid” thing like cannot use the Logitech extra features under Linux, makes people not to use Linux. If the people like us that buy Logitech products, don’t tell them anything, they will never release Linux drivers, don’t you think so?

  8. sathish avatar
    sathish

    Does anyone have such a thing for the LX 500 keyboard.
    I too am a n00b as almarma

  9. Joel Brunetti avatar
    Joel Brunetti

    Here is a gentoo init script I made up.

    #!/sbin/runscript
    #
    #Setup linux keycodes for
    #Logitech Cordless Desktop LX700
    #
    #
    #Written by Rene Seindal <rene{stupid spam bots}seindal.dk>
    #Adapted as Gentoo Init Script by Joel Brunetti <joelbrunetti{stupid spam bots}gmail.com>

    start() {

    ebegin “Starting Logitech Cordless Desktop LX700”

    setkeycodes e011 216 e075 148 e074 212 6c 105 6e 106 e001 154 6d 206 e004 202 6a 203 6b 219 e014 181 e013 182 e015 188 e055 187 e031 152 e078 167 e02d 168 e02f 162 e02c 192 e025 195 e026 194 e03b 227 e03c 228 e03d 229 e03e 230 e03f 231 e040 232 e041 233 e042 234 e043 235 e044 236 e057 237 e058 238

    eend $?
    }

    stop() {
    ebegin “Keycodes much be changed manually”
    eend $?
    }

    restart() {
    ebegin “Keycodes much be changed manually”
    eend $?
    }
    # Keys set by above script
    # Label scancode keycode
    # Messenger e011 216
    # Status e075 148
    # Webcam e074 212
    # 2win e001 154
    # X 6d 206
    # left 6c 105
    # right 6e 106
    # zoom_ e004 202
    # zoom+ 6a 203
    # % 6b 219
    # media film e014 181
    # media music e013 182
    # media photo e015 188
    # documents e055 187
    # flame e031 152
    # record e078 167
    # ipod e02d 168
    # eject e02f 162
    # preset1 e02c 192
    # preset2 e025 193
    # preset3 e026 194
    # F1 help e03b 227
    # F2 word e03c 228
    # F3 excel e03d 229
    # F4 ppt e03e 230
    # F5 undo e03f 231
    # F6 redo e040 232
    # F7 print e041 233
    # F8 save e042 234
    # F9 progA e043 235
    # F10 progB e044 236
    # F11 progC e057 237
    # F12 progD e058 238

    I hope it helps somebody out.

  10. trooubled0001 avatar
    trooubled0001

    ebigin…..much be changed ?!

  11. Absolutely amazing!!!!!!

    I never thought I would use my lx 700 special keys again (after leaving M$ behind).
    Just a little trouble (ops… yeah. I’m newbie): I’m running open suse 10.0 and everythig works perfectly until “automatic setup” section on the article. In other words, everytime I restart the machine there’s a lot of work to do to get the special keys working. The “update-rc.d -n logitechkbd start 75 S .” command doesn’t work for me… how can I record the commands on suse 10.0 start-up? Is there a file that I can change on text mode? Or is there a way to use the script sent by “Joel Brunetti” (how shall I use to change the text above to a ‘script’ file?)

    Thanks for the attention given to a new linux lover!!!

  12. I have the same problem. I follow each steps but xev still shows no output when I press the keys. I have a laptop. Maybe a problem with the other keyboard.

    Thank for your work and your help

  13. I think you will be interested in keyTouch (http://keytouch.sf.net) which makes it much easier to get your keyboard working. Maybe you want to make a keyboard file of your keyboard for it.

  14. On the other hand there are lx700 desktop keyboards where half of the multimedia keys do not generate any scancode. I am a “proud” owner of one such kbd. Therefore test the keyboard before buying.

  15. Hmm, what kernel you are using? I am at 2.6.14 and ‘man setkeycodes’ says:

    “…For the remaining scancodes 0x59-0x7f) or scancode pairs (0xe0 0x00 – 0xe0 0x7f) a corresponding keycode can be assigned (in the range 1-127).”

    And indeed, setkeycodes complains if I try to set any key code number > 127, even though this number is unused:

    # setkeycodes e012 146
    setkeycodes: code outside bounds

  16. madCoder avatar
    madCoder

    Any had any luck getting the LX700 to work via USB, including all media keys? I had most of my media keys working when it was connected via PS2, but when it’s connected with USB, I get this in my Xorg.0.log:

    LookupDeviceIntRec id=0x8 not found

    repeated twice for each time I press one of the non-standard keys (the standard keys work as expected btw). The mouse seems to work okay, its just the media keys on the keyboard that aren’t working. This is with X.org 7.0 if that makes a difference.

  17. ShipInTheNight avatar
    ShipInTheNight

    I had to put my keyboard into scancode mode before I got anything from the media keys. Check the mode with the command “kbd_mode”

  18. Nikolai Beier avatar
    Nikolai Beier

    Where does the kernel print the scancodes to? I have looked in various sytem logs, dmesg etc. without result.

    The article does not seem to explain how the shown example of a found scancode is generated.

  19. I’ve recently run into this kind of howto http://forums.gentoo.org/vi… I haven$t tried it yet but according to the comments there it seems to work with similar keyboards.

  20. what about the mouse? does it work correctly including the 4-way-scroll-wheel? I found this (http://lomoco.linux-gamers….) but it says that it will only work if it’s connected via USB. One poster at top said that the extra-keys wouldnt work with usb, so that means either extra-key or correct mouse-function?

  21. The scancodes (when a key isn’t recognized) are spit out by the kernel. Ctrl+Alt+F10 gets me to the kernel output. I’m using SuSE 10.0. It may be different in other distros.

  22. An easier way would be to use keyTouch http://keytouch.sourceforge

  23. Emmm…sorry… I have Logitech Cordless Desktop Deluxe SE with optical mouse… How can I use it with linux ubuntu? Only the keyboard doesn’t work.
    Thank you very much

    Sara (Italy)

  24. doucoure avatar
    doucoure

    LX700

  25. Works outstanding in slackware 11 !!!