twilightsupport
08-28-2004, 04:18 AM
Does anyone know a way to detect the speed of the mouse? By that I mean: how quickly is the mouse being moved at a given moment in the X and Y directions.
Of course it sounds simple... take the current position minus last position, take the elapsed time, divide the two and you're done. The problem with that is that the mouse will go out of the window eventually or hit the side of the screen and stop moving. So it seems that you need to keep re-centering it's position.
I've tried setting the mouse position on every frame back to the screen center and seem to be getting random or inconsistent results. Sometimes, even though I'm moving the mouse left, I get an occasional glitch where it appears to have moved right. And vice versa. I think this may be because I'm setting the mouse position too often. Not sure.
Is there an easy way to just get the speed of the mouse without having to make guesses and reset the position continuoulsy?
Thanks
Of course it sounds simple... take the current position minus last position, take the elapsed time, divide the two and you're done. The problem with that is that the mouse will go out of the window eventually or hit the side of the screen and stop moving. So it seems that you need to keep re-centering it's position.
I've tried setting the mouse position on every frame back to the screen center and seem to be getting random or inconsistent results. Sometimes, even though I'm moving the mouse left, I get an occasional glitch where it appears to have moved right. And vice versa. I think this may be because I'm setting the mouse position too often. Not sure.
Is there an easy way to just get the speed of the mouse without having to make guesses and reset the position continuoulsy?
Thanks