Updating a few more things to state events, will probably stop here for now and revist the trailing things later.

This commit is contained in:
2023-03-01 14:16:50 -08:00
parent 3cd6d555d1
commit 91163cfcad
15 changed files with 397 additions and 405 deletions

View File

@ -7,6 +7,7 @@
#include "dawnlibs.hpp"
#include "util/mathutils.hpp"
#include "assert/assert.hpp"
#include "state/StateEvent.hpp"
namespace Dawn {
class DawnGame;
@ -32,6 +33,9 @@ namespace Dawn {
public:
DawnGame *game;
StateEvent<inputbind_t> eventBindPressed;
StateEvent<inputbind_t> eventBindReleased;
IInputManager(DawnGame *game) {
assertNotNull(game);
this->game = game;
@ -163,7 +167,7 @@ namespace Dawn {
// For each bind...
while(it != this->binds.end()) {
float_t value = 0.0f;
float_t value = 0.0f, valCurrent;
// For each input axis...
auto bindIt = it->second.begin();
@ -176,10 +180,20 @@ namespace Dawn {
// Set into current values
if(this->currentIsLeft) {
valCurrent = this->valuesRight[it->first];
this->valuesLeft[it->first] = value;
} else {
valCurrent = this->valuesLeft[it->first];
this->valuesRight[it->first] = value;
}
// Fire events when necessary.
if(value == 0 && valCurrent == 1) {
eventBindReleased.invoke(it->first);
} else if(valCurrent == 0 && value == 1) {
eventBindPressed.invoke(it->first);
}
++it;
}