aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com')
-rw-r--r--vendor/github.com/karalabe/hid/README.md6
-rw-r--r--vendor/github.com/karalabe/hid/appveyor.yml1
-rw-r--r--vendor/github.com/karalabe/hid/hid.go2
-rw-r--r--vendor/github.com/karalabe/hid/hid_disabled.go2
-rw-r--r--vendor/github.com/karalabe/hid/hid_enabled.go14
5 files changed, 22 insertions, 3 deletions
diff --git a/vendor/github.com/karalabe/hid/README.md b/vendor/github.com/karalabe/hid/README.md
index 5c0213f3b..2851ffe42 100644
--- a/vendor/github.com/karalabe/hid/README.md
+++ b/vendor/github.com/karalabe/hid/README.md
@@ -24,6 +24,12 @@ and go-gettable.
Supported platforms at the moment are Linux, macOS and Windows (exclude constraints are also specified
for Android and iOS to allow smoother vendoring into cross platform projects).
+## Cross-compiling
+
+Using `go get` the embedded C library is compiled into the binary format of your host OS. Cross compiling to a different platform or architecture entails disabling CGO by default in Go, causing device enumeration `hid.Enumerate()` to yield no results.
+
+To cross compile a functional version of this library, you'll need to enable CGO during cross compilation via `CGO_ENABLED=1` and you'll need to install and set a cross compilation enabled C toolkit via `CC=your-cross-gcc`.
+
## Acknowledgements
Although the `hid` package is an implementation from scratch, it was heavily inspired by the existing
diff --git a/vendor/github.com/karalabe/hid/appveyor.yml b/vendor/github.com/karalabe/hid/appveyor.yml
index 34623ddb0..f43958747 100644
--- a/vendor/github.com/karalabe/hid/appveyor.yml
+++ b/vendor/github.com/karalabe/hid/appveyor.yml
@@ -29,3 +29,4 @@ install:
build_script:
- go install ./...
+ - go test -v ./...
diff --git a/vendor/github.com/karalabe/hid/hid.go b/vendor/github.com/karalabe/hid/hid.go
index be75f949d..60a40b8c2 100644
--- a/vendor/github.com/karalabe/hid/hid.go
+++ b/vendor/github.com/karalabe/hid/hid.go
@@ -2,7 +2,7 @@
// Copyright (c) 2017 Péter Szilágyi. All rights reserved.
//
// This file is released under the 3-clause BSD license. Note however that Linux
-// support depends on libusb, released under GNU GPL 2.1 or later.
+// support depends on libusb, released under GNU LGPL 2.1 or later.
// Package hid provides an interface for USB HID devices.
package hid
diff --git a/vendor/github.com/karalabe/hid/hid_disabled.go b/vendor/github.com/karalabe/hid/hid_disabled.go
index d8ecc9d5a..1f4026379 100644
--- a/vendor/github.com/karalabe/hid/hid_disabled.go
+++ b/vendor/github.com/karalabe/hid/hid_disabled.go
@@ -2,7 +2,7 @@
// Copyright (c) 2017 Péter Szilágyi. All rights reserved.
//
// This file is released under the 3-clause BSD license. Note however that Linux
-// support depends on libusb, released under GNU GPL 2.1 or later.
+// support depends on libusb, released under GNU LGPL 2.1 or later.
// +build !linux,!darwin,!windows ios !cgo
diff --git a/vendor/github.com/karalabe/hid/hid_enabled.go b/vendor/github.com/karalabe/hid/hid_enabled.go
index 3ceecce0d..419273be6 100644
--- a/vendor/github.com/karalabe/hid/hid_enabled.go
+++ b/vendor/github.com/karalabe/hid/hid_enabled.go
@@ -2,7 +2,7 @@
// Copyright (c) 2017 Péter Szilágyi. All rights reserved.
//
// This file is released under the 3-clause BSD license. Note however that Linux
-// support depends on libusb, released under GNU GPL 2.1 or later.
+// support depends on libusb, released under LGNU GPL 2.1 or later.
// +build linux,cgo darwin,!ios,cgo windows,cgo
@@ -48,6 +48,15 @@ import (
"unsafe"
)
+// enumerateLock is a mutex serializing access to USB device enumeration needed
+// by the macOS USB HID system calls, which require 2 consecutive method calls
+// for enumeration, causing crashes if called concurrently.
+//
+// For more details, see:
+// https://developer.apple.com/documentation/iokit/1438371-iohidmanagersetdevicematching
+// > "subsequent calls will cause the hid manager to release previously enumerated devices"
+var enumerateLock sync.Mutex
+
func init() {
// Initialize the HIDAPI library
C.hid_init()
@@ -66,6 +75,9 @@ func Supported() bool {
// - If the product id is set to 0 then any product matches.
// - If the vendor and product id are both 0, all HID devices are returned.
func Enumerate(vendorID uint16, productID uint16) []DeviceInfo {
+ enumerateLock.Lock()
+ defer enumerateLock.Unlock()
+
// Gather all device infos and ensure they are freed before returning
head := C.hid_enumerate(C.ushort(vendorID), C.ushort(productID))
if head == nil {