0

I'm trying to connect to a footswitch to receive signals from it. The loop has correctly displayed the name of my device in the first element, but it can't connect in the next line. I've added the footswitch's manifest. I've checked the usagePage, usageId, vendorId, and productId many times to ensure they are not incorrect. I'm not sure what to check next. Can anyone assist me?

private async void Initialize()
{
    // vendorId, productId
    string selector = HidDevice.GetDeviceSelector(usagePage, usageId);
    var devices = await DeviceInformation.FindAllAsync(selector);

    if (devices.Count > 0)
    {
        // Log all devices
        foreach (var deviceInfo in devices)
        {
            System.Diagnostics.Debug.WriteLine($"Found device: {deviceInfo.Id} - {deviceInfo.Name}");
        }

        var device = await HidDevice.FromIdAsync(devices[0].Id, Windows.Storage.FileAccessMode.Read);
        if (device != null)
        {
            device.InputReportReceived += OnInputReportReceived;
            System.Diagnostics.Debug.WriteLine($"Footswitch connected: {devices[0].Id}");
        }
        else
        {
            System.Diagnostics.Debug.WriteLine("Failed to connect to the footswitch.");
        }
    }
    else
    {
        System.Diagnostics.Debug.WriteLine("No footswitch found.");
    }
}
<DeviceCapability Name="humaninterfacedevice">
    <Device Id="vidpid:3553 B001 usb">
        <Function Type="usage:000C 0001" />
     </Device>
</DeviceCapability>

I careful checked usagePage, usageId, vendorId, productId. I also checked driver.I believe my footswitch is functioning normally at this time. This is because when I press on it, it acts as if I am clicking a mouse.

Corvus
  • 99
  • 1
  • 7
  • did you read all of the relevant [notes](https://learn.microsoft.com/en-us/uwp/api/windows.devices.humaninterfacedevice.hiddevice.fromidasync?view=winrt-22621#remarks) in the docs? "The first time this method is invoked by a store app, it should be called from a UI thread in order to display the consent prompt. After the user has granted consent, the method can be invoked from any application thread." – Jason Jul 05 '23 at 12:21

0 Answers0