* Input-related functions: gamepads */
| 11 | * Input-related functions: gamepads |
| 12 | */ |
| 13 | class Gamepad { |
| 14 | public: |
| 15 | Gamepad(int gamepadNumber = 0) : number(gamepadNumber) {}; |
| 16 | int number; |
| 17 | |
| 18 | GETTERSETTER(int, Number, number) |
| 19 | |
| 20 | Gamepad& operator=(const Gamepad& gamepad) { |
| 21 | if (this != &gamepad) { |
| 22 | set(static_cast<int>(gamepad)); |
| 23 | } |
| 24 | return *this; |
| 25 | } |
| 26 | |
| 27 | Gamepad& operator=(int gamepadNumber) { |
| 28 | if (this->number != gamepadNumber) { |
| 29 | set(gamepadNumber); |
| 30 | } |
| 31 | return *this; |
| 32 | } |
| 33 | |
| 34 | explicit operator int() const { return number; } |
| 35 | |
| 36 | /** |
| 37 | * Detect if a gamepad is available |
| 38 | */ |
| 39 | RLCPP_NODISCARD bool IsAvailable() const { return ::IsGamepadAvailable(number); } |
| 40 | |
| 41 | /** |
| 42 | * Detect if a gamepad is available |
| 43 | */ |
| 44 | static bool IsAvailable(int number) { return ::IsGamepadAvailable(number); } |
| 45 | |
| 46 | /** |
| 47 | * Return gamepad internal name id |
| 48 | */ |
| 49 | RLCPP_NODISCARD std::string GetName() const { return ::GetGamepadName(number); } |
| 50 | |
| 51 | /** |
| 52 | * Return gamepad internal name id |
| 53 | */ |
| 54 | explicit operator std::string() const { return GetName(); } |
| 55 | |
| 56 | /** |
| 57 | * Detect if a gamepad button has been pressed once |
nothing calls this directly
no outgoing calls
no test coverage detected