- unitat mouse per amagar el punter

- overlay captura el esc i confirma la eixida (falla en game)
This commit is contained in:
2026-04-04 22:32:53 +02:00
parent d4fc7c0ee8
commit a4ee304a79
7 changed files with 175 additions and 44 deletions

View File

@@ -0,0 +1,26 @@
#include "core/input/mouse.hpp"
namespace Mouse {
static constexpr Uint32 HIDE_DELAY = 3000; // Temps en ms per a amagar el cursor
static Uint32 last_move_time = 0;
static bool cursor_visible = true;
void handleEvent(const SDL_Event& event) {
if (event.type == SDL_EVENT_MOUSE_MOTION) {
last_move_time = SDL_GetTicks();
if (!cursor_visible) {
SDL_ShowCursor();
cursor_visible = true;
}
}
}
void updateCursorVisibility() {
if (cursor_visible && (SDL_GetTicks() - last_move_time > HIDE_DELAY)) {
SDL_HideCursor();
cursor_visible = false;
}
}
} // namespace Mouse