while(1) {
runWindowMessages();
runGameCodeIncludingMouseLook();
if(!mouseMoved) {
mouseX=mouseY=0;
}
mouseMoved = false;
}
But this just makes things jerky, since when the mouseX and mouseY are sampled, most of the time they are getting (0,0). (This is with vsync off btw.)
Thanks.
Raw mouse input, how to zero values when not moving?
Hi,
I'm using the win32 raw mouse input within the window messageProc, so when it receives the WM_INPUT message I then set my mouseX and mouseY values. My problem is that those values are only set when the mouse is moved, so that they aren't set to 0 when the mouse isn't moving.
This is causing problems with my mouse look, making it drift around the place. I tried setting a mouseMoved flag to true when the mouseX and mouseY variables are set, and then in my main loop I am doing this:
I do it like this:
Works like a charm.
Edit:
Oh wait, mouse look
Then you should do it like this:
//in the main/game loop if (mouse.lmb) xRot += mouse.x - mouse.xOld; if (mouse.lmb) yRot += mouse.y - mouse.yOld; mouse.xOld = mouse.x; mouse.yOld = mouse.y;//in the message loop case WM_MOUSEMOVE: mouse.x = GET_X_LPARAM (lParam); mouse.y = GET_Y_LPARAM (lParam); break;
Works like a charm.
Edit:
Oh wait, mouse look
Then you should do it like this:
Get the mouse coords from a variable that is updated in message cycleSnap mouse to the middle of the screenSubtract screen center coordinates from previously retrieved ones
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement