Original Post
I''m creating a class for my direct input code, and when I try to write the initialization member function, it gives me about 7 linker errors when I compile, any ideas?
//cDInput.h
class cDInput
{private:
LPDIRECTINPUT lpDI;
LPDIRECTINPUTDEVICE DeviceKeyboard;
LPDIRECTINPUTDEVICE DeviceMouse;
DIMOUSESTATE Mouse_State;
char Keys[256];
public:
cDInput();
~cDInput();
bool fCreate(HWND hWndMain,HINSTANCE hInstance);
bool fError(int ErrNo,HWND hWnd);
}
//cDInput.cpp
bool cDInput::fCreate(HWND hWndMain,HINSTANCE hInstance)
{ if(!USE_INPUT)return true;
if(DirectInputCreate(hInstance, DIRECTINPUT_VERSION, &lpDI, NULL)!=DI_OK)return fError(0x0001,hWndMain);
//Keyboard Init
if(lpDI->CreateDevice(GUID_SysKeyboard, &DeviceKeyboard, NULL)!=DI_OK)return fError(0x0002,hWndMain);
if(DeviceKeyboard->SetDataFormat(&c_dfDIKeyboard)!=DI_OK)return fError(0x0003,hWndMain);
if(DeviceKeyboard->SetCooperativeLevel(hWndMain, DISCL_FOREGROUND | DISCL_NONEXCLUSIVE)!=DI_OK)return fError(0x0004,hWndMain);
if(DeviceKeyboard->Acquire()!=DI_OK)return fError(0x0005,hWndMain);
//Mouse Init
if(lpDI->CreateDevice(GUID_SysMouse, &DeviceMouse, NULL)!=DI_OK)return fError(0x0006,hWndMain);
if(DeviceMouse->SetDataFormat(&c_dfDIMouse)!=DI_OK)return fError(0x0007,hWndMain);
if(DeviceMouse->SetCooperativeLevel(hWndMain, DISCL_FOREGROUND | DISCL_EXCLUSIVE)!=DI_OK)return fError(0x0008,hWndMain);
HANDLE HevtMouse = CreateEvent(0, 0, 0, 0);
if(DeviceMouse->SetEventNotification(HevtMouse)!=DI_OK)return fError(0x0009,hWndMain);
DIPROPDWORD dipdw = { { sizeof(DIPROPDWORD), sizeof(DIPROPHEADER), 0, DIPH_DEVICE,}, 32};
if(DeviceMouse->SetProperty(DIPROP_BUFFERSIZE, &dipdw.diph)!=DI_OK)return fError(0x000A,hWndMain);
if(DeviceMouse->Acquire()!=DI_OK)return fError(0x000B,hWndMain);
return true;
}
//These are the errors it returns:
Linking... cDInput.obj : error LNK2001: unresolved external symbol _GUID_SysMouse cDInput.obj : error LNK2001: unresolved external symbol _GUID_SysKeyboard dinput.lib(dilib1.obj) : error LNK2001: unresolved external symbol _GUID_ZAxis dinput.lib(dilib1.obj) : error LNK2001: unresolved external symbol _GUID_YAxis dinput.lib(dilib1.obj) : error LNK2001: unresolved external symbol _GUID_XAxis dinput.lib(dilib2.obj) : error LNK2001: unresolved external symbol _GUID_Key Debug/Shell.exe : fatal error LNK1120: 6 unresolved externals Error executing link.exe.