diff --git a/examples/blocks/blocks/gamepad.go b/examples/blocks/blocks/gamepad.go index 43f0a3917..a5214742e 100644 --- a/examples/blocks/blocks/gamepad.go +++ b/examples/blocks/blocks/gamepad.go @@ -124,6 +124,8 @@ func (c *gamepadConfig) Scan(gamepadID int, b virtualGamepadButton) bool { return false } +// IsButtonPressed returns a boolean value indicating whether +// the given virtual button b is pressed. func (c *gamepadConfig) IsButtonPressed(b virtualGamepadButton) bool { c.initializeIfNeeded() @@ -131,6 +133,7 @@ func (c *gamepadConfig) IsButtonPressed(b virtualGamepadButton) bool { if ok { return ebiten.IsGamepadButtonPressed(0, bb) } + a, ok := c.axes[b] if ok { v := ebiten.GamepadAxis(0, a.id) @@ -143,7 +146,7 @@ func (c *gamepadConfig) IsButtonPressed(b virtualGamepadButton) bool { return false } -// Name returns the button's name. +// Name returns the pysical button's name for the given virtual button. func (c *gamepadConfig) ButtonName(b virtualGamepadButton) string { c.initializeIfNeeded() diff --git a/examples/blocks/blocks/input.go b/examples/blocks/blocks/input.go index 3e3cd24e0..6e487df49 100644 --- a/examples/blocks/blocks/input.go +++ b/examples/blocks/blocks/input.go @@ -20,6 +20,7 @@ import ( "github.com/hajimehoshi/ebiten" ) +// Input manages the input state including gamepads and keyboards. type Input struct { keyStates map[ebiten.Key]int anyGamepadButtonPressed bool @@ -27,6 +28,7 @@ type Input struct { gamepadConfig gamepadConfig } +// StateForKey returns time length indicating how long the key is pressed. func (i *Input) StateForKey(key ebiten.Key) int { if i.keyStates == nil { return 0 @@ -34,6 +36,8 @@ func (i *Input) StateForKey(key ebiten.Key) int { return i.keyStates[key] } +// IsAnyGamepadButtonPressed returns a boolean value indicating +// whether any gamepad button is pressed. func (i *Input) IsAnyGamepadButtonPressed() bool { return i.anyGamepadButtonPressed }