Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SDL: Fix a bunch of input timeout edge-cases #1541

Merged
merged 4 commits into from
Oct 24, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions ffi/SDL2_0.lua
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,9 @@ local is_in_touch = false

function S.waitForEvent(sec, usec)
local event = ffi.new("union SDL_Event")
-- TimeVal's :tomsecs if we were passed one to begin with, otherwise, -1 => block
local timeout = sec and math.floor(sec * 1000000 + usec + 0.5) / 1000 or -1
-- TimeVal to ms if we were passed one to begin with, otherwise, -1 => block.
-- NOTE: Since we have *less* precision than a timeval, we round *up*, to avoid passing zero for < 1ms timevals.
local timeout = sec and math.ceil((sec * 1000000 + usec) * (1/1000)) or -1

-- Reset the queue
inputQueue = {}
Expand Down