hid

package
v0.0.0-...-6d4690e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 31, 2017 License: MPL-2.0 Imports: 11 Imported by: 2

Documentation

Overview

Package hid provides access to Human Interface Devices.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Device

type Device interface {
	// Close closes the device and associated resources.
	Close()

	// Write writes an output report to device. The first byte must be the
	// report number to write, zero if the device does not use numbered reports.
	Write([]byte) error

	// ReadCh returns a channel that will be sent input reports from the device.
	// If the device uses numbered reports, the first byte will be the report
	// number.
	ReadCh() <-chan []byte

	// ReadError returns the read error, if any after the channel returned from
	// ReadCh has been closed.
	ReadError() error
}

A Device provides access to a HID device.

type DeviceInfo

type DeviceInfo struct {
	// Path contains a platform-specific device path which is used to identify the device.
	Path string `json:"path"`

	VendorID      uint16 `json:"vendor_id"`
	ProductID     uint16 `json:"product_id"`
	VersionNumber uint16 `json:"version_number"`
	Manufacturer  string `json:"manufacturer"`
	Product       string `json:"product"`
	SerialNumber  string `json:"serial_number"`

	UsagePage uint16 `json:"usage_page"`
	Usage     uint16 `json:"usage"`

	InputReportLength  uint16 `json:"input_report_length"`
	OutputReportLength uint16 `json:"output_report_length"`
}

DeviceInfo provides general information about a device.

func ByPath

func ByPath(path string) (*DeviceInfo, error)

ByPath returns device info via it's file path

func Devices

func Devices() ([]*DeviceInfo, error)

Devices enumerates the attached USB HID devices as DeviceInfo objects

func (*DeviceInfo) Open

func (d *DeviceInfo) Open() (Device, error)

Open will satisfy the hid.Device interface, opening the device for reading writing

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL