[turbine/glfw] Move MandatoryRefreshPeriod to config.hpp
All checks were successful
Build / build (push) Successful in 2m45s

This commit is contained in:
Gary Talent 2024-12-10 23:29:50 -06:00
parent d85a10af84
commit 003f97201f
2 changed files with 15 additions and 9 deletions

View File

@ -4,8 +4,11 @@
#pragma once
#include <turbine/turbine.hpp>
namespace turbine::config {
constexpr bool GlFpsPrint = TURBINE_GL_FPS_PRINT;
inline constexpr bool GlFpsPrint = TURBINE_GL_FPS_PRINT;
inline constexpr TimeMs MandatoryRefreshPeriod = 168;
}

View File

@ -9,6 +9,8 @@
#include <imgui_impl_opengl3.h>
#endif
#include "config.hpp"
#include <ox/std/span.hpp>
#include "context.hpp"
@ -62,26 +64,27 @@ static void handleKeyPress(Context &ctx, int key, bool down) noexcept {
return map;
}();
auto const eventHandler = keyEventHandler(ctx);
auto const k = keyMap[static_cast<std::size_t>(key)];
setKeyDownStatus(ctx, k, down);
if (eventHandler) {
eventHandler(ctx, k, down);
auto const keyIdx = static_cast<std::size_t>(key);
if (keyIdx < keyMap.size()) {
auto const k = keyMap[keyIdx];
setKeyDownStatus(ctx, k, down);
if (eventHandler) {
eventHandler(ctx, k, down);
}
}
}
static void handleGlfwCursorPosEvent(GLFWwindow*, double, double) noexcept {
}
static constexpr TimeMs MandatoryRefreshPeriod = 168;
static void handleGlfwMouseButtonEvent(GLFWwindow *window, int, int, int) noexcept {
auto const ctx = static_cast<Context*>(glfwGetWindowUserPointer(window));
ctx->mandatoryRefreshPeriodEnd = MandatoryRefreshPeriod;
ctx->mandatoryRefreshPeriodEnd = config::MandatoryRefreshPeriod;
}
static void handleGlfwKeyEvent(GLFWwindow *window, int key, int, int action, int) noexcept {
auto const ctx = static_cast<Context*>(glfwGetWindowUserPointer(window));
ctx->mandatoryRefreshPeriodEnd = MandatoryRefreshPeriod;
ctx->mandatoryRefreshPeriodEnd = config::MandatoryRefreshPeriod;
if (action == GLFW_PRESS) {
handleKeyPress(*ctx, key, true);
} else if (action == GLFW_RELEASE) {