ADDED: EnableEventWaiting()
/ DisableEventWaiting()
Events waiting can be enabled/disabled, it toggles event polling.
This commit is contained in:
parent
f3aac87422
commit
db16833d8c
2 changed files with 32 additions and 15 deletions
|
@ -949,6 +949,8 @@ RLAPI Vector2 GetWindowScaleDPI(void); // Get window
|
||||||
RLAPI const char *GetMonitorName(int monitor); // Get the human-readable, UTF-8 encoded name of the primary monitor
|
RLAPI const char *GetMonitorName(int monitor); // Get the human-readable, UTF-8 encoded name of the primary monitor
|
||||||
RLAPI void SetClipboardText(const char *text); // Set clipboard text content
|
RLAPI void SetClipboardText(const char *text); // Set clipboard text content
|
||||||
RLAPI const char *GetClipboardText(void); // Get clipboard text content
|
RLAPI const char *GetClipboardText(void); // Get clipboard text content
|
||||||
|
RLAPI void EnableEventWaiting(void); // Enable waiting for events on EndDrawing(), no automatic event polling
|
||||||
|
RLAPI void DisableEventWaiting(void); // Disable waiting for events on EndDrawing(), automatic events polling
|
||||||
|
|
||||||
// Custom frame control functions
|
// Custom frame control functions
|
||||||
// NOTE: Those functions are intended for advance users that want full control over the frame processing
|
// NOTE: Those functions are intended for advance users that want full control over the frame processing
|
||||||
|
|
45
src/rcore.c
45
src/rcore.c
|
@ -394,6 +394,7 @@ typedef struct CoreData {
|
||||||
bool fullscreen; // Check if fullscreen mode is enabled
|
bool fullscreen; // Check if fullscreen mode is enabled
|
||||||
bool shouldClose; // Check if window set for closing
|
bool shouldClose; // Check if window set for closing
|
||||||
bool resizedLastFrame; // Check if window has been resized last frame
|
bool resizedLastFrame; // Check if window has been resized last frame
|
||||||
|
bool eventWaiting; // Wait for events before ending frame
|
||||||
|
|
||||||
Point position; // Window position on screen (required on fullscreen toggle)
|
Point position; // Window position on screen (required on fullscreen toggle)
|
||||||
Size display; // Display width and height (monitor, device-screen, LCD, ...)
|
Size display; // Display width and height (monitor, device-screen, LCD, ...)
|
||||||
|
@ -761,6 +762,9 @@ void InitWindow(int width, int height, const char *title)
|
||||||
CORE.Input.Mouse.scale = (Vector2){ 1.0f, 1.0f };
|
CORE.Input.Mouse.scale = (Vector2){ 1.0f, 1.0f };
|
||||||
CORE.Input.Mouse.cursor = MOUSE_CURSOR_ARROW;
|
CORE.Input.Mouse.cursor = MOUSE_CURSOR_ARROW;
|
||||||
CORE.Input.Gamepad.lastButtonPressed = -1;
|
CORE.Input.Gamepad.lastButtonPressed = -1;
|
||||||
|
#if defined(SUPPORT_EVENTS_WAITING)
|
||||||
|
CORE.Window.eventWaiting = true;
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(PLATFORM_ANDROID)
|
#if defined(PLATFORM_ANDROID)
|
||||||
CORE.Window.screen.width = width;
|
CORE.Window.screen.width = width;
|
||||||
|
@ -1899,6 +1903,29 @@ const char *GetMonitorName(int monitor)
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set clipboard text content
|
||||||
|
void SetClipboardText(const char *text)
|
||||||
|
{
|
||||||
|
#if defined(PLATFORM_DESKTOP)
|
||||||
|
glfwSetClipboardString(CORE.Window.handle, text);
|
||||||
|
#endif
|
||||||
|
#if defined(PLATFORM_WEB)
|
||||||
|
emscripten_run_script(TextFormat("navigator.clipboard.writeText('%s')", text));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
// Enable waiting for events on EndDrawing(), no automatic event polling
|
||||||
|
void EnableEventWaiting(void)
|
||||||
|
{
|
||||||
|
CORE.Window.eventWaiting = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable waiting for events on EndDrawing(), automatic events polling
|
||||||
|
RLAPI void DisableEventWaiting(void)
|
||||||
|
{
|
||||||
|
CORE.Window.eventWaiting = false;
|
||||||
|
}
|
||||||
|
|
||||||
// Get clipboard text content
|
// Get clipboard text content
|
||||||
// NOTE: returned string is allocated and freed by GLFW
|
// NOTE: returned string is allocated and freed by GLFW
|
||||||
const char *GetClipboardText(void)
|
const char *GetClipboardText(void)
|
||||||
|
@ -1912,16 +1939,7 @@ const char *GetClipboardText(void)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set clipboard text content
|
|
||||||
void SetClipboardText(const char *text)
|
|
||||||
{
|
|
||||||
#if defined(PLATFORM_DESKTOP)
|
|
||||||
glfwSetClipboardString(CORE.Window.handle, text);
|
|
||||||
#endif
|
|
||||||
#if defined(PLATFORM_WEB)
|
|
||||||
emscripten_run_script(TextFormat("navigator.clipboard.writeText('%s')", text));
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
// Show mouse cursor
|
// Show mouse cursor
|
||||||
void ShowCursor(void)
|
void ShowCursor(void)
|
||||||
|
@ -5038,11 +5056,8 @@ void PollInputEvents(void)
|
||||||
|
|
||||||
CORE.Window.resizedLastFrame = false;
|
CORE.Window.resizedLastFrame = false;
|
||||||
|
|
||||||
#if defined(SUPPORT_EVENTS_WAITING)
|
if (CORE.Window.eventWaiting) glfwWaitEvents(); // Wait for in input events before continue (drawing is paused)
|
||||||
glfwWaitEvents();
|
else glfwPollEvents(); // Poll input events: keyboard/mouse/window events (callbacks)
|
||||||
#else
|
|
||||||
glfwPollEvents(); // Register keyboard/mouse events (callbacks)... and window events!
|
|
||||||
#endif
|
|
||||||
#endif // PLATFORM_DESKTOP
|
#endif // PLATFORM_DESKTOP
|
||||||
|
|
||||||
#if defined(PLATFORM_WEB)
|
#if defined(PLATFORM_WEB)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue