input

package
v0.0.0-...-6aa7f09 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2023 License: Apache-2.0 Imports: 4 Imported by: 2

Documentation

Overview

Package input normalizes inputs from systems

Index

Constants

View Source
const (
	ActionDown
	ActionHold
	ActionUp
)

Action states used in keys and buttons.

View Source
const (
	KeyUnknown = Key(iota)
	KeySpace
	KeyApostrophe
	KeyComma
	KeyMinus
	KeyPeriod
	KeySlash
	Key0
	Key1
	Key2
	Key3
	Key4
	Key5
	Key6
	Key7
	Key8
	Key9
	KeySemicolon
	KeyEqual
	KeyA
	KeyB
	KeyC
	KeyD
	KeyE
	KeyF
	KeyG
	KeyH
	KeyI
	KeyJ
	KeyK
	KeyL
	KeyM
	KeyN
	KeyO
	KeyP
	KeyQ
	KeyR
	KeyS
	KeyT
	KeyU
	KeyV
	KeyW
	KeyX
	KeyY
	KeyZ
	KeyLeftBracket
	KeyBackslash
	KeyRightBracket
	KeyGraveAccent
	KeyWorld1
	KeyWorld2
	KeyEscape
	KeyEnter
	KeyTab
	KeyBackspace
	KeyInsert
	KeyDelete
	KeyArrowRight
	KeyArrowLeft
	KeyArrowDown
	KeyArrowUp
	KeyPageUp
	KeyPageDown
	KeyHome
	KeyEnd
	KeyCapsLock
	KeyScrollLock
	KeyNumLock
	KeyPrintScreen
	KeyPause
	KeyF1
	KeyF2
	KeyF3
	KeyF4
	KeyF5
	KeyF6
	KeyF7
	KeyF8
	KeyF9
	KeyF10
	KeyF11
	KeyF12
	KeyF13
	KeyF14
	KeyF15
	KeyF16
	KeyF17
	KeyF18
	KeyF19
	KeyF20
	KeyF21
	KeyF22
	KeyF23
	KeyF24
	KeyF25
	KeyKP0
	KeyKP1
	KeyKP2
	KeyKP3
	KeyKP4
	KeyKP5
	KeyKP6
	KeyKP7
	KeyKP8
	KeyKP9
	KeyKPDecimal
	KeyKPDivide
	KeyKPMultiply
	KeyKPSubtract
	KeyKPAdd
	KeyKPEnter
	KeyKPEqual
	KeyLeftShift
	KeyLeftControl
	KeyLeftAlt
	KeyLeftSuper
	KeyRightShift
	KeyRightControl
	KeyRightAlt
	KeyRightSuper
	KeyMenu
	KeyLast
)

Known input keys

View Source
const (
	MouseUnknown = MouseButton(iota)
	MouseLeft
	MouseRight
	MouseMiddle // aka wheel
	MouseThumb1
	MouseThumb2
)

Mouse button constants.

View Source
const (
	MouseDown
	MouseUp
	MouseMove
	MouseWheel
	PointerDown
	PointerMove
	PointerEnd
	PointerCancel
)

Pointer comments

Variables

This section is empty.

Functions

func System

func System(g *gorge.Context)

Types

type ActionState

type ActionState int

ActionState type

func (ActionState) String

func (k ActionState) String() string

type Context

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

Context to be used in gorge systems

func FromContext

func FromContext(g *gorge.Context) *Context

FromContext returns a input.Context from a gorge.Context

func (Context) IsDown

func (c Context) IsDown(v any) bool

IsDown checks if wether a key or mouse button is pressed.

func (Context) IsPressed

func (c Context) IsPressed(v any) bool

IsPressed alias to IsUp.

func (Context) IsUp

func (c Context) IsUp(v any) bool

IsUp checks if wether a key or mouse button is released.

type EventChar

type EventChar struct {
	Char rune
}

type EventKeyDown

type EventKeyDown struct {
	Key Key
}

EventKeyDown keydown event.

type EventKeyUp

type EventKeyUp struct {
	Key Key
}

EventKeyUp keyup event.

type EventMouseButtonDown

type EventMouseButtonDown struct {
	Button MouseButton
	PointerData
}

EventMouseButtonDown is triggered when a mouse button is pressed.

type EventMouseButtonUp

type EventMouseButtonUp struct {
	Button MouseButton
	PointerData
}

EventMouseButtonUp is triggered when a mouse button is released.

type EventPointer

type EventPointer struct {
	Type     PointerType
	Button   int // number of button or -1 for touch?
	Pointers map[int]PointerData
}

EventPointer on canvas

type Input

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

Input system tied to manager

func (*Input) CursorDelta

func (m *Input) CursorDelta() gm.Vec2

CursorDelta returns the current cursor position.

func (*Input) CursorPosition

func (m *Input) CursorPosition() gm.Vec2

CursorPosition returns the current cursor position.

func (*Input) KeyDown

func (m *Input) KeyDown(k Key) bool

func (*Input) KeyPress

func (m *Input) KeyPress(k Key) bool

GetKey checks if a key was pressed

func (*Input) KeyUp

func (m *Input) KeyUp(k Key) bool

func (*Input) MouseButtonClick

func (m *Input) MouseButtonClick(k MouseButton) bool

MouseButtonClick similar to MouseButtonUp

func (*Input) MouseButtonDown

func (m *Input) MouseButtonDown(k MouseButton) bool

MouseButtonDown returns true if the state of the mouse button is Down or Hold.

func (*Input) MouseButtonUp

func (m *Input) MouseButtonUp(k MouseButton) bool

MouseButtonUp returns true if the last mouse button state was up.

func (*Input) ScrollDelta

func (m *Input) ScrollDelta() gm.Vec2

ScrollDelta returns scrollDelta.

func (*Input) SetCursorDelta

func (m *Input) SetCursorDelta(d gm.Vec2)

SetCursorDelta sets cursor position by delta.

func (*Input) SetCursorPosition

func (m *Input) SetCursorPosition(p gm.Vec2)

func (*Input) SetKeyChar

func (m *Input) SetKeyChar(c rune)

SetKeyChar triggers an EventKeyChar event

func (*Input) SetKeyState

func (m *Input) SetKeyState(key Key, s ActionState)

func (*Input) SetMouseButtonState

func (m *Input) SetMouseButtonState(b MouseButton, s ActionState)

func (*Input) SetScrollDelta

func (m *Input) SetScrollDelta(delta gm.Vec2)

type Key

type Key int

Key represents a keyboard key.

func (Key) Char

func (k Key) Char() string

Char returns the default character for the specific key us layout based?

func (Key) String

func (k Key) String() string

type MouseButton

type MouseButton int

MouseButton represents a mouse button.

type PointerData

type PointerData struct {
	ScrollDelta gm.Vec2 // for Wheel
	Pos         gm.Vec2
}

PointerData common

type PointerType

type PointerType int

PointerType pointer event type

func (PointerType) String

func (p PointerType) String() string

Jump to

Keyboard shortcuts

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