usbdef_linux.go 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. package hid
  2. const UsbHidClass = 3
  3. type deviceDesc struct {
  4. Length uint8
  5. DescriptorType uint8
  6. USB uint16
  7. DeviceClass uint8
  8. DeviceSubClass uint8
  9. DeviceProtocol uint8
  10. MaxPacketSize uint8
  11. Vendor uint16
  12. Product uint16
  13. Revision uint16
  14. ManufacturerIndex uint8
  15. ProductIndex uint8
  16. SerialIndex uint8
  17. NumConfigurations uint8
  18. }
  19. type configDesc struct {
  20. Length uint8
  21. DescriptorType uint8
  22. TotalLength uint16
  23. NumInterfaces uint8
  24. ConfigurationValue uint8
  25. Configuration uint8
  26. Attributes uint8
  27. MaxPower uint8
  28. }
  29. type interfaceDesc struct {
  30. Length uint8
  31. DescriptorType uint8
  32. Number uint8
  33. AltSetting uint8
  34. NumEndpoints uint8
  35. InterfaceClass uint8
  36. InterfaceSubClass uint8
  37. InterfaceProtocol uint8
  38. InterfaceIndex uint8
  39. }
  40. type endpointDesc struct {
  41. Length uint8
  42. DescriptorType uint8
  43. Address uint8
  44. Attributes uint8
  45. MaxPacketSize uint16
  46. Interval uint8
  47. }
  48. type hidReportDesc struct {
  49. Length uint8
  50. DescriptorType uint8
  51. }
  52. const (
  53. USBDEVFS_CONNECT = 0x5517
  54. USBDEVFS_DISCONNECT = 0x5516
  55. USBDEVFS_CLAIM = 0x8004550f
  56. USBDEVFS_RELEASE = 0x80045510
  57. )
  58. const DevBusUsb = "/dev/bus/usb"
  59. const (
  60. UsbDescTypeDevice = 1
  61. UsbDescTypeConfig = 2
  62. UsbDescTypeString = 3
  63. UsbDescTypeInterface = 4
  64. UsbDescTypeEndpoint = 5
  65. UsbDescTypeReport = 33
  66. )