Commit ef8ced41 authored by Felix Lange's avatar Felix Lange Committed by Péter Szilágyi

vendor: update github.com/karalabe/hid (#18213)

Fixes #15101 because hidapi is no longer being called from an
init function.
parent 7e7781ff
...@@ -22,8 +22,8 @@ environment: ...@@ -22,8 +22,8 @@ environment:
install: install:
- rmdir C:\go /s /q - rmdir C:\go /s /q
- appveyor DownloadFile https://storage.googleapis.com/golang/go1.8.windows-%GOARCH%.zip - appveyor DownloadFile https://storage.googleapis.com/golang/go1.10.1.windows-%GOARCH%.zip
- 7z x go1.8.windows-%GOARCH%.zip -y -oC:\ > NUL - 7z x go1.10.1.windows-%GOARCH%.zip -y -oC:\ > NUL
- go version - go version
- gcc --version - gcc --version
......
...@@ -36,7 +36,7 @@ func (info DeviceInfo) Open() (*Device, error) { ...@@ -36,7 +36,7 @@ func (info DeviceInfo) Open() (*Device, error) {
// Close releases the HID USB device handle. On platforms that this file implements // Close releases the HID USB device handle. On platforms that this file implements
// the method is just a noop. // the method is just a noop.
func (dev *Device) Close() {} func (dev *Device) Close() error { return nil }
// Write sends an output report to a HID device. On platforms that this file // Write sends an output report to a HID device. On platforms that this file
// implements the method just returns an error. // implements the method just returns an error.
......
...@@ -41,6 +41,7 @@ package hid ...@@ -41,6 +41,7 @@ package hid
#endif #endif
*/ */
import "C" import "C"
import ( import (
"errors" "errors"
"runtime" "runtime"
...@@ -57,11 +58,6 @@ import ( ...@@ -57,11 +58,6 @@ import (
// > "subsequent calls will cause the hid manager to release previously enumerated devices" // > "subsequent calls will cause the hid manager to release previously enumerated devices"
var enumerateLock sync.Mutex var enumerateLock sync.Mutex
func init() {
// Initialize the HIDAPI library
C.hid_init()
}
// Supported returns whether this platform is supported by the HID library or not. // Supported returns whether this platform is supported by the HID library or not.
// The goal of this method is to allow programatically handling platforms that do // The goal of this method is to allow programatically handling platforms that do
// not support USB HID and not having to fall back to build constraints. // not support USB HID and not having to fall back to build constraints.
...@@ -113,6 +109,9 @@ func Enumerate(vendorID uint16, productID uint16) []DeviceInfo { ...@@ -113,6 +109,9 @@ func Enumerate(vendorID uint16, productID uint16) []DeviceInfo {
// Open connects to an HID device by its path name. // Open connects to an HID device by its path name.
func (info DeviceInfo) Open() (*Device, error) { func (info DeviceInfo) Open() (*Device, error) {
enumerateLock.Lock()
defer enumerateLock.Unlock()
path := C.CString(info.Path) path := C.CString(info.Path)
defer C.free(unsafe.Pointer(path)) defer C.free(unsafe.Pointer(path))
...@@ -135,7 +134,7 @@ type Device struct { ...@@ -135,7 +134,7 @@ type Device struct {
} }
// Close releases the HID USB device handle. // Close releases the HID USB device handle.
func (dev *Device) Close() { func (dev *Device) Close() error {
dev.lock.Lock() dev.lock.Lock()
defer dev.lock.Unlock() defer dev.lock.Unlock()
...@@ -143,6 +142,7 @@ func (dev *Device) Close() { ...@@ -143,6 +142,7 @@ func (dev *Device) Close() {
C.hid_close(dev.device) C.hid_close(dev.device)
dev.device = nil dev.device = nil
} }
return nil
} }
// Write sends an output report to a HID device. // Write sends an output report to a HID device.
......
...@@ -267,10 +267,10 @@ ...@@ -267,10 +267,10 @@
"revisionTime": "2017-04-30T22:20:11Z" "revisionTime": "2017-04-30T22:20:11Z"
}, },
{ {
"checksumSHA1": "UpjhOUZ1+0zNt+iIvdtECSHXmTs=", "checksumSHA1": "6XsjAARQFvlW6dS15al0ibTFPOQ=",
"path": "github.com/karalabe/hid", "path": "github.com/karalabe/hid",
"revision": "f00545f9f3748e591590be3732d913c77525b10f", "revision": "d815e0c1a2e2082a287a2806bc90bc8fc7b276a9",
"revisionTime": "2017-08-21T10:38:37Z", "revisionTime": "2018-11-28T19:21:57Z",
"tree": true "tree": true
}, },
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment