holesome/src/game/input/key_features.hpp

36 lines
774 B
C++
Raw Normal View History

2023-05-17 23:22:45 +02:00
#ifndef HOLESOME_KEY_FEATURES_HPP
#define HOLESOME_KEY_FEATURES_HPP
#include "direction.h"
#include "input_identity.h"
#include "../../config.h"
#include "input_device_group.h"
struct KeyFeatures
{
sf::Keyboard::Key key;
HardDirection hardDirection = HardDirection::NONE;
InputDeviceGroup deviceGroup = InputDeviceGroup::UNKNOWN;
explicit KeyFeatures(sf::Keyboard::Key key);
};
KeyFeatures::KeyFeatures(sf::Keyboard::Key key)
{
this->key = key;
hardDirection = Direction::getKeyDirection(key);
// Determine device group
for (const auto& groupKeys: KEY_GROUPS)
{
if (groupKeys.second.contains(key))
{
deviceGroup = groupKeys.first;
break;
}
}
}
#endif //HOLESOME_KEY_FEATURES_HPP