Skip to main content
GameDev.net gamedev.net
🔒 Locked

Direct Input error problem, c_dfDIMouse

Started by 123abcd1983 Feb 19, 2007 at 10:45 PM 5 replies 2.3k views
Original Post
123abcd1983
123abcd1983
Hi, I have some errors with my coding, but I don’t know what the problem is, wish anyone could give me some advice. Below is the error message, please give me any suggestion. DuckHunting2006 error LNK2001: unresolved external symbol _c_dfDIMouse DuckHunting2006 error LNK2019: unresolved external symbol _DirectInput8Create@20 referenced in function "long __cdecl InitDirectInput(struct HWND__ *)" (?InitDirectInput@@YAJPAUHWND__@@@Z) [\b] Global declaration
Quote:
LPDIRECTINPUT8 g_pDI = NULL; LPDIRECTINPUTDEVICE8 g_pMouse;
Quote:
HRESULT InitDirectInput(HWND hwnd) { HRESULT hr; if( FAILED( hr = DirectInput8Create ( GetModuleHandle(NULL),DIRECTINPUT_VERSION, IID_IDirectInput8, (VOID**)&g_pDI, NULL ) ) ) return hr; // Obtain an interface to the system Mouse device. if( FAILED( hr = g_pDI->CreateDevice( GUID_SysMouse, &g_pMouse, NULL ) ) ) return hr; // This tells DirectInput that we will be passing a DIMOUSESTATE structure // IDirectInputDevice8::GetDeviceState(). Even though we won't actually do // it in this sample. But setting the data format is important so that the // DIJOFS_* values work properly. if( FAILED( hr = g_pMouse -> SetDataFormat( &c_dfDIMouse ) ) ) return hr; // Set the cooperative level to let DInput know how this device should // interact with the system and with other DInput applications. // Exclusive access is required in order to perform force feedback. if( FAILED( hr = g_pMouse->SetCooperativeLevel( hwnd, DISCL_EXCLUSIVE | DISCL_BACKGROUND ) ) ) { return hr; } // Acquire the newly created device g_pMouse->Acquire(); // Set a timer to go off 12 times a second, to read input // Note: Typically an application would poll the Mouse // much faster than this, but this slow rate is simply // for the purposes of demonstration SetTimer( hwnd, 0, 1000 / 12, NULL ); return S_OK; }
Quote:
HRESULT UpdateInputState( IDirect3DDevice9* pd3dDevice, HWND hwnd ) { HRESULT hr; DIMOUSESTATE dims; // DirectInput Mouse state structure if( NULL == g_pMouse ) return S_OK; // Get the input's device state, and put the state in dims ZeroMemory( &dims, sizeof(dims) ); hr = g_pMouse->GetDeviceState( sizeof(DIMOUSESTATE), &dims ); if( FAILED(hr) ) { // DirectInput may be telling us that the input stream has been // interrupted. We aren't tracking any state between polls, so // we don't have any special reset that needs to be done. // We just re-acquire and try again. // If input is lost then acquire and keep trying hr = g_pMouse->Acquire(); while( hr == DIERR_INPUTLOST ) hr = g_pMouse->Acquire(); return S_OK; } return S_OK; }
Quote:
void CALLBACK OnDestroyDevice() { Xxxx xxxx if( g_pMouse ) g_pMouse->Unacquire(); // Release any DirectInput objects. SAFE_RELEASE( g_pMouse ); SAFE_RELEASE( g_pDI ); }
Specchum
Specchum
Have you linked in the direct input library?
"There is no dark side of the moon." - Pink Floyd
123abcd1983
123abcd1983
Quote:
Original post by Specchum
Have you linked in the direct input library?


I think i have linked the in the direct input library, because i have
#include

is it enough? need to do other thing?
Endurion
Endurion
For these GUIDs you need to

either include dxguid.lib (easier)

or

#define INITGUID before including dinput.h (but only once, which makes it nasty).
Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>
123abcd1983
123abcd1983
Quote:
Original post by Endurion
For these GUIDs you need to

either include dxguid.lib (easier)

or

#define INITGUID before including dinput.h (but only once, which makes it nasty).


How to include the dxguid.lib?
The dxguid.lib already in the "lib" folder,
should i copy it to "include" folder,
if i need to include like this i must copy it to "include" folder -> #include

but it didn't work, syntax error, i think it's because of i #include

or

How to define #define INITGUID , what value i have to assign for this variable, then shld i use this variable in any part of my code agains?
Endurion
Endurion
As Sc4Freak said, add both dinput8.lib and dxguid.lib to your solution; just like you would with a .cpp file.

#include does not add the library, it just includes the header for the function definitions.
Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>

Topic Locked

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

Sign in to reply to this topic.