16 Commits

Author SHA1 Message Date
Ray
e045e8fa1f REDESIGNED: Gestures system, process touch/mouse actions after being polled
Gestures system has been redesigned to avoid duplicate code calls on all platform backends, now platforms can just store `CORE.Input.Touch` state and information is processed on `rcore` main loop (`EndDrawing()`) after `PollInputEvents()`.

`rgestures` module was created on 2014 and it has barely been updated along the years, it has many problems. Current gestures detection mechanisms try to detect gestures only on touch-events detection (touch/mouse UP-DOWN-MOVE). A new (future) design could consider detection running per-frame.
2026-11-27 20:44:45 +01:00
Ray
aefcca3505 Reverted changes TextReplace() and TextReplaceAlloc()
After further review thy are considering a very limit case where the resulting strings are longer than INT_MAX, that only can happen if user passes that kind of limit. `MAX_TEXT_BUFFER_LENGTH` is  more than enough.
2026-11-27 19:35:53 +01:00
8054413f53 [examples] Use render width for high-DPI pixel grid (#6447)
Co-authored-by: yex743055-sudo <318559365+yex743055-sudo@users.noreply.github.com>
2026-11-27 19:21:52 +01:00
0a63f1252f Fix for integer overflow (#6452) (#6453)
* Fix for integer overflow (#6452)

* Change to avoid using (long long) and check for overflow before usage
2026-11-27 19:20:10 +01:00
99b0707988 [rtext] Fix TextJoin dropping the last string at the buffer limit (#6454) 2026-11-27 12:41:26 +01:00
Ray
40b9da5e54 Update CONVENTIONS.md 2026-11-26 23:04:32 +01:00
1f64f34cc0 [rcore][win32] Implement monitor query functions (#6450)
* [rcore][win32] Implement monitor query functions

* Update monitor name in RefreshMonitorsProc instead of lazily allocating it
2026-11-26 22:36:47 +01:00
7aeef57754 [rlsw] Add missing function declarations (#6451) 2026-11-25 20:00:43 +01:00
Ray
7cbadefd06 Remove some spacing on module data 2026-11-24 21:09:37 +01:00
Ray
9fcb245f28 Clipboard image enabled by default 2026-11-24 21:09:03 +01:00
dd8e7491e2 [rmodels] Fix memory leak in LoadModelAnimations() (#6449) 2026-11-24 15:14:10 +01:00
fa14dc7792 [Examples] Updated text_animations shaking delta generation (#6448) 2026-11-24 12:08:39 +01:00
88b10152e9 rlparser: update raylib_api.* by CI 2026-11-24 11:07:33 +00:00
Ray
867376c6cb ADDED: SetClipboardImage() -WIP- 2026-11-24 12:07:10 +01:00
Ray
b7011ad4d4 Update Makefile.Android 2026-11-24 12:01:18 +01:00
b4a4f9d360 [rtextures] Round instead of truncate in ColorFromHSV() (#6445) 2026-11-24 10:23:09 +01:00
28 changed files with 1384 additions and 1281 deletions

View File

@ -77,7 +77,7 @@ if (dataPtr != NULL)
dataPtr = NULL; dataPtr = NULL;
} }
``` ```
- Memory allocation return value checks: no checks are done, the probabilities of allocators failing are very low and it would add a great amount of checking code, if a finer control is needed for allocators, macors can be overriden by custom implementations. - Memory allocation return value checks: no checks are done, the probabilities of allocators failing are very low and it would add a great amount of checking code, if a finer control is needed for allocators, macros are provided to be overriden with custom implementations.
**If proposing new functions, please try to use a clear naming for function-name and functions-parameters, in case of doubt, open an issue for discussion.** **If proposing new functions, please try to use a clear naming for function-name and functions-parameters, in case of doubt, open an issue for discussion.**

View File

@ -26,15 +26,16 @@ PLATFORM ?= PLATFORM_ANDROID
RAYLIB_PATH ?= ..\.. RAYLIB_PATH ?= ..\..
# Define Android architecture (armeabi-v7a, arm64-v8a, x86, x86-64) and API version # Define Android architecture (armeabi-v7a, arm64-v8a, x86, x86-64) and API version
# Starting in 2019 using ARM64 is mandatory for published apps, # NOTE: Starting in 2019 using ARM64 is mandatory for published apps
# Starting on August 2020, minimum required target API is Android 10 (API level 29) # NOTE: Starting on August 2020, minimum required target API is Android 10 (API level 29)
# NOTE: Android 13 (API level 33), released on August 2022 should be a safe bet
ANDROID_ARCH ?= ARM64 ANDROID_ARCH ?= ARM64
ANDROID_API_VERSION = 29 ANDROID_API_VERSION = 33
# Android required path variables # Android required path variables
# NOTE: Starting with Android NDK r21, no more toolchain generation is required, NDK is the toolchain on itself # NOTE: Starting with Android NDK r21, no more toolchain generation is required, NDK is the toolchain on itself
ifeq ($(OS),Windows_NT) ifeq ($(OS),Windows_NT)
ANDROID_NDK = C:/android-ndk ANDROID_NDK = C:/android-ndk-r30
ANDROID_TOOLCHAIN = $(ANDROID_NDK)/toolchains/llvm/prebuilt/windows-x86_64 ANDROID_TOOLCHAIN = $(ANDROID_NDK)/toolchains/llvm/prebuilt/windows-x86_64
else else
ANDROID_NDK ?= /usr/lib/android/ndk ANDROID_NDK ?= /usr/lib/android/ndk
@ -55,10 +56,10 @@ ifeq ($(ANDROID_ARCH),x86_64)
endif endif
# Required path variables # Required path variables
# NOTE: JAVA_HOME must be set to JDK (using OpenJDK 13) # NOTE: JAVA_HOME must be set to JDK (using OpenJDK 27.0.1.1)
JAVA_HOME ?= C:/open-jdk JAVA_HOME ?= C:/open-jdk-27.0.1.1
ANDROID_HOME ?= C:/android-sdk ANDROID_HOME ?= C:/android-sdk
ANDROID_BUILD_TOOLS ?= $(ANDROID_HOME)/build-tools/29.0.3 ANDROID_BUILD_TOOLS ?= $(ANDROID_HOME)/build-tools/36.0.0
ANDROID_PLATFORM_TOOLS = $(ANDROID_HOME)/platform-tools ANDROID_PLATFORM_TOOLS = $(ANDROID_HOME)/platform-tools
# Android project configuration variables # Android project configuration variables
@ -137,7 +138,9 @@ CFLAGS += -ffunction-sections -funwind-tables -fstack-protector-strong -fPIC
# Compiler options for the linker # Compiler options for the linker
CFLAGS += -Wall -Wa,--noexecstack -Wformat -Werror=format-security -no-canonical-prefixes CFLAGS += -Wall -Wa,--noexecstack -Wformat -Werror=format-security -no-canonical-prefixes
# Preprocessor macro definitions # Preprocessor macro definitions
CFLAGS += -DANDROID -DPLATFORM_ANDROID -D__ANDROID_API__=$(ANDROID_API_VERSION) CFLAGS += -DANDROID -DPLATFORM_ANDROID
# NOTE: API level is already implicit on compiler call, no need for redefinition
#-D__ANDROID_API__=$(ANDROID_API_VERSION)
# Paths containing required header files # Paths containing required header files
INCLUDE_PATHS = -I. -I$(RAYLIB_PATH)/src -I$(NATIVE_APP_GLUE_PATH) INCLUDE_PATHS = -I. -I$(RAYLIB_PATH)/src -I$(NATIVE_APP_GLUE_PATH)

View File

@ -32,6 +32,7 @@ int main(void)
const int screenWidth = 800; const int screenWidth = 800;
const int screenHeight = 450; const int screenHeight = 450;
// Remove FLAG_WINDOW_HIGHDPI to compare with automatic DPI scaling disabled
SetConfigFlags(FLAG_WINDOW_HIGHDPI | FLAG_WINDOW_RESIZABLE); SetConfigFlags(FLAG_WINDOW_HIGHDPI | FLAG_WINDOW_RESIZABLE);
InitWindow(screenWidth, screenHeight, "raylib [core] example - highdpi demo"); InitWindow(screenWidth, screenHeight, "raylib [core] example - highdpi demo");
SetWindowMinSize(450, 450); SetWindowMinSize(450, 450);
@ -45,7 +46,6 @@ int main(void)
int pixelGridLabelY = pixelGridBottom + 30; int pixelGridLabelY = pixelGridBottom + 30;
int pixelGridDescY = pixelGridLabelY + 30; int pixelGridDescY = pixelGridLabelY + 30;
int cellSize = 50; int cellSize = 50;
float cellSizePx = (float)cellSize;
SetTargetFPS(60); // Set our game to run at 60 frames-per-second SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
@ -64,7 +64,11 @@ int main(void)
int currentMonitor = GetCurrentMonitor(); int currentMonitor = GetCurrentMonitor();
Vector2 dpiScale = GetWindowScaleDPI(); Vector2 dpiScale = GetWindowScaleDPI();
cellSizePx = ((float)cellSize)/dpiScale.x; int renderWidth = GetRenderWidth();
// The monitor DPI scale can differ from the actual render scale when HiDPI is disabled
float renderToLogicalX = (renderWidth > 0)? ((float)GetScreenWidth())/renderWidth : 1.0f;
int pixelCellWidth = (int)(cellSize*renderToLogicalX);
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Draw // Draw
@ -90,12 +94,12 @@ int main(void)
odd = true; odd = true;
const int minTextSpace = 30; const int minTextSpace = 30;
int lastTextX = -minTextSpace; int lastTextX = -minTextSpace;
for (int i = cellSize; i < GetRenderWidth(); i += cellSize, odd = !odd) for (int i = cellSize; i < renderWidth; i += cellSize, odd = !odd)
{ {
int x = (int)(((float)i)/dpiScale.x); int x = (int)(i*renderToLogicalX);
if (odd) DrawRectangle(x, pixelGridTop, (int)cellSizePx, pixelGridBottom - pixelGridTop, CLITERAL(Color){ 0, 121, 241, 100 }); if (odd) DrawRectangle(x, pixelGridTop, pixelCellWidth, pixelGridBottom - pixelGridTop, CLITERAL(Color){ 0, 121, 241, 100 });
DrawLine(x, pixelGridTop, (int)(((float)i)/dpiScale.x), pixelGridLabelY - 10, GRAY); DrawLine(x, pixelGridTop, x, pixelGridLabelY - 10, GRAY);
if ((x - lastTextX) >= minTextSpace) if ((x - lastTextX) >= minTextSpace)
{ {
@ -104,7 +108,7 @@ int main(void)
} }
} }
DrawTextCenter(TextFormat("Window is %d \"physical pixels\" wide", GetRenderWidth()), windowCenter, pixelGridDescY, 20, BLUE); DrawTextCenter(TextFormat("Window is %d \"physical pixels\" wide", renderWidth), windowCenter, pixelGridDescY, 20, BLUE);
const char *text = "Can you see this?"; const char *text = "Can you see this?";
Vector2 size = MeasureTextEx(GetFontDefault(), text, 20, 3); Vector2 size = MeasureTextEx(GetFontDefault(), text, 20, 3);

View File

@ -52,6 +52,7 @@ int main(void)
int frameCount = 0; int frameCount = 0;
Vector2 glyphPosition[MAX_TEXT_LENGTH] = { 0 }; Vector2 glyphPosition[MAX_TEXT_LENGTH] = { 0 };
Vector2 glyphDelta[MAX_TEXT_LENGTH] = { 0 };
unsigned char glyphAlpha[MAX_TEXT_LENGTH] = { 0 }; unsigned char glyphAlpha[MAX_TEXT_LENGTH] = { 0 };
SetTargetFPS(60); SetTargetFPS(60);
@ -66,8 +67,8 @@ int main(void)
if (IsKeyPressed(KEY_S)) text.delta = Clamp(text.delta - 2.0f, 10.0f, 60.0f); if (IsKeyPressed(KEY_S)) text.delta = Clamp(text.delta - 2.0f, 10.0f, 60.0f);
else if (IsKeyPressed(KEY_W)) text.delta = Clamp(text.delta + 2.0f, 10.0f, 60.0f); else if (IsKeyPressed(KEY_W)) text.delta = Clamp(text.delta + 2.0f, 10.0f, 60.0f);
if (IsKeyPressed(KEY_A)) text.duration = (int) Clamp((float) text.duration - 5.0f, 20.0f, 120.0f); if (IsKeyPressed(KEY_A)) text.duration = (int) Clamp((float) text.duration - 5.0f, 10.0f, 120.0f);
else if (IsKeyPressed(KEY_D)) text.duration = (int) Clamp((float) text.duration + 5.0f, 20.0f, 120.0f); else if (IsKeyPressed(KEY_D)) text.duration = (int) Clamp((float) text.duration + 5.0f, 10.0f, 120.0f);
if (IsKeyPressed(KEY_Z)) text.offset = Clamp(text.offset - 1.0f, 0.0f, 15.0f); if (IsKeyPressed(KEY_Z)) text.offset = Clamp(text.offset - 1.0f, 0.0f, 15.0f);
else if (IsKeyPressed(KEY_X)) text.offset = Clamp(text.offset + 1.0f, 0.0f, 15.0f); else if (IsKeyPressed(KEY_X)) text.offset = Clamp(text.offset + 1.0f, 0.0f, 15.0f);
if (IsKeyPressed(KEY_Q)) currentAnimation = currentAnimation? currentAnimation - 1 : animationsSize - 1; if (IsKeyPressed(KEY_Q)) currentAnimation = currentAnimation? currentAnimation - 1 : animationsSize - 1;
@ -107,18 +108,21 @@ int main(void)
for (unsigned int i = 0; i < TextLength(text.str); i++) for (unsigned int i = 0; i < TextLength(text.str); i++)
{ {
float time = (int) (frameCount + i*text.offset)%(int)text.duration; float time = (int) (frameCount + i*text.offset)%(int)text.duration;
float deltaX = (float) GetRandomValue(-text.delta/10, text.delta/10); if (time <= 1.0f) // Actives once every `text.duration` frames
float deltaY = (float) GetRandomValue(-text.delta/10, text.delta/10); {
glyphDelta[i].x = (float) GetRandomValue(-text.delta/10, text.delta/10);
glyphDelta[i].y = (float) GetRandomValue(-text.delta/10, text.delta/10);
}
if (time < (text.duration/2)) if (time < (text.duration/2))
{ {
glyphPosition[i].x = EaseLinearNone(time, glyphPosition[i].x, deltaX, text.duration/2); glyphPosition[i].x = EaseLinearNone(time, glyphPosition[i].x, glyphDelta[i].x, text.duration/2);
glyphPosition[i].y = EaseLinearNone(time, text.position.y, deltaY, text.duration/2); glyphPosition[i].y = EaseLinearNone(time, text.position.y, glyphDelta[i].y, text.duration/2);
} }
else else
{ {
glyphPosition[i].x = EaseLinearNone(time - text.duration/2, glyphPosition[i].x + deltaX, -deltaX, text.duration/2); glyphPosition[i].x = EaseLinearNone(time - text.duration/2, glyphPosition[i].x + glyphDelta[i].x, -glyphDelta[i].x, text.duration/2);
glyphPosition[i].y = EaseLinearNone(time - text.duration/2, text.position.y + deltaY, -deltaY, text.duration/2); glyphPosition[i].y = EaseLinearNone(time - text.duration/2, text.position.y + glyphDelta[i].y, -glyphDelta[i].y, text.duration/2);
} }
} }
} break; } break;

View File

@ -72,10 +72,6 @@
// Include pseudo-random numbers generator (rprand.h), based on Xoshiro128** and SplitMix64 // Include pseudo-random numbers generator (rprand.h), based on Xoshiro128** and SplitMix64
#define SUPPORT_RPRAND_GENERATOR 1 #define SUPPORT_RPRAND_GENERATOR 1
#endif #endif
#ifndef SUPPORT_MOUSE_GESTURES
// Mouse gestures are directly mapped like touches and processed by the gestures system
#define SUPPORT_MOUSE_GESTURES 1
#endif
#ifndef SUPPORT_SSH_KEYBOARD_RPI #ifndef SUPPORT_SSH_KEYBOARD_RPI
// Reconfigure standard input to receive key inputs, works with SSH connection // Reconfigure standard input to receive key inputs, works with SSH connection
#define SUPPORT_SSH_KEYBOARD_RPI 1 #define SUPPORT_SSH_KEYBOARD_RPI 1
@ -113,16 +109,6 @@
// Enabling this flag allows manual control of the frame processes, use at your own risk // Enabling this flag allows manual control of the frame processes, use at your own risk
#define SUPPORT_CUSTOM_FRAME_CONTROL 0 // Disabled by default #define SUPPORT_CUSTOM_FRAME_CONTROL 0 // Disabled by default
#endif #endif
#ifndef SUPPORT_CLIPBOARD_IMAGE
// Support for clipboard image loading
// NOTE: Only working on SDL3, GLFW (Windows) and RGFW (Windows)
// WARNING: It requires support for some additional flags:
// - SUPPORT_MODULE_RTEXTURES
// - SUPPORT_FILEFORMAT_BMP (Windows clipboard)
// - SUPPORT_FILEFORMAT_PNG (Wayland clipboard)
// - SUPPORT_FILEFORMAT_JPG
#define SUPPORT_CLIPBOARD_IMAGE 1
#endif
// rcore: Configuration values // rcore: Configuration values
// NOTE: Below values are already defined inside [rcore.c] so there is no need to be // NOTE: Below values are already defined inside [rcore.c] so there is no need to be

2
src/external/rlsw.h vendored
View File

@ -685,6 +685,7 @@ SWAPI void swSwapColorBuffers(void); // Swap software renderer color/back buffer
SWAPI void swEnable(SWstate state); SWAPI void swEnable(SWstate state);
SWAPI void swDisable(SWstate state); SWAPI void swDisable(SWstate state);
SWAPI void swGetIntegerv(SWget name, int *v);
SWAPI void swGetFloatv(SWget name, float *v); SWAPI void swGetFloatv(SWget name, float *v);
SWAPI const char *swGetString(SWget name); SWAPI const char *swGetString(SWget name);
SWAPI SWerrcode swGetError(void); SWAPI SWerrcode swGetError(void);
@ -746,6 +747,7 @@ SWAPI void swDrawElements(SWdraw mode, int count, int type, const void *indices)
SWAPI void swGenTextures(int count, uint32_t *textures); SWAPI void swGenTextures(int count, uint32_t *textures);
SWAPI void swDeleteTextures(int count, uint32_t *textures); SWAPI void swDeleteTextures(int count, uint32_t *textures);
SWAPI void swBindTexture(uint32_t id); SWAPI void swBindTexture(uint32_t id);
SWAPI void swTexStorage2D(int width, int height, SWinternalformat format);
SWAPI void swTexImage2D(int width, int height, SWformat format, SWtype type, const void *data); SWAPI void swTexImage2D(int width, int height, SWformat format, SWtype type, const void *data);
SWAPI void swTexSubImage2D(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); SWAPI void swTexSubImage2D(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels);
SWAPI void swTexParameteri(int param, int value); SWAPI void swTexParameteri(int param, int value);

View File

@ -19,7 +19,6 @@
* *
* DEPENDENCIES: * DEPENDENCIES:
* - Android NDK: Provides C API to access Android functionality * - Android NDK: Provides C API to access Android functionality
* - gestures: Gestures system for touch-ready devices (or simulated from mouse inputs)
* *
* *
* LICENSE: zlib/libpng * LICENSE: zlib/libpng
@ -706,12 +705,22 @@ const char *GetClipboardText(void)
return buffer; return buffer;
} }
// Set clipboard image content
bool SetClipboardImage(Image image)
{
bool result = false;
TRACELOG(LOG_WARNING, "SetClipboardImage() not implemented on target platform");
return result;
}
// Get clipboard image // Get clipboard image
Image GetClipboardImage(void) Image GetClipboardImage(void)
{ {
Image image = { 0 }; Image image = { 0 };
TRACELOG(LOG_WARNING, "GetClipboardImage() not implemented on target platform"); TRACELOG(LOG_WARNING, "Clipboard image retrieving not implemented");
return image; return image;
} }
@ -851,12 +860,6 @@ const char *GetKeyName(int key)
// Register all input events // Register all input events
void PollInputEvents(void) void PollInputEvents(void)
{ {
#if SUPPORT_GESTURES_SYSTEM
// NOTE: Gestures update must be called every frame to reset gestures correctly
// because ProcessGestureEvent() is called on an event, not every frame
UpdateGestures();
#endif
// Reset keys/chars pressed registered // Reset keys/chars pressed registered
CORE.Input.Keyboard.keyPressedQueueCount = 0; CORE.Input.Keyboard.keyPressedQueueCount = 0;
CORE.Input.Keyboard.charPressedQueueCount = 0; CORE.Input.Keyboard.charPressedQueueCount = 0;
@ -881,7 +884,7 @@ void PollInputEvents(void)
for (int i = 0; i < MAX_TOUCH_POINTS; i++) CORE.Input.Touch.previousTouchState[i] = CORE.Input.Touch.currentTouchState[i]; for (int i = 0; i < MAX_TOUCH_POINTS; i++) CORE.Input.Touch.previousTouchState[i] = CORE.Input.Touch.currentTouchState[i];
// Reset touch positions // Reset touch positions
//for (int i = 0; i < MAX_TOUCH_POINTS; i++) CORE.Input.Touch.position[i] = (Vector2){ 0, 0 }; //for (int i = 0; i < MAX_TOUCH_POINTS; i++) CORE.Input.Touch.currentPosition[i] = (Vector2){ 0, 0 };
// Register previous keys states // Register previous keys states
// NOTE: Android supports up to 260 keys // NOTE: Android supports up to 260 keys
@ -1462,7 +1465,7 @@ static int32_t AndroidInputCallback(struct android_app *app, AInputEvent *event)
// Register touch points position // Register touch points position
touchRaw.position[i] = (Vector2){ AMotionEvent_getX(event, i), AMotionEvent_getY(event, i) }; touchRaw.position[i] = (Vector2){ AMotionEvent_getX(event, i), AMotionEvent_getY(event, i) };
// Normalize CORE.Input.Touch.position[i] for CORE.Window.screen.width and CORE.Window.screen.height // Normalize CORE.Input.Touch.currentPosition[i] for CORE.Window.screen.width and CORE.Window.screen.height
float widthRatio = (float)(CORE.Window.screen.width + CORE.Window.renderOffset.x)/(float)CORE.Window.display.width; float widthRatio = (float)(CORE.Window.screen.width + CORE.Window.renderOffset.x)/(float)CORE.Window.display.width;
float heightRatio = (float)(CORE.Window.screen.height + CORE.Window.renderOffset.y)/(float)CORE.Window.display.height; float heightRatio = (float)(CORE.Window.screen.height + CORE.Window.renderOffset.y)/(float)CORE.Window.display.height;
touchRaw.position[i].x = touchRaw.position[i].x*widthRatio - (float)CORE.Window.renderOffset.x/2; touchRaw.position[i].x = touchRaw.position[i].x*widthRatio - (float)CORE.Window.renderOffset.x/2;
@ -1565,7 +1568,7 @@ static int32_t AndroidInputCallback(struct android_app *app, AInputEvent *event)
if (hover) continue; if (hover) continue;
CORE.Input.Touch.pointId[CORE.Input.Touch.pointCount] = touchRaw.pointId[i]; CORE.Input.Touch.pointId[CORE.Input.Touch.pointCount] = touchRaw.pointId[i];
CORE.Input.Touch.position[CORE.Input.Touch.pointCount] = touchRaw.position[i]; CORE.Input.Touch.currentPosition[CORE.Input.Touch.pointCount] = touchRaw.position[i];
CORE.Input.Touch.pointCount++; CORE.Input.Touch.pointCount++;
} }
@ -1577,10 +1580,10 @@ static int32_t AndroidInputCallback(struct android_app *app, AInputEvent *event)
// Stores the previous position of touch[0] only while it's active to calculate the delta // Stores the previous position of touch[0] only while it's active to calculate the delta
if (flags == AMOTION_EVENT_ACTION_MOVE) CORE.Input.Mouse.previousPosition = CORE.Input.Mouse.currentPosition; if (flags == AMOTION_EVENT_ACTION_MOVE) CORE.Input.Mouse.previousPosition = CORE.Input.Mouse.currentPosition;
else CORE.Input.Mouse.previousPosition = CORE.Input.Touch.position[0]; else CORE.Input.Mouse.previousPosition = CORE.Input.Touch.currentPosition[0];
// Map touch[0] as mouse input for convenience // Map touch[0] as mouse input for convenience
CORE.Input.Mouse.currentPosition = CORE.Input.Touch.position[0]; CORE.Input.Mouse.currentPosition = CORE.Input.Touch.currentPosition[0];
CORE.Input.Mouse.currentWheelMove = (Vector2){ 0.0f, 0.0f }; CORE.Input.Mouse.currentWheelMove = (Vector2){ 0.0f, 0.0f };
return 0; return 0;

View File

@ -22,7 +22,6 @@
* *
* DEPENDENCIES: * DEPENDENCIES:
* - rglfw: Manage graphic device, OpenGL context and inputs (Windows, Linux, OSX/macOS, FreeBSD...) * - rglfw: Manage graphic device, OpenGL context and inputs (Windows, Linux, OSX/macOS, FreeBSD...)
* - gestures: Gestures system for touch-ready devices (or simulated from mouse inputs)
* *
* *
* LICENSE: zlib/libpng * LICENSE: zlib/libpng
@ -59,6 +58,7 @@
typedef struct HWND__ *HWND; typedef struct HWND__ *HWND;
#endif #endif
#define WIN32_CLIPBOARD_IMPLEMENTATION
#include "../external/win32_clipboard.h" // Clipboard image copy-paste #include "../external/win32_clipboard.h" // Clipboard image copy-paste
#define GLFW_EXPOSE_NATIVE_WIN32 #define GLFW_EXPOSE_NATIVE_WIN32
@ -796,8 +796,7 @@ void *GetWindowHandle(void)
#if defined(_WIN32) #if defined(_WIN32)
handle = glfwGetWin32Window(platform.handle); // Type: HWND handle = glfwGetWin32Window(platform.handle); // Type: HWND
#endif #elif defined(__linux__)
#if defined(__linux__)
#if defined(_GLFW_WAYLAND) #if defined(_GLFW_WAYLAND)
#if defined(_GLFW_X11) #if defined(_GLFW_X11)
int platformID = glfwGetPlatform(); int platformID = glfwGetPlatform();
@ -818,8 +817,7 @@ void *GetWindowHandle(void)
platform.windowHandleX11 = glfwGetX11Window(platform.handle); platform.windowHandleX11 = glfwGetX11Window(platform.handle);
handle = &platform.windowHandleX11; handle = &platform.windowHandleX11;
#endif #endif
#endif #elif defined(__APPLE__)
#if defined(__APPLE__)
handle = (void *)glfwGetCocoaWindow(platform.handle); // Type: NSWindow* handle = (void *)glfwGetCocoaWindow(platform.handle); // Type: NSWindow*
#endif #endif
@ -1081,20 +1079,40 @@ void SetClipboardText(const char *text)
} }
// 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)
{ {
return glfwGetClipboardString(platform.handle); return glfwGetClipboardString(platform.handle);
} }
// Set clipboard image content
bool SetClipboardImage(Image image)
{
bool result = false;
#if defined(_WIN32)
#elif defined(__linux__)
#elif defined(__APPLE__)
#endif
return result;
}
// Get clipboard image // Get clipboard image
Image GetClipboardImage(void) Image GetClipboardImage(void)
{ {
Image image = { 0 }; Image image = { 0 };
#if SUPPORT_CLIPBOARD_IMAGE && SUPPORT_MODULE_RTEXTURES #if !SUPPORT_MODULE_RTEXTURES
#if defined(_WIN32) TRACELOG(LOG_WARNING, "Clipboard image requires SUPPORT_MODULE_RTEXTURES to work");
return image;
#endif
#if defined(_WIN32)
unsigned int dataSize = 0; unsigned int dataSize = 0;
void *bmpData = NULL; void *bmpData = NULL;
int width = 0; int width = 0;
@ -1106,13 +1124,10 @@ Image GetClipboardImage(void)
else else
{ {
image = LoadImageFromMemory(".bmp", (const unsigned char *)bmpData, (int)dataSize); image = LoadImageFromMemory(".bmp", (const unsigned char *)bmpData, (int)dataSize);
RL_FREE(bmpData); RL_FREE(bmpData);
} }
#elif defined(__linux__) && defined(_GLFW_X11) #elif defined(__linux__) && defined(_GLFW_X11)
// REF: https://github.com/ColleagueRiley/Clipboard-Copy-Paste/blob/main/x11.c // REF: https://github.com/ColleagueRiley/Clipboard-Copy-Paste/blob/main/x11.
static Atom clipboard = 0; static Atom clipboard = 0;
static Atom targetType = 0; static Atom targetType = 0;
static Atom property = 0; static Atom property = 0;
@ -1150,13 +1165,9 @@ Image GetClipboardImage(void)
image = LoadImageFromMemory(".png", data, (int)nitems); image = LoadImageFromMemory(".png", data, (int)nitems);
XFree(data); XFree(data);
} }
#else #else
TRACELOG(LOG_WARNING, "GetClipboardImage() not implemented on target platform"); TRACELOG(LOG_WARNING, "Clipboard image not implemented on target platform");
#endif // _WIN32 #endif
#else
TRACELOG(LOG_WARNING, "Clipboard image: SUPPORT_CLIPBOARD_IMAGE requires SUPPORT_MODULE_RTEXTURES to work properly");
#endif // SUPPORT_CLIPBOARD_IMAGE
return image; return image;
} }
@ -1245,11 +1256,9 @@ void OpenURL(const char *url)
char *cmd = (char *)RL_CALLOC(strlen(url) + 16, sizeof(char)); char *cmd = (char *)RL_CALLOC(strlen(url) + 16, sizeof(char));
#if defined(_WIN32) #if defined(_WIN32)
sprintf(cmd, "explorer \"%s\"", url); sprintf(cmd, "explorer \"%s\"", url);
#endif #elif defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__)
#if defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__)
sprintf(cmd, "xdg-open '%s'", url); // Alternatives: firefox, x-www-browser sprintf(cmd, "xdg-open '%s'", url); // Alternatives: firefox, x-www-browser
#endif #elif defined(__APPLE__)
#if defined(__APPLE__)
sprintf(cmd, "open '%s'", url); sprintf(cmd, "open '%s'", url);
#endif #endif
int result = system(cmd); int result = system(cmd);
@ -1307,21 +1316,14 @@ const char *GetKeyName(int key)
// Register all input events // Register all input events
void PollInputEvents(void) void PollInputEvents(void)
{ {
#if SUPPORT_GESTURES_SYSTEM
// NOTE: Gestures update must be called every frame to reset gestures correctly
// because ProcessGestureEvent() is called on an event, not every frame
UpdateGestures();
#endif
// Reset keys/chars pressed registered // Reset keys/chars pressed registered
CORE.Input.Keyboard.keyPressedQueueCount = 0; CORE.Input.Keyboard.keyPressedQueueCount = 0;
CORE.Input.Keyboard.charPressedQueueCount = 0; CORE.Input.Keyboard.charPressedQueueCount = 0;
// Reset last gamepad button/axis registered state // Reset last gamepad button/axis registered state
CORE.Input.Gamepad.lastButtonPressed = GAMEPAD_BUTTON_UNKNOWN; CORE.Input.Gamepad.lastButtonPressed = GAMEPAD_BUTTON_UNKNOWN;
//CORE.Input.Gamepad.axisCount = 0;
// Keyboard/Mouse input polling (automatically managed by GLFW3 through callback) // NOTE: Keyboard/Mouse input polling (automatically managed by GLFW3 through callback)
// Register previous keys states // Register previous keys states
for (int i = 0; i < MAX_KEYBOARD_KEYS; i++) for (int i = 0; i < MAX_KEYBOARD_KEYS; i++)
@ -1343,15 +1345,20 @@ void PollInputEvents(void)
// Register previous touch states // Register previous touch states
for (int i = 0; i < MAX_TOUCH_POINTS; i++) CORE.Input.Touch.previousTouchState[i] = CORE.Input.Touch.currentTouchState[i]; for (int i = 0; i < MAX_TOUCH_POINTS; i++) CORE.Input.Touch.previousTouchState[i] = CORE.Input.Touch.currentTouchState[i];
// Reset touch positions // Register previous touch positions and reset
//for (int i = 0; i < MAX_TOUCH_POINTS; i++) CORE.Input.Touch.position[i] = (Vector2){ 0, 0 }; for (int i = 0; i < MAX_TOUCH_POINTS; i++)
{
CORE.Input.Touch.previousPosition[i] = CORE.Input.Touch.currentPosition[i];
CORE.Input.Touch.currentPosition[i] = (Vector2){ 0, 0 };
}
// Map touch position to mouse position for convenience // Map touch position to mouse position for convenience
// WARNING: If the target desktop device supports touch screen, this behaviour should be reviewed! // WARNING: If the target desktop device supports touch screen, this behaviour should be reviewed!
// TODO: GLFW does not support multi-touch input yet // TODO: GLFW does not support multi-touch input yet
// REF: https://www.codeproject.com/Articles/668404/Programming-for-Multi-Touch // REF: https://www.codeproject.com/Articles/668404/Programming-for-Multi-Touch
// REF: https://docs.microsoft.com/en-us/windows/win32/wintouch/getting-started-with-multi-touch-messages // REF: https://docs.microsoft.com/en-us/windows/win32/wintouch/getting-started-with-multi-touch-messages
CORE.Input.Touch.position[0] = CORE.Input.Mouse.currentPosition; CORE.Input.Touch.currentPosition[0] = GetMousePosition();
CORE.Input.Touch.previousPosition[0] = CORE.Input.Mouse.currentPosition;
// Check if gamepads are ready // Check if gamepads are ready
// NOTE: Doing it here in case of disconnection // NOTE: Doing it here in case of disconnection
@ -1455,7 +1462,7 @@ void PollInputEvents(void)
glfwWaitEvents(); // Wait for in input events before continue (drawing is paused) glfwWaitEvents(); // Wait for in input events before continue (drawing is paused)
CORE.Time.previous = GetTime(); CORE.Time.previous = GetTime();
} }
else glfwPollEvents(); // Poll input events: keyboard/mouse/window events (callbacks) -> Update keys state else glfwPollEvents(); // Poll input events: keyboard/mouse/window events (callbacks)
CORE.Window.shouldClose = glfwWindowShouldClose(platform.handle); CORE.Window.shouldClose = glfwWindowShouldClose(platform.handle);
@ -2170,40 +2177,27 @@ static void CharCallback(GLFWwindow *window, unsigned int codepoint)
} }
} }
// GLFW3: Mouse button callback, runs on mouse button pressed // GLFW3: Mouse button callback, runs on mouse button pressed and released
static void MouseButtonCallback(GLFWwindow *window, int button, int action, int mods) static void MouseButtonCallback(GLFWwindow *window, int button, int action, int mods)
{ {
// WARNING: GLFW could only return GLFW_PRESS (1) or GLFW_RELEASE (0) for now, // WARNING: GLFW could only return GLFW_PRESS (1) or GLFW_RELEASE (0) for now,
// but future releases may add more actions (i.e. GLFW_REPEAT) // but future releases may add more actions (i.e. GLFW_REPEAT)
CORE.Input.Mouse.currentButtonState[button] = action; CORE.Input.Mouse.currentButtonState[button] = action;
CORE.Input.Touch.currentTouchState[button] = action;
#if SUPPORT_GESTURES_SYSTEM && SUPPORT_MOUSE_GESTURES // Processing mouse events as touches, using button id as touch id
// Process mouse events as touches to be able to use mouse-gestures if (action == GLFW_PRESS)
GestureEvent gestureEvent = { 0 }; {
CORE.Input.Touch.pointCount = 1;
// Register touch actions CORE.Input.Touch.pointId[button] = button;
if ((CORE.Input.Mouse.currentButtonState[button] == 1) && (CORE.Input.Mouse.previousButtonState[button] == 0)) gestureEvent.touchAction = TOUCH_ACTION_DOWN; CORE.Input.Touch.currentTouchState[button] = 1; // ACTION: DOWN
else if ((CORE.Input.Mouse.currentButtonState[button] == 0) && (CORE.Input.Mouse.previousButtonState[button] == 1)) gestureEvent.touchAction = TOUCH_ACTION_UP; CORE.Input.Touch.currentPosition[button] = GetMousePosition();
}
// NOTE: TOUCH_ACTION_MOVE event is registered in MouseCursorPosCallback() else if (action == GLFW_RELEASE)
{
// Assign a pointer ID // Point count and id should be reseted at some point
gestureEvent.pointId[0] = 0; CORE.Input.Touch.currentTouchState[button] = 0; // ACTION: UP
CORE.Input.Touch.currentPosition[button] = GetMousePosition();
// Register touch points count }
gestureEvent.pointCount = 1;
// Register touch points position, only one point registered
gestureEvent.position[0] = GetMousePosition();
// Normalize gestureEvent.position[0] for CORE.Window.screen.width and CORE.Window.screen.height
gestureEvent.position[0].x /= (float)GetScreenWidth();
gestureEvent.position[0].y /= (float)GetScreenHeight();
// Gesture data is sent to gestures-system for processing
ProcessGestureEvent(gestureEvent);
#endif
} }
// GLFW3: Cursor position callback, runs on mouse movement // GLFW3: Cursor position callback, runs on mouse movement
@ -2211,30 +2205,11 @@ static void MouseCursorPosCallback(GLFWwindow *window, double x, double y)
{ {
CORE.Input.Mouse.currentPosition.x = (float)x; CORE.Input.Mouse.currentPosition.x = (float)x;
CORE.Input.Mouse.currentPosition.y = (float)y; CORE.Input.Mouse.currentPosition.y = (float)y;
CORE.Input.Touch.position[0] = CORE.Input.Mouse.currentPosition;
#if SUPPORT_GESTURES_SYSTEM && SUPPORT_MOUSE_GESTURES // Register current touch position and movement action
// Process mouse events as touches to be able to use mouse-gestures CORE.Input.Touch.currentPosition[0] = CORE.Input.Mouse.currentPosition;
GestureEvent gestureEvent = { 0 }; if (Vector2Distance(CORE.Input.Touch.currentPosition[0], CORE.Input.Touch.previousPosition[0]) > 3.0f)
CORE.Input.Touch.currentTouchState[0] = 2; // ACTION: MOVE
gestureEvent.touchAction = TOUCH_ACTION_MOVE;
// Assign a pointer ID
gestureEvent.pointId[0] = 0;
// Register touch points count
gestureEvent.pointCount = 1;
// Register touch points position, only one point registered
gestureEvent.position[0] = CORE.Input.Touch.position[0];
// Normalize gestureEvent.position[0] for CORE.Window.screen.width and CORE.Window.screen.height
gestureEvent.position[0].x /= (float)GetScreenWidth();
gestureEvent.position[0].y /= (float)GetScreenHeight();
// Gesture data is sent to gestures-system for processing
ProcessGestureEvent(gestureEvent);
#endif
} }
// GLFW3: Mouse wheel scroll callback, runs on mouse wheel changes // GLFW3: Mouse wheel scroll callback, runs on mouse wheel changes
@ -2244,18 +2219,12 @@ static void MouseScrollCallback(GLFWwindow *window, double xoffset, double yoffs
CORE.Input.Mouse.currentWheelMove.y += (float)yoffset; CORE.Input.Mouse.currentWheelMove.y += (float)yoffset;
} }
// GLFW3: Cursor ennter callback, when cursor enters the window // GLFW3: Cursor enter callback, when cursor enters the window
// NOTE: Mouse position updated by MouseCursorPosCallback()
static void CursorEnterCallback(GLFWwindow *window, int entered) static void CursorEnterCallback(GLFWwindow *window, int entered)
{ {
if (entered) if (entered) CORE.Input.Mouse.cursorOnScreen = true;
{ else CORE.Input.Mouse.cursorOnScreen = false;
// NOTE: Mouse position updated by MouseCursorPosCallback()
CORE.Input.Mouse.cursorOnScreen = true;
}
else
{
CORE.Input.Mouse.cursorOnScreen = false;
}
} }
// GLFW3: Joystick connected/disconnected callback // GLFW3: Joystick connected/disconnected callback
@ -2277,8 +2246,4 @@ static void JoystickCallback(int jid, int event)
} }
} }
#ifdef _WIN32
# define WIN32_CLIPBOARD_IMPLEMENTATION
# include "../external/win32_clipboard.h"
#endif
// EOF // EOF

