From 4c8f967e0e164d27c53a459e09bd3983137999b8 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Wed, 11 Dec 2024 22:13:28 -0600 Subject: [PATCH] [turbine/glfw] Fix mandatoryRefreshPeriodEnd tracking --- deps/nostalgia/src/olympic/turbine/src/glfw/gfx.cpp | 12 ++++++------ .../src/olympic/turbine/src/glfw/turbine.cpp | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/deps/nostalgia/src/olympic/turbine/src/glfw/gfx.cpp b/deps/nostalgia/src/olympic/turbine/src/glfw/gfx.cpp index 231c3ed..8967630 100644 --- a/deps/nostalgia/src/olympic/turbine/src/glfw/gfx.cpp +++ b/deps/nostalgia/src/olympic/turbine/src/glfw/gfx.cpp @@ -78,17 +78,17 @@ static void handleGlfwCursorPosEvent(GLFWwindow*, double, double) noexcept { } static void handleGlfwMouseButtonEvent(GLFWwindow *window, int, int, int) noexcept { - auto const ctx = static_cast(glfwGetWindowUserPointer(window)); - ctx->mandatoryRefreshPeriodEnd = config::MandatoryRefreshPeriod; + auto &ctx = *static_cast(glfwGetWindowUserPointer(window)); + ctx.mandatoryRefreshPeriodEnd = ticksMs(ctx) + config::MandatoryRefreshPeriod; } static void handleGlfwKeyEvent(GLFWwindow *window, int key, int, int action, int) noexcept { - auto const ctx = static_cast(glfwGetWindowUserPointer(window)); - ctx->mandatoryRefreshPeriodEnd = config::MandatoryRefreshPeriod; + auto &ctx = *static_cast(glfwGetWindowUserPointer(window)); + ctx.mandatoryRefreshPeriodEnd = ticksMs(ctx) + config::MandatoryRefreshPeriod; if (action == GLFW_PRESS) { - handleKeyPress(*ctx, key, true); + handleKeyPress(ctx, key, true); } else if (action == GLFW_RELEASE) { - handleKeyPress(*ctx, key, false); + handleKeyPress(ctx, key, false); } } diff --git a/deps/nostalgia/src/olympic/turbine/src/glfw/turbine.cpp b/deps/nostalgia/src/olympic/turbine/src/glfw/turbine.cpp index 4e4b540..4ff6f08 100644 --- a/deps/nostalgia/src/olympic/turbine/src/glfw/turbine.cpp +++ b/deps/nostalgia/src/olympic/turbine/src/glfw/turbine.cpp @@ -88,7 +88,7 @@ ox::Error run(Context &ctx) noexcept { tickFps(ctx, ticks); draw(ctx); auto const realSleepTime = ox::min(static_cast(ctx.refreshWithinMs), sleepTime); - if (realSleepTime && ctx.mandatoryRefreshPeriodEnd >= ticks) { + if (realSleepTime && ctx.mandatoryRefreshPeriodEnd <= ticks) { glfwWaitEventsTimeout(static_cast(realSleepTime) / 1000); } }