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
Cant Set Cooperative Level...
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)
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
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
thanx
-Dan
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement