Corrected Mouse Velocity Calculation when Mouse Centering is On #423
|
@ -798,17 +798,45 @@ namespace SHADE
|
|||
|
||||
//Get cursor position, even when it is outside window
|
||||
POINT p;
|
||||
GetCursorPos(&p);
|
||||
GetCursorPos(&p); //This point is WRT the screen, not the window
|
||||
//ScreenToClient(GetActiveWindow(), &p);
|
||||
mouseScreenX = p.x;
|
||||
mouseScreenY = p.y;
|
||||
//SHLOGV_INFO("MouseScreenY = {}", mouseScreenY);
|
||||
|
||||
if (!mouseCentering)
|
||||
{
|
||||
//Velocity
|
||||
mouseVelocityX = static_cast<double>(mouseScreenX - mouseScreenXLast) / dt;
|
||||
mouseVelocityY = static_cast<double>(mouseScreenY - mouseScreenYLast) / dt;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Mouse centering
|
||||
//uint32_t width = SHADE::SHGraphicsSystemInterface::GetWindowWidth();
|
||||
//uint32_t height = SHADE::SHGraphicsSystemInterface::GetWindowHeight();
|
||||
int mouseCenterX = 0;
|
||||
int mouseCenterY = 0;
|
||||
RECT wndRect = { NULL }; //4th quadrant
|
||||
if (GetWindowRect(GetActiveWindow(), &wndRect))
|
||||
{
|
||||
mouseCenterX = wndRect.left + (wndRect.right - wndRect.left) / 2;
|
||||
mouseCenterY = wndRect.top + (wndRect.bottom - wndRect.top) / 2;
|
||||
//SHLOGV_INFO("W: {0}, H: {1}", (wndRect.right - wndRect.left), (wndRect.bottom - wndRect.top));
|
||||
}
|
||||
|
||||
//Velocity
|
||||
mouseVelocityX = static_cast<double>(mouseScreenX - mouseCenterX) / dt;
|
||||
mouseVelocityY = static_cast<double>(mouseScreenY - mouseCenterY) / dt;
|
||||
|
||||
//SHLOGV_INFO("mouseScreenY = {0:0}, mouseCenterY = {1:0}", mouseScreenY, mouseCenterY);
|
||||
//SHLOGV_INFO("{0.0}", mouseVelocityY);
|
||||
|
||||
SetMouseScreenPosition(mouseCenterX, mouseCenterY);
|
||||
}
|
||||
|
||||
//Mouse Centering
|
||||
if (mouseCentering)
|
||||
/*if (mouseCentering)
|
||||
{
|
||||
uint32_t width = SHADE::SHGraphicsSystemInterface::GetWindowWidth();
|
||||
uint32_t height = SHADE::SHGraphicsSystemInterface::GetWindowHeight();
|
||||
|
@ -819,7 +847,7 @@ namespace SHADE
|
|||
GetCursorPos(&p);
|
||||
mouseVelocityX -= static_cast<double>(p.x - mouseScreenX) / dt;
|
||||
mouseVelocityY -= static_cast<double>(p.y - mouseScreenY) / dt;
|
||||
}
|
||||
}*/
|
||||
|
||||
if (mouseVelocityX != 0.0 || mouseVelocityY != 0.0)
|
||||
controllerInUse = false;
|
||||
|
|
Loading…
Reference in New Issue