This topic is now archived and is closed to further replies.

DirectX9 and DirectInput

This topic is 4942 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

My log file says is all: 1 -> Attempting to bring DInput online 2 -> DirectInput8Create returned DIERR_INVALIDPARAM 3 -> Failed to obtain DirectInputObject I''ve got both dinput.lib and dinput8.lib linked in. Here''s what I''ve tried codewise:
#include <dinput.h>


LPDIRECTINPUT8 m_DirectInputObject;

HRESULT hr = DirectInput8Create(g_hInstance, DIRECTINPUT_VERSION, IID_IDirectInput8, (void **) &m_DirectInputObject, NULL);
After that I test hr and output the result to my logfile. My question (which I fear may be ambiguous) is which one of these could be invalid? I''ve used NULL in place of g_hInstance, thinking it could be a default setting and I wasn''t giving it the right instance...I''ve pretty much used this very set up before. If I''m not giving information that could help answer this question just let me know. Thank you in advance.

Share this post

Link to post
Share on other sites
The only thing I can see as causing a problem is the g_hInstance variable. Did you check it has already been initialised.

You could try this to check:

DirectInput8Create(GetModuleHandle(NULL), DIRECTINPUT_VERSION, IID_IDirectInput8 , (void**) &m_DirectInputObject, NULL)

Share this post

Link to post
Share on other sites
The error message that you may be referring to, one that "always pops up on dinput", is probably the version one...just a warning saying "DIRECTINPUT_VERSION undefined; defaulting to 0x0800."

You can get around this with #define DIRECTINPUT_VERSION 0x0800 just before #include <dinput.h>...or, apparently,

Instead of MSDN this time I tried my luck with the SDK docs itself. =) Good info...except little to no link information. Now I''m fishing around on MSDN and can''t find anything to do with dinput.h or dinput8.h...and dinput8.h isn''t anywhere on my entire system (did a search for it) so if it does exist I can''t include it at present.

I''d really appreciate a link to what page on MSDN you saw that discussed every page I go to discusses IDirectInput8::Create and nothing that might precede its use.

However, including (as I''d been doing) and linking were not the problems as I''d suspected they might had been. Though g_hInstance is initialized as global, it either isn''t properly done, is somehow out of scope, or is not the handle IDirectInput8::Create wants. GetModuleHandle(NULL) has fixed my problem. =)

Thanks everyone for your help.

Share this post

Link to post
Share on other sites