input

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package input defines backend-neutral input snapshots and events consumed by game. It should not know about Ragnarok gameplay, rendering, or network packets.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Key

type Key int
const (
	KeyEnter Key = iota
	KeyEscape
	KeyTab
	KeyArrowUp
	KeyArrowDown
	KeyArrowLeft
	KeyArrowRight
	KeyBackspace
	KeyShift
	KeyCtrl
	KeyAlt
	KeyG
	KeyL
	Key1
	Key2
	Key3
	Key4
	Key5
	Key6
	Key7
	Key8
	Key9
	KeyQ
	KeyW
	KeyE
	KeyR
	KeyT
	KeyY
	KeyU
	KeyI
	KeyO
	KeyF1
	KeyF2
	KeyF3
	KeyF4
	KeyF5
	KeyF6
	KeyF7
	KeyF8
	KeyF9
	KeyF12
)

type KeyCode added in v0.7.0

type KeyCode = gpucontext.Key

KeyCode identifies a physical keyboard position. Its names follow the browser KeyboardEvent.code convention (KeyW, Digit1, ArrowUp, and so on).

func KeyCodeFromName added in v0.7.0

func KeyCodeFromName(name string) (KeyCode, bool)

KeyCodeFromName resolves a layout-independent physical key name. Names use the same vocabulary as browser KeyboardEvent.code so scripts remain clear across QWERTY, AZERTY, and other layouts.

type MouseButton

type MouseButton int
const (
	MouseButtonLeft MouseButton = iota
	MouseButtonRight
)

type State

type State struct {
	MouseX  int
	MouseY  int
	MouseDX int
	MouseDY int

	WheelX float64
	WheelY float64

	TouchPoints []TouchPoint
	PinchDelta  float64
	// contains filtered or unexported fields
}

func NewState

func NewState() *State

func (*State) AddTextInput

func (s *State) AddTextInput(text string)

func (*State) AddWheel

func (s *State) AddWheel(x, y float64)

func (*State) ConsumeKeyCodePress added in v0.7.0

func (s *State) ConsumeKeyCodePress(code KeyCode) bool

ConsumeKeyCodePress reports a new physical key press once and prevents other physical-key consumers from acting on the same edge. Held state and layout-translated text input are left unchanged.

func (*State) EndFrame

func (s *State) EndFrame()

func (*State) JustPressed

func (s *State) JustPressed(key Key) bool

func (*State) KeyCodeDown added in v0.7.0

func (s *State) KeyCodeDown(code KeyCode) bool

func (*State) KeyCodeJustPressed added in v0.7.0

func (s *State) KeyCodeJustPressed(code KeyCode) bool

func (*State) KeyCodeJustReleased added in v0.7.0

func (s *State) KeyCodeJustReleased(code KeyCode) bool

func (*State) MouseJustPressed

func (s *State) MouseJustPressed(button MouseButton) bool

func (*State) MouseJustReleased

func (s *State) MouseJustReleased(button MouseButton) bool

func (*State) MousePressed

func (s *State) MousePressed(button MouseButton) bool

func (*State) Pressed

func (s *State) Pressed(key Key) bool

func (*State) ResetKeyboard added in v0.11.0

func (s *State) ResetKeyboard()

ResetKeyboard forgets held keys and pending keyboard input after focus loss. Releases may happen in another window and never reach us. Clear the edge history too, so cancellation does not trigger actions bound to key releases.

func (*State) SetKey

func (s *State) SetKey(key Key, pressed bool)

func (*State) SetKeyCode added in v0.7.0

func (s *State) SetKeyCode(code KeyCode, pressed bool)

func (*State) SetMouseButton

func (s *State) SetMouseButton(button MouseButton, pressed bool)

func (*State) SetMousePosition

func (s *State) SetMousePosition(x, y int)

func (*State) SetTouch

func (s *State) SetTouch(id TouchID, x, y int, pressed bool)

func (*State) TextInput

func (s *State) TextInput() string

func (*State) Update

func (s *State) Update()

type TouchID

type TouchID int64

type TouchPoint

type TouchPoint struct {
	ID TouchID
	X  int
	Y  int
}

Jump to

Keyboard shortcuts

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