diff options
Diffstat (limited to 'drafts')
-rw-r--r-- | drafts/input_util.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/drafts/input_util.cpp b/drafts/input_util.cpp new file mode 100644 index 00000000..193cba4a --- /dev/null +++ b/drafts/input_util.cpp @@ -0,0 +1,20 @@ +#include "input_util.hpp" + +#include <Windows.h> + +namespace cru::ui { +bool IsKeyDown(const int virtual_code) { + const auto result = ::GetKeyState(virtual_code); + return (static_cast<unsigned short>(result) & 0x8000) != 0; +} + +bool IsKeyToggled(const int virtual_code) { + const auto result = ::GetKeyState(virtual_code); + return (static_cast<unsigned short>(result) & 1) != 0; +} + +bool IsAnyMouseButtonDown() { + return IsKeyDown(VK_LBUTTON) || IsKeyDown(VK_RBUTTON) || + IsKeyDown(VK_MBUTTON); +} +} // namespace cru::ui |