From dd75e676bc3becca1988fde4e01047ce2aca925a Mon Sep 17 00:00:00 2001 From: Guldoman Date: Sun, 12 Nov 2023 00:48:34 +0100 Subject: [PATCH] Fix running `core.step` when receiving an event while not waiting When `time_to_wake` was <= 0, so when a coroutine needed to be executed as soon as possible, we didn't check for events, so we only performed a `core.step` with the blink timer. This resulted in jerky reactions to input. --- data/core/init.lua | 2 +- docs/api/system.lua | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/data/core/init.lua b/data/core/init.lua index 8b43d8ed..61ee9b97 100644 --- a/data/core/init.lua +++ b/data/core/init.lua @@ -1461,7 +1461,7 @@ function core.run() local cursor_time_to_wake = dt + 1 / config.fps next_step = now + cursor_time_to_wake end - if time_to_wake > 0 and system.wait_event(math.min(next_step - now, time_to_wake)) then + if system.wait_event(math.min(next_step - now, time_to_wake)) then next_step = nil -- if we've recevied an event, perform a step end else diff --git a/docs/api/system.lua b/docs/api/system.lua index 9e5ef289..ae0f7424 100644 --- a/docs/api/system.lua +++ b/docs/api/system.lua @@ -61,10 +61,10 @@ function system.poll_event() end --- ---Wait until an event is triggered. --- ----@param timeout number Amount of seconds, also supports fractions ----of a second, eg: 0.01 +---@param timeout? number Amount of seconds, also supports fractions +---of a second, eg: 0.01. If not provided, waits forever. --- ----@return boolean status True on success or false if there was an error. +---@return boolean status True on success or false if there was an error or if no event was received. function system.wait_event(timeout) end ---