Jump to content
  • Advertisement
Sign in to follow this  
nsto119

[.net] System.Windows.Forms input not sufficient for games?

This topic is 3485 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

I have a pretty simple input system that handles input callbacks (KeyDown, KeyUp, etc) but it seems like it's not responding fast enough. I can click twice in rapid succession and the event will only be invoked once. Is there another method for handling input that would be better? Also, strangely enough the KeyDown event is invoked twice every time I press a key... any idea what might be causing that?

Share this post


Link to post
Share on other sites
Advertisement
I use the KeyDown and KeyUp events to handle keyboard input and can't say I've encountered the issues you have. Do you have other controls on the form? Do you set the e.Handled after handling the events? Have you overridden IsInputKey on the form? Are you using PreviewKey at all?

The only bit of extra magic I find myself needing is for joystick input, for which I P/Invoke the old winmm API.

Share this post


Link to post
Share on other sites
Okay, I figured out the multiple key press problem (it was my fault, imagine that) and now everything works fine with the keyboard.

However, the mouse still doesn't respond as fast as I can click it, which I would really like to happen. Any ideas?



Ooh, also, how can I disable key repeat and delay? Is that something I'll have to P/Invoke from the Win API?

Share this post


Link to post
Share on other sites
Personally, I store the state of a key within my application; for example, I'll have a bool FireButton; that is set to true on KeyDown and false on KeyUp. That way you could detect its first event by checking if it used to be false before you set it to true.

Share this post


Link to post
Share on other sites
Quote:
Original post by benryves
Personally, I store the state of a key within my application; for example, I'll have a bool FireButton; that is set to true on KeyDown and false on KeyUp. That way you could detect its first event by checking if it used to be false before you set it to true.


Ah yes, that's a much better solution. Thank you.

Any ideas on getting mouse clicks to respond faster?

Share this post


Link to post
Share on other sites
I haven't encountered the problems you mentioned, I'm afraid. Maybe you could post an example snippet of what you're doing so we could see what it's not doing properly?

Share this post


Link to post
Share on other sites
Quote:
Original post by id0001
maybe it is fireing the doubleclick event instead of the click event when you click too fast.


Yup, just tested it and that's exactly what it's doing. Thanks :D

Share this post


Link to post
Share on other sites
Quote:
Original post by nsto119
Quote:
Original post by id0001
maybe it is fireing the doubleclick event instead of the click event when you click too fast.


Yup, just tested it and that's exactly what it's doing. Thanks :D

It is worth noting you can turn off double-click support if that is a problem for your game. I believe the snippet:
this.Setstyle(Controlstyles.StandardDoubleClick,false);
should suffice.
[Edit: This method presumes that this is a class that extends Control. If it doesn't, I'm not sure that it'll work.]

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!