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

Started by
7 comments, last by nerd_boy 15 years, 3 months ago
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?
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.

[Website] [+++ Divide By Cucumber Error. Please Reinstall Universe And Reboot +++]

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

[Website] [+++ Divide By Cucumber Error. Please Reinstall Universe And Reboot +++]

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

[Website] [+++ Divide By Cucumber Error. Please Reinstall Universe And Reboot +++]

maybe it is fireing the doubleclick event instead of the click event when you click too fast.
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
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.]

This topic is closed to new replies.

Advertisement