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.