mouse.cpp 484 B

1234567891011121314151617181920212223
  1. #if defined(Hiro_Mouse)
  2. namespace hiro {
  3. auto pMouse::position() -> Position {
  4. POINT point{};
  5. GetCursorPos(&point);
  6. return {point.x, point.y};
  7. }
  8. auto pMouse::pressed(Mouse::Button button) -> bool {
  9. switch(button) {
  10. case Mouse::Button::Left: return GetAsyncKeyState(VK_LBUTTON) & 0x8000;
  11. case Mouse::Button::Middle: return GetAsyncKeyState(VK_MBUTTON) & 0x8000;
  12. case Mouse::Button::Right: return GetAsyncKeyState(VK_RBUTTON) & 0x8000;
  13. }
  14. return false;
  15. }
  16. }
  17. #endif