It seems that it's quite easy to get Apple Magic Trackpad work on linux. Besides the trackpad you will need a bluetooth receiver. The most recent laptops come with a built-in Bluetooth but in my case I needed to buy it for my desktop pc.
Bluetooth receiver
I bought ASUS USB-BT400 bluetooth adapter mainly because it just works out of the box on Linux and it is Bluetooth 4.0 / 3.0 / 2.1 / 2.0 compatible.
On first boot I checked following things
That I have touchpad config tool for KDE. It was missing so installed it.$ sudo apt-get install kde-config-touchpad
That I have all needed bluetooth applications installed.
dpkg --get-selections | grep 'blue'
bluedevil install
bluetooth install
bluez install
libbluedevil2:amd64 install
libbluetooth3:amd64 install
That I can see the bluetooth adapter.
$ lsusb | grep 'ASUS'
Bus 003 Device 005: ID 0b05:17cb ASUSTek Computer, Inc.
After those things I powered up the Apple Magic Trackpad and scanned my bluetooth devices (System settings > Bluetooth)
A new bluetooth adapter found the Apple Wireless Trackpad. I paired and connected it. By the way default pin is: 0 0 0 0
Finally I checked the kernel message details of my Apple devices. The red text lines are for Apple Magic Trackpad and black text for Apple Magic Mouse.
$ dmesg | grep 'magic'
[ 37.587869] magicmouse 0005:05AC:030D.0009: unknown main item tag 0x0
[ 37.588008] magicmouse 0005:05AC:030D.0009: input,hidraw6: BLUETOOTH HID v3.06 Mouse [Apple Magic Mouse] on 5c:f3:70:63:97:a1
[157856.306955] magicmouse 0005:05AC:030E.000A: unknown main item tag 0x0
[157856.307157] magicmouse 0005:05AC:030E.000A: input,hidraw7: BLUETOOTH HID v1.60 Mouse [Apple Wireless Trackpad] on 5c:f3:70:63:97:a1
Once your trackpad has been paired, the "hid_magicmouse" module should automatically load. Both Apple Magic Mouse and Trackpad uses the same "hid_magicmouse" driver. To verify that it is loaded you can check it in terminal:
$ lsmod | grep 'magic'If it is not loaded you can load id this way:
hid_magicmouse 12679 0
hid 102264 6 hidp,hid_generic,usbhid,hid_logitech_dj,hid_magicmouse
$ sudo modprobe hid_magicmouse
Synaptic driver solution
So my Apple Magic Trackpad semi-worked right out of the box on Debian Testing (Jessie). I use KDE as default desktop environment.
What worked out of the box?
- Mouse movements (horizontal speed was slower than vertical - can be fixed)
- One finger click (Mouse left button)
- Two fingers click (Mouse right button)
- Two fingers gestures (scrolling top/down/left/right)
- Three fingers click (Paste)
(KDE: System settings > Input devices > Touchpad)
- Hot corner areas (example for scrolling)
- Tap clicking
To fix that slow horizontal scrolling I created following file:
/etc/X11/xorg.conf.d/60-apple-magic-trackpad.conf
And here is my configuration for that file:
# Configuration for fine-tuning only the Apple Magic Trackpad.
Section "InputClass"
Identifier "Apple Magic Trackpad"
Driver "synaptics"
# Match only the Apple Magic Trackpad
MatchUSBID "05ac:030e"
MatchIsTouchpad "on"
# Set resolution tweaks for better response
Option "VertResolution" "75"
Option "HorizResolution" "75"
# Set a timeout for multi finger click so accidental double-clicks don't
# happen when right clicking and other gestures
Option "EmulateMidButtonTime" "100"
# Increase sensitivity
Option "MinSpeed" "0.50"
Option "MaxSpeed" "1.00"
Option "AccelFactor" "0.1"
# Scrolling
Option "VertScrollDelta" "100"
Option "HorizScrollDelta" "100"
EndSection
Those settings were fine on my pc. I have Monitor (4K) and TV (1080p) connected to my pc. Those settings could be different if you don't have that big monitor or multi-monitor system.
Note: Every time you edit that file you will need to restart the X server, I restarted the PC just in case.
The final tuning I did using the Synaptiks GUI for touchpads
(KDE: System settings > Input devices > Touchpad)
MTRACK driver solution
Previous solution wasn't perfect so I did some googling and I found out that I need to install mtrack driver for 4 fingers gestures.
$ sudo apt-get install xserver-xorg-input-mtrack
After driver installation I configured the X server to use that driver. I opened again following configuration file:
/etc/X11/xorg.conf.d/60-apple-magic-trackpad.conf
And I edited it as below:
# Configuration for fine-tuning only the Apple Magic Trackpad.Here is listed all configuration options for Mtrack:
Section "InputClass"
Identifier "Apple Magic Trackpad"
Driver "mtrack"
# Match only the Apple Magic Trackpad
MatchUSBID "05ac:030e"
MatchIsTouchpad "on"
# Set resolution tweaks for better response
# Tap
Option "TapButton1" "1"
Option "TapButton2" "3"
Option "TapButton3" "8"
Option "TapButton4" "9"
# Click
Option "ClickFinger1" "1"
Option "ClickFinger2" "3"
Option "ClickFinger3" "2"
# Two finger swipe
Option "ScrollDistance" "15"
Option "ScrollUpButton" "4"
Option "ScrollDownButton" "5"
Option "ScrollLeftButton" "6"
Option "ScrollRightButton" "7"
# Three finger swipe
Option "SwipeDistance" "180"
Option "SwipeUpButton" "34"
Option "SwipeDownButton" "35"
Option "SwipeLeftButton" "8"
Option "SwipeRightButton" "9"
# Four finger swipe
Option "Swipe4Distance" "200"
Option "Swipe4UpButton" "20"
Option "Swipe4DownButton" "21"
Option "Swipe4LeftButton" "23"
Option "Swipe4RightButton" "22"
# Scaling
Option "ScaleDistance" "40"
Option "ScaleUpButton" "12"
Option "ScaleDownButton" "13"
# Rotate
Option "RotateDistance" "40"
Option "RotateLeftButton" "14"
Option "RotateRightButton" "14"
Option "TapDragEnable" "true"
Option "TapDragTime" "350"
Option "TapDragWait" "40"
Option "TapDragDist" "200"
Option "Sensitivity" "0.85"
Option "FingerHigh" "5"
Option "FingerLow" "5"
Option "IgnoreThumb" "true"
Option "IgnorePalm" "true"
# Option "ButtonMoveEmulate" "false"
Option "ButtonIntegrated" "true"
EndSection
https://github.com/BlueDragonX/xf86-input-mtrack
Those red text numbers in the configuration file are mouse button numbers. A common mouse have by default max 9 buttons and this is the layout for those 9 buttons:
1 = Left click
2 = Middle click
3 = Right click
4 = Scroll top
5 = Scroll down
6 = Scroll left
7 = Scroll right
8 = Back
9 = Forward
The rest button numbers in configuration file is just make it up by myself so there is not any big logic behind on that numbering.
Note: Remember restart the X server or PC after you have modified that 60-apple-magic-trackpad.conf -file.
With that configuration trackpad movents, gestures and clicks got through as mouse buttons. I tested that using the XEV input detection tool.
$ xev
I did those gestures on the trackpad and I sametime checked the log on Konsole. Example 3 fingers swipe left I got following info on ZEV:
ButtonPress event, serial 40, synthetic NO, window 0x7000001,
root 0xc9, subw 0x0, time 1002624673, (103,137), root:(103,278),
state 0x10, button 8, same_screen YES
As you can see it was registered as click on mouse button 8.
Then I installed following packages to bind trackpad gestures to various actions.
$ sudo apt-get install xautomation
$ sudo apt-get install xbindkeys
The final step was bind gestures and clicks to the actions
So I created configuration file for xbindkeys to the home folder
$ xbindkeys -d > ~/.xbindkeysrc
Then I added following rows to that configuration file. Basically I linked my keyboard shortcuts to the mouse buttons that are created by trackpad gestures:
# Minimize toggle - Swipe 4 fingers up - Key: Meta + F8
"xte 'keydown Super_L' 'key F8' 'keyup Super_L'"
b:20
# View all windows - Swipe 4 fingers down - Key: Meta + F8
"xte 'keydown Control_L' 'key F8' 'keyup Control_L'"
b:21
# Move current window to TV - Swipe 4 fingers right : Meta+b
"xte 'keydown Super_L' 'key b' 'keyup Super_L'"
b:22
# Move current window back to the monitor - Swipe 4 fingers left : Meta+v
"xte 'keydown Super_L' 'key v' 'keyup Super_L'"
b:23
# New Tab - FF - Swipe 3 fingers up : Control+t
#"xte 'keydown Control_L' 'key t' 'keyup Control_L'"
# b:34
# Close Tab - FF - Swipe 3 fingers down : Control+w
#"xte 'keydown Control_L' 'key w' 'keyup Control_L'"
# b:35
The last two Firefox actions I disabled because I sometimes launched accidentally those gesture actions.
KDE keyboard shortcut actions I configured using the following GUI:
(KDE: System settings > Shortcuts and Gestures)
In the screenshot above you can see META+V and META+B shortcuts are linked to move window to other screen. In xbindkey configuration those shortcuts are linked to 4 finger swipes by monitor locations (left / right). Nice gesture to move active MPV-videoplayer window to TV!
Short video demonstration about 4 fingers swipe up and down
- 4 fingers swipe up minimize / maximize all windows (toggle)
- 4 fingers swipe down presents all windows visible (toggle)
Final thoughs
I think synaptics driver offers much better feel for my trackpad but I cannot activate gestures for 3 and 4 fingers. Let's hope that it will get some new features in near future.
Mtrack driver seems to be working just fine but I still need to fine configure those pressure, distance and other settings to improve more my trackpad experience.
In Debian it seems to be almost impossible to try those other options like Touchegg. If you have some tips how to configure this Apple Magic Trackpad some other-way in Debian, please comment below.
Hello,
ReplyDeleteNice guide! I have one question do you have multi touch gestures working on your magic mouse aswell?
No I dont have multi gestures working on my Magic Mouse.
ReplyDelete