Sign in to follow this  

Best way to do mouselook?

Recommended Posts

Hi everyone,


I've tried to use the following code for allowing my mouse to move the camera look direction:


case WM_MOUSEMOVE: //Mouse movement for camera
mouseDeltaX = currMousePos.x - lastMousePos.x; mouseDeltaY = currMousePos.y - lastMousePos.y; //Find how much the mouse has moved
lastMousePos = currMousePos;
SetCursorPos(GetSystemMetrics(SM_CXSCREEN)/2, GetSystemMetrics(SM_CYSCREEN)/2); //Reset the cursor to the window centre


This doesn't seem to work though. I think the reason is that the function SetCursorPos() also causes a WM_MOUSEMOVE message to be sent, which means that the net movement each time is zero. What's the best way to make a simple mouselook function in C++? All I need at the moment is to determine how much the mouse has moved from its last position every time it moves. I think when I get that sorted, I will be able to take it from there!



Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this