microsoft / microsoft/WindowsAppSDK
PointerDevice.GetPointerDevice(...) fails for stylus and touch
- Dominant language
- C++
- Stars
- 4.7k
- Forks
- 471
- Avg merge
- 3d 13h
- Merged PRs (30d)
- 28
Description
### Describe the bug
`Windows.Devices.Input.PointerDevice.GetPointerDevice(e.Pointer.PointerId);` works when using mouse input, but fails on my Surface tablet using touch and stylus with message: "The parameter is incorrect. Failed to get pointer information."
This works in UWP, it is blocking for our upgrade to WASDK.
### Steps to reproduce the bug
This simple event handler will reproduce the issue:
```
private void Grid_PointerPressed(object sender, PointerRoutedEventArgs e)
{
try
{
PointerDevice d = Windows.Devices.Input.PointerDevice.GetPointerDevice(e.Pointer.PointerId);
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message);
}
}
```
### Expected behavior
I'd expect touch and stylus to work just like mouse does.
### Screenshots

### NuGet package version
Windows App SDK 1.7.1: 1.7.250401001
### Packaging type
Packaged (MSIX)
### Windows version
Windows 11 version 23H2 (22631, November 2023 Update)
### IDE
Visual Studio 2022
### Additional context
_No response_
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the Grid_PointerPressed handler and the Windows.Devices.Input.PointerDevice.GetPointerDevice call shown in the issue. Reproduce on a packaged Windows App SDK 1.7.1 app using mouse, touch, and stylus on Windows 11 23H2, then trace the pointer information path. Done means touch and stylus resolve the pointer device without the parameter error, matching mouse behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- api, desktop
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100