Pressure sensitivity no longer works for HUION graphics tablet with resent Linux kernel
Closed, ArchivedPublic

Description

System Information
Arch Linux 4.10.2-1-ARCH
GTX 1070 with Nvidia driver

Blender Version
Broken: 2.78c , 2.78b and 2.78a

Worked: Worked before upgrading to 4.10. Works fine in 4.8.11-1-ARCH

After updating my system the pressure sensitivity from a HUION H610 no longer works. The pressure sensitivity does still work in other programs such as GIMP, MyPaint and Krita.

Other notes:
I have noticed that the input devices listed in $xinput are different concerning the Huion tablet from Linux 4.8 to 4.10

In 4.8.11-1-ARCH:
$ xinput | grep HUION
HUION TopwinT261 Pen id=14 [slave pointer (2)]
HUION TopwinT261 Mouse id=15 [slave pointer (2)]
HUION TopwinT261 Consumer Control id=16 [slave pointer (2)]
HUION TopwinT261 System Control id=17 [slave keyboard (3)]
HUION TopwinT261 Keyboard id=18 [slave keyboard (3)]

In 4.10.2-1-ARCH:
$ xinput | grep HUION
HUION TopwinT261 Pad id=10 [slave pointer (2)]
HUION TopwinT261 Consumer Control id=11 [slave pointer (2)]
HUION TopwinT261 Pen Pen (0) id=16 [slave pointer (2)]
HUION TopwinT261 Pen id=9 [slave keyboard (3)]
HUION TopwinT261 Consumer Control id=15 [slave keyboard (3)]

Thanks.

Details

Type
Bug

@atharva (athar) could you try this patch?

Added check for pen - which may solve the problem. Otherwise it prints out stylus & types.

diff --git a/intern/ghost/intern/GHOST_SystemX11.cpp b/intern/ghost/intern/GHOST_SystemX11.cpp
index 30cfac08153..6fa0459b644 100644
--- a/intern/ghost/intern/GHOST_SystemX11.cpp
+++ b/intern/ghost/intern/GHOST_SystemX11.cpp
@@ -2154,11 +2154,12 @@ static BOOL is_stylus(const char *name, const char *type)
 	int i;
 	static const char *tablet_stylus_whitelist[] = {
 		"stylus",
+		"pen",  // try this!
 		"wizardpen",
 		"acecad",
 		NULL
 	};
-
+printf("Is Stylus: '%s', '%s'\n", name, type);
 	for (i = 0; tablet_stylus_whitelist[i] != NULL; i++) {
 		if (name && match_token(name, tablet_stylus_whitelist[i]))
 			return TRUE;

@Campbell Barton (campbellbarton) yeah I tried that patch, but that didn't solve the issue.

I got the following output:

bin]$ ./blender
Color management: using fallback mode for management
Is Stylus: 'Virtual core pointer','(null)'
Is Stylus: 'Virtual core keyboard','(null)'
Is Stylus: 'Virtual core XTEST pointer','(null)'
Is Stylus: 'Virtual core XTEST keyboard','(null)'
Is Stylus: 'Power Button','KEYBOARD'
Is Stylus: 'Power Button','KEYBOARD'
Is Stylus: '  USB Keyboard','KEYBOARD'
Is Stylus: '  USB Keyboard','KEYBOARD'
Is Stylus: 'USB Optical Mouse','MOUSE'
Is Stylus: '1060PRO Pad','PAD'
Is Stylus: '1060PRO Pen','TABLET'
Sergey Sharybin (sergey) closed this task as Archived.Jun 2 2017, 12:20 PM

@atharva (athar), you can test something like P485 to try getting idea whether stylus gets rejected by something else.

Please also note that we can only fix bugs which we can reproduce, and this one is not reproducable without specific hardware. We'll be happy to help you trouibleshooting the issue on #blendercoders IRC room at irc.freenode.net tho!

Hello, I think I have a solution to this. I have a similar tablet [Huion 540] with the same problem. The solution is to use xinput to disable some duplicates entries the device makes.

$ xinput 
⎡ Virtual core pointer                          id=2    [master pointer  (3)]
⎜   ↳...
⎜   ↳ HUION 540 Pad                             id=10   [slave  pointer  (2)]
⎜   ↳ HUION 540 Consumer Control                id=11   [slave  pointer  (2)]
⎜   ↳ HUION 540 Pen Pen (0)                     id=18   [slave  pointer  (2)]
⎣ Virtual core keyboard                         id=3    [master keyboard (2)]
    ...
    ↳ HUION 540 Consumer Control                id=12   [slave  keyboard (3)]
    ↳ HUION 540 Pen                             id=17   [slave  keyboard (3)]

