aboutsummaryrefslogtreecommitdiff
path: root/src/ui/input_util.cpp
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2019-01-01 23:16:02 +0800
committercrupest <crupest@outlook.com>2019-01-01 23:16:02 +0800
commit715428e4d728fd01c7c308b586315bce38aac8c5 (patch)
tree406b3f29a52a8cb12d0eeb14a8f7a983b34765fe /src/ui/input_util.cpp
parentb028e74a48de181ca078ad3bf4ababf4fa146cd3 (diff)
downloadcru-715428e4d728fd01c7c308b586315bce38aac8c5.tar.gz
cru-715428e4d728fd01c7c308b586315bce38aac8c5.tar.bz2
cru-715428e4d728fd01c7c308b586315bce38aac8c5.zip
...
Diffstat (limited to 'src/ui/input_util.cpp')
-rw-r--r--src/ui/input_util.cpp23
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);
+ }
+}