Search code examples
c++64-bitdirectx-11directinput

DirectInput8Create fails : E_INVALIDARG


I'm using DirectInput with Direct3D 11, and compiling for x64 and I get an E_INVALIDARG from this line:

HRESULT hr = DirectInput8Create(hInstance, DIRECTINPUT_VERSION, IID_IDirectInput8, reinterpret_cast<void **>(&this->_d8Input), 0);

When I set a break point to look at what is going on I get no sign of any invalid arguments. My hInstance is valid, so is the _d8Input pointer and the DIRECTINPUT_VERSION is set to 0x0800.

I've used direct input with D3D9 before, in the exact same way and didn't have any problems. What am I missing ?

Thanks.


Solution

  • Ok, it turns out I was compiling with /SUBSYSTEM:CONSOLE and the hInstance passed in from WinMain when using a console subsystem doesn't please DirectInput8Create at all.