From 6d89d5db5140c04cc94bf4791a32a06a89e95b62 Mon Sep 17 00:00:00 2001 From: HampusM Date: Mon, 23 May 2022 19:47:25 +0200 Subject: refactor: improve input handling in game loop --- src/engine/user/input.cpp | 5 +++++ src/engine/user/input.hpp | 2 ++ 2 files changed, 7 insertions(+) (limited to 'src/engine/user') diff --git a/src/engine/user/input.cpp b/src/engine/user/input.cpp index ac6d660..cbba143 100644 --- a/src/engine/user/input.cpp +++ b/src/engine/user/input.cpp @@ -38,6 +38,11 @@ bool UserInputObserver::is_key_pressed(Key key) noexcept return is_key_pressed; } +auto UserInputObserver::get_currently_pressed_key() const noexcept -> Key +{ + return _currently_pressed; +} + void UserInputObserver::clear_currently_pressed() noexcept { _currently_pressed_mutex.lock(); diff --git a/src/engine/user/input.hpp b/src/engine/user/input.hpp index 3cec1b8..29534e8 100644 --- a/src/engine/user/input.hpp +++ b/src/engine/user/input.hpp @@ -18,6 +18,8 @@ public: bool is_key_pressed(Key key) noexcept override; + Key get_currently_pressed_key() const noexcept override; + void clear_currently_pressed() noexcept override; private: -- cgit v1.2.3-18-g5258