Logitech t650 Wireless Touchpad (on Ubuntu)

Logitech Wireless Touchpad T650

I recently added a Logitech T650 Wireless Touchpad to my home office setup in an effort to match the Apple Magic Trackpad that I use at work. My command center at work consists of a 27″ iMac surrounded by dual monitors (one in the upright position, dedicated to tail-ing the logs!), an Apple Wireless Keyboard, and an Apple Magic Trackpad. The trackpad gestures are incredibly helpful on the Mac, so I wanted to bring that similar experience to my Ubuntu workstation at home.

Although I took a chance on the T650, I must say that I am pleased with its performance as a plug-and-play device. Out-of-the-box, the T650 cursor and gestures work great. Here is a quick comparison of the pros and cons.

PRO CON
  • Works out-of-the-box (cursor, left click, right click, two-finger scroll, three-finger click, three-finger swipe, top/left/right edge guestures)
  • Low-batter indicator blinks red when recharging is needed
  • Ability to use touchpad while charging
  • Requires a USB port for unified wireless receiver (bluetooth would be preferred)
  • Default right-click functionality is clunky, two-finger click would be better in my opinion
  • Tapping the touchpad cannot be used as a click (I’m guessing this would need to be implemented in the firmware)
  • Left edge gesture will delete text that you have typed!

The chart below summarizes the out-of-the-box mappings for the touchpad’s gestures and clicks.

Gesture Action Function
One-finger Press Button 1 Left-click
Three-finger Press Button 2 Middle-click (send window to back)
One-finger Press (in bottom-right corner) Button 3 Right-click
Two-finger swipe up Button 4 Scroll up
Two-finger swipe down Button 5 Scroll down
Two-finger swipe left Button 6 Scroll left
Two-finger swipe right Button 7 Scroll right
Three-finger swipe up Keypress 133 Super
Three-finger swipe down Keypress 133, 40 Super + D (show/hide all windows)
Three-finger swipe left Button 8 Browser back
Three-finger swipe right Button 9 Browser forward
Top edge swipe Keypress 37, 133, 201 Ctrl + Super + XF86TouchpadOff (F23, 0×70072)
Left edge swipe Keypress 37, 133, 22 Ctrl + Super + Backspace (this will actally delete text if you are in an input field!)
Right edge swipe Keypress 64, 133, 201 Alt + Super + XF86TouchpadOff (F23, 0×70072)

Configuring the T650

For the most part, these out-of-the-box settings are fine, but there were a couple of small tweaks that I had made in order to get things working to my liking. After a few hours of Googling and smashing away in Terminal I was able to accomplish the following:

  • Make three-finger press do right-click instead of middle-click
  • Invert horizontal and vertical scroll axis
  • Make three-finger swipe down initiate the window picker (Super + W)
  • Fix the backspace issue with the left edge gesture
  • Make the other edge gestures perform some useful tasks

Working with the device in Terminal

Most of what I set out to accomplish was performed in the Terminal, so let’s go over some of the shell commands that I used to work with this particular device.

xinput
A utility that is specifically designed to configure and test input devices (mice, keyboards, etc.). This allows to to view and diagnose the device behavior, as well as reconfigure how it works. If you don’t have it installed, run sudo apt-get install xinput.
lsusb
Lists all of the USB devices connected to your system. This is very helpful for identifying vendor codes, and with the -v argument reveals even more detail such as how the aforementioned codes will be interpreted by udev.
udev
The service responsible for managing devices in Linux. Configuration files in /etc/udev/ and /lib/udev/ already provide support for a variety of hardware. With udev we can do thing like apply a keymap to the device or trigger a script to run whenever a specific type of device is plugged in.
findkeyboards
Lists the device path of your keyboard. It lives in the /lib/udev/ folder, so you need to run it with the absolute path /lib/udev/findkeyboards.
udevadm
This is a tool for interfacing the udev service to reveal more information about the device.

The first thing to do is find out how the system identifies the device. I used xinput list, lsusb, and findkeyboards for this.

franklin@desktop-ubuntu:~$ lsusb
Bus 001 Device 003: ID 046d:09a1 Logitech, Inc. QuickCam Communicate MP/S5500
Bus 002 Device 002: ID 0bda:0151 Realtek Semiconductor Corp. Mass Storage Device (Multicard Reader)
Bus 003 Device 002: ID 051d:0002 American Power Conversion Uninterruptible Power Supply
Bus 005 Device 025: ID 046d:c52b Logitech, Inc. Unifying Receiver
Bus 008 Device 002: ID 046d:c05a Logitech, Inc. Optical Mouse M90
Bus 008 Device 003: ID 046e:55a1 Behavior Tech. Computer Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 008 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
franklin@desktop-ubuntu:~$ /lib/udev/findkeyboards
USB keyboard: input/event15
USB keyboard: input/mouse1
USB keyboard: input/event3
franklin@desktop-ubuntu:~$ xinput list
⎡ Virtual core pointer                    	id=2	[master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer              	id=4	[slave  pointer  (2)]
⎜   ↳ Logitech USB Optical Mouse              	id=9	[slave  pointer  (2)]
⎜   ↳ Logitech Unifying Device. Wireless PID:4101	id=12	[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)]
    ↳ Power Button                            	id=7	[slave  keyboard (3)]
    ↳ UVC Camera (046d:09a1)                  	id=8	[slave  keyboard (3)]
    ↳ BTC HP USB Multimedia Keyboard          	id=10	[slave  keyboard (3)]
    ↳ BTC HP USB Multimedia Keyboard          	id=11	[slave  keyboard (3)]

