Cant Set Cooperative Level...

Started by
2 comments, last by Ademan555 20 years, 1 month ago
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
When General Patton died after World War 2 he went to the gates of Heaven to talk to St. Peter. The first thing he asked is if there were any Marines in heaven. St. Peter told him no, Marines are too rowdy for heaven. He then asked why Patton wanted to know. Patton told him he was sick of the Marines overshadowing the Army because they did more with less and were all hard-core sons of bitches. St. Peter reassured him there were no Marines so Patton went into Heaven. As he was checking out his new home he rounded a corner and saw someone in Marine Dress Blues. He ran back to St. Peter and yelled "You lied to me! There are Marines in heaven!" St. Peter said "Who him? That's just God. He wishes he were a Marine."
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
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
When General Patton died after World War 2 he went to the gates of Heaven to talk to St. Peter. The first thing he asked is if there were any Marines in heaven. St. Peter told him no, Marines are too rowdy for heaven. He then asked why Patton wanted to know. Patton told him he was sick of the Marines overshadowing the Army because they did more with less and were all hard-core sons of bitches. St. Peter reassured him there were no Marines so Patton went into Heaven. As he was checking out his new home he rounded a corner and saw someone in Marine Dress Blues. He ran back to St. Peter and yelled "You lied to me! There are Marines in heaven!" St. Peter said "Who him? That's just God. He wishes he were a Marine."
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!!)
When General Patton died after World War 2 he went to the gates of Heaven to talk to St. Peter. The first thing he asked is if there were any Marines in heaven. St. Peter told him no, Marines are too rowdy for heaven. He then asked why Patton wanted to know. Patton told him he was sick of the Marines overshadowing the Army because they did more with less and were all hard-core sons of bitches. St. Peter reassured him there were no Marines so Patton went into Heaven. As he was checking out his new home he rounded a corner and saw someone in Marine Dress Blues. He ran back to St. Peter and yelled "You lied to me! There are Marines in heaven!" St. Peter said "Who him? That's just God. He wishes he were a Marine."

This topic is closed to new replies.

Advertisement