input

package
v0.0.0-...-acca49c Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

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

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action int

Action indicates what caused the key event to trigger. Either the key was pressed or the key was released. The This package GLFW action codes but you can use your own as long as the are of the Action type.

type Key

type Key int

Key represents a single key on the keyboard. This package exports GLFW key codes but you can use your own as long as the are of the Key type.

type KeyCommandExecutor

type KeyCommandExecutor interface {
	Execute(dt float64)
}

KeyCommandExecutor wraps the Execute command for key press callback.

Execute will be called once per simulation if the criteria is met within the Manager.

type KeyCommandExecutorFunc

type KeyCommandExecutorFunc func(dt float64)

KeyCommandExecutorFunc allows a callback to satisfy the KeyCommandExecutor interface. You would use this over satisfying the KeyCommandExecutor within a struct when the KeyCommandExecutor has no state.

func (KeyCommandExecutorFunc) Execute

func (c KeyCommandExecutorFunc) Execute(dt float64)

Execute will be called once per simulation if the criteria is met within the Manager.

type KeyEventMessage

type KeyEventMessage struct {
	Action   Action
	Key      Key
	Modifier ModifierKey
}

KeyEventMessage encapsulates the relevant information for a keyboard event. It should be dispatched when a WindowManager detects a keyboard event.

Upon receiving a KeyEventMessage the Manager will trigger the relevant command callbacks that the user has registered.

type ModifierKey

type ModifierKey int

ModifierKey represents a single keyboard modifier key. This package exports GLFW modifier codes but you can use your own as long as the are of the ModifierKey type.

type State

type State int

State represents the current state of a key within the input system.

const (
	// Release states that the listener will fire once when the key/button is released.
	Release State = iota
	// Press states that the listener will fire once when the key/button is pressed.
	Press
	// Release states that the listener will fire each frame while the key/button is pressed.
	Pressed
)

type System

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

System is responsible for executing all input commands.

System will subscribe to the KeyPressedEvent and KeyReleasedEvent topics of the supplied engine.Subscriber upon creation. When the System is notified of a KeyEventMessage it will call the KeyCommandExecutor registered with the specified key and action.

All KeyCommandExecutor's are called within the PreSimulate method to ensure that they only get called once per simulation.

func CreateSystem

func CreateSystem(subscriber engine.Subscriber) *System

CreateSystem creates a new System and subscribes the keyCallback to the KeyPressedEvent and KeyReleasedEvent via the passed in Subscriber.

func (*System) AddKeyCommands

func (s *System) AddKeyCommands(key Key, state State, commands ...KeyCommandExecutor)

AddKeyCommand will register the given commands, key and state within the Manager. The commands will be called once per simulation if the Manager has been notified of the relevant key and state changes.

func (*System) PreSimulate

func (s *System) PreSimulate(dt float64)

PreSimulate is responsible for triggering the registered KeyCommandExecutor's and should be called once per update.

The supplied dt (delta time) will be passed into all KeyCommandExecutor's.

Jump to

Keyboard shortcuts

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