vinput

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: MIT, MIT Imports: 11 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package vinput injects pointer, keyboard and touch input into the compositor through zwlr_virtual_pointer_v1, zwp_virtual_keyboard_v1 and lys_virtual_touch_v1, on a private Wayland connection: the input half of a remote-desktop bridge, and of lys-ui's own headless test harness. The seat's keymap is relayed to the virtual keyboard, so key codes mean what they mean on the real keyboard.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoTouch = errors.New("vinput: compositor lacks lys_virtual_touch_manager_v1, so no virtual touchscreen")

ErrNoTouch is Dial's refusal of Options.Touch on a compositor that serves no lys_virtual_touch_manager_v1.

Functions

func TouchAvailable

func TouchAvailable(display string) (bool, error)

TouchAvailable reports whether the compositor on display serves lys_virtual_touch_manager_v1, so Dial can arm Options.Touch there.

Types

type AxisSource

type AxisSource uint32

AxisSource is what a scroll comes from (wl_pointer.axis_source): a finger scroll lets clients scroll kinetically, a wheel clicks.

const (
	SourceWheel      AxisSource = 0
	SourceFinger     AxisSource = 1
	SourceContinuous AxisSource = 2
	SourceWheelTilt  AxisSource = 3
)

The axis sources, wl_pointer's values.

type Device

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

Device is one virtual pointer and, optionally, keyboard. Its methods are safe to call from any goroutine.

func Dial

func Dial(display string, opts Options) (*Device, error)

Dial connects to display (an absolute socket path, a name inside XDG_RUNTIME_DIR, or "" for WAYLAND_DISPLAY) and creates the devices.

func (*Device) Axis

func (v *Device) Axis(src AxisSource, axis ScrollAxis, value float64) error

Axis scrolls axis by value, in wl_pointer axis units, from src: one frame carrying the motion and its source.

func (*Device) AxisDiscrete

func (v *Device) AxisDiscrete(src AxisSource, axis ScrollAxis, value float64, steps int32) error

AxisDiscrete scrolls whole steps (a wheel), value the axis units they amount to, from src.

func (*Device) AxisStop

func (v *Device) AxisStop(src AxisSource, axis ScrollAxis) error

AxisStop ends a scroll sequence from src on axis (wl_pointer.axis_stop), the stop and its source in one frame as a touchpad sends them: the fingers lifted, and a client may start its kinetic glide.

func (*Device) Button

func (v *Device) Button(code uint32, pressed bool) error

Button presses or releases an evdev button code.

func (*Device) Close

func (v *Device) Close()

Close destroys the devices and disconnects.

func (*Device) HandleDisplayError

func (v *Device) HandleDisplayError(ev wl.DisplayErrorEvent)

HandleDisplayError implements wl.DisplayErrorHandler: the compositor's fatal protocol error, for Dial's failure message.

func (*Device) Key

func (v *Device) Key(code uint32, pressed bool) error

Key presses or releases an evdev key code.

func (*Device) Keymap

func (v *Device) Keymap() []byte

Keymap is the xkb_v1 text the virtual keyboard carries (the seat's, or the fallback), nil without a keyboard.

func (*Device) Modifiers

func (v *Device) Modifiers(depressed, latched, locked, group uint32) error

Modifiers declares the modifier state explicitly (xkb masks), for a seat that cannot derive it from the keys.

func (*Device) Motion

func (v *Device) Motion(dx, dy float64) error

Motion moves the pointer by (dx, dy).

func (*Device) MotionAbsolute

func (v *Device) MotionAbsolute(x, y, width, height uint32) error

MotionAbsolute moves the pointer to (x, y) within an extent of width x height (the compositor maps it onto its layout).

func (*Device) OutputSize

func (v *Device) OutputSize() (width, height int32)

OutputSize is the first output's current mode, 0x0 without one.

func (*Device) Roundtrip

func (v *Device) Roundtrip() error

Roundtrip waits until the compositor processed every request sent.

func (*Device) TouchCancel

func (v *Device) TouchCancel() error

TouchCancel cancels every touch point of the device.

func (*Device) TouchDown

func (v *Device) TouchDown(id, x, y, width, height uint32) error

TouchDown puts touch point id (below 65536) down at (x, y) within an extent of width x height spanning the output layout.

func (*Device) TouchMotion

func (v *Device) TouchMotion(id, x, y, width, height uint32) error

TouchMotion moves touch point id to (x, y) as TouchDown places it.

func (*Device) TouchUp

func (v *Device) TouchUp(id uint32) error

TouchUp lifts touch point id.

type Options

type Options struct {
	// Keyboard arms the virtual keyboard too; a pointer-only device
	// is the shape of a seat whose input devices are pointers only.
	Keyboard bool
	// Touch arms a virtual touchscreen spanning the output layout, which
	// only a compositor serving lys_virtual_touch_manager_v1 offers.
	Touch bool
	// FallbackKeymap is xkb_v1 text uploaded when the seat announces
	// none (a virtual-only seat, a headless compositor): the protocol
	// refuses key events before any keymap is set.
	FallbackKeymap []byte
	// Keymap is xkb_v1 text the keyboard carries instead of the seat's, the
	// way a tool such as wtype numbers keys its own way. It wins over the
	// seat's keymap and FallbackKeymap.
	Keymap []byte
}

Options tunes Dial.

type ScrollAxis

type ScrollAxis uint32

ScrollAxis is a wl_pointer axis.

const (
	AxisVertical   ScrollAxis = 0
	AxisHorizontal ScrollAxis = 1
)

The scroll axes.

Jump to

Keyboard shortcuts

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