summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Bradley <jcb@pikum.xyz>2023-12-06 21:11:29 -0500
committerJonathan Bradley <jcb@pikum.xyz>2023-12-06 21:11:29 -0500
commita7e6acea6f3d75ba162ac0bcedcf2900568b8ea6 (patch)
tree6baf26a51019ed68b5314ad1de70f5b10d42374f
parent94f2dd025cc9764fafdb89ef2830173b0e1c56e6 (diff)
player-input track if events happened this tick
-rw-r--r--src/player-input.cpp15
-rw-r--r--src/player-input.hpp4
2 files changed, 8 insertions, 11 deletions
diff --git a/src/player-input.cpp b/src/player-input.cpp
index 9f50307..1e87093 100644
--- a/src/player-input.cpp
+++ b/src/player-input.cpp
@@ -284,14 +284,14 @@ void PkeInput_Tick(double delta) {
auto &ev = registeredKeyEvents[i];
// TODO the idea here was right, but wrong place and too wide a swath
// if (i < count - 1) ev.isPressed = false;
- ev.pressCount = 0;
+ ev.thisTick = false;
}
count = registeredMouseButtonEvents.Count();
for (int64_t i = 0; i < count; ++i) {
auto &ev = registeredMouseButtonEvents[i];
// TODO the idea here was right, but wrong place and too wide a swath
// if (i < count - 1) ev.isPressed = false;
- ev.pressCount = 0;
+ ev.thisTick = false;
}
count = registeredScrollEvents.Count();
for (int64_t i = 0; i < count; ++i) {
@@ -348,15 +348,13 @@ void PkeInput_Tick(double delta) {
}
if (ev.action == GLFW_PRESS) {
primaryEvent->isPressed = true;
+ primaryEvent->thisTick = true;
} else if (ev.action == GLFW_RELEASE) {
- if (primaryEvent->isPressed == true) {
- primaryEvent->pressCount += 1;
- }
primaryEvent->isPressed = false;
+ primaryEvent->thisTick = true;
} else {
// repeat
primaryEvent->isPressed = true;
- primaryEvent->pressCount += 1;
}
}
} while (0);
@@ -375,11 +373,10 @@ void PkeInput_Tick(double delta) {
}
if (ev.action == GLFW_PRESS) {
primaryEvent->isPressed = true;
+ primaryEvent->thisTick = true;
} else if (ev.action == GLFW_RELEASE) {
- if (primaryEvent->isPressed == true) {
- primaryEvent->pressCount += 1;
- }
primaryEvent->isPressed = false;
+ primaryEvent->thisTick = true;
}
}
} while (0);
diff --git a/src/player-input.hpp b/src/player-input.hpp
index a44ae42..59d2c75 100644
--- a/src/player-input.hpp
+++ b/src/player-input.hpp
@@ -72,14 +72,14 @@ struct PkeCursorPosEvent : public PkeInputEventBase {
struct PkeKeyEvent : public PkeInputEventBase {
InputActionSetHandle sourceSet;
bool isPressed;
- int8_t pressCount;
+ bool thisTick;
int32_t button;
int32_t mods;
};
struct PkeMouseButtonEvent : public PkeInputEventBase {
InputActionSetHandle sourceSet;
bool isPressed;
- int8_t pressCount;
+ bool thisTick;
int32_t button;
int32_t mods;
};