Skip to content

File Controller.hpp

File List > Engine > include > Inputs > Controller.hpp

Go to the documentation of this file

/*
** EPITECH PROJECT, 2026
** G-ING-500-BAR-5-1-rtype-1
** File description:
** Controller.hpp
*/
#ifndef G_ING_500_BAR_5_1_RTYPE_1_CONTROLLER_HPP
#define G_ING_500_BAR_5_1_RTYPE_1_CONTROLLER_HPP
#include "IController.hpp"
#include <set>

namespace Engine {
class Controller : public IController {
  public:
    Controller(int gamepadId = 0);

    ~Controller() override = default;

    void Update() override;

    void addKeybind(const Action& action, const Keybind& kb, bool networked = false) override;

    bool isActionActive(const std::string& action) const override;

    bool isActionPressed(const std::string& action) const override;

    const std::set<Action>& getActiveActions() const override;

    const std::set<Action>& getNetworkedActiveActions() const override;

    void setGamepadId(const int gamepadId) {
        m_gamepadId = gamepadId;
    }

  private:
    int m_gamepadId;

    bool isKeybindPressed(const Keybind& kb) const;
    bool isKeybindPressedThisFrame(const Keybind& kb) const;
};
} // namespace Engine

#endif // G_ING_500_BAR_5_1_RTYPE_1_CONTROLLER_HPP