Jump to content
  • Advertisement
Sign in to follow this  
WuTz

DirectInput problem...

This topic is 3333 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi there! I've got a problem with DirectInput. Or... Its less a problem than a question. Can I ask DirectInput:"Is my MouseButton1 pressed or not?" I ask, because I only get MouseButton Events when the ButtonState changed. So in the Frame I press the Mouse is bMouse1=true. But only for that frame! I build in something to Toggle a Bool-Value based on the State-Chages. This would work for Fullscreen games, but mine is running in a window! So when I press the button outside of the Viewport, hold it, and drag it back into the viewport the Toggleing changed! When the Mouse is up it say: "Mouse1 is down! And when its down: "Released it!". It would be better when I could check every frame that my mouse is pressed or not. Any solutions?

Share this post


Link to post
Share on other sites
Advertisement
Iam using it only for the buttons. I've read that the Windows messages are to slow for fast games. But when Ican use them I know what I have to do :)

DirectInput for the Keyboard is ok, isn't it?

Share this post


Link to post
Share on other sites
Quote:
Original post by WuTz
Iam using it only for the buttons. I've read that the Windows messages are to slow for fast games. But when Ican use them I know what I have to do :)

DirectInput for the Keyboard is ok, isn't it?
Nope - it's just as bad. Window messages are pleanty fast for a game - you can't react to input more often than once per frame, and you process window messages once per frame, so it'll be fine.
It'll take a fraction of a millisecond to process all of your window messages. And, if you look at the link I posted you'll see that DirectInput is actually slower - all it does is create a new thread to read window messages - so you have the overhead of an extra thread as well.

Share this post


Link to post
Share on other sites
Ah. Ok. I will change this in my Engine. Thx :)

Are the Windows-Key-Messages like when I press a Key in windows? I mean eg. :

D *wait* DDDDDDDDDDDDDDDDDDD

I dont want that...

Share this post


Link to post
Share on other sites
Quote:
Original post by WuTz
Ah. Ok. I will change this in my Engine. Thx :)

Are the Windows-Key-Messages like when I press a Key in windows? I mean eg. :

D *wait* DDDDDDDDDDDDDDDDDDD

I dont want that...
You'll receive a WM_KEYDOWN for the first 'D', then there'll be a delay, then you'll receive 19 WM_KEYDOWN messages for the repeated 'D's, then a WM_KEYUP.

It's common to keep an array of 256 bools which you set to true when you get a WM_KEYDOWN for that key, and set to false when you get a WM_KEYUP. That way you can always know the current state of the keyboard.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!