/*
* author: Patrick-Christopher Mattulat
* e-mail: webmaster@lynarstudios.com
*/
#include
#include
using ls::atlantis::glossary::KeyboardKeys;
using ls::atlantis::input::KeyboardKeyMap;
using ls::atlantis::input::KeyStatus;
using ls::atlantis::input::SdlKeyboard;
using ::std::move;
SdlKeyboard::SdlKeyboard(KeyboardKeyMap _keys) : keys(::move(_keys))
{}
SdlKeyboard::~SdlKeyboard() = default;
bool SdlKeyboard::isFreed(const KeyboardKeys &_key)
{
const auto entry = this->keys.find(_key);
return entry != this->keys.end() && entry->second.getIsFreedValue();
}
bool SdlKeyboard::isPressed(const KeyboardKeys &_key)
{
const auto entry = this->keys.find(_key);
return entry != this->keys.end() && entry->second.getIsPressedValue();
}
void SdlKeyboard::reset()
{
for (auto &[key, status] : this->keys)
{
status.setIsFreedValue(false);
status.setIsPressedValue(false);
}
}
void SdlKeyboard::updateKey(const KeyboardKeys &_key, const bool _isFreed, const bool _isPressed)
{
this->keys[_key].setIsFreedValue(_isFreed);
this->keys[_key].setIsPressedValue(_isPressed);
}