hid

package
v0.0.0-...-6586ce7 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	USBHidClass = 3

	USBDevBus = "/dev/bus/usb"

	USBDevFSConnect    = 0x5517
	USBDevFSDisconnect = 0x5516
	USBDevFSClaim      = 0x8004550f
	USBDevFSRelease    = 0x80045510
	USBDevFSIoctl      = 0xc0105512
	USBDevFSBulk       = 0xc0185502
	USBDevFSControl    = 0xc0185500

	USBDescTypeDevice    = 1
	USBDescTypeConfig    = 2
	USBDescTypeString    = 3
	USBDescTypeInterface = 4
	USBDescTypeEndpoint  = 5
	USBDescTypeReport    = 33
)

Variables

View Source
var ErrDeviceAlreadyConnected = errors.New("hid: device already connected")

Functions

This section is empty.

Types

type DeviceInfo

type DeviceInfo struct {
	VendorID  uint16
	ProductID uint16
	Revision  uint16

	SubClass uint8
	Protocol uint8

	Interface uint8
	Bus       int
	Device    int
}

type USB

type USB struct {
	// contains filtered or unexported fields
}

func Device

func Device(path string) (*USB, error)

Device .

func Devices

func Devices(dir string) ([]*USB, error)

Devices returns a slice of USB devices by recursively searching the given directory. If the directory points to a USB device, then it will be returned as a slice of length 1.

func (*USB) Close

func (u *USB) Close(ctx context.Context) error

Close closes the device.

func (*USB) GetFeatureReport

func (u *USB) GetFeatureReport(ctx context.Context, v []byte) (int, error)

func (*USB) Info

func (u *USB) Info() DeviceInfo

Info returns information about the device.

func (*USB) Open

func (u *USB) Open(ctx context.Context) error

Open opens the USB HID device.

func (*USB) Read

func (u *USB) Read(ctx context.Context, v []byte, t time.Duration) (int, error)

func (*USB) SendFeatureReport

func (u *USB) SendFeatureReport(ctx context.Context, v []byte) (int, error)

func (*USB) Write

func (u *USB) Write(ctx context.Context, v []byte) (int, error)

Jump to

Keyboard shortcuts

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