Includes Aiptek, Hanwang, N-trig, Wacom, Waltop, & WizardPen (Ace Cad, KYE Systems, UC-LOGIC) Tablets
Last updated: September 19, 2012
Preliminaries
1) You must have X server 1.8 or up (Julia/Maverick has 1.9).
Sources
"xsetwacom: Support MapToOutput for TwinView" by Jason Gerecke
"xsetwacom: add "MapToOutput" parameters" by Peter Hutterer
"dix: add 3x3 transformation matrix xinput property for multi-head handling" by Peter Korsgaard
xf86-input-wacom from part II of the Wacom Bamboo Pen and Touch tablet HOW TO or section 2 of the Linux Wacom HOW TO.
"man xrandr"
"Transformation matrix"
"Matrix multiplication"
Miscellaneous Notes
First Wacom testers to report success were dsavi & mugginz.
First WizardPen (Genius MousePen 8x6/UC-LOGIC) testers to report success were elnaureth & 1script.
Summary
This HOW TO is divided into three sections. The first is the xsetwacom MapToOutput Method for tablets on the Wacom drivers. MapToOutput has been extended to apply to the Nvidia proprietary driver, i.e. TwinView starting with the xf86-input-wacom-0.12.0 release. The second is the Coordinate Transformation Matrix Method which works for all tablets. The third deals with getting either method to work through a reboot. Tablet PC rotation with CTM is in appendix 1.
Note: There is a X Server bug that prevents CTM from working correctly with xf86-input-evdev. If you apply a CTM to a input tool that uses xf86-input-evdev the associated cursor jumps around. Spurious lines are drawn in Gimp, Inkscape, etc. This is fixed in X Server 1.13.0. See Bugzilla Bug 49347. It's not clear which X Server version this bug first appeared in although it appears to affect at least the 1.11, 1.12 (Maya/Precise), and probably the 1.10 series.
I. xsetwacom MapToOutput Method - for Tablets using the xf86-input-wacom driver: Hanwang, N-trig, Wacom, & Waltop
The nice thing about MapToOutput is it does all of the matrix calculations for you automatically.
1) You must have xf86-input-wacom 0.10.9 (0.10.8+ after the 8-11-10 commit "xsetwacom: add "MapToOutput" parameters."; the default in Maverick is 0.10-8 ) if you have a 32-bit install. Otherwise if you have a 64-bit install you must have xf86-input-wacom 0.10.10+ (after the 1-11-11 commit "xsetwacom: fix 64-bit issues with MapToOutput").
First determine the "device name" of what you want bound on a specific screen. Your choices will be the stylus, eraser, or cursor (Wacom tablet mouse). In a terminal enter:
Code: Select all
xinput --list
Quotes added because you'll need them."Wacom BambooFun 2FG 6x8 Pen stylus"
The new method relies on a new xsetwacom command in the form:
Enter in a terminal:xsetwacom set <device name> MapToOutput VGA1
Code: Select all
xrandr
Code: Select all
xsetwacom set "device name" MapToOutput VGA1
Choose the monitor you want the input tool on using "HEAD-0", "HEAD-1", etc., e.g.:
Code: Select all
xsetwacom set "device name" MapToOutput HEAD-0
or
xsetwacom set "device name" MapToOutput HEAD-1
II. Coordinate Transformation Matrix Method - for all Tablets
While the following may seem a little daunting if you look at the examples you'll find it is not that hard. The code does the matrix multiplication for you. You are determining the matrix values by solving fractions involving your monitors' dimensions.
First determine the "Device name" of what you want bound on a specific screen. Your choices will be the stylus, eraser, or cursor (Wacom tablet mouse). In a terminal enter:
Code: Select all
xinput --list
Code: Select all
xinput list-props "Device Name"
Code: Select all
xinput list-props "Wacom BambooFun 2FG 6x8 Pen stylus"
Code: Select all
Coordinate Transformation Matrix (123): 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000
Code: Select all
[ 1 0 0 ]
[ 0 1 0 ]
[ 0 0 1 ]
What we will do with the transform is translate the currently assigned pixel coordinate vector X,Y of your tablet device to a new pixel coordinate vector X',Y'.
The numbers in the X server "Coordinate Transformation Matrix" are a 3x3 matrix read out row by row. Using an affine transformation means translation can be expressed with matrix multiplication. The equation we are looking at is in the form of:
Code: Select all
[ x' ] [ c0 c1 c2 ] [ x ]
[ y' ] = [ c3 c4 c5 ] * [ y ]
[ 1 ] [ c6 c7 c8 ] [ w ]
The associated linear equations would be:
Code: Select all
x' = (c0x + c1y + c2) / w'
y' = (c3x + c4y + c5) / w'
w' = (c6x + c7y + c8) = 1
Rumtscho describes how to calculate the general case in post #8.
I. Dual Monitors
a) Two monitors with the same resolution: is the simplest case.
Say both monitors are 1280x1024. You first set up the linear transform (matrix) like so.
Code: Select all
left: right:
[ 1280/(1280+1280) 0 0 ] [ 1280/(1280+1280) 0 1280/(1280+1280)]
[ 0 1024/1024 0 ] [ 0 1024/1024 0 ]
[ 0 0 1 ] [ 0 0 1 ]
Code: Select all
left: right:
[ 0.5 0 0 ] [ 0.5 0 0.5 ]
[ 0 1 0 ] [ 0 1 0 ]
[ 0 0 1 ] [ 0 0 1 ]
Now that you've determined the transform use the appropriate xinput command for the monitor you want your device on:
Left monitor:
Code: Select all
xinput set-prop "Device name" --type=float "Coordinate Transformation Matrix" 0.5 0 0 0 1 0 0 0 1
Code: Select all
xinput set-prop "Device name" --type=float "Coordinate Transformation Matrix" 0.5 0 0.5 0 1 0 0 0 1
* image courtesy of Rumtscho
Setting up the linear transform (matrix).
Code: Select all
left: right:
[ 1280/(1280+2560) 0 0 ] [ 2560/(1280+2560) 0 1280/(1280+2560)]
[ 0 1024/1440 0 ] [ 0 1440/1440 0 ]
[ 0 0 1 ] [ 0 0 1 ]
Left monitor:
Code: Select all
xinput set-prop "Wacom BambooFun 2FG 6x8 Pen stylus" --type=float "Coordinate Transformation Matrix" 0.333333 0 0 0 .711111 0 0 0 1
Code: Select all
xinput set-prop "Wacom BambooFun 2FG 6x8 Pen stylus" --type=float "Coordinate Transformation Matrix" 0.666666 0 0.333333 0 1 0 0 0 1
Left monitor 1600x1200 & right monitor (tablet pc) 1280x800. Tablet pc in laptop mode.
Code: Select all
left: right:
[ 1600/(1600+1280) 0 0 ] [ 1280/(1600+1280) 0 1600/(1600+1280)]
[ 0 1200/1200 0 ] [ 0 800/1200 0 ]
[ 0 0 1 ] [ 0 0 1 ]
Code: Select all
xinput set-prop "Serial Wacom Tablet stylus" --type=float "Coordinate Transformation Matrix" 0.555555 0 0 0 1 0 0 0 1
Code: Select all
xinput set-prop "Serial Wacom Tablet stylus" --type=float "Coordinate Transformation Matrix" 0.444444 0 0.555555 0 0.666666 0 0 0 1
Now if we rotate to tablet mode we are adding a rotational transformation. Let's use rotation by an angle A counter-clockwise about the origin. The functional form would be x' = xcosA − ysinA and y' = xsinA + ycosA but we want to make it affine so we can use multiplication. And we need to add it to the current matrix. So written in matrix form, it becomes something like:
Code: Select all
[ x' ] [ cosA*c0 -sinA*c1 c2 ] [ x ]
[ y' ] = [ sinA*c3 cosA*c4 c5 ] * [ y ]
[ 1 ] [ c6 c7 c8 ] [ w ]
Code: Select all
x' = (cosA*c0x + -sinA*c1y + c2) / w'
y' = (sinA*c3x + cosA*c4y + c5) / w'
w' = (c6x + c7y + c8) = 1
Code: Select all
right:
[ -1280/(1600+1280) 0 1280/1280 ]
[ 0 -800/1200 800/1200 ]
[ 0 0 1 ]
[ -0.444444 0 1 ]
[ 0 -0.666666 0.666666 ]
[ 0 0 1 ]
Code: Select all
xinput set-prop "Serial Wacom Tablet stylus" --type=float "Coordinate Transformation Matrix" -0.444444 0 1 0 -0.666666 0.666666 0 0 1
Code: Select all
right:
[ 0 800/(1600+800) 1600/(1600+800) ]
[ -1280/1280 0 1280/1280 ]
[ 0 0 1 ]
[ 0 0.333333 0.666666 ]
[ -1 0 1 ]
[ 0 0 1 ]
Code: Select all
xinput set-prop "Serial Wacom Tablet stylus" --type=float "Coordinate Transformation Matrix" 0 0.333333 0.666666 -1 0 1 0 0 1
Three monitors with the same resolution. You set up the linear transform and since we're scaling from 0-1 if all three monitors have the same resolution you'd end up with:
Code: Select all
left center right
[ 1280/(3*1280) 0 0 ] [ 1280/(3*1280) 0 1280/(3*1280) ] [ 1280/(3*1280) 0 (2*1280)/(3*1280) ]
[ 0 1024/1024 0 ] [ 0 1024/1024 0 ] [ 0 1024/1024 0 ]
[ 0 0 1 ] [ 0 0 1 ] [ 0 0 1 ]
left: center: right:
[ 0.3333 0 0 ] [ 0.3333 0 0.3333 ] [ 0.3333 0 0.6666 ]
[ 0 1 0 ] [ 0 1 0 ] [ 0 1 0 ]
[ 0 0 1 ] [ 0 0 1 ] [ 0 0 1 ]
* Rumtscho was able to use 4 decimal accuracy; matrices changed to reflect that
So now the xinput commands to set the device to the desired monitor are:
Left monitor:
Code: Select all
xinput set-prop "Device name" --type=float "Coordinate Transformation Matrix" 0.333333 0 0 0 1 0 0 0 1
Code: Select all
xinput set-prop "Device name" --type=float "Coordinate Transformation Matrix" 0.333333 0 0.333333 0 1 0 0 0 1
Code: Select all
xinput set-prop "Device name" --type=float "Coordinate Transformation Matrix" 0.333333 0 0.666666 0 1 0 0 0 1
III. To Have the Settings Last Through a Reboot
You have to apply the xinput or xsetwacom command with each restart. You should be able to add it to your xsetwacom start up script, if you have one. Otherwise run it from a convenient start up script. Sample start up scripts are attached to posts 1 & 2 of the Wacom Bamboo Pen and Touch tablet HOW TO thread. Add the appropriate command for each device (stylus, eraser, and cursor) to its section.
To set it up to auto-start, download a sample file or make your own, and rename it .xsetwacom.sh (or whatever you want) and place it in your home directory. Remember it will be a hidden file. To enable the xsetwacom commands in the .xsetwacom.sh file to apply to Xserver through a reboot you enter in a terminal:
Code: Select all
chmod +x ~/.xsetwacom.sh
Once the script is executable you can double click on it to apply it's settings or reboot to check the auto-start set up.
Note: In the sample scripts both "device name" and ID # are used. Be sure to check for yours using 'xinput --list' (without the quotes) in a terminal and use them. When you use a xorg.conf the "device names" will be stylus, eraser, touch, and pad. If you are hot plugging your tablet or other devices be sure to use "device name" as the ID # can change.
Appendix 1 - Tablet PC Rotation with CTM
Rather than axis inversion and swap for evdev rotation the CTM method can be used instead.
The CTM for none/normal or no rotation is the identity matrix:
Code: Select all
[ 1 0 0 ]
[ 0 1 0 ]
[ 0 0 1 ]
xinput set-prop "device name" "Coordinate Transformation Matrix" 1, 0, 0, 0, 1, 0, 0, 0, 1
The CTM for ccw/left rotation is:
Code: Select all
[ 0 -1 1 ]
[ 1 0 0 ]
[ 0 0 1 ]
xinput set-prop "device name" "Coordinate Transformation Matrix" 0, -1, 1, 1, 0, 0, 0, 0, 1
The CTM for half/inverted rotation is:
Code: Select all
[-1 0 1 ]
[ 0 -1 1 ]
[ 0 0 1 ]
xinput set-prop "device name" "Coordinate Transformation Matrix" -1, 0, 1, 0, -1, 1, 0, 0, 1
The CTM for cw/right rotation is:
Code: Select all
[ 0 1 0 ]
[-1 0 1 ]
[ 0 0 1 ]
xinput set-prop "device name" "Coordinate Transformation Matrix" 0, 1, 0, -1, 0, 1, 0, 0, 1
Use your "device name" from xinput list of course.