func (dev *Device) Close() error {
	dev.lock.Lock()
	defer dev.lock.Unlock()
	if dev.device != nil {
		C.hid_close(dev.device)
		dev.device = nil
	}
	return nil
}
Close releases the HID USB device handle.
package hid
import "C"
import (
	"errors"
	"runtime"
	"sync"
	"unsafe"
)
var enumerateLock sync.Mutex
func Supported() bool {
	return true
}
func Enumerate(vendorID uint16, productID uint16) []DeviceInfo {
	enumerateLock.Lock()
	defer enumerateLock.Unlock()
	head := C.hid_enumerate(C.ushort(vendorID), C.ushort(productID))
	if head == nil {
		return nil
	}
	defer C.hid_free_enumeration(head)
	var infos []DeviceInfo
	for ; head != nil; head = head.next {
		info := DeviceInfo{
			Path:      C.GoString(head.path),
			VendorID:  uint16(head.vendor_id),
			ProductID: uint16(head.product_id),
			Release:   uint16(head.release_number),
			UsagePage: uint16(head.usage_page),
			Usage:     uint16(head.usage),
			Interface: int(head.interface_number),
		}
		if head.serial_number != nil {
			info.Serial, _ = wcharTToString(head.serial_number)
		}
		if head.product_string != nil {
			info.Product, _ = wcharTToString(head.product_string)
		}
		if head.manufacturer_string != nil {
			info.Manufacturer, _ = wcharTToString(head.manufacturer_string)
		}
		infos = append(infos, info)
	}
	return infos
}
func (info DeviceInfo) Open() (*Device, error) {
	enumerateLock.Lock()
	defer enumerateLock.Unlock()
	path := C.CString(info.Path)
	defer C.free(unsafe.Pointer(path))
	device := C.hid_open_path(path)
	if device == nil {
		return nil, errors.New("hidapi: failed to open device")
	}
	return &Device{
		DeviceInfo: info,
		device:     device,
	}, nil
}
type Device struct {
	DeviceInfo  
	device *C.hid_device  
	lock   sync.Mutex
}