View File

@ -21,7 +21,6 @@
* *
* DEPENDENCIES: * DEPENDENCIES:
* - RGFW.h (main library): Windowing and inputs management * - RGFW.h (main library): Windowing and inputs management
* - gestures: Gestures system for touch-ready devices (or simulated from mouse inputs)
* *
* *
* LICENSE: zlib/libpng * LICENSE: zlib/libpng
@ -168,6 +167,17 @@ extern "C" {
#undef Size #undef Size
#endif #endif
#if defined(_WIN32)
#define WIN32_CLIPBOARD_IMPLEMENTATION
#define WINUSER_ALREADY_INCLUDED
#define WINBASE_ALREADY_INCLUDED
#define WINGDI_ALREADY_INCLUDED
#include "../external/win32_clipboard.h"
#elif defined(__linux__) && defined(DRGFW_X11)
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#endif
#include <stdbool.h> #include <stdbool.h>
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
@ -685,7 +695,7 @@ static void RGFW_cb_mouserawmotionfunc(const RGFW_event *e)
CORE.Input.Mouse.currentPosition.y += mouseY; CORE.Input.Mouse.currentPosition.y += mouseY;
// simulate touch with the mouse // simulate touch with the mouse
CORE.Input.Touch.position[0] = CORE.Input.Mouse.currentPosition; CORE.Input.Touch.currentPosition[0] = CORE.Input.Mouse.currentPosition;
RemapMouseToTouch(2); RemapMouseToTouch(2);
} }
static void RGFW_cb_mousemotionfunc(const RGFW_event *e) static void RGFW_cb_mousemotionfunc(const RGFW_event *e)
@ -713,7 +723,7 @@ static void RGFW_cb_mousemotionfunc(const RGFW_event *e)
CORE.Input.Mouse.currentPosition.y = mouseY; CORE.Input.Mouse.currentPosition.y = mouseY;
// simulate touch with the mouse // simulate touch with the mouse
CORE.Input.Touch.position[0] = CORE.Input.Mouse.currentPosition; CORE.Input.Touch.currentPosition[0] = CORE.Input.Mouse.currentPosition;
RemapMouseToTouch(2); RemapMouseToTouch(2);
} }
static void RGFW_cb_keyfunc(const RGFW_keyEvent* e) static void RGFW_cb_keyfunc(const RGFW_keyEvent* e)
@ -1307,27 +1317,17 @@ const char *GetClipboardText(void)
return RGFW_readClipboard(NULL); return RGFW_readClipboard(NULL);
} }
#if SUPPORT_CLIPBOARD_IMAGE
#if defined(_WIN32)
#define WIN32_CLIPBOARD_IMPLEMENTATION
#define WINUSER_ALREADY_INCLUDED
#define WINBASE_ALREADY_INCLUDED
#define WINGDI_ALREADY_INCLUDED
#include "../external/win32_clipboard.h"
#elif defined(__linux__) && defined(DRGFW_X11)
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#endif
#endif
// Get clipboard image // Get clipboard image
Image GetClipboardImage(void) Image GetClipboardImage(void)
{ {
Image image = { 0 }; Image image = { 0 };
#if SUPPORT_CLIPBOARD_IMAGE && SUPPORT_MODULE_RTEXTURES #if !SUPPORT_MODULE_RTEXTURES
#if defined(_WIN32) TRACELOG(LOG_WARNING, "Clipboard image requires SUPPORT_MODULE_RTEXTURES to work");
return image;
#endif
#if defined(_WIN32)
unsigned int dataSize = 0; unsigned int dataSize = 0;
void *fileData = NULL; void *fileData = NULL;
@ -1339,12 +1339,9 @@ Image GetClipboardImage(void)
else else
{ {
image = LoadImageFromMemory(".bmp", (const unsigned char *)fileData, (int)dataSize); image = LoadImageFromMemory(".bmp", (const unsigned char *)fileData, (int)dataSize);
RL_FREE(fileData); RL_FREE(fileData);
} }
#elif defined(__linux__) && defined(DRGFW_X11) #elif defined(__linux__) && defined(DRGFW_X11)
// REF: https://github.com/ColleagueRiley/Clipboard-Copy-Paste/blob/main/x11.c // REF: https://github.com/ColleagueRiley/Clipboard-Copy-Paste/blob/main/x11.c
Display *dpy = XOpenDisplay(NULL); Display *dpy = XOpenDisplay(NULL);
if (!dpy) return image; if (!dpy) return image;
@ -1390,11 +1387,8 @@ Image GetClipboardImage(void)
XDestroyWindow(dpy, win); XDestroyWindow(dpy, win);
XCloseDisplay(dpy); XCloseDisplay(dpy);
#else #else
TRACELOG(LOG_WARNING, "Clipboard image: PLATFORM_DESKTOP_RGFW doesn't implement GetClipboardImage() for this OS"); TRACELOG(LOG_WARNING, "Clipboard image not implemented on target platform");
#endif // _WIN32 #endif
#else
TRACELOG(LOG_WARNING, "Clipboard image: SUPPORT_CLIPBOARD_IMAGE requires SUPPORT_MODULE_RTEXTURES to work properly");
#endif // SUPPORT_CLIPBOARD_IMAGE
return image; return image;
} }
@ -1557,12 +1551,6 @@ const char *GetKeyName(int key)
// Register all input events // Register all input events
void PollInputEvents(void) void PollInputEvents(void)
{ {
#if SUPPORT_GESTURES_SYSTEM
// NOTE: Gestures update must be called every frame to reset gestures correctly
// because ProcessGestureEvent() is called on an event, not every frame
UpdateGestures();
#endif
// Reset keys/chars pressed registered // Reset keys/chars pressed registered
CORE.Input.Keyboard.keyPressedQueueCount = 0; CORE.Input.Keyboard.keyPressedQueueCount = 0;
CORE.Input.Keyboard.charPressedQueueCount = 0; CORE.Input.Keyboard.charPressedQueueCount = 0;
@ -1591,7 +1579,7 @@ void PollInputEvents(void)
for (int i = 0; i < MAX_TOUCH_POINTS; i++) CORE.Input.Touch.previousTouchState[i] = CORE.Input.Touch.currentTouchState[i]; for (int i = 0; i < MAX_TOUCH_POINTS; i++) CORE.Input.Touch.previousTouchState[i] = CORE.Input.Touch.currentTouchState[i];
// Map touch position to mouse position for convenience // Map touch position to mouse position for convenience
CORE.Input.Touch.position[0] = CORE.Input.Mouse.currentPosition; CORE.Input.Touch.currentPosition[0] = CORE.Input.Mouse.currentPosition;
// Register previous keys states // Register previous keys states
// NOTE: Android supports up to 260 keys // NOTE: Android supports up to 260 keys
@ -2042,35 +2030,29 @@ static KeyboardKey ConvertScancodeToKey(u32 keycode)
return (KeyboardKey)RGFW_keyConvertTable[keycode]; return (KeyboardKey)RGFW_keyConvertTable[keycode];
} }
// assign mouse to touches // Assign mouse input events to touches
// 0-TOUCH_ACTION_UP, 1-TOUCH_ACTION_DOWN, 2-TOUCH_ACTION_MOVE // NOTE: 0-TOUCH_ACTION_UP, 1-TOUCH_ACTION_DOWN, 2-TOUCH_ACTION_MOVE
void RemapMouseToTouch(int touchAction) void RemapMouseToTouch(int touchAction)
{ {
#if SUPPORT_GESTURES_SYSTEM #if SUPPORT_GESTURES_SYSTEM
if (touchAction < 0) return; if (touchAction < 0) return;
GestureEvent gestureEvent = { 0 }; GestureEvent gestureEvent = { 0 };
gestureEvent.touchAction = touchAction;
gestureEvent.pointId[0] = 0;
gestureEvent.pointCount = 1;
// Register touch actions // Register touch points position, only one point registered
gestureEvent.touchAction = touchAction; if ((touchAction == 2) /*|| realTouch*/) gestureEvent.position[0] = CORE.Input.Touch.currentPosition[0];
else gestureEvent.position[0] = GetMousePosition();
// Assign a pointer ID // Normalize gesture event position to [0.0f..1.0f]
gestureEvent.pointId[0] = 0; gestureEvent.position[0].x /= (float)GetScreenWidth();
gestureEvent.position[0].y /= (float)GetScreenHeight();
// Register touch points count // Gesture data is sent to gestures-system for processing
gestureEvent.pointCount = 1; ProcessGestureEvent(gestureEvent);
#endif
// Register touch points position, only one point registered
if (touchAction == 2 /*|| realTouch*/) gestureEvent.position[0] = CORE.Input.Touch.position[0];
else gestureEvent.position[0] = GetMousePosition();
// Normalize gestureEvent.position[0] for CORE.Window.screen.width and CORE.Window.screen.height
gestureEvent.position[0].x /= (float)GetScreenWidth();
gestureEvent.position[0].y /= (float)GetScreenHeight();
// Gesture data is sent to gestures-system for processing
ProcessGestureEvent(gestureEvent);
#endif
} }
// Helper functions for Time // Helper functions for Time

