Archived

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

SimDemon

DirectInput Init Trouble!

Recommended Posts

I think I''m doing it wrong, but could someone post the code to init. DirectInput(DI, DI Keyboard, etc.). When I do the one from tutorials it gives me my error: "Could Not Initialize DirectInput!" If thispost = 0 Then GoBack() Else Read() End If

Share this post


Link to post
Share on other sites
this is the bulk of the initialisation code from a class for dinput i've made:


       
LPDIRECTINPUT8 m_lpdi; // direct input object

LPDIRECTINPUTDEVICE8 m_lpDIKeyboard; // keyboard

LPDIRECTINPUTDEVICE8 m_lpDIMouse; // mouse

// initalise Dinput

DirectInput8Create(hInst,DIRECTINPUT_VERSION,
IID_IDirectInput8, (void **)&m_lpdi,NULL);
};

// get the mouse

if(FAILED(m_lpdi->CreateDevice(GUID_SysMouse, &m_lpDIMouse, NULL)))
{
return E_FAIL;
}

// set the mouseformat

if(FAILED(m_lpDIMouse->SetDataFormat(&c_dfDIMouse)))
{
return E_FAIL;
}

// set mouse cooperative level

if(FAILED(m_lpDIMouse->SetCooperativeLevel(hWnd,
DISCL_BACKGROUND | DISCL_NONEXCLUSIVE)))
{
return E_FAIL;
}

if(FAILED(m_lpDIMouse->Acquire()))
{
return E_FAIL;
}

// get the keyboard

if(FAILED(m_lpdi->CreateDevice(GUID_SysKeyboard, &m_lpDIKeyboard, NULL)))
{
return E_FAIL;
}

// set the keyboard format

if(FAILED(m_lpDIKeyboard->SetDataFormat(&c_dfDIKeyboard)))
{
return E_FAIL;
}

// set keyboard cooperative level

if(FAILED(m_lpDIKeyboard->SetCooperativeLevel(hWnd,
DISCL_BACKGROUND | DISCL_NONEXCLUSIVE)))
{
return E_FAIL;
}

// acquire the keyboard

if(FAILED(m_lpDIKeyboard->Acquire()))
{
return E_FAIL;
}


works fine for me all the time. hope it helps.

[edited by - helicon56 on May 4, 2002 11:28:17 AM]

Share this post


Link to post
Share on other sites