Page MenuHome

Microsoft Surface pens does not send first events when moves
Closed, ResolvedPublic

Description

Microsoft Surface Pro 2 using Microsoft Pen
Windows 10 64 bits
Pen driver update to last version.
Full system info: P736

Versions: Blender 2.79b, Blender 2.8 and Blender 2.8 greasepencil-object branch.

Areas affected: Any area of Blender using pen events: Texture Paint, Grease Pencil, etc.

When draw using a microsoft pen, the first events are missing. This problem is not present in Wacom products.

You can see the problems in a video created by @Daniel Martinez Lara (pepeland) : https://t.co/Od5T5csS1B?amp=1

To analysis the problem, we have added some printf lines to modal operator GPENCIL_OT_draw to print the events received (you can see them in the console window in the video)

printf("Event: %d \n", event->type);
 if (event->tablet_data != NULL) {
     printf("Event: %d Pressure: %f\n", event->type, event->tablet_data->Pressure);
 }

Debug with the lines above, we have verified that the event is not received for the first movements of the pen and only after a while. After that, all events work perfect.

The error could be a driver problem, or maybe some threshold limit defined internally in Blender.

This error is important because a lot of new hardware is using this pen and the bug makes unusable the pen for Blender.

Event Timeline

There are a very large number of changes, so older changes are hidden. Show Older Changes
LazyDodo (LazyDodo) added a comment.EditedJun 22 2018, 8:23 PM

kinda feels like some gesture recognition layer is sitting on the evens until it determines, 'nahhhhhh it's nothing' could be worth looking into if we're getting a WM_TABLET_QUERYSYSTEMGESTURESTATUS message, and if we do report back we don't want any of it..

The windows "Flicks" are disabled (or must be) , I forget mention in the video that programs like Krita, Sketch Book, Gimp are working fine without problem with the same laptop, only in Blender I notice this issue

Good point, I was thinking on that in all my tests with playing diferent wintab drivres, windows flicks, programs options, etc but Krita works fine with both, wintab or pointer input. The only program that i found with similar problem is Mischief (2D drawing program) but as I comented in the video
Mischief can "recreate" the first part of the stroke

Bastien Montagne (mont29) lowered the priority of this task from Needs Triage by Developer to Confirmed, Medium.

That’s gonna be hard for us to investigate, since afaik none of main devs have that kind of hardware? So I think it’s in your desk @Antonio Vazquez (antoniov) ;)

I’d suggest you run Blender with --debug-events option, and then go checking in ghost event handling code what’s happening exactly.

I haven't this hardware either. I will try to instruct @Daniel Martinez Lara (pepeland) to make the debug.

If you need any help I have Surface Pro 4 with pen.

I've fixed a seemingly identical bug to this locally affecting my Monoprice MP22. I compared it to my tablet test program and it looks like the primary issue was not specifically reactivating things on focus, and potentially violating wintab spec by initializing in an invalid state (apparently you have to open with context disabled if using certain flags, then enable after)

@Colby Klein (shakesoda) I don't know how the tab events are handled, but it's good to know you had something similar in your tablet and that this fix solves the issue.

We need someone that knows how Blender events work to review your patch. @Campbell Barton (campbellbarton) @Sergey Sharybin (sergey) Could you take a look at the patch?

probably easier if they look directly at D3573 which appear to be the same patch.

Yes, both are the same diff.

Good to hear some news about that!

@Colby Klein (shakesoda) We have been testing your changes in a Surface 4 and according to @Daniel Martinez Lara (pepeland) the problem is not solved (he did the test because I haven't a Surface)

Any idea? test?

@Antonio Vazquez (antoniov) hm, I see. I thought it was the same bug, since it matched what I was seeing, but it must be separate. This does fix my MP22 and possibly other non-Wacom tablets when drawing on GP objects though. Assuming the patch doesn't cause any regressions (I haven't noticed any at least), it'd still be good to merge.

I've also noticed there is an issue related to annotate, it (seemingly) activates on tweak, which has an unwanted threshold for drawing. This messed up my testing for a while after I'd fixed the regular GP issue and has a similar appearance.

@Colby Klein (shakesoda) I don't know enought the event code to answer your question about commit your change or not. Could you ask to Campbell or Sergey (they know how works this area)

