33 lines
785 B
C++
33 lines
785 B
C++
#include "core/input/mouse.hpp"
|
|
|
|
namespace Mouse {
|
|
|
|
namespace {
|
|
|
|
// Temps (ms) sense moviment de ratolí abans d'amagar el cursor.
|
|
constexpr Uint32 HIDE_DELAY_MS = 3000;
|
|
|
|
Uint32 last_move_time = 0;
|
|
bool cursor_visible = true;
|
|
|
|
} // namespace
|
|
|
|
void handleEvent(const SDL_Event& ev) {
|
|
if (ev.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_MS)) {
|
|
SDL_HideCursor();
|
|
cursor_visible = false;
|
|
}
|
|
}
|
|
|
|
} // namespace Mouse
|