View File

@ -21,7 +21,6 @@
* *
* DEPENDENCIES: * DEPENDENCIES:
* - SDL 2 or SDL 3 (main library): Windowing and inputs management * - SDL 2 or SDL 3 (main library): Windowing and inputs management
* - gestures: Gestures system for touch-ready devices (or simulated from mouse inputs)
* *
* *
* LICENSE: zlib/libpng * LICENSE: zlib/libpng
@ -1200,27 +1199,37 @@ const char *GetClipboardText(void)
return buffer; return buffer;
} }
// Set clipboard image content
bool SetClipboardImage(Image image)
{
bool result = false;
// TODO: bool SDL_SetClipboardData(SDL_ClipboardDataCallback callback, SDL_ClipboardCleanupCallback cleanup, void *userdata, const char *const *mime_types, size_t num_mime_types);
return result;
}
// Get clipboard image // Get clipboard image
Image GetClipboardImage(void) Image GetClipboardImage(void)
{ {
Image image = { 0 }; Image image = { 0 };
#if SUPPORT_CLIPBOARD_IMAGE
#if !SUPPORT_MODULE_RTEXTURES #if !SUPPORT_MODULE_RTEXTURES
TRACELOG(LOG_WARNING, "Enabling SUPPORT_CLIPBOARD_IMAGE requires SUPPORT_MODULE_RTEXTURES to work properly"); TRACELOG(LOG_WARNING, "Clipboard image requires SUPPORT_MODULE_RTEXTURES to work");
return image; return image;
#endif #endif
// It's nice to have support Bitmap on Linux as well, but not as necessary as Windows // It's nice to have support Bitmap on Linux as well, but not as necessary as Windows
#if !SUPPORT_FILEFORMAT_BMP && defined(_WIN32) #if !SUPPORT_FILEFORMAT_BMP && defined(_WIN32)
TRACELOG(LOG_WARNING, "WARNING: Enabling SUPPORT_CLIPBOARD_IMAGE requires SUPPORT_FILEFORMAT_BMP, specially on Windows"); TRACELOG(LOG_WARNING, "Clipboard image requires SUPPORT_FILEFORMAT_BMP on Windows");
return image; return image;
#endif #endif
// From what I've tested applications on Wayland saves images on clipboard as PNG // From what I've tested applications on Wayland saves images on clipboard as PNG
#if (!SUPPORT_FILEFORMAT_PNG || !SUPPORT_FILEFORMAT_JPG) && !defined(_WIN32) #if (!SUPPORT_FILEFORMAT_PNG || !SUPPORT_FILEFORMAT_JPG) && !defined(_WIN32)
TRACELOG(LOG_WARNING, "WARNING: Getting image from the clipboard might not work without SUPPORT_FILEFORMAT_PNG or SUPPORT_FILEFORMAT_JPG"); TRACELOG(LOG_WARNING, "Clipboard image might require SUPPORT_FILEFORMAT_PNG or SUPPORT_FILEFORMAT_JPG");
#endif #endif
// Let's hope compiler put these arrays in static memory // Let's hope compiler put these arrays in static memory
const char *imageFormats[] = { const char *imageFormats[] = {
"image/bmp", "image/bmp",
@ -1228,6 +1237,7 @@ Image GetClipboardImage(void)
"image/jpg", "image/jpg",
"image/tiff", "image/tiff",
}; };
const char *imageExtensions[] = { const char *imageExtensions[] = {
".bmp", ".bmp",
".png", ".png",
@ -1236,7 +1246,7 @@ Image GetClipboardImage(void)
}; };
size_t dataSize = 0; size_t dataSize = 0;
void *fileData = NULL; void *fileData = NULL;
for (int i = 0; i < SDL_arraysize(imageFormats); i++) for (int i = 0; i < SDL_arraysize(imageFormats); i++)
{ {
@ -1245,19 +1255,17 @@ Image GetClipboardImage(void)
if (fileData) if (fileData)
{ {
image = LoadImageFromMemory(imageExtensions[i], fileData, (int)dataSize); image = LoadImageFromMemory(imageExtensions[i], fileData, (int)dataSize);
SDL_free(fileData); SDL_free(fileData);
if (IsImageValid(image)) if (IsImageValid(image))
{ {
TRACELOG(LOG_INFO, "Clipboard: Got image from clipboard successfully: %s", imageExtensions[i]); TRACELOG(LOG_INFO, "Clipboard image retrieved successfully (%s image data)", imageExtensions[i]);
return image; return image;
} }
} }
} }
if (!IsImageValid(image)) TRACELOG(LOG_WARNING, "Clipboard: Couldn't get clipboard data. ERROR: %s", SDL_GetError()); if (!IsImageValid(image)) TRACELOG(LOG_WARNING, "Clipboard image data can not be retrieved, ERROR: %s", SDL_GetError());
#endif // SUPPORT_CLIPBOARD_IMAGE
return image; return image;
} }
@ -1416,12 +1424,6 @@ const char *GetKeyName(int key)
// Register all input events // Register all input events
void PollInputEvents(void) void PollInputEvents(void)
{ {
#if SUPPORT_GESTURES_SYSTEM
// NOTE: Gestures update must be called every frame to reset gestures correctly
// because ProcessGestureEvent() is called on an event, not every frame
UpdateGestures();
#endif
// Reset keys/chars pressed registered // Reset keys/chars pressed registered
CORE.Input.Keyboard.keyPressedQueueCount = 0; CORE.Input.Keyboard.keyPressedQueueCount = 0;
CORE.Input.Keyboard.charPressedQueueCount = 0; CORE.Input.Keyboard.charPressedQueueCount = 0;
@ -1456,7 +1458,7 @@ void PollInputEvents(void)
for (int i = 0; i < MAX_TOUCH_POINTS; i++) CORE.Input.Touch.previousTouchState[i] = CORE.Input.Touch.currentTouchState[i]; for (int i = 0; i < MAX_TOUCH_POINTS; i++) CORE.Input.Touch.previousTouchState[i] = CORE.Input.Touch.currentTouchState[i];
// Map touch position to mouse position for convenience // Map touch position to mouse position for convenience
if (CORE.Input.Touch.pointCount == 0) CORE.Input.Touch.position[0] = CORE.Input.Mouse.currentPosition; if (CORE.Input.Touch.pointCount == 0) CORE.Input.Touch.currentPosition[0] = CORE.Input.Mouse.currentPosition;
int touchAction = -1; // 0-TOUCH_ACTION_UP, 1-TOUCH_ACTION_DOWN, 2-TOUCH_ACTION_MOVE int touchAction = -1; // 0-TOUCH_ACTION_UP, 1-TOUCH_ACTION_DOWN, 2-TOUCH_ACTION_MOVE
bool realTouch = false; // Flag to differentiate real touch gestures from mouse ones bool realTouch = false; // Flag to differentiate real touch gestures from mouse ones
@ -1741,7 +1743,7 @@ void PollInputEvents(void)
CORE.Input.Mouse.currentPosition.y = (float)event.motion.y; CORE.Input.Mouse.currentPosition.y = (float)event.motion.y;
} }
CORE.Input.Touch.position[0] = CORE.Input.Mouse.currentPosition; CORE.Input.Touch.currentPosition[0] = CORE.Input.Mouse.currentPosition;
touchAction = 2; touchAction = 2;
} break; } break;
@ -1956,36 +1958,6 @@ void PollInputEvents(void)
} break; } break;
default: break; default: break;
} }
#if SUPPORT_GESTURES_SYSTEM
if (touchAction > -1)
{
// Process mouse events as touches to be able to use mouse-gestures
GestureEvent gestureEvent = { 0 };
// Register touch actions
gestureEvent.touchAction = touchAction;
// Assign a pointer ID
gestureEvent.pointId[0] = 0;
// Register touch points count
gestureEvent.pointCount = 1;
// Register touch points position, only one point registered
if (touchAction == 2 || realTouch) gestureEvent.position[0] = CORE.Input.Touch.position[0];
else gestureEvent.position[0] = GetMousePosition();
// Normalize gestureEvent.position[0] for CORE.Window.screen.width and CORE.Window.screen.height
gestureEvent.position[0].x /= (float)GetScreenWidth();
gestureEvent.position[0].y /= (float)GetScreenHeight();
// Gesture data is sent to gestures-system for processing
ProcessGestureEvent(gestureEvent);
touchAction = -1;
}
#endif
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
} }
@ -2182,7 +2154,7 @@ int InitPlatform(void)
// Disable mouse events being interpreted as touch events // Disable mouse events being interpreted as touch events
// NOTE: This is wanted because there are SDL_FINGER* events available which provide unique data // NOTE: This is wanted because there are SDL_FINGER* events available which provide unique data
// Due to the way PollInputEvents() and rgestures.h are currently implemented, setting this won't break SUPPORT_MOUSE_GESTURES
SDL_SetHint(SDL_HINT_TOUCH_MOUSE_EVENTS, "0"); SDL_SetHint(SDL_HINT_TOUCH_MOUSE_EVENTS, "0");
SDL_EventState(SDL_DROPFILE, SDL_ENABLE); SDL_EventState(SDL_DROPFILE, SDL_ENABLE);
@ -2289,8 +2261,8 @@ static void UpdateTouchPointsSDL(SDL_TouchFingerEvent event)
{ {
SDL_Finger *finger = fingers[i]; SDL_Finger *finger = fingers[i];
CORE.Input.Touch.pointId[i] = finger->id; CORE.Input.Touch.pointId[i] = finger->id;
CORE.Input.Touch.position[i].x = finger->x*CORE.Window.screen.width; CORE.Input.Touch.currentPosition[i].x = finger->x*CORE.Window.screen.width;
CORE.Input.Touch.position[i].y = finger->y*CORE.Window.screen.height; CORE.Input.Touch.currentPosition[i].y = finger->y*CORE.Window.screen.height;
CORE.Input.Touch.currentTouchState[i] = 1; CORE.Input.Touch.currentTouchState[i] = 1;
} }
@ -2304,8 +2276,8 @@ static void UpdateTouchPointsSDL(SDL_TouchFingerEvent event)
{ {
SDL_Finger *finger = SDL_GetTouchFinger(event.touchId, i); SDL_Finger *finger = SDL_GetTouchFinger(event.touchId, i);
CORE.Input.Touch.pointId[i] = (int)finger->id; CORE.Input.Touch.pointId[i] = (int)finger->id;
CORE.Input.Touch.position[i].x = finger->x*CORE.Window.screen.width; CORE.Input.Touch.currentPosition[i].x = finger->x*CORE.Window.screen.width;
CORE.Input.Touch.position[i].y = finger->y*CORE.Window.screen.height; CORE.Input.Touch.currentPosition[i].y = finger->y*CORE.Window.screen.height;
CORE.Input.Touch.currentTouchState[i] = 1; CORE.Input.Touch.currentTouchState[i] = 1;
} }
#endif #endif

View File

