DirectInput or WndProc?

I've noticed the in the August SDK (and previous ones) that all of the samples use a WndProc function to handle keyboard and mouse input. I assume there is a good reason that DirectInput is not being used.
Could someone please enlighten me as to what it is....
Does using WndProc give better performance than DirectInput



Answer this question

DirectInput or WndProc?

  • Sarmad

     Jason Barrett wrote:
    all of the samples use a WndProc function to handle keyboard and mouse input. I assume there is a good reason that DirectInput is not being used.

    My understanding is that it maintains the clarity/simplicity of the sample code by not introducing another DX component.

    The vast majority of the D3D samples tend to use quite trivial keyboard/mouse input that, as you've probably seen, can be handled by a few lines in the appropriate WndProc callback.

     Jason Barrett wrote:

    Does using WndProc give better performance than DirectInput

    DInput, as far back as I can remember, has always had the advantage of being much lower-level than the standard Win32/WinProc stuff, so it should still be more efficient/faster.

    For anything more advanced than a sample (e.g. a game/application) I would use DInput - it's not necessarily the performance that is the bonus, but also the features that DInput offers that I find useful.

    hth
    Jack

  • Grismath

     Jason Barrett wrote:


     Jack Hoxley wrote:
    I would use DInput - it's not necessarily the performance that is the bonus, but also the features that DInput offers that I find useful.


    When you say 'features' do you mean Action Mapping

    Yes, that is without a doubt one of the cool things you get in DInput that (to my knowledge) you don't get elsewhere Smile

     Jason Barrett wrote:

    At the moment getting immediate mouse/keyboard data by calling 'GetDeviceState' but I'm now thinking that getting buffered data would be more reliable.

    I always use buffered input - as it delivers me a list of events that have occured in a similar(ish) way to WndProc's message pump...

    Although, I'm not sure if there's any reason to pick between them for anything other than your own personal coding style and/or software's architecture.
     
     Jason Barrett wrote:

    After reading the docs it looks like action mapping is better than both, any opinion

    Action mapping is probably your best bet if you want to have a set of controls for a player(s) and so on... Our game is a management one where it's heavily GUI based so I don't use action mapping for it - so it's not necessarily going to be the best solution!

    hth
    Jack

  • Mehdi311ggg

     Jack Hoxley wrote:
    For anything more advanced than a sample (e.g. a game/application) I would use DInput - it's not necessarily the performance that is the bonus, but also the features that DInput offers that I find useful.

    Especially if you're creating something like a flight simulator or driving game that uses input other than a mouse and keyboard. Smile

  • Christian Liensberger

    In general, DirectInput is best if what you want to do is treat the keyboard like a 100-plus key joypad. If you want to input any sort of text, then WM_KEYDOWN/WM_CHAR is your friend, because it handles all the annoying modifiers, buffering, localisation, etc for you. Usually, games have both systems, and decide which they want to use according to the circumstance.

  • Shrad

    Thanks for that,
    I've gone with DirectInput and now have a working 'simple' input manager class.

     Jack Hoxley wrote:
    I would use DInput - it's not necessarily the performance that is the bonus, but also the features that DInput offers that I find useful.


    When you say 'features' do you mean Action Mapping

    At the moment getting immediate mouse/keyboard data by calling 'GetDeviceState' but I'm now thinking that getting buffered data would be more reliable. After reading the docs it looks like action mapping is better than both, any opinion

  • DirectInput or WndProc?