uwp开发中自定义Hid设备打不开设备句柄

Package.appxmanifest文件中舔加


<DeviceCapability Name="humaninterfacedevice">

<Device Id="any">

<Function Type="usage:ff20 0001"/> <!--custom-->

<Function Type="usage:ff21 0003"/> <!--custom-->

<Function Type="usage:0001 *"/> <!--standard game controll-->

<Function Type="usage:ff00 *"/>

</Device>

</DeviceCapability>


MainPage.xaml.cs文件中代码

public MainPage()
{
this.InitializeComponent();
StartSending();
}
public async void StartSending()
{

var devices = await DeviceInformation.FindAllAsync(HidDevice.GetDeviceSelector(0xff20,0x0001, 0x0f0d, 0x015d));

DeviceInformation device=null;

if (devices.Any())

{

device = devices.FirstOrDefault();

HidDevice hidDevice = await HidDevice.FromIdAsync(device.Id, FileAccessMode.ReadWrite);

if (hidDevice != null)

{

while (true)

{

var outReport = hidDevice.CreateOutputReport();

byte[] buffer = new byte[(int)outReport.Data.Capacity];

// fill data

outReport.Data = buffer.AsBuffer();

await hidDevice.SendOutputReportAsync(outReport);

await Task.Delay(500);

}

}

}

}

这个Hid设备读写操件在Win32桌面开发中是正常的。但在UWP中不正常

问题如下:

HidDevice hidDevice = await HidDevice.FromIdAsync(device.Id, FileAccessMode.ReadWrite);

hidDevice 获取的返回值是null这是什么原因,有人知道吗?

是下位机的描述符问题,还是上位机的权限问题?