Sign in to follow this  
Followers 0
svetpet

DirectInput too fast

13 posts in this topic

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?
0

Share this post


Link to post
Share on other sites
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.
0

Share this post


Link to post
Share on other sites
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.
0

Share this post


Link to post
Share on other sites
You don't want to check if the keys are down in those cases. Check if they're pressed instead :)
0

Share this post


Link to post
Share on other sites
How can i acheive this?
So far my code to detect this is
[code]

bool DirectInput::mouseButtonDown(int button)
{
return (mMouseState.rgbButtons[button]) != 0;
}
[/code]
this detects if mouse button is down. How to check if it is pressed only?
0

Share this post


Link to post
Share on other sites
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.
1

Share this post


Link to post
Share on other sites
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.
0

Share this post


Link to post
Share on other sites
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.
0

Share this post


Link to post
Share on other sites
[url="http://msdn.microsoft.com/en-us/library/ms632585(v=VS.85).aspx"]Windows provides functions[/url] 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.
0

Share this post


Link to post
Share on other sites
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.
0

Share this post


Link to post
Share on other sites
Isn't Direct Input deprecated now because it doesn't handle high polling rates of modern keyboards and mice?
0

Share this post


Link to post
Share on other sites
[url="http://www.gamedev.net/blog/233/entry-1567278-reasons-not-to-use-directinput-for-keyboard-input/"]Reasons.[/url]
0

Share this post


Link to post
Share on other sites
[quote]
Yeah but that ain't using window messages.[/quote]
Apologies, I meant discouraged in favour of the standards Windows input APIs.

[quote]
Isn't Direct Input deprecated now because it doesn't handle high polling rates of modern keyboards and mice? [/quote]
[url="http://archive.gamedev.net/community/forums/mod/journal/journal.asp?jn=300672&reply_id=3074105"]Here[/url] is a comprehensive list. It also contains [url="http://msdn.microsoft.com/en-us/library/ee418864.aspx"]this link[/url] containing this quote from Microsoft:
[quote]
DirectInput is a set of API calls that abstracts input devices on the system. Internally, DirectInput creates a second thread to read WM_INPUT data, and using the DirectInput APIs will add more overhead than simply reading WM_INPUT directly. DirectInput is only useful for reading data from DirectInput joysticks; however, if you only need to support the Xbox 360 controller for Windows, then use XInput instead. Overall, using DirectInput offers no advantages when reading data from mouse or keyboard devices, and the use of DirectInput in these scenarios is discouraged.[/quote]
0

Share this post


Link to post
Share on other sites
[quote name='rip-off' timestamp='1301587637' post='4792614']
[quote]
Yeah but that ain't using window messages.[/quote]
Apologies, I meant discouraged in favour of the standards Windows input APIs.
[/quote]

Oh I only thought it was favored to use window messages instead of DirectInput. Replacing my DirectInput code with messages would be hard, but now it'll get easy. :)
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0