hid

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

package hid is for USB Human Interface Devices.

Index

Constants

View Source
const (
	REPORT_TYPE_INPUT   = 1
	REPORT_TYPE_OUTPUT  = 2
	REPORT_TYPE_FEATURE = 3
)

Variables

View Source
var (
	ErrHIDInvalidPort    = errors.New("invalid USB port")
	ErrHIDInvalidCore    = errors.New("invalid USB core")
	ErrHIDReportTransfer = errors.New("failed to transfer HID report")
)

from usb-hid.go

View Source
var DefaultSetupHandler = setupHandler

Functions

func SendUSBPacket

func SendUSBPacket(b []byte)

SendUSBPacket sends a HIDPacket.

func SetHandler

func SetHandler(d hidDevicer)

SetHandler sets the handler. Only the first time it is called, it calls machine.EnableHID for USB configuration

Types

type RingBuffer

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

RingBuffer is ring buffer implementation inspired by post at https://www.embeddedrelated.com/showthread/comp.arch.embedded/77084-1.php

func NewRingBuffer

func NewRingBuffer() *RingBuffer

NewRingBuffer returns a new ring buffer.

func (*RingBuffer) Clear

func (rb *RingBuffer) Clear()

Clear resets the head and tail pointer to zero.

func (*RingBuffer) Get

func (rb *RingBuffer) Get() ([]byte, bool)

Get returns a byte from the buffer. If the buffer is empty, the method will return a false as the second value.

func (*RingBuffer) Put

func (rb *RingBuffer) Put(val []byte) bool

Put stores a byte in the buffer. If the buffer is already full, the method will return false.

func (*RingBuffer) Used

func (rb *RingBuffer) Used() uint8

Used returns how many bytes in buffer have been used.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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