hid

package
v0.1.30 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package hid implements iap over hid transport

Index

Constants

This section is empty.

Variables

View Source
var DefaultReportDefs = ReportDefs{
	ReportDef{ID: 0x01, Len: 12, Dir: ReportDirAccIn},
	ReportDef{ID: 0x02, Len: 14, Dir: ReportDirAccIn},
	ReportDef{ID: 0x03, Len: 20, Dir: ReportDirAccIn},
	ReportDef{ID: 0x04, Len: 63, Dir: ReportDirAccIn},

	ReportDef{ID: 0x05, Len: 8, Dir: ReportDirAccIn},
	ReportDef{ID: 0x06, Len: 10, Dir: ReportDirAccIn},
	ReportDef{ID: 0x07, Len: 14, Dir: ReportDirAccIn},
	ReportDef{ID: 0x08, Len: 20, Dir: ReportDirAccIn},
	ReportDef{ID: 0x09, Len: 63, Dir: ReportDirAccIn},
}

DefaultReportDefs is a default set of report types for use with ipod-gadget

View Source
var LegacyReportDefs = ReportDefs{
	ReportDef{ID: 0x01, Len: 5, Dir: ReportDirAccIn},
	ReportDef{ID: 0x02, Len: 9, Dir: ReportDirAccIn},
	ReportDef{ID: 0x03, Len: 13, Dir: ReportDirAccIn},
	ReportDef{ID: 0x04, Len: 17, Dir: ReportDirAccIn},
	ReportDef{ID: 0x05, Len: 25, Dir: ReportDirAccIn},
	ReportDef{ID: 0x06, Len: 49, Dir: ReportDirAccIn},
	ReportDef{ID: 0x07, Len: 95, Dir: ReportDirAccIn},
	ReportDef{ID: 0x08, Len: 193, Dir: ReportDirAccIn},
	ReportDef{ID: 0x09, Len: 257, Dir: ReportDirAccIn},
	ReportDef{ID: 0x0A, Len: 385, Dir: ReportDirAccIn},
	ReportDef{ID: 0x0B, Len: 513, Dir: ReportDirAccIn},
	ReportDef{ID: 0x0C, Len: 767, Dir: ReportDirAccIn},

	ReportDef{ID: 0x0D, Len: 5, Dir: ReportDirAccOut},
	ReportDef{ID: 0x0E, Len: 9, Dir: ReportDirAccOut},
	ReportDef{ID: 0x0F, Len: 13, Dir: ReportDirAccOut},
	ReportDef{ID: 0x10, Len: 17, Dir: ReportDirAccOut},
	ReportDef{ID: 0x11, Len: 25, Dir: ReportDirAccOut},
	ReportDef{ID: 0x12, Len: 49, Dir: ReportDirAccOut},
	ReportDef{ID: 0x13, Len: 95, Dir: ReportDirAccOut},
	ReportDef{ID: 0x14, Len: 193, Dir: ReportDirAccOut},
	ReportDef{ID: 0x15, Len: 255, Dir: ReportDirAccOut},
}

Functions

This section is empty.

Types

type Decoder

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

func NewDecoder

func NewDecoder(r ReportReader, defs ReportDefs) *Decoder

func NewDecoderDefault

func NewDecoderDefault(r ReportReader) *Decoder

func (*Decoder) ReadFrame

func (e *Decoder) ReadFrame() ([]byte, error)

type Encoder

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

func NewEncoder

func NewEncoder(w ReportWriter, defs ReportDefs) *Encoder

func NewEncoderDefault

func NewEncoderDefault(w ReportWriter) *Encoder

func (*Encoder) WriteFrame

func (e *Encoder) WriteFrame(data []byte) error

type LinkControl

type LinkControl byte
const (
	LinkControlDone         LinkControl = 0x00
	LinkControlContinue     LinkControl = 0x01
	LinkControlMoreToFollow LinkControl = 0x02
)

type Report

type Report struct {
	ID          byte
	LinkControl LinkControl
	Data        []byte
}

type ReportDef

type ReportDef struct {
	// id
	ID int
	// lenth of the report not including the id.
	Len int
	// direction
	Dir ReportDir
}

ReportDef represents a hid report type from the descriptor

func (ReportDef) MaxPayload

func (def ReportDef) MaxPayload() int

MaxPayload returns the maximum payload that a report can fit

type ReportDefs

type ReportDefs []ReportDef

ReportDefs is a collection of ReportDef

func (ReportDefs) Find

func (defs ReportDefs) Find(id int) (ReportDef, error)

Find finds the report type based on id

func (ReportDefs) Pick

func (defs ReportDefs) Pick(payloadSize int, dir ReportDir) (ReportDef, error)

Pick finds the best matching report type

type ReportDir

type ReportDir uint8

ReportDir is the report direction

const (
	// Device to host (ipod->accessory)
	ReportDirAccIn ReportDir = 0
	// Host to device (accessory->ipod)
	ReportDirAccOut ReportDir = 1
)

type ReportReader

type ReportReader interface {
	ReadReport() (Report, error)
}

func NewReportReader

func NewReportReader(r io.Reader) ReportReader

type ReportWriter

type ReportWriter interface {
	WriteReport(Report) error
}

func NewReportWriter

func NewReportWriter(w io.Writer) ReportWriter

type SingleReport

type SingleReport []byte

func (SingleReport) ReadReport

func (s SingleReport) ReadReport() (Report, error)

type Transport

type Transport struct {
	*Decoder
	*Encoder
}

func NewTransport

func NewTransport(r ReportReader, w ReportWriter, defs ReportDefs) *Transport

Jump to

Keyboard shortcuts

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