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;
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);
CORE.Input.Mouse.currentPosition.x *= ((float)GetScreenWidth() / (float)canvasWidth);
CORE.Input.Mouse.currentPosition.y *= ((float)GetScreenHeight() / (float)canvasHeight);
{
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;
touchAction = 2;
} break;