input prpg
This commit is contained in:
61
src/input/Input.cpp
Normal file
61
src/input/Input.cpp
Normal 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) {
|
||||
}
|
Reference in New Issue
Block a user