Documentation
¶
Index ¶
- Constants
- func ParseGamepadLayout(data []byte) (GamepadGUID, GamepadLayout, error)
- type ButtonInput
- type Direction
- type Gamepad
- func (self *Gamepad) Config() *GamepadConfig
- func (self *Gamepad) Dir() Direction
- func (self *Gamepad) Dir8() Direction
- func (self *Gamepad) HorzDir() Direction
- func (self *Gamepad) IsIdle() bool
- func (self *Gamepad) Pressed(action TriggerAction) bool
- func (self *Gamepad) PressedTicks(action TriggerAction) int32
- func (self *Gamepad) Repeat(action TriggerAction) bool
- func (self *Gamepad) RepeatAs(action TriggerAction, repeatFirst, repeatNext int32) bool
- func (self *Gamepad) RepeatDir() Direction
- func (self *Gamepad) RepeatDirAs(repeatFirst, repeatNext int32) Direction
- func (self *Gamepad) Status() GamepadStatus
- func (self *Gamepad) Trigger(action TriggerAction) bool
- func (self *Gamepad) TriggerDir() Direction
- func (self *Gamepad) TriggerDir8() Direction
- func (self *Gamepad) Unwind()
- func (self *Gamepad) Update() error
- func (self *Gamepad) Zero()
- type GamepadConfig
- func (self *GamepadConfig) DeleteAllTriggerActions()
- func (self *GamepadConfig) DeleteTriggerAction(action TriggerAction)
- func (self *GamepadConfig) GetMapping(action TriggerAction) GamepadTrigger
- func (self *GamepadConfig) MapTriggerAction(action TriggerAction, trigger GamepadTrigger)
- func (self *GamepadConfig) MapTriggerActionToButton(action TriggerAction, button GamepadStandardInput)
- func (self *GamepadConfig) MapTriggerActionToButtons(action TriggerAction, buttons ...GamepadStandardInput)
- func (self *GamepadConfig) SetDirButtons(dirButtons GamepadDirButtons)
- func (self *GamepadConfig) SetLayouts(knownLayouts map[GamepadGUID]GamepadLayout)
- func (self *GamepadConfig) SetRepeatRate(repeatFirst int32, repeatNext int32)
- type GamepadDirButtons
- type GamepadGUID
- type GamepadLayout
- type GamepadLayoutInput
- func (self GamepadLayoutInput) Index() int
- func (self GamepadLayoutInput) IsAnalog() bool
- func (self GamepadLayoutInput) IsBinary() bool
- func (self GamepadLayoutInput) IsButton() bool
- func (self GamepadLayoutInput) Pressed(id ebiten.GamepadID) bool
- func (self GamepadLayoutInput) String() string
- func (self GamepadLayoutInput) Value(id ebiten.GamepadID) float64
- type GamepadStandardInput
- type GamepadStatus
- type GamepadTrigger
- type InputMode
- type KBGP
- func (self *KBGP) Dir() Direction
- func (self *KBGP) Dir8() Direction
- func (self *KBGP) Gamepad() *Gamepad
- func (self *KBGP) HorzDir() Direction
- func (self *KBGP) Keyboard() *Keyboard
- func (self *KBGP) Pressed(action TriggerAction) bool
- func (self *KBGP) PressedTicks(action TriggerAction) int32
- func (self *KBGP) Repeat(action TriggerAction) bool
- func (self *KBGP) RepeatAs(action TriggerAction, repeatFirst, repeatNext int32) bool
- func (self *KBGP) RepeatDir() Direction
- func (self *KBGP) RepeatDirAs(repeatFirst, repeatNext int32) Direction
- func (self *KBGP) SetRepeatRate(repeatFirst int32, repeatNext int32)
- func (self *KBGP) Trigger(action TriggerAction) bool
- func (self *KBGP) TriggerDir() Direction
- func (self *KBGP) TriggerDir8() Direction
- func (self *KBGP) Unwind()
- func (self *KBGP) Update() error
- func (self *KBGP) UsedGamepadMoreRecentlyThanKeyboard() bool
- func (self *KBGP) UsedKeyboardMoreRecentlyThanGamepad() bool
- func (self *KBGP) Zero()
- type KBGPLike
- type KeyInput
- type KeyList
- type Keyboard
- func (self *Keyboard) Config() *KeyboardConfig
- func (self *Keyboard) Dir() Direction
- func (self *Keyboard) Dir8() Direction
- func (self *Keyboard) HorzDir() Direction
- func (self *Keyboard) IsIdle() bool
- func (self *Keyboard) Pressed(action TriggerAction) bool
- func (self *Keyboard) PressedTicks(action TriggerAction) int32
- func (self *Keyboard) Repeat(action TriggerAction) bool
- func (self *Keyboard) RepeatAs(action TriggerAction, repeatFirst, repeatNext int32) bool
- func (self *Keyboard) RepeatDir() Direction
- func (self *Keyboard) RepeatDirAs(repeatFirst, repeatNext int32) Direction
- func (self *Keyboard) Trigger(action TriggerAction) bool
- func (self *Keyboard) TriggerDir() Direction
- func (self *Keyboard) TriggerDir8() Direction
- func (self *Keyboard) Unwind()
- func (self *Keyboard) Update() error
- func (self *Keyboard) Zero()
- type KeyboardConfig
- func (self *KeyboardConfig) DeleteAllTriggerActions()
- func (self *KeyboardConfig) DeleteTriggerAction(action TriggerAction)
- func (self *KeyboardConfig) GetMapping(action TriggerAction) KeyboardTrigger
- func (self *KeyboardConfig) MapTriggerAction(action TriggerAction, trigger KeyboardTrigger)
- func (self *KeyboardConfig) MapTriggerActionToKey(action TriggerAction, key ebiten.Key)
- func (self *KeyboardConfig) MapTriggerActionToKeys(action TriggerAction, keys []ebiten.Key)
- func (self *KeyboardConfig) SetDirTriggers(dirTriggers KeyboardDirTriggers)
- func (self *KeyboardConfig) SetRepeatRate(repeatFirst int32, repeatNext int32)
- type KeyboardDirTriggers
- type KeyboardTrigger
- type MultiButton
- type MultiKey
- type RepeatDetectorKBGP
- type SingleButton
- type SingleKey
- type TriggerAction
- type UnassignedButton
- type UnassignedKey
Constants ¶
const GamepadLayoutDatSize = layoutDatLen
const GamepadNumStandardInputs = int(gamepadNumStandardInputs)
Variables ¶
This section is empty.
Functions ¶
func ParseGamepadLayout ¶
func ParseGamepadLayout(data []byte) (GamepadGUID, GamepadLayout, error)
Types ¶
type ButtonInput ¶
type ButtonInput struct { Button GamepadStandardInput Mode InputMode }
type Gamepad ¶
type Gamepad struct {
// contains filtered or unexported fields
}
func NewGamepad ¶
func NewGamepad() *Gamepad
func (*Gamepad) Config ¶
func (self *Gamepad) Config() *GamepadConfig
func (*Gamepad) Pressed ¶
func (self *Gamepad) Pressed(action TriggerAction) bool
func (*Gamepad) PressedTicks ¶
func (self *Gamepad) PressedTicks(action TriggerAction) int32
func (*Gamepad) Repeat ¶
func (self *Gamepad) Repeat(action TriggerAction) bool
func (*Gamepad) RepeatAs ¶
func (self *Gamepad) RepeatAs(action TriggerAction, repeatFirst, repeatNext int32) bool
func (*Gamepad) RepeatDirAs ¶
func (*Gamepad) Status ¶
func (self *Gamepad) Status() GamepadStatus
func (*Gamepad) Trigger ¶
func (self *Gamepad) Trigger(action TriggerAction) bool
func (*Gamepad) TriggerDir ¶
func (*Gamepad) TriggerDir8 ¶
type GamepadConfig ¶
type GamepadConfig Gamepad
The GamepadConfig allows the user to modify the mappings, triggers, repeat rates and direction buttons for a Gamepad. This object can be obtained through the Gamepad.Config() method.
func (*GamepadConfig) DeleteAllTriggerActions ¶
func (self *GamepadConfig) DeleteAllTriggerActions()
func (*GamepadConfig) DeleteTriggerAction ¶
func (self *GamepadConfig) DeleteTriggerAction(action TriggerAction)
Equivalent to *GamepadConfig.MapTriggerAction(action, nil).
func (*GamepadConfig) GetMapping ¶
func (self *GamepadConfig) GetMapping(action TriggerAction) GamepadTrigger
Returns nil if not mapped.
func (*GamepadConfig) MapTriggerAction ¶
func (self *GamepadConfig) MapTriggerAction(action TriggerAction, trigger GamepadTrigger)
Sets a trigger.
func (*GamepadConfig) MapTriggerActionToButton ¶
func (self *GamepadConfig) MapTriggerActionToButton(action TriggerAction, button GamepadStandardInput)
func (*GamepadConfig) MapTriggerActionToButtons ¶
func (self *GamepadConfig) MapTriggerActionToButtons(action TriggerAction, buttons ...GamepadStandardInput)
func (*GamepadConfig) SetDirButtons ¶
func (self *GamepadConfig) SetDirButtons(dirButtons GamepadDirButtons)
func (*GamepadConfig) SetLayouts ¶
func (self *GamepadConfig) SetLayouts(knownLayouts map[GamepadGUID]GamepadLayout)
func (*GamepadConfig) SetRepeatRate ¶
func (self *GamepadConfig) SetRepeatRate(repeatFirst int32, repeatNext int32)
type GamepadDirButtons ¶
type GamepadDirButtons struct { Up GamepadStandardInput Down GamepadStandardInput Right GamepadStandardInput Left GamepadStandardInput }
Struct for use with *GamepadConfig.SetDirButtons()
func DirButtonsDPad ¶
func DirButtonsDPad() GamepadDirButtons
type GamepadGUID ¶
type GamepadGUID struct {
// contains filtered or unexported fields
}
func BytesToGamepadGUID ¶
func BytesToGamepadGUID(buffer []byte) (GamepadGUID, error)
func StringToGamepadGUID ¶
func StringToGamepadGUID(guidStr string) (GamepadGUID, error)
func (GamepadGUID) Equal ¶
func (self GamepadGUID) Equal(other GamepadGUID) bool
func (GamepadGUID) ToBytes ¶
func (self GamepadGUID) ToBytes() []byte
func (GamepadGUID) ToString ¶
func (self GamepadGUID) ToString() string
Uses lowercase for hex values. For uppercase, see ToStringUpper().
func (GamepadGUID) ToStringUpper ¶
func (self GamepadGUID) ToStringUpper() string
func (GamepadGUID) ToZeroName ¶
func (self GamepadGUID) ToZeroName() string
Shorter encoding, uses 0-9, a-z, and then A-Z for compressing sequences of zeroes.
func (GamepadGUID) WriteToBuffer ¶
func (self GamepadGUID) WriteToBuffer(buffer []byte)
type GamepadLayout ¶
type GamepadLayout [GamepadNumStandardInputs]GamepadLayoutInput
func StandardGamepadLayout ¶
func StandardGamepadLayout() GamepadLayout
func (*GamepadLayout) AxisCorrespondence ¶
func (self *GamepadLayout) AxisCorrespondence(index int) (GamepadStandardInput, bool)
Slow.
func (*GamepadLayout) ButtonCorrespondence ¶
func (self *GamepadLayout) ButtonCorrespondence(index int) (GamepadStandardInput, bool)
Slow.
func (*GamepadLayout) Export ¶
func (self *GamepadLayout) Export(writer io.Writer, guid GamepadGUID) error
TODO: could consider adding the gamepad model / type too, but general xbox-like
seems fine, or it could be detected from the layout defined and undefined inputs.
func (*GamepadLayout) Reset ¶
func (self *GamepadLayout) Reset()
type GamepadLayoutInput ¶
type GamepadLayoutInput uint8
func NewGamepadAnalogButtonLayoutInput ¶
func NewGamepadAnalogButtonLayoutInput(index int) GamepadLayoutInput
func NewGamepadAxisLayoutInput ¶
func NewGamepadAxisLayoutInput(index int) GamepadLayoutInput
func NewGamepadBinaryButtonLayoutInput ¶
func NewGamepadBinaryButtonLayoutInput(index int) GamepadLayoutInput
func (GamepadLayoutInput) Index ¶
func (self GamepadLayoutInput) Index() int
The index will be -1 if undefined.
func (GamepadLayoutInput) IsAnalog ¶
func (self GamepadLayoutInput) IsAnalog() bool
func (GamepadLayoutInput) IsBinary ¶
func (self GamepadLayoutInput) IsBinary() bool
func (GamepadLayoutInput) IsButton ¶
func (self GamepadLayoutInput) IsButton() bool
func (GamepadLayoutInput) Pressed ¶
func (self GamepadLayoutInput) Pressed(id ebiten.GamepadID) bool
func (GamepadLayoutInput) String ¶
func (self GamepadLayoutInput) String() string
func (GamepadLayoutInput) Value ¶
func (self GamepadLayoutInput) Value(id ebiten.GamepadID) float64
type GamepadStandardInput ¶
type GamepadStandardInput uint8
const ( GamepadUp GamepadStandardInput = iota GamepadRight GamepadLeft GamepadDown GamepadButtonTop GamepadButtonRight GamepadButtonLeft GamepadButtonBottom GamepadShoulderLeft GamepadShoulderRight GamepadTriggerLeft GamepadTriggerRight GamepadLeftStickButton GamepadRightStickButton GamepadLeftStickHorzAxis GamepadLeftStickVertAxis GamepadRightStickHorzAxis GamepadRightStickVertAxis // TODO: maybe use GamepadFuncRight or OptLeft? weird though. it's also "options" on dualshock4 // also missing dualShock4 touchpad button. could determine by num buttons. // also main stick vs secondary stick instead of left and right? GamepadStart GamepadSelect GamepadMeta )
func (GamepadStandardInput) IsAxis ¶
func (self GamepadStandardInput) IsAxis() bool
func (GamepadStandardInput) StdEquivalent ¶
func (self GamepadStandardInput) StdEquivalent() ebiten.StandardGamepadButton
func (GamepadStandardInput) StdEquivalentPressed ¶
func (self GamepadStandardInput) StdEquivalentPressed(id ebiten.GamepadID) bool
func (GamepadStandardInput) String ¶
func (self GamepadStandardInput) String() string
type GamepadStatus ¶
type GamepadStatus uint8
func (GamepadStatus) IsConfigured ¶
func (self GamepadStatus) IsConfigured() bool
func (GamepadStatus) IsConnected ¶
func (self GamepadStatus) IsConnected() bool
func (GamepadStatus) IsDisconnected ¶
func (self GamepadStatus) IsDisconnected() bool
func (GamepadStatus) IsJustConnected ¶
func (self GamepadStatus) IsJustConnected() bool
func (GamepadStatus) IsJustDisconnected ¶
func (self GamepadStatus) IsJustDisconnected() bool
type GamepadTrigger ¶
type GamepadTrigger interface { Pressed(id ebiten.GamepadID, layout *GamepadLayout) bool Inputs() []ButtonInput String() string }
type KBGP ¶
type KBGP struct {
// contains filtered or unexported fields
}
func (*KBGP) Pressed ¶
func (self *KBGP) Pressed(action TriggerAction) bool
func (*KBGP) PressedTicks ¶
func (self *KBGP) PressedTicks(action TriggerAction) int32
func (*KBGP) Repeat ¶
func (self *KBGP) Repeat(action TriggerAction) bool
func (*KBGP) RepeatAs ¶
func (self *KBGP) RepeatAs(action TriggerAction, repeatFirst, repeatNext int32) bool
See also repeat detector.
func (*KBGP) RepeatDirAs ¶
See also repeat detector.
func (*KBGP) SetRepeatRate ¶
func (*KBGP) Trigger ¶
func (self *KBGP) Trigger(action TriggerAction) bool
func (*KBGP) TriggerDir ¶
func (*KBGP) TriggerDir8 ¶
func (*KBGP) Unwind ¶
func (self *KBGP) Unwind()
All inputs are blocked (won't be triggered) until a subsequent update determines that actions are not pressed anymore. This is very helpful for scene transitions or context switches where you don't want previous state to affect the new context.
func (*KBGP) UsedGamepadMoreRecentlyThanKeyboard ¶
func (*KBGP) UsedKeyboardMoreRecentlyThanGamepad ¶
type KBGPLike ¶
type KBGPLike interface { Update() error Zero() Unwind() Pressed(TriggerAction) bool Trigger(TriggerAction) bool Repeat(TriggerAction) bool RepeatAs(TriggerAction, int32, int32) bool PressedTicks(TriggerAction) int32 Dir() Direction TriggerDir() Direction Dir8() Direction TriggerDir8() Direction RepeatDir() Direction RepeatDirAs(int32, int32) Direction }
A common interface implemented by Gamepad, Keyboard and KBGP.
type KeyList ¶
type KeyList []ebiten.Key
func NewKeyList ¶
func NewKeyList(keys ...ebiten.Key) KeyList
Accepts *any* of the given keys as a trigger.
type Keyboard ¶
type Keyboard struct {
// contains filtered or unexported fields
}
func NewKeyboard ¶
func NewKeyboard() *Keyboard
func (*Keyboard) Config ¶
func (self *Keyboard) Config() *KeyboardConfig
func (*Keyboard) Pressed ¶
func (self *Keyboard) Pressed(action TriggerAction) bool
func (*Keyboard) PressedTicks ¶
func (self *Keyboard) PressedTicks(action TriggerAction) int32
func (*Keyboard) Repeat ¶
func (self *Keyboard) Repeat(action TriggerAction) bool
func (*Keyboard) RepeatAs ¶
func (self *Keyboard) RepeatAs(action TriggerAction, repeatFirst, repeatNext int32) bool
func (*Keyboard) RepeatDirAs ¶
func (*Keyboard) Trigger ¶
func (self *Keyboard) Trigger(action TriggerAction) bool
func (*Keyboard) TriggerDir ¶
func (*Keyboard) TriggerDir8 ¶
func (*Keyboard) Unwind ¶
func (self *Keyboard) Unwind()
All inputs are blocked (won't be triggered) until a subsequent update determines that actions are not pressed anymore. This is very helpful for scene transitions or context switches where you don't want previous state to affect the new context.
type KeyboardConfig ¶
type KeyboardConfig Keyboard
func (*KeyboardConfig) DeleteAllTriggerActions ¶
func (self *KeyboardConfig) DeleteAllTriggerActions()
func (*KeyboardConfig) DeleteTriggerAction ¶
func (self *KeyboardConfig) DeleteTriggerAction(action TriggerAction)
Equivalent to *KeyboardConfig.MapTriggerAction(action, nil).
func (*KeyboardConfig) GetMapping ¶
func (self *KeyboardConfig) GetMapping(action TriggerAction) KeyboardTrigger
Returns nil if not mapped.
func (*KeyboardConfig) MapTriggerAction ¶
func (self *KeyboardConfig) MapTriggerAction(action TriggerAction, trigger KeyboardTrigger)
Sets a trigger.
func (*KeyboardConfig) MapTriggerActionToKey ¶
func (self *KeyboardConfig) MapTriggerActionToKey(action TriggerAction, key ebiten.Key)
func (*KeyboardConfig) MapTriggerActionToKeys ¶
func (self *KeyboardConfig) MapTriggerActionToKeys(action TriggerAction, keys []ebiten.Key)
func (*KeyboardConfig) SetDirTriggers ¶
func (self *KeyboardConfig) SetDirTriggers(dirTriggers KeyboardDirTriggers)
func (*KeyboardConfig) SetRepeatRate ¶
func (self *KeyboardConfig) SetRepeatRate(repeatFirst int32, repeatNext int32)
type KeyboardDirTriggers ¶
type KeyboardDirTriggers struct { Up KeyboardTrigger Down KeyboardTrigger Right KeyboardTrigger Left KeyboardTrigger }
Struct for use with *KeyboardConfig.SetDirTriggers()
func DirKeysArrows ¶
func DirKeysArrows() KeyboardDirTriggers
Get an instance of KeyboardDirTriggers corresponding to directional arrows.
func DirKeysArrowsAndWASD ¶
func DirKeysArrowsAndWASD() KeyboardDirTriggers
Get an instance of KeyboardDirTriggers corresponding to both WASD and directional arrows.
func DirKeysWASD ¶
func DirKeysWASD() KeyboardDirTriggers
Get an instance of KeyboardDirTriggers corresponding to WASD.
type KeyboardTrigger ¶
type MultiButton ¶
type MultiButton struct {
ButtonInputs []ButtonInput
}
func NewMultiButton ¶
func NewMultiButton(buttons ...GamepadStandardInput) MultiButton
func (*MultiButton) Add ¶
func (self *MultiButton) Add(button GamepadStandardInput)
func (*MultiButton) AddBreaker ¶
func (self *MultiButton) AddBreaker(button GamepadStandardInput)
func (MultiButton) Inputs ¶
func (self MultiButton) Inputs() []ButtonInput
func (MultiButton) Pressed ¶
func (self MultiButton) Pressed(id ebiten.GamepadID, layout *GamepadLayout) bool
func (MultiButton) String ¶
func (self MultiButton) String() string
type MultiKey ¶
type MultiKey struct {
KeyInputs []KeyInput
}
func NewMultiKey ¶
func NewMultiKey(keys ...ebiten.Key) MultiKey
func (*MultiKey) AddBreakerKey ¶
func (self *MultiKey) AddBreakerKey(key ebiten.Key)
func (*MultiKey) AddNormalKey ¶
func (self *MultiKey) AddNormalKey(key ebiten.Key)
type RepeatDetectorKBGP ¶
NOTE: I don't think generics are relevant for this right now.
func (RepeatDetectorKBGP) Repeat ¶
func (self RepeatDetectorKBGP) Repeat(input *KBGP, action TriggerAction) bool
func (RepeatDetectorKBGP) RepeatDir ¶
func (self RepeatDetectorKBGP) RepeatDir(input *KBGP) Direction
type SingleButton ¶
type SingleButton GamepadStandardInput
func (SingleButton) Inputs ¶
func (self SingleButton) Inputs() []ButtonInput
func (SingleButton) Pressed ¶
func (self SingleButton) Pressed(id ebiten.GamepadID, layout *GamepadLayout) bool
func (SingleButton) String ¶
func (self SingleButton) String() string
type TriggerAction ¶
type TriggerAction uint16
type UnassignedButton ¶
type UnassignedButton struct{}
func (UnassignedButton) Inputs ¶
func (self UnassignedButton) Inputs() []ButtonInput
func (UnassignedButton) Pressed ¶
func (self UnassignedButton) Pressed(id ebiten.GamepadID, layout *GamepadLayout) bool
func (UnassignedButton) String ¶
func (self UnassignedButton) String() string
type UnassignedKey ¶
type UnassignedKey struct{}
func (UnassignedKey) Inputs ¶
func (self UnassignedKey) Inputs() []KeyInput
func (UnassignedKey) Pressed ¶
func (self UnassignedKey) Pressed() bool
func (UnassignedKey) String ¶
func (self UnassignedKey) String() string