Skip to main content
gamedev.net
🔒 Locked

Mouse Probs.

Started by Blue*Omega Apr 1, 2000 at 9:43 PM 0 replies 1.7k views
Original Post
Blue*Omega
Blue*Omega
Hi! I''m new to this forum but what I''ve seen so far has been VERY helpful... So I was wondering if anyone knew the answer to my problem. In my little engine i have a routine set up to capture mouse movement and clicks. Here''s the code. case WM_MOUSEMOVE: mousex = LOWORD (lParam) - 400; mousey = HIWORD (lParam) - 300; mouseclk = wParam; //SetCursorPos (400, 300); break; This works fine but... If I un-comment the SetCursor my program crashes! I want to set up a Quake II/III style console so I am trying to get the mouse to recenter it''s self whenever it is moved (by the way, this program runs in 800x600). I just don''t know how to get the mouse to center without SetCursor! Can anyone help me??? Blue*Omega :)
Big Al
Big Al
Okay,
Let's See here:

case WM_MOUSEMOVE:
mousex = LOWORD(lParam) - 400;
mousey = HIWORD(lParam) - 300;
mouseclk = wParam;
SetCursorPos(400,300);
break;

I assume you are letting Windows "blit" your cursor for you.

Hence: Whenever you call SetCursorPos() it sends the WM_MOUSEMOVE call to your app, resulting in a never ending loop. (I think)

Thus this code should fix it:
case WM_MOUSEMOVE:
mousex = LOWORD(lParam) - 400;
mousey = HIWORD(lParam) - 300;
mouseclk = wParam;
if ((LOWORD(lParam) != 400) /* OR MARKS */ // (HIWORD(lParam) != 300))
SetCursorPos(400,300);
break;


Edited by - Big Al on 4/3/00 2:51:09 AM

Topic Locked

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

Sign in to reply to this topic.