Documentation
¶
Overview ¶
Package hid encodes keyboard and mouse input as hidrpc messages (and the JSON-RPC fallbacks where hidrpc has no message type, e.g. the wheel).
Index ¶
- Constants
- func Keys(ctx context.Context, d kvm.Device, combos []string, layout string, holdMS int) error
- func MouseClick(ctx context.Context, d kvm.Device, p Point, b Button, count int) error
- func MouseMove(ctx context.Context, d kvm.Device, p Point) error
- func MouseScroll(ctx context.Context, d kvm.Device, dy, dx int) error
- func Type(ctx context.Context, d kvm.Device, text string, opt TypeOptions) error
- type Button
- type Point
- type TypeOptions
- type UntypableError
Constants ¶
const ( LayoutUS = "en-US" LayoutUK = "en-UK" )
Layout names accepted by Type and Keys. Values follow the firmware's keyboard layout ISO codes ("en-US", "en-UK", ...).
const ( ModCtrl byte = 0x01 ModShift byte = 0x02 ModAlt byte = 0x04 ModMeta byte = 0x08 ModRightCtrl byte = 0x10 ModRightShift byte = 0x20 ModAltGr byte = 0x40 // AltRight ModRightMeta byte = 0x80 )
USB HID modifier bits (firmware ui/src/keyboardMappings.ts `modifiers`).
Variables ¶
This section is empty.
Functions ¶
func Keys ¶
Keys presses each combo in turn ("win+x", "ctrl+alt+Delete", "enter", "f11", "shift"), releasing everything after each one. holdMS is how long each combo is held (0 = default).
func MouseClick ¶
MouseClick moves to p, presses and releases b (count times).
func MouseScroll ¶
MouseScroll sends wheel detents; positive dy = up. hidrpc has a wheel message type but 0.5.9 does not handle it, so this uses the JSON-RPC wheelReport like the UI.
Types ¶
type Point ¶
type Point struct {
X, Y float64
Normalized bool
Width, Height int // screen size in pixels; required when !Normalized
}
Point is an absolute position. If Normalized, X and Y are 0..1 of the screen; otherwise they are pixels of a Width x Height screen.
type TypeOptions ¶
type TypeOptions struct {
Layout string // "" = ask the device (getKeyboardLayout), else LayoutUS/LayoutUK
// Delay between characters; 0 = sensible default.
DelayMS int
}
TypeOptions controls Type.
type UntypableError ¶
type UntypableError struct {
Layout string
Chars []string // quoted runes, in the order they appear
}
UntypableError is returned by Type when the layout cannot produce some of the characters. Nothing has been sent to the device.
func (*UntypableError) Error ¶
func (e *UntypableError) Error() string