Skip to content

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

Open
Crisspl wants to merge 9 commits intoraysan5:masterfrom
Crisspl:rcore-rgfw-input-fix
Open

WebRGFW: remapping mouse/touch position to canvas pixel coordinates#5679
Crisspl wants to merge 9 commits intoraysan5:masterfrom
Crisspl:rcore-rgfw-input-fix

Conversation

@Crisspl
Copy link
Contributor

@Crisspl Crisspl commented Mar 21, 2026

Actually doing something very similar to what is done in rcore_web.
This probably should be fixed RGFW-side, but RGFW has more problems on web that should be addressed, so preapring this minimalistic change on the side of raylib is the best i could do here. Also opened an issue about this on RGFW repo: ColleagueRiley/RGFW#493

@raysan5
Copy link
Owner

raysan5 commented Mar 22, 2026

@Crisspl please, could you review formatting to follow raylib code conventions?

} break;
case RGFW_mousePosChanged:
{
float event_x = 0.0f, event_y = 0.0f;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, use mouseX, mouseY

double canvasWidth = 0.0;
double canvasHeight = 0.0;
emscripten_get_element_css_size("#canvas", &canvasWidth, &canvasHeight);
event_x *= ((float)GetScreenWidth() / (float)canvasWidth);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note raylib does not use spaces between / and *

@Crisspl
Copy link
Contributor Author

Crisspl commented Mar 23, 2026

sure, i will take care of it tommorow 🫡

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants