inputbackend

package
v0.0.0-...-c7db75a Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2021 License: GPL-3.0 Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Interface

type Interface interface {
	// Process processes any events.
	Process() error
	// CursorPosition returns a position of a mouse cursor relative to the game screen (window).
	CursorPosition() (x int, y int)
	// InputChars return "printable" runes read from the keyboard at the time update is called.
	InputChars() []rune
	// IsKeyPressed checks if the provided key is down.
	IsKeyPressed(key Key) bool
	// IsKeyJustPressed checks if the provided key is just transitioned from up to down.
	IsKeyJustPressed(key Key) bool
	// IsKeyJustReleased checks if the provided key is just transitioned from down to up.
	IsKeyJustReleased(key Key) bool
	// IsMouseButtonPressed checks if the provided mouse button is down.
	IsMouseButtonPressed(button MouseButton) bool
	// IsMouseButtonJustPressed checks if the provided mouse button is just transitioned from up to down.
	IsMouseButtonJustPressed(button MouseButton) bool
	// IsMouseButtonJustReleased checks if the provided mouse button is just transitioned from down to up.
	IsMouseButtonJustReleased(button MouseButton) bool
	// KeyPressDuration returns how long the key is pressed in frames.
	KeyPressDuration(key Key) int
}

Interface represents an interface offering Keyboard and Mouse interactions.

type Key

type Key int

Key represents button on a traditional keyboard.

const (
	Key0 Key = iota
	Key1
	Key2
	Key3
	Key4
	Key5
	Key6
	Key7
	Key8
	Key9
	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
	KeyApostrophe
	KeyBackslash
	KeyBackspace
	KeyCapsLock
	KeyComma
	KeyDelete
	KeyDown
	KeyEnd
	KeyEnter
	KeyEqual
	KeyEscape
	KeyF1
	KeyF2
	KeyF3
	KeyF4
	KeyF5
	KeyF6
	KeyF7
	KeyF8
	KeyF9
	KeyF10
	KeyF11
	KeyF12
	KeyGraveAccent
	KeyHome
	KeyInsert
	KeyKP0
	KeyKP1
	KeyKP2
	KeyKP3
	KeyKP4
	KeyKP5
	KeyKP6
	KeyKP7
	KeyKP8
	KeyKP9
	KeyKPAdd
	KeyKPDecimal
	KeyKPDivide
	KeyKPEnter
	KeyKPEqual
	KeyKPMultiply
	KeyKPSubtract
	KeyLeft
	KeyLeftBracket
	KeyMenu
	KeyMinus
	KeyNumLock
	KeyPageDown
	KeyPageUp
	KeyPause
	KeyPeriod
	KeyPrintScreen
	KeyRight
	KeyRightBracket
	KeyScrollLock
	KeySemicolon
	KeySlash
	KeySpace
	KeyTab
	KeyUp
	KeyAlt
	KeyControl
	KeyShift
	KeyTilde
	KeyMouse3
	KeyMouse4
	KeyMouse5
	KeyMouseWheelUp
	KeyMouseWheelDown

	KeyMin = Key0
	KeyMax = KeyMouseWheelDown
)

Input keys

type KeyMod

type KeyMod int

KeyMod represents a "modified" key action. This could mean, for example, ctrl-S

const (
	// KeyModAlt is the Alt key modifier
	KeyModAlt KeyMod = 1 << iota
	// KeyModControl is the Control key modifier
	KeyModControl
	// KeyModShift is the Shift key modifier
	KeyModShift
)

type MouseButton

type MouseButton int

MouseButton represents a traditional 3-button mouse

const (
	// MouseButtonLeft is the left mouse button
	MouseButtonLeft MouseButton = iota
	// MouseButtonMiddle is the middle mouse button
	MouseButtonMiddle
	// MouseButtonRight is the right mouse button
	MouseButtonRight
	// MouseButtonMin is the lowest MouseButton
	MouseButtonMin = MouseButtonLeft
	// MouseButtonMax is the highest MouseButton
	MouseButtonMax = MouseButtonRight
)

type MouseButtonMod

type MouseButtonMod int

MouseButtonMod represents a "modified" mouse button action. This could mean, for example, ctrl-mouse_left

const (
	// MouseButtonModLeft is a modified left mouse button
	MouseButtonModLeft MouseButtonMod = 1 << iota
	// MouseButtonModMiddle is a modified middle mouse button
	MouseButtonModMiddle
	// MouseButtonModRight is a modified right mouse button
	MouseButtonModRight
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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