DirectInput: Is it worth it?

Started by
7 comments, last by Bosh 18 years, 10 months ago
I'm debating on whether or not to use DirectInput in a simple FPS game. What do you guys / the professional game developers use? On one hand, it seems like DirectInput would be faster than windows messages since it has direct access to the devices. But, how much faster is it? Also, it seems like it would be better on picking up keys that are pressed, held for short times, then released. Windows reports an initial key press, then a short pause, then begins repeatedly sending the key press (atleast, I think so?). If you are checking for key states every frame, DirectInput seems like it would be better. On the other hand, DI doesn't seem very convenient. It ignores all user settings like mouse acceleration, key repeat rates, swapped buttons, etc. With those pros/cons, what do you guys/gals generally use for input to handle your primary control schemes in games?
Advertisement
Yes Direct Input is worth it and is just about the best thing there is (if not the only thing). It does a lot more than the windows messages can. I seriously doubt any professional game would use windows messages. But yes, it is quite unconveient (as most Direct-Anything™ is [grin]) but it's a lot better than Windows messaging. Anything that the messages can do, DI can do, but a lot better. No contest between the two really... Just my opinion though [smile] if you are making a really simple game and won't need to configure your input at all, or remap any keys, or if the precision of key strokes does not matter, then the windows messages should be enough - if not, DI it is!
Quote:Original post by Drew_Benton
But yes, it is quite unconveient (as most Direct-Anything™ is [grin]) but it's a lot better than Windows messaging. Anything that the messages can do, DI can do, but a lot better.

Except with text input. If you want to do this, I recommend that you sit on the WM_CHAR message. Windows does a lot of stuff with text input that DInput doesn't do - like repeating keys, IME, ect...
Dustin Franklin ( circlesoft :: KBase :: Mystic GD :: ApolloNL )
Can you use DirectInput and still receive WM_CHAR messages? It seems to me that all WM_KEYDOWN messages are supressed by DirectInput, but is this the case with WM_CHAR? And if it is, how can you use DirectInput and windows messaging simulatenously?
just consider using the buffered input of DI and forget about your WM_Messages. Otherwise youll have some trick-coding to do in order to maintain input modularity. To answer your original question, yes DI is worth it and works well. its also very simple to implement, as well as simple to abstract to a point where reuse is viable.
"Let Us Now Try Liberty"-- Frederick Bastiat
Yeah, I have a DirectInput system in place and can swap it out w/ forwarding windows messages.. just wondering which one is worth it :) It looks like I'll stick with DI.
Quote:
On the other hand, DI doesn't seem very convenient. It ignores all user settings like mouse acceleration, key repeat rates, swapped buttons, etc.

For most games that is very useful. In general, users have set those settings to be convenient for normal applications; for games usually different settings are more useful. You can set those in your application though (via DI) and they will be stored per game in the user profile.

Besides, DI also does device abstraction for you which imho is the best thing of all. It means that you do not have to specifically support all kinds of input hardware (this-and-that joystick/padthing); you can just say I need such-and-such axes and these buttons and I will use them much like this and DI will set up the best mapping on the user's hardware (which is adjustable).

Greetz,

Illco
I use both DInput and windows messaging. They both have pros and cons, and do not interfere with each other.
Windows messages has great keyboard support compared to DirectInput (unless you use buffered data, which I still haven't fully figured out, but for basic games it doesn't matter). But, mouse support and joystick support blow away windows messaging

This topic is closed to new replies.

Advertisement