This commit is contained in:
Zack Buhman 2025-12-21 21:10:31 -06:00
parent be143930c8
commit b2e0a6026b
2 changed files with 37 additions and 1 deletions

View File

@ -14,7 +14,7 @@ CFLAGS += -Wno-error=unused-function
CFLAGS += -Wno-error=unused-variable CFLAGS += -Wno-error=unused-variable
CFLAGS += -DUNICODE 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 OPT = -Og

View File

@ -3,6 +3,7 @@
#include <d3dx9.h> #include <d3dx9.h>
#include <stdint.h> #include <stdint.h>
#include <stdio.h> #include <stdio.h>
#include <dinput.h>
struct CUSTOMVERTEX struct CUSTOMVERTEX
{ {
@ -25,6 +26,8 @@ IDirect3DVertexDeclaration9 * g_pVertexDeclaration = NULL;
ID3DXConstantTable * g_pConstantTable = NULL; ID3DXConstantTable * g_pConstantTable = NULL;
IDirect3DVertexShader9 * g_pVertexShader = NULL; IDirect3DVertexShader9 * g_pVertexShader = NULL;
IDirectInput8 * g_pDI = NULL;
HRESULT InitDirect3D(HWND hwnd) HRESULT InitDirect3D(HWND hwnd)
{ {
g_pD3D = Direct3DCreate9(D3D_SDK_VERSION); g_pD3D = Direct3DCreate9(D3D_SDK_VERSION);
@ -52,6 +55,35 @@ HRESULT InitDirect3D(HWND hwnd)
return S_OK; 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() void Cleanup()
{ {
if (g_pd3dDevice != NULL) if (g_pd3dDevice != NULL)
@ -105,6 +137,10 @@ void Render()
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine, int nCmdShow) int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine, int nCmdShow)
{ {
InitDirectInput(hInstance);
return 0;
const wchar_t CLASS_NAME[] = L"Sample Window Class"; const wchar_t CLASS_NAME[] = L"Sample Window Class";
WNDCLASS wc = {}; WNDCLASS wc = {};