Thread: DirectInput

  1. #1
    Registered User
    Join Date
    Oct 2003
    Posts
    83

    DirectInput

    Okay - I'm getting into OpenGL Game programming. OpenGL is a graphics only library. What about input? You can use three things that I know of:

    DirectInput: Supposed to be hard to learn, Microsoft only

    GLUT: Flexibility supposed to be limited. (PS can I use the Win32 API for everything, but use GLUT for input? How?)

    Win32 API: Lag my friend, lag.

    But also what I've been thinking - although Linux/Unix is a great OS, it isn't a gaming OS. Windows, sadly, is the gaming OS of choice. Is portibility really that important?

    So what should I use? Win32? GLUT? DI? What are the pros/cons of each.

    Also: How can I use GLUT with the win32 API? Is it possible?

    PS: DirectSound vs FMOD. What are your thoughts?

    EDIT: Is there anything else I can use for input?

  2. #2
    Registered User glUser3f's Avatar
    Join Date
    Aug 2003
    Posts
    345
    I use DI, not that hard to learn, at least not as hard as Direct Audio, and you can use an input class with functions like keyDown and getMouseMovement, so you can easily port it to other platforms later.
    something like this:
    http://www.two-kings.de/tutorials/dinput.html

    EDIT:
    > FMOD vs. Direct Audio
    FMOD wins hands down, portable, extremely easy to use, supports a wide range of formats (unlike DA's wave and midi)
    Last edited by glUser3f; 01-06-2004 at 05:32 PM.

  3. #3
    Banal internet user
    Join Date
    Aug 2002
    Posts
    1,380
    Windows game, eh?

    DirectX is wonderful, assuming you're a Windows-only developer. Honestly, they're not difficult APIs to learn. DirectSound has a lot of neat functionality, and DirectInput is very fast.
    Last edited by BMJ; 01-06-2004 at 05:57 PM.

  4. #4
    Registered User
    Join Date
    Oct 2003
    Posts
    83
    I'm not a Windows only-developer - I use Linux. But. For Games, linux portability isn't that important. No one plays any REAL games on Linux. Open-source is great, I love it! But in the gaming world... commercial rules. That's just my opinion. I hear OpenGL is easier to learn, and is more functional. I will probobly learn Direct3d after OpenGL, and my OpenGL book teaches DirectInput and DirectSound.

    Gaming is the only thing that fast multi-hardware input would really be used - and Windows is the only gaming platform - I guess DirectInput is the way to go.

    As for sound, I already learned the basics of FMOD. It's pretty nice.

  5. #5
    Banal internet user
    Join Date
    Aug 2002
    Posts
    1,380
    Originally posted by punkrockguy318
    I hear OpenGL is easier to learn, and is more functional. I will probobly learn Direct3d after OpenGL, and my OpenGL book teaches DirectInput and DirectSound.
    Direct3D 8/9 is not as hard to learn as the older interfaces. The modern Direct3D/OpenGL argument is less based on one being "better" than the other so much as preference, target-platform, and feature differences. Again though, that's IMO.

    I guess, when I work with a Windows game, I tend to stick to straightforward "DirectX", the modern generation is formidable, and many developers agree.

  6. #6
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    Um, just because you use the Win32 API doesn't mean input has to be laggy. Sure it is if you just use the msg handler, of course it will be. Check out:

    GetAsyncKeyState

    That will get you the current state of the keys ( and buttons ) asynchronously. You won't be seeing much lag if any with this but you can use whatever you want obviously. Just trying to broaden your horizons.
    "...the results are undefined, and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces." --Scott Meyers

  7. #7
    Registered User
    Join Date
    Oct 2003
    Posts
    83
    Originally posted by MrWizard
    Um, just because you use the Win32 API doesn't mean input has to be laggy. Sure it is if you just use the msg handler, of course it will be. Check out:

    GetAsyncKeyState

    That will get you the current state of the keys ( and buttons ) asynchronously. You won't be seeing much lag if any with this but you can use whatever you want obviously. Just trying to broaden your horizons.
    Yeah - I did some more reasearch. Looks like a nice function to me. What is faster iyo? di or gaks?

  8. #8
    Registered User
    Join Date
    Oct 2003
    Posts
    83
    Also.. What does async stand for?

  9. #9
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    Aysnc=asynchronous input - able to press multiple keys at once and respond to each accordingly.

    DirectInput has very little to do with DirectX or Direct3D. Yes it is a part of the entire API but the similiarities end there.

    DirectInput is fairly easy to get up and running and once it is, it is very simple to add mouse, keyboard, joystick, and/or any gaming device that is compatible with DX including wheels, pedals, etc.

    DirectInput works directly with the hardware so it is always going to be faster and have lower latency than any equivalent API calls. For games, don't use the API for retrieving input from the players - period.

  10. #10
    Banal internet user
    Join Date
    Aug 2002
    Posts
    1,380
    Plus, DirectInput allows you to get the state of any key, not just those defined with virtual keycodes, and it also allows you to multithread input handling objects... and like Bubba said, almost all Windows-compatible devices have a DirectInput driver which gives you complete control of the input device at the lowest-level possible.

  11. #11
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    I would use DirectInput if I were you. I have used it on the majority of the games I have written/helped written. I was merely giving you another option for future reference.
    "...the results are undefined, and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces." --Scott Meyers

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. DirectInput
    By Lionmane in forum Windows Programming
    Replies: 4
    Last Post: 11-12-2005, 11:43 PM
  2. DirectInput and Dev-C++
    By Niara in forum Game Programming
    Replies: 2
    Last Post: 03-11-2005, 10:20 AM
  3. DirectInput woes again....
    By VirtualAce in forum Game Programming
    Replies: 4
    Last Post: 05-25-2004, 03:02 PM
  4. DirectInput or WM_KEYDOWN question
    By Mecnels in forum Game Programming
    Replies: 4
    Last Post: 03-18-2003, 06:45 AM
  5. My DirectInput tutorial....
    By jdinger in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 06-18-2002, 11:32 PM