This commit is contained in:
arthur.jamet
2021-05-19 09:08:12 +02:00
parent 6a539a7bd9
commit a924ed32df
4 changed files with 47 additions and 7 deletions
+1 -5
View File
@@ -11,7 +11,7 @@
#include <raylib.h> #include <raylib.h>
#include <vector> #include <vector>
namespace RAY { namespace RAY::Controller {
//! @brief Entity representing a gamepad controller //! @brief Entity representing a gamepad controller
class GamePad { class GamePad {
@@ -53,10 +53,6 @@ namespace RAY {
//! @brief Sets gamepad's id //! @brief Sets gamepad's id
void setID(int id); void setID(int id);
//! @brief Fetch currently pressed buttons
//! @return Returns a vector containing keycode of currently pressed buttons
std::vector<GamePad::Button> getPressedButtons(void);
private: private:
//! @brief The id of the controller, used to fetch buttons' states //! @brief The id of the controller, used to fetch buttons' states
+1 -1
View File
@@ -12,7 +12,7 @@
#include <raylib.h> #include <raylib.h>
#include <vector> #include <vector>
namespace RAY { namespace RAY::Controller {
class Keyboard { class Keyboard {
public: public:
typedef ::KeyboardKey Key; typedef ::KeyboardKey Key;
+1 -1
View File
@@ -12,7 +12,7 @@
#include <raylib.h> #include <raylib.h>
#include <vector> #include <vector>
namespace RAY { namespace RAY::Controller {
class Mouse { class Mouse {
public: public:
typedef ::MouseButton Button; typedef ::MouseButton Button;
+44
View File
@@ -0,0 +1,44 @@
/*
** EPITECH PROJECT, 2021
** Bomberman
** File description:
** Gamepad
*/
#include "Controllers/Gamepad.hpp"
RAY::Controller::GamePad::GamePad(int id):
_id(id)
{
}
bool RAY::Controller::GamePad::isPressed(RAY::Controller::GamePad::Button button)
{
return IsGamepadButtonPressed(this->_id, button);
}
bool RAY::Controller::GamePad::isDown(RAY::Controller::GamePad::Button button)
{
return IsGamepadButtonDown(this->_id, button);
}
bool RAY::Controller::GamePad::isReleased(RAY::Controller::GamePad::Button button)
{
return IsGamepadButtonReleased(this->_id, button);
}
bool RAY::Controller::GamePad::isUp(RAY::Controller::GamePad::Button button)
{
return IsGamepadButtonUp(this->_id, button);
}
bool RAY::Controller::GamePad::isAvailable(RAY::Controller::GamePad::Button button)
{
return IsGamepadAvailable(this->_id);
}
void RAY::Controller::GamePad::setID(int id)
{
this->_id = id;
}