along with Aiptek, Hanwang, N-trig, Waltop, & WizardPen (Ace Cad, KYE Systems, UC-LOGIC) Tablets

Last updated: November 21, 2011

Preliminaries

1)You must haveX server 1.8 or up (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 Bamboo P & T HOW TO or section 2 of the linuxwacom 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 thexsetwacom MapToOutput Methodfor tablets on the Wacom drivers. MapToOutput has been extended to apply to the Nvidia proprietary driver, i.e.TwinViewstarting with the xf86-input-wacom-0.12.0 release. The second is theCoordinate Transformation Matrix Methodwhich works for all tablets. The third deals with getting either method to work through a reboot.

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 havexf86-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:

The output should contain the "device names" you are after. For example for the stylus it might be:Code: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

and select the name of the monitor, among the monitors you see in the output, that you would like the device on. Substitute that monitor name for VGA1 in the command. Using your "device name" (in quotes) from 'xinput list' you can now use the xsetwacom command:Code:xrandr

2)Code:xsetwacom set "device name" MapToOutput VGA1TwinView(NVidia proprietary driver binary). Support was added with the "xsetwacom: Support MapToOutput for TwinView" commit on 6-23-11 (in the 0.11.99+ tree) and is available in the xf86-input-wacom-0.12.0 release tar.

Choose the monitor you want the input tool on using "HEAD-0", "HEAD-1", etc., e.g.:

Code:xsetwacom set "device name" MapToOutput HEAD-0 or xsetwacom set "device name" MapToOutput HEAD-1Note: the above MapToOutput commands only apply to the current xrandr configuration, they will need to be re-applied with a restart (or rotation). So you'll have to set up the xsetwacomMapToOutputcommand(s) in a startup script. See below.

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:

Using the "Device name" (in quotes) enter in a terminal:Code:xinput --list

For example:Code:xinput list-props "Device Name"

This will give an output that contains your current 'Coordinate Transformation Matrix' for the device as the X server sees it:Code:xinput list-props "Wacom BambooFun 2FG 6x8 Pen stylus"

Now let's do a quick overview of the math involved. Notice that while it is an Identity matrix:Code:Coordinate Transformation Matrix (123): 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000

which has the effect of multiplying by 1, or in other words no transformation, the addition of a third vector value (beyond X & Y) makes it an affine transformation with homogeneous coordinates. We need to determine the transform matrix appropriate to the monitor you want to place the device on.Code:[ 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:

The third vector value w (the row) 0 0 1, with c8 or w always equal to 1, is what makes it affine.Code:[ x' ] [ c0 c1 c2 ] [ x ] [ y' ] = [ c3 c4 c5 ] * [ y ] [ 1 ] [ c6 c7 c8 ] [ w ]

The associated linear equations would be:

So c0 and c4 corresponds to the scaling on the X and Y axes, c2 and c5 corresponds to the translation (X & Y offsets) on those axes, and c6, c7, and c8 are always 0, 0 and 1.Code: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 below.

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.

Using fractions amounts to scaling from 0-1 so you end up with the following.Code: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 ]

With the c2 = 0.5 on the right matrix being the x offset.Code: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:xinput set-prop "Device name" --type=float "Coordinate Transformation Matrix" 0.5 0 0 0 1 0 0 0 1:Right monitor

Code:xinput set-prop "Device name" --type=float "Coordinate Transformation Matrix" 0.5 0 0.5 0 1 0 0 0 1b) Two monitors with different resolutions: example by Rumtscho

* image courtesy of Rumtscho

Setting up the linear transform (matrix).

Since for Rumtscho 'xinput --list' returned the stylus "Device name" as "Wacom BambooFun 2FG 6x8 Pen stylus" the appropriate xinput commands for device placement on the monitors are:Code: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:xinput set-prop "Wacom BambooFun 2FG 6x8 Pen stylus" --type=float "Coordinate Transformation Matrix" 0.333333 0 0 0 .711111 0 0 0 1:Right monitor

Code:xinput set-prop "Wacom BambooFun 2FG 6x8 Pen stylus" --type=float "Coordinate Transformation Matrix" 0.666666 0 0.333333 0 1 0 0 0 1c) Two monitors with one rotated: example courtesy of lejono

