Code: Select all
#pragma once
#include <dinput.h>
#include <vector>
class DIJoystick
{
public:
DIJoystick();
~DIJoystick();
BOOL CALLBACK EnumCallBack( LPDIDEVICEINSTANCE lpDevInst, LPVOID pvRef);
IDirectInput* pDirectInput;
IDirectInputDevice* GamePad;
std::vector< LPDIDEVICEINSTANCE> EnumDevList;
};
Code: Select all
#include "DInput.h"
DIJoystick::DIJoystick()
{
HINSTANCE hInst;
pDirectInput = 0;
GamePad = 0;
pDirectInput->EnumDevices(DI8DEVCLASS_GAMECTRL, EnumCallBack, NULL, DIEDFL_ALLDEVICES);
pDirectInput->CreateDevice(EnumDevList[0]->guidProduct, &GamePad, NULL);
}
BOOL CALLBACK DIJoystick::EnumCallBack( LPDIDEVICEINSTANCE lpDevInst, VOID* pvRef)
{
EnumDevList.push_back(lpDevInst);
EnumDevList[EnumDevList.size() -1]->dwSize = sizeof(LPDIDEVICEINSTANCE);
return DIENUM_CONTINUE;
}
DIJoystick::~DIJoystick()
{
}
http://msdn.microsoft.com/en-us/library ... s.85).aspx
http://msdn.microsoft.com/en-us/library ... s.85).aspx
The line
Code: Select all
pDirectInput->EnumDevices(DI8DEVCLASS_GAMECTRL, EnumCallBack, NULL, DIEDFL_ALLDEVICES);
I had this same problem trying to make my own win32 program with the msgproc function. Someone please explain what I'm doing wrong.