GamepadButton

Namespace:

namespace Lenga\Engine\Enumerations;

Identifies a physical button on a gamepad controller. Use with Input::getButton() and Input::getButtonDown().

Values

Case Value Description
UNKNOWN 0 Unknown or unmapped button.
LEFT_FACE_UP 1 D-pad up / left face up (e.g. Y on Xbox, △ on PlayStation).
LEFT_FACE_RIGHT 2 D-pad right / left face right (e.g. B, ○).
LEFT_FACE_DOWN 3 D-pad down / left face down (e.g. A, ✕).
LEFT_FACE_LEFT 4 D-pad left / left face left (e.g. X, □).
RIGHT_FACE_UP 5 Right face up button.
RIGHT_FACE_RIGHT 6 Right face right button.
RIGHT_FACE_DOWN 7 Right face down button.
RIGHT_FACE_LEFT 8 Right face left button.
LEFT_TRIGGER_1 9 Left bumper (LB / L1).
LEFT_TRIGGER_2 10 Left trigger (LT / L2).
RIGHT_TRIGGER_1 11 Right bumper (RB / R1).
RIGHT_TRIGGER_2 12 Right trigger (RT / R2).
MIDDLE_LEFT 13 Select / Back / Share button.
MIDDLE 14 Guide / Home / PS button.
MIDDLE_RIGHT 15 Start / Options / Menu button.
LEFT_THUMB 16 Left analogue stick click (L3).
RIGHT_THUMB 17 Right analogue stick click (R3).

Example

use Lenga\Engine\Core\Behaviour;
use Lenga\Engine\Core\Input;
use Lenga\Engine\Enumerations\GamepadButton;

class GamepadController extends Behaviour
{
    public float $jumpForce = 8.0;

    public function update(): void
    {
        // Jump on the face-down button (A / ✕)
        if (Input::getButtonDown(GamepadButton::LEFT_FACE_DOWN->name)) {
            $this->jump();
        }
    }

    private function jump(): void { /* ... */ }
}