hid.go 672 B

123456789101112131415161718192021222324252627282930313233343536373839
  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. }
  18. //
  19. // A common HID device interace
  20. //
  21. type Device interface {
  22. Open() error
  23. Close()
  24. Info() Info
  25. HIDReport() ([]byte, error)
  26. SetReport(int, []byte) error
  27. GetReport(int) ([]byte, error)
  28. Read(size int, ms time.Duration) ([]byte, error)
  29. Write(data []byte, ms time.Duration) (int, error)
  30. Ctrl(rtype, req, val, index int, data []byte, t int) (int, error)
  31. }
  32. // Default Logger setting
  33. var Logger = log.New(ioutil.Discard, "hid", log.LstdFlags)