examples/blocks/blocks/gamepad.go
func (c *gamepadConfig) IsButtonPressed(b virtualGamepadButton) bool {
	if !c.gamepadIDInitialized {
		panic("not reached")
	}

	c.initializeIfNeeded()

	bb, ok := c.buttons[b]
	if ok {
		return ebiten.IsGamepadButtonPressed(c.gamepadID, bb)
	}

	a, ok := c.axes[b]
	if ok {
		v := ebiten.GamepadAxis(c.gamepadID, a.id)
		if a.positive {
			return axisThreshold <= v && v <= 1.0
		} else {
			return -1.0 <= v && v <= -axisThreshold
		}
	}
	return false
}
func (c *gamepadConfig) IsButtonPressed(b virtualGamepadButton) bool {
	if !c.gamepadIDInitialized {
		panic("not reached")
	}

	c.initializeIfNeeded()

	bb, ok := c.buttons[b]
	if ok {
		return ebiten.IsGamepadButtonPressed(c.gamepadID, bb)
	}

	a, ok := c.axes[b]
	if ok {
		v := ebiten.GamepadAxis(c.gamepadID, a.id)
		if a.positive {
			return axisThreshold <= v && v <= 1.0
		} else {
			return -1.0 <= v && v <= -axisThreshold
		}
	}
	return false
}
func ( c * gamepadConfig ) IsButtonPressed ( b virtualGamepadButton ) bool { if ! c . gamepadIDInitialized { panic ( " " ) } c . initializeIfNeeded ( ) bb , ok := c . buttons [ b ] if ok { return ebiten . IsGamepadButtonPressed ( c . gamepadID , bb ) } a , ok := c . axes [ b ] if ok { v := ebiten . GamepadAxis ( c . gamepadID , a . id ) if a . positive { return axisThreshold <= v && v <= 1.0 } else { return - 1.0 <= v && v <= - axisThreshold } } return false }
// IsButtonPressed returns a boolean value indicating whether
// the given virtual button b is pressed.
IsButtonPressed returns a boolean value indicating whether the given virtual button b is pressed .