aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ui/input_util.cpp23
-rw-r--r--src/ui/input_util.hpp18
-rw-r--r--src/ui/ui_base.cpp17
3 files changed, 41 insertions, 17 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);
+ }
+}
diff --git a/src/ui/input_util.hpp b/src/ui/input_util.hpp
new file mode 100644
index 00000000..13f568b3
--- /dev/null
+++ b/src/ui/input_util.hpp
@@ -0,0 +1,18 @@
+#pragma once
+
+// ReSharper disable once CppUnusedIncludeDirective
+#include "pre.hpp"
+
+namespace cru::ui
+{
+ enum class MouseButton
+ {
+ Left,
+ Right,
+ Middle
+ };
+
+ bool IsKeyDown(int virtual_code);
+ bool IsKeyToggled(int virtual_code);
+ bool IsAnyMouseButtonDown();
+}
diff --git a/src/ui/ui_base.cpp b/src/ui/ui_base.cpp
index c91fcd7b..2853011d 100644
--- a/src/ui/ui_base.cpp
+++ b/src/ui/ui_base.cpp
@@ -1,23 +1,6 @@
#include "ui_base.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);
- }
}