예제 #1
0
        public void get_status()
        {
            int result = NativeHidApiLibAdapter.hid_write(device, cmd.GetStatus.Pointer, new IntPtr(cmd.GetStatus.Length));

            checkResult(result);
            read();
        }
예제 #2
0
        private void initialize()
        {
            var res = NativeHidApiLibAdapter.hid_enumerate(vid, pid);

            if (res == IntPtr.Zero)
            {
                throw new DeviceNotConnectedException();
            }
            info = (hid_device_info)Marshal.PtrToStructure(res, typeof(hid_device_info));
        }
예제 #3
0
        private byte[] read()
        {
            IntPtr length = new IntPtr(32);
            IntPtr data   = getBuffer(new byte[32]);
            int    result = NativeHidApiLibAdapter.hid_read(device, data, length);
            var    arr    = new byte[result];

            Marshal.Copy(data, arr, 0, result);
            return(arr);
        }
예제 #4
0
        public void fire()
        {
            int result = NativeHidApiLibAdapter.hid_write(device, cmd.Fire.Pointer, new IntPtr(cmd.Fire.Length));

            checkResult(result);
        }
예제 #5
0
        public void turnLedOn()
        {
            int result = NativeHidApiLibAdapter.hid_write(device, cmd.Led_On.Pointer, new IntPtr(cmd.Led_On.Length));

            checkResult(result);
        }
예제 #6
0
        private void openDevice()
        {
            StringBuilder path = new StringBuilder(info.path, info.path.Length);

            device = NativeHidApiLibAdapter.hid_open_path(path);
        }
예제 #7
0
 public void Dispose()
 {
     NativeHidApiLibAdapter.hid_close(device);
     cmd.Dispose();
 }