Skip to content

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

Merged
raysan5 merged 9 commits into
raysan5:masterfrom
Crisspl:rcore-rgfw-input-fix
Mar 23, 2026
Merged

WebRGFW: remapping mouse/touch position to canvas pixel coordinates#5679
raysan5 merged 9 commits into
raysan5:masterfrom
Crisspl:rcore-rgfw-input-fix

Conversation

@Crisspl

@Crisspl Crisspl commented Mar 21, 2026

Copy link
Copy Markdown
Contributor

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

raysan5 commented Mar 22, 2026

Copy link
Copy Markdown
Owner

@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
Copy Markdown
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
Copy Markdown
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

Crisspl commented Mar 23, 2026

Copy link
Copy Markdown
Contributor Author

sure, i will take care of it tommorow 🫡

@raysan5 raysan5 merged commit 1e74aba into raysan5:master Mar 23, 2026
16 checks passed
@raysan5

raysan5 commented Mar 23, 2026

Copy link
Copy Markdown
Owner

@Crisspl thanks, I'm merging and reviewing it myself.

raysan5 added a commit that referenced this pull request Mar 23, 2026
@Crisspl

Crisspl commented Mar 23, 2026

Copy link
Copy Markdown
Contributor Author

oh, great. Thank you!

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