Customize Huion tablet buttons on Linux
Tuesday, 3 November 2020
The “Huion Kamvas Pro (2019)” comes with 16 physical buttons and two touch strips along the sides of the tablet. On Windows, you can configure the buttons to send custom keystrokes (e.g. toggling painting tools or changing brush size). However, the key mapping is mirrored from the left to the right side, so you can only have 10 distinct assignments.
On Linux, the pen works out-of-the-box on my Ubuntu machines, but there’s no good way to customize the buttons. You can force X to use the wacom drivers (xf86-input-wacom) which lets you use xsetwacom to customize some of the buttons, but the touch strips don’t seem to be supported, nor do buttons 13 through 16 (the bottom right buttons).
I have published a Python program that watches the raw data coming from the tablet and sends commands using xdotool. It currently has a few rough edges: setting it up requires a bit of compilation in order to link to libxdo, and you also need to have permission to read from the /dev/hidraw device which you don’t have by default. For the permissions, I’m sure someone more knowledgeable can suggest a better way to set things up, but you can run the program as root or a setuid program, or manually grant read access on the /dev/hidraw file.
Configuring it should be pretty easy. Here are some buttons that I have configured for use with Krita, for example:
4=ctrl+s
5=ctrl+z
6=ctrl+shift+equal
7=ctrl+minus
Note that using this program doesn’t replace whatever button events get sent to X, which might cause problems for buttons 1 through 3 if you haven’t no-op’d them with xsetwacom.