diff options
-rw-r--r-- | CruUI.vcxproj | 2 | ||||
-rw-r--r-- | src/ui/input_util.cpp | 23 | ||||
-rw-r--r-- | src/ui/input_util.hpp | 18 | ||||
-rw-r--r-- | src/ui/ui_base.cpp | 17 |
4 files changed, 43 insertions, 17 deletions
diff --git a/CruUI.vcxproj b/CruUI.vcxproj index 23e51e34..ee2c7eb1 100644 --- a/CruUI.vcxproj +++ b/CruUI.vcxproj @@ -148,6 +148,7 @@ <ClCompile Include="src\ui\controls\toggle_button.cpp" /> <ClCompile Include="src\ui\cursor.cpp" /> <ClCompile Include="src\ui\events\ui_event.cpp" /> + <ClCompile Include="src\ui\input_util.cpp" /> <ClCompile Include="src\ui\layout_base.cpp" /> <ClCompile Include="src\ui\render\render_object.cpp" /> <ClCompile Include="src\ui\ui_manager.cpp" /> @@ -175,6 +176,7 @@ <ClInclude Include="src\ui\d2d_util.hpp" /> <ClInclude Include="src\ui\cursor.hpp" /> <ClInclude Include="src\ui\events\ui_event.hpp" /> + <ClInclude Include="src\ui\input_util.hpp" /> <ClInclude Include="src\ui\layout_base.hpp" /> <ClInclude Include="src\ui\render\render_object.hpp" /> <ClInclude Include="src\ui\ui_manager.hpp" /> 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); - } } |