| 65 | Fvector2 CUICursor::GetCursorPositionDelta() const { return Fvector2{vPos.x - vPrevPos.x, vPos.y - vPrevPos.y}; } |
| 66 | |
| 67 | void CUICursor::UpdateCursorPosition(const int _dx, const int _dy) |
| 68 | { |
| 69 | vPrevPos = vPos; |
| 70 | |
| 71 | const u32 screen_size_x = GetSystemMetrics(SM_CXSCREEN); |
| 72 | const u32 screen_size_y = GetSystemMetrics(SM_CYSCREEN); |
| 73 | |
| 74 | const bool m_b_use_win_cursor = (screen_size_y >= Device.dwHeight && screen_size_x >= Device.dwWidth); |
| 75 | |
| 76 | if (m_b_use_win_cursor) |
| 77 | { |
| 78 | Ivector2 pti{}; |
| 79 | |
| 80 | GetCursorPos((LPPOINT)&pti); |
| 81 | |
| 82 | HWND hwnd = Device.m_hWnd; |
| 83 | if (hwnd) |
| 84 | ScreenToClient(hwnd, (LPPOINT)&pti); |
| 85 | |
| 86 | vPos.x = (float)pti.x * (UI_BASE_WIDTH / (float)Device.dwWidth); |
| 87 | vPos.y = (float)pti.y * (UI_BASE_HEIGHT / (float)Device.dwHeight); |
| 88 | } |
| 89 | else |
| 90 | { |
| 91 | constexpr float sens = 1.0f; |
| 92 | vPos.x += _dx * sens; |
| 93 | vPos.y += _dy * sens; |
| 94 | } |
| 95 | |
| 96 | clamp(vPos.x, 0.f, UI_BASE_WIDTH); |
| 97 | clamp(vPos.y, 0.f, UI_BASE_HEIGHT); |
| 98 | } |
| 99 | |
| 100 | void CUICursor::SetUICursorPosition(const Fvector2& pos) |
| 101 | { |
no test coverage detected