Non-wacom tablets broken on Blender in linux? #43367

Closed
opened 2015-01-22 13:13:14 +01:00 by Bastien Montagne · 19 comments

Disclaimer: I already spent one whole day investigating that, so report will be quite long.

Affects at least Blender 2.69 to 2.73 (and latest master). Suspect it is related to newest Xorg somehow.

Issue

On my OS (debian64 testing, up-to-date), in Blender, is have no pressure when using my tablet (Genius 450). Each stroke gets the init pressure, and keep it until the end.
Same tablet works perfectly under Gimp (not so relevant, afaik GDK uses new X11 device handling) and Krita (which uses very similar code as Blender when handling tablets).

Note I tried another (even more name-less) tablet, with exact same results.

Question 1: can anybody else confirm the issue?

Investigations

Issue is, X11 Ghost does not get 'tablet' events (XDeviceMotionEvent) once pen is down. When pen is only hovering (without being pressed), those events reach ghost without any issue.

Here is a (cleaned up) example of events as processed by GHOST_SystemX11::processEvents:

[...]

pen is hovering tablet...

processEvents:
    TabletEvent
    MotionNotify
processEvents:
    TabletEvent
    MotionNotify

pen goes down

processEvents:
    TabletEvent (p: 473)  <- only time we get some pressure info
    MotionNotify
    ButtonPress

pen is drawing

processEvents:
    MotionNotify
processEvents:
    MotionNotify
[...]
processEvents:
    MotionNotify

pen goes up

processEvents:
    MotionNotify
    ButtonRelease

pen is hovering tablet again...

processEvents:
    TabletEvent
    MotionNotify
processEvents:
    TabletEvent
    MotionNotify

Built krita to add prints there too, and tablet events reach krita in all cases (pressed or hovering pen).

So from this it looks like Blender does (or does not) do something that prevents it to get XDeviceMotionEvent's once pen is pressed. Odd thing is, afaik there were no changes here since my last fix (in 2014/01), and at that time it worked perfectly. So would expect some kind of change in API or behavior of recent X libs.

I also used XGetDeviceMotionEvents to get 'history' of tablet events, and there pressure changes are available. So it’s clearly a problem of not getting some X11 events we should get.

Unfortunately, I’m starting to be short on ideas to try here, not an X11 expert at all… :(

Disclaimer: I already spent one whole day investigating that, so report will be quite long. Affects at least Blender 2.69 to 2.73 (and latest master). Suspect it is related to newest Xorg somehow. # Issue On my OS (debian64 testing, up-to-date), in Blender, is have no pressure when using my tablet (Genius 450). Each stroke gets the init pressure, and keep it until the end. Same tablet works perfectly under Gimp (not so relevant, afaik GDK uses new X11 device handling) and Krita (which uses very similar code as Blender when handling tablets). Note I tried another (even more name-less) tablet, with exact same results. Question 1: can anybody else confirm the issue? # Investigations Issue is, X11 Ghost does not get 'tablet' events (XDeviceMotionEvent) once pen is down. When pen is only hovering (without being pressed), those events reach ghost without any issue. Here is a (cleaned up) example of events as processed by `GHOST_SystemX11::processEvents`: ``` [...] ``` # pen is hovering tablet... ``` processEvents: TabletEvent MotionNotify ``` ``` processEvents: TabletEvent MotionNotify ``` # pen goes down ``` processEvents: TabletEvent (p: 473) <- only time we get some pressure info MotionNotify ButtonPress ``` # pen is drawing ``` processEvents: MotionNotify ``` ``` processEvents: MotionNotify ``` ``` [...] ``` ``` processEvents: MotionNotify ``` # pen goes up ``` processEvents: MotionNotify ButtonRelease ``` # pen is hovering tablet again... ``` processEvents: TabletEvent MotionNotify ``` ``` processEvents: TabletEvent MotionNotify ``` Built krita to add prints there too, and tablet events reach krita in all cases (pressed or hovering pen). So from this it looks like Blender does (or does not) do something that prevents it to get XDeviceMotionEvent's once pen is pressed. Odd thing is, afaik there were no changes here since my last fix (in 2014/01), and at that time it worked perfectly. So would expect some kind of change in API or behavior of recent X libs. I also used `XGetDeviceMotionEvents` to get 'history' of tablet events, and there pressure changes are available. So it’s clearly a problem of not getting some X11 events we should get. Unfortunately, I’m starting to be short on ideas to try here, not an X11 expert at all… :(
Author
Owner

Changed status to: 'Open'

Changed status to: 'Open'
Author
Owner

Added subscriber: @mont29

Added subscriber: @mont29
Member

Added subscriber: @JulianEisel

Added subscriber: @JulianEisel
Member

Have a Wacom here, so I doubt I can help on the coding side. But I recently learned about a nice tool to print out X11 events called "xev" maybe that's helpful for troubleshooting.

Have a Wacom here, so I doubt I can help on the coding side. But I recently learned about a nice tool to print out X11 events called "xev" maybe that's helpful for troubleshooting.

This issue was referenced by 0d5ebabe43

This issue was referenced by 0d5ebabe437dcf5ce48685667d479d4706ba9d76
Author
Owner

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'
Author
Owner

Closed by commit 0d5ebabe43.

Closed by commit 0d5ebabe43.

Added subscriber: @CedricPAILLE

Added subscriber: @CedricPAILLE

Hi,

We had a similar problem here with Wacom tablets, I was able to make the pressure work. The problem is in GHOST_WindowX11, the events are overwritten by the X11's macros (DeviceMotionNotify), once for the sytus and secondly for the eraser case (line 587-607).

Here's the patch:

diff --git i/intern/ghost/intern/GHOST_SystemX11.cpp w/intern/ghost/intern/GHOST_SystemX11.cpp
index d4693e9..1a80efd 100644
--- i/intern/ghost/intern/GHOST_SystemX11.cpp
+++ w/intern/ghost/intern/GHOST_SystemX11.cpp
@@ -1181,7 +1181,10 @@ GHOST_SystemX11::processEvent(XEvent *xe)
 		default:
 		{
 #ifdef WITH_X11_XINPUT
-			if (xe->type == m_xtablet.MotionEvent) {
+			if (xe->type == m_xtablet.MotionEvent ||
+				xe->type == m_xtablet.MotionEventEraser ||
+				xe->type == m_xtablet.PressEvent ||
+				xe->type == m_xtablet.PressEventEraser) {
 				XDeviceMotionEvent *data = (XDeviceMotionEvent *)xe;
 				const unsigned char axis_first = data->first_axis;
 				const unsigned char axes_end = axis_first + data->axes_count;  /* after the last */
diff --git i/intern/ghost/intern/GHOST_SystemX11.h w/intern/ghost/intern/GHOST_SystemX11.h
index bc35b6c..378f07d 100644
--- i/intern/ghost/intern/GHOST_SystemX11.h
+++ w/intern/ghost/intern/GHOST_SystemX11.h
@@ -286,6 +286,12 @@ public:
 		int MotionEvent;
 		int ProxInEvent;
 		int ProxOutEvent;
+		int PressEvent;
+
+		int MotionEventEraser;
+		int ProxInEventEraser;
+		int ProxOutEventEraser;
+		int PressEventEraser;
 
 		int PressureLevels;
 		int XtiltLevels, YtiltLevels;
diff --git i/intern/ghost/intern/GHOST_WindowX11.cpp w/intern/ghost/intern/GHOST_WindowX11.cpp
index 125ec26..0b3df19 100644
--- i/intern/ghost/intern/GHOST_WindowX11.cpp
+++ w/intern/ghost/intern/GHOST_WindowX11.cpp
@@ -577,7 +577,7 @@ void GHOST_WindowX11::initXInputDevices()
 	if (version && (version != (XExtensionVersion *)NoSuchExtension)) {
 		if (version->present) {
 			GHOST_SystemX11::GHOST_TabletX11 &xtablet = m_system->GetXTablet();
-			XEventClass xevents[10], ev;
+			XEventClass xevents[8], ev;
 			int dcount = 0;
 
 			/* With modern XInput (xlib 1.6.2 at least and/or evdev 2.9.0) and some 'no-name' tablets
@@ -588,7 +588,7 @@ void GHOST_WindowX11::initXInputDevices()
 			if (xtablet.StylusDevice) {
 				DeviceMotionNotify(xtablet.StylusDevice, xtablet.MotionEvent, ev);
 				if (ev) xevents[dcount++] = ev;
-				DeviceButton1Motion(xtablet.StylusDevice, xtablet.MotionEvent, ev);
+				DeviceButtonPress(xtablet.StylusDevice, xtablet.PressEvent, ev);
 				if (ev) xevents[dcount++] = ev;
 				ProximityIn(xtablet.StylusDevice, xtablet.ProxInEvent, ev);
 				if (ev) xevents[dcount++] = ev;
@@ -596,13 +596,13 @@ void GHOST_WindowX11::initXInputDevices()
 				if (ev) xevents[dcount++] = ev;
 			}
 			if (xtablet.EraserDevice) {
-				DeviceMotionNotify(xtablet.EraserDevice, xtablet.MotionEvent, ev);
+				DeviceMotionNotify(xtablet.EraserDevice, xtablet.MotionEventEraser, ev);
 				if (ev) xevents[dcount++] = ev;
-				DeviceButton1Motion(xtablet.EraserDevice, xtablet.MotionEvent, ev);
+				DeviceButtonPress(xtablet.EraserDevice, xtablet.PressEventEraser, ev);
 				if (ev) xevents[dcount++] = ev;
-				ProximityIn(xtablet.EraserDevice, xtablet.ProxInEvent, ev);
+				ProximityIn(xtablet.EraserDevice, xtablet.ProxInEventEraser, ev);
 				if (ev) xevents[dcount++] = ev;
-				ProximityOut(xtablet.EraserDevice, xtablet.ProxOutEvent, ev);
+				ProximityOut(xtablet.EraserDevice, xtablet.ProxOutEventEraser, ev);
 				if (ev) xevents[dcount++] = ev;
 			}
 
Hi, We had a similar problem here with Wacom tablets, I was able to make the pressure work. The problem is in GHOST_WindowX11, the events are overwritten by the X11's macros (DeviceMotionNotify), once for the sytus and secondly for the eraser case (line 587-607). Here's the patch: ``` diff --git i/intern/ghost/intern/GHOST_SystemX11.cpp w/intern/ghost/intern/GHOST_SystemX11.cpp index d4693e9..1a80efd 100644 --- i/intern/ghost/intern/GHOST_SystemX11.cpp +++ w/intern/ghost/intern/GHOST_SystemX11.cpp @@ -1181,7 +1181,10 @@ GHOST_SystemX11::processEvent(XEvent *xe) default: { #ifdef WITH_X11_XINPUT - if (xe->type == m_xtablet.MotionEvent) { + if (xe->type == m_xtablet.MotionEvent || + xe->type == m_xtablet.MotionEventEraser || + xe->type == m_xtablet.PressEvent || + xe->type == m_xtablet.PressEventEraser) { XDeviceMotionEvent *data = (XDeviceMotionEvent *)xe; const unsigned char axis_first = data->first_axis; const unsigned char axes_end = axis_first + data->axes_count; /* after the last */ diff --git i/intern/ghost/intern/GHOST_SystemX11.h w/intern/ghost/intern/GHOST_SystemX11.h index bc35b6c..378f07d 100644 --- i/intern/ghost/intern/GHOST_SystemX11.h +++ w/intern/ghost/intern/GHOST_SystemX11.h @@ -286,6 +286,12 @@ public: int MotionEvent; int ProxInEvent; int ProxOutEvent; + int PressEvent; + + int MotionEventEraser; + int ProxInEventEraser; + int ProxOutEventEraser; + int PressEventEraser; int PressureLevels; int XtiltLevels, YtiltLevels; diff --git i/intern/ghost/intern/GHOST_WindowX11.cpp w/intern/ghost/intern/GHOST_WindowX11.cpp index 125ec26..0b3df19 100644 --- i/intern/ghost/intern/GHOST_WindowX11.cpp +++ w/intern/ghost/intern/GHOST_WindowX11.cpp @@ -577,7 +577,7 @@ void GHOST_WindowX11::initXInputDevices() if (version && (version != (XExtensionVersion *)NoSuchExtension)) { if (version->present) { GHOST_SystemX11::GHOST_TabletX11 &xtablet = m_system->GetXTablet(); - XEventClass xevents[10], ev; + XEventClass xevents[8], ev; int dcount = 0; /* With modern XInput (xlib 1.6.2 at least and/or evdev 2.9.0) and some 'no-name' tablets @@ -588,7 +588,7 @@ void GHOST_WindowX11::initXInputDevices() if (xtablet.StylusDevice) { DeviceMotionNotify(xtablet.StylusDevice, xtablet.MotionEvent, ev); if (ev) xevents[dcount++] = ev; - DeviceButton1Motion(xtablet.StylusDevice, xtablet.MotionEvent, ev); + DeviceButtonPress(xtablet.StylusDevice, xtablet.PressEvent, ev); if (ev) xevents[dcount++] = ev; ProximityIn(xtablet.StylusDevice, xtablet.ProxInEvent, ev); if (ev) xevents[dcount++] = ev; @@ -596,13 +596,13 @@ void GHOST_WindowX11::initXInputDevices() if (ev) xevents[dcount++] = ev; } if (xtablet.EraserDevice) { - DeviceMotionNotify(xtablet.EraserDevice, xtablet.MotionEvent, ev); + DeviceMotionNotify(xtablet.EraserDevice, xtablet.MotionEventEraser, ev); if (ev) xevents[dcount++] = ev; - DeviceButton1Motion(xtablet.EraserDevice, xtablet.MotionEvent, ev); + DeviceButtonPress(xtablet.EraserDevice, xtablet.PressEventEraser, ev); if (ev) xevents[dcount++] = ev; - ProximityIn(xtablet.EraserDevice, xtablet.ProxInEvent, ev); + ProximityIn(xtablet.EraserDevice, xtablet.ProxInEventEraser, ev); if (ev) xevents[dcount++] = ev; - ProximityOut(xtablet.EraserDevice, xtablet.ProxOutEvent, ev); + ProximityOut(xtablet.EraserDevice, xtablet.ProxOutEventEraser, ev); if (ev) xevents[dcount++] = ev; } ```
Author
Owner

Grrr… new x11 seems picky here.

Thanks for the patch, have a brand new wacom tablet, so will check (and hopefully apply!) soon. :)

Grrr… new x11 seems picky here. Thanks for the patch, have a brand new wacom tablet, so will check (and hopefully apply!) soon. :)

:)
Yes, would be interesting to know if it fixes for non-wacom tablets too...

:) Yes, would be interesting to know if it fixes for non-wacom tablets too...
Author
Owner

Applied, thanks again for the patch! :D

Applied, thanks again for the patch! :D

You're welcome !

Glad to hear it's working

You're welcome ! Glad to hear it's working

Changed status from 'Resolved' to: 'Open'

Changed status from 'Resolved' to: 'Open'
Storm reopened this issue 2015-03-05 17:08:36 +01:00

Added subscriber: @Storm-14

Added subscriber: @Storm-14

I'm still experiencing this issue as of today, with the latest Arch Linux package:
https://www.archlinux.org/packages/community/x86_64/blender/

My tablet is a Genius i608x, using udev drivers. Pressure works in Krita (painting program).

system-info.txt

I'm still experiencing this issue as of today, with the latest Arch Linux package: https://www.archlinux.org/packages/community/x86_64/blender/ My tablet is a Genius i608x, using udev drivers. Pressure works in Krita (painting program). [system-info.txt](https://archive.blender.org/developer/F147439/system-info.txt)
Author
Owner

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'
Bastien Montagne self-assigned this 2015-03-05 17:14:10 +01:00
Author
Owner

Please do not reopen bugs yourself, this is manager task. If you had checked carefully, you would have seen that Arch package is 31/01, while last commit related to this report in Blender is from two weeks later (13/02)…

Furthermore, please always test with latest official version (from our buildbot), non-official builds such as distribution packages are not accepted in a bug report.

Please **do not** reopen bugs yourself, this is manager task. If you had checked carefully, you would have seen that Arch package is 31/01, while last commit related to this report in Blender is from two weeks later (13/02)… Furthermore, please **always** test with **latest official** version (from [our buildbot](https://builder.blender.org/download)), non-official builds such as distribution packages are not accepted in a bug report.

My apologies. I thought it's OK to change status, since the system allows me to do it...

This issue was said to be fixed on 27/01 (in a forum thread about the issue, linking to the 27/01 commit above: https://developer.blender.org/T43367#284437 ) which is 4 days before the Arch package build date so I expected it should already be in there.

I'm going to contact the Arch package maintainer then.

My apologies. I thought it's OK to change status, since the system allows me to do it... This issue was said to be fixed on 27/01 (in a forum thread about the issue, linking to the 27/01 commit above: https://developer.blender.org/T43367#284437 ) which is 4 days before the Arch package build date so I expected it should already be in there. I'm going to contact the Arch package maintainer then.
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
5 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#43367
No description provided.