Advertisement Jump to content
Sign in to follow this  
Tesl

DirectInput8Create() Failing?

This topic is 4903 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

This is probably one of the most simplist mistakes youv ever seen, but another set of eyes often helps! Everything is compiling fine, but i was getting exceptions when accessing null pointers. I traced it back to realise that the DirectInput object was not being successfully created, this is the function:
InputDevice::InputDevice(HINSTANCE hinst, HWND hWnd)
{
	lpdi = NULL;
	this->hWnd = hWnd;

	if (FAILED(DirectInput8Create(hinst, DIRECTINPUT_VERSION,
			IID_IDirectInput8,(void**)&lpdi, NULL)))
	{
		lpdi = NULL;
		MessageBox(hWnd, "DirectInput unavailable!", NULL, NULL);
	}
}
Where lpdi is earlier declared as a LPDIRECTINPUT8. I took the HRESULT and stuck it into the Error lookup, and was then given: HRESULT: 0x80070057 (2147942487) Name: E_INVALIDARG Description: An invalid parameter was passed to the returning function Severity code: Failed Facility Code: FACILITY_WIN32 (7) Error Code: 0x0057 (87) But, i really cant see anything wrong with that? Iv linked in the libraries dxguid.lib and dinput8.lib, and have included <dinput.h>. From what i can see iv done everything, and see no reason why DirectInput could be unavailable? (I even updated everything through windowsupdate to check!) Has anyone ever had any problems like this before? Its possible iv made a verrrrrry simple mistake though that im just not seeing.... Thanks!

Share this post


Link to post
Share on other sites
Advertisement
Here's my code to init Dx :

if FAILED(DirectInput8Create(GetModuleHandle(NULL),
DIRECTINPUT_VERSION,
IID_IDirectInput8,
(void**)&DInput,
NULL))
{
DebugManager->Print(Error, __FUNCTION__, "Unable to initialize DirectInput 8 !");
return false;
}



Check values of your hinst and hWnd, maybe they are wrong...
Try to replace DIRECTINPUT_VERSION by 0x0800

Share this post


Link to post
Share on other sites
EDIT - found the problem now, you were right and my values for hinst and hWnd were incorrect. Thanks a lot :)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!