I am getting an unresolved external for the following:
c_dfDIKeyboard
GUID_SysKeyboard
DirectInput8Create@20
IID_IDirectInput8A
It seems that it would be due to me not linking things properly...
But my linker has additional libraries under:
C:/Program Files/Microsoft DirectX SDK (August 2007)/Lib/x86
And additional includes under:
C:/Program Files/Microsoft DirectX SDK (August 2007)/Includes
....and both of those directories are correct for me.
So here is a huge chunk of code.
Code:
#ifndef _INPUT_H_
#define _INPUT_H_
#include "d3d9.h"
#include "d3dx9.h"
#include <dinput.h>
#pragma comment(lib, "d3dx9.lib")
#pragma comment(lib, "d3d9.lib")
class InputDevice
{
public:
~InputDevice(void);
LPDIRECTINPUT8 Interface;
LPDIRECTINPUTDEVICE8 Device;
protected:
InputDevice(void);
private:
};
#endif
Code:
#ifndef _KEYBOARD_H_
#define _KEYBOARD_H_
#include "inputdevice.h"
#include <iostream>
#include "keys.h"
using namespace std;
class KeyboardDevice : public InputDevice
{
public:
KeyboardDevice(void){}
KeyboardDevice(HWND hWnd, HINSTANCE hInstance);
~KeyboardDevice(void);
void Update(void);
bool Pressed(Key key);
void Print(void);
//protected:
unsigned char state[256], pState[256];
};
#endif
Code:
#include "window.h"
#include "point.h"
#include "graphicdevice.h"
#include "application.h"
#include <windows.h>
#include "keyboarddevice.h"
//#define KEY_DOWN(vk_code) (GetAsyncKeyState(vk_code) & 0x8000 ? 1 : 0)
//#define KEY_UP(vk_code) (GetAsyncKeyState(vk_code) & 0x8000 ? 0 : 1)
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
Window AppWindow(hInstance, nShowCmd, Point(500, 500), Point(50, 50), FALSE);
GraphicDevice Graphics(AppWindow.Handle());
Application Program = Application();
KeyboardDevice Keyboard(AppWindow.Handle(), hInstance);
MSG WindowsMessages;
Program.LoadContent();
while(1)
{
if(Keyboard.Pressed(Keys::Escape)) PostMessage(AppWindow.Handle(), WM_DESTROY, 0, 0);
while(PeekMessage(&WindowsMessages, NULL, 0, 0, PM_REMOVE))
{
TranslateMessage(&WindowsMessages);
DispatchMessage(&WindowsMessages);
} if(WindowsMessages.message == WM_QUIT) break;
Keyboard.Update();
Program.DrawStart(Graphics);
Program.Draw();
Program.DrawEnd(Graphics);
}
Program.UnloadContent();
//Graphics.Dispose();
return WindowsMessages.wParam;
}
...If you need more code than this, let me know and I will post it.