Skip to main content
GameDev.net gamedev.net
🔒 Locked

DirectInput8Create() problems

Started by eco Jul 6, 2001 at 2:46 AM 7 replies 7.8k views
Original Post
eco
eco
Ok. My code compiles fine but I can''t use Direct Input because this function (DirectInput8Create() ) fails. Here is my code:
  
HRESULT hr;
		hr = DirectInput8Create(p_Config.hinst, DIRECTINPUT_VERSION, IID_IDirectInput8, (void **)DInput, NULL);
		if(FAILED(hr))
		{
			if(hr == DIERR_INVALIDPARAM)
				Debug += "*** DirectInput8Create() FAILED *** Invalid Params";
			else if(hr == DIERR_BETADIRECTINPUTVERSION)
				Debug += "*** DirectInput8Create() FAILED *** Beta Direct Input Version";
			else if(hr == DIERR_OLDDIRECTINPUTVERSION)
				Debug += "*** DirectInput8Create() FAILED *** Old Direct Input Version";
			else if(hr == DIERR_OUTOFMEMORY)
				Debug += "*** DirectInput8Create() FAILED *** Out of Memory";
			else
			{
				char buffer[512];
				sprintf(buffer, "%s", DXGetErrorString8(hr));
				char buffer2[512];

				
				sprintf(buffer2, "*** DirectInput8Create() FAILED *** Error: %s", buffer);
				Debug += buffer2;
			}
			return false;
  
When run, it doesn''t return any of the possible return values for DirectInput8Create(), instead DirectInput8Create() returns E_POINTER (An invalid pointer, usually NULL, was passed as a parameter). p_Config.hinst gets it value from the hinstance of the program (Config.hinst = hinstance. This is part of a class. LPDIRECTINPUT8 DInput is a private member of the class. Any ideas? Thanks, eco
"Build a man a fire, and you keep him warm for an evening.Set a man on fire, and you keep him warm for the rest of his life!"-Unknown
Tornado
Tornado
Maybe:

hr = DirectInput8Create(p_Config.hinst, DIRECTINPUT_VERSION, IID_IDirectInput8, (void **)&DInput, NULL);


- Goblineye Entertainment
The road to success is always under construction
Goblineye EntertainmentThe road to success is always under construction
eco
eco
Always so easy for you guys isn''t it? Who knows why I took the & out in the first place but now it works and I''m happy. Thanks Tornado.

-eco
"Build a man a fire, and you keep him warm for an evening.Set a man on fire, and you keep him warm for the rest of his life!"-Unknown
chench
chench
Here is my code, I have the problem too :( ,

[code]
HRESULT hr;

HINSTANCE hInstance = (HINSTANCE)GetModuleHandle(NULL);

hr = DirectInput8Create(hInstance,
DIRECTINPUT_VERSION,
IID_IDirectInput8,
(void**)&m_pDI,
NULL);

if ( FAILED(hr) ) return false;

[/code]

I define DIRECTINPUT_VERSION in my header file

#define DIRECTINPUT_VERSION 0x0800














chench
chench
I know my problem
I never call the CInput's constructor
so just add the following statement will solve the problem

CInput* pInput = new CInput

pInput->Init(hWnd)




Evil Steve
Evil Steve
I'm glad you found the solution to your problem, and congratulations on reviving a thread that's over 10 years old :)

However - that just goes to show you how old DirectInput is - you really shouldn't be using it if you can help it, and absolutely not for keyboard or mouse input.
chench
chench
[quote name='Evil Steve' timestamp='1314881380' post='4856268']
I'm glad you found the solution to your problem, and congratulations on reviving a thread that's over 10 years old :)

However - that just goes to show you how old DirectInput is - you really shouldn't be using it if you can help it, and absolutely not for keyboard or mouse input.
[/quote]


I was just learning DirectInput, I do not know what could replace it :(
Washu
Washu
...
In time the project grows, the ignorance of its devs it shows, with many a convoluted function, it plunges into deep compunction, the price of failure is high, Washu's mirth is nigh.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.