Logitech Trackballs and Linux

Like a few people, I'm a big fan of Logitech's finger-thumb operated trackballs. Some tips on the trackballs I own.

Apparently Logitech stopped due to infringing patent US4862165 A.

Logitech TrackMan Marble FX

It was discontinued very permaturely, but a very comfortable, if somewhat weird to get used to, trackball.

Broken buttons

Like other Logitech mice the microswitches die eventually. It uses a MATSUSHITA AHM19001 9TH, unlike other mice that use an Omron D2FC-F-7N. The Omron can replace the left mouse button only, the holes through the microswitch are much smaller on the Omron, so wouldn't fit on the right mouse button mounting lugs.

Salvaging switches from a Marble Mouse USB also works.

The replacement is easy, unscrew 4 (one is behind the sticker) screws, desolder old button, solder new one in.

Connecting to your PC

It's native mode is PS/2, if you have a PS/2 port then it's easy. If not then there are several options.

Active PS2->USB Adaptor:
Active adaptors mostly just work, although I've not found one that understands the fourth button. Some interpret it as movement, most ignore it.
You need 2 converters, a Logitech 501102-1002 PS2-Serial adapter, and a USB-Serial controller (I'm using an FTDI-based one).Once connected together, you then need to use inputattach to get linux to use the serial port as a mouse:
inputattach -mman4 /dev/ttyUSB0
If this works, you can make it automatic via. systemd:
cat <<EOF > /etc/systemd/system/inputattach-mman4@.service
Description=inputattach for mouseman serial input devices
# Based on: https://sourceforge.net/p/linuxwacom/xf86-input-wacom/ci/master/tree/conf/wacom-inputattach%40.service.in
# See also: /etc/udev/rules.d/logitech-marble-fx.rules

ExecStart=/usr/bin/inputattach -mman4 /dev/%I

cat <<EOF > /etc/udev/rules.d/logitech-marble-fx.rules
ACTION=="add", \
  SUBSYSTEM=="usb-serial", \
  ATTRS{manufacturer}=="FTDI", \
  ATTRS{product}=="US232R", \
  ATTRS{serial}=="FTEJOT2T", \
  TAG+="systemd", ENV{SYSTEMD_WANTS}+="inputattach-mman4@%k.service"
Note that the udev rule is based around my USB-serial device, this will need modifying for whatever you're using.Finally you can turn on wheel emulation in xorg.conf:
Section "InputClass"
        Identifier         "Logitech Marble FX (serial)"
        MatchProduct       "Logitech M+ Mouse"
        MatchDevicePath    "/dev/input/event*"
        Option             "EmulateWheel"          "true"
        Option             "EmulateWheelButton"    "2"
        Option             "Emulate3Buttons"       "false"
        Option             "XAxisMapping"          "6 7"
        Option             "YAxisMapping"          "4 5"
Gutting a Trackman Marble:
In theory you could rip the innards out of a Trackman Marble USB mouse. The sensor fits the mounting perfectly, but you would have to re-use the button boards from the old mouse to keep the button layout---so it's very much a one-way procedure. Once connected you would have to increase sensitivity dramatically to make it usable, to the point that it might be somewhat inaccurate.

Logitech Cordless TrackMan FX

This is a wireless USB(!) version of the Marble FX, with a truncated version of the case. It's slightly less comfortable than the corded marble FX, but still pretty good.

Unlike the older device, this is much easier to get working. Out the box it works reasonably. However, IMO the middle and side button are the wrong way around. Also, middle-click scroll emulation is nice. To achieve both, you can add the following into xorg.conf:

Section "InputClass"
    Identifier         "Logitech Cordless TrackMan FX"
    MatchProduct       "Logitech USB Receiver"
    MatchDevicePath    "/dev/input/event*"
    Option             "EmulateWheel"          "true"
    Option             "EmulateWheelButton"    "8"
    Option             "Emulate3Buttons"       "false"
    Option             "XAxisMapping"          "6 7"
    Option             "YAxisMapping"          "4 5"
    Option  "ButtonMapping" "1 10 3 4 5 6 7 2"

Or the following xinput commands:

xinput --set-button-map "Logitech USB Receiver" 1 10 3 4 5 6 7 2
xinput set-prop "Logitech USB Receiver" "Evdev Wheel Emulation" 1
xinput set-prop "Logitech USB Receiver" "Evdev Wheel Emulation Button" 8

NB: This doesn't distinguish between any other device that uses the same receiver, e.g. the Cordless Trackman Optical. If you alternate between the two then you'll have to do something else. In theory you could read what's connected and set up your computer appropriately (The mouseware software under windows allows this), but I've not done this yet.

Broken buttons

Again, the buttons eventually start sticking and need replacing. Although a low battery can cause similar symptoms.

The left button is an OMRON D2FC-7 JAPAN, other buttons are labelled IC DM1.

Unscrew the three screws on the bottom, and the upper shell lifts off (with all the button mechanisms staying attached).

I replaced them with OMRON D2F-01F, stiffer buttons may have been better, but I'm not sure I'll tell the difference.

Logitech Cordless Trackman Optical

It's not as good as the Trackman Marble FX, but it is cordless, and has lots o' buttons. It is detected as a USB mouse quite happily, it can't report the "lock" button if connected as PS/2 though.

Smartscroll Mode

Apparently it can do something called "smart scroll". No idea what this is supposed to mean, apart from when it's on the wee buttons will report a scroll-button press as well as their own. Great. Both lmctl and lomoco will let you turn it off, however lomoco is in an unfathomable state atm, whilst lmctl still works for what we want. Compile / install .deb, then you can use a udev rule like:

SUBSYSTEM=="usb", ATTR{manufacturer}=="Logitech", ATTR{bDeviceClass}=="00", ATTR{bDeviceSubClass}=="00" \
  , RUN+="/usr/bin/lmctl -b $env{BUSNUM} -d $env{DEVNUM} -8 --no-sms"

Xorg configuration

So long as you use the evdev driver, all the buttons should work just fine. You can reorder the buttons using xinput, for example:

xinput --set-button-map "Logitech USB Receiver" \
    1 9 3 4 5 11 12 8 2 10 6 7

This will... + Make the "up" side button (7) the middle button + Make the small up/down buttons (9 & 10) the horizontal scroll buttons + Jumble the remaining buttons to the top

Assigning functions to remaining buttons

You can use xbindkeys and xvkbd to map all the extra buttons now at your disposal to key events. E.g. my .xbindkeysrc says:

# Double-up button: Home
"/usr/bin/xvkbd -xsendevent -text '\[Home]'"
   m:0x0 + b:6
# Double-dn button: Home
"/usr/bin/xvkbd -xsendevent -text '\[End]'"
   m:0x0 + b:7
# Back button: Alt-Left (i.e. back in most browsers)
"/usr/bin/xvkbd -xsendevent -text '\A\[Left]'"
   m:0x0 + b:8
# Lock button: Ctrl-T (i.e. new tab)
"/usr/bin/xvkbd -xsendevent -text '\Ct'"
   m:0x0 + b:10

Ideally I'd also want to rotate the pointer movement 225 degrees and use the "down" side button for pretend scroll-wheeling, but alas the evdev driver doesn't let you do that.