Through process of elimination, you can see that Ubuntu recognizes the touchpad as a Logitech Unifying Device. If you’re having trouble identifying the listed devices, simply run the commands before and after plugging in the device.

Fixing the right-click

To fix the right-click, we can use xinput to remap the mouse buttons. First, let’s look at the current button map. In the command below, we are using the name of the device as an argument for xinput, but you can also use the identifier (12).

franklin@desktop-ubuntu:~$ xinput get-button-map "Logitech Unifying Device. Wireless PID:4101"
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24

The default button map should always be sequential. To make our change, we are going to run the following:

franklin@desktop-ubuntu:~$ xinput set-button-map "Logitech Unifying Device. Wireless PID:4101" 1 3 1

The new button map makes three-finger click act as right-click and makes clicking the bottom corner area function as a normal left-click. Don’t worry that there are only three digits in the button map; xinput will preserve the rest of the sequence.

Inverting the scroll axis

Scroll inversion is something that I have setup on my Apple Magic Trackpad, so I am used to flicking my fingers up on the pad to scroll down. Changing this with the T650 is also part of the button map. We can simply flip-flop the 4, 5, 6, and 7 buttons to invert scrolling. Our button map now becomes:

franklin@desktop-ubuntu:~$ xinput set-button-map "Logitech Unifying Device. Wireless PID:4101" 1 3 1 5 4 7 6

Fixing the swipe gestures

One of my favorite things about the Apple Trackpad is its integration with Exposé; I can four-finger swipe up and down to quickly view all of my open windows in a zoomed-out thumbnail view. Ubuntu Unity boasts a similar  window chooser that is bound to the Super + W keys, which makes sense when you think about it (W = window). I wanted this to work on the T650 without changing the keybinding in Compiz, so what I did was change the keymap for the touchpad device so that the keycode for letter D actually becomes W.

To do this, I added a custom keymap file in the /lib/udev folder. This file expects a map of scancodes to keypresses. We can find the scancode using the keymap command that ships with udev. Simply run the following command, then observe the output as you perform the gestures in question. Note that the first argument is the device path as returned by the findkeyboards command above.

franklin@desktop-ubuntu:~$ sudo /lib/udev/keymap -i input/event15
Press ESC to finish, or Control-C if this device is not your primary keyboard
scan code: 0x700E3   key code: leftmeta
scan code: 0x70007   key code: d

scan code: 0x700E0   key code: leftctrl
scan code: 0x700E3   key code: leftmeta
scan code: 0x7002A   key code: backspace

scan code: 0x700E0   key code: leftctrl
scan code: 0x700E3   key code: leftmeta
scan code: 0x70072   key code: f23

scan code: 0x700E2   key code: leftalt
scan code: 0x700E3   key code: leftmeta
scan code: 0x70072   key code: f23

The output above represents “three-finger swipe down”, “left edge swipe”, “top edge swipe”, and “right edge swipe” respectively. With the scancodes in hand, I can create a keymap for my device.

/lib/udev/keymaps/logitech-t650

0x70007 w
0x70072 leftmeta
0x700E2 leftmeta
0x700E0 unknown
0x7002A unknown

The first line maps D to W so that three-finger swipe down will display our window chooser. The remaining lines will make the edge gestures function as the Super key by cancelling out the leftctrl, backspace, f23 and leftalt scancodes. The command below applies the keymap to our device.

franklin@desktop-ubuntu:~$ sudo /lib/udev/keymap input/event15 /lib/udev/keymaps/logitech-t650

Finally, to make this all come together we can add a udev rule that will apply our keymap anytime this device is plugged in.

/etc/udev/rules.d/85-logitech-t650.rules

# Logitech Wireless Touchpad T650 (keymap)
ENV{ID_VENDOR}=="Logitech*", ATTRS{name}=="Logitech Unifying Device. Wireless PID:4101", RUN+="keymap $name logitech-t650"

Conclusion

In the end, the Logitech T650 has proven to be a great addition to my workstation. Although it would be nice to get a little more out of the edge gestures, I think that further research and experimentation may be all that is needed.

Resources

Thanks to the following blogs, articles, forums!