holesome/src/game/input/input_mapper.h

45 lines
1.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"
/**
* Maps the inputs to actions.
*/
class InputMapper
{
public:
InputMapper();
static std::shared_ptr<InputMapper> getInstance();
void processEvents();
std::shared_ptr<InputIdentity> getInputIdentity(InputDeviceType deviceType, unsigned int gamepadId = 0);
std::vector<std::shared_ptr<InputIdentity>> getAllInputIdentities();
2023-05-09 20:50:50 +02:00
private:
static inline std::shared_ptr<InputMapper> singletonInstance = nullptr;
std::shared_ptr<InputIdentity> allIdentity;
std::shared_ptr<InputIdentity> keyboardIdentity;
std::map<unsigned int, std::shared_ptr<InputIdentity>> gamepadIdentities;
void handleKeyPress(sf::Event::KeyEvent event);
2023-05-16 21:56:55 +02:00
void handleKeyRelease(sf::Event::KeyEvent event);
2023-05-09 20:50:50 +02:00
void handleJoystickMovement(sf::Event::JoystickMoveEvent event);
2023-05-09 20:50:50 +02:00
void addGamepadIdentity(unsigned int gamepadId);
2023-05-16 21:56:55 +02:00
void deactivateGamepadIdentity(unsigned int gamepadId);
};
#endif //HOLESOME_INPUT_MAPPER_H