Jump to content

View more

Image of the Day

Boxes as reward for our ranking mode. ヾ(☆▽☆)
#indiedev #gamedev #gameart #screenshotsaturday https://t.co/ALF1InmM7K
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

DirectInput too fast

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
13 replies to this topic

#1 Illuminated   Members   

171
Like
0Likes
Like

Posted 31 March 2011 - 03:01 AM

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?

#2 mhagain   Members   

13153
Like
0Likes
Like

Posted 31 March 2011 - 03:58 AM

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.

It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.


#3 Illuminated   Members   

171
Like
0Likes
Like

Posted 31 March 2011 - 04:11 AM

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.

#4 simpler   Members   

927
Like
0Likes
Like

Posted 31 March 2011 - 05:05 AM

You don't want to check if the keys are down in those cases. Check if they're pressed instead :)

#5 Illuminated   Members   

171
Like
0Likes
Like

Posted 31 March 2011 - 05:18 AM

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?

#6 Adam_42   Members   

3585
Like
1Likes
Like

Posted 31 March 2011 - 06:37 AM

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.

#7 rip-off   Moderators   

10885
Like
0Likes
Like

Posted 31 March 2011 - 07:57 AM

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.

#8 simpler   Members   

927
Like
0Likes
Like

Posted 31 March 2011 - 08:34 AM

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.

#9 rip-off   Moderators   

10885
Like
0Likes
Like

Posted 31 March 2011 - 09:04 AM

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.

#10 simpler   Members   

927
Like
0Likes
Like

Posted 31 March 2011 - 09:36 AM

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.

#11 Malal   Members   

118
Like
0Likes
Like

Posted 31 March 2011 - 09:40 AM

Isn't Direct Input deprecated now because it doesn't handle high polling rates of modern keyboards and mice?

#12 Evil Steve   Members   

2016
Like
0Likes
Like

Posted 31 March 2011 - 10:07 AM

Reasons.

Steve Macpherson
Senior Systems Programmer

Rockstar North


#13 rip-off   Moderators   

10885
Like
0Likes
Like

Posted 31 March 2011 - 10:07 AM

Yeah but that ain't using window messages.

Apologies, I meant discouraged in favour of the standards Windows input APIs.

Isn't Direct Input deprecated now because it doesn't handle high polling rates of modern keyboards and mice?

Here is a comprehensive list. It also contains this link containing this quote from Microsoft:

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.



#14 simpler   Members   

927
Like
0Likes
Like

Posted 31 March 2011 - 11:07 AM

Yeah but that ain't using window messages.

Apologies, I meant discouraged in favour of the standards Windows input APIs.


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. :)




Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.