OK. I have updated the revision title/summary to reflect the test result.

@Sergey Sharybin (sergey) @Campbell Barton (campbellbarton) can one of you review D3573?

The problem was resolved using the "official" Microsoft Pen.

@Antonio Vazquez (antoniov) Hi Antonio. I have surface book2 15' and official Microsoft Surface Pen and I can definitely still see the issue in all builds of blender 2.8 :(. The latest build I just tested is from October 13.

@Maciej (MaciejGliwa) The problem disappears when you use the "official" Microsoft pen... any other pen gets the error.

@Antonio Vazquez (antoniov) I am using the latest official microsoft pen and there is definitely an issue at the beginning of the stroke, it is not correctly registering the movement of the pen. I can record my screen and share with you the video of what is happening exactly.

With the latest official microsoft pen works better because "reconstruct" the first part of the stroke, with others pens the first part of the stroke is not created, but yes,
is definitely an issue at the beginning of the stroke in blender

@Daniel Martinez Lara (pepeland) I see what you mean. Yeah, it creates a stroke, it is just that the very beginning of the stroke is always a straight line. It makes it really difficult to draw "circular" shapes, especially when you draw on a small section of the screen.

Yes, is really really annoying, a little trick is if you make a "double click" taping twice in the screen, now you can draw small circle.
I have the same problem with MIschief (link)
but not with Krita, photoshop, mypaint, etc,

@Daniel Martinez Lara (pepeland) Ahh, thanks for the tip! Also (please correct me if that is off topic) but I also noticed that grease pencil is super fast on my another desktop computer with wacom tablet (cintiq 24hd), but on my surface book 2 15' with pretty much exactly the same specs it is much much slower. Did you experience that on your surface book Daniel? (I saw that you use one on the video you shared)

Be sure that you have the surface attached to the keyboard base, GP need a proper graphic card and the Nvidia card is in the base not in the screen part

Maciej (MaciejGliwa) added a comment.EditedOct 14 2018, 8:05 PM

@Daniel Martinez Lara (pepeland) Sorry my bad, after investigating for quite some time I found out that my battery setting wasn't set to "best performance" on the windows task bar, once I set it correctly now blender is blasting fast, yay! Now if only we could get that little issue with stroke solved it would be perfect.

yes the issue with stroke is so annoying in deed, can you check if you have the same problem with mischief link

@Daniel Martinez Lara (pepeland) Ok, so I was just about to return my surface book to store after restoring the entire windows system to factory settings when I read your email....lol...so I actually installed everything back again to test mischief. And it actually works with no problems at all!

I am very much on the fence with Surface Book 2 15'. The specs are great, but the microsoft pen is horrible to use because it has only one button which is super hard to press. And there is no alternatives to the pen, bamboo ink pen apparently doesn't support surface book 2 15'....

Might just return it and see if there will be better pens in the future and you guys will figure out the pen drivers in blender.

I will have Surface Book for few more days so if you want me to test anything just let me know, I will gladly do it.

I registered here for the first time just to comment:

I'm using an HP x360 laptop with an HP active pen and have the same problem. I installed WinTab drivers because Blender does not support Windows Ink and since then the pressure sensitivity works great.

However, I experience the same problem where Blender does not register the first part of the stroke und only seems to accept a "click" when the pen starts to move.

I hope this problem can get fixed soon-ish, because working with 2.8 and a pen is simply put AMAZING. Nothing even comes close to the productivity I can achieve in texture painting - and of course with Grease Pencil.

Lutz Scharf (Luzifer) reopened this task as Open.Dec 8 2018, 8:11 PM

I find how to resolve this problem
setting -> device -> pen and window ink ,then check this
you can setting follow my picture

my English is terrible

I find how to resolve this problem
setting -> device -> pen and window ink ,then check this
you can setting follow my picture


my English is terrible

Hi, would you mind sharing a screenshot in English? Google Translate says "Please allow me to use the pen as mouse in some desktop applications". I do not have that checkbox in my settings.

Same here. I do not have that checkbox in my settings.

my windows10 version is rs5

and my computer is surfce pro4 use surfce pen
and i installed wintab driver

