Day 6 - xinput.h different

I was following along with the video and was getting a compile error when I tried to do the loop that was going over the controller indexes. XUSER_MAX_COUNT is undefined.

I assume that constant is defined in the xinput.h file. For now I am just using the direct value of 4, but I think Casey was able to compile with that defined constant.

I also noticed when he opened the xinput.h file, his looked vastly different from mine. Mine only has the header definition for xinput9_1_0.dll, and doesn't even mention xinput1_4.dll as a possible value. Where did he get the updated xinput.h file?

Is that something that is bundled with VS 2013? I'm using VS 2010.

Thanks!
You are probably using xinput.h file from DirectX SDK, right?

VS2013 includes header files and libraries from Windows 8 SDK. You can try installing it to see if it gets your updated xinput.h header. Don't worry that it has "Windows 8" in name, it will work fine also on Windows 7.

http://msdn.microsoft.com/en-us/windows/desktop/bg162891.aspx
I started to download that SDK, but then thought I'd go look.

The Xinput file looks like it's being loaded from

"C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Include"

I Installed the DirectX June 2010 SDK, and browsed the source for that and found a newer version that has the XUSER_MAX_COUNT defined in it.

How do I get my project to load the xinput from the DirectX SDK instead of the Windows 7.0A location?
Oh, right Windows 7 SDK also includes older headers.

To use DirectX SDK headers you need to add include path to it for compiler. If you use IDE, then open project properties, go to C/C++ -> General. And add "$(DXSDK_DIR)Include" to "Additional Include Directories".

If you use build.bat or similar commandline build system, add "/I$(DXSDK_DIR)Include" to cl.exe arguments.
mmozeiko
Oh, right Windows 7 SDK also includes older headers.

To use DirectX SDK headers you need to add include path to it for compiler. If you use IDE, then open project properties, go to C/C++ -> General. And add "$(DXSDK_DIR)Include" to "Additional Include Directories".

If you use build.bat or similar commandline build system, add "/I$(DXSDK_DIR)Include" to cl.exe arguments.


I'm using the batch file. I'm not sure what's going wrong.

Here's what my build.bat looks like:
1
2
3
4
5
6
@echo off

mkdir ..\..\build
pushd ..\..\build
cl -FC -Zi /I"$(DXSDK_DIR)Include" ..\Handmade_Hero\Code\win32_handmade.cpp User32.lib Gdi32.lib
popd


Added in the check for XUSER_MAX_COUNT and the compiler is still complaining that it's undefined.

I checked the environment variable DXSDK_DIR, and it looks like it points to the correct place. I put the "" around the path since there will be spaces. I Don't know if that's really required. I tried with and without with the same result.
Oh, sorry. My mistake.
If you build with command line, then you need to add "/I%DXSDK_DIR%Include" to command line. $(X) is IDE style of accessing env variables.
mmozeiko
Oh, sorry. My mistake.
If you build with command line, then you need to add "/I%DXSDK_DIR%Include" to command line. $(X) is IDE style of accessing env variables.


Gah. I feel like an idiot for not seeing that myself. It's working. Thanks so much for taking the time to help me out with that!