feat(menu): submenú Controls i bloqueig de polling amb menú obert
This commit is contained in:
1 parent
350625dec0
commit
fb40d0effb
8 files changed
+229
-7
No files matched your search
@@ -0,0 +1,31 @@
|
||||
#include "core/input/input_state.hpp"
|
||||
|
||||
#include <array>
|
||||
|
||||
namespace InputState {
|
||||
|
||||
namespace {
|
||||
|
||||
bool blocked = false;
|
||||
|
||||
// Buffer retornat quan el bloqueig és actiu. `SDL_GetKeyboardState`
|
||||
// retorna un pointer d'una mida igual a `SDL_SCANCODE_COUNT`; el
|
||||
// nostre buffer ha de ser com a mínim igual de gran perquè els
|
||||
// consumidors puguin indexar-lo amb qualsevol scancode sense
|
||||
// llegir fora de rang.
|
||||
auto zeroKeyboard() -> const bool* {
|
||||
static const std::array<bool, SDL_SCANCODE_COUNT> ZEROS{};
|
||||
return ZEROS.data();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void setBlocked(bool value) { blocked = value; }
|
||||
|
||||
auto isBlocked() -> bool { return blocked; }
|
||||
|
||||
auto getKeyboardState() -> const bool* {
|
||||
return blocked ? zeroKeyboard() : SDL_GetKeyboardState(nullptr);
|
||||
}
|
||||
|
||||
} // namespace InputState
|
||||
Reference in new issue
Block a user