Thanks! I do not have a Surface device but the Windows version SHOULD be correct. I suppose this is workaround only available to Surface.

I will try to find out if this can be activated on my HP laptop as well.

Either way, this does not make this less of a bug, because I don't think Blender wants to be a "legacy application" in this area, especially with Grease Pencil as its new feature.

some applications (like pint tool sai,Photoshop cs3) use “ wintab ” don’t have pen pressure on win10 tablet,I guess blender use “wintab”

other applications (like clip studio pro) use“ tablet api“ is ok

grease pencil is great tool :)

Sorry, has this made it into the daily builds by now? Neither of them (blender-2.79.0-git.d753726ce712-windows64, blender-2.80.0-git.7f40d553f903-windows64) fix the issue for me (Toshiba/Wacom Pen on Windows 10 convertible, https://developer.blender.org/T57538). Thanks for your efforts!

T55589 has not been resolved.

I am using the Microsoft Surface Book with Microsoft Pen. The first events still do not show in Grease Pencil drawings.
After it was announced that it was resolved, I downloaded builds after January 14 and still have the same problem.
Is there a certain build I should be using that has the fix?

It should be in all the latest builds.

@Christopher Peerman (chris_82), any other ideas for solving this?

The builds after January 14 work with my HP x360 laptop and HP pen.

I installed WinTab drivers, maybe this is the crucial difference?

With the Microsoft Surface Book and Surface Pen.
I use the wintab drivers also. The issue is as described. If I draw a horizontal line and then try to start at the horizontal line to make vertical lines starting at the horizontal. The first part of the verticle lines do not start at the horizontal line. There is a delay before ink starts.

I just tried the latest blender-2.80-3d8cbb534f82-win64 build on my Surface Book and it is working fine on there. I don't have the WinTab drivers for the Surface Book installed, I do however have the drivers for my Wacom Bamboo installed. When I get the chance I'll try different combinations of drivers and see if that has any effect. Are there any other settings you may have changed at all? I'll take a look through the various Pen & Ink settings and see if this makes any difference.

I just tried enabling the 'LegacyPenInteractionModel' which a few people have recommended around the internet using the following commands and it definitely doesn't work with the fix. I'll take a look and see if I can work out any ways of improving it with legacy mode enabled.

Enable (from Administrator command prompt):
reg add HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Pen /v LegacyPenInteractionModel /t REG_DWORD /d 1 /f

Disable (from Administrator command prompt):
reg add HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Pen /v LegacyPenInteractionModel /t REG_DWORD /d 0 /f

@Jerrry Earls (midije) could you check if you're using the current version of Windows 10. Also if you've added the following key to your registry could you remove it (or set it to 0) and see if that fixes it or not?

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Pen]
"LegacyPenInteractionModel"=dword:00000001

I am running the latest Windows 10 Version 1809.
I did try the legacy command a while back and then reverted back after it did not work. The last 2.8 build I used was posted on the 18th. This evening I will download the latest 2.8 Build and delete the wintab drivers and try without. Where can I get the Wacom Bamboo drivers?

For my CTH-470 tablet I got the driver from here https://www.wacom.com/en/support/product-support/drivers. I did my test earlier with the Wacom drivers uninstalled.

Unfortunately without having a machine with the problem present it may take a while to track down. I'll have a play around on my machine and see if I can get legacy mode to work as well as this may also shed some light on the problem

I just tried enabling the 'LegacyPenInteractionModel' which a few people have recommended around the internet using the following commands and it definitely doesn't work with the fix. I'll take a look and see if I can work out any ways of improving it with legacy mode enabled.

I can confirm for my system that this key needs to be disabled in order for the changes to work (recent nightly builds, referred to in my first comment). I am not certain of the state of the drivers from previous experiments (i.e. whether WinTab is used somehow), the hardware driver used is by Wacom (7.3.4.48).

Thanks for solving this!

I've taken a look at the legacy behaviour it seems that with the new behaviour we get WM_POINTERDOWN and WM_LBUTTONDOWN, followed by WM_POINTERUPDATE, WM_TOUCH and WM_MOUSEMOVE events. However with machines running legacy versions of Windows we only get WM_POINTERDOWN and WM_POINTERUPDATE events only, until after a long delay and we'll get the WM_LBUTTONDOWN and WM_MOUSEMOVE events.

