has to be done like that because of += in case of captured mouse

This commit is contained in:
criss 2026-03-21 01:55:41 +01:00
parent 68e249ccd8
commit c28f9fd229

View File

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