🔒 Locked
Direct Input problem
Advertisement
Original Post
im trying to initialize Direct Input but get an error:
error C2065: ''DirectInputCreate'' : undeclared identifier
i cant seem to understand why.
heres parts of my code:
#include "dinput.h"
blah blah...
//Globals
LPDIRECTINPUT lpdi;
LPDIRECTINPUTDEVICE lpdiKeyboard;
blah blah...
int DI_Init()
{
if(DirectInputCreate(main_instance,DIRECTINPUT_VERSION,&lpdi,NULL)!=DI_OK)
{
MessageBox(main_window_handle,"Could not create DirectInput Object","Error",MB_OK);
return 0;
}
if(lpdi->CreateDevice(GUID_SysKeyboard,&lpdiKeyboard,NULL)!=DI_OK)
{
MessageBox(main_window_handle,"Could not create DirectInput device","Error",MB_OK);
return 0;
}
if(lpdiKeyboard->SetCooperativeLevel(main_window_handle,DISCL_NONEXCLUSIVE|DISCL_BACKGROUND)!=DI_OK)
{
MessageBox(main_window_handle,"Could not set cooperative level","Error",MB_OK);
return 0;
}
if(lpdiKeyboard->SetDataFormat(&c_dfDIKeyboard)!=DI_OK)
{
MessageBox(main_window_handle,"Could not set data format","Error",MB_OK);
return 0;
}
if(lpdiKeyboard->Acquire()!=DI_OK)
{
MessageBox(main_window_handle,"Could not acquire input device","Error",MB_OK);
return 0;
}
return 1;
}
im using DirectX 8 SDK maybe thats the problem.
any help will be wellcome.
I had the same problem, you need to link dinput8.lib, and include dinput8.h. You must have the SDK, I believe in there is a simple tutorial that shows you how to set up DirectInput, check that out too.
I have tryed to add #define DIRECTINPUT_VERSION 0x0700
but all that happend is that it tells me:
warning C4005: ''DIRECTINPUT_VERSION'' : macro redefinition
: see previous definition of ''DIRECTINPUT_VERSION''
which points to:
DirectInputCreat(main_instance,DIRECTINPUT_VERSION,&lpdi,NULL)
and the error C2065: ''DirectInputCreate'' : undeclared identifier
remains
i really want to code in DX7
more help appriciated.
but all that happend is that it tells me:
warning C4005: ''DIRECTINPUT_VERSION'' : macro redefinition
: see previous definition of ''DIRECTINPUT_VERSION''
which points to:
DirectInputCreat(main_instance,DIRECTINPUT_VERSION,&lpdi,NULL)
and the error C2065: ''DirectInputCreate'' : undeclared identifier
remains
i really want to code in DX7
more help appriciated.
Yes i do use VC++ and no i dont have dinput in Stdafx

Maybe you could mail me the source for your small test prog
to see if i can compile it.
to see if i can compile it.
Do you use the *good* dinput header file ? The default is the one given with MSVC (which is DX3 I think). Make sure you really include the header provided with the DX SDK.
Im very confused right now, i could compile VolkerG´s test code
without any problems,so im just sitting here scratching my head trying to find out wats wrong with my code.
without any problems,so im just sitting here scratching my head trying to find out wats wrong with my code.
Problem solved thanks to VolkerG
many thanks.
many thanks.
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement