keysDown is sometimes missed on main thread when framerate is low
When triggering combo, the keys used are also being handled by overlay
The first issue happens when the hid thread loops twice, setting keysDown and then unsetting it in the second loop before the main thread has a chance to read the keys state. The hid thread now aggregates key downs into keysDownPending shared data, which is only cleared by the main thread when it has a chance to read it. This solution also works for very low fps situation where the user presses and releases a key within the duration of a single frame.
The second issue happens because handleInput in the main thread is called even while overlay is fading in/out. I moved the overlay hide/show blocks in the hid thread into the mutex block because there's a race condition in which the main thread could read the combo before the hid thread sets the fading flags. Didn't notice any fps drop from this change.
This PR fixes 2 issues:
keysDown
is sometimes missed on main thread when framerate is lowThe first issue happens when the hid thread loops twice, setting keysDown and then unsetting it in the second loop before the main thread has a chance to read the keys state. The hid thread now aggregates key downs into
keysDownPending
shared data, which is only cleared by the main thread when it has a chance to read it. This solution also works for very low fps situation where the user presses and releases a key within the duration of a single frame.The second issue happens because handleInput in the main thread is called even while overlay is fading in/out. I moved the overlay hide/show blocks in the hid thread into the mutex block because there's a race condition in which the main thread could read the combo before the hid thread sets the fading flags. Didn't notice any fps drop from this change.