1

Topic: HidSharp.Exceptions.DeviceIOException on HidDevice.Open, Windows only

I have a consistent issue specifically to Windows. On Linux, this exact code runs without issue, but on Windows it throws a DeviceIOException every time, but only for this one device. This is running on HidSharp 2.1.0, .NET Core 3.0.

using System;
using System.Linq;
using HidSharp;
using HidSharp.Reports.Input;

namespace HidTest
{
    class Program
    {
        static void Main(string[] args)
        {
            var devices = HidSharp.DeviceList.Local.GetHidDevices();
            var tablets = devices.Where(d => d.GetFriendlyName() == "Intuos PS").ToList();
            tablets.OrderBy(t => t.GetFriendlyName());
            Device = tablets[0];
            Console.WriteLine(Device.GetMaxInputReportLength());
            var descriptor = Device.GetReportDescriptor();
            Console.WriteLine(descriptor);
            Reciever = descriptor.CreateHidDeviceInputReceiver();
            Reciever.Start(Device.Open());
            Reciever.Received += PacketReceived;
            Console.Read();
        }

        static HidDevice Device;
        static HidDeviceInputReceiver Reciever;

        static void PacketReceived(object sender, EventArgs e)
        {
            var buffer = new byte[Device.GetMaxInputReportLength()];
            Reciever.TryRead(buffer, 0, out var rpt);
            Console.WriteLine(BitConverter.ToString(buffer));
        }
    }
}

This throws this exception every time

Exception has occurred: CLR/HidSharp.Exceptions.DeviceIOException
An unhandled exception of type 'HidSharp.Exceptions.DeviceIOException' occurred in HidSharp.dll: 'Unable to open HID class device (\\?\hid#vid_056a&pid_030e&mi_02#8&123e7efa&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}).'
   at HidSharp.Platform.Windows.WinHidStream.Init(String path)
   at HidSharp.Platform.Windows.WinHidDevice.OpenDeviceDirectly(OpenConfiguration openConfig)
   at HidSharp.Device.OpenDeviceAndRestrictAccess(OpenConfiguration openConfig)
   at HidSharp.Device.Open(OpenConfiguration openConfig)
   at HidSharp.Device.Open()
   at HidSharp.HidDevice.Open()
   at HidTest.Program.Main(String[] args) in \\vmware-host\Shared Folders\Repos\hidtest\HidTest\Program.cs:line 20

2

Re: HidSharp.Exceptions.DeviceIOException on HidDevice.Open, Windows only

If it shows up to the OS as a mouse or keyboard, FWIW, Windows will block access to it for "security".

3

Re: HidSharp.Exceptions.DeviceIOException on HidDevice.Open, Windows only

Is there any workaround for this? I know that github.com/djpnewton/vmulti pulls it off without this issue in this project: github.com/hawku/TabletDriver