Documentation ¶
Overview ¶
Package input normalizes inputs from systems
Index ¶
- Constants
- func System(g *gorge.Context)
- type ActionState
- type Context
- type EventChar
- type EventKeyDown
- type EventKeyUp
- type EventMouseButtonDown
- type EventMouseButtonUp
- type EventPointer
- type Input
- func (m *Input) CursorDelta() gm.Vec2
- func (m *Input) CursorPosition() gm.Vec2
- func (m *Input) KeyDown(k Key) bool
- func (m *Input) KeyPress(k Key) bool
- func (m *Input) KeyUp(k Key) bool
- func (m *Input) MouseButtonClick(k MouseButton) bool
- func (m *Input) MouseButtonDown(k MouseButton) bool
- func (m *Input) MouseButtonUp(k MouseButton) bool
- func (m *Input) ScrollDelta() gm.Vec2
- func (m *Input) SetCursorDelta(d gm.Vec2)
- func (m *Input) SetCursorPosition(p gm.Vec2)
- func (m *Input) SetKeyChar(c rune)
- func (m *Input) SetKeyState(key Key, s ActionState)
- func (m *Input) SetMouseButtonState(b MouseButton, s ActionState)
- func (m *Input) SetScrollDelta(delta gm.Vec2)
- type Key
- type MouseButton
- type PointerData
- type PointerType
Constants ¶
const ( ActionDown ActionHold ActionUp )
Action states used in keys and buttons.
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
const ( MouseUnknown = MouseButton(iota) MouseLeft MouseRight MouseMiddle // aka wheel MouseThumb1 MouseThumb2 )
Mouse button constants.
const ( MouseDown MouseUp MouseMove MouseWheel PointerDown PointerMove PointerEnd PointerCancel )
Pointer comments
Variables ¶
This section is empty.
Functions ¶
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 ¶
FromContext returns a input.Context from a gorge.Context
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 ¶
CursorDelta returns the current cursor position.
func (*Input) CursorPosition ¶
CursorPosition returns the current cursor position.
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) SetCursorDelta ¶
SetCursorDelta sets cursor position by delta.
func (*Input) SetCursorPosition ¶
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 ¶
type Key ¶
type Key int
Key represents a keyboard key.
type PointerData ¶
PointerData common
type PointerType ¶
type PointerType int
PointerType pointer event type
func (PointerType) String ¶
func (p PointerType) String() string