input prpg

This commit is contained in:
2025-09-20 12:47:47 -05:00
parent 1d16c0ae68
commit a896b772fb
5 changed files with 256 additions and 0 deletions

61
src/input/Input.cpp Normal file
View File

@@ -0,0 +1,61 @@
// Copyright (c) 2025 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#include "Input.hpp"
using namespace Dawn;
Input::Input(void) :
states({}),
buttons({})
{
}
float_t Input::getCurrent(const InputBind &bind) const {
auto it = states.find(bind);
if(it != states.end()) {
return it->second.current;
}
return 0.0f;
}
float_t Input::getPrevious(const InputBind &bind) const {
auto it = states.find(bind);
if(it != states.end()) {
return it->second.previous;
}
return 0.0f;
}
float_t Input::getWhen(const InputBind &bind) const {
auto it = states.find(bind);
if(it != states.end()) {
return it->second.when;
}
return 0.0f;
}
bool_t Input::isDown(const InputBind &bind) const {
return this->getCurrent(bind) != 0.0f;
}
bool_t Input::isUp(const InputBind &bind) const {
return this->getCurrent(bind) == 0.0f;
}
bool_t Input::wasPressed(const InputBind &bind) const {
return this->getPrevious(bind) == 0.0f && this->getCurrent(bind) != 0.0f;
}
bool_t Input::wasReleased(const InputBind &bind) const {
return this->getPrevious(bind) != 0.0f && this->getCurrent(bind) == 0.0f;
}
void Input::update(void) {
}
Input::~Input(void) {
}