I am trying to port a library from classic desktop to UWP. It all works like planned except for one thing. When I try to open a HID connection to the device(A wiimote) it won't connect if the permissions are on readwrite. It does work with read only permissions.
What could be the problem. The permissions in the manifest are set to the correct values.
EDIT: I checked the DeviceAccessStatus to see if the permissions are not good but it returns DeviceAccessStatus.Allowed
Manifest code
<Capabilities>
<Capability Name="internetClient" />
<DeviceCapability Name="humaninterfacedevice">
<Device Id="any">
<Function Type="usage:0005 *"/>
<Function Type="usage:0001 0005"/>
</Device>
</DeviceCapability>
</Capabilities>
Connection code
var selector = HidDevice.GetDeviceSelector(1, 5);
var devices = await DeviceInformation.FindAllAsync(selector);
if (devices.Count > 0)
{
foreach (var device in devices)
{
var deviceId = device.Id;
var foundDevice = await HidDevice.FromIdAsync(deviceId, FileAccessMode.ReadWrite); // Does not work always returns null
if (foundDevice == null)continue;
// if the vendor and product IDs match up
if (foundDevice.VendorId == VID && foundDevice.ProductId == PID)
{
// Unrelated code
Your code looks good except that the selector you are grabbing may be too selective. You might want to look at the text it is spitting out and remove anything that is unnecessarily narrow like the usage page or usage id.
I'd like to bet that there is a problem with your device specification in the manifest. Have a look at this article http://www.idevstream.com/?p=322. It will help you identify the usage page and usage id of your device. Once you've got that, I'll bet it will connect. Here's an example of one that I was stuck on until I read the article: https://github.com/MelbourneDeveloper/Ledger.Net/blob/master/src/Ledger.Net.UWPUnitTest/Package.appxmanifest
Also, have a look at this code in Hid.Net for connection: https://github.com/MelbourneDeveloper/Hid.Net/blob/80714078fc8772dd04b60648b0fe6974205a3d8f/Hid.Net.UWP/UWPHidDevice.cs#L95