Documentation
¶
Overview ¶
Package hid provides a structured representation of HID report descriptors.
A HID report descriptor is a byte-coded DSL. This package models it as a tree of Go structs (including nested collections) and encodes it to the exact descriptor byte stream.
Index ¶
- Constants
- type AnyItem
- type Collection
- type CollectionKind
- type Data
- type Feature
- type Input
- type Item
- type ItemType
- type LogicalMaximum
- type LogicalMinimum
- type LongItem
- type MainFlags
- type Output
- type Report
- type ReportCount
- type ReportSize
- type Usage
- type UsageMaximum
- type UsageMinimum
- type UsagePage
Constants ¶
const ( UsagePageGenericDesktop uint16 = 0x01 UsagePageSimulation uint16 = 0x02 UsagePageVR uint16 = 0x03 UsagePageSport uint16 = 0x04 UsagePageGame uint16 = 0x05 UsagePageKeyboard uint16 = 0x07 UsagePageLEDs uint16 = 0x08 UsagePageButton uint16 = 0x09 UsagePageConsumer uint16 = 0x0C )
Common Usage Pages. Values per HID Usage Tables.
const ( UsagePointer uint16 = 0x01 UsageMouse uint16 = 0x02 UsageJoystick uint16 = 0x04 UsageGamePad uint16 = 0x05 UsageKeyboard uint16 = 0x06 UsageX uint16 = 0x30 UsageY uint16 = 0x31 UsageZ uint16 = 0x32 UsageRx uint16 = 0x33 UsageRy uint16 = 0x34 UsageRz uint16 = 0x35 UsageWheel uint16 = 0x38 )
Generic Desktop usages.
const (
UsageACPan uint16 = 0x0238
)
Consumer usages.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AnyItem ¶
AnyItem is an escape hatch for rarely used or vendor-defined items.
For short items, Data must have length 0, 1, 2, or 4. For other sizes, use LongItem.
type Collection ¶
type Collection struct {
Kind CollectionKind
Items []Item
}
Collection begins a collection (Main item, tag 0xA) and implicitly ends it.
type CollectionKind ¶
type CollectionKind uint8
CollectionKind values.
const ( CollectionPhysical CollectionKind = 0x00 CollectionApplication CollectionKind = 0x01 CollectionLogical CollectionKind = 0x02 )
type Data ¶
type Data []uint8
Data is a strongly-typed byte slice used for HID report descriptor payloads.
It exists to avoid exposing raw []byte fields on report descriptor models. The underlying representation is still bytes because that is what the USB/HID specification ultimately requires.
type Feature ¶
type Feature struct{ Flags MainFlags }
Feature encodes a Feature main item (tag 0xB).
type Item ¶
type Item interface {
// contains filtered or unexported methods
}
Item is one node in a HID report descriptor.
type ItemType ¶
type ItemType uint8
ItemType is the HID short item "type" field. See HID 1.11 spec: Main=0, Global=1, Local=2, Reserved=3.
type LogicalMaximum ¶
type LogicalMaximum struct{ Max int32 }
LogicalMaximum sets the logical maximum (Global item, tag 0x2).
type LogicalMinimum ¶
type LogicalMinimum struct{ Min int32 }
LogicalMinimum sets the logical minimum (Global item, tag 0x1).
type MainFlags ¶
type MainFlags uint8
const ( MainData MainFlags = 0x00 MainConst MainFlags = 0x01 MainArray MainFlags = 0x00 MainVar MainFlags = 0x02 MainAbs MainFlags = 0x00 MainRel MainFlags = 0x04 MainNoWrap MainFlags = 0x00 MainWrap MainFlags = 0x08 MainLinear MainFlags = 0x00 MainNonLinear MainFlags = 0x10 MainPreferredState MainFlags = 0x00 MainNoPreferredState MainFlags = 0x20 MainNoNullPosition MainFlags = 0x00 MainNullState MainFlags = 0x40 MainNonVolatile MainFlags = 0x00 MainVolatile MainFlags = 0x80 )
type Report ¶
type Report struct {
Items []Item
}
Report is a complete HID report descriptor (type 0x22).
type ReportCount ¶
type ReportCount struct{ Count uint16 }
ReportCount sets report count (Global item, tag 0x9).
type ReportSize ¶
type ReportSize struct{ Bits uint8 }
ReportSize sets report size in bits (Global item, tag 0x7).
type UsageMaximum ¶
type UsageMaximum struct{ Max uint16 }
UsageMaximum sets the usage maximum (Local item, tag 0x2).
type UsageMinimum ¶
type UsageMinimum struct{ Min uint16 }
UsageMinimum sets the usage minimum (Local item, tag 0x1).