Skip to main content
gamedev.net
🔒 Locked

Direct Input problem

Started by Load Runner Oct 13, 2001 at 2:26 PM 9 replies 1.1k views
Original Post
Load Runner
Load Runner
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.
Romance is dead,it was bougth by Disney and Hallmark and sold to the public in small portions.
Lunatic Raven
Lunatic Raven
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.
"...."
VolkerG
VolkerG
DirectX 8 doesn''t have the function DirectInputCreate anymore. There you use DirectInput8Create. But if you only want to use DirectInput7 only, you can put the following line before the include for the dinput.h file:

#define DIRECTINPUT_VERSION 0x0700
Load Runner
Load Runner
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.

Romance is dead,it was bougth by Disney and Hallmark and sold to the public in small portions.
VolkerG
VolkerG
Thats strange. I''ve just created a very small test programm and it compiles. No problem with a redifinition.

If you''re using VC++:
Do you include "dinput.h" in "stdafx.h", too? That could be the problem.
Load Runner
Load Runner
Yes i do use VC++ and no i dont have dinput in Stdafx

Romance is dead,it was bougth by Disney and Hallmark and sold to the public in small portions.
Load Runner
Load Runner
Maybe you could mail me the source for your small test prog
to see if i can compile it.
Romance is dead,it was bougth by Disney and Hallmark and sold to the public in small portions.
Prosper/LOADED
Prosper/LOADED
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.
Load Runner
Load Runner
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.
Romance is dead,it was bougth by Disney and Hallmark and sold to the public in small portions.
VolkerG
VolkerG
Would it be possible to give me access to yout code? Only the file that causes the error would be needed.
Load Runner
Load Runner
Problem solved thanks to VolkerG
many thanks.
Romance is dead,it was bougth by Disney and Hallmark and sold to the public in small portions.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.