Friday, February 17, 2012

Logitech Wireless Touchpad

So I got the Logitech wireless touchpad today, did a quick search on google and confirmed it works on linux. Naturally I assumed it interacted as a multitouch touchpad just like a synaptics touchpad. Well from my initial findings it does not. It seems to take on the role of interpreting the multitouch events on the device and send keyboard presses for different events. These are, of course, mapped to common keyboard commands on Windows. After a little playing with the device, which out of the box works great on linux, I started to figure out the keyboard commands. This is where my very recent trials getting the very awesome Razer Anasi working with all macro keys working came in handy. From what I learned through this simple post http://askubuntu.com/questions/69804/how-do-i-change-the-keymap-of-a-single-device-logitech-presenter I knew I could remap the keyboard events to whatever key I wanted. Using this command

sudo /lib/udev/keymap -i /dev/input/by-id/usb-Logitech_USB_Receiver-event-mouse

I figured out the scan codes for all the gesuteres logitech talks about on this page http://logitech-en-amr.custhelp.com/app/answers/detail/a_id/26426/~/gesture-navigation-with-the-logitech-wireless-touchpad

Here is my "map" of the gestures

Three Down
scan code: 0x7004E   key code: pagedown
Three Up
scan code: 0x7004B   key code: pageup
Three Left
scan code: 0x90004   key code: 113
Three Right
scan code: 0x90005   key code: 114
Four Down
scan code: 0x700E3   key code: leftmeta
scan code: 0x70007   key code: d
Four Up
scan code: 0x700E2   key code: leftalt
scan code: 0x7002B   key code: tab
Four Right
scan code: 0x700E3   key code: leftmeta
scan code: 0x7004F   key code: right
Four Left
scan code: 0x700E3   key code: leftmeta
scan code: 0x70050   key code: left

You can see how Logitech did things each gesture comes out as a keyboard press, the one really cool bonus of the keyboard output is that this device should work without any special drivers. The bad part, no custom gestures (not that I've gotten utouch to work under arch anyway). Next all you need to do is create the keymap for the touchpad, I created a file, /lib/udev/keymaps/logitech-touchpad

0x7004E hiragana #Three Down, screendown
0x7004B kpjpcomma # Three Up, screenup
0x90005 leftmeta #Three Right, Activities
0x90004 back #three Left, Back
0x700E2 leftalt #Four up 1
0x7002B f11 #Four up 2, toggle maximized state
0x700E3 leftalt #Four down 1
0x70007 f7 #Four Down 2, Move window
#0x700E3 First part of four right
#0x7004F second part of four right
#0x700E3 First part of four right
#0x70050 second part of four right

The first two are what I'm already using on my keyboard to switch desktops using xbindkeys. Its really easy to configure and I'm sure could write a little post about it if needed. I'm hoping the rest of the remappings make sense,

Now just use this command to remap the touchpad on the fly, if you are going to use different mappings this is very useful for testing.

sudo /lib/udev/keymap /dev/input/by-id/usb-Logitech_USB_Receiver-event-mouse /lib/udev/keymaps/logitech-touchpad

And I have some fun and functional gestures.

The next step is to make a udev rule to load this whenever the device is detected, however I don't intend to restart my computer for a while now so I haven't built the udev rules, I'll follow up with my rule when I make it, otherwise check out the askubuntu.com post. I also hope to post about my fun with the Razer Anasi - the tricks to get it working might also give us clues to unlocking more gestures with the Logitech device.

5 comments:

  1. Can you map right click and middle click on a gesture?

    ReplyDelete
    Replies
    1. You don't need to – tapping with two fingers is right click, with three fingers it's middle click.

      Delete
  2. Hi all. I've just plugged a logitech wireless touchpad on a
    Fedora 17 rig and it's working fine.
    It has been recognised immediatly without any intervention.

    Even though it is not programmable, default gestures listed on
    Logitech's page http://goo.gl/HbCWZ are fine. In order to get the
    most of gnome shell, I've mapped 4 finger sweep in the
    following manner:

    Up -> Alt+Tab
    Down -> Super (windows key)
    Left -> Workspace Up
    Right -> Workspace Down


    To do that, fire up dconf-editor and select:

    org.gnome.desktop.wm.keybindings

    modify parameters as follows

    panel-main-menu ['F1','d']
    switch to workspace-up [Up,'Left']
    switch to workspace-down [Down,'Right']

    That's all.

    ReplyDelete
  3. Hey Thor

    I just got a logitech TK820. It is a keyboard with basically the same kind of trackpad as yours built in. However, it appears to send different scan codes, and I am having a bear of a time trying to remap its gestures.

    It actually appears to send more than one scan code per gesture. But I am not sure.

    For example, when I do $ sudo showkey -s, and I do a four finger swipe down, I get
    0xe0 0x5b 0x32 0xe0 0xdb 0xb2.

    For the same event (four finger swipe down), the relevant (i think?) output in xev is KeyRelease event, serial 41, synthetic NO, window 0x4200001,
    root 0xa4, subw 0x4200002, time 183859, (27,30), root:(1394,83),
    state 0x50, keycode 133 (keysym 0xffeb, Super_L), same_screen YES,
    XLookupString gives 0 bytes:
    XFilterEvent returns: False

    KeyRelease event, serial 41, synthetic NO, window 0x4200001,
    root 0xa4, subw 0x4200002, time 183859, (27,30), root:(1394,83),
    state 0x10, keycode 58 (keysym 0x6d, m), same_screen YES,
    XLookupString gives 1 bytes: (6d) "m"
    XFilterEvent returns: False

    This tells me that whatever the scan codes are for this event, it is translated to lmeta+m. It would be really helpful if I could change this to some arbitrary set of keys, just as you've done.

    Do you have any thoughts? Ideas? Anyone?

    ReplyDelete
  4. Hi, did you have any further success with the TK820? I got the same, and I'd be happy to try some solutions...

    ReplyDelete