Allow people calling the advanced PollEvents manually to use the wait feature on a per call basis.

This commit is contained in:
Jeffery Myers 2021-09-27 15:57:39 -07:00
parent 92f6290dbb
commit a3530ee7dc
2 changed files with 12 additions and 8 deletions

View File

@ -946,7 +946,7 @@ RLAPI const char *GetClipboardText(void); // Get clipboa
// By default EndDrawing() does this job: draws everything + SwapScreenBuffer() + manage frame timming + PollInputEvents()
// To avoid that behaviour and control frame processes manually, enable in config.h: SUPPORT_CUSTOM_FRAME_CONTROL
RLAPI void SwapScreenBuffer(void); // Swap back buffer with front buffer (screen drawing)
RLAPI void PollInputEvents(void); // Register all input events
RLAPI void PollInputEvents(bool waitForEvents); // Register all input events
RLAPI void WaitTime(float ms); // Wait for some milliseconds (halt program execution)
// Cursor-related functions

View File

@ -2001,7 +2001,12 @@ void EndDrawing(void)
CORE.Time.frame += waitTime; // Total frame time: update + draw + wait
}
PollInputEvents(); // Poll user events (before next frame update)
bool wait = false;
#if defined(SUPPORT_EVENTS_WAITING)
wait = true;
#endif
PollInputEvents(wait); // Poll user events (before next frame update)
#endif
#if defined(SUPPORT_EVENTS_AUTOMATION)
@ -4573,7 +4578,7 @@ void SwapScreenBuffer(void)
}
// Register all input events
void PollInputEvents(void)
void PollInputEvents(bool waitForEvents)
{
#if defined(SUPPORT_GESTURES_SYSTEM)
// NOTE: Gestures update must be called every frame to reset gestures correctly
@ -4719,11 +4724,10 @@ void PollInputEvents(void)
CORE.Window.resizedLastFrame = false;
#if defined(SUPPORT_EVENTS_WAITING)
glfwWaitEvents();
#else
glfwPollEvents(); // Register keyboard/mouse events (callbacks)... and window events!
#endif
if (waitForEvents)
glfwWaitEvents();
else
glfwPollEvents(); // Register keyboard/mouse events (callbacks)... and window events!
#endif // PLATFORM_DESKTOP
// Gamepad support using emscripten API