Share via

[UWP]Windows.Devices.Input.PointerDevice.GetPointerDevices() - Does it return a list of same objects - why?

AxD 706 Reputation points
2020-10-30T21:37:10.393+00:00

In Microsoft Learn, at Retrieve pointer properties it reads:

Note The values returned by the properties discussed here are based on all detected pointer devices: Boolean properties return non-zero if at least one device supports a specific capability, and numeric properties return the maximum value exposed by any one pointer device.

So, if I get the above right, then the following code (taken from the same paragraph in that documentation) ...

IReadOnlyList<PointerDevice> pointerDevices = Windows.Devices.Input.PointerDevice.GetPointerDevices();  

... would return a list of PointerDevice objects - and each and every object in this list returned the same information?

I don't understand: Why should it make sense to iterate through this list then, if each item in the iteration returned the exact same values?

Developer technologies | Universal Windows Platform (UWP)
0 comments No comments

Answer accepted by question author

Yan Gu - MSFT 2,681 Reputation points
2020-11-02T06:03:19.93+00:00

Hello,
Welcome to Microsoft Q&A,

and each and every object in this list returned the same information?

The information of each item in the pointerDevices list is not exactly the same.

The Pointer Device Type value of a pen will be Pen, and the Is External value of a pen will be True, while the Pointer Device Type value of a mouse will be Mouse, and the Is External value of a mouse will be False. The Max Contacts value shows the number of devices of a certain type. The Physical Device Rect value of each item is the same, because the bounding rectangle supported by the input device is the same and the Screen Rect value of each item is the same, also because the bounding rectangle supported by the input device is the same. You can select the Simulator option instead of using Local Machine to run the project, and you will view the different value.

You can use PointerDevice instance to detect the presence of input devices and retrieve the capabilities and attributes of each device. Please refer to the sample for specific applications.


If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

Was this answer helpful?

0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.