Guest User

Untitled

a guest
May 13th, 2024
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.49 KB | None | 0 0
  1. using System.Runtime.InteropServices;
  2. using System.Collections;
  3. using System;
  4. using System.Text;
  5.  
  6.  
  7. public class HIDapi {
  8.  
  9.  
  10.  
  11.     [DllImport("hidapi")]
  12.     public static extern int hid_init();
  13.  
  14.     [DllImport("hidapi")]
  15.     public static extern int hid_exit();  
  16.  
  17.     [DllImport("hidapi")]
  18.     public static extern IntPtr hid_error(IntPtr device);
  19.  
  20.  
  21.     [DllImport("hidapi")]
  22.     public static extern IntPtr hid_enumerate(ushort vendor_id, ushort product_id);
  23.  
  24.     [DllImport("hidapi")]
  25.     public static extern void hid_free_enumeration(IntPtr devs);
  26.  
  27.     [DllImport("hidapi")]
  28.     public static extern int hid_get_feature_report(IntPtr device, byte[] data, UIntPtr length);
  29.  
  30.     [DllImport("hidapi")]
  31.     public static extern int hid_get_indexed_string(IntPtr device, int string_index, StringBuilder str, UIntPtr maxlen);
  32.  
  33.     [DllImport("hidapi")]
  34.     public static extern int hid_get_manufacturer_string(IntPtr device, StringBuilder str, UIntPtr maxlen);
  35.  
  36.     [DllImport("hidapi")]
  37.     public static extern int hid_get_product_string(IntPtr device, StringBuilder str, UIntPtr maxlen);
  38.  
  39.     [DllImport("hidapi")]
  40.     public static extern int hid_get_serial_number_string(IntPtr device, StringBuilder str, UIntPtr maxlen);
  41.  
  42.     [DllImport("hidapi")]
  43.     public static extern IntPtr hid_open(ushort vendor_id, ushort product_id, string serial_number);
  44.  
  45.     [DllImport("hidapi")]
  46.     public static extern void hid_close(IntPtr device);
  47.  
  48.     [DllImport("hidapi")]
  49.     public static extern IntPtr hid_open_path(string path);
  50.  
  51.     [DllImport("hidapi")]
  52.     public static extern int hid_read(IntPtr device, byte[] data, UIntPtr length);
  53.  
  54.     [DllImport("hidapi")]
  55.     public static extern int hid_read_timeout(IntPtr dev, byte[] data, UIntPtr length, int milliseconds);
  56.  
  57.     [DllImport("hidapi")]
  58.     public static extern int hid_send_feature_report(IntPtr device, byte[] data, UIntPtr length);
  59.  
  60.     [DllImport("hidapi")]
  61.     public static extern int hid_set_nonblocking(IntPtr device, int nonblock);
  62.  
  63.     [DllImport("hidapi")]
  64.     public static extern int hid_write(IntPtr device, byte[] data, UIntPtr length);
  65. }
  66.  
  67. struct hid_device_info {
  68.     public string path;
  69.     public ushort vendor_id;
  70.     public ushort product_id;
  71.     public string serial_number;
  72.     public ushort release_number;
  73.     public string manufacturer_string;
  74.     public string product_string;
  75.     public ushort usage_page;
  76.     public ushort usage;
  77.     public int interface_number;
  78.     public IntPtr next;
  79. }
Advertisement
Add Comment
Please, Sign In to add comment