We found many users couldn’t use their pen/stylus in our Unity app at all, while others could.
We tracked it down to this option in the Windows pen settings: “Let me use my pen as a mouse in some desktop apps”.
When ticked, the pen doesn’t work in our Unity app, even though from the description it sounds like exactly what we want.
By “not work”, I mean that it registers no mouse or touch events when the screen is touched, released, and does not register while touching the screen, ie none of GetMouseButtonDown(), GetMouseButtonUp() or GetMouseButton() ever return true, and Input.touchCount remains zero throughout.
We can advise users of a work-around by telling them to untick that option, but many users have this, and we’d rather be able to deal with it in-app. Also I’m not sure whether this is an option users could reasonably want to leave on for other purposes (presumably so).
So how do we deal with it in-app?
I tried creating a test app using Unity’s new InputSystem, which replaces the old Input class. In this case it CAN detect pen events regardless of the Windows settings, but the new class gets a lot of other events wrong, and would require entirely replacing the previous input system, possibly in any third party code we use too. So we’d rather avoid this.
Can we make the Input class work with pens regardless of the Windows setting?
Can you give me more information on your pen configuration? Particularly,
What brand is it?
Do you have Windows Ink enabled in the tablet driver app? The tablets can often be configured to skip Windows Ink and be wintab only. We don’t have a wintab implementation, so we wouldn’t get those events.
I’m expecting that this is happening when users have their pen in wintab only mode.
We’re doing some work on improving the pen experience in Unity, so the story will improve. But we aren’t supporting wintab right now because we don’t have the bandwidth to do so.
I am able to get events with a Huion H950P stylus and tablet I have with the settings you reported. Please let us know what version of Unity and what styluses your users are having trouble with.
We have found the same result on all laptops we’ve tried: Surface Book, Surface Pro, and Toshiba X30t, using the pens that came with the laptops.
I don’t use the pen other than for testing, so have never changed any of the default settings (I’m on a Surface Book), and I don’t know much about pens. But it looks like wintab is something that has to be downloaded and installed separately? I haven’t done that, so I guess I don’t have it. By default, my pen was working, because I had “Let me use my pen as a mouse in some desktop apps” disabled. But if I tick that option, it stops working.
We are using Unity 2019.2.17f1. Has something been fixed related to this in a newer version?
I attach a simple test project. It allows a cube to be dragged around with mouse, touch or pen, and shows text about the events received.
We do still get Input.mousePosition updating to follow the pen, but can’t detect when the pen touches the screen.
Phil, I’m surprised to hear it can work at all. Did you try that setting in both states? It’s only when ticked that it doesn’t work.
Can you take a look at the videos in the attached zip and compare them with the behavior you are seeing? These are from my HP Spectre x360 laptop pen. The video names state whether the “Use my pen as a mouse in some desktop apps” status.
If you are just using the pen that came with the laptops without installing any additional Wacom software, you probably aren’t using wintab. To just use wintab you have to 1) have wintab.dll in system32 AND have Windows Ink turned off in the vendor-specific settings app. Which you probably don’t have for a build-in stylus.
@RobAtApex , sorry for the delayed response on this. Have you opened an issue on this yet? I would not expect that we get mouse move events but no up and down events at all.
In the meantime, I will see if I can get information on Microsoft on what this setting is supposed to do. Given my knowledge of WM_POINTER events, it should act as a mouse if the app isn’t handling it as a pen.
Yes I opened ticket #823570, but not sure I opened it in the right way and only getting occasional response there.
Agreed I would have expected it just turns pen events into mouse events for apps, but obviously not. I get the impression the option was previously worded differently and said something about “legacy apps”, so maybe that’s what it now means by “some apps”, although still not sure what that means. Again, I would have thought it just meant turning pen events into mouse events.