Ejemplo n.º 1
0
        public bool Read(ref byte[] data)
        {
            var count = default(uint);

            data[0] = 0;
            return(HidPlatform.ReadFile(this.ReadHandle, data, (uint)data.Length, ref count, IntPtr.Zero));
        }
Ejemplo n.º 2
0
 private static IntPtr SetupDiGetClassDevs()
 {
     return(HidPlatform.SetupDiGetClassDevs(
                ref HID,
                0,
                IntPtr.Zero,
                HidPlatform.DIGCF_PRESENT | HidPlatform.DIGCF_DEVICEINTERFACE
                ));
 }
Ejemplo n.º 3
0
 public void Close()
 {
     if (this.ReadHandle != IntPtr.Zero && HidPlatform.CloseHandle(this.ReadHandle) == 1)
     {
         this.ReadHandle = IntPtr.Zero;
     }
     if (this.WriteHandle != IntPtr.Zero && HidPlatform.CloseHandle(this.WriteHandle) == 1)
     {
         this.WriteHandle = IntPtr.Zero;
     }
 }
Ejemplo n.º 4
0
 private static bool SetupDiGetDeviceInterfaceDetail(IntPtr devices, ref HidPlatform.SP_DEVICE_INTERFACE_DATA deviceInterface, uint size, IntPtr data)
 {
     return(HidPlatform.SetupDiGetDeviceInterfaceDetail(
                devices,
                ref deviceInterface,
                data,
                size,
                out size,
                IntPtr.Zero
                ));
 }
Ejemplo n.º 5
0
 public bool Write(byte[] data, bool input = false)
 {
     if (input)
     {
         return(HidPlatform.HidD_SetOutputReport(this.ReadHandle, data, (uint)data.Length));
     }
     else
     {
         var count = default(uint);
         return(HidPlatform.WriteFile(this.WriteHandle, data, (uint)data.Length, ref count, IntPtr.Zero));
     }
 }
Ejemplo n.º 6
0
 public bool Read(ref byte[] data, bool input = false)
 {
     data[0] = 0;
     if (input)
     {
         return(HidPlatform.HidD_GetInputReport(this.ReadHandle, data, (uint)data.Length));
     }
     else
     {
         var count = default(uint);
         return(HidPlatform.ReadFile(this.ReadHandle, data, (uint)data.Length, ref count, IntPtr.Zero));
     }
 }
Ejemplo n.º 7
0
        private static uint SetupDiGetDeviceInterfaceDetail(IntPtr devices, ref HidPlatform.SP_DEVICE_INTERFACE_DATA deviceInterface)
        {
            var size = default(uint);

            HidPlatform.SetupDiGetDeviceInterfaceDetail(
                devices,
                ref deviceInterface,
                IntPtr.Zero,
                0,
                out size,
                IntPtr.Zero
                );
            return(size);
        }
Ejemplo n.º 8
0
 private void OpenDevice(string devicePath)
 {
     this.ReadHandle = HidPlatform.CreateFile(
         devicePath,
         HidPlatform.FILE_ACCESS_READ,
         HidPlatform.FILE_SHARE_READ | HidPlatform.FILE_SHARE_WRITE,
         0,
         HidPlatform.FILE_CREATION_DISPOSITON_OPEN_EXISTING,
         0,
         0
         );
     this.WriteHandle = HidPlatform.CreateFile(
         devicePath,
         HidPlatform.FILE_ACCESS_WRITE,
         HidPlatform.FILE_SHARE_READ | HidPlatform.FILE_SHARE_WRITE,
         0,
         HidPlatform.FILE_CREATION_DISPOSITON_OPEN_EXISTING,
         0,
         0
         );
 }
Ejemplo n.º 9
0
 static HidDevice()
 {
     HidPlatform.HidD_GetHidGuid(out HID);
 }