input

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package input tracks keyboard state from gogpu EventSource callbacks.

Prefer this over polling Native().Input() — held-key polling is unreliable on some Wayland compositors, while press/release events stay consistent.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Wire

func Wire(es gpucontext.EventSource, keys *Keyboard, edges *Edges)

Wire registers Keyboard and/or Edges on an EventSource. Pass nil for either side you do not need.

Types

type Edges

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

Edges latches press and release events until the sim consumes them. Useful for one-shot actions (pause, confirm) that must not repeat every frame.

func NewEdges

func NewEdges() *Edges

NewEdges returns empty edge latches.

func (*Edges) ConsumePressed

func (e *Edges) ConsumePressed(key gpucontext.Key) bool

ConsumePressed returns true once per press edge for key.

func (*Edges) ConsumeReleased

func (e *Edges) ConsumeReleased(key gpucontext.Key) bool

ConsumeReleased returns true once per release edge for key.

func (*Edges) OnPress

func (e *Edges) OnPress(key gpucontext.Key)

OnPress records a key-down edge. Call from EventSource OnKeyPress.

func (*Edges) OnRelease

func (e *Edges) OnRelease(key gpucontext.Key)

OnRelease records a key-up edge. Call from EventSource OnKeyRelease.

type Keyboard

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

Keyboard tracks which keys are currently held.

func NewKeyboard

func NewKeyboard() *Keyboard

NewKeyboard returns an empty held-key map.

func (*Keyboard) Pressed

func (k *Keyboard) Pressed(key gpucontext.Key) bool

Pressed reports whether key is currently held.

func (*Keyboard) Set

func (k *Keyboard) Set(key gpucontext.Key, pressed bool)

Set records whether key is currently down. Call from OnKeyPress/OnKeyRelease.

Jump to

Keyboard shortcuts

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