2020年3月29日 星期日

Running Wacom Bamboo Slate client application on Ubuntu Bionic


I have several Wacom Bamboo Slate, which is a kind of graphics tablet in different size. The most special feature of Bamboo Slate is that you could use the customized pen to draw on a real paper on the top of the tablet, and you could get the digital image at the same time. It also supports "Live mode" so the tablet could behave like a normal graphic tablet.

Unfortunately, the corresponding client application only supported on Android, iOS, Windows, and OSX. Here shows how to make it work on one of the Linux distribution, Ubuntu Bionic.

Tuhi project


There is an open source project Tuhi https://github.com/tuhiproject/tuhi is trying to support the client application of the device.


Build Tuhi


The biggest issue that may happen to you on Ubuntu Bionic is the one of the build prerequisites, pygobject-3.0 should be 3.30 or higher. The corresponding debian package on Ubuntu Bionic is
python-gi-dev, and the latest version Bionic provides is 3.26.x (2020 March). 3.30 is only available on Eoan or later.

There are two solutions. First, you may build the code in a python virtual environment, which currently provides PyGObject 3.34.0. Or tweak the source code to unlock the dependency check to allow to use elder version of pygobject. I tried the latter solution with 3.26, and both of the normal and live modes work well for me.


Run Normal Mode in a Python Virtual Environment

After building the code, you will get several runner with the suffix .devel to run the application in development mode. You may execute tuhi.devel directly.


Run Live Mode in a Python Virtual Environment

Regarding live mode, the application needs more system permission because it will create a HID device, and need to communicate with the Linux kernel to create device nodes. You may use the following command to execute the live mode runner:

sudo <your python interpreter of your virtual environment> tools/tuhi-live.py

so you could get enough permission to run the live runner.


The Difference Between Normal and Live Mode From System Perspective

The normal mode is mainly based on the session bus of dbus mechanism and GTK3. The live mode is mainly based on being a HID device of Linux kernel.

Both of normal and live mode are established by communicating with the rule of the device firmware. Check the Protocol and Interactions class of the protocol module.


Get the Correct Dimension in Live Mode

If you are using the device in the normal mode, it works like a charm. If you are using the device in the live mode, you may be aware of the distortion of what you are drawing. This is caused by the mismatch of the ratio between your monitor dimension and your bamboo slate. By setting the slate dimension it will help.

There are several ways to match the ratio. Here is mine:
  • Constrain the tablet in one monitor only. This may be optional for you because I use multiple monitors.
  • Remove the out-of-range part of the table panel to match the monitor dimension.
Thanks for FLOSS. We already have the corresponding tools to achieve the above tasks. I will illustrate what I used in the following sessions.


Constrain the Tablet in One Monitor Only

Firstly let's check if the device has been regarded as one of the input device of your X.

$ xinput
⎡ Virtual core pointer                    id=2 [master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer              id=4 [slave  pointer  (2)]
⎜   ↳ Logitech M310                            id=10 [slave  pointer  (2)]
⎜   ↳ Logitech K520                            id=11 [slave  pointer  (2)]
⎜   ↳ SynPS/2 Synaptics TouchPad              id=15 [slave  pointer  (2)]
⎜   ↳ Wacom A4 - Office - Slate Pen stylus    id=17 [slave  pointer  (2)]
⎣ Virtual core keyboard                    id=3 [master keyboard (2)]
    ↳ Virtual core XTEST keyboard              id=5 [slave  keyboard (3)]
    ↳ Power Button                            id=6 [slave  keyboard (3)]
    ↳ Video Bus                                id=7 [slave  keyboard (3)]
    ↳ Power Button                            id=8 [slave  keyboard (3)]
    ↳ Sleep Button                            id=9 [slave  keyboard (3)]
    ↳ Chicony USB2.0 Camera: Chicony          id=12 [slave  keyboard (3)]
    ↳ Intel HID events                        id=13 [slave  keyboard (3)]
    ↳ AT Translated Set 2 keyboard            id=14 [slave  keyboard (3)]
    ↳ Logitech K520                            id=16 [slave  keyboard (3)]

Neat, we have "Wacom A4 - Office - Slate Pen stylus" as one of the input device now. The let's check with a more specific tool by:

xsetwacom list
Wacom A4 - Office - Slate Pen stylus id: 17 type: STYLUS

The listed name is exactly the input device name.


Man xsetwacom will Tell You a LOT

You may use "xsetwacom list parameters" to check your Wacom device status, and then setup them via "xsetwacom set <device> <parameter> <value>".

For example, inquiry by

$ xsetwacom get "Wacom A4 - Office - Slate Pen stylus" Mode
Absolute

Tip: "man setwacom" to know how many parameters are available.

If it is not in the absolute mode, change it by

$ xsetwacom set "Wacom A4 - Office - Slate Pen stylus" Mode Absolute

Inquiry the monitor output source:

$ xrandr -q

According to its output, we could constrain the tablet in the target monitor via
$ xsetwacom set "Wacom A4 - Office - Slate Pen stylus" MapToOutput eDP-1
You may be aware of the change of the value of "Coordinate Transformation Matrix" output by "xinput list-props <your wacom device name>" before and after the MapToOutput setting.

Finally, make sure the value of "Wacom Tablet Area" is in the 1:1 ratio of your monitor.

$ xinput list-props "Wacom A4 - Office - Slate Pen stylus"
Device 'Wacom A4 - Office - Slate Pen stylus':
Device Enabled (169): 1
Coordinate Transformation Matrix (171): 0.545455, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000
Device Accel Profile (300): 0
Device Accel Constant Deceleration (301): 1.000000
Device Accel Adaptive Deceleration (302): 1.000000
Device Accel Velocity Scaling (303): 10.000000
Device Node (292): "/dev/input/event18"
Wacom Tablet Area (732): 2500, 6362, 28700, 21100
Wacom Rotation (733): 0
Wacom Pressurecurve (734): 0, 0, 100, 100
Wacom Serial IDs (465): 1, 1, 2, 0, 0
Wacom Serial ID binding (735): 0
Wacom Pressure Threshold (736): 26
Wacom Sample and Suppress (737): 2, 4
Wacom Enable Touch (738): 0
Wacom Hover Click (739): 1
Wacom Enable Touch Gesture (740): 0
Wacom Touch Gesture Parameters (741): 0, 0, 250
Wacom Tool Type (742): "STYLUS" (731)
Wacom Button Actions (743): "Wacom button action 0" (744), "Wacom button action 1" (745), "Wacom button action 2" (746), "None" (0), "None" (0), "None" (0), "None" (0), "Wacom button action 3" (747)
Wacom button action 0 (744): 1572865
Wacom button action 1 (745): 1572866
Wacom button action 2 (746): 1572867
Wacom button action 3 (747): 1572872
Wacom Pressure Recalibration (748): 1
Wacom Panscroll Threshold (749): 1300
Device Product ID (293): 1386, 1
Wacom Debug Levels (750): 0, 0
That's it. Enjoy your drawing!


沒有留言:

張貼留言