@ -91,10 +91,28 @@ typedef enum MONITOR_DPI_TYPE {
#include <GL/gl.h> #include <GL/gl.h>
#endif #endif
#define WIN32_CLIPBOARD_IMPLEMENTATION
#define WINUSER_ALREADY_INCLUDED
#define WINBASE_ALREADY_INCLUDED
#define WINGDI_ALREADY_INCLUDED
#include "../external/win32_clipboard.h"
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Types and Structures Definition // Types and Structures Definition
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
typedef struct {
HMONITOR handle; // Win32 monitor handle
char *name; // Human-readable UTF-8 name
int x; // Virtual desktop X position
int y; // Virtual desktop Y position
int width; // Current mode width (pixels)
int height; // Current mode height (pixels)
int physicalWidth; // Physical width (mm)
int physicalHeight; // Physical height (mm)
int refreshRate; // Current mode refresh rate (Hz)
} Win32Monitor;
// NOTE: appScreenSize is the last screen size requested by the app, // NOTE: appScreenSize is the last screen size requested by the app,
// the backend must keep the client area this size (after DPI scaling is applied) // the backend must keep the client area this size (after DPI scaling is applied)
// when the window isn't fullscreen/maximized/minimized // when the window isn't fullscreen/maximized/minimized
@ -119,6 +137,11 @@ typedef struct {
bool perMonitorDPIAwareV2; // Flag to check DPI-awareness level. This is used mainly to distinguish between per-monitor DPI awareness v1 and v2 bool perMonitorDPIAwareV2; // Flag to check DPI-awareness level. This is used mainly to distinguish between per-monitor DPI awareness v1 and v2
Win32Monitor *monitors;
int monitorCount;
int monitorCapacity;
int currentMonitor;
LARGE_INTEGER timerFrequency; LARGE_INTEGER timerFrequency;
char *clipboardText; char *clipboardText;
@ -283,14 +306,6 @@ typedef struct {
DWORD clear; DWORD clear;
} FlagsOp; } FlagsOp;
// Monitor info type
typedef struct {
HMONITOR needle;
int index;
int matchIndex;
RECT rect;
} MonitorInfo;
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Global Const Variables Definition // Global Const Variables Definition
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
@ -460,6 +475,23 @@ static void LoadWin32FunctionPointers(void)
} }
} }
static int GetMonitorIndexFromHWND(HWND hwnd)
{
HMONITOR handle = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST);
int result = 0;
for (int i = 0; i < platform.monitorCount; i++)
{
if (platform.monitors[i].handle == handle)
{
result = i;
break;
}
}
return result;
}
// GetDpiForWindow with a fallback for older versions of Windows // GetDpiForWindow with a fallback for older versions of Windows
static UINT GetDpiForWindowCompat(HWND hwnd) static UINT GetDpiForWindowCompat(HWND hwnd)
{ {
@ -880,37 +912,6 @@ static HICON ConvertImageToWindowsIcon(Image image)
return result; return result;
} }
// Count monitors process
// NOTE: Required by GetMonitorCount()
static BOOL CALLBACK CountMonitorsProc(HMONITOR handle, HDC hdc, LPRECT rect, LPARAM lparam)
{
int *count = (int *)lparam;
*count += 1;
// Always return TRUE to continue the loop, otherwise, the caller
// can't distinguish between stopping the loop and an error
return TRUE;
}
// Find monitor process
// NOTE: Required by GetCurrentMonitor()
static BOOL CALLBACK FindMonitorProc(HMONITOR handle, HDC hdc, LPRECT rect, LPARAM lparam)
{
MonitorInfo *monitor = (MonitorInfo *)lparam;
if (handle == monitor->needle)
{
monitor->matchIndex = monitor->index;
monitor->rect = *rect;
}
monitor->index += 1;
// Always return TRUE to continue the loop, otherwise, the caller
// can't distinguish between stopping the loop and an error
return TRUE;
}
// Get style changed required operations flags // Get style changed required operations flags
// NOTE: Required for deferred operations // NOTE: Required for deferred operations
static void GetStyleChangeFlagOps(DWORD coreWindowFlags, STYLESTRUCT *style, FlagsOp *deferredFlags) static void GetStyleChangeFlagOps(DWORD coreWindowFlags, STYLESTRUCT *style, FlagsOp *deferredFlags)
@ -1157,22 +1158,55 @@ void SetWindowPosition(int x, int y)
{ {
if (platform.hwnd != NULL) if (platform.hwnd != NULL)
{ {
RECT rect = { 0 }; RECT rect = { x, y, x, y };
if (GetWindowRect(platform.hwnd, &rect)) AdjustWindowRectExForDpiCompat(&rect, MakeWindowStyle(CORE.Window.flags), FALSE, WINDOW_STYLE_EX, GetDpiForWindowCompat(platform.hwnd));
{ SetWindowPos(platform.hwnd, NULL, rect.left, rect.top, 0, 0, SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOSIZE);
int width = rect.right - rect.left;
int height = rect.bottom - rect.top;
// Move the window to the new position (keeping size and z-order)
SetWindowPos(platform.hwnd, NULL, x, y, width, height, SWP_NOZORDER | SWP_NOACTIVATE);
}
} }
} }
// Set monitor for the current window // Place window on a given monitor
void SetWindowMonitor(int monitor) void SetWindowMonitor(int monitor)
{ {
TRACELOG(LOG_WARNING, "SetWindowMonitor not implemented"); if ((monitor >= 0) && (monitor < platform.monitorCount))
{
MONITORINFO info = { 0 };
info.cbSize = sizeof(info);
HMONITOR monitorHandle = platform.monitors[monitor].handle;
if (GetMonitorInfoW(monitorHandle, &info))
{
RECT windowRect = { 0 };
GetWindowRect(platform.hwnd, &windowRect);
int windowWidth = windowRect.right - windowRect.left;
int windowHeight = windowRect.bottom - windowRect.top;
RECT rcWork = info.rcWork;
int x = rcWork.left + ((rcWork.right - rcWork.left) - windowWidth)/2;
int y = rcWork.top + ((rcWork.bottom - rcWork.top) - windowHeight)/2;
// Keep title bar on-screen if window is larger than the target monitor's work area
if (x < rcWork.left) x = rcWork.left;
if (y < rcWork.top) y = rcWork.top;
SetWindowPos(platform.hwnd, NULL, x, y, 0, 0, SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOSIZE);
GetWindowRect(platform.hwnd, &windowRect);
int newWidth = windowRect.right - windowRect.left;
int newHeight = windowRect.bottom - windowRect.top;
// The window size can change due to the WM_DPICHANGED event. The window has to be re-centered if this happens
if ((newWidth != windowWidth) || (newHeight != windowHeight))
{
x = rcWork.left + ((rcWork.right - rcWork.left) - newWidth)/2;
y = rcWork.top + ((rcWork.bottom - rcWork.top) - newHeight)/2;
if (x < rcWork.left) x = rcWork.left;
if (y < rcWork.top) y = rcWork.top;
SetWindowPos(platform.hwnd, NULL, x, y, 0, 0, SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOSIZE);
}
}
else TRACELOG(LOG_WARNING, "WIN32: Failed to get monitor info [ERROR: %lu]", GetLastError());
}
else TRACELOG(LOG_WARNING, "WIN32: Failed to find monitor with index %d", monitor);
} }
// Set window minimum dimensions (FLAG_WINDOW_RESIZABLE) // Set window minimum dimensions (FLAG_WINDOW_RESIZABLE)
@ -1236,87 +1270,190 @@ void *GetWindowHandle(void)
return (void *)platform.hwnd; return (void *)platform.hwnd;
} }
// Update all monitor info in PlatformData. This function is called via EnumDisplayMonitors
static BOOL CALLBACK RefreshMonitorsProc(HMONITOR handle, HDC hdc, LPRECT rect, LPARAM lparam)
{
MONITORINFOEXW info = { 0 };
info.cbSize = sizeof(info);
if (!GetMonitorInfoW(handle, (MONITORINFO *)&info)) return TRUE;
if (platform.monitorCount == platform.monitorCapacity)
{
platform.monitorCapacity += 1;
platform.monitors = (Win32Monitor *)RL_REALLOC(platform.monitors, platform.monitorCapacity*sizeof(Win32Monitor));
}
bool isPrimary = ((info.dwFlags & MONITORINFOF_PRIMARY) != 0);
// The primary monitor should always be at the first index
if (isPrimary && (platform.monitorCount > 0)) memmove(platform.monitors + 1, platform.monitors, sizeof(Win32Monitor)*platform.monitorCount);
Win32Monitor *monitor = &platform.monitors[(isPrimary)? 0 : platform.monitorCount];
*monitor = (Win32Monitor){ 0 };
monitor->handle = handle;
DEVMODEW dm = { 0 };
dm.dmSize = sizeof(dm);
if (EnumDisplaySettingsExW(info.szDevice, ENUM_CURRENT_SETTINGS, &dm, EDS_ROTATEDMODE))
{
monitor->x = (int)dm.dmPosition.x;
monitor->y = (int)dm.dmPosition.y;
monitor->width = (int)dm.dmPelsWidth;
monitor->height = (int)dm.dmPelsHeight;
monitor->refreshRate = (int)dm.dmDisplayFrequency;
}
const WCHAR *monitorNameW = info.szDevice;
DISPLAY_DEVICEW display = { 0 };
for (DWORD displayIndex = 0; ; displayIndex++)
{
display = (DISPLAY_DEVICEW){ 0 };
display.cb = sizeof(display);
if (!EnumDisplayDevicesW(info.szDevice, displayIndex, &display, 0)) break;
if ((display.StateFlags & DISPLAY_DEVICE_ACTIVE) != 0)
{
// Take name from first active display and break out of loop
monitorNameW = display.DeviceString;
break;
}
}
int nameSize = WideCharToMultiByte(CP_UTF8, 0, monitorNameW, -1, NULL, 0, NULL, NULL);
if (nameSize > 0)
{
monitor->name = (char *)RL_CALLOC(nameSize, sizeof(char));
WideCharToMultiByte(CP_UTF8, 0, monitorNameW, -1, monitor->name, nameSize, NULL, NULL);
}
HDC dc = CreateDCW(L"DISPLAY", info.szDevice, NULL, NULL);
if (dc)
{
// Checking these functions as a proxy for Windows version
if ((pSetProcessDpiAwarenessContext != NULL) || (pGetDpiForMonitor != NULL))
{
// Windows 8.1+, HORZSIZE/VERTSIZE report physical size in millimeters
monitor->physicalWidth = GetDeviceCaps(dc, HORZSIZE);
monitor->physicalHeight = GetDeviceCaps(dc, VERTSIZE);
}
else
{
// Older Windows fallback: use system DPI
int dpiX = GetDeviceCaps(dc, LOGPIXELSX);
int dpiY = GetDeviceCaps(dc, LOGPIXELSY);
// Divide native display resolution by DPI to get physical size in inches
// Multiply by 25.4 to convert from inches to millimeters
if (dpiX > 0) monitor->physicalWidth = (int)(dm.dmPelsWidth*25.4f/dpiX);
if (dpiY > 0) monitor->physicalHeight = (int)(dm.dmPelsHeight*25.4f/dpiY);
}
DeleteDC(dc);
}
platform.monitorCount += 1;
// Return TRUE to continue iterating
return TRUE;
}
int GetMonitorCount(void) int GetMonitorCount(void)
{ {
int count = 0; return platform.monitorCount;
int result = EnumDisplayMonitors(NULL, NULL, CountMonitorsProc, (LPARAM)&count);
if (result == 0) TRACELOG(LOG_ERROR, "%s failed, error=%lu", "EnumDisplayMonitors", GetLastError());
return count;
} }
// Get current monitor where window is placed // Get current monitor where window is placed
int GetCurrentMonitor(void) int GetCurrentMonitor(void)
{ {
HMONITOR monitor = MonitorFromWindow(platform.hwnd, MONITOR_DEFAULTTOPRIMARY); return platform.currentMonitor;
if (!monitor) TRACELOG(LOG_ERROR, "%s failed, error=%lu", "MonitorFromWindow", GetLastError());
MonitorInfo info = { 0 };
info.needle = monitor;
info.index = 0;
info.matchIndex = -1;
int result = EnumDisplayMonitors(NULL, NULL, FindMonitorProc, (LPARAM)&info);
if (result == 0) TRACELOG(LOG_ERROR, "%s failed, error=%lu", "EnumDisplayMonitors", GetLastError());
return info.matchIndex;
} }
// Get selected monitor position // Get selected monitor position
Vector2 GetMonitorPosition(int monitor) Vector2 GetMonitorPosition(int monitor)
{ {
TRACELOG(LOG_WARNING, "GetMonitorPosition not implemented"); Vector2 position = { 0 };
return (Vector2){ 0, 0 };
if ((monitor >= 0) && (monitor < platform.monitorCount))
{
position.x = (float)platform.monitors[monitor].x;
position.y = (float)platform.monitors[monitor].y;
}
else TRACELOG(LOG_WARNING, "WIN32: Failed to find monitor with index %d", monitor);
return position;
} }
// Get selected monitor width (currently used by monitor) // Get selected monitor width (currently used by monitor)
int GetMonitorWidth(int monitor) int GetMonitorWidth(int monitor)
{ {
//TRACELOG(LOG_WARNING, "GetMonitorWidth not implemented"); int width = 0;
return 0;
if ((monitor >= 0) && (monitor < platform.monitorCount)) width = platform.monitors[monitor].width;
else TRACELOG(LOG_WARNING, "WIN32: Failed to find monitor with index %d", monitor);
return width;
} }
// Get selected monitor height (currently used by monitor) // Get selected monitor height (currently used by monitor)
int GetMonitorHeight(int monitor) int GetMonitorHeight(int monitor)
{ {
//TRACELOG(LOG_WARNING, "GetMonitorHeight not implemented"); int height = 0;
return 0;
if ((monitor >= 0) && (monitor < platform.monitorCount)) height = platform.monitors[monitor].height;
else TRACELOG(LOG_WARNING, "WIN32: Failed to find monitor with index %d", monitor);
return height;
} }
// Get selected monitor physical width in millimetres // Get selected monitor physical width in millimetres
int GetMonitorPhysicalWidth(int monitor) int GetMonitorPhysicalWidth(int monitor)
{ {
TRACELOG(LOG_WARNING, "GetMonitorPhysicalWidth not implemented"); int physicalWidth = 0;
return 0;
if ((monitor >= 0) && (monitor < platform.monitorCount)) physicalWidth = platform.monitors[monitor].physicalWidth;
else TRACELOG(LOG_WARNING, "WIN32: Failed to find monitor with index %d", monitor);
return physicalWidth;
} }
// Get selected monitor physical height in millimetres // Get selected monitor physical height in millimetres
int GetMonitorPhysicalHeight(int monitor) int GetMonitorPhysicalHeight(int monitor)
{ {
TRACELOG(LOG_WARNING, "GetMonitorPhysicalHeight not implemented"); int physicalHeight = 0;
return 0;
if ((monitor >= 0) && (monitor < platform.monitorCount)) physicalHeight = platform.monitors[monitor].physicalHeight;
else TRACELOG(LOG_WARNING, "WIN32: Failed to find monitor with index %d", monitor);
return physicalHeight;
} }
// Get selected monitor refresh rate // Get selected monitor refresh rate
int GetMonitorRefreshRate(int monitor) int GetMonitorRefreshRate(int monitor)
{ {
TRACELOG(LOG_WARNING, "GetMonitorRefreshRate not implemented"); int refreshRate = 0;
return 0;
if ((monitor >= 0) && (monitor < platform.monitorCount)) refreshRate = platform.monitors[monitor].refreshRate;
else TRACELOG(LOG_WARNING, "WIN32: Failed to find monitor with index %d", monitor);
return refreshRate;
} }
// Get the human-readable, UTF-8 encoded name of the selected monitor // Get the human-readable, UTF-8 encoded name of the selected monitor
const char *GetMonitorName(int monitor) const char *GetMonitorName(int monitor)
{ {
TRACELOG(LOG_WARNING, "GetMonitorName not implemented"); const char *name = NULL;
return 0;
if ((monitor >= 0) && (monitor < platform.monitorCount)) name = platform.monitors[monitor].name;
else TRACELOG(LOG_WARNING, "WIN32: Failed to find monitor with index %d", monitor);
return name;
} }
// Get window position XY on monitor // Get window position XY on monitor
Vector2 GetWindowPosition(void) Vector2 GetWindowPosition(void)
{ {
//TRACELOG(LOG_WARNING, "GetWindowPosition not implemented"); return (Vector2){ (float)CORE.Window.position.x, (float)CORE.Window.position.y };
return (Vector2){ 0, 0 };
} }
// Get window scale DPI factor for current monitor // Get window scale DPI factor for current monitor
@ -1417,20 +1554,71 @@ const char *GetClipboardText(void)
return platform.clipboardText; return platform.clipboardText;
} }
#if SUPPORT_CLIPBOARD_IMAGE && SUPPORT_MODULE_RTEXTURES // Set clipboard image content
#define WIN32_CLIPBOARD_IMPLEMENTATION bool SetClipboardImage(Image image)
#define WINUSER_ALREADY_INCLUDED {
#define WINBASE_ALREADY_INCLUDED bool result = false;
#define WINGDI_ALREADY_INCLUDED
#include "../external/win32_clipboard.h" BOOL opened = OpenClipboard(NULL);
#endif if (opened)
{
EmptyClipboard();
Image imCopy = { 0 };
bool useCopy = false;
if (image.format != PIXELFORMAT_UNCOMPRESSED_R8G8B8A8)
{
// Make sure data is RGBA 32bit
imCopy = ImageCopy(image);
ImageFormat(&imCopy, PIXELFORMAT_UNCOMPRESSED_R8G8B8A8);
useCopy = true;
}
// Calculate bitmap information size.
BITMAPINFOHEADER header = { 0 };
header.biSize = sizeof(BITMAPINFOHEADER);
header.biWidth = image.width;
header.biHeight = -image.height; // Top-down bitmap
header.biPlanes = 1;
header.biBitCount = 32;
header.biCompression = BI_RGB;
header.biSizeImage = image.width*image.height*4;
SIZE_T size = sizeof(header) + header.biSizeImage;
HGLOBAL memory = GlobalAlloc(GMEM_MOVEABLE, size);
if (memory)
{
BYTE *data = (BYTE *)GlobalLock(memory);
memcpy(data, &header, sizeof(header));
memcpy(data + sizeof(header), useCopy? imCopy.data : image.data, header.biSizeImage);
GlobalUnlock(memory);
HANDLE clipset = SetClipboardData(CF_DIB, memory);
if (clipset == NULL) GlobalFree(memory);
}
if (useCopy) UnloadImage(imCopy);
CloseClipboard();
}
return result;
}
// Get clipboard image // Get clipboard image
Image GetClipboardImage(void) Image GetClipboardImage(void)
{ {
Image image = { 0 }; Image image = { 0 };
#if !SUPPORT_MODULE_RTEXTURES
TRACELOG(LOG_WARNING, "Clipboard image requires SUPPORT_MODULE_RTEXTURES to work");
return image;
#endif
#if SUPPORT_CLIPBOARD_IMAGE && SUPPORT_MODULE_RTEXTURES
unsigned int dataSize = 0; unsigned int dataSize = 0;
void *fileData = NULL; void *fileData = NULL;
int width = 0; int width = 0;
@ -1441,12 +1629,10 @@ Image GetClipboardImage(void)
if (fileData == NULL) TRACELOG(LOG_WARNING, "Clipboard image: Couldn't get clipboard data."); if (fileData == NULL) TRACELOG(LOG_WARNING, "Clipboard image: Couldn't get clipboard data.");
else else
{ {
// TODO: Support additional image file-formats
image = LoadImageFromMemory(".bmp", (const unsigned char*)fileData, (int)dataSize); image = LoadImageFromMemory(".bmp", (const unsigned char*)fileData, (int)dataSize);
RL_FREE(fileData); RL_FREE(fileData);
} }
#else
TRACELOG(LOG_WARNING, "Clipboard image: SUPPORT_CLIPBOARD_IMAGE requires SUPPORT_MODULE_RTEXTURES to work properly");
#endif // SUPPORT_CLIPBOARD_IMAGE
return image; return image;
} }
@ -1669,7 +1855,7 @@ void PollInputEvents(void)
// Reset touch positions // Reset touch positions
// TODO: It resets on target platform the mouse position and not filled again until a move-event, // TODO: It resets on target platform the mouse position and not filled again until a move-event,
// so, if mouse is not moved it returns a (0, 0) position... this behaviour should be reviewed! // so, if mouse is not moved it returns a (0, 0) position... this behaviour should be reviewed!
//for (int i = 0; i < MAX_TOUCH_POINTS; i++) CORE.Input.Touch.position[i] = (Vector2){ 0, 0 }; //for (int i = 0; i < MAX_TOUCH_POINTS; i++) CORE.Input.Touch.currentPosition[i] = (Vector2){ 0, 0 };
memcpy(CORE.Input.Keyboard.previousKeyState, CORE.Input.Keyboard.currentKeyState, sizeof(CORE.Input.Keyboard.previousKeyState)); memcpy(CORE.Input.Keyboard.previousKeyState, CORE.Input.Keyboard.currentKeyState, sizeof(CORE.Input.Keyboard.previousKeyState));
@ -1777,7 +1963,11 @@ HGLRC InitOpenGL(HWND hwnd, HDC hdc)
HGLRC tempContext = wglCreateContext(dummyHDC); HGLRC tempContext = wglCreateContext(dummyHDC);
//if (!tempContext) { TRACELOG(LOG_ERROR, "%s failed, error=%lu", "wglCreateContext", GetLastError()); return -1; } //if (!tempContext) { TRACELOG(LOG_ERROR, "%s failed, error=%lu", "wglCreateContext", GetLastError()); return -1; }
BOOL result = wglMakeCurrent(dummyHDC, tempContext); BOOL result = wglMakeCurrent(dummyHDC, tempContext);
//if (!result) { TRACELOG(LOG_ERROR, "%s failed, error=%lu", "wglMakeCurrent", GetLastError()); return -1; } if (!result)
{
TRACELOG(LOG_ERROR, "GL: Context failed to be set as current, error code: %lu", GetLastError());
return NULL;
}
// Load WGL extension entry points // Load WGL extension entry points
wglCreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC)wglGetProcAddress("wglCreateContextAttribsARB"); wglCreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC)wglGetProcAddress("wglCreateContextAttribsARB");
@ -1954,24 +2144,6 @@ int InitPlatform(void)
result = (int)RegisterClassExW(&windowClass); result = (int)RegisterClassExW(&windowClass);
if (result == 0) TRACELOG(LOG_ERROR, "WIN32: Failed to register window class [ERROR: %lu]", GetLastError()); if (result == 0) TRACELOG(LOG_ERROR, "WIN32: Failed to register window class [ERROR: %lu]", GetLastError());
// Get primary monitor info
POINT primaryTopLeft = { 0 };
HMONITOR monitor = MonitorFromPoint(primaryTopLeft, MONITOR_DEFAULTTOPRIMARY);
if (monitor != NULL)
{
MONITORINFO info = { 0 };
info.cbSize = sizeof(info);
result = (int)GetMonitorInfoW(monitor, &info);
if (result == 0) TRACELOG(LOG_WARNING, "WIN32: DISPLAY: Failed to get monitor info [ERROR: %u]", GetLastError());
else
{
CORE.Window.display.width = info.rcMonitor.right - info.rcMonitor.left;
CORE.Window.display.height = info.rcMonitor.bottom - info.rcMonitor.top;
}
}
else TRACELOG(LOG_WARNING, "WIN32: DISPLAY: Failed to get primary monitor from point [ERROR: %u]", GetLastError());
// Create window // Create window
// NOTE: Title string needs to be converted to WCHAR // NOTE: Title string needs to be converted to WCHAR
WCHAR *titleWide = NULL; WCHAR *titleWide = NULL;
@ -2024,26 +2196,39 @@ int InitPlatform(void)
int windowWidth = rect.right - rect.left; int windowWidth = rect.right - rect.left;
int windowHeight = rect.bottom - rect.top; int windowHeight = rect.bottom - rect.top;
HMONITOR currentMonitor = MonitorFromWindow(platform.hwnd, MONITOR_DEFAULTTONEAREST); // Set initial monitor array capacity. This array only grows with RL_REALLOC
MONITORINFO monitorInfo = { 0 }; platform.monitorCapacity = 1;
monitorInfo.cbSize = sizeof(monitorInfo); platform.monitors = (Win32Monitor *)RL_CALLOC(platform.monitorCapacity, sizeof(Win32Monitor));
if (GetMonitorInfoW(currentMonitor, &monitorInfo)) platform.monitorCount = 0;
EnumDisplayMonitors(NULL, NULL, RefreshMonitorsProc, 0);
platform.currentMonitor = GetMonitorIndexFromHWND(platform.hwnd);
if (platform.monitorCount > 0)
{ {
// rcWork is the monitor area, not including the taskbar // This is only used for logging on desktop backends
RECT rcWork = monitorInfo.rcWork; CORE.Window.display.width = platform.monitors[platform.currentMonitor].width;
int monitorWidth = rcWork.right - rcWork.left; CORE.Window.display.height = platform.monitors[platform.currentMonitor].height;
int monitorHeight = rcWork.bottom - rcWork.top;
int x = rcWork.left + (monitorWidth - windowWidth)/2;
int y = rcWork.top + (monitorHeight - windowHeight)/2;
// Ensure the window doesn't go off-screen; otherwise, the user might not be able to move it HMONITOR currentMonitor = platform.monitors[platform.currentMonitor].handle;
if (x < rcWork.left) x = rcWork.left; MONITORINFO monitorInfo = { 0 };
if (y < rcWork.top) y = rcWork.top; monitorInfo.cbSize = sizeof(monitorInfo);
if (GetMonitorInfoW(currentMonitor, &monitorInfo))
{
// rcWork is the monitor area, not including the taskbar
RECT rcWork = monitorInfo.rcWork;
int monitorWidth = rcWork.right - rcWork.left;
int monitorHeight = rcWork.bottom - rcWork.top;
int x = rcWork.left + (monitorWidth - windowWidth)/2;
int y = rcWork.top + (monitorHeight - windowHeight)/2;
// Center the window and set it to the correct DPI-adjusted size // Ensure the window doesn't go off-screen; otherwise, the user might not be able to move it
SetWindowPos(platform.hwnd, NULL, x, y, windowWidth, windowHeight, SWP_NOZORDER | SWP_NOACTIVATE); if (x < rcWork.left) x = rcWork.left;
if (y < rcWork.top) y = rcWork.top;
// Center the window and set it to the correct DPI-adjusted size
SetWindowPos(platform.hwnd, NULL, x, y, windowWidth, windowHeight, SWP_NOZORDER | SWP_NOACTIVATE);
}
else TRACELOG(LOG_WARNING, "DISPLAY: Unable to retrieve information about monitor");
} }
else TRACELOG(LOG_WARNING, "DISPLAY: Unable to retrieve information about monitor");
if ((platform.desiredFlags & FLAG_WINDOW_HIDDEN) == 0) if ((platform.desiredFlags & FLAG_WINDOW_HIDDEN) == 0)
{ {
@ -2148,6 +2333,18 @@ void ClosePlatform(void)
shcore = NULL; shcore = NULL;
} }
if (platform.monitors != NULL)
{
for (int i = 0; i < platform.monitorCount; i++)
{
if (platform.monitors[i].name != NULL) RL_FREE(platform.monitors[i].name);
}
RL_FREE(platform.monitors);
}
platform = (PlatformData){ 0 };
#if SUPPORT_WINMM_HIGHRES_TIMER && !SUPPORT_BUSY_WAIT_LOOP #if SUPPORT_WINMM_HIGHRES_TIMER && !SUPPORT_BUSY_WAIT_LOOP
timeEndPeriod(1); // Restore time period timeEndPeriod(1); // Restore time period
#endif #endif
@ -2242,6 +2439,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpara
// in response to WM_WINDOWPOSCHANGED but looks like when a window is created, // in response to WM_WINDOWPOSCHANGED but looks like when a window is created,
// this message can be obtained without getting WM_WINDOWPOSCHANGED // this message can be obtained without getting WM_WINDOWPOSCHANGED
HandleWindowResize(hwnd, &platform.appScreenWidth, &platform.appScreenHeight); HandleWindowResize(hwnd, &platform.appScreenWidth, &platform.appScreenHeight);
platform.currentMonitor = GetMonitorIndexFromHWND(hwnd);
result = 0; // If an application processes WM_SIZE message, it should return zero result = 0; // If an application processes WM_SIZE message, it should return zero
} break; } break;
case WM_GETMINMAXINFO: case WM_GETMINMAXINFO:
@ -2344,13 +2542,19 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpara
default: break; default: break;
} }
} break; } break;
//case WM_MOVE: break; case WM_MOVE:
{
CORE.Window.position.x = (int)(short)LOWORD(lparam);
CORE.Window.position.y = (int)(short)HIWORD(lparam);
platform.currentMonitor = GetMonitorIndexFromHWND(hwnd);
result = DefWindowProcW(hwnd, msg, wparam, lparam);
} break;
case WM_WINDOWPOSCHANGED: case WM_WINDOWPOSCHANGED:
{ {
WINDOWPOS *pos = (WINDOWPOS*)lparam; WINDOWPOS *pos = (WINDOWPOS*)lparam;
if (!(pos->flags & SWP_NOSIZE)) HandleWindowResize(hwnd, &platform.appScreenWidth, &platform.appScreenHeight); if (!(pos->flags & SWP_NOSIZE)) HandleWindowResize(hwnd, &platform.appScreenWidth, &platform.appScreenHeight);
DefWindowProc(hwnd, msg, wparam, lparam); DefWindowProcW(hwnd, msg, wparam, lparam);
} break; } break;
case WM_GETDPISCALEDSIZE: case WM_GETDPISCALEDSIZE:
{ {
@ -2419,6 +2623,26 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpara
HandleWindowResize(hwnd, &platform.appScreenWidth, &platform.appScreenHeight); HandleWindowResize(hwnd, &platform.appScreenWidth, &platform.appScreenHeight);
} break; } break;
case WM_DISPLAYCHANGE:
{
for (int i = 0; i < platform.monitorCount; i++)
{
if (platform.monitors[i].name != NULL) RL_FREE(platform.monitors[i].name);
platform.monitors[i].name = NULL;
}
platform.monitorCount = 0;
EnumDisplayMonitors(NULL, NULL, RefreshMonitorsProc, 0);
platform.currentMonitor = GetMonitorIndexFromHWND(platform.hwnd);
POINT position = { 0, 0 };
if (ClientToScreen(hwnd, &position))
{
CORE.Window.position.x = (int)position.x;
CORE.Window.position.y = (int)position.y;
}
result = DefWindowProcW(hwnd, msg, wparam, lparam);
} break;
case WM_SETCURSOR: case WM_SETCURSOR:
{ {
// Called when mouse moves, enters/leaves window... // Called when mouse moves, enters/leaves window...
@ -2428,7 +2652,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpara
return 0; return 0;
} }
result = DefWindowProc(hwnd, msg, wparam, lparam); result = DefWindowProcW(hwnd, msg, wparam, lparam);
} break; } break;
case WM_PAINT: case WM_PAINT:
{ {
@ -2454,7 +2678,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpara
{ {
CORE.Input.Mouse.currentPosition.x = (float)GET_X_LPARAM(lparam); CORE.Input.Mouse.currentPosition.x = (float)GET_X_LPARAM(lparam);
CORE.Input.Mouse.currentPosition.y = (float)GET_Y_LPARAM(lparam); CORE.Input.Mouse.currentPosition.y = (float)GET_Y_LPARAM(lparam);
CORE.Input.Touch.position[0] = CORE.Input.Mouse.currentPosition; CORE.Input.Touch.currentPosition[0] = CORE.Input.Mouse.currentPosition;
} }
} break; } break;
case WM_SYSKEYDOWN: case WM_SYSKEYDOWN:

