ソースを参照

add the ability to explicitly set endpoints

Matthew Di Ferrante 8 年 前
コミット
3a6504b709
2 ファイル変更7 行追加1 行削除
  1. 1 0
      hid.go
  2. 6 1
      usb_linux.go

+ 1 - 0
hid.go

@@ -23,6 +23,7 @@ type Device interface {
 	Open() error
 	Close()
 	Info() Info
+	SetEndpoint(int)
 	HIDReport() ([]byte, error)
 	SetReport(int, []byte) error
 	GetReport(int) ([]byte, error)

+ 6 - 1
usb_linux.go

@@ -27,6 +27,11 @@ type usbDevice struct {
 	path string
 }
 
+func (hid *usbDevice) SetEndpoint(ep int) {
+	hid.epOut = ep
+	hid.epIn = ep + 0x80
+}
+
 func (hid *usbDevice) Open() (err error) {
 	if hid.f != nil {
 		return errors.New("device is already opened")
@@ -34,7 +39,7 @@ func (hid *usbDevice) Open() (err error) {
 	if hid.f, err = os.OpenFile(hid.path, os.O_RDWR, 0644); err != nil {
 		return
 	} else {
-		return hid.claim()
+		return nil //hid.claim()
 	}
 }