Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Pen doesn't work on some Windows laptops, depending on settings

Discussion in 'Windows' started by RobAtApex, May 21, 2020.

  1. RobAtApex

    RobAtApex

    Joined:
    Jun 19, 2017
    Posts:
    21
    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?

    Thanks,
    Rob.
     
  2. KevinWelton

    KevinWelton

    Joined:
    Jul 26, 2018
    Posts:
    239
    Hi Rob,

    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.

    -Kevin
     
  3. Phil_Z

    Phil_Z

    Unity Technologies

    Joined:
    Oct 7, 2019
    Posts:
    36
    Hi Rob,

    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.

    - Phil
     
  4. RobAtApex

    RobAtApex

    Joined:
    Jun 19, 2017
    Posts:
    21
    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.

    Thanks,
    Rob.
     

    Attached Files:

  5. KevinWelton

    KevinWelton

    Joined:
    Jul 26, 2018
    Posts:
    239
    Rob,

    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.
     

    Attached Files:

  6. RobAtApex

    RobAtApex

    Joined:
    Jun 19, 2017
    Posts:
    21
    Yep, that's the same behaviour. When the setting is ticked, the cube doesn't move and no mouse or touch begin/end events are ever received.

    Do you think this is an issue with Unity?

    Also, I can confirm that wintab.dll is not present in the system32 folder.
     
  7. KevinWelton

    KevinWelton

    Joined:
    Jul 26, 2018
    Posts:
    239
    @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.
     
  8. RobAtApex

    RobAtApex

    Joined:
    Jun 19, 2017
    Posts:
    21
    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.