Documentation ¶
Index ¶
- type GameController
- type State
- func (s *State) AddController(index int, v GameController) bool
- func (s *State) GetController(index int) (GameController, bool)
- func (s *State) KeyDown(name string) bool
- func (s *State) KeysDown(shifted bool) []string
- func (s *State) RemoveController(index int) bool
- func (s *State) ResetKeyDown()
- func (s *State) SetKeyDown(name string, down bool)
- type Vector
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GameController ¶
type GameController interface { ID() int // Usually the controller index number Name() string // Friendly name of the controller // State setters, to be called by the engine. // Note: button names are implementation-specific, use Button*() methods in your code. SetButtonState(name string, pressed bool) GetButtonState(name string) bool SetAxisState(name string, value int) // value maybe -32768 to 32767 // State getters. ButtonA() bool ButtonB() bool ButtonX() bool ButtonY() bool ButtonL1() bool // Left shoulder ButtonR1() bool // Right shoulder ButtonL2() bool // Left trigger (digital) ButtonR2() bool // Right trigger (digital) ButtonLStick() bool ButtonRStick() bool ButtonStart() bool ButtonSelect() bool // Back button ButtonHome() bool // Guide button // D-Pad buttons. ButtonUp() bool ButtonLeft() bool ButtonRight() bool ButtonDown() bool // Axis getters. Returns Vectors ranging from -1.0 to 1.0 being a // percentage of the axis between neutral and maxed out. LeftStick() Vector RightStick() Vector LeftTrigger() float64 RightTrigger() float64 }
GameController holds event state for one or more (Xbox-style) controllers.
type State ¶
type State struct { // Mouse buttons. Button1 bool // Left Button2 bool // Middle Button3 bool // Right // Special keys Escape bool Space bool Enter bool Shift bool Ctrl bool Alt bool Up bool Left bool Right bool Down bool // Cursor position CursorX int CursorY int // Window resized WindowResized bool // Touch state Touching bool TouchNumFingers int TouchCenterX int TouchCenterY int GestureRotated float64 GesturePinched float64 // Game controller events. // NOTE: for SDL2 you will need to call GameControllerEventState(1) // from veandco/go-sdl2/sdl for events to be read by SDL2. Controllers map[int]GameController // contains filtered or unexported fields }
State holds the current state of key/mouse events.
func (*State) AddController ¶
func (s *State) AddController(index int, v GameController) bool
AddController adds a new controller to the event state. This is typically called automatically by the render engine, e.g. on an SDL ControllerDeviceEvent.
func (*State) GetController ¶
func (s *State) GetController(index int) (GameController, bool)
GetController gets a registered controller by index.
func (*State) KeysDown ¶
KeysDown returns a list of all key names currently pressed down. Set shifted to True to return the key symbols correctly shifted (uppercase, or symbols on number keys, etc.)
func (*State) RemoveController ¶
RemoveController removes the available controller.
func (*State) ResetKeyDown ¶
func (s *State) ResetKeyDown()
ResetKeyDown clears all key-down states.
func (*State) SetKeyDown ¶
SetKeyDown sets that a named key is pressed down.