Documentation
¶
Index ¶
- type Action
- type ActionParams
- type Binding
- type Device
- type DeviceID
- type Error
- type ErrorDetails
- type Event
- type EventData
- type HelloSchemaJson
- type HelloSchemaJsonParams
- type HelloSchemaJsonResult
- type InputAction
- type InputEvent
- type InputKind
- type InputSchemaJson
- type ListDevicesSchemaJson
- type ListDevicesSchemaJsonParams
- type ListDevicesSchemaJsonResult
- type PeerInfo
- type Request
- type RequestParams
- type Response
- type ResponseErr
- type ResponseOk
- type ResponseOkData
- type SetBindingSchemaJson
- type SetBindingSchemaJsonParams
- type SetBindingSchemaJsonResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Action ¶
type Action struct {
// Action-specific parameters. Schema depends on 'type'.
Params ActionParams `json:"params,omitempty,omitzero" yaml:"params,omitempty" mapstructure:"params,omitempty"`
// Action type. Built-ins are well-known; plugin actions use
// 'plugin.<plugin_id>.<action_id>'.
Type string `json:"type" yaml:"type" mapstructure:"type"`
}
An executable action bound to an input.
func (*Action) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler.
type ActionParams ¶
type ActionParams map[string]interface{}
Action-specific parameters. Schema depends on 'type'.
type Binding ¶
type Binding struct {
// Action corresponds to the JSON schema field "action".
Action Action `json:"action" yaml:"action" mapstructure:"action"`
// DeviceId corresponds to the JSON schema field "device_id".
DeviceId DeviceID `json:"device_id" yaml:"device_id" mapstructure:"device_id"`
// InputId corresponds to the JSON schema field "input_id".
InputId string `json:"input_id" yaml:"input_id" mapstructure:"input_id"`
// Trigger corresponds to the JSON schema field "trigger".
Trigger InputAction `json:"trigger" yaml:"trigger" mapstructure:"trigger"`
}
Maps an input on a specific device to an action.
func (*Binding) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler.
type Device ¶
type Device struct {
// Id corresponds to the JSON schema field "id".
Id DeviceID `json:"id" yaml:"id" mapstructure:"id"`
// Manufacturer string from the HID descriptor. May be missing on cheap/clone
// devices.
Manufacturer *string `json:"manufacturer,omitempty,omitzero" yaml:"manufacturer,omitempty" mapstructure:"manufacturer,omitempty"`
// OS-opaque path used by the HID library to (re)open the device. Format varies
// per OS; clients should treat it as an opaque token.
Path string `json:"path" yaml:"path" mapstructure:"path"`
// Product name string from the HID descriptor.
Product *string `json:"product,omitempty,omitzero" yaml:"product,omitempty" mapstructure:"product,omitempty"`
// USB Product ID as a 4-digit hexadecimal string (lowercase or uppercase, no '0x'
// prefix).
ProductId string `json:"product_id" yaml:"product_id" mapstructure:"product_id"`
// Serial number string from the HID descriptor. Not all HID devices expose one.
SerialNumber *string `json:"serial_number,omitempty,omitzero" yaml:"serial_number,omitempty" mapstructure:"serial_number,omitempty"`
// USB Vendor ID as a 4-digit hexadecimal string (lowercase or uppercase, no '0x'
// prefix).
VendorId string `json:"vendor_id" yaml:"vendor_id" mapstructure:"vendor_id"`
}
A HID device known to the daemon. Returned by list_devices.
func (*Device) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler.
type DeviceID ¶
type DeviceID string
Stable identifier for a HID device. Format: VID_<hex>_PID_<hex>[_<serial>].
func (*DeviceID) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler.
type Error ¶
type Error struct {
// Stable, machine-readable error code in SCREAMING_SNAKE_CASE.
Code string `json:"code" yaml:"code" mapstructure:"code"`
// Optional structured context for debugging.
Details ErrorDetails `json:"details,omitempty,omitzero" yaml:"details,omitempty" mapstructure:"details,omitempty"`
// Human-readable error message. Free form, may be localized in future versions.
Message string `json:"message" yaml:"message" mapstructure:"message"`
}
Failure payload returned in a Response with ok=false.
func (*Error) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler.
type ErrorDetails ¶
type ErrorDetails map[string]interface{}
Optional structured context for debugging.
type Event ¶
type Event struct {
// Event-specific payload. Refined by the schema in
// schemas/events/<name>.schema.json.
Data EventData `json:"data" yaml:"data" mapstructure:"data"`
// Event name in snake_case.
Name string `json:"name" yaml:"name" mapstructure:"name"`
// Type corresponds to the JSON schema field "type".
Type interface{} `json:"type" yaml:"type" mapstructure:"type"`
}
Server -> client, no correlation. Stream of hardware events or daemon notifications.
func (*Event) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler.
type EventData ¶
type EventData map[string]interface{}
Event-specific payload. Refined by the schema in schemas/events/<name>.schema.json.
type HelloSchemaJson ¶
type HelloSchemaJson struct {
// Params corresponds to the JSON schema field "params".
Params HelloSchemaJsonParams `json:"params" yaml:"params" mapstructure:"params"`
// Result corresponds to the JSON schema field "result".
Result HelloSchemaJsonResult `json:"result" yaml:"result" mapstructure:"result"`
}
Mandatory first request after a WebSocket connection is established. The client declares the protocol_version it speaks. The server either accepts (Response.ok=true with its own identification) or closes the connection with an UNSUPPORTED_PROTOCOL_VERSION error. After a successful hello no further version negotiation happens; the contract is fixed for the session.
func (*HelloSchemaJson) UnmarshalJSON ¶
func (j *HelloSchemaJson) UnmarshalJSON(value []byte) error
UnmarshalJSON implements json.Unmarshaler.
type HelloSchemaJsonParams ¶
type HelloSchemaJsonParams struct {
// Client corresponds to the JSON schema field "client".
Client PeerInfo `json:"client" yaml:"client" mapstructure:"client"`
// Major version of the protocol the client implements. Currently '1'.
ProtocolVersion string `json:"protocol_version" yaml:"protocol_version" mapstructure:"protocol_version"`
}
func (*HelloSchemaJsonParams) UnmarshalJSON ¶
func (j *HelloSchemaJsonParams) UnmarshalJSON(value []byte) error
UnmarshalJSON implements json.Unmarshaler.
type HelloSchemaJsonResult ¶
type HelloSchemaJsonResult struct {
// Protocol version the server agrees to speak for this session.
ProtocolVersion string `json:"protocol_version" yaml:"protocol_version" mapstructure:"protocol_version"`
// Server corresponds to the JSON schema field "server".
Server PeerInfo `json:"server" yaml:"server" mapstructure:"server"`
}
func (*HelloSchemaJsonResult) UnmarshalJSON ¶
func (j *HelloSchemaJsonResult) UnmarshalJSON(value []byte) error
UnmarshalJSON implements json.Unmarshaler.
type InputAction ¶
type InputAction string
const InputActionClick InputAction = "click"
const InputActionPress InputAction = "press"
const InputActionRelease InputAction = "release"
const InputActionRotateCcw InputAction = "rotate_ccw"
const InputActionRotateCw InputAction = "rotate_cw"
func (*InputAction) UnmarshalJSON ¶
func (j *InputAction) UnmarshalJSON(value []byte) error
UnmarshalJSON implements json.Unmarshaler.
type InputEvent ¶
type InputEvent struct {
// Action corresponds to the JSON schema field "action".
Action InputAction `json:"action" yaml:"action" mapstructure:"action"`
// DeviceId corresponds to the JSON schema field "device_id".
DeviceId DeviceID `json:"device_id" yaml:"device_id" mapstructure:"device_id"`
// Logical identifier of the input within the device (e.g. 'K1', 'ENC1').
InputId string `json:"input_id" yaml:"input_id" mapstructure:"input_id"`
// Kind corresponds to the JSON schema field "kind".
Kind InputKind `json:"kind" yaml:"kind" mapstructure:"kind"`
// Unix epoch in milliseconds when the event was captured by the daemon.
TimestampMs int `json:"timestamp_ms" yaml:"timestamp_ms" mapstructure:"timestamp_ms"`
}
A single hardware event coming from a HID device.
func (*InputEvent) UnmarshalJSON ¶
func (j *InputEvent) UnmarshalJSON(value []byte) error
UnmarshalJSON implements json.Unmarshaler.
type InputKind ¶
type InputKind string
const InputKindEncoder InputKind = "encoder"
const InputKindKey InputKind = "key"
func (*InputKind) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler.
type InputSchemaJson ¶
type InputSchemaJson struct {
// Data corresponds to the JSON schema field "data".
Data InputEvent `json:"data" yaml:"data" mapstructure:"data"`
}
Pushed by the daemon for every hardware event captured on a connected HID device. High-frequency: encoders may emit many per second.
func (*InputSchemaJson) UnmarshalJSON ¶
func (j *InputSchemaJson) UnmarshalJSON(value []byte) error
UnmarshalJSON implements json.Unmarshaler.
type ListDevicesSchemaJson ¶
type ListDevicesSchemaJson struct {
// No parameters in v1.
Params ListDevicesSchemaJsonParams `json:"params" yaml:"params" mapstructure:"params"`
// Result corresponds to the JSON schema field "result".
Result ListDevicesSchemaJsonResult `json:"result" yaml:"result" mapstructure:"result"`
}
Returns the HID devices currently known to the daemon. No filters in v1; clients filter client-side if needed.
func (*ListDevicesSchemaJson) UnmarshalJSON ¶
func (j *ListDevicesSchemaJson) UnmarshalJSON(value []byte) error
UnmarshalJSON implements json.Unmarshaler.
type ListDevicesSchemaJsonParams ¶
type ListDevicesSchemaJsonParams map[string]interface{}
No parameters in v1.
type ListDevicesSchemaJsonResult ¶
type ListDevicesSchemaJsonResult struct {
// All currently enumerated HID devices.
Devices []Device `json:"devices" yaml:"devices" mapstructure:"devices"`
}
func (*ListDevicesSchemaJsonResult) UnmarshalJSON ¶
func (j *ListDevicesSchemaJsonResult) UnmarshalJSON(value []byte) error
UnmarshalJSON implements json.Unmarshaler.
type PeerInfo ¶
type PeerInfo struct {
// Stable identifier of the peer implementation.
Name string `json:"name" yaml:"name" mapstructure:"name"`
// Semver version of the peer build.
Version string `json:"version" yaml:"version" mapstructure:"version"`
}
Self-identification of a protocol peer (client or server).
func (*PeerInfo) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler.
type Request ¶
type Request struct {
// Client-generated correlation id (UUID v4 or nanoid).
Id string `json:"id" yaml:"id" mapstructure:"id"`
// Method name in snake_case.
Method string `json:"method" yaml:"method" mapstructure:"method"`
// Method-specific arguments. Refined by the schema in
// schemas/methods/<method>.schema.json.
Params RequestParams `json:"params" yaml:"params" mapstructure:"params"`
// Type corresponds to the JSON schema field "type".
Type interface{} `json:"type" yaml:"type" mapstructure:"type"`
}
Client -> server. Expects a correlated Response with the same id.
func (*Request) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler.
type RequestParams ¶
type RequestParams map[string]interface{}
Method-specific arguments. Refined by the schema in schemas/methods/<method>.schema.json.
type ResponseErr ¶
type ResponseErr struct {
// Error corresponds to the JSON schema field "error".
Error Error `json:"error" yaml:"error" mapstructure:"error"`
// Echo of the original Request.id.
Id string `json:"id" yaml:"id" mapstructure:"id"`
// Ok corresponds to the JSON schema field "ok".
Ok interface{} `json:"ok" yaml:"ok" mapstructure:"ok"`
// Type corresponds to the JSON schema field "type".
Type interface{} `json:"type" yaml:"type" mapstructure:"type"`
}
func (*ResponseErr) UnmarshalJSON ¶
func (j *ResponseErr) UnmarshalJSON(value []byte) error
UnmarshalJSON implements json.Unmarshaler.
type ResponseOk ¶
type ResponseOk struct {
// Method-specific result. Refined by the schema in
// schemas/methods/<method>.schema.json.
Data ResponseOkData `json:"data" yaml:"data" mapstructure:"data"`
// Echo of the original Request.id.
Id string `json:"id" yaml:"id" mapstructure:"id"`
// Ok corresponds to the JSON schema field "ok".
Ok interface{} `json:"ok" yaml:"ok" mapstructure:"ok"`
// Type corresponds to the JSON schema field "type".
Type interface{} `json:"type" yaml:"type" mapstructure:"type"`
}
func (*ResponseOk) UnmarshalJSON ¶
func (j *ResponseOk) UnmarshalJSON(value []byte) error
UnmarshalJSON implements json.Unmarshaler.
type ResponseOkData ¶
type ResponseOkData map[string]interface{}
Method-specific result. Refined by the schema in schemas/methods/<method>.schema.json.
type SetBindingSchemaJson ¶
type SetBindingSchemaJson struct {
// Params corresponds to the JSON schema field "params".
Params SetBindingSchemaJsonParams `json:"params" yaml:"params" mapstructure:"params"`
// Empty acknowledgement object. Reserved for future fields (e.g. server-assigned
// binding id) without breaking the schema.
Result SetBindingSchemaJsonResult `json:"result" yaml:"result" mapstructure:"result"`
}
Creates or updates a binding (input -> action) on a device. The pair (device_id, input_id, trigger) is the unique key; calling this method with an existing key replaces the previous action.
func (*SetBindingSchemaJson) UnmarshalJSON ¶
func (j *SetBindingSchemaJson) UnmarshalJSON(value []byte) error
UnmarshalJSON implements json.Unmarshaler.
type SetBindingSchemaJsonParams ¶
type SetBindingSchemaJsonParams struct {
// Binding corresponds to the JSON schema field "binding".
Binding Binding `json:"binding" yaml:"binding" mapstructure:"binding"`
}
func (*SetBindingSchemaJsonParams) UnmarshalJSON ¶
func (j *SetBindingSchemaJsonParams) UnmarshalJSON(value []byte) error
UnmarshalJSON implements json.Unmarshaler.
type SetBindingSchemaJsonResult ¶
type SetBindingSchemaJsonResult map[string]interface{}
Empty acknowledgement object. Reserved for future fields (e.g. server-assigned binding id) without breaking the schema.