Jump to content
  • Advertisement
Sign in to follow this  
snoddas14

DirecInput acting were wird, help needed!

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

hey i got this strange thing.... i complie it and it get no error, but then when i run it MsVs .net ends it and get´s me an break error! here is the code!
bool InputD3D(HINSTANCE hInst, HWND wndHandle)
{
	hr = DirectInput8Create(hInst, DIRECTINPUT_VERSION, IID_IDirectInput8, 
		(void**)&din, NULL);
	if(FAILED(hr))
	{
		return FALSE;
	}
	hr = din->CreateDevice(GUID_SysKeyboard, &dinkey, NULL);
	if(FAILED(hr))
	{
		return FALSE;
	}

	hr =dinkey->SetDataFormat(&c_dfDIKeyboard);
	if(FAILED(hr))
	{
		return FALSE;
	}
	hr = dinkey->SetCooperativeLevel(wndHandle, DISCL_BACKGROUND);
	if(FAILED(hr))
	{
		return FALSE;
	}

	return TRUE;
}
void DInput(void)
{
	static BYTE keystate[256];
	dinkey->Acquire();
	dinkey->GetDeviceState(256, (LPVOID)keystate);
	if(keystate[DIK_W] &0x80)
		MessageBox(NULL,"W är ned tryckt?","You made it idot",MB_OK);

	return;

}

best regard Me.

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by snoddas14
i complie it and it get no error, but then when i run it
MsVs .net ends it and get´s me an break error!
Where? And what's the exact error? Are you using the debug runtimes? Any relevant debug output?

Share this post


Link to post
Share on other sites
I had a problem with this code yesterday too, the code


hr = DirectInput8Create(hInst, DIRECTINPUT_VERSION, IID_IDirectInput8,
(void**)&din, NULL);



would always fail. I changed it to


hr = DirectInput8Create(GetModuleHandle(NULL), DIRECTINPUT_VERSION, IID_IDirectInput8,
(void**)&din, NULL);



and it compiled and ran fine.

Hope this helps.

Share this post


Link to post
Share on other sites
hmm, i would i need a bit mor info to you guys.

when i komplie it i get no errors no warnings and one sucess!
but then when i runt it MSVS.net Breaks is and stop it and give me som sort of
"0x000000000 trying to get 0x000000005"
if i would be able to view a pictur of it, it would be easiyer!!

Share this post


Link to post
Share on other sites
Quote:
Original post by snoddas14
but then when i runt it MSVS.net Breaks is and stop it and give me som sort of
"0x000000000 trying to get 0x000000005"
Where? What line does it break on? That's a a sure sign of trying to dereference a null pointer, and the line it breaks on is the line with the null pointer. You can use the debugger to look at the values of your variables and find which one is null, then you can find out why it's null (If it wasn't set up correctly, or it was released / deleted).

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!