Commit d9b8990a authored by Phillip Castaneda's avatar Phillip Castaneda
Browse files

Adding XInput support for win32. Not currently an option to compile out - todo.

parent 6a6c0c87
......@@ -4,7 +4,7 @@
The zlib/libpng License
Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
Copyright (c) 2005-2010 Phillip Castaneda (pjcast -- www.wreckedgames.com)
This software is provided 'as-is', without any express or implied warranty. In no
event will the authors be held liable for any damages arising from the use of this
......@@ -45,21 +45,16 @@ compatiable with many systems and operating systems
Win32/
Contains Visual Studio .Net Solution Files
Contains CodeBlocks + MinGW + StlPort project files for OIS
Contains CodeBlocks project files for OIS
---- Dependencies ------------------------------------------------------
DirectInput 8
Ogre & CEGUI 0.4.0 If building CEGUIOgre OIS Demo
SDL/
A test bed for an OIS InputManager with SDL as the backend. Not recommended;
however, useful for platforms with non-native OIS ports for temporary use.
Linux/
---- Dependencies ------------------------------------------------------
X11
Ogre (GLX Platform) & CEGUI 0.4.0 If building CEGUIOgre OIS Demo
Newer Linux Kernel (2.6+ ?) for Event API - else, use --disable-joyevents
Newer Linux Kernel (2.6+ ?) for Event API
Steps to build on Linux:
./bootstrap
......@@ -68,9 +63,7 @@ Linux/
---- Configure build options --------------------------------------------
./configure --help --- List all configure options
./configure --disable-ogre --- Disables CEGUIOgre ActionMapping Demo
./configure --disable-joyevents --- Uses /dev/input/jsX instead of
/dev/input/eventX
LinuxCB/
Contains CodeBlock files for building OIS and Demos with codeblocks
......@@ -79,9 +72,5 @@ LinuxCB/
settings. It also installs libOIS to ~/libs
Mac/
XCode-1.5/
Non-complete native OIS port.
XCode-2.2/
Working, complete, OIS port to OSX using SDL as a backend.
\ No newline at end of file
Working, mostly complete OSX vackend.
\ No newline at end of file
......@@ -64,7 +64,7 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="ois_static_d.lib"
AdditionalDependencies="ois_static_d.lib xinput.lib"
OutputFile="$(OutDir)/CommandLine.exe"
LinkIncremental="2"
AdditionalLibraryDirectories="..\..\lib;..\..\src\win32\extras\WiiMote"
......@@ -99,9 +99,9 @@
/>
</Configuration>
<Configuration
Name="Debug|x64"
OutputDirectory="$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
Name="Release|Win32"
OutputDirectory="Release"
IntermediateDirectory="Release"
ConfigurationType="1"
CharacterSet="2"
>
......@@ -119,16 +119,17 @@
/>
<Tool
Name="VCMIDLTool"
TargetEnvironment="3"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
Optimization="2"
InlineFunctionExpansion="1"
OmitFramePointers="true"
AdditionalIncludeDirectories="..\..\includes;..\CommandLine\"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_STLP_DEBUG"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
StringPooling="true"
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
......@@ -145,16 +146,17 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="ois_d.lib"
AdditionalDependencies="ois_static.lib xinput.lib"
OutputFile="$(OutDir)/CommandLine.exe"
LinkIncremental="2"
AdditionalLibraryDirectories="..\..\lib64"
LinkIncremental="1"
AdditionalLibraryDirectories="..\..\lib;..\..\src\win32\extras\WiiMote"
GenerateDebugInformation="true"
ProgramDatabaseFile="$(OutDir)/CommandLine.pdb"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
TargetMachine="17"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
......@@ -180,9 +182,9 @@
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="Release"
IntermediateDirectory="Release"
Name="Debug|x64"
OutputDirectory="$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="2"
>
......@@ -200,17 +202,16 @@
/>
<Tool
Name="VCMIDLTool"
TargetEnvironment="3"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
InlineFunctionExpansion="1"
OmitFramePointers="true"
Optimization="0"
AdditionalIncludeDirectories="..\..\includes;..\CommandLine\"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
StringPooling="true"
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_STLP_DEBUG"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
......@@ -227,17 +228,16 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="ois_static.lib"
AdditionalDependencies="ois_d.lib"
OutputFile="$(OutDir)/CommandLine.exe"
LinkIncremental="1"
AdditionalLibraryDirectories="..\..\lib;..\..\src\win32\extras\WiiMote"
LinkIncremental="2"
AdditionalLibraryDirectories="..\..\lib64"
GenerateDebugInformation="true"
ProgramDatabaseFile="$(OutDir)/CommandLine.pdb"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
TargetMachine="1"
TargetMachine="17"
/>
<Tool
Name="VCALinkTool"
......
......@@ -64,7 +64,7 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="ois_static_d.lib"
AdditionalDependencies="ois_static_d.lib xinput.lib"
OutputFile="$(OutDir)/DemoFFTest.exe"
LinkIncremental="2"
AdditionalLibraryDirectories="..\..\lib;..\..\src\win32\extras\WiiMote"
......@@ -146,7 +146,7 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="ois_static.lib"
AdditionalDependencies="ois_static.lib xinput.lib"
OutputFile="$(OutDir)/DemoFFTest.exe"
LinkIncremental="1"
AdditionalLibraryDirectories="..\..\lib;..\..\src\win32\extras\WiiMote"
......
......@@ -68,7 +68,7 @@
/>
<Tool
Name="VCLibrarianTool"
AdditionalDependencies="dxguid.lib dinput8.lib"
AdditionalDependencies="dxguid.lib dinput8.lib xinput.lib"
OutputFile="$(OutDir)/OIS_static_d.lib"
AdditionalLibraryDirectories="..\src\win32\extras\WiiMote"
/>
......@@ -140,7 +140,7 @@
/>
<Tool
Name="VCLibrarianTool"
AdditionalDependencies="dxguid.lib dinput8.lib"
AdditionalDependencies="dxguid.lib dinput8.lib xinput.lib"
OutputFile="$(OutDir)/OIS_d.lib"
/>
<Tool
......@@ -212,7 +212,7 @@
/>
<Tool
Name="VCLibrarianTool"
AdditionalDependencies="dxguid.lib dinput8.lib"
AdditionalDependencies="dxguid.lib dinput8.lib xinput.lib"
OutputFile="$(OutDir)/OIS_static.lib"
AdditionalLibraryDirectories="..\src\win32\extras\WiiMote"
/>
......@@ -289,7 +289,7 @@
/>
<Tool
Name="VCLibrarianTool"
AdditionalDependencies="dxguid.lib dinput8.lib"
AdditionalDependencies="dxguid.lib dinput8.lib xinput.lib"
OutputFile="$(OutDir)/OIS.lib"
/>
<Tool
......@@ -361,7 +361,7 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="dxguid.lib dinput8.lib"
AdditionalDependencies="dxguid.lib dinput8.lib xinput.lib"
AdditionalLibraryDirectories="..\src\win32\extras\WiiMote\"
GenerateDebugInformation="false"
OptimizeReferences="2"
......@@ -451,7 +451,7 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="dxguid.lib dinput8.lib"
AdditionalDependencies="dxguid.lib dinput8.lib xinput.lib"
GenerateDebugInformation="true"
TargetMachine="17"
/>
......@@ -531,7 +531,7 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="dxguid.lib dinput8.lib"
AdditionalDependencies="dxguid.lib dinput8.lib xinput.lib"
OutputFile="$(OutDir)/OIS_d.dll"
AdditionalLibraryDirectories="..\src\win32\extras\WiiMote\"
GenerateDebugInformation="true"
......@@ -613,7 +613,7 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="dxguid.lib dinput8.lib"
AdditionalDependencies="dxguid.lib dinput8.lib xinput.lib"
OutputFile="$(OutDir)/OIS_d.dll"
TargetMachine="17"
/>
......
......@@ -69,7 +69,7 @@
/>
<Tool
Name="VCLibrarianTool"
AdditionalDependencies="dxguid.lib dinput8.lib"
AdditionalDependencies="dxguid.lib dinput8.lib xinput.lib"
OutputFile="$(OutDir)/OIS_static_d.lib"
AdditionalLibraryDirectories="..\src\win32\extras\WiiMote"
/>
......@@ -142,7 +142,7 @@
/>
<Tool
Name="VCLibrarianTool"
AdditionalDependencies="dxguid.lib dinput8.lib"
AdditionalDependencies="dxguid.lib dinput8.lib xinput.lib"
OutputFile="$(OutDir)/OIS_static.lib"
AdditionalLibraryDirectories="..\src\win32\extras\WiiMote"
/>
......@@ -215,7 +215,7 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="dxguid.lib dinput8.lib"
AdditionalDependencies="dxguid.lib dinput8.lib xinput.lib"
AdditionalLibraryDirectories="..\src\win32\extras\WiiMote\"
GenerateDebugInformation="false"
OptimizeReferences="2"
......@@ -298,7 +298,7 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="dxguid.lib dinput8.lib"
AdditionalDependencies="dxguid.lib dinput8.lib xinput.lib"
OutputFile="$(OutDir)/OIS_d.dll"
AdditionalLibraryDirectories="..\src\win32\extras\WiiMote\"
GenerateDebugInformation="true"
......@@ -379,7 +379,7 @@
/>
<Tool
Name="VCLibrarianTool"
AdditionalDependencies="dxguid.lib dinput8.lib"
AdditionalDependencies="dxguid.lib dinput8.lib xinput.lib"
OutputFile="$(OutDir)/OIS_d.lib"
/>
<Tool
......@@ -455,7 +455,7 @@
/>
<Tool
Name="VCLibrarianTool"
AdditionalDependencies="dxguid.lib dinput8.lib"
AdditionalDependencies="dxguid.lib dinput8.lib xinput.lib"
OutputFile="$(OutDir)/OIS.lib"
/>
<Tool
......@@ -531,7 +531,7 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="dxguid.lib dinput8.lib"
AdditionalDependencies="dxguid.lib dinput8.lib xinput.lib"
GenerateDebugInformation="true"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
......@@ -611,7 +611,7 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="dxguid.lib dinput8.lib"
AdditionalDependencies="dxguid.lib dinput8.lib xinput.lib"
OutputFile="$(OutDir)/OIS_d.dll"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
......@@ -897,13 +897,6 @@
Name="VCResourceCompilerTool"
/>
</FileConfiguration>
<FileConfiguration
Name="OIS_ReleaseDll|Win32"
>
<Tool
Name="VCResourceCompilerTool"
/>
</FileConfiguration>
<FileConfiguration
Name="OIS_DebugDll|Win32"
ExcludedFromBuild="true"
......
......@@ -46,6 +46,14 @@ namespace OIS
/** @copydoc Object::_initialize */
virtual void _initialize();
/**
@remarks
Enum each PNP device using WMI and check each device ID to see if it contains
"IG_" (ex. "VID_045E&PID_028E&IG_00"). If it does, then it's an XInput device
Unfortunately this information can not be found by just using DirectInput
*/
static void CheckXInputDevices(JoyStickInfoList &joys);
protected:
//! Enumerates all things
void _enumerate();
......@@ -60,12 +68,12 @@ namespace OIS
IDirectInput8* mDirectInput;
IDirectInputDevice8* mJoyStick;
DIDEVCAPS mDIJoyCaps;
DWORD coopSetting;
GUID deviceGuid;
JoyStickInfo mJoyInfo;
//! A force feedback device
Win32ForceFeedback* ff_device;
Win32ForceFeedback* mFfDevice;
//! Mapping
int _AxisNumber;
......
......@@ -27,6 +27,7 @@ restrictions:
#define DIRECTINPUT_VERSION 0x0800
#include <windows.h>
#include <dinput.h>
#include <XInput.h>
//Max number of elements to collect from buffered DirectInput
#define KEYBOARD_DX_BUFFERSIZE 17
......@@ -54,10 +55,13 @@ namespace OIS
public:
int devId;
GUID deviceID;
GUID productGuid;
std::string vendor;
bool isXInput;
int xInputDev;
};
typedef std::vector< JoyStickInfo > JoyStickInfoList;
typedef std::vector<JoyStickInfo> JoyStickInfoList;
}
#endif //_WIN32_INPUTSYSTEM_PREREQS_H
......@@ -74,7 +74,7 @@ void Win32InputManager::_initialize( ParamList &paramList )
hInst = GetModuleHandle(0);
//Create the input system
//Create the device
hr = DirectInput8Create( hInst, DIRECTINPUT_VERSION, IID_IDirectInput8, (VOID**)&mDirectInput, NULL );
if (FAILED(hr))
OIS_EXCEPT( E_General, "Win32InputManager::Win32InputManager >> Not able to init DirectX8 Input!");
......@@ -117,7 +117,19 @@ void Win32InputManager::_parseConfigSettings( ParamList &paramList )
void Win32InputManager::_enumerateDevices()
{
//Enumerate all attached devices
mDirectInput->EnumDevices(NULL , _DIEnumDevCallback, this, DIEDFL_ATTACHEDONLY);
mDirectInput->EnumDevices(NULL, _DIEnumDevCallback, this, DIEDFL_ATTACHEDONLY);
int xinputControllers = 0;
//let's check how many possible XInput devices we may have (max 4)...
for(int i = 0; i < 3; ++i)
{
XINPUT_STATE state;
if(XInputGetState(i, &state) != ERROR_DEVICE_NOT_CONNECTED)
{ //Once we found 1, just check our whole list against devices
Win32JoyStick::CheckXInputDevices(unusedJoyStickList);
break;
}
}
}
//--------------------------------------------------------------------------------//
......@@ -133,6 +145,8 @@ BOOL CALLBACK Win32InputManager::_DIEnumDevCallback(LPCDIDEVICEINSTANCE lpddi, L
GET_DIDEVICE_TYPE(lpddi->dwDevType) == DI8DEVTYPE_FLIGHT)
{
JoyStickInfo jsInfo;
jsInfo.isXInput = false;
jsInfo.productGuid = lpddi->guidProduct;
jsInfo.deviceID = lpddi->guidInstance;
jsInfo.vendor = lpddi->tszInstanceName;
jsInfo.devId = _this_->joySticks;
......
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment