diff --git a/Makefile b/Makefile index 3668573..94d8d87 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ CFLAGS += -Wno-error=unused-function CFLAGS += -Wno-error=unused-variable CFLAGS += -DUNICODE -LDFLAGS += -Wl,--subsystem,windows -mwindows -mconsole -municode -ld3d9 -ld3dx9 -lwinmm +LDFLAGS += -Wl,--subsystem,windows -mwindows -mconsole -municode -ld3d9 -ld3dx9 -lwinmm -ldinput8 -ldxguid OPT = -Og diff --git a/main.cpp b/main.cpp index f49a830..1c6f367 100644 --- a/main.cpp +++ b/main.cpp @@ -3,6 +3,7 @@ #include #include #include +#include struct CUSTOMVERTEX { @@ -25,6 +26,8 @@ IDirect3DVertexDeclaration9 * g_pVertexDeclaration = NULL; ID3DXConstantTable * g_pConstantTable = NULL; IDirect3DVertexShader9 * g_pVertexShader = NULL; +IDirectInput8 * g_pDI = NULL; + HRESULT InitDirect3D(HWND hwnd) { g_pD3D = Direct3DCreate9(D3D_SDK_VERSION); @@ -52,6 +55,35 @@ HRESULT InitDirect3D(HWND hwnd) return S_OK; } +BOOL CALLBACK EnumDevicesCallback(LPCDIDEVICEINSTANCE lpddi, + LPVOID pvRef) +{ + printf("enum devices callback"); + return DIENUM_CONTINUE; +} + +HRESULT InitDirectInput(HINSTANCE hInstance) +{ + HRESULT hr; + + hr = DirectInput8Create(hInstance, + DIRECTINPUT_VERSION, + IID_IDirectInput8, + (void **)&g_pDI, + NULL); + if (FAILED(hr)) + return hr; + + hr = g_pDI->EnumDevices(DI8DEVCLASS_GAMECTRL, + EnumDevicesCallback, + NULL, + DIEDFL_ATTACHEDONLY); + if (FAILED(hr)) + return hr; + + return S_OK; +} + void Cleanup() { if (g_pd3dDevice != NULL) @@ -105,6 +137,10 @@ void Render() int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine, int nCmdShow) { + InitDirectInput(hInstance); + + return 0; + const wchar_t CLASS_NAME[] = L"Sample Window Class"; WNDCLASS wc = {};