- unitat mouse per amagar el punter
- overlay captura el esc i confirma la eixida (falla en game)
This commit is contained in:
26
source/core/input/mouse.cpp
Normal file
26
source/core/input/mouse.cpp
Normal 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
|
||||
Reference in New Issue
Block a user