1#ifndef RAYLIB_CPP_INCLUDE_GAMEPAD_HPP_
2#define RAYLIB_CPP_INCLUDE_GAMEPAD_HPP_
7#include "./raylib-cpp-utils.hpp"
16 Gamepad(
int gamepadNumber = 0) : number(gamepadNumber) {};
19 GETTERSETTER(
int, Number, number)
22 if (
this != &gamepad) {
23 set(
static_cast<int>(gamepad));
28 Gamepad& operator=(
int gamepadNumber) {
29 if (this->number != gamepadNumber) {
35 explicit operator int()
const {
return number; }
40 [[nodiscard]]
bool IsAvailable()
const { return ::IsGamepadAvailable(number); }
45 static bool IsAvailable(
int number) { return ::IsGamepadAvailable(number); }
50 [[nodiscard]] std::string
GetName()
const { return ::GetGamepadName(number); }
55 explicit operator std::string()
const {
return GetName(); }
60 [[nodiscard]]
bool IsButtonPressed(
int button)
const { return ::IsGamepadButtonPressed(number, button); }
65 [[nodiscard]]
bool IsButtonDown(
int button)
const { return ::IsGamepadButtonDown(number, button); }
70 [[nodiscard]]
bool IsButtonReleased(
int button)
const { return ::IsGamepadButtonReleased(number, button); }
75 [[nodiscard]]
bool IsButtonUp(
int button)
const { return ::IsGamepadButtonUp(number, button); }
85 [[nodiscard]]
int GetAxisCount()
const { return ::GetGamepadAxisCount(number); }
90 [[nodiscard]]
float GetAxisMovement(
int axis)
const { return ::GetGamepadAxisMovement(number, axis); }
92 int SetMappings(
const std::string_view mappings) {
93 return SetGamepadMappings(mappings.data());
99 void SetVibration(
float leftMotor,
float rightMotor,
float duration)
const {
100 ::SetGamepadVibration(number, leftMotor, rightMotor, duration);
103 void set(
int gamepadNumber) { number = gamepadNumber; }
Input-related functions: gamepads.
bool IsButtonReleased(int button) const
Detect if a gamepad button has been released once.
int GetAxisCount() const
Return gamepad axis count for a gamepad.
void SetVibration(float leftMotor, float rightMotor, float duration) const
Set gamepad vibration for both motors (duration in seconds)
static bool IsAvailable(int number)
Detect if a gamepad is available.
static int GetButtonPressed()
Get the last gamepad button pressed.
bool IsAvailable() const
Detect if a gamepad is available.
bool IsButtonDown(int button) const
Detect if a gamepad button is being pressed.
std::string GetName() const
Return gamepad internal name id.
bool IsButtonUp(int button) const
Detect if a gamepad button is NOT being pressed.
bool IsButtonPressed(int button) const
Detect if a gamepad button has been pressed once.
float GetAxisMovement(int axis) const
Return axis movement value for a gamepad axis.
All raylib-cpp classes and functions appear in the raylib namespace.