I'm going to need to do some research to see if there is anything to cause this. I one approach I want to look at is to correctly handle the WM_POINTERxxx events and switch us over to pointer mode for compatible versions of Windows, this should make Blender more compatible with older versions of Windows.

I made sure Legacy was disabled on my Surface Book. I downloaded the 2.8 build on the 28th.
Still had the issue. I uninstalled Wintab drivers and still had the same issue. As for as I know to use wintab drivers you just install them without having to make any changes in Device Manager.

Is it something I am missing or not understanding?

Just to give an update to this. I've been working on this and I hope to have something put up for code review later this week. The new version uses the WM_POINTERxxx messages for Touch and Stylus and the GetPointerInfo, GetPointerPenInfo and GetPointerTouch info. So far it seems to be working well, I've just got a little more work to do with it and spend some time testing it. I also hope that this implementation will also fix issues some users have seen on Windows 8.

Great, thank you guys for your work!

I'm not able to verify myself if this fix is working, so please let us know if there are further issues.

I just pulled master and built this change. The fix improved the behavior, but pen interaction is still broken.

I've made a quick video showing the new behavior:
https://youtu.be/KPz4_Ffxv8M

In this video, I do a texture paint with the pen 3 different times. Each time, I touchdown, draw, then release. After I finish a stroke, I hit CTRL-Z to erase the entire stroke I drew. I draw each stroke continuously, with constant pressure and speed, until I lift up.

The paint update cuts in/out, resulting in long periods of time where the new line being drawn is invisible. I'm using a standard Windows 10 PC, build 1809, and the default Microsoft Pen driver.

I just downloaded the latest build this evening and now in grease pencil I can connect lines as expected. The pen starts at the beginning of strokes.
I do see an unwanted speck within lines sometimes but this change has definitely solved the pen starting at first event issue for me.

I am using Microsoft Surface Book with the latest Windows 10 1809 build.

Keep up the good work!!

Did these issues also happen with 2.80 before this fix? What about the 2.79 daily build? If the problem is not caused specifically by yesterday's change, can you create a new bug report for them?

@Imran Peerbhai (ipeerbhai), if I'm understanding correctly, the issue is that it's not refreshing the display but the resulting stroke is correct? I assume the stroke stepping artifacts are from the image being low resolution.

@Brecht Van Lommel (brecht) -- yes, your understanding is correct -- resulting stroke is correct. I just tried 2d drawing instead of texture painting and that worked!

While testing, I noticed a few bugs related to pen in 2d drawing:

  1. I can't repro it reliably, but I notice a very faint streak between last mouse position and first pen touchdown under some circumstances ( distance, first run ). It's a bug people can live with ( CTRL-Z when it happens ), and seems to be rare.
  2. Fast strokes lag behind pen position by about 1/2". This is pretty consistent, and is dependent on how fast I move the pen. At slow speeds, pen doesn't really lag.

I also noticed these two bugs in Texture painting( unrelated ) :

  1. The "disappearing stroke" bug as in the video. ( Video was just a flat color, with single color pen strokes painted on top to a low poly STL ).
  2. All painted textures "disappear" forever, cannot draw any textures at all, if painted STL object placed into a collection.

I love the new 2.8 changes, and had a blast using the texture paint. Should I file any of those issues I noticed as bugs?
Thanks!

where can i test 2.79 build? On blender.org there is 2.79 from March 22?

@Imran Peerbhai (ipeerbhai): yes ,you can file bug reports for those things.

@Paul (rice): note that this is only fixed in the 2.80 daily build, not the 2.79 build.

Paul (rice) added a comment.EditedApr 5 2019, 4:48 PM

Ok so ive tested 2.8 daily build from Lazydodo link. It is still broken when wintab enabled and when windows ink is enabled it only kinda helps. Right now there is no lag with the stroke at start but spacing of brush in texture paint mode looks like its a random value.
Is there a plan to repair this also on 2.79?

I have found that since the fix on Suface Pen first events that now Grese Pencil effects do not work and the clean up loose points under strokes do not work.

Please create new bug reports for those issues.