Results 1 to 10 of 98

Thread: HOW TO Setup a Wacom Tablet with Multi-Monitors in Maverick and Natty

Threaded View

  1. #1
    Join Date
    Nov 2008
    Beans
    9,635
    Distro
    Ubuntu 12.04 Precise Pangolin

    HOW TO Setup a Wacom Tablet with Multi-Monitors in Maverick and Natty

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

    Last updated: November 21, 2011

    Preliminaries
    1) You must have X 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 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.


    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:
    xinput --list
    The output should contain the "device names" you are after. For example for the stylus it might be:
    "Wacom BambooFun 2FG 6x8 Pen stylus"
    Quotes added because you'll need them.

    The new method relies on a new xsetwacom command in the form:
    xsetwacom set <device name> MapToOutput VGA1
    Enter in a terminal:
    Code:
    xrandr
    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:
    xsetwacom set "device name" MapToOutput VGA1
    2) TwinView (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-1
    Note: 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 xsetwacom MapToOutput command(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:
    Code:
    xinput --list
    Using the "Device name" (in quotes) enter in a terminal:
    Code:
    xinput list-props "Device Name"
    For example:
    Code:
    xinput list-props "Wacom BambooFun 2FG 6x8 Pen stylus"
    This will give an output that contains your current 'Coordinate Transformation Matrix' for the device as the X server sees it:
    Code:
    Coordinate Transformation Matrix (123):	1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000
    Now let's do a quick overview of the math involved. Notice that while it is an Identity matrix:
    Code:
    [ 1 0 0 ]
    [ 0 1 0 ]
    [ 0 0 1 ]
    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.

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

    The associated linear equations would be:
    Code:
    x' = (c0x + c1y + c2) / w'
    y' = (c3x + c4y + c5) / w'
    w' = (c6x + c7y + c8) = 1
    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.

    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.
    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               ]
    Using fractions amounts to scaling from 0-1 so you end up with the following.
    Code:
      left:           right:
    [ 0.5 0 0 ]     [ 0.5 0 0.5 ]
    [ 0   1 0 ]     [ 0   1 0   ]
    [ 0   0 1 ]     [ 0   0 1   ]
    With the c2 = 0.5 on the right matrix being the x offset.

    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 1
    b) Two monitors with different resolutions: example by Rumtscho

    * image courtesy of Rumtscho

    Setting up the linear transform (matrix).
    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               ]
    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:
    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 1
    c) 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:
    Code:
    xinput set-prop "Serial Wacom Tablet stylus" --type=float "Coordinate Transformation Matrix" 0.444444 0 0.555555 0 0.666666 0 0 0 1
    * lejono established 6 decimal accuracy; matrices changed to reflect that

    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:
    Code:
    [ x' ]   [ cosA*c0 -sinA*c1 c2 ]   [ x ]
    [ y' ] = [ sinA*c3  cosA*c4 c5 ] * [ y ]
    [ 1  ]   [ c6       c7      c8 ]   [ w ]
    representing the equations:
    Code:
    x' = (cosA*c0x + -sinA*c1y + c2) / w'
    y' = (sinA*c3x +  cosA*c4y + c5) / w'
    w' = (c6x      +  c7y      + c8) = 1
    If we rotate the tablet 180 degrees to inverted, since cos(180) = -1 and sin(180) = 0 you end up with:
    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 monitor rotated to inverted:
    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
    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:
       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 monitor rotated 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 1
    II. 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:
    Code:
      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      ]
    * tested by mugginz, he used 3 decimal accuracy
    * 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 1
    Note: 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 the Bamboo P & T 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:
    chmod +x ~/.xsetwacom.sh
    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.

    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:
    Code:
     [ 1  0  0 ]
     [ 0  1  0 ]
     [ 0  0  1 ]
    and the command to implement it:
    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:
    Code:
     [ 0  1  0 ]
     [-1  0  1 ]
     [ 0  0  1 ]
    and the command to implement it:
    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:
    Code:
     [-1  0  1 ]
     [ 0 -1  1 ]
     [ 0  0  1 ]
    and the command to implement it:
    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:
    Code:
     [ 0 -1  1 ]
     [ 1  0  0 ]
     [ 0  0  1 ]
    and the command to implement it:
    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" from xinput list of course.
    Last edited by Favux; November 22nd, 2011 at 04:19 AM.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •