hid.go 702 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package hid
  2. import (
  3. "io/ioutil"
  4. "log"
  5. "time"
  6. )
  7. //
  8. // General information about the HID device
  9. //
  10. type Info struct {
  11. Vendor uint16
  12. Product uint16
  13. Revision uint16
  14. SubClass uint8
  15. Protocol uint8
  16. Interface uint8
  17. Bus int
  18. Device int
  19. }
  20. //
  21. // A common HID device interace
  22. //
  23. type Device interface {
  24. Open() error
  25. Close()
  26. Info() Info
  27. HIDReport() ([]byte, error)
  28. SetReport(int, []byte) error
  29. GetReport(int) ([]byte, error)
  30. Read(size int, ms time.Duration) ([]byte, error)
  31. Write(data []byte, ms time.Duration) (int, error)
  32. Ctrl(rtype, req, val, index int, data []byte, t int) (int, error)
  33. }
  34. // Default Logger setting
  35. var Logger = log.New(ioutil.Discard, "hid", log.LstdFlags)