Page MenuHome

Tablet not drawing - moving pen causes drawing to break
Needs Triage, NormalPublic

Description

System Information
Operating system: MacOS 10.15.5 (19F101)
Graphics card: AMD Radeon Pro 5300M 4 GB
Intel UHD Graphics 630 1536 MB
(I am on a MacBook Pro (16-inch, 2019))

Blender Version
Broken: 2.83.2 2020-07-09, also 2.90.0 2020-07-27

Worked: None

Short description of error
I have 2 graphics tablets - a Huion 610Pro and an XP-PEN Artist 12 - and both exhibit the same behavior: unable to draw in 2d mode.

Exact steps for others to reproduce the error

  1. Open Blender
  2. Choose 2D Animation from the splash screen
  3. Can draw using the mouse
  4. Bring tablet pen onscreen (don't need to click, simply moving the cursor with the pen does it)
  5. Can no longer draw with mouse(!)
  6. Cannot draw with pen

Both tablets work perfectly fine in other applications (eg Photoshop). I actually bought the XPPen because I thought the Huion was old and maybe that was the issue.
The bizarre thing is that simply moving the cursor with the tablet causes the issue. You do NOT need to touch pen to tablet and try to draw.

I tried this with 'clean' settings (i.e Load Default) and also with Emulate 3 Button Mouse.

I also turned on Screencast keys to see if some command was being issued by the tablets, but I see nothing coming through.

Event Timeline

Ok, looking around more I found this bug report: https://developer.blender.org/T62565

In it there is discussion of tablet pressure. So, I decided to run Blender 2.83.2 with --debug-events and see, and sure enough that does seem to be the issue.

wm_event_do_handlers: Handling event
wmEvent  type:1 / LEFTMOUSE, val:2 / RELEASE,
         prev_type:1 / LEFTMOUSE, prev_val:2 / RELEASE,
         shift:0, ctrl:0, alt:0, oskey:0, keymodifier:0, is_repeat:0,
         mouse:(1836,636), ascii:'', utf8:'', pointer:0x7fd10cc2b028
 tablet: active: 1, pressure 0.0000, tilt: (0.0000 0.0000)

Now, in bug https://developer.blender.org/T62565 it says that a fix was put in place for 2.83. As far as I can tell both 2.83 and 2.9 still exhibit this behavior.

So - the questions are:

  1. Was this actually implemented/committed/rolled out?
  2. How can I fix this so I can actually use my tablet?

More observations. I compiled my own version so I could add some debugging information and hard coded values to see what's going on.

In gpencil_paint.c in the gpencil_draw_apply_event method the event->tablet.pressure is always 0 when it comes from my tablets. If I hard-code in a value later by inserting this around line 2800

if (p->pressure < 0.001f) {
  p->pressure = 0.75f;
  if (G.debug & G_DEBUG) {
    printf("GPencil - gpencil_draw_apply_event manually setting pressure: %.4f\n", p->pressure);
  }
}

Then I get the debug string and I can actually draw! Of course the pressure never changes, but it is a step in the right direction.
Whatever is firing the event is not reading the pressure from my tablet. Could this be configuration on my side? Perhaps. But I did no configuration to get the pen to work in Photoshop, and the Pen Tablet tool reports varying pressure.

The other thing I have noticed, digging into this more, is that after trying to use the tablet, the debug messages will ALWAYS print out

tablet: active: 1 pressure: 0.0000

even if I go back to trying to draw with the mouse.
Perhaps this is expected behavior?

FYI - annotation_draw_invoke in annotate_paint.c DOES work and does get correct tablet pressure.

Today is the first day I am looking at the Blender code, so I am not confident I will find the source of the event information.

Sorry for the spam. Last comment on this, I promise.