Handle global mouse state for Emscripten (#12669)

This commit is contained in:
Temdog007 2025-04-02 07:21:21 -07:00 committed by GitHub
parent 53d053279e
commit cc8ec6cf18
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 66 additions and 0 deletions

View file

@ -117,6 +117,8 @@ static void loop(void *arg)
struct mouse_loop_data *loop_data = (struct mouse_loop_data *)arg;
SDL_Event event;
SDL_Renderer *renderer = loop_data->renderer;
float fx, fy;
SDL_MouseButtonFlags flags;
/* Check for events */
while (SDL_PollEvent(&event)) {
@ -265,6 +267,10 @@ static void loop(void *arg)
DrawObject(renderer, active);
}
flags = SDL_GetGlobalMouseState(&fx, &fy);
SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255);
SDL_RenderDebugTextFormat(renderer, 0, 0, "Global Mouse State: x=%f y=%f flags=%" SDL_PRIu32, fx, fy, flags);
SDL_RenderPresent(renderer);
#ifdef SDL_PLATFORM_EMSCRIPTEN