WebRGFW: remapping mouse/touch position to canvas pixel coordinates (#5679)

* RGFW also requires RGBA8 images as window icons, as raylib already reports in raylib.h

* LibraryConfigurations.cmake: exchanged MATCHES -> STREQUAL in platform choosing if-statements

* WebRGFW: remapping mouse/touch position to canvas pixel coordinates

* fix 'typo'

* has to be done like that because of += in case of captured mouse
This commit is contained in:
Krzysztof Szenk
2026-03-23 11:31:06 +01:00
committed by GitHub
parent 83e35ba170
commit 1e74aba7c3

View File

@@ -1447,15 +1447,37 @@ void PollInputEvents(void)
} break;
case RGFW_mousePosChanged:
{
float event_x = 0.0f, event_y = 0.0f;
if (RGFW_window_isCaptured(platform.window))
{
CORE.Input.Mouse.currentPosition.x += (float)rgfw_event.mouse.vecX;
CORE.Input.Mouse.currentPosition.y += (float)rgfw_event.mouse.vecY;
event_x = (float)rgfw_event.mouse.vecX;
event_y = (float)rgfw_event.mouse.vecY;
}
else
{
CORE.Input.Mouse.currentPosition.x = (float)rgfw_event.mouse.x;
CORE.Input.Mouse.currentPosition.y = (float)rgfw_event.mouse.y;
event_x = (float)rgfw_event.mouse.x;
event_y = (float)rgfw_event.mouse.y;
}
#if defined(__EMSCRIPTEN__)
{
double canvasWidth = 0.0;
double canvasHeight = 0.0;
emscripten_get_element_css_size("#canvas", &canvasWidth, &canvasHeight);
event_x *= ((float)GetScreenWidth() / (float)canvasWidth);
event_y *= ((float)GetScreenHeight() / (float)canvasHeight);
}
#endif
if (RGFW_window_isCaptured(platform.window))
{
CORE.Input.Mouse.currentPosition.x += event_x;
CORE.Input.Mouse.currentPosition.y += event_y;
}
else
{
CORE.Input.Mouse.currentPosition.x = event_x;
CORE.Input.Mouse.currentPosition.y = event_y;
}
CORE.Input.Touch.position[0] = CORE.Input.Mouse.currentPosition;