Add Keyboard.IsAnyKeyDown

This commit is contained in:
Wojtek Figat
2021-06-02 09:47:37 +02:00
parent d111b2ba03
commit 398fc4be37
2 changed files with 29 additions and 31 deletions

View File

@@ -223,6 +223,27 @@ bool Mouse::Update(EventQueue& queue)
return false;
}
void Keyboard::State::Clear()
{
Platform::MemoryClear(this, sizeof(State));
}
Keyboard::Keyboard()
: InputDevice(SpawnParams(Guid::New(), TypeInitializer), TEXT("Keyboard"))
{
_state.Clear();
_prevState.Clear();
}
bool Keyboard::IsAnyKeyDown() const
{
// TODO: optimize with SIMD
bool result = false;
for (auto e : _state.Keys)
result |= e;
return result;
}
void Keyboard::OnCharInput(Char c, Window* target)
{
// Skip control characters