DirectInput too fast

Started by
12 comments, last by simpler 13 years ago
Is DirectInput detecting input too fast?
I got both DirectInput and win32 input( with msgProc) and it seems to me that DirectInput just detects it too fast.
Anyone got the same observation?
Advertisement
Waht do you mean by "detecting input too fast"? Do you mean that your mouse movements are faster (i.e. cover more space in the same time) when you use DirectInput? Or is this to do with the keyboard? Or do you mean something else?

If you mean the mouse movements seem faster then the answer is that sometimes they are and sometimes they aren't, and it all depends on your hardware.

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.

For instance i got something like this:
If( Dinput->keyDown(DIK_ESC) )
{
showMenu();
}

and when i press escape it kinda blinks and must press escape and unpress it really fast in order to showMenu();

same with mouse input - i got one checkbox.
And i test if the mouse button is down and over the checkbox and if it is i check the checkbox or uncheck it of it is already checked.
But when i click it blinks - checks, unchecks, checks until it decides to stop and again must click and unclick really fast in order to check/uncheck it.
You don't want to check if the keys are down in those cases. Check if they're pressed instead :)
How can i acheive this?
So far my code to detect this is


bool DirectInput::mouseButtonDown(int button)
{
return (mMouseState.rgbButtons[button]) != 0;
}

this detects if mouse button is down. How to check if it is pressed only?
Compare the state in the current frame to that in the previous frame. If it's changed then either the button has been pressed or it's been released. The current state will tell you which one.
Why are you using DirectInput? Responding to state changes is easier under a normal window procedure. AFAIK DirectInput is deprecated in favour of windows messages except for joysticks.
I think it's easier to use DirectInput in many cases. With DirectInput you can check to state of keyboard + mouse from where ever you want in your code if you simply have a global DirectInput instance. But when you are using windows messages you have to take arguments in the functions where you have to check keyboard + mouse states.

It might be better to use windows messages, but easier with DirectInput since you don't have to have any good structure in your program to use it. Hope you understand what I mean.
Windows provides functions like GetKeyboardState(), GetKeyState() and GetAsyncKeyState() (mouse buttons are considered virtual keys), and it would appear that GetMouseMovePointsEx() will provide the current mouse position. I'm not a Win32 programmer, but it would appear that these functions would meet your needs.
Yeah but that ain't using window messages. Or is it favored to use those functions as well? They do the same thing, so it doesn't feel like it matter that much to use them instead of DirectInput imo.

This topic is closed to new replies.

Advertisement