View File

@ -21,7 +21,6 @@
* *
* DEPENDENCIES: * DEPENDENCIES:
* - DRM and GLM: System libraries for display initialization and configuration * - DRM and GLM: System libraries for display initialization and configuration
* - gestures: Gestures system for touch-ready devices (or simulated from mouse inputs)
* *
* *
* LICENSE: zlib/libpng * LICENSE: zlib/libpng
@ -555,12 +554,22 @@ const char *GetClipboardText(void)
return NULL; return NULL;
} }
// Set clipboard image content
bool SetClipboardImage(Image image)
{
bool result = false;
TRACELOG(LOG_WARNING, "SetClipboardImage() not implemented on target platform");
return result;
}
// Get clipboard image // Get clipboard image
Image GetClipboardImage(void) Image GetClipboardImage(void)
{ {
Image image = { 0 }; Image image = { 0 };
TRACELOG(LOG_WARNING, "GetClipboardImage() not implemented on target platform"); TRACELOG(LOG_WARNING, "Clipboard image retrieving not implemented");
return image; return image;
} }
@ -1078,12 +1087,6 @@ const char *GetKeyName(int key)
// Register all input events // Register all input events
void PollInputEvents(void) void PollInputEvents(void)
{ {
#if SUPPORT_GESTURES_SYSTEM
// NOTE: Gestures update must be called every frame to reset gestures correctly
// because ProcessGestureEvent() is called on an event, not every frame
UpdateGestures();
#endif
// Reset keys/chars pressed registered // Reset keys/chars pressed registered
CORE.Input.Keyboard.keyPressedQueueCount = 0; CORE.Input.Keyboard.keyPressedQueueCount = 0;
CORE.Input.Keyboard.charPressedQueueCount = 0; CORE.Input.Keyboard.charPressedQueueCount = 0;
@ -1135,7 +1138,7 @@ void PollInputEvents(void)
// Map touch position to mouse position for convenience // Map touch position to mouse position for convenience
// NOTE: For DRM touchscreen devices, this mapping is disabled to avoid false touch detection // NOTE: For DRM touchscreen devices, this mapping is disabled to avoid false touch detection
// CORE.Input.Touch.position[0] = CORE.Input.Mouse.currentPosition; // CORE.Input.Touch.currentPosition[0] = CORE.Input.Mouse.currentPosition;
// Handle the mouse/touch/gestures events // Handle the mouse/touch/gestures events
PollMouseEvents(); PollMouseEvents();
@ -1946,8 +1949,8 @@ static void InitEvdevInput(void)
// Reset variables // Reset variables
for (int i = 0; i < MAX_TOUCH_POINTS; i++) for (int i = 0; i < MAX_TOUCH_POINTS; i++)
{ {
CORE.Input.Touch.position[i].x = -1; CORE.Input.Touch.currentPosition[i].x = -1;
CORE.Input.Touch.position[i].y = -1; CORE.Input.Touch.currentPosition[i].y = -1;
platform.touchActive[i] = false; platform.touchActive[i] = false;
platform.touchPosition[i].x = -1; platform.touchPosition[i].x = -1;
platform.touchPosition[i].y = -1; platform.touchPosition[i].y = -1;
@ -2327,8 +2330,8 @@ static void PollMouseEvents(void)
if (fd == -1) return; if (fd == -1) return;
struct input_event event = { 0 }; struct input_event event = { 0 };
int touchAction = -1; // 0-TOUCH_ACTION_UP, 1-TOUCH_ACTION_DOWN, 2-TOUCH_ACTION_MOVE int touchAction = -1; // Actions: 0-TOUCH_ACTION_UP, 1-TOUCH_ACTION_DOWN, 2-TOUCH_ACTION_MOVE
static bool isMultitouch = false; // Detect if device supports MT events static bool isMultitouch = false; // Detect if device supports MT events
// Try to read data from the mouse/touch/gesture and only continue if successful // Try to read data from the mouse/touch/gesture and only continue if successful
while (read(fd, &event, sizeof(event)) == (int)sizeof(event)) while (read(fd, &event, sizeof(event)) == (int)sizeof(event))
@ -2346,7 +2349,7 @@ static void PollMouseEvents(void)
else CORE.Input.Mouse.currentPosition.x += event.value; else CORE.Input.Mouse.currentPosition.x += event.value;
// NOTE: For DRM touchscreen, do not simulate touch from mouse movement // NOTE: For DRM touchscreen, do not simulate touch from mouse movement
// CORE.Input.Touch.position[0].x = CORE.Input.Mouse.currentPosition.x; // CORE.Input.Touch.currentPosition[0].x = CORE.Input.Mouse.currentPosition.x;
touchAction = 2; // TOUCH_ACTION_MOVE touchAction = 2; // TOUCH_ACTION_MOVE
} }
@ -2360,7 +2363,7 @@ static void PollMouseEvents(void)
else CORE.Input.Mouse.currentPosition.y += event.value; else CORE.Input.Mouse.currentPosition.y += event.value;
// NOTE: For DRM touchscreen, do not simulate touch from mouse movement // NOTE: For DRM touchscreen, do not simulate touch from mouse movement
// CORE.Input.Touch.position[0].y = CORE.Input.Mouse.currentPosition.y; // CORE.Input.Touch.currentPosition[0].y = CORE.Input.Mouse.currentPosition.y;
touchAction = 2; // TOUCH_ACTION_MOVE touchAction = 2; // TOUCH_ACTION_MOVE
} }
@ -2565,7 +2568,7 @@ static void PollMouseEvents(void)
{ {
if (platform.touchActive[i]) if (platform.touchActive[i])
{ {
CORE.Input.Touch.position[k] = platform.touchPosition[i]; CORE.Input.Touch.currentPosition[k] = platform.touchPosition[i];
CORE.Input.Touch.pointId[k] = platform.touchId[i]; CORE.Input.Touch.pointId[k] = platform.touchId[i];
k++; k++;
} }
@ -2576,8 +2579,8 @@ static void PollMouseEvents(void)
// Clear remaining slots // Clear remaining slots
for (int i = k; i < MAX_TOUCH_POINTS; i++) for (int i = k; i < MAX_TOUCH_POINTS; i++)
{ {
CORE.Input.Touch.position[i].x = -1; CORE.Input.Touch.currentPosition[i].x = -1;
CORE.Input.Touch.position[i].y = -1; CORE.Input.Touch.currentPosition[i].y = -1;
CORE.Input.Touch.pointId[i] = -1; CORE.Input.Touch.pointId[i] = -1;
} }
@ -2591,7 +2594,7 @@ static void PollMouseEvents(void)
for (int i = 0; i < MAX_TOUCH_POINTS; i++) for (int i = 0; i < MAX_TOUCH_POINTS; i++)
{ {
gestureEvent.pointId[i] = i; gestureEvent.pointId[i] = i;
gestureEvent.position[i] = CORE.Input.Touch.position[i]; gestureEvent.position[i] = CORE.Input.Touch.currentPosition[i];
} }
ProcessGestureEvent(gestureEvent); ProcessGestureEvent(gestureEvent);

View File

@ -19,7 +19,6 @@
* *
* DEPENDENCIES: * DEPENDENCIES:
* - rlsw: Software renderer * - rlsw: Software renderer
* - gestures: Gestures system for touch-ready devices (or simulated from mouse inputs)
* *
* *
* LICENSE: zlib/libpng * LICENSE: zlib/libpng
@ -308,12 +307,22 @@ const char *GetClipboardText(void)
return NULL; return NULL;
} }
// Set clipboard image content
bool SetClipboardImage(Image image)
{
bool result = false;
TRACELOG(LOG_WARNING, "SetClipboardImage() not implemented on target platform");
return result;
}
// Get clipboard image // Get clipboard image
Image GetClipboardImage(void) Image GetClipboardImage(void)
{ {
Image image = { 0 }; Image image = { 0 };
TRACELOG(LOG_WARNING, "GetClipboardImage() not implemented on target platform"); TRACELOG(LOG_WARNING, "Clipboard image retrieving not implemented");
return image; return image;
} }
@ -438,12 +447,6 @@ const char *GetKeyName(int key)
// Register all input events // Register all input events
void PollInputEvents(void) void PollInputEvents(void)
{ {
#if SUPPORT_GESTURES_SYSTEM
// NOTE: Gestures update must be called every frame to reset gestures correctly
// because ProcessGestureEvent() is called on an event, not every frame
UpdateGestures();
#endif
// Reset keys/chars pressed registered // Reset keys/chars pressed registered
CORE.Input.Keyboard.keyPressedQueueCount = 0; CORE.Input.Keyboard.keyPressedQueueCount = 0;
CORE.Input.Keyboard.charPressedQueueCount = 0; CORE.Input.Keyboard.charPressedQueueCount = 0;
@ -461,7 +464,7 @@ void PollInputEvents(void)
// Reset touch positions // Reset touch positions
// TODO: It resets on target platform the mouse position and not filled again until a move-event, // TODO: It resets on target platform the mouse position and not filled again until a move-event,
// so, if mouse is not moved it returns a (0, 0) position... this behaviour should be reviewed! // so, if mouse is not moved it returns a (0, 0) position... this behaviour should be reviewed!
//for (int i = 0; i < MAX_TOUCH_POINTS; i++) CORE.Input.Touch.position[i] = (Vector2){ 0, 0 }; //for (int i = 0; i < MAX_TOUCH_POINTS; i++) CORE.Input.Touch.currentPosition[i] = (Vector2){ 0, 0 };
// Register previous keys states // Register previous keys states
// NOTE: Android supports up to 260 keys // NOTE: Android supports up to 260 keys

View File

@ -22,7 +22,6 @@
* *
* DEPENDENCIES: * DEPENDENCIES:
* - <platform-specific SDK dependency> * - <platform-specific SDK dependency>
* - gestures: Gestures system for touch-ready devices (or simulated from mouse inputs)
* *
* *
* LICENSE: zlib/libpng * LICENSE: zlib/libpng
@ -287,12 +286,22 @@ const char *GetClipboardText(void)
return NULL; return NULL;
} }
// Set clipboard image content
bool SetClipboardImage(Image image)
{
bool result = false;
TRACELOG(LOG_WARNING, "SetClipboardImage() not implemented on target platform");
return result;
}
// Get clipboard image // Get clipboard image
Image GetClipboardImage(void) Image GetClipboardImage(void)
{ {
Image image = { 0 }; Image image = { 0 };
TRACELOG(LOG_WARNING, "GetClipboardImage() not implemented on target platform"); TRACELOG(LOG_WARNING, "Clipboard image retrieving not implemented");
return image; return image;
} }
@ -413,12 +422,6 @@ const char *GetKeyName(int key)
// Register all input events // Register all input events
void PollInputEvents(void) void PollInputEvents(void)
{ {
#if SUPPORT_GESTURES_SYSTEM
// NOTE: Gestures update must be called every frame to reset gestures correctly
// because ProcessGestureEvent() is called on an event, not every frame
UpdateGestures();
#endif
// Reset keys/chars pressed registered // Reset keys/chars pressed registered
CORE.Input.Keyboard.keyPressedQueueCount = 0; CORE.Input.Keyboard.keyPressedQueueCount = 0;
CORE.Input.Keyboard.charPressedQueueCount = 0; CORE.Input.Keyboard.charPressedQueueCount = 0;
@ -436,7 +439,7 @@ void PollInputEvents(void)
// Reset touch positions // Reset touch positions
// TODO: It resets on target platform the mouse position and not filled again until a move-event, // TODO: It resets on target platform the mouse position and not filled again until a move-event,
// so, if mouse is not moved it returns a (0, 0) position... this behaviour should be reviewed! // so, if mouse is not moved it returns a (0, 0) position... this behaviour should be reviewed!
//for (int i = 0; i < MAX_TOUCH_POINTS; i++) CORE.Input.Touch.position[i] = (Vector2){ 0, 0 }; //for (int i = 0; i < MAX_TOUCH_POINTS; i++) CORE.Input.Touch.currentPosition[i] = (Vector2){ 0, 0 };
// Register previous keys states // Register previous keys states
// NOTE: Android supports up to 260 keys // NOTE: Android supports up to 260 keys

View File

@ -17,8 +17,8 @@
* Custom flag for rcore on target platform -not used- * Custom flag for rcore on target platform -not used-
* *
* DEPENDENCIES: * DEPENDENCIES:
* - emscripten: Allow interaction between browser API and C * - Emscripten SDK: Allow interaction between browser API and C
* - gestures: Gestures system for touch-ready devices (or simulated from mouse inputs) * - libglfw.js: GLFW implementation over Emscripten SDK
* *
* *
* LICENSE: zlib/libpng * LICENSE: zlib/libpng
@ -883,17 +883,34 @@ EM_JS(unsigned char *, GetLastPastedImage, (int *width, int *height), {
const char *GetClipboardText(void) const char *GetClipboardText(void)
{ {
RequestClipboardData(); RequestClipboardData();
return GetLastPastedText(); return GetLastPastedText();
} }
// Set clipboard image content
bool SetClipboardImage(Image image)
{
bool result = false;
TRACELOG(LOG_WARNING, "SetClipboardImage() not implemented on target platform");
return result;
}
// Get clipboard image // Get clipboard image
Image GetClipboardImage(void) Image GetClipboardImage(void)
{ {
Image image = { 0 }; Image image = { 0 };
int width = 0;
int height = 0; #if !SUPPORT_MODULE_RTEXTURES
TRACELOG(LOG_WARNING, "Clipboard image requires SUPPORT_MODULE_RTEXTURES to work");
return image;
#endif
RequestClipboardData(); RequestClipboardData();
int width = 0;
int height = 0;
unsigned char *data = GetLastPastedImage(&width, &height); unsigned char *data = GetLastPastedImage(&width, &height);
if (data != NULL) if (data != NULL)
@ -1082,12 +1099,6 @@ const char *GetKeyName(int key)
// Register all input events // Register all input events
void PollInputEvents(void) void PollInputEvents(void)
{ {
#if SUPPORT_GESTURES_SYSTEM
// NOTE: Gestures update must be called every frame to reset gestures correctly
// because ProcessGestureEvent() is called on an event, not every frame
UpdateGestures();
#endif
// Reset keys/chars pressed registered // Reset keys/chars pressed registered
CORE.Input.Keyboard.keyPressedQueueCount = 0; CORE.Input.Keyboard.keyPressedQueueCount = 0;
CORE.Input.Keyboard.charPressedQueueCount = 0; CORE.Input.Keyboard.charPressedQueueCount = 0;
@ -1121,7 +1132,7 @@ void PollInputEvents(void)
// Reset touch positions // Reset touch positions
// TODO: It resets on target platform the mouse position and not filled again until a move-event, // TODO: It resets on target platform the mouse position and not filled again until a move-event,
// so, if mouse is not moved it returns a (0, 0) position... this behaviour should be reviewed! // so, if mouse is not moved it returns a (0, 0) position... this behaviour should be reviewed!
//for (int i = 0; i < MAX_TOUCH_POINTS; i++) CORE.Input.Touch.position[i] = (Vector2){ 0, 0 }; //for (int i = 0; i < MAX_TOUCH_POINTS; i++) CORE.Input.Touch.currentPosition[i] = (Vector2){ 0, 0 };
// Gamepad support using emscripten API // Gamepad support using emscripten API
// NOTE: GLFW3 joystick functionality not available in web // NOTE: GLFW3 joystick functionality not available in web
@ -1664,35 +1675,6 @@ static void MouseButtonCallback(GLFWwindow *window, int button, int action, int
// but future releases may add more actions (i.e. GLFW_REPEAT) // but future releases may add more actions (i.e. GLFW_REPEAT)
CORE.Input.Mouse.currentButtonState[button] = action; CORE.Input.Mouse.currentButtonState[button] = action;
CORE.Input.Touch.currentTouchState[button] = action; CORE.Input.Touch.currentTouchState[button] = action;
#if SUPPORT_GESTURES_SYSTEM && SUPPORT_MOUSE_GESTURES
// Process mouse events as touches to be able to use mouse-gestures
GestureEvent gestureEvent = { 0 };
// Register touch actions
if ((CORE.Input.Mouse.currentButtonState[button] == 1) && (CORE.Input.Mouse.previousButtonState[button] == 0)) gestureEvent.touchAction = TOUCH_ACTION_DOWN;
else if ((CORE.Input.Mouse.currentButtonState[button] == 0) && (CORE.Input.Mouse.previousButtonState[button] == 1)) gestureEvent.touchAction = TOUCH_ACTION_UP;
// NOTE: TOUCH_ACTION_MOVE event is registered in MouseMoveCallback()
// Assign a pointer ID
gestureEvent.pointId[0] = 0;
// Register touch points count
gestureEvent.pointCount = 1;
// Register touch points position, only one point registered
gestureEvent.position[0] = GetMousePosition();
// Normalize gestureEvent.position[0] for CORE.Window.screen.width and CORE.Window.screen.height
gestureEvent.position[0].x /= (float)GetScreenWidth();
gestureEvent.position[0].y /= (float)GetScreenHeight();
// Gesture data is sent to gestures-system for processing
// Prevent calling ProcessGestureEvent() when Emscripten is present and there's a touch gesture, so EmscriptenTouchCallback() can handle it itself
if (GetMouseX() != 0 || GetMouseY() != 0) ProcessGestureEvent(gestureEvent);
#endif
} }
// GLFW3: Called on mouse move // GLFW3: Called on mouse move
@ -1703,31 +1685,8 @@ static void MouseMoveCallback(GLFWwindow *window, double x, double y)
{ {
CORE.Input.Mouse.currentPosition.x = (float)x; CORE.Input.Mouse.currentPosition.x = (float)x;
CORE.Input.Mouse.currentPosition.y = (float)y; CORE.Input.Mouse.currentPosition.y = (float)y;
CORE.Input.Touch.position[0] = CORE.Input.Mouse.currentPosition; CORE.Input.Touch.currentPosition[0] = CORE.Input.Mouse.currentPosition;
} }
#if SUPPORT_GESTURES_SYSTEM && SUPPORT_MOUSE_GESTURES
// Process mouse events as touches to be able to use mouse-gestures
GestureEvent gestureEvent = { 0 };
gestureEvent.touchAction = TOUCH_ACTION_MOVE;
// Assign a pointer ID
gestureEvent.pointId[0] = 0;
// Register touch points count
gestureEvent.pointCount = 1;
// Register touch points position, only one point registered
gestureEvent.position[0] = CORE.Input.Touch.position[0];
// Normalize gestureEvent.position[0] for CORE.Window.screen.width and CORE.Window.screen.height
gestureEvent.position[0].x /= (float)GetScreenWidth();
gestureEvent.position[0].y /= (float)GetScreenHeight();
// Gesture data is sent to gestures-system for processing
ProcessGestureEvent(gestureEvent);
#endif
} }
// GLFW3: Called on mouse wheel scrolling // GLFW3: Called on mouse wheel scrolling
@ -1832,11 +1791,11 @@ static EM_BOOL EmscriptenTouchCallback(int eventType, const EmscriptenTouchEvent
CORE.Input.Touch.pointId[i] = touchEvent->touches[i].identifier; CORE.Input.Touch.pointId[i] = touchEvent->touches[i].identifier;
// Register touch points position // Register touch points position
CORE.Input.Touch.position[i] = (Vector2){touchEvent->touches[i].targetX, touchEvent->touches[i].targetY}; CORE.Input.Touch.currentPosition[i] = (Vector2){touchEvent->touches[i].targetX, touchEvent->touches[i].targetY};
// Normalize gestureEvent.position[x] for CORE.Window.screen.width and CORE.Window.screen.height // Normalize gestureEvent.position[x] for CORE.Window.screen.width and CORE.Window.screen.height
CORE.Input.Touch.position[i].x *= ((float)GetScreenWidth()/(float)canvasWidth); CORE.Input.Touch.currentPosition[i].x *= ((float)GetScreenWidth()/(float)canvasWidth);
CORE.Input.Touch.position[i].y *= ((float)GetScreenHeight()/(float)canvasHeight); CORE.Input.Touch.currentPosition[i].y *= ((float)GetScreenHeight()/(float)canvasHeight);
if (eventType == EMSCRIPTEN_EVENT_TOUCHSTART) CORE.Input.Touch.currentTouchState[i] = 1; if (eventType == EMSCRIPTEN_EVENT_TOUCHSTART) CORE.Input.Touch.currentTouchState[i] = 1;
else if (eventType == EMSCRIPTEN_EVENT_TOUCHEND) CORE.Input.Touch.currentTouchState[i] = 0; else if (eventType == EMSCRIPTEN_EVENT_TOUCHEND) CORE.Input.Touch.currentTouchState[i] = 0;
@ -1845,34 +1804,10 @@ static EM_BOOL EmscriptenTouchCallback(int eventType, const EmscriptenTouchEvent
// Update mouse position when single touch detected // Update mouse position when single touch detected
if (CORE.Input.Touch.pointCount == 1) if (CORE.Input.Touch.pointCount == 1)
{ {
CORE.Input.Mouse.currentPosition.x = CORE.Input.Touch.position[0].x; CORE.Input.Mouse.currentPosition.x = CORE.Input.Touch.currentPosition[0].x;
CORE.Input.Mouse.currentPosition.y = CORE.Input.Touch.position[0].y; CORE.Input.Mouse.currentPosition.y = CORE.Input.Touch.currentPosition[0].y;
} }
#if SUPPORT_GESTURES_SYSTEM
GestureEvent gestureEvent = { 0 };
gestureEvent.pointCount = CORE.Input.Touch.pointCount;
// Register touch actions
if (eventType == EMSCRIPTEN_EVENT_TOUCHSTART) gestureEvent.touchAction = TOUCH_ACTION_DOWN;
else if (eventType == EMSCRIPTEN_EVENT_TOUCHEND) gestureEvent.touchAction = TOUCH_ACTION_UP;
else if (eventType == EMSCRIPTEN_EVENT_TOUCHMOVE) gestureEvent.touchAction = TOUCH_ACTION_MOVE;
else if (eventType == EMSCRIPTEN_EVENT_TOUCHCANCEL) gestureEvent.touchAction = TOUCH_ACTION_CANCEL;
for (int i = 0; (i < gestureEvent.pointCount) && (i < MAX_TOUCH_POINTS); i++)
{
gestureEvent.pointId[i] = CORE.Input.Touch.pointId[i];
gestureEvent.position[i] = CORE.Input.Touch.position[i];
// Normalize gestureEvent.position[i]
gestureEvent.position[i].x /= (float)GetScreenWidth();
gestureEvent.position[i].y /= (float)GetScreenHeight();
}
// Gesture data is sent to gestures system for processing
ProcessGestureEvent(gestureEvent);
#endif
if (eventType == EMSCRIPTEN_EVENT_TOUCHEND) if (eventType == EMSCRIPTEN_EVENT_TOUCHEND)
{ {
// Identify the EMSCRIPTEN_EVENT_TOUCHEND and remove it from the list // Identify the EMSCRIPTEN_EVENT_TOUCHEND and remove it from the list
@ -1884,7 +1819,7 @@ static EM_BOOL EmscriptenTouchCallback(int eventType, const EmscriptenTouchEvent
for (int j = i; j < CORE.Input.Touch.pointCount - 1; j++) for (int j = i; j < CORE.Input.Touch.pointCount - 1; j++)
{ {
CORE.Input.Touch.pointId[j] = CORE.Input.Touch.pointId[j + 1]; CORE.Input.Touch.pointId[j] = CORE.Input.Touch.pointId[j + 1];
CORE.Input.Touch.position[j] = CORE.Input.Touch.position[j + 1]; CORE.Input.Touch.currentPosition[j] = CORE.Input.Touch.currentPosition[j + 1];
} }
// Decrease touch points count to remove the last one // Decrease touch points count to remove the last one
CORE.Input.Touch.pointCount--; CORE.Input.Touch.pointCount--;

View File

@ -16,8 +16,7 @@
* Custom flag for rcore on target platform -not used- * Custom flag for rcore on target platform -not used-
* *
* DEPENDENCIES: * DEPENDENCIES:
* - emscripten: Allow interaction between browser API and C * - Emscripten SDK: Allow interaction between browser API and C
* - gestures: Gestures system for touch-ready devices (or simulated from mouse inputs)
* *
* *
* LICENSE: zlib/libpng * LICENSE: zlib/libpng
@ -864,12 +863,15 @@ EM_ASYNC_JS(void, RequestClipboardData, (void), {
EM_JS(char *, GetLastPastedText, (void), { EM_JS(char *, GetLastPastedText, (void), {
var str = window._lastClipboardString || ""; var str = window._lastClipboardString || "";
var length = lengthBytesUTF8(str) + 1; var length = lengthBytesUTF8(str) + 1;
if (length > 1) if (length > 1)
{ {
var ptr = _malloc(length); var ptr = _malloc(length);
stringToUTF8(str, ptr, length); stringToUTF8(str, ptr, length);
return ptr; return ptr;
} }
return 0; return 0;
}); });
@ -885,7 +887,7 @@ EM_JS(unsigned char *, GetLastPastedImage, (int *width, int *height), {
// Set the width and height via the pointers passed from C // Set the width and height via the pointers passed from C
// HEAP32 handles the 4-byte integers // HEAP32 handles the 4-byte integers
if (width) setValue(width, window._lastImgWidth, 'i32'); if (width) setValue(width, window._lastImgWidth, 'i32');
if (height) setValue(height, window._lastImgHeight, 'i32'); if (height) setValue(height, window._lastImgHeight, 'i32');
// Clear the JS buffer so there is no need to fetch the same image twice // Clear the JS buffer so there is no need to fetch the same image twice
@ -907,14 +909,30 @@ const char *GetClipboardText(void)
return GetLastPastedText(); return GetLastPastedText();
} }
// Set clipboard image content
bool SetClipboardImage(Image image)
{
bool result = false;
TRACELOG(LOG_WARNING, "SetClipboardImage() not implemented on target platform");
return result;
}
// Get clipboard image // Get clipboard image
Image GetClipboardImage(void) Image GetClipboardImage(void)
{ {
Image image = { 0 }; Image image = { 0 };
#if !SUPPORT_MODULE_RTEXTURES
TRACELOG(LOG_WARNING, "Clipboard image requires SUPPORT_MODULE_RTEXTURES to work");
return image;
#endif
RequestClipboardData();
int width = 0; int width = 0;
int height = 0; int height = 0;
RequestClipboardData();
unsigned char *data = GetLastPastedImage(&width, &height); unsigned char *data = GetLastPastedImage(&width, &height);
if (data != NULL) if (data != NULL)
@ -1101,12 +1119,6 @@ const char *GetKeyName(int key)
// Register all input events // Register all input events
void PollInputEvents(void) void PollInputEvents(void)
{ {
#if SUPPORT_GESTURES_SYSTEM
// NOTE: Gestures update must be called every frame to reset gestures correctly
// because ProcessGestureEvent() is called on an event, not every frame
UpdateGestures();
#endif
// Reset keys/chars pressed registered // Reset keys/chars pressed registered
CORE.Input.Keyboard.keyPressedQueueCount = 0; CORE.Input.Keyboard.keyPressedQueueCount = 0;
CORE.Input.Keyboard.charPressedQueueCount = 0; CORE.Input.Keyboard.charPressedQueueCount = 0;
@ -1140,7 +1152,7 @@ void PollInputEvents(void)
// Reset touch positions // Reset touch positions
// TODO: It resets on target platform the mouse position and not filled again until a move-event, // TODO: It resets on target platform the mouse position and not filled again until a move-event,
// so, if mouse is not moved it returns a (0, 0) position... this behaviour should be reviewed! // so, if mouse is not moved it returns a (0, 0) position... this behaviour should be reviewed!
//for (int i = 0; i < MAX_TOUCH_POINTS; i++) CORE.Input.Touch.position[i] = (Vector2){ 0, 0 }; //for (int i = 0; i < MAX_TOUCH_POINTS; i++) CORE.Input.Touch.currentPosition[i] = (Vector2){ 0, 0 };
// Get number of gamepads connected // Get number of gamepads connected
int numGamepads = 0; int numGamepads = 0;
@ -1617,34 +1629,6 @@ static EM_BOOL EmscriptenMouseCallback(int eventType, const EmscriptenMouseEvent
default: break; default: break;
} }
#if SUPPORT_GESTURES_SYSTEM && SUPPORT_MOUSE_GESTURES
// Process mouse events as touches to be able to use mouse-gestures
GestureEvent gestureEvent = { 0 };
// Register touch actions
if ((CORE.Input.Mouse.currentButtonState[MOUSE_BUTTON_LEFT] == 1) && (CORE.Input.Mouse.previousButtonState[MOUSE_BUTTON_LEFT] == 0)) gestureEvent.touchAction = TOUCH_ACTION_DOWN;
else if ((CORE.Input.Mouse.currentButtonState[MOUSE_BUTTON_LEFT] == 0) && (CORE.Input.Mouse.previousButtonState[MOUSE_BUTTON_LEFT] == 1)) gestureEvent.touchAction = TOUCH_ACTION_UP;
// NOTE: TOUCH_ACTION_MOVE event is registered in MouseMoveCallback()
// Assign a pointer ID
gestureEvent.pointId[0] = 0;
// Register touch points count
gestureEvent.pointCount = 1;
// Register touch points position, only one point registered
gestureEvent.position[0] = GetMousePosition();
// Normalize gestureEvent.position[0] for CORE.Window.screen.width and CORE.Window.screen.height
gestureEvent.position[0].x /= (float)GetScreenWidth();
gestureEvent.position[0].y /= (float)GetScreenHeight();
// Gesture data is sent to gestures-system for processing
// Prevent calling ProcessGestureEvent() when Emscripten is present and there's a touch gesture, so EmscriptenTouchCallback() can handle it itself
if (GetMouseX() != 0 || GetMouseY() != 0) ProcessGestureEvent(gestureEvent);
#endif
// Don't prevent default to allow focusing on canvas // Don't prevent default to allow focusing on canvas
return 0; return 0;
} }
@ -1673,32 +1657,9 @@ static EM_BOOL EmscriptenMouseMoveCallback(int eventType, const EmscriptenMouseE
CORE.Input.Mouse.currentPosition.x = normalizedX*(float)CORE.Window.screen.width; CORE.Input.Mouse.currentPosition.x = normalizedX*(float)CORE.Window.screen.width;
CORE.Input.Mouse.currentPosition.y = normalizedY*(float)CORE.Window.screen.height; CORE.Input.Mouse.currentPosition.y = normalizedY*(float)CORE.Window.screen.height;
CORE.Input.Touch.position[0] = CORE.Input.Mouse.currentPosition; CORE.Input.Touch.currentPosition[0] = CORE.Input.Mouse.currentPosition;
} }
#if SUPPORT_GESTURES_SYSTEM && SUPPORT_MOUSE_GESTURES
// Process mouse events as touches to be able to use mouse-gestures
GestureEvent gestureEvent = { 0 };
gestureEvent.touchAction = TOUCH_ACTION_MOVE;
// Assign a pointer ID
gestureEvent.pointId[0] = 0;
// Register touch points count
gestureEvent.pointCount = 1;
// Register touch points position, only one point registered
gestureEvent.position[0] = CORE.Input.Touch.position[0];
// Normalize gestureEvent.position[0] for CORE.Window.screen.width and CORE.Window.screen.height
gestureEvent.position[0].x /= (float)GetScreenWidth();
gestureEvent.position[0].y /= (float)GetScreenHeight();
// Gesture data is sent to gestures-system for processing
ProcessGestureEvent(gestureEvent);
#endif
return 1; // The event was consumed by the callback handler return 1; // The event was consumed by the callback handler
} }
@ -1775,11 +1736,11 @@ static EM_BOOL EmscriptenTouchCallback(int eventType, const EmscriptenTouchEvent
CORE.Input.Touch.pointId[i] = touchEvent->touches[i].identifier; CORE.Input.Touch.pointId[i] = touchEvent->touches[i].identifier;
// Register touch points position // Register touch points position
CORE.Input.Touch.position[i] = (Vector2){touchEvent->touches[i].targetX, touchEvent->touches[i].targetY}; CORE.Input.Touch.currentPosition[i] = (Vector2){touchEvent->touches[i].targetX, touchEvent->touches[i].targetY};
// Normalize gestureEvent.position[x] for CORE.Window.screen.width and CORE.Window.screen.height // Normalize gestureEvent.position[x] for CORE.Window.screen.width and CORE.Window.screen.height
CORE.Input.Touch.position[i].x *= ((float)GetScreenWidth()/(float)canvasWidth); CORE.Input.Touch.currentPosition[i].x *= ((float)GetScreenWidth()/(float)canvasWidth);
CORE.Input.Touch.position[i].y *= ((float)GetScreenHeight()/(float)canvasHeight); CORE.Input.Touch.currentPosition[i].y *= ((float)GetScreenHeight()/(float)canvasHeight);
if (eventType == EMSCRIPTEN_EVENT_TOUCHSTART) CORE.Input.Touch.currentTouchState[i] = 1; if (eventType == EMSCRIPTEN_EVENT_TOUCHSTART) CORE.Input.Touch.currentTouchState[i] = 1;
else if (eventType == EMSCRIPTEN_EVENT_TOUCHEND) CORE.Input.Touch.currentTouchState[i] = 0; else if (eventType == EMSCRIPTEN_EVENT_TOUCHEND) CORE.Input.Touch.currentTouchState[i] = 0;
@ -1788,34 +1749,10 @@ static EM_BOOL EmscriptenTouchCallback(int eventType, const EmscriptenTouchEvent
// Update mouse position if a single touch is detected // Update mouse position if a single touch is detected
if (CORE.Input.Touch.pointCount == 1) if (CORE.Input.Touch.pointCount == 1)
{ {
CORE.Input.Mouse.currentPosition.x = CORE.Input.Touch.position[0].x; CORE.Input.Mouse.currentPosition.x = CORE.Input.Touch.currentPosition[0].x;
CORE.Input.Mouse.currentPosition.y = CORE.Input.Touch.position[0].y; CORE.Input.Mouse.currentPosition.y = CORE.Input.Touch.currentPosition[0].y;
} }
#if SUPPORT_GESTURES_SYSTEM
GestureEvent gestureEvent = { 0 };
gestureEvent.pointCount = CORE.Input.Touch.pointCount;
// Register touch actions
if (eventType == EMSCRIPTEN_EVENT_TOUCHSTART) gestureEvent.touchAction = TOUCH_ACTION_DOWN;
else if (eventType == EMSCRIPTEN_EVENT_TOUCHEND) gestureEvent.touchAction = TOUCH_ACTION_UP;
else if (eventType == EMSCRIPTEN_EVENT_TOUCHMOVE) gestureEvent.touchAction = TOUCH_ACTION_MOVE;
else if (eventType == EMSCRIPTEN_EVENT_TOUCHCANCEL) gestureEvent.touchAction = TOUCH_ACTION_CANCEL;
for (int i = 0; (i < gestureEvent.pointCount) && (i < MAX_TOUCH_POINTS); i++)
{
gestureEvent.pointId[i] = CORE.Input.Touch.pointId[i];
gestureEvent.position[i] = CORE.Input.Touch.position[i];
// Normalize gestureEvent.position[i]
gestureEvent.position[i].x /= (float)GetScreenWidth();
gestureEvent.position[i].y /= (float)GetScreenHeight();
}
// Gesture data is sent to gestures system for processing
ProcessGestureEvent(gestureEvent);
#endif
if (eventType == EMSCRIPTEN_EVENT_TOUCHEND) if (eventType == EMSCRIPTEN_EVENT_TOUCHEND)
{ {
// Identify the EMSCRIPTEN_EVENT_TOUCHEND and remove it from the list // Identify the EMSCRIPTEN_EVENT_TOUCHEND and remove it from the list
@ -1827,8 +1764,9 @@ static EM_BOOL EmscriptenTouchCallback(int eventType, const EmscriptenTouchEvent
for (int j = i; j < CORE.Input.Touch.pointCount - 1; j++) for (int j = i; j < CORE.Input.Touch.pointCount - 1; j++)
{ {
CORE.Input.Touch.pointId[j] = CORE.Input.Touch.pointId[j + 1]; CORE.Input.Touch.pointId[j] = CORE.Input.Touch.pointId[j + 1];
CORE.Input.Touch.position[j] = CORE.Input.Touch.position[j + 1]; CORE.Input.Touch.currentPosition[j] = CORE.Input.Touch.currentPosition[j + 1];
} }
// Decrease touch points count to remove the last one // Decrease touch points count to remove the last one
CORE.Input.Touch.pointCount--; CORE.Input.Touch.pointCount--;
break; break;

View File

@ -1031,6 +1031,7 @@ RLAPI Vector2 GetWindowScaleDPI(void); // Get window
RLAPI const char *GetMonitorName(int monitor); // Get the human-readable, UTF-8 encoded name of the specified monitor RLAPI const char *GetMonitorName(int monitor); // Get the human-readable, UTF-8 encoded name of the specified 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 bool SetClipboardImage(Image image); // Set clipboard image content
RLAPI Image GetClipboardImage(void); // Get clipboard image content RLAPI Image GetClipboardImage(void); // Get clipboard image content
RLAPI void EnableEventWaiting(void); // Enable waiting for events on EndDrawing(), no automatic event polling 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 RLAPI void DisableEventWaiting(void); // Disable waiting for events on EndDrawing(), automatic events polling

View File

@ -42,9 +42,6 @@
* #define SUPPORT_GESTURES_SYSTEM 1 * #define SUPPORT_GESTURES_SYSTEM 1
* Gestures module is included (rgestures.h) to support gestures detection: tap, hold, swipe, drag * Gestures module is included (rgestures.h) to support gestures detection: tap, hold, swipe, drag
* *
* #define SUPPORT_MOUSE_GESTURES 1
* Mouse gestures are directly mapped like touches and processed by gestures system
*
* #define SUPPORT_BUSY_WAIT_LOOP 1 * #define SUPPORT_BUSY_WAIT_LOOP 1
* Use busy wait loop for timing sync, if not defined, a high-resolution timer is setup and used * Use busy wait loop for timing sync, if not defined, a high-resolution timer is setup and used
* *
@ -322,11 +319,9 @@ typedef struct CoreData {
char **dropFilepaths; // Store dropped files paths pointers (provided by GLFW) char **dropFilepaths; // Store dropped files paths pointers (provided by GLFW)
unsigned int dropFileCount; // Count dropped files strings unsigned int dropFileCount; // Count dropped files strings
} Window; } Window;
struct { struct {
const char *basePath; // Base path for data storage const char *basePath; // Base path for data storage
} Storage; } Storage;
struct { struct {
struct { struct {
@ -343,7 +338,6 @@ typedef struct CoreData {
int charPressedQueue[MAX_CHAR_PRESSED_QUEUE]; // Input characters queue (unicode) int charPressedQueue[MAX_CHAR_PRESSED_QUEUE]; // Input characters queue (unicode)
int charPressedQueueCount; // Input characters queue count int charPressedQueueCount; // Input characters queue count
} Keyboard; } Keyboard;
struct { struct {
Vector2 offset; // Mouse offset Vector2 offset; // Mouse offset
@ -361,16 +355,14 @@ typedef struct CoreData {
char previousButtonState[MAX_MOUSE_BUTTONS]; // Registers previous mouse button state char previousButtonState[MAX_MOUSE_BUTTONS]; // Registers previous mouse button state
Vector2 currentWheelMove; // Registers current mouse wheel variation Vector2 currentWheelMove; // Registers current mouse wheel variation
Vector2 previousWheelMove; // Registers previous mouse wheel variation Vector2 previousWheelMove; // Registers previous mouse wheel variation
} Mouse; } Mouse;
struct { struct Touch {
int pointCount; // Number of touch points active int pointCount; // Number of touch points active
int pointId[MAX_TOUCH_POINTS]; // Point identifiers int pointId[MAX_TOUCH_POINTS]; // Point identifiers
Vector2 position[MAX_TOUCH_POINTS]; // Touch position on screen Vector2 currentPosition[MAX_TOUCH_POINTS]; // Touch position on screen
Vector2 previousPosition[MAX_TOUCH_POINTS]; // Previous touch position on screen Vector2 previousPosition[MAX_TOUCH_POINTS]; // Previous touch position on screen
char currentTouchState[MAX_TOUCH_POINTS]; // Registers current touch state char currentTouchState[MAX_TOUCH_POINTS]; // Registers current touch state: 0-UP, 1-DOWN, 2-MOVE, 3-CANCEL
char previousTouchState[MAX_TOUCH_POINTS]; // Registers previous touch state char previousTouchState[MAX_TOUCH_POINTS]; // Registers previous touch state: 0-UP, 1-DOWN, 2-MOVE, 3-CANCEL
} Touch; } Touch;
struct { struct {
int lastButtonPressed; // Register last gamepad button pressed int lastButtonPressed; // Register last gamepad button pressed
@ -380,9 +372,7 @@ typedef struct CoreData {
char currentButtonState[MAX_GAMEPADS][MAX_GAMEPAD_BUTTONS]; // Current gamepad buttons state char currentButtonState[MAX_GAMEPADS][MAX_GAMEPAD_BUTTONS]; // Current gamepad buttons state
char previousButtonState[MAX_GAMEPADS][MAX_GAMEPAD_BUTTONS]; // Previous gamepad buttons state char previousButtonState[MAX_GAMEPADS][MAX_GAMEPAD_BUTTONS]; // Previous gamepad buttons state
float axisState[MAX_GAMEPADS][MAX_GAMEPAD_AXES]; // Gamepad axes state float axisState[MAX_GAMEPADS][MAX_GAMEPAD_AXES]; // Gamepad axes state
} Gamepad; } Gamepad;
} Input; } Input;
struct { struct {
double current; // Current time measure (seconds) double current; // Current time measure (seconds)
@ -393,7 +383,6 @@ typedef struct CoreData {
double target; // Desired time for one frame, if 0 not applied (seconds) double target; // Desired time for one frame, if 0 not applied (seconds)
unsigned long long base; // Base time measure for hi-res timer (ticks or nanoseconds) unsigned long long base; // Base time measure for hi-res timer (ticks or nanoseconds)
unsigned int frameCounter; // Frame counter (frames) unsigned int frameCounter; // Frame counter (frames)
} Time; } Time;
} CoreData; } CoreData;
@ -524,7 +513,7 @@ const char *TextFormat(const char *text, ...); // Formatting of text with variab
#include "platforms/rcore_desktop_glfw.c" #include "platforms/rcore_desktop_glfw.c"
#elif defined(PLATFORM_DESKTOP_SDL) #elif defined(PLATFORM_DESKTOP_SDL)
#include "platforms/rcore_desktop_sdl.c" #include "platforms/rcore_desktop_sdl.c"
#elif (defined(PLATFORM_DESKTOP_RGFW) || defined(PLATFORM_WEB_RGFW)) #elif defined(PLATFORM_DESKTOP_RGFW) || defined(PLATFORM_WEB_RGFW)
#include "platforms/rcore_desktop_rgfw.c" #include "platforms/rcore_desktop_rgfw.c"
#elif defined(PLATFORM_DESKTOP_WIN32) #elif defined(PLATFORM_DESKTOP_WIN32)
#include "platforms/rcore_desktop_win32.c" #include "platforms/rcore_desktop_win32.c"
@ -579,8 +568,17 @@ const char *TextFormat(const char *text, ...); // Formatting of text with variab
//Vector2 GetMonitorPosition(int monitor) //Vector2 GetMonitorPosition(int monitor)
//const char *GetMonitorName(int monitor) //const char *GetMonitorName(int monitor)
// Clipboard interaction support
// NOTE: Only working on SDL3, GLFW (Windows) and RGFW (Windows)
// WARNING: It requires support for some additional flags:
// - SUPPORT_MODULE_RTEXTURES
// - SUPPORT_FILEFORMAT_BMP (Windows clipboard)
// - SUPPORT_FILEFORMAT_PNG (Wayland clipboard)
// - SUPPORT_FILEFORMAT_JPG
//void SetClipboardText(const char *text) //void SetClipboardText(const char *text)
//const char *GetClipboardText(void) //const char *GetClipboardText(void)
//bool SetClipboardImage(Image image)
//Image GetClipboardImage(void)
//void ShowCursor(void) //void ShowCursor(void)
//void HideCursor(void) //void HideCursor(void)
@ -860,8 +858,8 @@ bool IsCursorOnScreen(void)
// Clear background (framebuffer) to color // Clear background (framebuffer) to color
void ClearBackground(Color color) void ClearBackground(Color color)
{ {
rlClearColor(color.r, color.g, color.b, color.a); // Set clear color rlClearColor(color.r, color.g, color.b, color.a); // Set clear color
rlClearScreenBuffers(); // Clear current framebuffers rlClearScreenBuffers(); // Clear screen framebuffers (color and depth)
} }
// Begin canvas (framebuffer) drawing // Begin canvas (framebuffer) drawing
@ -909,11 +907,59 @@ void EndDrawing(void)
double waitTime = CORE.Time.current - CORE.Time.previous; double waitTime = CORE.Time.current - CORE.Time.previous;
CORE.Time.previous = CORE.Time.current; CORE.Time.previous = CORE.Time.current;
CORE.Time.frame += waitTime; // Total frame time: update + draw + wait CORE.Time.frame += waitTime; // Total frame time: update + draw + wait
}
#if SUPPORT_GESTURES_SYSTEM
// NOTE: Gestures update must be called every frame to reset gestures correctly
// because ProcessGestureEvent() is called on an event, not every frame
//UpdateGestures();
#endif
PollInputEvents(); // Poll user events (before next frame update)
#if SUPPORT_GESTURES_SYSTEM
// If a previous swipe gesture was detected, just reset it
if ((GESTURES.current == GESTURE_SWIPE_RIGHT) ||
(GESTURES.current == GESTURE_SWIPE_UP) ||
(GESTURES.current == GESTURE_SWIPE_LEFT) ||
(GESTURES.current == GESTURE_SWIPE_DOWN))
{
GESTURES.current = GESTURE_NONE;
}
else if (((GESTURES.current == GESTURE_TAP) || (GESTURES.current == GESTURE_DOUBLETAP)) &&
(GESTURES.current != GESTURE_DRAG) && (GESTURES.Touch.pointCount == 1))
{
double currentTime = rgGetCurrentTime();
if ((currentTime - GESTURES.Touch.eventTime) > MIN_HOLD_TIME)
{
GESTURES.current = GESTURE_HOLD;
GESTURES.Hold.timeDuration = (currentTime - GESTURES.Touch.eventTime);
}
} }
PollInputEvents(); // Poll user events (before next frame update) // Process gestures event: touch state changes
// NOTE: Touch move action (position change) is considered on move event (with threshold)
// WARNING: Only considering one touch point (id = 0), mouse on desktop platforms
if (CORE.Input.Touch.currentTouchState[0] != CORE.Input.Touch.previousTouchState[0])
{
// Register a new event with current touch data
GestureEvent gestureEvent = { 0 };
gestureEvent.pointCount = 1; // Register touch points count
gestureEvent.pointId[0] = 0; // Assign a pointer ID
gestureEvent.position[0] = CORE.Input.Touch.currentPosition[0];
gestureEvent.touchAction = CORE.Input.Touch.currentTouchState[0];
// Normalize gesture event position [0.0f..1.0f]
gestureEvent.position[0].x /= (float)GetScreenWidth();
gestureEvent.position[0].y /= (float)GetScreenHeight();
// Gesture data is sent to gestures-system for processing
ProcessGestureEvent(gestureEvent);
}
#endif #endif
#endif // !SUPPORT_CUSTOM_FRAME_CONTROL
#if SUPPORT_SCREEN_CAPTURE #if SUPPORT_SCREEN_CAPTURE
if (IsKeyPressed(KEY_F12)) if (IsKeyPressed(KEY_F12))
@ -1675,8 +1721,7 @@ void WaitTime(double seconds)
// System halt functions // System halt functions
#if defined(_WIN32) #if defined(_WIN32)
Sleep((unsigned long)(sleepSeconds*1000.0)); Sleep((unsigned long)(sleepSeconds*1000.0));
#endif #elif defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__EMSCRIPTEN__)
#if defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__EMSCRIPTEN__)
struct timespec req = { 0 }; struct timespec req = { 0 };
time_t sec = sleepSeconds; time_t sec = sleepSeconds;
long nsec = (sleepSeconds - sec)*1000000000L; long nsec = (sleepSeconds - sec)*1000000000L;
@ -1685,8 +1730,7 @@ void WaitTime(double seconds)
// NOTE: Use nanosleep() on Unix platforms... usleep() it's deprecated // NOTE: Use nanosleep() on Unix platforms... usleep() it's deprecated
while (nanosleep(&req, &req) == -1) continue; while (nanosleep(&req, &req) == -1) continue;
#endif #elif defined(__APPLE__)
#if defined(__APPLE__)
usleep(sleepSeconds*1000000.0); usleep(sleepSeconds*1000000.0);
#endif #endif
@ -2424,6 +2468,7 @@ bool IsFileExtension(const char *fileName, const char *ext)
bool IsFileHidden(const char *filePath) bool IsFileHidden(const char *filePath)
{ {
bool result = false; bool result = false;
#if defined(_WIN32) #if defined(_WIN32)
unsigned long attribs = GetFileAttributesA(filePath); unsigned long attribs = GetFileAttributesA(filePath);
@ -2435,6 +2480,7 @@ bool IsFileHidden(const char *filePath)
if ((basePath[0] == '.') && (strcmp(basePath, ".") != 0) && (strcmp(basePath, "..") != 0)) result = true; if ((basePath[0] == '.') && (strcmp(basePath, ".") != 0) && (strcmp(basePath, "..") != 0)) result = true;
#endif #endif
return result; return result;
} }
@ -2692,9 +2738,7 @@ const char *GetApplicationDirectory(void)
appDir[0] = '.'; appDir[0] = '.';
appDir[1] = '\\'; appDir[1] = '\\';
} }
#elif defined(__linux__) #elif defined(__linux__)
unsigned int size = sizeof(appDir); unsigned int size = sizeof(appDir);
ssize_t len = readlink("/proc/self/exe", appDir, size); ssize_t len = readlink("/proc/self/exe", appDir, size);
@ -2714,9 +2758,7 @@ const char *GetApplicationDirectory(void)
appDir[0] = '.'; appDir[0] = '.';
appDir[1] = '/'; appDir[1] = '/';
} }
#elif defined(__APPLE__) #elif defined(__APPLE__)
uint32_t size = sizeof(appDir); uint32_t size = sizeof(appDir);
if (_NSGetExecutablePath(appDir, &size) == 0) if (_NSGetExecutablePath(appDir, &size) == 0)
@ -2736,9 +2778,7 @@ const char *GetApplicationDirectory(void)
appDir[0] = '.'; appDir[0] = '.';
appDir[1] = '/'; appDir[1] = '/';
} }
#elif defined(__FreeBSD__) #elif defined(__FreeBSD__)
size_t size = sizeof(appDir); size_t size = sizeof(appDir);
int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1}; int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1};
@ -2759,9 +2799,7 @@ const char *GetApplicationDirectory(void)
appDir[0] = '.'; appDir[0] = '.';
appDir[1] = '/'; appDir[1] = '/';
} }
#elif defined(__wasm__) #elif defined(__wasm__)
appDir[0] = '/'; appDir[0] = '/';
#endif #endif
@ -3853,8 +3891,8 @@ void PlayAutomationEvent(AutomationEvent event)
case INPUT_TOUCH_DOWN: CORE.Input.Touch.currentTouchState[event.params[0]] = true; break; // param[0]: id case INPUT_TOUCH_DOWN: CORE.Input.Touch.currentTouchState[event.params[0]] = true; break; // param[0]: id
case INPUT_TOUCH_POSITION: // param[0]: id, param[1]: x, param[2]: y case INPUT_TOUCH_POSITION: // param[0]: id, param[1]: x, param[2]: y
{ {
CORE.Input.Touch.position[event.params[0]].x = (float)event.params[1]; CORE.Input.Touch.currentPosition[event.params[0]].x = (float)event.params[1];
CORE.Input.Touch.position[event.params[0]].y = (float)event.params[2]; CORE.Input.Touch.currentPosition[event.params[0]].y = (float)event.params[2];
} break; } break;
case INPUT_GAMEPAD_CONNECT: CORE.Input.Gamepad.ready[event.params[0]] = true; break; // param[0]: gamepad case INPUT_GAMEPAD_CONNECT: CORE.Input.Gamepad.ready[event.params[0]] = true; break; // param[0]: gamepad
case INPUT_GAMEPAD_DISCONNECT: CORE.Input.Gamepad.ready[event.params[0]] = false; break; // param[0]: gamepad case INPUT_GAMEPAD_DISCONNECT: CORE.Input.Gamepad.ready[event.params[0]] = false; break; // param[0]: gamepad
@ -4272,14 +4310,14 @@ Vector2 GetMouseWheelMoveV(void)
// Get touch position X for touch point 0 (relative to screen size) // Get touch position X for touch point 0 (relative to screen size)
int GetTouchX(void) int GetTouchX(void)
{ {
int touchX = (int)CORE.Input.Touch.position[0].x; int touchX = (int)CORE.Input.Touch.currentPosition[0].x;
return touchX; return touchX;
} }
// Get touch position Y for touch point 0 (relative to screen size) // Get touch position Y for touch point 0 (relative to screen size)
int GetTouchY(void) int GetTouchY(void)
{ {
int touchY = (int)CORE.Input.Touch.position[0].y; int touchY = (int)CORE.Input.Touch.currentPosition[0].y;
return touchY; return touchY;
} }
@ -4288,7 +4326,7 @@ Vector2 GetTouchPosition(int index)
{ {
Vector2 position = { -1.0f, -1.0f }; Vector2 position = { -1.0f, -1.0f };
if (index < MAX_TOUCH_POINTS) position = CORE.Input.Touch.position[index]; if (index < MAX_TOUCH_POINTS) position = CORE.Input.Touch.currentPosition[index];
else TRACELOG(LOG_WARNING, "INPUT: Required touch point out of range (Max touch points: %i)", MAX_TOUCH_POINTS); else TRACELOG(LOG_WARNING, "INPUT: Required touch point out of range (Max touch points: %i)", MAX_TOUCH_POINTS);
return position; return position;
@ -4565,14 +4603,14 @@ static void RecordAutomationEvent(void)
if (currentEventList->count == currentEventList->capacity) return; // Security check if (currentEventList->count == currentEventList->capacity) return; // Security check
// Event type: INPUT_TOUCH_POSITION // Event type: INPUT_TOUCH_POSITION
if (((int)CORE.Input.Touch.position[id].x != (int)CORE.Input.Touch.previousPosition[id].x) || if (((int)CORE.Input.Touch.currentPosition[id].x != (int)CORE.Input.Touch.previousPosition[id].x) ||
((int)CORE.Input.Touch.position[id].y != (int)CORE.Input.Touch.previousPosition[id].y)) ((int)CORE.Input.Touch.currentPosition[id].y != (int)CORE.Input.Touch.previousPosition[id].y))
{ {
currentEventList->events[currentEventList->count].frame = CORE.Time.frameCounter; currentEventList->events[currentEventList->count].frame = CORE.Time.frameCounter;
currentEventList->events[currentEventList->count].type = INPUT_TOUCH_POSITION; currentEventList->events[currentEventList->count].type = INPUT_TOUCH_POSITION;
currentEventList->events[currentEventList->count].params[0] = id; currentEventList->events[currentEventList->count].params[0] = id;
currentEventList->events[currentEventList->count].params[1] = (int)CORE.Input.Touch.position[id].x; currentEventList->events[currentEventList->count].params[1] = (int)CORE.Input.Touch.currentPosition[id].x;
currentEventList->events[currentEventList->count].params[2] = (int)CORE.Input.Touch.position[id].y; currentEventList->events[currentEventList->count].params[2] = (int)CORE.Input.Touch.currentPosition[id].y;
TRACELOG(LOG_INFO, "AUTOMATION: Frame: %i | Event type: INPUT_TOUCH_POSITION | Event parameters: %i, %i, %i", currentEventList->events[currentEventList->count].frame, currentEventList->events[currentEventList->count].params[0], currentEventList->events[currentEventList->count].params[1], currentEventList->events[currentEventList->count].params[2]); TRACELOG(LOG_INFO, "AUTOMATION: Frame: %i | Event type: INPUT_TOUCH_POSITION | Event parameters: %i, %i, %i", currentEventList->events[currentEventList->count].frame, currentEventList->events[currentEventList->count].params[0], currentEventList->events[currentEventList->count].params[1], currentEventList->events[currentEventList->count].params[2]);
currentEventList->count++; currentEventList->count++;

View File

@ -123,7 +123,7 @@ extern "C" { // Prevents name mangling of functions
#endif #endif
void ProcessGestureEvent(GestureEvent event); // Process gesture event and translate it into gestures void ProcessGestureEvent(GestureEvent event); // Process gesture event and translate it into gestures
void UpdateGestures(void); // Update gestures detected (must be called every frame) //void UpdateGestures(void); // Update gestures detected (must be called every frame)
#if defined(RGESTURES_STANDALONE) #if defined(RGESTURES_STANDALONE)
void SetGesturesEnabled(unsigned int flags); // Enable a set of gestures using flags void SetGesturesEnabled(unsigned int flags); // Enable a set of gestures using flags
@ -181,13 +181,14 @@ float GetGesturePinchAngle(void); // Get gesture pinch ang
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Defines and Macros // Defines and Macros
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
#define FORCE_TO_SWIPE 0.2f // Swipe force, measured in normalized screen units/time #define MIN_TAP_TIME 0.3f // Tap minimum time (DOWN-UP), measured in seconds
#define MINIMUM_DRAG 0.015f // Drag minimum force, measured in normalized screen units (0.0f to 1.0f) #define MIN_HOLD_TIME 0.6f // Hold minimum time, measured in seconds
#define DRAG_TIMEOUT 0.3f // Drag minimum time for web, measured in seconds #define MAX_DOUBLETAP_RANGE 0.03f // DoubleTap maximum range between first and second tap, measured in normalized screen units (0.0f to 1.0f)
#define MINIMUM_PINCH 0.005f // Pinch minimum force, measured in normalized screen units (0.0f to 1.0f) #define MIN_DRAG_TIME 0.3f // Drag minimum time, measured in seconds
#define TAP_TIMEOUT 0.3f // Tap minimum time, measured in seconds #define MIN_DRAG_DISTANCE 0.015f // Drag minimum distance, measured in normalized screen units (0.0f to 1.0f)
#define PINCH_TIMEOUT 0.3f // Pinch minimum time, measured in seconds #define MIN_SWIPE_FORCE 0.2f // Swipe force, measured in normalized screen units/time
#define DOUBLETAP_RANGE 0.03f // DoubleTap range, measured in normalized screen units (0.0f to 1.0f) #define MIN_PINCH_TIME 0.3f // Pinch minimum time, measured in seconds
#define MIN_PINCH_DISTANCE 0.005f // Pinch minimum distance, measured in normalized screen units (0.0f to 1.0f)
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Types and Structures Definition // Types and Structures Definition
@ -235,7 +236,7 @@ typedef struct {
// Global Variables Definition // Global Variables Definition
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
static GesturesData GESTURES = { static GesturesData GESTURES = {
.current = GESTURE_NONE, // No current gesture detected .current = GESTURE_NONE, // No current gesture detected
.Touch.firstId = -1, .Touch.firstId = -1,
.enabledFlags = 0b0000001111111111 // All gestures supported by default .enabledFlags = 0b0000001111111111 // All gestures supported by default
}; };
@ -265,19 +266,22 @@ bool IsGestureDetected(unsigned int gesture)
} }
// Process gesture event and translate it into gestures // Process gesture event and translate it into gestures
// TODO: Tap gesture is detected on DOWN action but should be detected on UP action
void ProcessGestureEvent(GestureEvent event) void ProcessGestureEvent(GestureEvent event)
{ {
// Reset required variables // Reset required variables
GESTURES.Touch.pointCount = event.pointCount; // Required on UpdateGestures() GESTURES.Touch.pointCount = event.pointCount;
if (GESTURES.Touch.pointCount == 1) // One touch point if (GESTURES.Touch.pointCount == 1) // One touch point
{ {
if (event.touchAction == TOUCH_ACTION_DOWN) if (event.touchAction == TOUCH_ACTION_DOWN)
{ {
GESTURES.Touch.tapCounter++; // Tap counter GESTURES.Touch.tapCounter++; // Tap counter
// Detect GESTURE_DOUBLE_TAP // Detect GESTURE_DOUBLE_TAP
if ((GESTURES.current == GESTURE_NONE) && (GESTURES.Touch.tapCounter >= 2) && ((rgGetCurrentTime() - GESTURES.Touch.eventTime) < TAP_TIMEOUT) && (rgVector2Distance(GESTURES.Touch.downPositionA, event.position[0]) < DOUBLETAP_RANGE)) if ((GESTURES.current == GESTURE_NONE) && (GESTURES.Touch.tapCounter >= 2) &&
((rgGetCurrentTime() - GESTURES.Touch.eventTime) < MIN_TAP_TIME) &&
(rgVector2Distance(GESTURES.Touch.downPositionA, event.position[0]) < MAX_DOUBLETAP_RANGE))
{ {
GESTURES.current = GESTURE_DOUBLETAP; GESTURES.current = GESTURE_DOUBLETAP;
GESTURES.Touch.tapCounter = 0; GESTURES.Touch.tapCounter = 0;
@ -300,15 +304,14 @@ void ProcessGestureEvent(GestureEvent event)
} }
else if (event.touchAction == TOUCH_ACTION_UP) else if (event.touchAction == TOUCH_ACTION_UP)
{ {
// A swipe can happen while the current gesture is drag, but (especially for web) also hold, so set upPosition for both cases GESTURES.Touch.upPosition = event.position[0];
if (GESTURES.current == GESTURE_DRAG || GESTURES.current == GESTURE_HOLD) GESTURES.Touch.upPosition = event.position[0];
// NOTE: GESTURES.Drag.intensity is dependent on the resolution of the screen // NOTE: GESTURES.Drag.intensity is dependent on the resolution of the screen
GESTURES.Drag.distance = rgVector2Distance(GESTURES.Touch.downPositionA, GESTURES.Touch.upPosition); GESTURES.Drag.distance = rgVector2Distance(GESTURES.Touch.downPositionA, GESTURES.Touch.upPosition);
GESTURES.Drag.intensity = GESTURES.Drag.distance/(float)((rgGetCurrentTime() - GESTURES.Swipe.startTime)); GESTURES.Drag.intensity = GESTURES.Drag.distance/(float)((rgGetCurrentTime() - GESTURES.Swipe.startTime));
// Detect GESTURE_SWIPE // Detect GESTURE_SWIPE
if ((GESTURES.Drag.intensity > FORCE_TO_SWIPE) && (GESTURES.current != GESTURE_DRAG)) if ((GESTURES.Drag.intensity > MIN_SWIPE_FORCE) && (GESTURES.current != GESTURE_DRAG))
{ {
// NOTE: Angle should be inverted in Y // NOTE: Angle should be inverted in Y
GESTURES.Drag.angle = 360.0f - rgVector2Angle(GESTURES.Touch.downPositionA, GESTURES.Touch.upPosition); GESTURES.Drag.angle = 360.0f - rgVector2Angle(GESTURES.Touch.downPositionA, GESTURES.Touch.upPosition);
@ -335,14 +338,10 @@ void ProcessGestureEvent(GestureEvent event)
{ {
GESTURES.Touch.moveDownPositionA = event.position[0]; GESTURES.Touch.moveDownPositionA = event.position[0];
if (GESTURES.current == GESTURE_HOLD) if ((GESTURES.current == GESTURE_TAP) || (GESTURES.current == GESTURE_HOLD))
{ {
if (GESTURES.Hold.resetRequired) GESTURES.Touch.downPositionA = event.position[0];
GESTURES.Hold.resetRequired = false;
// Detect GESTURE_DRAG // Detect GESTURE_DRAG
if ((rgGetCurrentTime() - GESTURES.Touch.eventTime) > DRAG_TIMEOUT) if ((rgGetCurrentTime() - GESTURES.Touch.eventTime) > MIN_DRAG_TIME)
{ {
GESTURES.Touch.eventTime = rgGetCurrentTime(); GESTURES.Touch.eventTime = rgGetCurrentTime();
GESTURES.current = GESTURE_DRAG; GESTURES.current = GESTURE_DRAG;
@ -363,13 +362,11 @@ void ProcessGestureEvent(GestureEvent event)
GESTURES.Touch.previousPositionA = GESTURES.Touch.downPositionA; GESTURES.Touch.previousPositionA = GESTURES.Touch.downPositionA;
GESTURES.Touch.previousPositionB = GESTURES.Touch.downPositionB; GESTURES.Touch.previousPositionB = GESTURES.Touch.downPositionB;
//GESTURES.Pinch.distance = rgVector2Distance(GESTURES.Touch.downPositionA, GESTURES.Touch.downPositionB);
GESTURES.Pinch.vector.x = GESTURES.Touch.downPositionB.x - GESTURES.Touch.downPositionA.x; GESTURES.Pinch.vector.x = GESTURES.Touch.downPositionB.x - GESTURES.Touch.downPositionA.x;
GESTURES.Pinch.vector.y = GESTURES.Touch.downPositionB.y - GESTURES.Touch.downPositionA.y; GESTURES.Pinch.vector.y = GESTURES.Touch.downPositionB.y - GESTURES.Touch.downPositionA.y;
GESTURES.current = GESTURE_HOLD; //GESTURES.current = GESTURE_HOLD;
GESTURES.Hold.timeDuration = rgGetCurrentTime(); //GESTURES.Hold.timeDuration = rgGetCurrentTime();
} }
else if (event.touchAction == TOUCH_ACTION_MOVE) else if (event.touchAction == TOUCH_ACTION_MOVE)
{ {
@ -381,16 +378,16 @@ void ProcessGestureEvent(GestureEvent event)
GESTURES.Pinch.vector.x = GESTURES.Touch.moveDownPositionB.x - GESTURES.Touch.moveDownPositionA.x; GESTURES.Pinch.vector.x = GESTURES.Touch.moveDownPositionB.x - GESTURES.Touch.moveDownPositionA.x;
GESTURES.Pinch.vector.y = GESTURES.Touch.moveDownPositionB.y - GESTURES.Touch.moveDownPositionA.y; GESTURES.Pinch.vector.y = GESTURES.Touch.moveDownPositionB.y - GESTURES.Touch.moveDownPositionA.y;
if ((rgVector2Distance(GESTURES.Touch.previousPositionA, GESTURES.Touch.moveDownPositionA) >= MINIMUM_PINCH) || (rgVector2Distance(GESTURES.Touch.previousPositionB, GESTURES.Touch.moveDownPositionB) >= MINIMUM_PINCH)) if ((rgVector2Distance(GESTURES.Touch.previousPositionA, GESTURES.Touch.moveDownPositionA) >= MIN_PINCH_DISTANCE) || (rgVector2Distance(GESTURES.Touch.previousPositionB, GESTURES.Touch.moveDownPositionB) >= MIN_PINCH_DISTANCE))
{ {
if ( rgVector2Distance(GESTURES.Touch.previousPositionA, GESTURES.Touch.previousPositionB) > rgVector2Distance(GESTURES.Touch.moveDownPositionA, GESTURES.Touch.moveDownPositionB) ) GESTURES.current = GESTURE_PINCH_IN; if (rgVector2Distance(GESTURES.Touch.previousPositionA, GESTURES.Touch.previousPositionB) > rgVector2Distance(GESTURES.Touch.moveDownPositionA, GESTURES.Touch.moveDownPositionB) ) GESTURES.current = GESTURE_PINCH_IN;
else GESTURES.current = GESTURE_PINCH_OUT; else GESTURES.current = GESTURE_PINCH_OUT;
} }
else //else
{ //{
GESTURES.current = GESTURE_HOLD; // GESTURES.current = GESTURE_HOLD;
GESTURES.Hold.timeDuration = rgGetCurrentTime(); // GESTURES.Hold.timeDuration = rgGetCurrentTime();
} //}
// NOTE: Angle should be inverted in Y // NOTE: Angle should be inverted in Y
GESTURES.Pinch.angle = 360.0f - rgVector2Angle(GESTURES.Touch.moveDownPositionA, GESTURES.Touch.moveDownPositionB); GESTURES.Pinch.angle = 360.0f - rgVector2Angle(GESTURES.Touch.moveDownPositionA, GESTURES.Touch.moveDownPositionB);
@ -411,24 +408,33 @@ void ProcessGestureEvent(GestureEvent event)
} }
} }
/*
// Update gestures detected (must be called every frame) // Update gestures detected (must be called every frame)
void UpdateGestures(void) void UpdateGestures(void)
{ {
// NOTE: Gestures are processed through system callbacks on touch events // NOTE: Gestures are processed through system callbacks on touch events
// Detect GESTURE_HOLD // Detect GESTURE_HOLD
if (((GESTURES.current == GESTURE_TAP) || (GESTURES.current == GESTURE_DOUBLETAP)) && (GESTURES.Touch.pointCount < 2)) if (((GESTURES.current == GESTURE_TAP) || (GESTURES.current == GESTURE_DOUBLETAP)) &&
(GESTURES.Touch.pointCount < 2))
{ {
GESTURES.current = GESTURE_HOLD; if ((rgGetCurrentTime() - GESTURES.Touch.eventTime) > MIN_HOLD_TIME)
GESTURES.Hold.timeDuration = rgGetCurrentTime(); {
GESTURES.current = GESTURE_HOLD;
GESTURES.Hold.timeDuration = (rgGetCurrentTime() - GESTURES.Touch.eventTime);
}
} }
// Detect GESTURE_NONE // Detect GESTURE_NONE
if ((GESTURES.current == GESTURE_SWIPE_RIGHT) || (GESTURES.current == GESTURE_SWIPE_UP) || (GESTURES.current == GESTURE_SWIPE_LEFT) || (GESTURES.current == GESTURE_SWIPE_DOWN)) if ((GESTURES.current == GESTURE_SWIPE_RIGHT) ||
(GESTURES.current == GESTURE_SWIPE_UP) ||
(GESTURES.current == GESTURE_SWIPE_LEFT) ||
(GESTURES.current == GESTURE_SWIPE_DOWN))
{ {
GESTURES.current = GESTURE_NONE; GESTURES.current = GESTURE_NONE;
} }
} }
*/
// Get latest detected gesture // Get latest detected gesture
int GetGestureDetected(void) int GetGestureDetected(void)

View File

@ -1079,7 +1079,6 @@ typedef struct rlglData {
int framebufferWidth; // Current framebuffer width int framebufferWidth; // Current framebuffer width
int framebufferHeight; // Current framebuffer height int framebufferHeight; // Current framebuffer height
} State; // Renderer state } State; // Renderer state
struct { struct {
bool vao; // VAO support (OpenGL ES2 could not support VAO extension) (GL_ARB_vertex_array_object) bool vao; // VAO support (OpenGL ES2 could not support VAO extension) (GL_ARB_vertex_array_object)
@ -1101,7 +1100,6 @@ typedef struct rlglData {
float maxAnisotropyLevel; // Maximum anisotropy level supported (minimum is 2.0f) float maxAnisotropyLevel; // Maximum anisotropy level supported (minimum is 2.0f)
int maxDepthBits; // Maximum bits for depth component int maxDepthBits; // Maximum bits for depth component
} ExtSupported; // Extensions supported flags } ExtSupported; // Extensions supported flags
} rlglData; } rlglData;

View File

@ -6808,10 +6808,9 @@ static ModelAnimation *LoadModelAnimationsGLTF(const char *fileName, int *animCo
{ {
TRACELOG(LOG_WARNING, "MODEL: [%s] Expected one unique skin to load animation data from, but found %i", fileName, data->skins_count); TRACELOG(LOG_WARNING, "MODEL: [%s] Expected one unique skin to load animation data from, but found %i", fileName, data->skins_count);
} }
cgltf_free(data);
} }
cgltf_free(data);
UnloadFileData(fileData); UnloadFileData(fileData);
return animations; return animations;

View File

@ -1925,7 +1925,8 @@ char *TextReplaceAlloc(const char *text, const char *search, const char *replace
for (count = 0; (temp = strstr(insertPoint, search)); count++) insertPoint = temp + searchLen; for (count = 0; (temp = strstr(insertPoint, search)); count++) insertPoint = temp + searchLen;
// Allocate returning string and point temp to it // Allocate returning string and point temp to it
int tempLen = textLen + (replaceLen - searchLen)*count + 1; int tempLen = textLen + count*(replaceLen - searchLen) + 1;
temp = result = (char *)RL_CALLOC(tempLen, sizeof(char)); temp = result = (char *)RL_CALLOC(tempLen, sizeof(char));
// First time through the loop, all the variable are set correctly from here on, // First time through the loop, all the variable are set correctly from here on,
@ -2101,7 +2102,7 @@ char *TextJoin(char **textList, int count, const char *delimiter)
int textLength = TextLength(textList[i]); int textLength = TextLength(textList[i]);
// Make sure joined text could fit inside MAX_TEXT_BUFFER_LENGTH // Make sure joined text could fit inside MAX_TEXT_BUFFER_LENGTH
if ((totalLength + textLength + delimiterLen) < MAX_TEXT_BUFFER_LENGTH) if ((totalLength + textLength + ((i < (count - 1))? delimiterLen : 0)) < MAX_TEXT_BUFFER_LENGTH)
{ {
memcpy(textPtr, textList[i], textLength); memcpy(textPtr, textList[i], textLength);
totalLength += textLength; totalLength += textLength;

View File

@ -5331,7 +5331,7 @@ Color ColorFromHSV(float hue, float saturation, float value)
k = (t < k)? t : k; k = (t < k)? t : k;
k = (k < 1)? k : 1; k = (k < 1)? k : 1;
k = (k > 0)? k : 0; k = (k > 0)? k : 0;
color.r = (unsigned char)((value - value*saturation*k)*255.0f); color.r = (unsigned char)((value - value*saturation*k)*255.0f + 0.5f);
// Green channel // Green channel
k = fmodf((3.0f + hue/60.0f), 6); k = fmodf((3.0f + hue/60.0f), 6);
@ -5339,7 +5339,7 @@ Color ColorFromHSV(float hue, float saturation, float value)
k = (t < k)? t : k; k = (t < k)? t : k;
k = (k < 1)? k : 1; k = (k < 1)? k : 1;
k = (k > 0)? k : 0; k = (k > 0)? k : 0;
color.g = (unsigned char)((value - value*saturation*k)*255.0f); color.g = (unsigned char)((value - value*saturation*k)*255.0f + 0.5f);
// Blue channel // Blue channel
k = fmodf((1.0f + hue/60.0f), 6); k = fmodf((1.0f + hue/60.0f), 6);
@ -5347,7 +5347,7 @@ Color ColorFromHSV(float hue, float saturation, float value)
k = (t < k)? t : k; k = (t < k)? t : k;
k = (k < 1)? k : 1; k = (k < 1)? k : 1;
k = (k > 0)? k : 0; k = (k > 0)? k : 0;
color.b = (unsigned char)((value - value*saturation*k)*255.0f); color.b = (unsigned char)((value - value*saturation*k)*255.0f + 0.5f);
return color; return color;
} }

View File

@ -3550,6 +3550,17 @@
"description": "Get clipboard text content", "description": "Get clipboard text content",
"returnType": "const char *" "returnType": "const char *"
}, },
{
"name": "SetClipboardImage",
"description": "Set clipboard image content",
"returnType": "bool",
"params": [
{
"type": "Image",
"name": "image"
}
]
},
{ {
"name": "GetClipboardImage", "name": "GetClipboardImage",
"description": "Get clipboard image content", "description": "Get clipboard image content",

View File

@ -3427,6 +3427,14 @@ return {
description = "Get clipboard text content", description = "Get clipboard text content",
returnType = "const char *" returnType = "const char *"
}, },
{
name = "SetClipboardImage",
description = "Set clipboard image content",
returnType = "bool",
params = {
{type = "Image", name = "image"}
}
},
{ {
name = "GetClipboardImage", name = "GetClipboardImage",
description = "Get clipboard image content", description = "Get clipboard image content",

View File

@ -2453,6 +2453,12 @@
(description "Get clipboard text content") (description "Get clipboard text content")
(return-type "const char *")) (return-type "const char *"))
((name "SetClipboardImage")
(description "Set clipboard image content")
(return-type "bool")
(params
((type "Image") (name "image"))))
((name "GetClipboardImage") ((name "GetClipboardImage")
(description "Get clipboard image content") (description "Get clipboard image content")
(return-type "Image")) (return-type "Image"))

File diff suppressed because it is too large Load Diff

View File

@ -681,7 +681,7 @@
<Param type="unsigned int" name="frames" desc="" /> <Param type="unsigned int" name="frames" desc="" />
</Callback> </Callback>
</Callbacks> </Callbacks>
<Functions count="619"> <Functions count="620">
<Function name="InitWindow" retType="void" paramCount="3" desc="Initialize window and OpenGL context"> <Function name="InitWindow" retType="void" paramCount="3" desc="Initialize window and OpenGL context">
<Param type="int" name="width" desc="" /> <Param type="int" name="width" desc="" />
<Param type="int" name="height" desc="" /> <Param type="int" name="height" desc="" />
@ -802,6 +802,9 @@
</Function> </Function>
<Function name="GetClipboardText" retType="const char *" paramCount="0" desc="Get clipboard text content"> <Function name="GetClipboardText" retType="const char *" paramCount="0" desc="Get clipboard text content">
</Function> </Function>
<Function name="SetClipboardImage" retType="bool" paramCount="1" desc="Set clipboard image content">
<Param type="Image" name="image" desc="" />
</Function>
<Function name="GetClipboardImage" retType="Image" paramCount="0" desc="Get clipboard image content"> <Function name="GetClipboardImage" retType="Image" paramCount="0" desc="Get clipboard image content">
</Function> </Function>
<Function name="EnableEventWaiting" retType="void" paramCount="0" desc="Enable waiting for events on EndDrawing(), no automatic event polling"> <Function name="EnableEventWaiting" retType="void" paramCount="0" desc="Enable waiting for events on EndDrawing(), no automatic event polling">