Updated raylib-cpp header files

This commit is contained in:
2025-09-08 22:06:21 -04:00
parent a0a658ca8a
commit fff611cc72
45 changed files with 2533 additions and 2382 deletions

View File

@@ -3,122 +3,104 @@
#include <string>
#include "./raylib.hpp"
#include "./raylib-cpp-utils.hpp"
#include "./raylib.hpp"
namespace raylib {
/**
* Input-related functions: gamepads
*/
class Gamepad {
public:
Gamepad(int gamepadNumber = 0) {
set(gamepadNumber);
}
public:
Gamepad(int gamepadNumber = 0) { set(gamepadNumber); }
int number;
GETTERSETTER(int, Number, number)
Gamepad& operator=(const Gamepad& gamepad) {
set(gamepad);
if (this != &gamepad) {
set(static_cast<int>(gamepad));
}
return *this;
}
Gamepad& operator=(int gamepadNumber) {
set(gamepadNumber);
if (this->number != gamepadNumber) {
set(gamepadNumber);
}
return *this;
}
operator int() const { return number; }
explicit operator int() const { return number; }
/**
* Detect if a gamepad is available
*/
inline bool IsAvailable() const {
return ::IsGamepadAvailable(number);
}
[[nodiscard]] bool IsAvailable() const { return ::IsGamepadAvailable(number); }
/**
* Detect if a gamepad is available
*/
static inline bool IsAvailable(int number) {
return ::IsGamepadAvailable(number);
}
static bool IsAvailable(int number) { return ::IsGamepadAvailable(number); }
/**
* Return gamepad internal name id
*/
std::string GetName() const {
return ::GetGamepadName(number);
}
[[nodiscard]] std::string GetName() const { return ::GetGamepadName(number); }
/**
* Return gamepad internal name id
*/
operator std::string() const {
return GetName();
}
explicit operator std::string() const { return GetName(); }
/**
* Detect if a gamepad button has been pressed once
*/
inline bool IsButtonPressed(int button) const {
return ::IsGamepadButtonPressed(number, button);
}
[[nodiscard]] bool IsButtonPressed(int button) const { return ::IsGamepadButtonPressed(number, button); }
/**
* Detect if a gamepad button is being pressed
*/
inline bool IsButtonDown(int button) const {
return ::IsGamepadButtonDown(number, button);
}
[[nodiscard]] bool IsButtonDown(int button) const { return ::IsGamepadButtonDown(number, button); }
/**
* Detect if a gamepad button has been released once
*/
inline bool IsButtonReleased(int button) const {
return ::IsGamepadButtonReleased(number, button);
}
[[nodiscard]] bool IsButtonReleased(int button) const { return ::IsGamepadButtonReleased(number, button); }
/**
* Detect if a gamepad button is NOT being pressed
*/
inline bool IsButtonUp(int button) const {
return ::IsGamepadButtonUp(number, button);
}
[[nodiscard]] bool IsButtonUp(int button) const { return ::IsGamepadButtonUp(number, button); }
/**
* Get the last gamepad button pressed
*/
inline int GetButtonPressed() const {
return ::GetGamepadButtonPressed();
}
static int GetButtonPressed() { return ::GetGamepadButtonPressed(); }
/**
* Return gamepad axis count for a gamepad
*/
inline int GetAxisCount() const {
return ::GetGamepadAxisCount(number);
}
[[nodiscard]] int GetAxisCount() const { return ::GetGamepadAxisCount(number); }
/**
* Return axis movement value for a gamepad axis
*/
inline float GetAxisMovement(int axis) const {
return ::GetGamepadAxisMovement(number, axis);
}
[[nodiscard]] float GetAxisMovement(int axis) const { return ::GetGamepadAxisMovement(number, axis); }
inline int SetMappings(const std::string& mappings) {
return SetGamepadMappings(mappings.c_str());
}
static int SetMappings(const std::string& mappings) { return SetGamepadMappings(mappings.c_str()); }
protected:
inline void set(int gamepadNumber) {
number = gamepadNumber;
/**
* Set gamepad vibration for both motors (duration in seconds)
*/
void SetVibration(float leftMotor, float rightMotor, float duration) const {
::SetGamepadVibration(number, leftMotor, rightMotor, duration);
}
protected:
void set(int gamepadNumber) { number = gamepadNumber; }
};
} // namespace raylib
} // namespace raylib
using RGamepad = raylib::Gamepad;
#endif // RAYLIB_CPP_INCLUDE_GAMEPAD_HPP_
#endif // RAYLIB_CPP_INCLUDE_GAMEPAD_HPP_