Disabling id 17 like so

$ xinput disable 17

makes pressure work again.
I don't know if this problem is blender's or the kernels.

I'm on Arch, Linux Kernel 4.9.56-1-lts

I think I am having the same issue. I have a Monoprice tablet (product ID 10594), which I think is just a Huion H610 with different branding. (It has the same specs, same appearance, and works with the Huion driver on Windows.) Pressure sensitivity doesn't work in Blender 2.79 on either Ubuntu 17.04 or 17.10, but works in Krita. I also tried a Blender 2.80 build (blender-2.80-83de7c4094b-linux-glibc219-x86_64) and got the same problem. Pressure sensitivity works correctly for me in Blender 2.79 on Windows 10.

As in @Jesus Balbastro (awesomehaircut)'s situation, the problem seems to be related to the fact that the tablet creates multiple xinput entries. I tried uncommenting some printfs in GHOST_SystemX11.cpp and got these results when running Blender 2.79 on the command line.

...
Tablet type:'(null)', name:'Virtual core pointer', index:0
Tablet type:'(null)', name:'Virtual core keyboard', index:1
Tablet type:'(null)', name:'Virtual core XTEST pointer', index:2
Tablet type:'(null)', name:'Virtual core XTEST keyboard', index:3
Tablet type:'KEYBOARD', name:'Power Button', index:4
Tablet type:'KEYBOARD', name:'Video Bus', index:5
Tablet type:'KEYBOARD', name:'Power Button', index:6
Tablet type:'PAD', name:'10594 Pad', index:7
Tablet type:'TABLET', name:'10594 Pen', index:8
	found stylus
Tablet type:'KEYBOARD', name:'MOSART Semi. 2.4G Keyboard Mouse', index:9
Tablet type:'MOUSE', name:'MOSART Semi. 2.4G Keyboard Mouse', index:10
Tablet type:'KEYBOARD', name:'Laptop_Integrated_Webcam_FHD: I', index:11
Tablet type:'KEYBOARD', name:'Dell WMI hotkeys', index:12
Tablet type:'KEYBOARD', name:'AT Translated Set 2 keyboard', index:13
Tablet type:'TOUCHPAD', name:'SynPS/2 Synaptics TouchPad', index:14
Tablet type:'KEYBOARD', name:'MOSART Semi. 2.4G Keyboard Mouse', index:15
Tablet type:'STYLUS', name:'10594 Pen Pen (0)', index:16
...

It appears that there is a TABLET device entry named "10594 Pen" and a STYLUS device entry named "10594 Pen Pen (0)", and the former gets detected as a stylus first, causing the latter to not be used as a stylus. I tried modifying the code in GHOST_SystemX11.cpp so that a TABLET device would not be considered a stylus. When I did this, the STYLUS device was detected as a stylus and pressure sensitivity worked. It looks like forcing GHOST_SystemX11::refreshXInputDevices to skip over the "10594 Pen" device fixes the issue for me. Unfortunately, disabling the "10594 Pen" device in xinput doesn't seem to work for me. Also, if I set my xorg configuration to ignore the device, it no longer shows up in xinput, but Blender still detects it, resulting in no pressure sensitivity.

The workaround I am using for now is to change line 2214 of GHOST_SystemX11.cpp from

(is_stylus(device_info[i].name, device_type) || (device_info[i].type == m_atom.TABLET)))

to

(is_stylus(device_info[i].name, device_type)))

I assume this workaround could cause trouble with some brands of tablets, but it seems to work well with the one I have. I would like to find a workaround that doesn't require modifying the Blender source, but @Jesus Balbastro (awesomehaircut)'s solution above didn't work for me.

I would be happy to help debug the issue, as I have an affected tablet and some software development experience. However, I have very little experience with handling X input devices.

Update: I must have done something wrong when I tried blacklisting the "10594 Pen" device in my xorg configuration, because I just tried it again, and instead of working with no pressure sensitivity, the tablet didn't work at all. Maybe I disabled the wrong device the first time I tried it.

I don't know why I didn't mention I enabled the device again. Somehow I didn't notice I did.
What works for me is to disconnect the tablet, run blender and disable and enable the device.

@Jesus Balbastro (awesomehaircut) That seems to work for me. Thanks for the workaround!

I don't know why I didn't mention I enabled the device again. Somehow I didn't notice I did.
What works for me is to disconnect the tablet, run blender and disable and enable the device.

Thank you, it works for me either.