diff options
author | crupest <crupest@outlook.com> | 2019-01-01 23:17:32 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2019-01-01 23:17:32 +0800 |
commit | 06edefebe8dfb138404397fb2c46732da6cd733a (patch) | |
tree | 79f81f3015084589ba97cb12d6cf46b916e17a33 /src/ui/input_util.cpp | |
parent | 4683f1565b7fdb2e5f9367d5cd365a00cc3a7e1d (diff) | |
parent | 715428e4d728fd01c7c308b586315bce38aac8c5 (diff) | |
download | cru-06edefebe8dfb138404397fb2c46732da6cd733a.tar.gz cru-06edefebe8dfb138404397fb2c46732da6cd733a.tar.bz2 cru-06edefebe8dfb138404397fb2c46732da6cd733a.zip |
...
Diffstat (limited to 'src/ui/input_util.cpp')
-rw-r--r-- | src/ui/input_util.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/ui/input_util.cpp b/src/ui/input_util.cpp new file mode 100644 index 00000000..6cf2d695 --- /dev/null +++ b/src/ui/input_util.cpp @@ -0,0 +1,23 @@ +#include "input_util.hpp" + +#include "system_headers.hpp" + +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); + } +} |