holesome/src/game/input/input_mapper.h

42 lines
1 KiB
C
Raw Normal View History

#ifndef HOLESOME_INPUT_MAPPER_H
#define HOLESOME_INPUT_MAPPER_H
#include "../game.h"
#include <SFML/Window/Event.hpp>
#include "../../config.h"
2023-05-09 20:50:50 +02:00
#include "direction.h"
2023-05-16 21:56:55 +02:00
#include "input_identity.h"
class Game;
/**
* Maps the inputs to actions.
*/
class InputMapper
{
public:
2023-05-08 18:20:55 +02:00
static void setGame(Game *game);
2023-05-08 18:20:55 +02:00
static void processEvents();
2023-05-16 21:56:55 +02:00
static std::shared_ptr<InputIdentity> getInputIdentity(InputDeviceType deviceType, unsigned int gamepadId = 0);
2023-05-09 20:50:50 +02:00
private:
2023-05-08 18:20:55 +02:00
static inline Game *game = nullptr;
2023-05-16 21:56:55 +02:00
static std::shared_ptr<InputIdentity> allIdentity;
static std::shared_ptr<InputIdentity> keyboardIdentity;
static std::map<unsigned int, std::shared_ptr<InputIdentity>> gamepadIdentities;
static inline std::vector<HardDirection> inputDirectionBuffer = std::vector<HardDirection>();
2023-05-09 20:50:50 +02:00
2023-05-08 18:20:55 +02:00
static void handleKeyPress(sf::Event::KeyEvent event);
2023-05-09 20:50:50 +02:00
static void handleKeyRelease(sf::Event::KeyEvent event);
2023-05-16 21:56:55 +02:00
static void handleJoystickMovement(sf::Event::JoystickMoveEvent event);
};
#endif //HOLESOME_INPUT_MAPPER_H