linuxinput

package
v2.8.0 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2026 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DeviceName     = "Zaparoo"
	DefaultTimeout = 40 * time.Millisecond
)

Variables

Functions

func ParseKeyCombo added in v2.7.0

func ParseKeyCombo(arg string) (codes []int, isCombo bool, err error)

ParseKeyCombo parses a keyboard key argument string and returns the corresponding key codes. It supports both single keys (e.g., "a", "{f9}") and combo keys with the "+" delimiter (e.g., "{ctrl+q}", "{shift+a}").

The function returns:

  • codes: slice of keyboard codes ready to be used with Press() or Combo()
  • isCombo: true if multiple keys detected (use Combo()), false for single key (use Press())
  • error: if any key name is unknown

Examples:

  • ParseKeyCombo("a") -> [30], false, nil
  • ParseKeyCombo("{f9}") -> [67], false, nil
  • ParseKeyCombo("{ctrl+q}") -> [29, 16], true, nil
  • ParseKeyCombo("{shift+a}") -> [42, 30], true, nil

func ToGamepadCode

func ToGamepadCode(name string) (int, bool)

ToGamepadCode converts a single ZapScript button symbol to a uinput code.

func ToKeyboardCode

func ToKeyboardCode(name string) (int, bool)

ToKeyboardCode converts a single ZapScript key symbol to a uinput code.

Types

type Gamepad

type Gamepad struct {
	Device uinput.Gamepad
	Delay  time.Duration
}

func NewGamepad

func NewGamepad(delay time.Duration) (Gamepad, error)

NewGamepad returns a uinput virtual gamepad device. It takes a delay duration which is used between presses to avoid overloading the OS or user applications. This device must be closed when the service stops.

func (*Gamepad) Close

func (k *Gamepad) Close() error

func (*Gamepad) Combo

func (k *Gamepad) Combo(keys ...int) error

func (*Gamepad) Press

func (k *Gamepad) Press(key int) error

type Keyboard

type Keyboard struct {
	Device uinput.Keyboard
	Delay  time.Duration
}

func NewKeyboard

func NewKeyboard(delay time.Duration) (Keyboard, error)

NewKeyboard returns a uinput virtual keyboard device. It takes a delay duration which is used between presses to avoid overloading the OS or user applications. This device must be closed when the service stops.

func (*Keyboard) Close

func (k *Keyboard) Close() error

func (*Keyboard) Combo

func (k *Keyboard) Combo(keys ...int) error

func (*Keyboard) Press

func (k *Keyboard) Press(key int) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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