Skip to main content
GameDev.net gamedev.net
🔒 Locked

Basic DirectInput question ...

Started by FearedPixel Nov 26, 2002 at 12:22 PM 6 replies 350+ views
Original Post
FearedPixel
FearedPixel
What benefits do we get from using directinput for input? Why not just use the standard windows api functions to get keyboard/mouse input? If the only devices I need to use is mouse/keyboard, why use DirectInput?
acidkobra
acidkobra
You are evil for even suggesting that you use the windows api functions!!! just kidddin but really directinput allows for better control (as far as setting the co-op lvl). I think when you get down to it it''s easier and faster. But i suppose for some things using the windows api might be better. But if you''re making a quake or somthing use directinput.

The only thing that defines man from animal is our knowledge of computer programming.
The only thing that defines man from animal is our knowledge of computer programming.
FearedPixel
FearedPixel
I hope I wasn''t suggesting that i use windows api functions for input, because I dont. I just wanna know the advantages of using DirectInput.
alnite
alnite
You can use keyboard, mouse, and joysticks easily. Some people say DirectInput is faster, but I don''t know. Tried API, tried DirectInput, can''t see the difference.

But I think DirectInput allows you to read every single key in your keyboard, including Ctrl, Alt, Shift. You can detect whether a user press a shift button..just the shift.


My compiler generates one error message: "does not compile."
Jim Adams
Jim Adams
Mostly because of speed. The Windows API generally works through the message queue, meaning that any input has to wait to be processed, whereas DirectInput immediately queries the devices for their current state. You can, however, use hooks in certain cases, but again you are having to wait for device messages to work through every hook until it eventually gets to yours.



Jim Adams
home.att.net/~rpgbook
Author, Programming Role-Playing Games with DirectX
and Focus On: Advanced Animation with DirectX

Drath
Drath
If I am correct, using the API functions would only retrieve the status of every thing once per loop? (assuming the program accesses the message loop once per frame) Then an advantage would be you could accuratly count how many times a key was pressed which is needed for some games. This is more of a question than an answer for its something I''m wondering about.
kressilac
kressilac
I've found that Direct Input was pretty easy to setup and you did not have to deal with the Windows I/O. When you use Direct Input in Exclusive modes you can avoif the windows message pump all together. The mouse messages are not sent to it.

[snipped problem I was having with Direct Input]

I take it back. Direct Input is pretty easy if you don't make a junior programming error by not accessing the buffered array improperly.



Kressilac


[edited by - kressilac on November 26, 2002 11:07:49 PM]
Derek Licciardi (Kressilac)Elysian Productions Inc.
md_lasalle
md_lasalle
quote:
Original post by kressilac

I take it back. Direct Input is pretty easy if you don''t make a junior programming error by not accessing the buffered array improperly.




Hi, i have problems with accessing the buffered arrays... would you look at my thread...please !!!

http://www.gamedev.net/community/forums/topic.asp?topic_id=220457

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.