Search code examples
c#visual-studio-2013directxsharpdxmanaged-directx

How to get started with DirectInput from a Visual Studio 2013 C# solution on Windows 8.1?


Following a comment posted to one of my questions, I am trying to get started using DirectInput.

I am absolutely unfamiliar with it, and I don't know how to get started at all. The namespace seems to be Microsoft.DirectX.DirectInput but I cannot seem to find it anywhere in my references. It says in several places that you just have to add it from the references in my project but I couldn't find it. I checked for a DirectX SDK but it seems it is now part of the Windows SDK and the Windows SDK is already installed with Windows 8 so I shouldn't have to do anything?

I found a couple of alternatives, of which SharpDX sounds like a good one. I have not been able to start with this either... I have installed the SharpDx.Input nuGet package but I can't seem to use the code I can find elsewhere, like here. new DirectInput() for instance is not recognized at all by Visual Studio.


Solution

  • The "Microsoft.DirectX.DirectInput" assemblies are Managed DirectX 1.1 and are deprecated. Furthermore, VS 2013 defaults to using .NET 4.x which is not supported by legacy Managed DirectX 1.1. See DirectX and .NET.

    The underlying DirectInput component whether used by C# or C++ is legacy and is not recommended for use for mouse or keyboard. For Xbox One and Xbox 360 common controllers, we recommend using XINPUT. To use legacy HID devices (joysticks, PS3 controllers, some haptic controllers, etc.), you still use DirectInput. For XINPUT use on Windows 8.x, see this blog. For use from C++, you should look at DirectX Tool Kit particularly the GamePad class.