2023-05-07 12:27:11 +02:00
|
|
|
#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"
|
2023-05-17 23:22:45 +02:00
|
|
|
#include "input_device_group.h"
|
2023-05-07 12:27:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Maps the inputs to actions.
|
|
|
|
*/
|
|
|
|
class InputMapper
|
|
|
|
{
|
2023-05-17 14:13:39 +02:00
|
|
|
|
2023-05-07 12:27:11 +02:00
|
|
|
public:
|
2023-05-17 14:13:39 +02:00
|
|
|
InputMapper();
|
|
|
|
static std::shared_ptr<InputMapper> getInstance();
|
2023-05-07 12:27:11 +02:00
|
|
|
|
2023-05-17 14:13:39 +02:00
|
|
|
void processEvents();
|
2023-05-20 00:10:03 +02:00
|
|
|
void updateIdentityEvents();
|
2023-05-07 12:27:11 +02:00
|
|
|
|
2023-05-20 00:10:03 +02:00
|
|
|
std::shared_ptr<InputIdentity> getInputIdentity(InputDeviceGroup deviceGroup, unsigned int gamepadId = 0);
|
|
|
|
|
|
|
|
std::set<std::shared_ptr<InputIdentity>> getInputIdentities();
|
|
|
|
|
|
|
|
public:
|
|
|
|
std::set<std::shared_ptr<InputIdentity>> newInputIdentities;
|
|
|
|
std::set<std::shared_ptr<InputIdentity>> deprecatedInputIdentities;
|
2023-05-09 20:50:50 +02:00
|
|
|
|
2023-05-07 12:27:11 +02:00
|
|
|
private:
|
2023-05-17 14:13:39 +02:00
|
|
|
static inline std::shared_ptr<InputMapper> singletonInstance = nullptr;
|
|
|
|
|
2023-05-20 00:10:03 +02:00
|
|
|
std::set<std::shared_ptr<InputIdentity>> inputIdentities;
|
2023-05-07 12:27:11 +02:00
|
|
|
|
2023-05-17 14:13:39 +02:00
|
|
|
void handleKeyPress(sf::Event::KeyEvent event);
|
2023-05-16 21:56:55 +02:00
|
|
|
|
2023-05-17 14:13:39 +02:00
|
|
|
void handleKeyRelease(sf::Event::KeyEvent event);
|
2023-05-09 20:50:50 +02:00
|
|
|
|
2023-05-17 14:13:39 +02:00
|
|
|
void handleJoystickMovement(sf::Event::JoystickMoveEvent event);
|
2023-05-09 20:50:50 +02:00
|
|
|
|
2023-05-20 00:10:03 +02:00
|
|
|
void deactivateIdentity(const std::shared_ptr<InputIdentity>& identity);
|
2023-05-07 12:27:11 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif //HOLESOME_INPUT_MAPPER_H
|