From 0f14383241ceebf3cf457cfa4b103f169c50b343 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Fri, 10 Aug 2012 12:15:31 +0000 Subject: [PATCH] build: split the D3d9 build flags into D3d9 and Xinput for situations where we want Xinput but not D3D (ie. OpenGL). --- build/vs2010/Lol.Core.Rules.props | 7 ++++--- build/vs2010/Lol.Core.Vars.props | 14 ++++++++++++-- src/platform/d3d9/d3d9input.cpp | 10 +++++----- src/platform/sdl/sdlapp.cpp | 4 ++-- src/platform/sdl/sdlinput.cpp | 7 +++++-- 5 files changed, 28 insertions(+), 14 deletions(-) diff --git a/build/vs2010/Lol.Core.Rules.props b/build/vs2010/Lol.Core.Rules.props index fc920ebe..1e499ab4 100644 --- a/build/vs2010/Lol.Core.Rules.props +++ b/build/vs2010/Lol.Core.Rules.props @@ -10,8 +10,8 @@ true Fast $(SolutionDir)\..\..\src;$(SolutionDir)\..\..\src\bullet;$(FlexIncludes);$(BtPhysIncludes);%(AdditionalIncludeDirectories) - $(GlIncludes);$(SdlIncludes);$(D3d9Includes);%(AdditionalIncludeDirectories) - $(GlIncludes);$(SdlIncludes);$(D3d9Includes);%(AdditionalIncludeDirectories) + $(GlIncludes);$(SdlIncludes);$(D3d9Includes);$(XinputIncludes);%(AdditionalIncludeDirectories) + $(GlIncludes);$(SdlIncludes);$(D3d9Includes);$(XinputIncludes);%(AdditionalIncludeDirectories) NOMINMAX;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) WIN32;$(Win32Defines);%(PreprocessorDefinitions) WIN32;$(Win32Defines);%(PreprocessorDefinitions) @@ -43,13 +43,14 @@ - kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;$(SdlDeps);$(GdiDeps);%(AdditionalDependencies) + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;$(SdlDeps);$(GdiDeps);$(XinputDeps);%(AdditionalDependencies) $(GlDeps);%(AdditionalDependencies) $(D3d9Deps);%(AdditionalDependencies) %(AdditionalDependencies) $(SdlLibs);%(AdditionalLibraryDirectories) $(GlLibs);%(AdditionalLibraryDirectories) $(D3d9Libs);%(AdditionalLibraryDirectories) + $(XinputLibs);%(AdditionalLibraryDirectories) %(AdditionalLibraryDirectories) xapilibd.lib;d3d9d.lib;d3dx9d.lib;xgraphicsd.lib;xboxkrnl.lib;xnetd.lib;xaudiod2.lib;xactd3.lib;x3daudiod.lib;xmcored.lib;xbdm.lib;vcompd.lib;%(AdditionalDependencies) xapilib.lib;d3d9.lib;d3dx9.lib;xgraphics.lib;xboxkrnl.lib;xnet.lib;xaudio2.lib;xact3.lib;x3daudio.lib;xmcore.lib;vcomp.lib;%(AdditionalDependencies) diff --git a/build/vs2010/Lol.Core.Vars.props b/build/vs2010/Lol.Core.Vars.props index 44ce2d7b..32bc83e5 100644 --- a/build/vs2010/Lol.Core.Vars.props +++ b/build/vs2010/Lol.Core.Vars.props @@ -61,10 +61,17 @@ $(DXSDK_DIR)\Include $(DXSDK_DIR)\Lib\x86 $(DXSDK_DIR)\Lib\x64 - d3d9.lib;d3dx9.lib;xinput.lib - d3d9.lib;d3dx9d.lib;xinput.lib + d3d9.lib;d3dx9.lib + d3d9.lib;d3dx9d.lib USE_D3D9;$(Win32Defines) + + $(DXSDK_DIR)\Include + $(DXSDK_DIR)\Lib\x86 + $(DXSDK_DIR)\Lib\x64 + xinput.lib + USE_XINPUT;$(Win32Defines) + libsysmodule_stub.a;libsysutil_stub.a;libresc_stub.a; libpngdec_stub.a; @@ -104,6 +111,9 @@ $(D3d9Includes) $(D3d9Libs) $(D3d9Deps) + $(XinputIncludes) + $(XinputLibs) + $(XinputDeps) $(Win32Defines) $(XboxDefines) $(Ps3Deps) diff --git a/src/platform/d3d9/d3d9input.cpp b/src/platform/d3d9/d3d9input.cpp index 4c0b5780..9d054107 100644 --- a/src/platform/d3d9/d3d9input.cpp +++ b/src/platform/d3d9/d3d9input.cpp @@ -12,7 +12,7 @@ # include "config.h" #endif -#if defined USE_D3D9 +#if defined USE_XINPUT # include # include #endif @@ -32,7 +32,7 @@ class D3d9InputData friend class D3d9Input; private: -#if defined USE_D3D9 +#if defined USE_XINPUT Array m_joysticks; #endif }; @@ -44,7 +44,7 @@ private: D3d9Input::D3d9Input() : m_data(new D3d9InputData()) { -#if defined USE_D3D9 +#if defined USE_XINPUT for (int i = 0; i < XUSER_MAX_COUNT; i++) { XINPUT_STATE state; @@ -63,7 +63,7 @@ D3d9Input::D3d9Input() D3d9Input::~D3d9Input() { -#if defined USE_D3D9 +#if defined USE_XINPUT /* Unregister all the joysticks we added */ while (m_data->m_joysticks.Count()) { @@ -83,7 +83,7 @@ void D3d9Input::TickDraw(float seconds) { Entity::TickDraw(seconds); -#if defined USE_D3D9 +#if defined USE_XINPUT for (int i = 0; i < m_data->m_joysticks.Count(); i++) { XINPUT_STATE state; diff --git a/src/platform/sdl/sdlapp.cpp b/src/platform/sdl/sdlapp.cpp index 5adaaa78..d8241608 100644 --- a/src/platform/sdl/sdlapp.cpp +++ b/src/platform/sdl/sdlapp.cpp @@ -28,7 +28,7 @@ #include "lolgl.h" #include "platform/sdl/sdlapp.h" #include "platform/sdl/sdlinput.h" -#if defined USE_D3D9 +#if defined USE_XINPUT # include "platform/d3d9/d3d9input.h" #endif @@ -93,7 +93,7 @@ SdlApp::SdlApp(char const *title, ivec2 res, float fps) : Audio::Setup(2); /* Autoreleased objects */ -# if defined USE_D3D9 +# if defined USE_XINPUT /* Prefer D3d9 for joysticks on Windows, because the X360 pads are not * advertised with the proper number of axes. */ new D3d9Input(); diff --git a/src/platform/sdl/sdlinput.cpp b/src/platform/sdl/sdlinput.cpp index b0700d8e..33cbb110 100644 --- a/src/platform/sdl/sdlinput.cpp +++ b/src/platform/sdl/sdlinput.cpp @@ -69,10 +69,13 @@ SdlInput::SdlInput() { SDL_Joystick *sdlstick = SDL_JoystickOpen(i); - /* Blacklist HDAPS, it's not a real joystick */ + /* Blacklist some devices: + * - HDAPS, it's not a real joystick. + * - X360 controllers, Xinput handles them better since + * it won't think there is only one trigger axis. */ char const *name = SDL_JoystickName(i); if (strstr(name, "HDAPS") -# if !defined USE_D3D9 +# if defined USE_XINPUT || strstr(name, "XBOX 360 For Windows") # endif || false)