SetCursorCenter Windows
All checks were successful
Run ReCI Build Test / Explore-Gitea-Actions (push) Successful in 1m50s

This commit is contained in:
2025-06-29 19:44:33 -04:00
parent 42deab60f4
commit bb776026ad
2 changed files with 15 additions and 8 deletions

View File

@@ -280,6 +280,7 @@ public:
void SetCursorCustomIcon() const;
/// @returns Where the cursor was just before we teleported it to the center.
/// @note On some remote desktop software you won't actually see the cursor move, It does work though. - Redacted.
/// @note This is useful for 3D games.
std::pair<int, int> SetCursorCenter();

View File

@@ -13,13 +13,19 @@ public:
using namespace ReWindow;
//bool local_fullscreen_mode = false;
// TODO get rid of this.
bool local_focused = true;
//bool local_vsync = false;
//bool local_cursor_visible = true;
//bool local_closing = false;
std::pair<int, int> RWindow::SetCursorCenter() {
auto current_cursor_pos = GetAccurateMouseCoordinates();
RECT client_rect;
GetClientRect(platform->hwnd, &client_rect);
POINT center((client_rect.right - client_rect.left) / 2, (client_rect.bottom - client_rect.top) / 2 );
ClientToScreen(platform->hwnd, &center);
SetCursorPos(center.x, center.y);
return current_cursor_pos;
}
void RWindow::PollEvents() {
MSG msg;
while (PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE))
@@ -152,8 +158,9 @@ LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
}
//This is the same as "Motion Notify" in the X Window System.
case WM_MOUSEMOVE:
break;
case WM_MOUSEMOVE: {
}
}
return DefWindowProc(hwnd, uMsg, wParam, lParam);
}
@@ -291,7 +298,6 @@ namespace OpenGL {
typedef HGLRC (WINAPI *WGLCREATECONTEXTPROC)(HDC hdc);
WGLCREATECONTEXTPROC wglCreateContext = nullptr;
}
bool OpenGLWindow::Open() {