Skip to main content
GameDev.net gamedev.net
🔒 Locked

Mouse problem

Started by Allebarde Apr 15, 2002 at 4:11 AM 0 replies 150+ views
Original Post
Allebarde
Allebarde
Hi! I have again a mouse Problem: int a= mouseState.lY; int b= mouseState.lX; when I debug, i always have a and b =0: is it normal? What kind of informations contain lX and lY?? If my window is 800*600, are mouseState.lX and mouseState.lY between 0-800 and 0-600? Thanks for your help. Bye!
Zeke
Zeke
Ive just got done reading a chapter about direct input this morning so I might be able to help ya.

Firstly when you set up the mouse input you have to specify whether you want absolute values or relative values. If you have set up absolute values (which means the actual position of the mouse) then I assume yes the results will be within those ranges you stated. If however you have specified relative values then the values you get will be relative to a position i.e. if the mouse is at 100,400 and you move it right 5 units then the values you get from mouseState will be 5,0.

Im not sure why you are getting 0 every time though. I might sound stupid here but you are actually moving the mouse around right? Because if you have specified relative values and you dont move the mouse around then a and b will be 0 every time (and in fact unless you catch it the frame after you move the mouse it will give you 0's because i assume for relative values it changes the position it uses to the new position every frame so what it actually does is give you the change in x and y every frame-giving you 0,0, unless you move the mouse just before you step into the function).

Hope ive helped

p.s. if you arent using direct input just ignore me

edit: Ive just found out that I was a bit confuddled about that absolute/relative values part, that is for something else. For mouse input the mouseState.lX and mouseState.lY are always relative to the last position. So if you want the actual coordinates of the cursor you will need to keep track of it yourself (i.e. global/class variables that increase/decrease according to the changes).
If you want to check to make sure the values arent _always_ 0, do something like:

char buffer[20]={0};
sprintf(buffer, "MouseX=%.2f,
MouseY=%.2f",mouseState.lX,mouseState.lY);
OutputDebugString(buffer);

This will then write out the those values to the debug window each frame (OutputDebugString might be MSVC specific so if you arent using that compiler you will have to find the equivalent for yours). Because the problem I think you are having is while you are debugging the actual game doesnt get the mouse input (because the compiler has focus) so you need to see these values while the game is running properly if you see what I mean.


[edited by - Zeke on April 15, 2002 9:53:59 AM]
Just my thoughts take them as you will. "People spend too much time thinking about the past, whatever else it is, its gone"-Mel Gibson, Man Without A Face

Topic Locked

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

Sign in to reply to this topic.