Left monitor 1600x1200 & right monitor (tablet pc) 1280x800. Tablet pc in laptop mode.

Code: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 ]:Left monitor

Code:xinput set-prop "Serial Wacom Tablet stylus" --type=float "Coordinate Transformation Matrix" 0.555555 0 0 0 1 0 0 0 1:Right monitor

* lejono established 6 decimal accuracy; matrices changed to reflect thatCode: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 rotional 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:

representing the equations:Code:[ x' ] [ cosA*c0 -sinA*c1 c2 ] [ x ] [ y' ] = [ sinA*c3 cosA*c4 c5 ] * [ y ] [ 1 ] [ c6 c7 c8 ] [ w ]

If we rotate the tablet 180 degrees to inverted, since cos(180) = -1 and sin(180) = 0 you end up with:Code:x' = (cosA*c0x + -sinA*c1y + c2) / w' y' = (sinA*c3x + cosA*c4y + c5) / w' w' = (c6x + c7y + c8) = 1

Code: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 ]:Right monitorrotated to inverted

Now what happens if we rotate the tablet pc to portrait mode? Note X & Y swap, becoming 800x1280. Since cos(270) = 0 and sin(270) = -1 you end up with this matrix.Code: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: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 ]:Right monitorrotated to portrait

Code:xinput set-prop "Serial Wacom Tablet stylus" --type=float "Coordinate Transformation Matrix" 0 0.333333 0.666666 -1 0 1 0 0 1II. Three Monitors - simple case

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:

* tested by mugginz, he used 3 decimal accuracyCode: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:xinput set-prop "Device name" --type=float "Coordinate Transformation Matrix" 0.333333 0 0 0 1 0 0 0 1:Center monitor

Code:xinput set-prop "Device name" --type=float "Coordinate Transformation Matrix" 0.333333 0 0.333333 0 1 0 0 0 1:Right monitor

Code:xinput set-prop "Device name" --type=float "Coordinate Transformation Matrix" 0.333333 0 0.666666 0 1 0 0 0 1Note: The xinput command does not last through a restart. See below.

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 theBamboo P & T HOW TOthread. 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:

or you could right click on the file and in Properties, in the Permission tab, check Execute as program. Then go to System->Preferences->Startup Applications and click on add and for the command write "sh /home/yourusername/.xsetwacom.sh" (without the quotes). You can also change your settings on the fly using the xsetwacom parameters in a terminal. They only apply during the current session.Code: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

Evdev rotation for those of you using evdev for touch seems to be broken currently on Natty. You can use the CTM to do it instead.

The CTM for none/normal or no rotation is the identity matrix:

and the command to implement it:Code:[ 1 0 0 ] [ 0 1 0 ] [ 0 0 1 ]

xinput set-prop "Wacom Bamboo 2FG 4x5 Finger" "Coordinate Transformation Matrix" 1, 0, 0, 0, 1, 0, 0, 0, 1

The CTM for ccw/left rotation is:

and the command to implement it:Code:[ 0 1 0 ] [-1 0 1 ] [ 0 0 1 ]

xinput set-prop "Wacom Bamboo 2FG 4x5 Finger" "Coordinate Transformation Matrix" 0, 1, 0, -1, 0, 1, 0, 0, 1

The CTM for half/inverted rotation is:

and the command to implement it:Code:[-1 0 1 ] [ 0 -1 1 ] [ 0 0 1 ]

xinput set-prop "Wacom Bamboo 2FG 4x5 Finger" "Coordinate Transformation Matrix" -1, 0, 1, 0, -1, 1, 0, 0, 1

The CTM for cw/right rotation is:

and the command to implement it:Code:[ 0 -1 1 ] [ 1 0 0 ] [ 0 0 1 ]

xinput set-prop "Wacom Bamboo 2FG 4x5 Finger" "Coordinate Transformation Matrix" 0, -1, 1, 1, 0, 0, 0, 0, 1

Use your touch "device name" fromxinput listof course.

## Bookmarks