Yes, however normally people who use DirectX or OpenGL use SFML, Allegro, or SDL for input because it's easier. It's really your choice however. I'd recommend either using Allegro or SDL, because with SFML you have to do a lot of extra stuff to capture input with it. You can either use Direct Input or an Input Library, with the latter being easier. If you're main goal is to learn all about DirectX however, you can use Direct Input.

Well if you want to learn DirectX strictly then using Direct Input would be your best bet. Later on if it gets too difficult you can progress to an Input Library, but you seem smart enough to be able to handle Direct Input !

I am getitng the following error.
1> c:\program files\microsoft directx sdk (june 2010)\include\dinput.h: DIRECTINPUT_VERSION undefined. Defaulting to version 0x0800
do I need to include an older sdk for dx.

Did you install the DirectX SDK? If the DirectX SDK was installed after the Windows SDK, the DirectX \include directory will come before the Windows SDK \include directory in your PATH. This means that Visual Studio will be build with the version of objidl.h that ships in the DirectX SDK. You must build with the version of objidl.h that ships in the Windows 7 SDK.

Look at your VC++ Directory Settings in VS and see if the Windows SDK include path (C:\Program Files\Microsoft SDKs\Windows\v7.0\Include) is at the top of the list. This will make Visual Studio use the SDK resources first. You should also change the settings for the Executable and Library directories, so that the Windows SDK directories are at the top.

You can take a look at something I posted a while back. The Input namespace is implemented using DirectInput. It's a bit of a mess since it does some stuff like key-mapping and abstraction, but you should be able to just look over the "initialize" and "update" functions and the mouse related functions and see how to set it up and read mouse input.

Please note that I wrote this a while back and I've learned a lot of important stuff since then, so don't think that this is actually good code. It's not horrible, but it's not designed at a professional level either. It's just an example of the basic underlying procedure. The files you want in the archive are "Bricks/Bricks/ns_Input.h" and "Bricks/Bricks/ns_Input.cpp".

Hope that helps.

Edited by Khatharr, 24 October 2012 - 10:05 PM.

void hurrrrrrrr() {__asm sub [ebp+4],5;}

There are ten kinds of people in this world: those who understand binary and those who don't.

Nooooooooooooo! Never use DirectInput for keyboard or mouse input. Just use WM_MOUSEMOVE, WM_LBUTTONDOWN and so on.

Using DirectInput will remove pointer ballistics, which will make your mouse pointer feel extremely sluggish. It's also hundreds of lines of code to set up and use, where as window messages are "free". And finally, it's actually slower than using window messages - DirectInput spawns another thread to process raw input messages, meaning it has a higher overhead.

If you're just doing this to learn DirectInput, then go ahead - but never use DirectInput for keyboard or mouse input in a shipping product.

Overall, the best method to receive high-definition mouse movement data is WM_INPUT. If your users are just moving a mouse pointer, then consider using WM_MOUSEMOVE to avoid needing to perform pointer ballistics. Both of these window messages will work well even if the mouse isn't a high-definition mouse. By supporting high definition, Windows games can offer more precise control to users.