keymap

package
v0.0.0-...-b7bdad3 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2017 License: MIT Imports: 2 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action string

Action is a name/label for an action.

type AxisHandler

type AxisHandler func(val float64) (stopPropagation bool)

AxisHandler is a function that handles gamepad axis state. The function will directly be given the result of ebiten.GamepadAxis. It should return true if no later handlers should be called for the same axis.

type AxisHandlerMap

type AxisHandlerMap map[Action]AxisHandler

AxisHandlerMap maps axis Actions to their handlers.

type ButtonHandler

type ButtonHandler func(down bool) (stopPropagation bool)

ButtonHandler is a function that handles a button state. The parameter down is true if the button is pressed. It should return true if no later handlers should be called for the same button.

type ButtonHandlerMap

type ButtonHandlerMap map[Action]ButtonHandler

ButtonHandlerMap maps button Actions to their handlers.

type GamepadAxisMap

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

GamepadAxisMap is a bi-directional map connecting gamepad axes and actions.

func NewGamepadAxisMap

func NewGamepadAxisMap() *GamepadAxisMap

NewGamepadAxisMap returns a new, initialized GamepadAxisMap.

func (*GamepadAxisMap) Actions

func (gm *GamepadAxisMap) Actions() []Action

Actions returns a slice containing all actions currently in the map.

func (*GamepadAxisMap) Axes

func (gm *GamepadAxisMap) Axes() []int

Axes returns a slice containing all axes currently in the map.

func (*GamepadAxisMap) DelAction

func (gm *GamepadAxisMap) DelAction(a Action)

DelAction removes the action and its associated axis.

func (*GamepadAxisMap) DelAxis

func (gm *GamepadAxisMap) DelAxis(ax int)

DelAxis removes the axis and its associated action.

func (*GamepadAxisMap) GetAction

func (gm *GamepadAxisMap) GetAction(b int) (a Action, ok bool)

GetAction returns the action associated with the button.

func (*GamepadAxisMap) GetAxis

func (gm *GamepadAxisMap) GetAxis(a Action) (ax int, ok bool)

GetAxis returns the axis associated with the action.

func (*GamepadAxisMap) Set

func (gm *GamepadAxisMap) Set(ax int, a Action)

Set associates the given axis and action with each other.

type GamepadBtnMap

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

GamepadBtnMap is a bi-directional map connecting gamepad buttons and actions.

func NewGamepadBtnMap

func NewGamepadBtnMap() *GamepadBtnMap

NewGamepadBtnMap returns a new, initialized GamepadBtnMap.

func (*GamepadBtnMap) Actions

func (gm *GamepadBtnMap) Actions() []Action

Actions returns a slice containing all actions currently in the map.

func (*GamepadBtnMap) Buttons

func (gm *GamepadBtnMap) Buttons() []ebiten.GamepadButton

Buttons returns a slice containing all buttons currently in the map.

func (*GamepadBtnMap) DelAction

func (gm *GamepadBtnMap) DelAction(a Action)

DelAction removes the action and its associated button.

func (*GamepadBtnMap) DelButton

func (gm *GamepadBtnMap) DelButton(b ebiten.GamepadButton)

DelButton removes the button and its associated action.

func (*GamepadBtnMap) GetAction

func (gm *GamepadBtnMap) GetAction(b ebiten.GamepadButton) (a Action, ok bool)

GetAction returns the action associated with the button.

func (*GamepadBtnMap) GetButton

func (gm *GamepadBtnMap) GetButton(a Action) (b ebiten.GamepadButton, ok bool)

GetButton returns the button associated with the action.

func (*GamepadBtnMap) Set

func (gm *GamepadBtnMap) Set(b ebiten.GamepadButton, a Action)

Set associates the given button and action with each other.

type KeyMap

type KeyMap struct {
	KeyMouse    *KeyMouseMap
	GamepadBtn  *GamepadBtnMap
	GamepadAxis *GamepadAxisMap
	// contains filtered or unexported fields
}

KeyMap groups all map types.

func New

func New(btnHandlers ButtonHandlerMap, gamepadAxisHandlers AxisHandlerMap) *KeyMap

New creates and returns a new, empty KeyMap. The btnHandlers map shared between keyboard/mouse and gamepad buttons. This means that if an action handler for a keyboard/mouse buttton stops propagation then a gamepad button that maps to the same action in a later layer will not be handled.

type KeyMouseMap

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

KeyMouseMap is a bi-directional map connecting keyboard/mouse buttons and actions.

func NewKeyMouseMap

func NewKeyMouseMap() *KeyMouseMap

NewKeyMouseMap returns a new, initialized KeyMouseMap.

func (*KeyMouseMap) Actions

func (km *KeyMouseMap) Actions() []Action

Actions returns a slice containing all actions currently in the map.

func (*KeyMouseMap) Buttons

func (km *KeyMouseMap) Buttons() []button.KeyMouse

Buttons returns a slice containing all buttons currently in the map.

func (*KeyMouseMap) DelAction

func (km *KeyMouseMap) DelAction(a Action)

DelAction removes the action and its associated button.

func (*KeyMouseMap) DelButton

func (km *KeyMouseMap) DelButton(b button.KeyMouse)

DelButton removes the button and its associated action.

func (*KeyMouseMap) GetAction

func (km *KeyMouseMap) GetAction(b button.KeyMouse) (a Action, ok bool)

GetAction returns the action associated with the button.

func (*KeyMouseMap) GetButton

func (km *KeyMouseMap) GetButton(a Action) (b button.KeyMouse, ok bool)

GetButton returns the button associated with the action.

func (*KeyMouseMap) Set

func (km *KeyMouseMap) Set(b button.KeyMouse, a Action)

Set associates the given button and action with each other.

type Layers

type Layers []*KeyMap

Layers is a slice of KeyMaps. It enables buttons to be overloaded with multiple actions with the option of skipping later handlers for buttons handled at earlier layers.

func (Layers) Update

func (l Layers) Update()

Update checks input state and calls handlers for any actions triggered. It handles each layer in order. If the handler for a button stops propagation then later following layers will not handle any actions the same button triggers.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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