Skip to main content
gamedev.net
🔒 Locked

mouse coordinates problem

Started by Lord_Vader 5 replies 1.2k views
Original Post
Lord_Vader
Lord_Vader
Greetings, Until now when I was rotating my models, I was taking the coordinates of the cursor using something like:

//In WindowProc function
case WM_MOUSEMOVE:
{
        mouse_x = LOWORD(lParam);          
	mouse_y = HIWORD(lParam);	
}
break;


and used theese coordinates as rotations angles. The problem is that when the cursor reaches the end of the monitor the rotation of the model inevitably stops. What I want is the rotation(like an FPS game) to continue(making loops) no matter how I move the mouse. How can I achieve this? Thanks
Illco
Illco
WM_MOUSEMOVE is a window message i.e. it is only sent to your window as long as the event of movement happens within the window's area. This causes mouse movements outside your window to be lost.

With GetCursorPos() you can get the mouse position asynchronously regardless of whether it is in your window. If you use this function in a separate update() function of yours (separate from the window message handling function(s)) you will be ok.

Greetz,

Illco
dave
dave
If you want to be able to continually look in a direction, ie have the mouse run off the screen into infinity, you could use SetCursorPos() to move the cursor back to the center of the screen every tenth frame or something. This way the cursor will never reach the edge.
reana1
reana1
It looks like you can also capture the mouse: SetCapture
But there may be a reason to avoid that (interfering with other programs? anyone?)
GetCursorPos() sounds better though.
Tadd- WarbleWare
TheAdmiral
TheAdmiral
I sorely hope this game is running in exclusive mode. Any application that moves my mouse cursor around in Windowed mode is one that's about to be uninstalled for good.

May I suggest you have a look at some of the input libraries? DirectInput and its cousins make life easier for you in cases like these, and will often offer high-precision input (potentially way above the screen resolution). Google High-DPI mouse input if you're interested.

Regards
Admiral
Ring3 Circus - Diary of a programmer, journal of a hacker.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.