Jump to content
  • Advertisement

Archived

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

Ademan555

Cant Set Cooperative Level...

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

I have a keyboard class and it ALWYAS fails to set the cooperative level... (this is my init function, despite the slightly counter-intuitive name)
bool KEYBOARD::Get(HINSTANCE hInstance, HWND hWnd, LPDIRECTINPUT8 pDInput)
{
	if (pDInput)
	{
		KEYBOARD::pDInput = pDInput;
	}
	else
	{
		if (FAILED(DirectInput8Create(hInstance, DIRECTINPUT_VERSION, IID_IDirectInput8, (void **)&(KEYBOARD::pDInput), NULL)))
			return FALSE;
	}

	if (FAILED(KEYBOARD::pDInput->CreateDevice(GUID_SysKeyboard, &(KEYBOARD::pDev), NULL)))
	{
		#ifndef __RELEASE___
		OutputDebugString("Failed to Create Keyboard device\n");
		#endif
		return FALSE;
	}

	if (FAILED(KEYBOARD::pDev->SetDataFormat(&c_dfDIKeyboard)))
	{
		#ifndef __RELEASE___
		OutputDebugString("Failed to set Keyboard Data Format\n");
		#endif
		return FALSE;
	}

	if (FAILED(KEYBOARD::pDev->Acquire()))
	{
		#ifndef __RELEASE___
		OutputDebugString("Failed to Acquire Keyboard device\n");
		#endif
		return FALSE;
	}

	if (FAILED(KEYBOARD::pDev->SetCooperativeLevel(hWnd, DISCL_FOREGROUND|DISCL_NONEXCLUSIVE)))
	{
		#ifndef __RELEASE___
		OutputDebugString("Failed to Set Keyboard Cooperative Level\n");
		#endif
		return FALSE;
	}

	return TRUE;
}
{/source]

thanx
-Dan

Share this post


Link to post
Share on other sites
Advertisement
I don''t think you can set the cooperative level while you''ve got the device aquired. Swap the Aquire and SetCooperativeLevel calls and see if that works.

By the way, the Debug Runtime should tell you why your call to SetCooperativeLevel is not working. Make sure you''re running the Debug Runtime with the Debug Output Level set to max. This will help you GREATLY when trying to debug your apps.

neneboricua

Share this post


Link to post
Share on other sites
Thanx a lot, the dumb book im using to learn all of dx didnt specify what order to do everythign in, so i just did some trial and error and did what worked, (which it did, but it just didnt set teh right cooperative level)
thanx
-Dan

Share this post


Link to post
Share on other sites
Yay, its workign now, but now i gotta ask if anyone has any Directinput8 tutorials on immediate mouse access... because my code dont work... (ebonics!!)

Share this post


Link to post
Share on other sites

  • 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!