aboutsummaryrefslogtreecommitdiff
path: root/src/ui/input_util.cpp
blob: 3fe34f107eb785da2b93320ec37a4b1789134fcf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#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);
}
}  // namespace cru::ui