if(g_States::Instance().MouseLook()) { //Test the mouse input POINT mousePos; GetCursorPos(&mousePos); mouseX = mousePos.x; //g_InputEngine::Instance().GetX(); mouseY = mousePos.y; //g_InputEngine::Instance().GetY(); mouseX = mouseX - m_HalfWidth; mouseY = mouseY - m_HalfHeight; mouseFloat = mouseX * C_MOUSESMOOTHINGFACTOR; g_Scene::Instance().GetCamera()->RotateYaw(-mouseFloat); mouseFloat = mouseY * C_MOUSESMOOTHINGFACTOR; g_Scene::Instance().GetCamera()->RotatePitch(mouseFloat); //Reset mouse to center on the screen SetCursorPos(m_HalfWidth,m_HalfHeight); }
So, this is the Mouselook function of the prototype spacegame, which I developed for fun, and back, what I did was change it instead of GetCursorPos(&mousePos);
. This will get the current cursor position no matter when your input code updates the location of the mouse cursor. The rest of the math in the function is for sensitivity and actual camera rotation only. Hope this code helps you work a bit.
Let me know if you need more explanation.
Edit: I just remembered the reason I did this. This is because the screen flickered and it moved, but the input mechanism will be updated by calling SetCursorPos()
because I used WM_MOUSEMOVE to update the input mechanism. I'm not sure how you get your input, but it will still help you.
source share