Direct Input 8 doesn't work
I wanted to use Direct Input from Tutorial 23, but I can't get it to work. First I had to alter it a bit, because I use DirectX SDK 8.0a:
LPDIRECTINPUT8 g_DI; // Direct Input ( Add )
LPDIRECTINPUTDEVICE8 g_KDIDev; // Keyboard Device ( Add )
int DI_Init()
{
HRESULT hr;
hr = DirectInput8Create(hInstance, DIRECTINPUT_VERSION,
IID_IDirectInput8, (void**)&g_DI, NULL);
if(FAILED(hr))
{
MessageBox(NULL, "Creating Direct Input 8 Failed","Fatal Error",MB_OK|MB_ICONERROR);
return(false);
}
hr = g_DI->CreateDevice( GUID_SysKeyboard,
&g_KDIDev,
NULL);
if(FAILED(hr))
{
MessageBox(NULL, "Creating Direct Input 8 Device Failed","Fatal Error",MB_OK|MB_ICONERROR);
return(false);
}
hr = g_KDIDev->SetDataFormat(&c_dfDIKeyboard);
if (FAILED(hr))
{
MessageBox(NULL, "Setting Data for Keyboard Failed","Fatal Error",MB_OK|MB_ICONERROR);
return(false);
}
hr = g_KDIDev->SetCooperativeLevel(hWnd, DISCL_FOREGROUND | DISCL_EXCLUSIVE);
if (FAILED(hr))
{
MessageBox(NULL, "Set Cooperative Level Failed","Fatal Error",MB_OK|MB_ICONERROR);
return(false);
}
if (g_KDIDev)
g_KDIDev->Acquire();
else
return(false);
return(true);
}
But it goes wrong with the DirectInput8Create() function. I can't figure out why, can anyone help me?
Edited by - MarcJ on August 15, 2001 8:10:18 AM
August 15, 2001 08:12 AM
It works now, I guess I was trying to initialize Direct Input too early

This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement