Sensing/polling mouse movement

Started by
7 comments, last by ejthayer 17 years, 12 months ago
I'm sure many of you are thinking that doing this is easy. But that is really not the case if you want to do it well. The problem I am having is sluggish mouse movement. The DirectX GetDeviceState has a major problem. The mouse info it returns is actually about 4 to 5 frames old instaed of returning the current mouse state as the docs say it does. This slightly old info results in a very sluggish movement to the mouse. Games that I have played that have this problem are Hitman 2, Grand Theft Auto SA, and Serious Sam. I'm sure others do as well but I try not to play too much because it takes away from work time. World of warcraft on the other hand has this problem solved. They sense mouse input so that even if the game is running at 10 fps the mouse still moves around the screen or moves the viewpoint perfectly. This greatly increases the quality of game play in low FPS situations. Does anyone know or have suggestions on how to get the current exact mouse position from windows?
Advertisement
Hey ejthayer,

Have you tried getting to the mouse through the vanilla GetCursorPos function? Not sure if GetDeviceState has overhead in DirectX's interfacing system, but I guess it might be worth a shot...unless, of course, GetDeviceState on the mouse is just a wrapper for GetCursorPos...a little bit of research didn't turn up anything for me, but I just googled it/MSDNed it and looked at the first few results.

Hope that helps,
Aviosity
Maybe the mouse cursor is rendered by DirectX which in case of low framerates will slowdown the mouse as well, unlike The Sims 2 which I think changes the windows cursor instead which isn't rendered by the application. I am guessing WoW does this too.
http://sourceforge.net/projects/pingux/ <-- you know you wanna see my 2D Engine which supports DirectX and OpenGL or insert your renderer here :)
Hi, I'm very very very newbie but I'm programming an application and the only way ?ve founded to catch the mouse position, and events is throught windows API, using uMsg and casting it in a switch/case WM_LBUTTONDOWN....

If I'm doing something wrong, please tell me.

Sorry for my bad writting.
I spent most of my money on booze, women and cars. The rest I just wasted. George Best
Yes I have tried the GetCursorPos, it returns the same old data that DirectInput does. Currently I'm trying some things in assembler to get the up to date mouse info.

Using the windows message system to get mouse info works OK in some cases but is usually the slowest way to go.
Is this a single-threaded application? If not, there may be an issue with that, where one thread is in a long processing loop and doesn't return the mouse info. But now I'm just shooting in the dark, maybe someone with more experience has an answer?

Aviosity
Quote:Original post by falledAngel
Hi, I'm very very very newbie but I'm programming an application and the only way ?ve founded to catch the mouse position, and events is throught windows API, using uMsg and casting it in a switch/case WM_LBUTTONDOWN....

If I'm doing something wrong, please tell me.

WM_MOUSEMOVE is probably more suitable, as it doesn't require the user to click; but, as the OP noted, messaging is the slower approach.


Quote:
Sorry for my bad writting.

Your writing is legible, which is what really matters[smile].

OP, have you considered the Raw Input API before resorting to ASM?
No I have do not know anything about the Raw input API, what can you tell me about it?
Thnaks, I found info on the Raw input API in the microsoft website, I will see if it solves the problem.


This topic is closed to new replies.

Advertisement