123
This commit is contained in:
53
CryInput/CryInput.cpp
Normal file
53
CryInput/CryInput.cpp
Normal file
@@ -0,0 +1,53 @@
|
||||
// CryInput.cpp : Defines the entry point for the DLL application.
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
|
||||
#ifndef _XBOX
|
||||
_ACCESS_POOL;
|
||||
#endif //_XBOX
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ILog.h>
|
||||
#include <IInput.h>
|
||||
#include "Input.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#define DEBUG_CLIENTBLOCK new( _NORMAL_BLOCK, THIS_FILE, __LINE__)
|
||||
#define new DEBUG_CLIENTBLOCK
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Pointer to Global ISystem.
|
||||
static ISystem* gISystem = 0;
|
||||
ISystem* GetISystem()
|
||||
{
|
||||
return gISystem;
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef _XBOX
|
||||
BOOL APIENTRY DllMain( HANDLE hModule,
|
||||
DWORD ul_reason_for_call,
|
||||
LPVOID lpReserved
|
||||
)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
#endif //_XBOX
|
||||
|
||||
IInput *CreateInput( ISystem *pSystem,void* hinst, void* hwnd, bool usedinput)
|
||||
{
|
||||
gISystem = pSystem;
|
||||
CInput *pInput=new CInput;
|
||||
if (!pInput->Init(pSystem,(HINSTANCE)hinst,(HWND)hwnd,usedinput))
|
||||
{
|
||||
delete pInput;
|
||||
return NULL;
|
||||
}
|
||||
return pInput;
|
||||
}
|
||||
|
||||
#include <CrtDebugStats.h>
|
||||
464
CryInput/CryInput.vcproj
Normal file
464
CryInput/CryInput.vcproj
Normal file
@@ -0,0 +1,464 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="7.10"
|
||||
Name="CryInput"
|
||||
ProjectGUID="{BDBC2938-D1D4-4773-9466-4E085586B073}"
|
||||
SccProjectName="Perforce Project"
|
||||
SccAuxPath=""
|
||||
SccLocalPath="."
|
||||
SccProvider="MSSCCI:Perforce SCM">
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"/>
|
||||
</Platforms>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="D:\Games\FC\Bin32"
|
||||
IntermediateDirectory="Release"
|
||||
ConfigurationType="2"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="FALSE"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="3"
|
||||
GlobalOptimizations="TRUE"
|
||||
InlineFunctionExpansion="2"
|
||||
EnableIntrinsicFunctions="TRUE"
|
||||
FavorSizeOrSpeed="2"
|
||||
OmitFramePointers="TRUE"
|
||||
EnableFiberSafeOptimizations="FALSE"
|
||||
OptimizeForProcessor="2"
|
||||
AdditionalIncludeDirectories="..\CryCommon"
|
||||
PreprocessorDefinitions="_RELEASE;WIN32;NDEBUG;_WINDOWS;_USRDLL;CRYINPUT_EXPORTS"
|
||||
StringPooling="TRUE"
|
||||
RuntimeLibrary="2"
|
||||
BufferSecurityCheck="FALSE"
|
||||
EnableFunctionLevelLinking="FALSE"
|
||||
EnableEnhancedInstructionSet="0"
|
||||
UsePrecompiledHeader="3"
|
||||
PrecompiledHeaderThrough="stdafx.h"
|
||||
PrecompiledHeaderFile=".\Release/CryInput.pch"
|
||||
AssemblerListingLocation=".\Release/"
|
||||
ObjectFile=".\Release/"
|
||||
ProgramDataBaseFileName=".\Release/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="TRUE"
|
||||
CompileAs="0"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalOptions="/MACHINE:I386"
|
||||
OutputFile=".\Release/CryInput.dll"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="TRUE"
|
||||
ProgramDatabaseFile=".\Release/CryInput.pdb"
|
||||
ImportLibrary="$(IntDir)/$(TargetName).lib"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
MkTypLibCompatible="TRUE"
|
||||
SuppressStartupBanner="TRUE"
|
||||
TargetEnvironment="1"
|
||||
TypeLibraryName=".\Release/CryInput.tlb"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
Culture="1033"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Profile|Win32"
|
||||
OutputDirectory="D:\Games\FC\Bin32"
|
||||
IntermediateDirectory="Profile"
|
||||
ConfigurationType="2"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="FALSE"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="3"
|
||||
GlobalOptimizations="TRUE"
|
||||
InlineFunctionExpansion="2"
|
||||
EnableIntrinsicFunctions="TRUE"
|
||||
FavorSizeOrSpeed="2"
|
||||
OmitFramePointers="TRUE"
|
||||
EnableFiberSafeOptimizations="FALSE"
|
||||
OptimizeForProcessor="2"
|
||||
AdditionalIncludeDirectories="..\CryCommon"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;CRYINPUT_EXPORTS"
|
||||
StringPooling="TRUE"
|
||||
RuntimeLibrary="2"
|
||||
BufferSecurityCheck="FALSE"
|
||||
EnableFunctionLevelLinking="FALSE"
|
||||
EnableEnhancedInstructionSet="0"
|
||||
UsePrecompiledHeader="3"
|
||||
PrecompiledHeaderThrough="stdafx.h"
|
||||
PrecompiledHeaderFile=".\Profile/CryInput.pch"
|
||||
AssemblerListingLocation=".\Profile/"
|
||||
ObjectFile=".\Profile/"
|
||||
ProgramDataBaseFileName=".\Profile/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="TRUE"
|
||||
DebugInformationFormat="3"
|
||||
CompileAs="0"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalOptions="/MACHINE:I386"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="TRUE"
|
||||
GenerateDebugInformation="TRUE"
|
||||
BaseAddress="0x33500000"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
MkTypLibCompatible="TRUE"
|
||||
SuppressStartupBanner="TRUE"
|
||||
TargetEnvironment="1"
|
||||
TypeLibraryName="C:\MasterCD/CryInput.tlb"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
Culture="1033"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="D:\Games\FC\Bin32"
|
||||
IntermediateDirectory=".\Debug"
|
||||
ConfigurationType="2"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="FALSE"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
OptimizeForProcessor="0"
|
||||
AdditionalIncludeDirectories="..\CryCommon"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;CRYINPUT_EXPORTS"
|
||||
MinimalRebuild="TRUE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
BufferSecurityCheck="TRUE"
|
||||
EnableFunctionLevelLinking="TRUE"
|
||||
UsePrecompiledHeader="3"
|
||||
PrecompiledHeaderThrough="stdafx.h"
|
||||
PrecompiledHeaderFile=".\Debug/CryInput.pch"
|
||||
AssemblerListingLocation=".\Debug/"
|
||||
ObjectFile=".\Debug/"
|
||||
ProgramDataBaseFileName=".\Debug/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="TRUE"
|
||||
DebugInformationFormat="4"
|
||||
CompileAs="0"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalOptions="/MACHINE:I386"
|
||||
LinkIncremental="2"
|
||||
SuppressStartupBanner="TRUE"
|
||||
GenerateDebugInformation="TRUE"
|
||||
ImportLibrary="$(IntDir)/$(TargetName).lib"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
MkTypLibCompatible="TRUE"
|
||||
SuppressStartupBanner="TRUE"
|
||||
TargetEnvironment="1"
|
||||
TypeLibraryName=".\Debug/CryInput.tlb"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
Culture="1033"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Debug64|Win32"
|
||||
OutputDirectory="D:\Games\FC\Bin32"
|
||||
IntermediateDirectory="Debug64"
|
||||
ConfigurationType="2"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="FALSE"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="..\CryCommon;C:\DXSDK\Include"
|
||||
PreprocessorDefinitions="WIN64;_DEBUG;_WINDOWS;_USRDLL;CRYINPUT_EXPORTS"
|
||||
BasicRuntimeChecks="0"
|
||||
RuntimeLibrary="1"
|
||||
BufferSecurityCheck="FALSE"
|
||||
UsePrecompiledHeader="3"
|
||||
PrecompiledHeaderThrough="stdafx.h"
|
||||
PrecompiledHeaderFile="$(IntDir)/$(ProjectName).pch"
|
||||
AssemblerListingLocation="$(IntDir)/"
|
||||
ObjectFile="$(IntDir)/"
|
||||
ProgramDataBaseFileName="$(IntDir)/$(ProjectName).pdb"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="TRUE"
|
||||
Detect64BitPortabilityProblems="TRUE"
|
||||
DebugInformationFormat="3"
|
||||
CompileAs="0"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalOptions="/MACHINE:AMD64"
|
||||
OutputFile="$(OutDir)/$(ProjectName).dll"
|
||||
LinkIncremental="2"
|
||||
SuppressStartupBanner="TRUE"
|
||||
GenerateDebugInformation="TRUE"
|
||||
ProgramDatabaseFile="$(OutDir)/$(ProjectName).pdb"
|
||||
LargeAddressAware="2"
|
||||
ImportLibrary="$(OutDir)/$(ProjectName).lib"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
MkTypLibCompatible="TRUE"
|
||||
SuppressStartupBanner="TRUE"
|
||||
TargetEnvironment="1"
|
||||
TypeLibraryName=".\Debug/CryInput.tlb"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
Culture="1033"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release64|Win32"
|
||||
OutputDirectory="D:\Games\FC\Bin32"
|
||||
IntermediateDirectory="Release64"
|
||||
ConfigurationType="2"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="FALSE"
|
||||
CharacterSet="2"
|
||||
WholeProgramOptimization="TRUE">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="3"
|
||||
GlobalOptimizations="TRUE"
|
||||
InlineFunctionExpansion="2"
|
||||
EnableIntrinsicFunctions="TRUE"
|
||||
AdditionalIncludeDirectories="..\CryCommon;C:\DXSDK\Include"
|
||||
PreprocessorDefinitions="_RELEASE;NDEBUG;WIN64;WIN32;_AMD64_;_WINDOWS;_USRDLL;CRYINPUT_EXPORTS"
|
||||
BasicRuntimeChecks="0"
|
||||
RuntimeLibrary="2"
|
||||
BufferSecurityCheck="FALSE"
|
||||
UsePrecompiledHeader="3"
|
||||
PrecompiledHeaderThrough="stdafx.h"
|
||||
PrecompiledHeaderFile="$(IntDir)/$(ProjectName).pch"
|
||||
AssemblerListingLocation="$(IntDir)/"
|
||||
ObjectFile="$(IntDir)/"
|
||||
ProgramDataBaseFileName="$(IntDir)/$(ProjectName).pdb"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="TRUE"
|
||||
Detect64BitPortabilityProblems="TRUE"
|
||||
DebugInformationFormat="3"
|
||||
CompileAs="0"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalOptions="/MACHINE:AMD64"
|
||||
OutputFile="$(OutDir)/$(ProjectName).dll"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="TRUE"
|
||||
GenerateDebugInformation="TRUE"
|
||||
ProgramDatabaseFile="$(OutDir)/$(ProjectName).pdb"
|
||||
LargeAddressAware="2"
|
||||
ImportLibrary="$(OutDir)/$(ProjectName).lib"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
MkTypLibCompatible="TRUE"
|
||||
SuppressStartupBanner="TRUE"
|
||||
TargetEnvironment="1"
|
||||
TypeLibraryName=".\Debug/CryInput.tlb"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
Culture="1033"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat">
|
||||
<File
|
||||
RelativePath=".\CryInput.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Input.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Joystick.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\StdAfx.cpp">
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
UsePrecompiledHeader="1"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Profile|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
UsePrecompiledHeader="1"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
UsePrecompiledHeader="1"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug64|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
UsePrecompiledHeader="1"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release64|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
UsePrecompiledHeader="1"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\XActionMap.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\XActionMapManager.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\XKeyboard.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\XMouse.cpp">
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl">
|
||||
<File
|
||||
RelativePath="Input.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Joystick.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Keyboard.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\StdAfx.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\XActionMap.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\XActionMapManager.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\XKeyboard.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\XMouse.h">
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Resource Files"
|
||||
Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe">
|
||||
</Filter>
|
||||
<File
|
||||
RelativePath=".\ReadMe.txt">
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
||||
10
CryInput/CryInput.vcproj.vspscc
Normal file
10
CryInput/CryInput.vcproj.vspscc
Normal file
@@ -0,0 +1,10 @@
|
||||
""
|
||||
{
|
||||
"FILE_VERSION" = "9237"
|
||||
"ENLISTMENT_CHOICE" = "NEVER"
|
||||
"PROJECT_FILE_RELATIVE_PATH" = ""
|
||||
"NUMBER_OF_EXCLUDED_FILES" = "0"
|
||||
"ORIGINAL_PROJECT_FILE_PATH" = "file:F:\\Crytek\\CryInput\\CryInput.vcproj"
|
||||
"NUMBER_OF_NESTED_PROJECTS" = "0"
|
||||
"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROJECT"
|
||||
}
|
||||
222
CryInput/CryInput_XBox.vcproj
Normal file
222
CryInput/CryInput_XBox.vcproj
Normal file
@@ -0,0 +1,222 @@
|
||||
<?xml version="1.0" encoding = "windows-1251"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="7.00"
|
||||
Name="CryInput_XBox"
|
||||
ProjectGUID="{E2E8D5F5-B6CF-4FFE-833C-6877C40D41A5}"
|
||||
SccProjectName=""$/Game01", GBOAAAAA"
|
||||
SccAuxPath=""
|
||||
SccLocalPath=".."
|
||||
SccProvider="MSSCCI:Microsoft Visual SourceSafe">
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Xbox"/>
|
||||
</Platforms>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Xbox"
|
||||
OutputDirectory="Debug_XBox"
|
||||
IntermediateDirectory="Debug_XBox"
|
||||
ConfigurationType="4"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="FALSE">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
OptimizeForProcessor="2"
|
||||
AdditionalIncludeDirectories="..\CryCommon"
|
||||
PreprocessorDefinitions="_XBOX,_DEBUG;_LIB;DEBUG_KEYBOARD"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="5"
|
||||
BufferSecurityCheck="TRUE"
|
||||
UsePrecompiledHeader="2"
|
||||
PrecompiledHeaderFile=".\Debug_XBox/CryInput_XBox.pch"
|
||||
AssemblerListingLocation=".\Debug_XBox/"
|
||||
ObjectFile=".\Debug_XBox/"
|
||||
ProgramDataBaseFileName=".\Debug_XBox/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="TRUE"
|
||||
DebugInformationFormat="4"
|
||||
CompileAs="0"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
OutputFile="$(OutDir)/CryInputXBox.lib"
|
||||
SuppressStartupBanner="TRUE"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Xbox"
|
||||
OutputDirectory="Release_XBox"
|
||||
IntermediateDirectory="Release_XBox"
|
||||
ConfigurationType="4"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="FALSE">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
InlineFunctionExpansion="1"
|
||||
OptimizeForProcessor="2"
|
||||
AdditionalIncludeDirectories="..\CryCommon"
|
||||
PreprocessorDefinitions="_XBOX,NDEBUG;_LIB;DEBUG_KEYBOARD"
|
||||
StringPooling="TRUE"
|
||||
RuntimeLibrary="4"
|
||||
EnableFunctionLevelLinking="TRUE"
|
||||
UsePrecompiledHeader="2"
|
||||
PrecompiledHeaderFile="$(IntDir)/CryInput_XBox.pch"
|
||||
AssemblerListingLocation="$(IntDir)/"
|
||||
ObjectFile="$(IntDir)/"
|
||||
ProgramDataBaseFileName="$(IntDir)/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="TRUE"
|
||||
DebugInformationFormat="2"
|
||||
CompileAs="0"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
OutputFile="$(OutDir)/CryInputXBox.lib"
|
||||
SuppressStartupBanner="TRUE"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Profile|Xbox"
|
||||
OutputDirectory="Profile"
|
||||
IntermediateDirectory="Profile"
|
||||
ConfigurationType="4"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="FALSE">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
InlineFunctionExpansion="2"
|
||||
OptimizeForProcessor="2"
|
||||
AdditionalIncludeDirectories="..\CryCommon"
|
||||
PreprocessorDefinitions="_XBOX,NDEBUG;_LIB"
|
||||
StringPooling="TRUE"
|
||||
RuntimeLibrary="4"
|
||||
EnableFunctionLevelLinking="TRUE"
|
||||
UsePrecompiledHeader="2"
|
||||
PrecompiledHeaderFile=".\CryInput_XBox___Xbox_Profile/CryInput_XBox.pch"
|
||||
AssemblerListingLocation=".\CryInput_XBox___Xbox_Profile/"
|
||||
ObjectFile=".\CryInput_XBox___Xbox_Profile/"
|
||||
ProgramDataBaseFileName=".\CryInput_XBox___Xbox_Profile/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="TRUE"
|
||||
DebugInformationFormat="2"
|
||||
CompileAs="0"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
OutputFile="$(OutDir)/CryInputXBox.lib"
|
||||
SuppressStartupBanner="TRUE"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Controlleres"
|
||||
Filter="">
|
||||
<File
|
||||
RelativePath="XDebugKeyboard.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="XDebugKeyboard.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="XGamepad.cpp">
|
||||
<FileConfiguration
|
||||
Name="Debug|Xbox">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Xbox">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Profile|Xbox">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="XGamepad.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="XKeyboard.cpp">
|
||||
<FileConfiguration
|
||||
Name="Debug|Xbox"
|
||||
ExcludedFromBuild="TRUE">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Xbox"
|
||||
ExcludedFromBuild="TRUE">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="XKeyboard.h">
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Managers"
|
||||
Filter="">
|
||||
<File
|
||||
RelativePath="XActionMap.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="XActionMap.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="XActionMapManager.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="XActionMapManager.h">
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Common"
|
||||
Filter="">
|
||||
<File
|
||||
RelativePath=".\CryInput.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Input.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Input.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="StdAfx.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\StdAfx.h">
|
||||
</File>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
||||
10
CryInput/CryInput_XBox.vcproj.vspscc
Normal file
10
CryInput/CryInput_XBox.vcproj.vspscc
Normal file
@@ -0,0 +1,10 @@
|
||||
""
|
||||
{
|
||||
"FILE_VERSION" = "9237"
|
||||
"ENLISTMENT_CHOICE" = "NEVER"
|
||||
"PROJECT_FILE_RELATIVE_PATH" = ""
|
||||
"NUMBER_OF_EXCLUDED_FILES" = "0"
|
||||
"ORIGINAL_PROJECT_FILE_PATH" = "file:E:\\Game01\\CryInput\\CryInput_XBox.vcproj"
|
||||
"NUMBER_OF_NESTED_PROJECTS" = "0"
|
||||
"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROJECT"
|
||||
}
|
||||
997
CryInput/Input.cpp
Normal file
997
CryInput/Input.cpp
Normal file
@@ -0,0 +1,997 @@
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Crytek CryENGINE Source code
|
||||
//
|
||||
// File:Input.cpp
|
||||
// Description: General input system
|
||||
//
|
||||
// History:
|
||||
// -Jan 31,2001:Created by Marco Corbetta
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "stdafx.h"
|
||||
#pragma warning(disable:4786)
|
||||
#include <stdio.h>
|
||||
#include <ILog.h>
|
||||
#include <IInput.h>
|
||||
#include <ISystem.h>
|
||||
#include "Input.h"
|
||||
//#include "ActionMap.h"
|
||||
#include "XActionMapManager.h"
|
||||
//#include "..\Common\Log.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#define DEBUG_CLIENTBLOCK new( _NORMAL_BLOCK, THIS_FILE, __LINE__)
|
||||
#define new DEBUG_CLIENTBLOCK
|
||||
#endif
|
||||
|
||||
#if defined (WIN32) || (WIN64)
|
||||
#pragma comment(lib, "dinput8.lib")
|
||||
#pragma comment(lib, "dxguid.lib")
|
||||
#endif
|
||||
|
||||
#ifdef PS2
|
||||
|
||||
#include<sifrpc.h>
|
||||
#include <sifdev.h>
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////
|
||||
int g_nKeys[]={
|
||||
XKEY_BACKSPACE ,
|
||||
XKEY_TAB ,
|
||||
XKEY_RETURN ,
|
||||
XKEY_CONTROL ,
|
||||
XKEY_ALT ,
|
||||
XKEY_SHIFT ,
|
||||
XKEY_PAUSE ,
|
||||
XKEY_CAPSLOCK ,
|
||||
XKEY_ESCAPE ,
|
||||
XKEY_SPACE ,
|
||||
XKEY_PAGE_DOWN ,
|
||||
XKEY_PAGE_UP ,
|
||||
XKEY_END ,
|
||||
XKEY_HOME ,
|
||||
XKEY_LEFT ,
|
||||
XKEY_UP ,
|
||||
XKEY_RIGHT ,
|
||||
XKEY_DOWN ,
|
||||
XKEY_PRINT ,
|
||||
XKEY_INSERT ,
|
||||
XKEY_DELETE ,
|
||||
XKEY_HELP ,
|
||||
XKEY_0 ,
|
||||
XKEY_1 ,
|
||||
XKEY_2 ,
|
||||
XKEY_3 ,
|
||||
XKEY_4 ,
|
||||
XKEY_5 ,
|
||||
XKEY_6 ,
|
||||
XKEY_7 ,
|
||||
XKEY_8 ,
|
||||
XKEY_9 ,
|
||||
XKEY_A ,
|
||||
XKEY_B ,
|
||||
XKEY_C ,
|
||||
XKEY_D ,
|
||||
XKEY_E ,
|
||||
XKEY_F ,
|
||||
XKEY_G ,
|
||||
XKEY_H ,
|
||||
XKEY_I ,
|
||||
XKEY_J ,
|
||||
XKEY_K ,
|
||||
XKEY_L ,
|
||||
XKEY_M ,
|
||||
XKEY_N ,
|
||||
XKEY_O ,
|
||||
XKEY_P ,
|
||||
XKEY_Q ,
|
||||
XKEY_R ,
|
||||
XKEY_S ,
|
||||
XKEY_T ,
|
||||
XKEY_U ,
|
||||
XKEY_V ,
|
||||
XKEY_W ,
|
||||
XKEY_X ,
|
||||
XKEY_Y ,
|
||||
XKEY_Z ,
|
||||
XKEY_TILDE ,
|
||||
XKEY_MINUS ,
|
||||
XKEY_EQUALS ,
|
||||
XKEY_LBRACKET ,
|
||||
XKEY_RBRACKET ,
|
||||
XKEY_BACKSLASH ,
|
||||
XKEY_SEMICOLON ,
|
||||
XKEY_APOSTROPHE ,
|
||||
XKEY_COMMA ,
|
||||
XKEY_PERIOD ,
|
||||
XKEY_SLASH ,
|
||||
XKEY_NUMPAD0 ,
|
||||
XKEY_NUMPAD1 ,
|
||||
XKEY_NUMPAD2 ,
|
||||
XKEY_NUMPAD3 ,
|
||||
XKEY_NUMPAD4 ,
|
||||
XKEY_NUMPAD5 ,
|
||||
XKEY_NUMPAD6 ,
|
||||
XKEY_NUMPAD7 ,
|
||||
XKEY_NUMPAD8 ,
|
||||
XKEY_NUMPAD9 ,
|
||||
XKEY_MULTIPLY ,
|
||||
XKEY_ADD ,
|
||||
XKEY_SEPARATOR ,
|
||||
XKEY_SUBTRACT ,
|
||||
XKEY_DECIMAL ,
|
||||
XKEY_DIVIDE ,
|
||||
XKEY_NUMPADENTER ,
|
||||
XKEY_F1 ,
|
||||
XKEY_F2 ,
|
||||
XKEY_F3 ,
|
||||
XKEY_F4 ,
|
||||
XKEY_F5 ,
|
||||
XKEY_F6 ,
|
||||
XKEY_F7 ,
|
||||
XKEY_F8 ,
|
||||
XKEY_F9 ,
|
||||
XKEY_F10 ,
|
||||
XKEY_F11 ,
|
||||
XKEY_F12 ,
|
||||
XKEY_F13 ,
|
||||
XKEY_F14 ,
|
||||
XKEY_F15 ,
|
||||
XKEY_F16 ,
|
||||
XKEY_F17 ,
|
||||
XKEY_F18 ,
|
||||
XKEY_F19 ,
|
||||
XKEY_F20 ,
|
||||
XKEY_F21 ,
|
||||
XKEY_F22 ,
|
||||
XKEY_F23 ,
|
||||
XKEY_F24 ,
|
||||
XKEY_NUMLOCK ,
|
||||
XKEY_SCROLLLOCK ,
|
||||
XKEY_LCONTROL ,
|
||||
XKEY_RCONTROL ,
|
||||
XKEY_LALT ,
|
||||
XKEY_RALT ,
|
||||
XKEY_LSHIFT ,
|
||||
XKEY_RSHIFT ,
|
||||
XKEY_WIN_LWINDOW ,
|
||||
XKEY_WIN_RWINDOW ,
|
||||
XKEY_WIN_APPS ,
|
||||
XKEY_OEM_102 ,
|
||||
//,
|
||||
XKEY_MOUSE1 ,
|
||||
XKEY_MOUSE2 ,
|
||||
XKEY_MOUSE3 ,
|
||||
XKEY_MOUSE4 ,
|
||||
XKEY_MOUSE5 ,
|
||||
XKEY_MOUSE6 ,
|
||||
XKEY_MOUSE7 ,
|
||||
XKEY_MOUSE8 ,
|
||||
XKEY_MWHEEL_UP ,
|
||||
XKEY_MWHEEL_DOWN ,
|
||||
XKEY_MAXIS_X ,
|
||||
XKEY_MAXIS_Y ,
|
||||
|
||||
// Gamepad
|
||||
XKEY_GP_A,
|
||||
XKEY_GP_B,
|
||||
XKEY_GP_X,
|
||||
XKEY_GP_Y,
|
||||
XKEY_GP_WHITE,
|
||||
XKEY_GP_BLACK,
|
||||
XKEY_GP_LEFT_TRIGGER,
|
||||
XKEY_GP_RIGHT_TRIGGER,
|
||||
|
||||
XKEY_GP_DPAD_UP ,
|
||||
XKEY_GP_DPAD_DOWN ,
|
||||
XKEY_GP_DPAD_LEFT ,
|
||||
XKEY_GP_DPAD_RIGHT ,
|
||||
XKEY_GP_START ,
|
||||
XKEY_GP_BACK ,
|
||||
XKEY_GP_LEFT_THUMB ,
|
||||
XKEY_GP_RIGHT_THUMB ,
|
||||
|
||||
XKEY_GP_STHUMBLUP,
|
||||
XKEY_GP_STHUMBLDOWN,
|
||||
XKEY_GP_STHUMBLLEFT,
|
||||
XKEY_GP_STHUMBLRIGHT,
|
||||
|
||||
XKEY_GP_STHUMBLX,
|
||||
XKEY_GP_STHUMBLY,
|
||||
XKEY_GP_STHUMBRX,
|
||||
XKEY_GP_STHUMBRY,
|
||||
|
||||
XKEY_NULL
|
||||
};
|
||||
|
||||
bool CInput::Init(ISystem *pSystem,HINSTANCE hinst,HWND hwnd,bool dinput)
|
||||
{
|
||||
m_pSystem = pSystem;
|
||||
|
||||
#ifndef PS2
|
||||
m_pLog=pSystem->GetILog();
|
||||
|
||||
#ifndef _XBOX
|
||||
m_hinst=hinst;
|
||||
m_hwnd=hwnd;
|
||||
m_postingenable = 1;
|
||||
|
||||
//if (dinput)
|
||||
{
|
||||
m_pLog->Log("Initializing Direct Input\n");
|
||||
|
||||
HRESULT hr = DirectInput8Create(m_hinst,
|
||||
DIRECTINPUT_VERSION,
|
||||
IID_IDirectInput8,
|
||||
(void**)&m_g_pdi, NULL);
|
||||
|
||||
|
||||
//HRESULT hr = DirectInputCreate(m_hinst, DIRECTINPUT_VERSION, &m_g_pdi, NULL);
|
||||
if (FAILED(hr) && dinput)
|
||||
{
|
||||
m_pLog->Log("Cannot initialize Direct Input\n");
|
||||
return (false);
|
||||
}
|
||||
}
|
||||
//else
|
||||
// return (true);
|
||||
|
||||
m_pLog->Log("Direct Input initialized (CryInputDLL)\n");
|
||||
#endif //_XBOX
|
||||
|
||||
#ifndef _XBOX
|
||||
//if (!m_Keyboard.Init(this,m_pLog,m_g_pdi,hinst,hwnd) && dinput)
|
||||
if (!m_Keyboard.Init(this,m_pSystem,m_g_pdi,hinst,hwnd) && dinput)
|
||||
return (false);
|
||||
m_pLog->LogToFile("Keyboard initialized\n");
|
||||
|
||||
m_Mouse.m_pInput = this;
|
||||
if (!m_Mouse.Init(m_pSystem,m_g_pdi,hinst,hwnd,dinput) && dinput)
|
||||
return (false);
|
||||
m_pLog->Log("Mouse initialized\n");
|
||||
|
||||
if (!m_Joystick.Init(m_pLog))
|
||||
{
|
||||
m_pLog->Log("Cannot initialize joystick\n");
|
||||
}
|
||||
else
|
||||
m_pLog->Log("Joystick initialized\n");
|
||||
#else //_XBOX
|
||||
|
||||
if (!m_Gamepad.Init(m_pLog))
|
||||
{
|
||||
m_pLog->Log("Cannot initialize Gamepad\n");
|
||||
}
|
||||
else
|
||||
m_pLog->Log("Gamepad initialized\n");
|
||||
#ifdef DEBUG_KEYBOARD
|
||||
if (!m_Keyboard.Init(this, m_pLog))
|
||||
{
|
||||
m_pLog->Log("Cannot initialize Keyboard\n");
|
||||
}
|
||||
else
|
||||
m_pLog->LogToFile("Keyboard initialized\n");
|
||||
#endif //DEBUG_KEYBOARD
|
||||
|
||||
#endif //_XBOX
|
||||
|
||||
m_pLog->Log("initializing Key/name Mapping\n");
|
||||
|
||||
int n=0;
|
||||
while(g_nKeys[n]!=0)
|
||||
{
|
||||
m_mapKeyNames.insert(KeyNamesMapItor::value_type(GetKeyName(g_nKeys[n]),g_nKeys[n]));
|
||||
//m_pLog->Log("KEY==> %s",GetKeyName(g_nKeys[n]));
|
||||
n++;
|
||||
}
|
||||
|
||||
m_bPreviousFocus = false;
|
||||
m_exclusivelistener = 0;
|
||||
#endif
|
||||
return (true);
|
||||
}
|
||||
|
||||
////////////////////Morgantini...init PS2 version ///////////////////////
|
||||
#ifdef PS2
|
||||
|
||||
bool CInput::Init(ILog *pLog,ITimer *pTimer)
|
||||
{
|
||||
|
||||
m_pLog=pLog;
|
||||
m_pLog->Log("Initializing PS2 Input\n");
|
||||
|
||||
|
||||
|
||||
if (!m_Mouse.Init(pLog,pTimer))
|
||||
{
|
||||
m_pLog->Log("Cannot initialize Mouse\n");
|
||||
//TO BE CHANGED return (false);
|
||||
}
|
||||
else
|
||||
m_pLog->Log("PS2 Mouse initialized\n");
|
||||
|
||||
//Set the pad on mouse
|
||||
m_Mouse.SetPad(&m_Joystick);
|
||||
|
||||
|
||||
|
||||
|
||||
if (!m_Keyboard.Init(pLog))
|
||||
{
|
||||
m_pLog->Log("Cannot initialize Keyboard\n");
|
||||
//TO BE CHANGED return (false);
|
||||
}
|
||||
else
|
||||
m_pLog->LogToFile("PS2 Keyboard initialized\n");
|
||||
|
||||
|
||||
if (!m_Joystick.Init(pLog))
|
||||
{
|
||||
m_pLog->Log("Cannot initialize joystick\n");
|
||||
//TO BE CHANGED return (false);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if(!m_Keyboard.IsInit())
|
||||
{
|
||||
m_Keyboard.SetPad(&m_Joystick);
|
||||
|
||||
}
|
||||
|
||||
//TiZ m_pLog->Log("PS2 Joystick initialized\n");
|
||||
}
|
||||
|
||||
return (true);
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
///////////////////////////////////////////
|
||||
void CInput::ShutDown()
|
||||
{
|
||||
m_pLog->Log("Input Shutdown\n");
|
||||
|
||||
#ifndef _XBOX
|
||||
m_Keyboard.ShutDown();
|
||||
m_Mouse.Shutdown();
|
||||
m_Joystick.ShutDown();
|
||||
#else //_XBOX
|
||||
m_Gamepad.ShutDown();
|
||||
#ifdef DEBUG_KEYBOARD
|
||||
m_Keyboard.ShutDown();
|
||||
#endif //DEBUG_KEYBOARD
|
||||
#endif //_XBOX
|
||||
|
||||
#ifndef PS2
|
||||
#ifndef _XBOX
|
||||
if (m_g_pdi)
|
||||
{
|
||||
m_g_pdi->Release();
|
||||
m_g_pdi = NULL;
|
||||
}
|
||||
#endif //_XBOX
|
||||
#endif
|
||||
//
|
||||
delete this;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////
|
||||
void CInput::Update(bool bFocus)
|
||||
{
|
||||
if(bFocus)
|
||||
{
|
||||
m_console = m_pSystem->GetIConsole();
|
||||
#ifndef _XBOX
|
||||
m_Keyboard.Update();
|
||||
m_Mouse.Update(m_bPreviousFocus); // m_bPreviousFocus used to skip first mouse read after getting focus
|
||||
m_Joystick.Update();
|
||||
#else //_XBOX
|
||||
m_Gamepad.Update();
|
||||
#ifdef DEBUG_KEYBOARD
|
||||
m_Keyboard.Update();
|
||||
#endif //DEBUG_KEYBOARD
|
||||
#endif //_XBOX
|
||||
}
|
||||
|
||||
m_bPreviousFocus = bFocus;
|
||||
}
|
||||
|
||||
void CInput::ClearKeyState()
|
||||
{
|
||||
m_Keyboard.ClearKeyState();
|
||||
m_Mouse.ClearKeyState();
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////
|
||||
IActionMapManager* CInput::CreateActionMapManager()
|
||||
{
|
||||
CXActionMapManager *pAMM = new CXActionMapManager(this);
|
||||
if(!pAMM)
|
||||
return NULL;
|
||||
|
||||
return pAMM;
|
||||
}
|
||||
///////////////////////////////////////////////
|
||||
const char* CInput::GetKeyName(int iKey,int modifiers, bool bGUI)
|
||||
{
|
||||
static char szKeyName[8]; szKeyName[0]=0;
|
||||
|
||||
if (bGUI)
|
||||
{
|
||||
bool bNumLock = ((GetKeyState(XKEY_NUMLOCK) & 0x01) != 0);
|
||||
|
||||
switch(iKey)
|
||||
{
|
||||
case XKEY_SPACE: return " ";
|
||||
case XKEY_MULTIPLY: return "*";
|
||||
case XKEY_ADD: return "+";
|
||||
case XKEY_SUBTRACT: return "-";
|
||||
case XKEY_DECIMAL: return ".";
|
||||
case XKEY_DIVIDE: return "/";
|
||||
case XKEY_NUMPAD0: return (bNumLock ? "0" : "");
|
||||
case XKEY_NUMPAD1: return (bNumLock ? "1" : "");
|
||||
case XKEY_NUMPAD2: return (bNumLock ? "2" : "");
|
||||
case XKEY_NUMPAD3: return (bNumLock ? "3" : "");
|
||||
case XKEY_NUMPAD4: return (bNumLock ? "4" : "");
|
||||
case XKEY_NUMPAD5: return (bNumLock ? "5" : "");
|
||||
case XKEY_NUMPAD6: return (bNumLock ? "6" : "");
|
||||
case XKEY_NUMPAD7: return (bNumLock ? "7" : "");
|
||||
case XKEY_NUMPAD8: return (bNumLock ? "8" : "");
|
||||
case XKEY_NUMPAD9: return (bNumLock ? "9" : "");
|
||||
case XKEY_BACKSPACE:
|
||||
case XKEY_TAB:
|
||||
case XKEY_RETURN:
|
||||
case XKEY_PAUSE:
|
||||
case XKEY_CAPSLOCK:
|
||||
case XKEY_ESCAPE:
|
||||
case XKEY_PAGE_DOWN:
|
||||
case XKEY_PAGE_UP:
|
||||
case XKEY_END:
|
||||
case XKEY_HOME:
|
||||
case XKEY_LEFT:
|
||||
case XKEY_UP:
|
||||
case XKEY_RIGHT:
|
||||
case XKEY_DOWN:
|
||||
case XKEY_PRINT:
|
||||
case XKEY_INSERT:
|
||||
case XKEY_DELETE:
|
||||
case XKEY_HELP:
|
||||
case XKEY_SEPARATOR:
|
||||
case XKEY_NUMPADENTER:
|
||||
case XKEY_F1:
|
||||
case XKEY_F2:
|
||||
case XKEY_F3:
|
||||
case XKEY_F4:
|
||||
case XKEY_F5:
|
||||
case XKEY_F6:
|
||||
case XKEY_F7:
|
||||
case XKEY_F8:
|
||||
case XKEY_F9:
|
||||
case XKEY_F10:
|
||||
case XKEY_F11:
|
||||
case XKEY_F12:
|
||||
case XKEY_F13:
|
||||
case XKEY_F14:
|
||||
case XKEY_F15:
|
||||
case XKEY_F16:
|
||||
case XKEY_F17:
|
||||
case XKEY_F18:
|
||||
case XKEY_F19:
|
||||
case XKEY_F20:
|
||||
case XKEY_F21:
|
||||
case XKEY_F22:
|
||||
case XKEY_F23:
|
||||
case XKEY_F24:
|
||||
case XKEY_NUMLOCK:
|
||||
case XKEY_SCROLLLOCK:
|
||||
case XKEY_LCONTROL:
|
||||
case XKEY_RCONTROL:
|
||||
case XKEY_LALT:
|
||||
case XKEY_RALT:
|
||||
case XKEY_LSHIFT:
|
||||
case XKEY_RSHIFT:
|
||||
case XKEY_WIN_LWINDOW:
|
||||
case XKEY_WIN_RWINDOW:
|
||||
case XKEY_WIN_APPS:
|
||||
case XKEY_MOUSE1:
|
||||
case XKEY_MOUSE2:
|
||||
case XKEY_MOUSE3:
|
||||
case XKEY_MOUSE4:
|
||||
case XKEY_MOUSE5:
|
||||
case XKEY_MOUSE6:
|
||||
case XKEY_MOUSE7:
|
||||
case XKEY_MOUSE8:
|
||||
case XKEY_MWHEEL_UP:
|
||||
case XKEY_MWHEEL_DOWN:
|
||||
case XKEY_MAXIS_X:
|
||||
case XKEY_MAXIS_Y:
|
||||
case XKEY_GP_A:
|
||||
case XKEY_GP_B:
|
||||
case XKEY_GP_X:
|
||||
case XKEY_GP_Y:
|
||||
case XKEY_GP_WHITE:
|
||||
case XKEY_GP_BLACK:
|
||||
case XKEY_GP_LEFT_TRIGGER:
|
||||
case XKEY_GP_RIGHT_TRIGGER:
|
||||
case XKEY_GP_DPAD_UP:
|
||||
case XKEY_GP_DPAD_DOWN:
|
||||
case XKEY_GP_DPAD_LEFT:
|
||||
case XKEY_GP_DPAD_RIGHT:
|
||||
case XKEY_GP_START:
|
||||
case XKEY_GP_BACK:
|
||||
case XKEY_GP_LEFT_THUMB:
|
||||
case XKEY_GP_RIGHT_THUMB:
|
||||
case XKEY_GP_STHUMBLUP:
|
||||
case XKEY_GP_STHUMBLDOWN:
|
||||
case XKEY_GP_STHUMBLLEFT:
|
||||
case XKEY_GP_STHUMBLRIGHT:
|
||||
case XKEY_GP_STHUMBLX:
|
||||
case XKEY_GP_STHUMBLY:
|
||||
case XKEY_GP_STHUMBRX:
|
||||
case XKEY_GP_STHUMBRY:
|
||||
return "";
|
||||
}
|
||||
|
||||
sprintf(szKeyName,"%c", m_Keyboard.XKEY2ASCII(iKey, modifiers));
|
||||
|
||||
return szKeyName;
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (iKey)
|
||||
{
|
||||
case XKEY_NULL: return "";
|
||||
case XKEY_BACKSPACE: return "backspace";
|
||||
case XKEY_TAB: return "tab";
|
||||
case XKEY_RETURN: return "return";
|
||||
case XKEY_PAUSE: return "pause";
|
||||
case XKEY_CAPSLOCK: return "capslock";
|
||||
case XKEY_ESCAPE: return "esc";
|
||||
case XKEY_SPACE: return "spacebar";
|
||||
case XKEY_PAGE_DOWN: return "pagedown";
|
||||
case XKEY_PAGE_UP: return "pageup";
|
||||
case XKEY_END: return "end";
|
||||
case XKEY_HOME: return "home";
|
||||
case XKEY_LEFT: return "left";
|
||||
case XKEY_UP: return "up";
|
||||
case XKEY_RIGHT: return "right";
|
||||
case XKEY_DOWN: return "down";
|
||||
case XKEY_PRINT: return "printscreen";
|
||||
case XKEY_INSERT: return "insert";
|
||||
case XKEY_DELETE: return "delete";
|
||||
case XKEY_HELP: return "help";
|
||||
case XKEY_NUMPAD0: return "numpad0";
|
||||
case XKEY_NUMPAD1: return "numpad1";
|
||||
case XKEY_NUMPAD2: return "numpad2";
|
||||
case XKEY_NUMPAD3: return "numpad3";
|
||||
case XKEY_NUMPAD4: return "numpad4";
|
||||
case XKEY_NUMPAD5: return "numpad5";
|
||||
case XKEY_NUMPAD6: return "numpad6";
|
||||
case XKEY_NUMPAD7: return "numpad7";
|
||||
case XKEY_NUMPAD8: return "numpad8";
|
||||
case XKEY_NUMPAD9: return "numpad9";
|
||||
case XKEY_MULTIPLY: return "multiply";
|
||||
case XKEY_ADD: return "add";
|
||||
case XKEY_SEPARATOR: return "separator";
|
||||
case XKEY_SUBTRACT: return "subtract";
|
||||
case XKEY_DECIMAL: return "decimal";
|
||||
case XKEY_DIVIDE: return "divide";
|
||||
case XKEY_NUMPADENTER: return "numpad enter";
|
||||
case XKEY_F1: return "f1";
|
||||
case XKEY_F2: return "f2";
|
||||
case XKEY_F3: return "f3";
|
||||
case XKEY_F4: return "f4";
|
||||
case XKEY_F5: return "f5";
|
||||
case XKEY_F6: return "f6";
|
||||
case XKEY_F7: return "f7";
|
||||
case XKEY_F8: return "f8";
|
||||
case XKEY_F9: return "f9";
|
||||
case XKEY_F10: return "f10";
|
||||
case XKEY_F11: return "f11";
|
||||
case XKEY_F12: return "f12";
|
||||
case XKEY_F13: return "f13";
|
||||
case XKEY_F14: return "f14";
|
||||
case XKEY_F15: return "f15";
|
||||
case XKEY_F16: return "f16";
|
||||
case XKEY_F17: return "f17";
|
||||
case XKEY_F18: return "f18";
|
||||
case XKEY_F19: return "f19";
|
||||
case XKEY_F20: return "f20";
|
||||
case XKEY_F21: return "f21";
|
||||
case XKEY_F22: return "f22";
|
||||
case XKEY_F23: return "f23";
|
||||
case XKEY_F24: return "f24";
|
||||
case XKEY_NUMLOCK: return "numlock";
|
||||
case XKEY_SCROLLLOCK: return "scrolllock";
|
||||
case XKEY_LCONTROL: return "lctrl";
|
||||
case XKEY_RCONTROL: return "rctrl";
|
||||
case XKEY_LALT: return "lalt";
|
||||
case XKEY_RALT: return "ralt";
|
||||
case XKEY_LSHIFT: return "lshift";
|
||||
case XKEY_RSHIFT: return "rshift";
|
||||
case XKEY_WIN_LWINDOW: return "lwin";
|
||||
case XKEY_WIN_RWINDOW: return "rwin";
|
||||
case XKEY_WIN_APPS: return "apps";
|
||||
case XKEY_MOUSE1: return "mouse1";
|
||||
case XKEY_MOUSE2: return "mouse2";
|
||||
case XKEY_MOUSE3: return "mouse3";
|
||||
case XKEY_MOUSE4: return "mouse4";
|
||||
case XKEY_MOUSE5: return "mouse5";
|
||||
case XKEY_MOUSE6: return "mouse6";
|
||||
case XKEY_MOUSE7: return "mouse7";
|
||||
case XKEY_MOUSE8: return "mouse8";
|
||||
case XKEY_MWHEEL_UP: return "mwheelup";
|
||||
case XKEY_MWHEEL_DOWN: return "mwheeldown";
|
||||
case XKEY_MAXIS_X: return "maxisx";
|
||||
case XKEY_MAXIS_Y: return "maxisy";
|
||||
|
||||
case XKEY_GP_A: return "gp_a";
|
||||
case XKEY_GP_B: return "gp_b";
|
||||
case XKEY_GP_X: return "gp_x";
|
||||
case XKEY_GP_Y: return "gp_y";
|
||||
case XKEY_GP_WHITE: return "gp_white";
|
||||
case XKEY_GP_BLACK: return "gp_black";
|
||||
case XKEY_GP_LEFT_TRIGGER: return "gp_left_trigger";
|
||||
case XKEY_GP_RIGHT_TRIGGER: return "gp_right_trigger";
|
||||
|
||||
case XKEY_GP_DPAD_UP: return "gp_dpad_up";
|
||||
case XKEY_GP_DPAD_DOWN: return "gp_dpad_down";
|
||||
case XKEY_GP_DPAD_LEFT: return "gp_dpad_left";
|
||||
case XKEY_GP_DPAD_RIGHT: return "gp_dpad_right";
|
||||
case XKEY_GP_START: return "gp_start";
|
||||
case XKEY_GP_BACK: return "gp_back";
|
||||
case XKEY_GP_LEFT_THUMB: return "gp_left_thumb";
|
||||
case XKEY_GP_RIGHT_THUMB: return "gp_right_thumb";
|
||||
|
||||
case XKEY_GP_STHUMBLUP: return "gp_sthumblup";
|
||||
case XKEY_GP_STHUMBLDOWN: return "gp_sthumbldown";
|
||||
case XKEY_GP_STHUMBLLEFT: return "gp_sthumblleft";
|
||||
case XKEY_GP_STHUMBLRIGHT: return "gp_sthumblright";
|
||||
|
||||
case XKEY_GP_STHUMBLX: return "gp_sthumblx";
|
||||
case XKEY_GP_STHUMBLY: return "gp_sthumbly";
|
||||
case XKEY_GP_STHUMBRX: return "gp_sthumbrx";
|
||||
case XKEY_GP_STHUMBRY: return "gp_sthumbry";
|
||||
}
|
||||
|
||||
sprintf(szKeyName,"%c", m_Keyboard.XKEY2ASCII(iKey, modifiers));
|
||||
|
||||
return szKeyName;
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
bool CInput::GetOSKeyName(int nKey, wchar_t *szwKeyName, int iBufSize)
|
||||
{
|
||||
if (IS_KEYBOARD_KEY(nKey))
|
||||
{
|
||||
return m_Keyboard.GetOSKeyName(nKey, szwKeyName, iBufSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (IS_MOUSE_KEY(nKey))
|
||||
{
|
||||
return m_Mouse.GetOSKeyName(nKey, szwKeyName, iBufSize);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int CInput::VK2XKEY(int nKey)
|
||||
{
|
||||
//#ifdef DEBUG_KEYBOARD
|
||||
switch(nKey)
|
||||
{
|
||||
case VK_ESCAPE: return XKEY_ESCAPE;
|
||||
case '1': return XKEY_1;
|
||||
case '2': return XKEY_2;
|
||||
case '3': return XKEY_3;
|
||||
case '4': return XKEY_4;
|
||||
case '5': return XKEY_5;
|
||||
case '6': return XKEY_6;
|
||||
case '7': return XKEY_7;
|
||||
case '8': return XKEY_8;
|
||||
case '9': return XKEY_9;
|
||||
case '10': return XKEY_0;
|
||||
case VK_SUBTRACT: return XKEY_MINUS;
|
||||
case VK_OEM_PLUS: return XKEY_EQUALS;
|
||||
case VK_BACK: return XKEY_BACKSPACE;
|
||||
case VK_TAB: return XKEY_TAB;
|
||||
case 'Q': return XKEY_Q;
|
||||
case 'W': return XKEY_W;
|
||||
case 'E': return XKEY_E;
|
||||
case 'R': return XKEY_R;
|
||||
case 'T': return XKEY_T;
|
||||
case 'Y': return XKEY_Y;
|
||||
case 'U': return XKEY_U;
|
||||
case 'I': return XKEY_I;
|
||||
case 'O': return XKEY_O;
|
||||
case 'P': return XKEY_P;
|
||||
case VK_OEM_4: return XKEY_LBRACKET;
|
||||
case VK_OEM_6: return XKEY_RBRACKET;
|
||||
case VK_RETURN: return XKEY_RETURN;
|
||||
case VK_LCONTROL: return XKEY_LCONTROL;
|
||||
case 'A': return XKEY_A;
|
||||
case 'S': return XKEY_S;
|
||||
case 'D': return XKEY_D;
|
||||
case 'F': return XKEY_F;
|
||||
case 'G': return XKEY_G;
|
||||
case 'H': return XKEY_H;
|
||||
case 'J': return XKEY_J;
|
||||
case 'K': return XKEY_K;
|
||||
case 'L': return XKEY_L;
|
||||
case VK_OEM_1: return XKEY_SEMICOLON;
|
||||
case VK_OEM_7: return XKEY_APOSTROPHE;
|
||||
case VK_OEM_3: return XKEY_TILDE;
|
||||
case VK_LSHIFT: return XKEY_LSHIFT;
|
||||
case VK_OEM_5: return XKEY_BACKSLASH;
|
||||
case 'Z': return XKEY_Z;
|
||||
case 'X': return XKEY_X;
|
||||
case 'C': return XKEY_C;
|
||||
case 'V': return XKEY_V;
|
||||
case 'B': return XKEY_B;
|
||||
case 'N': return XKEY_N;
|
||||
case 'M': return XKEY_M;
|
||||
case VK_OEM_COMMA: return XKEY_COMMA;
|
||||
case VK_OEM_PERIOD: return XKEY_PERIOD;
|
||||
case VK_OEM_2: return XKEY_SLASH;
|
||||
case VK_RSHIFT: return XKEY_RSHIFT;
|
||||
case VK_MULTIPLY: return XKEY_MULTIPLY;
|
||||
case VK_LMENU: return XKEY_LALT;
|
||||
case VK_SPACE: return XKEY_SPACE;
|
||||
case VK_CAPITAL: return XKEY_CAPSLOCK;
|
||||
case VK_F1: return XKEY_F1;
|
||||
case VK_F2: return XKEY_F2;
|
||||
case VK_F3: return XKEY_F3;
|
||||
case VK_F4: return XKEY_F4;
|
||||
case VK_F5: return XKEY_F5;
|
||||
case VK_F6: return XKEY_F6;
|
||||
case VK_F7: return XKEY_F7;
|
||||
case VK_F8: return XKEY_F8;
|
||||
case VK_F9: return XKEY_F9;
|
||||
case VK_F10: return XKEY_F10;
|
||||
case VK_NUMLOCK: return XKEY_NUMLOCK;
|
||||
case VK_SCROLL: return XKEY_SCROLLLOCK;
|
||||
case VK_NUMPAD7: return XKEY_NUMPAD7;
|
||||
case VK_NUMPAD8: return XKEY_NUMPAD8;
|
||||
case VK_NUMPAD9: return XKEY_NUMPAD9;
|
||||
case VK_NUMPAD4: return XKEY_NUMPAD4;
|
||||
case VK_NUMPAD5: return XKEY_NUMPAD5;
|
||||
case VK_NUMPAD6: return XKEY_NUMPAD6;
|
||||
case VK_ADD: return XKEY_ADD;
|
||||
case VK_NUMPAD1: return XKEY_NUMPAD1;
|
||||
case VK_NUMPAD2: return XKEY_NUMPAD2;
|
||||
case VK_NUMPAD3: return XKEY_NUMPAD3;
|
||||
case VK_NUMPAD0: return XKEY_NUMPAD0;
|
||||
case VK_DECIMAL: return XKEY_DECIMAL;
|
||||
case VK_F11: return XKEY_F11;
|
||||
case VK_F12: return XKEY_F12;
|
||||
case VK_F13: return XKEY_F13;
|
||||
case VK_F14: return XKEY_F14;
|
||||
case VK_F15: return XKEY_F15;
|
||||
case VK_KANA: return 0;
|
||||
case VK_CONVERT: return 0;
|
||||
//case VK_NOCONVERT: return 0;
|
||||
// case VK_YEN: return 0;
|
||||
// case VK_NUMPADEQUALS: return 0;
|
||||
// case VK_CIRCUMFLEX: return 0;
|
||||
// case VK_AT: return 0;
|
||||
// case VK_COLON: return 0;
|
||||
// case VK_UNDERLINE: return 0;
|
||||
// case VK_KANJI: return 0;
|
||||
// case VK_STOP: return 0;
|
||||
// case VK_AX: return 0;
|
||||
// case VK_UNLABELED: return 0;
|
||||
//case VK_NUMPADENTER: return XKEY_NUMPADENTER;
|
||||
case VK_RCONTROL: return XKEY_RCONTROL;
|
||||
// case VK_NUMPADCOMMA: return XKEY_SEPARATOR;
|
||||
case VK_DIVIDE: return XKEY_DIVIDE;
|
||||
// case VK_SYSRQ: return XKEY_PRINT;
|
||||
case VK_RMENU: return XKEY_RALT;
|
||||
case VK_PAUSE: return XKEY_PAUSE;
|
||||
case VK_HOME: return XKEY_HOME;
|
||||
case VK_UP: return XKEY_UP;
|
||||
case VK_PRIOR: return XKEY_PAGE_UP;
|
||||
case VK_LEFT: return XKEY_LEFT;
|
||||
case VK_RIGHT: return XKEY_RIGHT;
|
||||
case VK_END: return XKEY_END;
|
||||
case VK_DOWN: return XKEY_DOWN;
|
||||
case VK_NEXT: return XKEY_PAGE_DOWN;
|
||||
case VK_INSERT: return XKEY_INSERT;
|
||||
case VK_DELETE: return XKEY_DELETE;
|
||||
case VK_LWIN: return XKEY_WIN_LWINDOW;
|
||||
case VK_RWIN: return XKEY_WIN_RWINDOW;
|
||||
case VK_APPS: return XKEY_WIN_APPS;
|
||||
case VK_OEM_102: return XKEY_OEM_102;
|
||||
case VK_OEM_MINUS: return XKEY_MINUS;
|
||||
};
|
||||
//#endif // DEBUG_KEYBOARD
|
||||
|
||||
|
||||
return XKEY_NULL;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
int CInput::GetKeyID(const char *sName)
|
||||
{
|
||||
if (!sName)
|
||||
{
|
||||
return XKEY_NULL;
|
||||
}
|
||||
|
||||
KeyNamesMapItor itor;
|
||||
|
||||
char sTemp[256];
|
||||
strcpy(sTemp,sName);
|
||||
|
||||
_strlwr(sTemp);
|
||||
|
||||
itor=m_mapKeyNames.find(sTemp);
|
||||
|
||||
if(itor!=m_mapKeyNames.end())
|
||||
return itor->second;
|
||||
|
||||
return XKEY_NULL;
|
||||
}
|
||||
|
||||
//think if can be better
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
const char *CInput::GetXKeyPressedName()
|
||||
{
|
||||
if(MousePressed(XKEY_MOUSE1))
|
||||
{
|
||||
return GetKeyName(XKEY_MOUSE1);
|
||||
}
|
||||
if(MousePressed(XKEY_MOUSE2))
|
||||
{
|
||||
return GetKeyName(XKEY_MOUSE2);
|
||||
}
|
||||
if(MousePressed(XKEY_MOUSE3))
|
||||
{
|
||||
return GetKeyName(XKEY_MOUSE3);
|
||||
}
|
||||
if(MousePressed(XKEY_MOUSE4))
|
||||
{
|
||||
return GetKeyName(XKEY_MOUSE4);
|
||||
}
|
||||
if(MousePressed(XKEY_MOUSE5))
|
||||
{
|
||||
return GetKeyName(XKEY_MOUSE5);
|
||||
}
|
||||
if(MousePressed(XKEY_MOUSE6))
|
||||
{
|
||||
return GetKeyName(XKEY_MOUSE6);
|
||||
}
|
||||
if(MousePressed(XKEY_MOUSE7))
|
||||
{
|
||||
return GetKeyName(XKEY_MOUSE7);
|
||||
}
|
||||
if(MousePressed(XKEY_MOUSE8))
|
||||
{
|
||||
return GetKeyName(XKEY_MOUSE8);
|
||||
}
|
||||
if(MousePressed(XKEY_MWHEEL_DOWN))
|
||||
{
|
||||
return GetKeyName(XKEY_MWHEEL_DOWN);
|
||||
}
|
||||
if(MousePressed(XKEY_MWHEEL_UP))
|
||||
{
|
||||
return GetKeyName(XKEY_MWHEEL_UP);
|
||||
}
|
||||
return GetKeyPressedName();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CInput::AddEventListener( IInputEventListener *pListener )
|
||||
{
|
||||
// Add new listener to list if not added yet.
|
||||
if (std::find(m_listeners.begin(),m_listeners.end(),pListener) == m_listeners.end())
|
||||
{
|
||||
m_listeners.push_back( pListener );
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CInput::RemoveEventListener( IInputEventListener *pListener )
|
||||
{
|
||||
// Remove listener if it is in list.
|
||||
Listeners::iterator it = std::find(m_listeners.begin(),m_listeners.end(),pListener);
|
||||
if (it != m_listeners.end())
|
||||
{
|
||||
m_listeners.erase( it );
|
||||
//m_listeners.erase( std::remove(m_listeners.begin(),m_listeners.end(),pListener),m_listeners.end() );
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CInput::AddConsoleEventListener( IInputEventListener *pListener )
|
||||
{
|
||||
if (std::find(m_consolelisteners.begin(),m_consolelisteners.end(),pListener) == m_consolelisteners.end())
|
||||
{
|
||||
m_consolelisteners.push_back( pListener );
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CInput::RemoveConsoleEventListener( IInputEventListener *pListener )
|
||||
{
|
||||
Listeners::iterator it = std::find(m_consolelisteners.begin(),m_consolelisteners.end(),pListener);
|
||||
if (it != m_consolelisteners.end())
|
||||
{
|
||||
m_consolelisteners.erase( it );
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CInput::EnableEventPosting ( bool bEnable )
|
||||
{
|
||||
m_postingenable = bEnable;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CInput::PostInputEvent( const SInputEvent &event )
|
||||
{
|
||||
if (m_postingenable)
|
||||
{
|
||||
BroadcastEvent( event );
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CInput::BroadcastEvent( const SInputEvent &event )
|
||||
{
|
||||
if (!m_postingenable)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (Listeners::const_iterator it = m_consolelisteners.begin(); it != m_consolelisteners.end(); ++it)
|
||||
{
|
||||
if ((*it)->OnInputEvent( event ))
|
||||
break;
|
||||
}
|
||||
|
||||
if (m_exclusivelistener)
|
||||
{
|
||||
m_exclusivelistener->OnInputEvent( event );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Send this event to all listeners.
|
||||
for (Listeners::const_iterator it = m_listeners.begin(); it != m_listeners.end(); ++it)
|
||||
{
|
||||
if ((*it)->OnInputEvent( event ))
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CInput::SetExclusiveListener( IInputEventListener *pListener )
|
||||
{
|
||||
m_exclusivelistener = pListener;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
IInputEventListener *CInput::GetExclusiveListener()
|
||||
{
|
||||
return m_exclusivelistener;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
int CInput::GetModifiers() const
|
||||
{
|
||||
return m_Keyboard.GetModifiers();
|
||||
}
|
||||
264
CryInput/Input.h
Normal file
264
CryInput/Input.h
Normal file
@@ -0,0 +1,264 @@
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Crytek CryENGINE Source code
|
||||
//
|
||||
// File:Input.h
|
||||
//
|
||||
// History:
|
||||
// -Jan 31,2001:Created by Marco Corbetta
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef INPUT_H
|
||||
#define INPUT_H
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#ifndef _XBOX
|
||||
#ifdef WIN32
|
||||
#include <dinput.h>
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#endif
|
||||
#else
|
||||
#include <xtl.h>
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <IInput.h>
|
||||
#include <IConsole.h>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <queue>
|
||||
|
||||
|
||||
// PC devices
|
||||
#ifndef _XBOX
|
||||
#include "XKeyboard.h"
|
||||
#endif //_XBOX
|
||||
#include "XMouse.h"
|
||||
#include "Joystick.h"
|
||||
|
||||
// XBox devices
|
||||
#ifdef _XBOX
|
||||
#include "XGamepad.h"
|
||||
#include "XDebugKeyboard.h"
|
||||
#endif // _XBOX
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
===========================================
|
||||
The Input interface Class
|
||||
Win32 code requires Directx 8
|
||||
===========================================
|
||||
*/
|
||||
struct ILog;
|
||||
|
||||
typedef std::map<string,int> KeyNamesMap;
|
||||
typedef KeyNamesMap::iterator KeyNamesMapItor;
|
||||
|
||||
typedef std::queue<int> VirtualKeyQueue;
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
class CInput :
|
||||
public IInput
|
||||
{
|
||||
private:
|
||||
|
||||
public:
|
||||
|
||||
CInput()
|
||||
{
|
||||
m_console = 0;
|
||||
m_pSystem = NULL;
|
||||
m_pLog=NULL;
|
||||
#if !defined(_XBOX) && !defined(PS2)
|
||||
m_g_pdi = NULL;
|
||||
#endif
|
||||
}
|
||||
bool Init(ISystem *pSystem,HINSTANCE hinst, HWND hwnd, bool usedinput);
|
||||
|
||||
#ifdef PS2
|
||||
|
||||
bool Init(ISystem *pSystem);
|
||||
|
||||
#endif
|
||||
|
||||
void ShutDown();
|
||||
void Update(bool bFocus);
|
||||
void ClearKeyState();
|
||||
|
||||
#ifndef _XBOX
|
||||
#ifndef PS2
|
||||
inline void SetMouseExclusive(bool exclusive,void *hwnd=0) { m_Mouse.SetExclusive(exclusive,hwnd); }
|
||||
#else
|
||||
inline void SetMouseExclusive(bool exclusive,void *hwnd=0) { } //PS2 version....do nothing
|
||||
#endif
|
||||
|
||||
void AddEventListener( IInputEventListener *pListener );
|
||||
void RemoveEventListener( IInputEventListener *pListener );
|
||||
void EnableEventPosting ( bool bEnable );
|
||||
void PostInputEvent( const SInputEvent &event );
|
||||
|
||||
virtual void AddConsoleEventListener( IInputEventListener *pListener );
|
||||
virtual void RemoveConsoleEventListener( IInputEventListener *pListener );
|
||||
|
||||
void SetExclusiveListener( IInputEventListener *pListener );
|
||||
IInputEventListener *GetExclusiveListener();
|
||||
|
||||
int GetModifiers() const;
|
||||
|
||||
inline void SetKeyboardExclusive(bool exclusive,void *hwnd=0) { m_Keyboard.SetExclusive(exclusive,hwnd); }
|
||||
inline bool KeyDown(int p_key) { return (m_Keyboard.KeyDown(p_key)); }
|
||||
inline bool KeyPressed(int p_key) { return (m_Keyboard.KeyPressed(p_key)); }
|
||||
inline bool KeyReleased(int p_key) { return (m_Keyboard.KeyReleased(p_key)); }
|
||||
inline bool MouseDown(int p_numButton) { return (m_Mouse.MouseDown(p_numButton)); }
|
||||
inline bool MousePressed(int p_numButton) { return (m_Mouse.MousePressed(p_numButton)); }
|
||||
inline bool MouseDblClick(int p_numButton) { return (m_Mouse.MouseDblClick(p_numButton)); }
|
||||
inline bool MouseReleased(int p_numButton) { return (m_Mouse.MouseReleased(p_numButton)); }
|
||||
inline float MouseGetDeltaX() { return (m_Mouse.GetDeltaX()); }
|
||||
inline float MouseGetDeltaY() { return (m_Mouse.GetDeltaY()); }
|
||||
inline float MouseGetDeltaZ() { return (m_Mouse.GetDeltaZ()); }
|
||||
inline float MouseGetVScreenX() { return m_Mouse.GetVScreenX(); }
|
||||
inline float MouseGetVScreenY() { return m_Mouse.GetVScreenY(); }
|
||||
inline void SetMouseInertia(float kinertia) { m_Mouse.SetInertia(kinertia); }
|
||||
inline bool JoyButtonPressed(int p_numButton) { return (m_Joystick.IsButtonPressed(p_numButton)); }
|
||||
inline int JoyGetDir() { return (m_Joystick.GetDir()); }
|
||||
inline int JoyGetHatDir() { return (m_Joystick.GetHatDir()); }
|
||||
inline Vec3 JoyGetAnalog1Dir(unsigned int joystickID) const { return (m_Joystick.GetAnalog1Dir(joystickID)); }
|
||||
inline Vec3 JoyGetAnalog2Dir(unsigned int joystickID) const { return (m_Joystick.GetAnalog2Dir(joystickID)); }
|
||||
inline CXKeyboard *GetKeyboard() { return (&m_Keyboard); }
|
||||
inline CXMouse * GetMouse() { return (&m_Mouse); }
|
||||
inline int GetKeyPressedCode() { return (m_Keyboard.GetKeyPressedCode()); }
|
||||
inline const char *GetKeyPressedName() { return (m_Keyboard.GetKeyPressedName()); }
|
||||
inline int GetKeyDownCode() { return (m_Keyboard.GetKeyDownCode()); }
|
||||
inline const char *GetKeyDownName() { return (m_Keyboard.GetKeyDownName()); }
|
||||
inline void WaitForKey() { m_Keyboard.WaitForKey(); }
|
||||
inline unsigned char GetKeyState(int nKey) { return m_Keyboard.GetKeyState(nKey); };
|
||||
//Interface specifics
|
||||
inline IKeyboard *GetIKeyboard() { return (&m_Keyboard); }
|
||||
inline IMouse * GetIMouse() { return (&m_Mouse); }
|
||||
#endif // _XBOX
|
||||
#ifdef _XBOX
|
||||
inline void SetMouseExclusive(bool exclusive,void *hwnd=0) { }
|
||||
inline void SetKeyboardExclusive(bool exclusive,void *hwnd=0) { }
|
||||
inline bool KeyDown(int p_key) { return m_Keyboard.KeyDown(p_key); }
|
||||
inline bool KeyPressed(int p_key) { return m_Keyboard.KeyPressed(p_key); }
|
||||
inline bool KeyReleased(int p_key) { return m_Keyboard.KeyReleased(p_key); }
|
||||
inline bool MouseDown(int p_numButton) { return m_Gamepad.KeyDown(p_numButton); }
|
||||
inline bool MousePressed(int p_numButton) { return 0; }
|
||||
inline bool MouseDblClick(int p_numButton) { return 0; }
|
||||
inline bool MouseReleased(int p_numButton) { return 0; }
|
||||
inline float MouseGetDeltaX() { return m_Gamepad.GetDeltaX(); }
|
||||
inline float MouseGetDeltaY() { return m_Gamepad.GetDeltaY(); }
|
||||
inline float MouseGetDeltaZ() { return 0; }
|
||||
inline int MouseGetVScreenX() { return 0; }
|
||||
inline int MouseGetVScreenY() { return 0; }
|
||||
inline void SetMouseInertia(float kinertia) { 0; }
|
||||
inline bool JoyButtonPressed(int p_numButton) { return 0; }
|
||||
inline int JoyGetDir() { return 0; } // never called
|
||||
inline int JoyGetHatDir() { return 0; } // never called
|
||||
inline Vec3 JoyGetAnalog1Dir(unsigned int joystickID) const { return Vec3(); }
|
||||
inline Vec3 JoyGetAnalog2Dir(unsigned int joystickID) const { return Vec3(); }
|
||||
//inline CXKeyboard *GetKeyboard() { return 0; } //never called
|
||||
inline CXMouse * GetMouse(){ return 0; } //never called
|
||||
|
||||
inline int GetKeyPressedCode() { return (m_Keyboard.GetKeyPressedCode()); }
|
||||
inline const char *GetKeyPressedName() { return (m_Keyboard.GetKeyPressedName()); }
|
||||
inline int GetKeyDownCode() { return (m_Keyboard.GetKeyDownCode()); }
|
||||
inline const char *GetKeyDownName() { return (m_Keyboard.GetKeyDownName()); }
|
||||
inline void WaitForKey() { m_Keyboard.WaitForKey(); }
|
||||
|
||||
//Interface specifics
|
||||
inline IKeyboard *GetIKeyboard() { return &m_Keyboard; }
|
||||
inline IMouse * GetIMouse() { return 0; }
|
||||
|
||||
//! return the Xbox gamepad interface
|
||||
inline IGamepad * GetIGamepad() {return &m_Gamepad;}
|
||||
|
||||
#endif// _XBOX
|
||||
|
||||
const char *GetKeyName(int nKey, int modifiers=0, bool bGUI=0);
|
||||
bool GetOSKeyName(int nKey, wchar_t *szwKeyName, int iBufSize);
|
||||
int GetKeyID(const char *sName);
|
||||
IActionMapManager* CreateActionMapManager();
|
||||
const char *GetXKeyPressedName();
|
||||
int VK2XKEY(int nKey);
|
||||
void EnableBufferedInput(bool bEnable)
|
||||
{
|
||||
m_bBufferedInput=bEnable;
|
||||
if(m_bBufferedInput==false)
|
||||
{
|
||||
while(!m_qVKQueue.empty())
|
||||
{
|
||||
m_qVKQueue.pop();
|
||||
}
|
||||
}
|
||||
}
|
||||
int GetBufferedKey()
|
||||
{
|
||||
if(!m_qVKQueue.empty())
|
||||
{
|
||||
int nRet=m_qVKQueue.front();
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
const char* GetBufferedKeyName()
|
||||
{
|
||||
return GetKeyName(GetBufferedKey());
|
||||
}
|
||||
void PopBufferedKey()
|
||||
{
|
||||
if(!m_qVKQueue.empty())
|
||||
m_qVKQueue.pop();
|
||||
}
|
||||
void FeedVirtualKey(int nVirtualKey,long lParam,bool bDown)
|
||||
{
|
||||
m_Keyboard.FeedVirtualKey(nVirtualKey,lParam,bDown);
|
||||
//if(m_bBufferedInput)
|
||||
// m_qVKQueue.push(nVirtualKey);
|
||||
}
|
||||
private:
|
||||
void BroadcastEvent( const SInputEvent &event );
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
IConsole *m_console;
|
||||
#ifndef _XBOX
|
||||
CXKeyboard m_Keyboard;
|
||||
CXMouse m_Mouse;
|
||||
CJoystick m_Joystick;
|
||||
#else //_XBOX
|
||||
CXGamepad m_Gamepad;
|
||||
#ifdef DEBUG_KEYBOARD
|
||||
CXDebugKeyboard m_Keyboard;
|
||||
#endif //DEBUG_KEYBOARD
|
||||
#endif // _XBOX
|
||||
|
||||
ILog *m_pLog;
|
||||
#if !defined(_XBOX) && !defined(PS2)
|
||||
LPDIRECTINPUT8 m_g_pdi;
|
||||
HINSTANCE m_hinst;
|
||||
HWND m_hwnd;
|
||||
#endif
|
||||
struct IXBInput *m_pIInput;
|
||||
KeyNamesMap m_mapKeyNames;
|
||||
bool m_bPreviousFocus; // used to skip first mouse read after getting focus (removes random movements)
|
||||
bool m_bBufferedInput;
|
||||
VirtualKeyQueue m_qVKQueue;
|
||||
ISystem *m_pSystem;
|
||||
|
||||
typedef std::vector<IInputEventListener*> Listeners;
|
||||
Listeners m_listeners;
|
||||
Listeners m_consolelisteners;
|
||||
IInputEventListener *m_exclusivelistener;
|
||||
|
||||
bool m_postingenable;
|
||||
};
|
||||
|
||||
#endif
|
||||
1190
CryInput/Joystick.cpp
Normal file
1190
CryInput/Joystick.cpp
Normal file
File diff suppressed because it is too large
Load Diff
237
CryInput/Joystick.h
Normal file
237
CryInput/Joystick.h
Normal file
@@ -0,0 +1,237 @@
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Crytek CryENGINE Source code
|
||||
//
|
||||
// File:Joystick.h
|
||||
//
|
||||
// History:
|
||||
// -Jan 31,2001:Created by Marco Corbetta
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef JOYSTICK_H
|
||||
#define JOYSTICK_H
|
||||
|
||||
#define JOY_DIR_UP 0
|
||||
#define JOY_DIR_DOWN 1
|
||||
#define JOY_DIR_LEFT 2
|
||||
#define JOY_DIR_RIGHT 3
|
||||
#define JOY_DIR_NONE -1
|
||||
|
||||
#define JOY_UPDATE_TIME 1.0f/10.0f //10 times for second
|
||||
|
||||
|
||||
#include "Cry_Math.h"
|
||||
|
||||
#ifdef PS2
|
||||
|
||||
#include <libpad.h>
|
||||
|
||||
|
||||
/////BUTTON'S ID FOR PS2
|
||||
|
||||
#define PS2_BUTTON_SQUARE 1
|
||||
#define PS2_BUTTON_CROSS 2
|
||||
#define PS2_BUTTON_TRIANGLE 3
|
||||
#define PS2_BUTTON_CIRCLE 4
|
||||
#define PS2_BUTTON_L1 5
|
||||
#define PS2_BUTTON_L2 6
|
||||
#define PS2_BUTTON_R1 7
|
||||
#define PS2_BUTTON_R2 8
|
||||
#define PS2_BUTTON_START 9
|
||||
#define PS2_BUTTON_SELECT 10
|
||||
|
||||
#define PS2_DIR_LEFT 1
|
||||
#define PS2_DIR_RIGHT 2
|
||||
#define PS2_DIR_UP 3
|
||||
#define PS2_DIR_DOWN 4
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
===========================================
|
||||
The Joystick interface Class
|
||||
===========================================
|
||||
*/
|
||||
struct ILog;
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
class CJoystick
|
||||
{
|
||||
public:
|
||||
CJoystick();
|
||||
~CJoystick();
|
||||
|
||||
bool Init(ILog *pLog);
|
||||
void Update();
|
||||
void ShutDown();
|
||||
|
||||
int GetNumButtons();
|
||||
bool IsButtonPressed(int buttonnum);
|
||||
int GetDir();
|
||||
int GetHatDir();
|
||||
|
||||
// get analog direction (two analog sticks)
|
||||
Vec3 GetAnalog1Dir(unsigned int joystickID) const;
|
||||
Vec3 GetAnalog2Dir(unsigned int joystickID) const;
|
||||
|
||||
private:
|
||||
|
||||
bool m_initialized;
|
||||
bool m_hatswitch;
|
||||
|
||||
int m_numbuttons;
|
||||
float m_joytime;
|
||||
|
||||
unsigned char m_buttons[8];
|
||||
unsigned char m_dirs[4];
|
||||
unsigned char m_hatdirs[4];
|
||||
|
||||
unsigned int m_numjoysticks; //!< Number of available joysticks
|
||||
// this is for returning analog controller directional input. Input is in the range -1..1 for the x and y axis. z unused
|
||||
Vec3 *m_vAnalog1Dir;
|
||||
Vec3 *m_vAnalog2Dir;
|
||||
|
||||
ILog *m_pLog;
|
||||
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
///////////////PS2 SPECIFIC CODE ////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef PS2
|
||||
|
||||
//PS2 INTERFACE
|
||||
public:
|
||||
|
||||
|
||||
bool ButtonPressed(int Type);
|
||||
bool ButtonHasBeenPressed(int Type);
|
||||
|
||||
|
||||
bool DigitalCrossDirection(int Type);
|
||||
unsigned char LeftStickX();
|
||||
unsigned char LeftStickY();
|
||||
unsigned char RightStickX();
|
||||
unsigned char RightStickY();
|
||||
|
||||
|
||||
|
||||
//PS2 "INTERNAL" UTILITY
|
||||
private:
|
||||
|
||||
void GetAnalog(unsigned char *pData);
|
||||
void GetDigital(unsigned char *pData);
|
||||
void GetButton(unsigned char *pData);
|
||||
|
||||
//Convert the PS2 pad information in PC style format(used by the interface).
|
||||
void ConvertPadInformation();
|
||||
|
||||
|
||||
//The type of Joystick
|
||||
int JoyType;
|
||||
|
||||
|
||||
//For analogic stick
|
||||
unsigned char m_RightX;
|
||||
unsigned char m_RightY;
|
||||
|
||||
unsigned char m_LeftX;
|
||||
unsigned char m_LeftY;
|
||||
|
||||
//For digital stick
|
||||
bool m_Left;
|
||||
bool m_Right;
|
||||
bool m_Up;
|
||||
bool m_Down;
|
||||
|
||||
//Digital button
|
||||
|
||||
bool m_L1;
|
||||
bool m_L2;
|
||||
bool m_R1;
|
||||
bool m_R2;
|
||||
|
||||
bool m_Square;
|
||||
bool m_Circle;
|
||||
bool m_Triangle;
|
||||
bool m_Cross;
|
||||
|
||||
bool m_Start;
|
||||
bool m_Select;
|
||||
|
||||
bool m_TriggerL;
|
||||
bool m_TriggerR;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
bool m_old_L1;
|
||||
bool m_old_L2;
|
||||
bool m_old_R1;
|
||||
bool m_old_R2;
|
||||
|
||||
bool m_old_Square;
|
||||
bool m_old_Circle;
|
||||
bool m_old_Triangle;
|
||||
bool m_old_Cross;
|
||||
|
||||
bool m_old_Start;
|
||||
bool m_old_Select;
|
||||
|
||||
bool m_old_TriggerL;
|
||||
bool m_old_TriggerR;
|
||||
|
||||
//USED TO SIMULATE MOUSE/////////////////
|
||||
|
||||
float m_fMouseScreenX;
|
||||
float m_fMouseScreenY;
|
||||
|
||||
float m_fMouseDeltaX;
|
||||
float m_fMouseDeltaY;
|
||||
|
||||
public:
|
||||
|
||||
float GetVScreenX();
|
||||
float GetVScreenY();
|
||||
|
||||
float GetDeltaX();
|
||||
float GetDeltaY();
|
||||
|
||||
|
||||
void SetScreenX(float x){m_MouseScreenX=x;}
|
||||
void SetScreenY(float y){m_MouseScreenY=y;}
|
||||
|
||||
|
||||
|
||||
//END MOUSE SIMULATION //////////////////
|
||||
|
||||
|
||||
///USED TO SIMULATE THE KEYBOARD ////////
|
||||
|
||||
bool KeyDown(int p_key);
|
||||
bool KeyPressed(int p_key);
|
||||
|
||||
////////////////////////////////////////
|
||||
|
||||
bool HasControl;
|
||||
bool HasMovControl(){return HasControl;}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
///////////////END PS2 SPECIFIC CODE ////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
151
CryInput/Keyboard.h
Normal file
151
CryInput/Keyboard.h
Normal file
@@ -0,0 +1,151 @@
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Crytek CryENGINE Source code
|
||||
//
|
||||
// File:Keyboard.h
|
||||
//
|
||||
// History:
|
||||
// -Jan 31,2001:Created by Marco Corbetta
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef KEYBOARD_H
|
||||
#define KEYBOARD_H
|
||||
|
||||
/*
|
||||
===========================================
|
||||
The Keyboard interface Class
|
||||
Requires Directx 8
|
||||
===========================================
|
||||
*/
|
||||
#include <IInput.h>
|
||||
#ifdef PS2
|
||||
#include <libusbkb.h>
|
||||
#include <sifdev.h>
|
||||
#include <sifrpc.h>
|
||||
#include "Joystick.h"
|
||||
#endif
|
||||
|
||||
struct ILog;
|
||||
struct ICVar;
|
||||
|
||||
//struct AsciiKey
|
||||
//{
|
||||
// char lc[32];
|
||||
// char uc[32];
|
||||
//};
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
class CKeyboard :
|
||||
public IKeyboard
|
||||
{
|
||||
public:
|
||||
|
||||
CKeyboard() { m_exmode=false; }
|
||||
|
||||
#ifdef WIN32
|
||||
bool Init(ILog *pLog,LPDIRECTINPUT8 &g_pdi,HINSTANCE hinst,HWND hwnd);
|
||||
#else
|
||||
bool Init(ILog *pLog);
|
||||
#endif
|
||||
|
||||
void ShutDown();
|
||||
void Update();
|
||||
|
||||
inline void SetKey(int p_key,int value)
|
||||
{
|
||||
#ifdef WIN32
|
||||
m_Keys[p_key]=value;
|
||||
#endif
|
||||
}
|
||||
|
||||
inline void SetPrevKey(int p_key,int value)
|
||||
{
|
||||
#ifdef WIN32
|
||||
m_oldKeys[p_key]=value;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool KeyDown(int p_key);
|
||||
bool KeyPressed(int p_key);
|
||||
bool KeyReleased(int p_key);
|
||||
void ClearKey(int p_key);
|
||||
int GetKeyPressedCode();
|
||||
const char *GetKeyPressedName();
|
||||
|
||||
int GetKeyDownCode();
|
||||
const char *GetKeyDownName();
|
||||
|
||||
void SetExclusive(bool value,void *hwnd=0);
|
||||
|
||||
void WaitForKey();
|
||||
|
||||
void ClearKeyState();
|
||||
static void SetupKeyNames();
|
||||
static AsciiKey m_AsciiTable[256];
|
||||
static char m_keynames[256][32];
|
||||
|
||||
private:
|
||||
|
||||
bool Acquire();
|
||||
bool UnAcquire();
|
||||
|
||||
#ifdef WIN32
|
||||
LPDIRECTINPUTDEVICE8 m_g_pKeyboard;
|
||||
HINSTANCE m_hinst;
|
||||
HWND m_hwnd;
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////
|
||||
////////PS2 SPECIFIC DATA /////////////////
|
||||
///////////////////////////////////////////
|
||||
|
||||
#ifdef PS2
|
||||
|
||||
//Keyboard's ID
|
||||
int m_KeyboardNumber;
|
||||
|
||||
unsigned char ASCIPRESSED[255];
|
||||
unsigned char ASCIPRESSEDOLD[255];
|
||||
|
||||
//Just one key pressed a time (as the PC version) to be updated
|
||||
char m_KeyPressedName;
|
||||
|
||||
//Keyboard info
|
||||
USBKBINFO_t keyinfo;
|
||||
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////
|
||||
////////PS2 SPECIFIC FUNCTIONS ////////////
|
||||
///////////////////////////////////////////
|
||||
|
||||
#ifdef PS2
|
||||
public:
|
||||
|
||||
void SetPad(CJoystick *pJoy){m_pJoy=pJoy;}
|
||||
int ConvertCode(int Code);
|
||||
|
||||
private:
|
||||
|
||||
//CARLONE....IF NO MOUSE....USE JOYSTICK TO SIMULATE IT
|
||||
CJoystick *m_pJoy;
|
||||
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////
|
||||
///////////////////////////////////////////
|
||||
///////////////////////////////////////////
|
||||
|
||||
ICVar *m_cvBufferedKeys;
|
||||
|
||||
unsigned char m_Keys[256],m_oldKeys[256];
|
||||
int m_KeyTable[256];
|
||||
bool m_exmode;
|
||||
|
||||
char m_tempstring[256];
|
||||
|
||||
ILog *m_pLog;
|
||||
};
|
||||
|
||||
#endif
|
||||
5
CryInput/MSSCCPRJ.SCC
Normal file
5
CryInput/MSSCCPRJ.SCC
Normal file
@@ -0,0 +1,5 @@
|
||||
SCC = This is a source code control file
|
||||
|
||||
[CryInput.vcproj]
|
||||
SCC_Aux_Path = "P4SCC#perforce:1666##marcoc_code##PC018"
|
||||
SCC_Project_Name = Perforce Project
|
||||
41
CryInput/ReadMe.txt
Normal file
41
CryInput/ReadMe.txt
Normal file
@@ -0,0 +1,41 @@
|
||||
========================================================================
|
||||
DYNAMIC LINK LIBRARY : CryInput
|
||||
========================================================================
|
||||
|
||||
|
||||
AppWizard has created this CryInput DLL for you.
|
||||
|
||||
This file contains a summary of what you will find in each of the files that
|
||||
make up your CryInput application.
|
||||
|
||||
CryInput.dsp
|
||||
This file (the project file) contains information at the project level and
|
||||
is used to build a single project or subproject. Other users can share the
|
||||
project (.dsp) file, but they should export the makefiles locally.
|
||||
|
||||
CryInput.cpp
|
||||
This is the main DLL source file.
|
||||
|
||||
When created, this DLL does not export any symbols. As a result, it
|
||||
will not produce a .lib file when it is built. If you wish this project
|
||||
to be a project dependency of some other project, you will either need to
|
||||
add code to export some symbols from the DLL so that an export library
|
||||
will be produced, or you can check the "doesn't produce lib" checkbox in
|
||||
the Linker settings page for this project.
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
Other standard files:
|
||||
|
||||
StdAfx.h, StdAfx.cpp
|
||||
These files are used to build a precompiled header (PCH) file
|
||||
named CryInput.pch and a precompiled types file named StdAfx.obj.
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
Other notes:
|
||||
|
||||
AppWizard uses "TODO:" to indicate parts of the source code you
|
||||
should add to or customize.
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
8
CryInput/StdAfx.cpp
Normal file
8
CryInput/StdAfx.cpp
Normal file
@@ -0,0 +1,8 @@
|
||||
// stdafx.cpp : source file that includes just the standard includes
|
||||
// CryInput.pch will be the pre-compiled header
|
||||
// stdafx.obj will contain the pre-compiled type information
|
||||
|
||||
#include "stdafx.h"
|
||||
|
||||
// TODO: reference any additional headers you need in STDAFX.H
|
||||
// and not in this file
|
||||
46
CryInput/StdAfx.h
Normal file
46
CryInput/StdAfx.h
Normal file
@@ -0,0 +1,46 @@
|
||||
// stdafx.h : include file for standard system include files,
|
||||
// or project specific include files that are used frequently, but
|
||||
// are changed infrequently
|
||||
//
|
||||
|
||||
#if !defined(AFX_STDAFX_H__448E473C_48A4_4BA1_8498_3F9DAA9FE6A4__INCLUDED_)
|
||||
#define AFX_STDAFX_H__448E473C_48A4_4BA1_8498_3F9DAA9FE6A4__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// THIS MUST BE AT THE VERY BEGINING OF STDAFX.H FILE.
|
||||
// Disable STL threading support, (makes STL faster)
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
#define _NOTHREADS
|
||||
#define _STLP_NO_THREADS
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Insert your headers here
|
||||
|
||||
#include "platform.h"
|
||||
|
||||
#ifdef WIN32
|
||||
#include <windows.h>
|
||||
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
||||
#include <dinput.h>
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
#define USE_NEWPOOL
|
||||
#include <CryMemoryManager.h>
|
||||
|
||||
#ifdef _DEBUG
|
||||
#include <crtdbg.h>
|
||||
#endif
|
||||
|
||||
#include <ITimer.h>
|
||||
#include <IInput.h>
|
||||
// TODO: reference additional headers your program requires here
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_STDAFX_H__448E473C_48A4_4BA1_8498_3F9DAA9FE6A4__INCLUDED_)
|
||||
247
CryInput/XActionMap.cpp
Normal file
247
CryInput/XActionMap.cpp
Normal file
@@ -0,0 +1,247 @@
|
||||
// XActionMap.cpp: implementation of the CXActionMap class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "Input.h"
|
||||
#include "XActionMap.h"
|
||||
#include "XActionMapManager.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#define DEBUG_CLIENTBLOCK new( _NORMAL_BLOCK, THIS_FILE, __LINE__)
|
||||
#define new DEBUG_CLIENTBLOCK
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
CXActionMap::CXActionMap(CXActionMapManager *pManager)
|
||||
{
|
||||
m_pManager=pManager;
|
||||
|
||||
}
|
||||
|
||||
CXActionMap::~CXActionMap()
|
||||
{
|
||||
}
|
||||
|
||||
void CXActionMap::GetBinding(XACTIONID nActionID, int nKeyPos, XBind &Bind)
|
||||
{
|
||||
Bind.nKey=XKEY_NULL;
|
||||
Bind.nModifier=XKEY_NULL;
|
||||
if ((nKeyPos<0) || (nKeyPos>MAX_BINDS_PER_ACTION))
|
||||
return;
|
||||
BindsMapItor itor;
|
||||
itor=m_mapBinds.find(nActionID);
|
||||
if (itor==m_mapBinds.end())
|
||||
return;
|
||||
Bind=itor->second.keys[nKeyPos].Bind;
|
||||
}
|
||||
|
||||
void CXActionMap::GetBinding(XACTIONID nActionID, int nKeyPos, int &nKey, int &nModifier)
|
||||
{
|
||||
nKey=XKEY_NULL;
|
||||
nModifier=XKEY_NULL;
|
||||
if ((nKeyPos<0) || (nKeyPos>MAX_BINDS_PER_ACTION))
|
||||
return;
|
||||
BindsMapItor itor;
|
||||
itor=m_mapBinds.find(nActionID);
|
||||
if (itor==m_mapBinds.end())
|
||||
return;
|
||||
nKey=itor->second.keys[nKeyPos].Bind.nKey;
|
||||
nModifier=itor->second.keys[nKeyPos].Bind.nModifier;
|
||||
}
|
||||
|
||||
void CXActionMap::GetBinding(XACTIONID nActionID, int nKeyPos, char *pszKey, char *pszModifier)
|
||||
{
|
||||
int nKey;
|
||||
int nModifier;
|
||||
GetBinding(nActionID, nKeyPos, nKey, nModifier);
|
||||
strcpy(pszKey, m_pManager->m_pInput->GetKeyName(nKey));
|
||||
strcpy(pszModifier, m_pManager->m_pInput->GetKeyName(nModifier));
|
||||
}
|
||||
|
||||
void CXActionMap::GetBindDifferences(IActionMap *pActionMap, std::vector<int>& keys)
|
||||
{
|
||||
keys.clear();
|
||||
|
||||
for (BindsMapItor itor = m_mapBinds.begin(); itor != m_mapBinds.end(); ++itor)
|
||||
{
|
||||
XACTIONID action = itor->first;
|
||||
XBind bind;
|
||||
|
||||
pActionMap->GetBinding(action, 0, bind);
|
||||
if (bind.nKey==XKEY_NULL)
|
||||
{
|
||||
for (int i = 0; i < MAX_BINDS_PER_ACTION; ++i)
|
||||
{
|
||||
if (itor->second.keys[i].Bind.nKey!=XKEY_NULL)
|
||||
{
|
||||
keys.push_back(itor->second.keys[i].Bind.nKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CXActionMap::ResetAllBindings()
|
||||
{
|
||||
BindsMapItor itor;
|
||||
itor=m_mapBinds.begin();
|
||||
while (itor!=m_mapBinds.end())
|
||||
{
|
||||
itor->second.RemoveAllBindings();
|
||||
++itor;
|
||||
}
|
||||
}
|
||||
|
||||
void CXActionMap::ResetBinding(XACTIONID nActionID)
|
||||
{
|
||||
BindsMapItor itor;
|
||||
itor=m_mapBinds.find(nActionID);
|
||||
if (itor!=m_mapBinds.end())
|
||||
itor->second.RemoveAllBindings();
|
||||
}
|
||||
|
||||
void CXActionMap::RemoveBind(XACTIONID nActionID, XBind &NewBind, XActionActivationMode aam)//,int nKey,int nModifier)
|
||||
{
|
||||
BindsMapItor itor;
|
||||
itor=m_mapBinds.find(nActionID);
|
||||
if (itor!=m_mapBinds.end())
|
||||
itor->second.RemoveBind(NewBind, aam);//nKey,nModifier,aam);
|
||||
}
|
||||
|
||||
void CXActionMap::BindAction(XACTIONID nActionID,int nKey, int nModifier, int iKeyPos)//, bool bConfigurable, bool bReplicate)
|
||||
{
|
||||
XBind Bind;
|
||||
Bind.nKey=nKey;
|
||||
Bind.nModifier=nModifier;
|
||||
// Bind.bConfigurable=bConfigurable;
|
||||
// Bind.bReplicate=bReplicate;
|
||||
BindAction(nActionID, Bind, iKeyPos);
|
||||
}
|
||||
|
||||
void CXActionMap::BindAction(XACTIONID nActionID, XBind &NewBind, int iKeyPos)//,int nKey,int nModifier)
|
||||
{
|
||||
BindsMapItor itor;
|
||||
XActionActivationMode aam=m_pManager->GetActionActivationMode(nActionID);
|
||||
RemoveBind(nActionID, NewBind, aam);
|
||||
/* itor=m_mapBinds.begin();
|
||||
XActionActivationMode aam;
|
||||
aam=m_pManager->GetActionActivationMode(nActionID);
|
||||
|
||||
while(itor!=m_mapBinds.end())
|
||||
{
|
||||
itor->second.RemoveBind(NewBind, aam);//nKey,nModifier,aam);
|
||||
++itor;
|
||||
}
|
||||
*/
|
||||
//insert a new bind
|
||||
itor=m_mapBinds.find(nActionID);
|
||||
|
||||
if(itor==m_mapBinds.end())
|
||||
{
|
||||
XActionBind bind;
|
||||
|
||||
if (iKeyPos > -1)
|
||||
{
|
||||
bind.SetBind(iKeyPos, NewBind, aam);
|
||||
}
|
||||
else
|
||||
{
|
||||
bind.PushBind(NewBind, aam);//nKey,nModifier,aam);
|
||||
}
|
||||
m_mapBinds.insert(BindsMapItor::value_type(nActionID,bind));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (iKeyPos > -1)
|
||||
{
|
||||
itor->second.SetBind(iKeyPos, NewBind, aam);
|
||||
}
|
||||
else
|
||||
{
|
||||
itor->second.PushBind(NewBind, aam);//nKey,nModifier,aam);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CXActionMap::BindAction(XACTIONID nActionID, const char *sKey,const char *sModifier, int iKeyPos)
|
||||
{
|
||||
if (!sKey)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
char sTemp[256];strcpy(sTemp,sKey);
|
||||
_strlwr(sTemp);
|
||||
XBind NewBind;
|
||||
NewBind.nKey=m_pManager->m_pInput->GetKeyID(sTemp);
|
||||
NewBind.nModifier=0;
|
||||
if(NewBind.nKey ){
|
||||
if(sModifier)
|
||||
{
|
||||
strcpy(sTemp,sModifier);_strlwr(sTemp);
|
||||
NewBind.nModifier=m_pManager->m_pInput->GetKeyID(sTemp);
|
||||
}
|
||||
|
||||
BindAction(nActionID,NewBind, iKeyPos);//nKey,nModifier);
|
||||
}
|
||||
}
|
||||
|
||||
bool CXActionMap::CheckActionMap(XACTIONID nActionID)
|
||||
{
|
||||
CurrentActionMapItor itor;
|
||||
itor=m_mapCurrentActions.find(nActionID);
|
||||
if(itor!=m_mapCurrentActions.end())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void CXActionMap::Reset()
|
||||
{
|
||||
m_mapCurrentActions.clear();
|
||||
|
||||
}
|
||||
|
||||
void CXActionMap::Update()
|
||||
{
|
||||
m_mapCurrentActions.clear();
|
||||
|
||||
BindsMapItor itor=m_mapBinds.begin();
|
||||
while(itor!=m_mapBinds.end())
|
||||
{
|
||||
XActionBind &bind=itor->second;
|
||||
//optional value send by mouse or pads
|
||||
float fValue=0.0;
|
||||
XActivationEvent ae;
|
||||
if(m_pManager->CheckBind(bind,fValue,ae))
|
||||
{
|
||||
m_mapCurrentActions.insert(CurrentActionMapItor::value_type(itor->first,XActionData(fValue,ae)));
|
||||
}
|
||||
++itor;
|
||||
}
|
||||
//if(!m_mapCurrentActions.empty())
|
||||
//{
|
||||
CurrentActionMapItor itorA;
|
||||
itorA=m_mapCurrentActions.begin();
|
||||
while(itorA!=m_mapCurrentActions.end())
|
||||
{
|
||||
m_pManager->Notify(itorA->first,itorA->second.fParam,itorA->second.aeEvent);
|
||||
//avoid to loop forever if the action map is cleaned
|
||||
//inside notify(eg SetActionMap())
|
||||
if(m_mapCurrentActions.empty())
|
||||
return;
|
||||
++itorA;
|
||||
}
|
||||
//}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CXActionMap::ProcessInputEvent( const SInputEvent &event )
|
||||
{
|
||||
}
|
||||
70
CryInput/XActionMap.h
Normal file
70
CryInput/XActionMap.h
Normal file
@@ -0,0 +1,70 @@
|
||||
// XActionMap.h: interface for the CXActionMap class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_XACTIONMAP_H__8B377CD3_569A_4B34_A450_351530562078__INCLUDED_)
|
||||
#define AFX_XACTIONMAP_H__8B377CD3_569A_4B34_A450_351530562078__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <IInput.h>
|
||||
#include "XActionMapManager.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
typedef std::map<XACTIONID,XActionBind> BindsMap;
|
||||
typedef BindsMap::iterator BindsMapItor;
|
||||
|
||||
struct XActionData{
|
||||
XActionData(float p,XActivationEvent e){
|
||||
fParam=p;
|
||||
aeEvent=e;
|
||||
}
|
||||
XActionData(const XActionData &o)
|
||||
{
|
||||
fParam=o.fParam;
|
||||
aeEvent=o.aeEvent;
|
||||
}
|
||||
float fParam;
|
||||
XActivationEvent aeEvent;
|
||||
};
|
||||
typedef std::map<XACTIONID,XActionData> CurrentActionMap;
|
||||
typedef CurrentActionMap::iterator CurrentActionMapItor;
|
||||
///////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
class CXActionMap :
|
||||
public IActionMap
|
||||
{
|
||||
public:
|
||||
CXActionMap(CXActionMapManager *pManager);
|
||||
virtual ~CXActionMap();
|
||||
public:
|
||||
//IActionMap
|
||||
void ResetAllBindings();
|
||||
void ResetBinding(XACTIONID nActionID);
|
||||
void RemoveBind(XACTIONID nActionID, XBind &NewBind, XActionActivationMode aam);
|
||||
void BindAction(XACTIONID nActionID, XBind &NewBind, int iKeyPos = -1);//XACTIONID nActionID,int nKey,int nModifier=XKEY_NULL);
|
||||
void BindAction(XACTIONID nActionID,int nKey, int nModifier=XKEY_NULL, int iKeyPos = -1);//, bool bConfigurable=true, bool bReplicate=false);
|
||||
void BindAction(XACTIONID nActionID,const char *sKey,const char *sModifier=NULL, int iKeyPos = -1);
|
||||
void GetBinding(XACTIONID nActionID, int nKeyPos, XBind &Bind);
|
||||
void GetBinding(XACTIONID nActionID, int nKeyPos, int &nKey, int &nModifier); // nKey==XKEY_NULL if no more keys are bound to this action or action doesnt exist
|
||||
void GetBinding(XACTIONID nActionID, int nKeyPos, char *pszKey, char *pszModifier); // pszKey=="" if no more keys are bound to this action or action doesnt exist
|
||||
void GetBindDifferences(IActionMap *pActionMap, std::vector<int>& keys);
|
||||
////////////
|
||||
bool CheckActionMap(XACTIONID nActionID);
|
||||
void Update();
|
||||
void Reset();
|
||||
|
||||
void ProcessInputEvent( const SInputEvent &event );
|
||||
private:
|
||||
CXActionMapManager *m_pManager;
|
||||
BindsMap m_mapBinds;
|
||||
CurrentActionMap m_mapCurrentActions;
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_XACTIONMAP_H__8B377CD3_569A_4B34_A450_351530562078__INCLUDED_)
|
||||
436
CryInput/XActionMapManager.cpp
Normal file
436
CryInput/XActionMapManager.cpp
Normal file
@@ -0,0 +1,436 @@
|
||||
// XActionMapManager.cpp: implementation of the CXActionMapManager class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "Input.h"
|
||||
#include "XActionMap.h"
|
||||
#include "XActionMapManager.h"
|
||||
|
||||
#include <ISystem.h>
|
||||
|
||||
#ifdef _DEBUG
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#define DEBUG_CLIENTBLOCK new( _NORMAL_BLOCK, THIS_FILE, __LINE__)
|
||||
#define new DEBUG_CLIENTBLOCK
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
CXActionMapManager::CXActionMapManager(CInput *pInput)
|
||||
{
|
||||
m_bEnabled = 1;
|
||||
m_pInput=pInput;
|
||||
m_pCurrentActionMap=NULL;
|
||||
m_pSink=NULL;
|
||||
m_bInvertedMouse=false;
|
||||
pInput->AddEventListener( this );
|
||||
}
|
||||
|
||||
CXActionMapManager::~CXActionMapManager()
|
||||
{
|
||||
ActionMapMapItor itor;
|
||||
itor=m_mapActionMaps.begin();
|
||||
while(itor!=m_mapActionMaps.end())
|
||||
{
|
||||
CXActionMap *pMap=itor->second;
|
||||
delete pMap;
|
||||
++itor;
|
||||
}
|
||||
}
|
||||
|
||||
void CXActionMapManager::SetSink(IActionMapSink *pSink)
|
||||
{
|
||||
m_pSink=pSink;
|
||||
}
|
||||
|
||||
void CXActionMapManager::CreateAction(XACTIONID nActionID,const char *sActionName,XActionActivationMode aam)
|
||||
{
|
||||
ActionIDsMapItor itorID;
|
||||
ActionNamesMapItor itorName;
|
||||
itorID=m_mapActionIDs.find(nActionID);
|
||||
//if the action ID already exists return
|
||||
if(itorID!=m_mapActionIDs.end())
|
||||
return;
|
||||
//if the action Name already exists return
|
||||
itorName=m_mapActionNames.find(sActionName);
|
||||
if(itorName!=m_mapActionNames.end())
|
||||
return;
|
||||
m_mapActionIDs.insert(ActionIDsMapItor::value_type(nActionID,aam));
|
||||
m_mapActionNames.insert(ActionNamesMapItor::value_type(sActionName,nActionID));
|
||||
}
|
||||
|
||||
XActionActivationMode CXActionMapManager::GetActionActivationMode(XACTIONID nActionID)
|
||||
{
|
||||
ActionIDsMapItor itorID;
|
||||
itorID=m_mapActionIDs.find(nActionID);
|
||||
//default
|
||||
if(itorID==m_mapActionIDs.end())
|
||||
return aamOnPress;
|
||||
|
||||
return itorID->second;
|
||||
}
|
||||
|
||||
void CXActionMapManager::GetActionMaps(IActionMapDumpSink *pCallback)
|
||||
{
|
||||
ActionMapMapItor itor=m_mapActionMaps.begin();
|
||||
while (itor!=m_mapActionMaps.end())
|
||||
{
|
||||
pCallback->OnElementFound(itor->first.c_str(), itor->second);
|
||||
++itor;
|
||||
}
|
||||
}
|
||||
|
||||
void CXActionMapManager::RemoveBind(XACTIONID nActionID, XBind &NewBind, XActionActivationMode aam)
|
||||
{
|
||||
ActionMapMapItor itor=m_mapActionMaps.begin();
|
||||
while (itor!=m_mapActionMaps.end())
|
||||
{
|
||||
itor->second->RemoveBind(nActionID, NewBind, aam);
|
||||
++itor;
|
||||
}
|
||||
}
|
||||
|
||||
IActionMap *CXActionMapManager::CreateActionMap(const char *s)
|
||||
{
|
||||
ActionMapMapItor itor;
|
||||
itor=m_mapActionMaps.find(s);
|
||||
//if the map already exists return the existing one
|
||||
if(itor!=m_mapActionMaps.end())
|
||||
return itor->second;
|
||||
|
||||
CXActionMap *pAM=new CXActionMap(this);
|
||||
m_mapActionMaps.insert(ActionMapMapItor::value_type(s,pAM));
|
||||
|
||||
return pAM;
|
||||
}
|
||||
|
||||
IActionMap *CXActionMapManager::GetActionMap(const char *s)
|
||||
{
|
||||
ActionMapMapItor itor;
|
||||
itor=m_mapActionMaps.find(s);
|
||||
|
||||
if(itor!=m_mapActionMaps.end())
|
||||
return itor->second;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void CXActionMapManager::Update(unsigned int nTimeMSec)
|
||||
{
|
||||
m_nCurrentTime=nTimeMSec;
|
||||
if(m_pCurrentActionMap)
|
||||
m_pCurrentActionMap->Update();
|
||||
}
|
||||
|
||||
void CXActionMapManager::ResetAllBindings()
|
||||
{
|
||||
ActionMapMapItor itor;
|
||||
itor=m_mapActionMaps.begin();
|
||||
|
||||
while(itor!=m_mapActionMaps.end())
|
||||
{
|
||||
CXActionMap *pAM=itor->second;
|
||||
if (pAM)
|
||||
pAM->ResetAllBindings();
|
||||
++itor;
|
||||
}
|
||||
}
|
||||
|
||||
void CXActionMapManager::SetActionMap(const char *s)
|
||||
{
|
||||
// reset keys when changing action map
|
||||
//m_pInput->GetIKeyboard()->ClearKeyState();
|
||||
|
||||
|
||||
ActionMapMapItor itor;
|
||||
itor=m_mapActionMaps.find(s);
|
||||
|
||||
if(itor!=m_mapActionMaps.end())
|
||||
{
|
||||
CXActionMap *pNewActionMap = itor->second;
|
||||
|
||||
if(m_pCurrentActionMap)
|
||||
{
|
||||
// reset the key state for all actions
|
||||
std::vector<int> keys;
|
||||
std::vector<int>::iterator i;
|
||||
m_pCurrentActionMap->GetBindDifferences(pNewActionMap, keys);
|
||||
|
||||
for (i=keys.begin(); i != keys.end(); ++i)
|
||||
m_pInput->GetIKeyboard()->ClearKey(*i);
|
||||
|
||||
m_pCurrentActionMap->Reset();
|
||||
}
|
||||
|
||||
m_pCurrentActionMap = pNewActionMap;
|
||||
}
|
||||
else
|
||||
m_pCurrentActionMap=NULL;
|
||||
}
|
||||
|
||||
bool CXActionMapManager::CheckActionMap(XACTIONID nActionID)
|
||||
{
|
||||
if(!m_pCurrentActionMap)
|
||||
return false;
|
||||
return m_pCurrentActionMap->CheckActionMap(nActionID);
|
||||
}
|
||||
|
||||
bool CXActionMapManager::CheckActionMap(const char *sActionName)
|
||||
{
|
||||
ActionNamesMapItor itorName;
|
||||
itorName=m_mapActionNames.find(sActionName);
|
||||
if(itorName==m_mapActionNames.end())
|
||||
return false;
|
||||
return CheckActionMap(itorName->second);
|
||||
}
|
||||
|
||||
void CXActionMapManager::SetInvertedMouse(bool bEnable)
|
||||
{
|
||||
m_bInvertedMouse=bEnable;
|
||||
}
|
||||
|
||||
bool CXActionMapManager::GetInvertedMouse()
|
||||
{
|
||||
return m_bInvertedMouse;
|
||||
}
|
||||
|
||||
bool CXActionMapManager::CheckBind(XActionBind &bind,float &fVal,XActivationEvent &ae)
|
||||
{
|
||||
int n=0;
|
||||
while(n<MAX_BINDS_PER_ACTION)
|
||||
{
|
||||
//if (bind.keys[n].Bind.nKey==XKEY_MWHEEL_DOWN)
|
||||
// int a=1;
|
||||
|
||||
if(CheckKey(bind.keys[n],ae))
|
||||
{
|
||||
switch(bind.keys[n].Bind.nKey)
|
||||
{
|
||||
case XKEY_MAXIS_X:
|
||||
fVal=m_pInput->MouseGetDeltaX();
|
||||
break;
|
||||
case XKEY_MAXIS_Y:
|
||||
fVal=m_bInvertedMouse?-m_pInput->MouseGetDeltaY():m_pInput->MouseGetDeltaY();
|
||||
break;
|
||||
case XKEY_MWHEEL_UP:
|
||||
case XKEY_MWHEEL_DOWN:
|
||||
fVal=m_pInput->MouseGetDeltaZ();
|
||||
break;
|
||||
default:
|
||||
fVal=0.0;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
n++;
|
||||
}
|
||||
ae=etPressing;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CXActionMapManager::CheckKey(struct XActionBind::tagKey &key,XActivationEvent &ae)
|
||||
{
|
||||
switch(key.aam)
|
||||
{
|
||||
case aamOnPress:
|
||||
ae=etPressing;
|
||||
return CheckPressedKey(key);
|
||||
break;
|
||||
case aamOnPressAndRelease:
|
||||
if(CheckPressedKey(key)){
|
||||
ae=etPressing;
|
||||
return true;
|
||||
}
|
||||
ae=etReleasing;
|
||||
return CheckReleasedKey(key);
|
||||
break;
|
||||
case aamOnDoublePress:
|
||||
return CheckDoublePressedKey(key);
|
||||
ae=etDoublePressing;
|
||||
break;
|
||||
case aamOnRelease:
|
||||
ae=etReleasing;
|
||||
return CheckReleasedKey(key);
|
||||
break;
|
||||
case aamOnHold:
|
||||
ae=etHolding;
|
||||
return CheckHoldKey(key);
|
||||
break;
|
||||
default:
|
||||
CryError( "<CryInput> (CXActionMapManager::CheckKey) Unknown Key pressed" );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CXActionMapManager::CheckPressedKey(struct XActionBind::tagKey &key)
|
||||
{
|
||||
if(IS_NULL_KEY(key.Bind.nKey))
|
||||
return false;
|
||||
|
||||
if(IS_KEYBOARD_KEY(key.Bind.nKey))
|
||||
{
|
||||
return m_pInput->KeyPressed(key.Bind.nKey);
|
||||
}
|
||||
else if(IS_MOUSE_KEY(key.Bind.nKey))
|
||||
{
|
||||
return m_pInput->MousePressed(key.Bind.nKey);
|
||||
}
|
||||
#ifndef _XBOX
|
||||
else if(IS_JOYPAD_KEY(key.Bind.nKey))
|
||||
{
|
||||
//<<FIXME>> implement joypad
|
||||
return false;
|
||||
}
|
||||
#else // _XBOX
|
||||
else if(IS_GAMEPAD_KEY(key.Bind.nKey))
|
||||
{
|
||||
return m_pInput->GetIGamepad()->KeyPressed(key.Bind.nKey);
|
||||
}
|
||||
#endif //_XBOX
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CXActionMapManager::CheckDoublePressedKey(struct XActionBind::tagKey &key)
|
||||
{
|
||||
unsigned int nDeltaTime=m_nCurrentTime-key.nLastPess;
|
||||
if(IS_NULL_KEY(key.Bind.nKey))
|
||||
return false;
|
||||
|
||||
if(IS_KEYBOARD_KEY(key.Bind.nKey))
|
||||
{
|
||||
if(m_pInput->KeyPressed(key.Bind.nKey))
|
||||
{
|
||||
if(nDeltaTime<300)
|
||||
{
|
||||
key.nLastPess=0;
|
||||
return true;
|
||||
}
|
||||
key.nLastPess=m_nCurrentTime;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else if(IS_MOUSE_KEY(key.Bind.nKey))
|
||||
{
|
||||
if(m_pInput->MousePressed(key.Bind.nKey))
|
||||
{
|
||||
if(nDeltaTime<300)
|
||||
{
|
||||
key.nLastPess=0;
|
||||
return true;
|
||||
}
|
||||
key.nLastPess=m_nCurrentTime;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#ifndef _XBOX
|
||||
else if(IS_JOYPAD_KEY(key.Bind.nKey))
|
||||
{
|
||||
|
||||
return false;
|
||||
}
|
||||
#else // _XBOX
|
||||
else if(IS_GAMEPAD_KEY(key.Bind.nKey))
|
||||
{
|
||||
|
||||
return false;
|
||||
}
|
||||
#endif //_XBOX
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CXActionMapManager::CheckReleasedKey(struct XActionBind::tagKey &key)
|
||||
{
|
||||
if(IS_NULL_KEY(key.Bind.nKey))
|
||||
return false;
|
||||
|
||||
if(IS_KEYBOARD_KEY(key.Bind.nKey))
|
||||
{
|
||||
return m_pInput->KeyReleased(key.Bind.nKey);
|
||||
}
|
||||
else if(IS_MOUSE_KEY(key.Bind.nKey))
|
||||
{
|
||||
return m_pInput->MouseReleased(key.Bind.nKey);
|
||||
}
|
||||
#ifndef _XBOX
|
||||
else if(IS_JOYPAD_KEY(key.Bind.nKey))
|
||||
{
|
||||
//<<FIXME>> implement joypad
|
||||
return false;
|
||||
}
|
||||
#else //_XBOBX
|
||||
else if(IS_GAMEPAD_KEY(key.Bind.nKey))
|
||||
{
|
||||
return m_pInput->GetIGamepad()->KeyReleased(key.Bind.nKey);
|
||||
|
||||
}
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CXActionMapManager::CheckHoldKey(struct XActionBind::tagKey &key)
|
||||
{
|
||||
if(IS_NULL_KEY(key.Bind.nKey))
|
||||
return false;
|
||||
|
||||
if(IS_KEYBOARD_KEY(key.Bind.nKey))
|
||||
{
|
||||
return m_pInput->KeyDown(key.Bind.nKey);
|
||||
}
|
||||
else if(IS_MOUSE_KEY(key.Bind.nKey))
|
||||
{
|
||||
return m_pInput->MouseDown(key.Bind.nKey);
|
||||
}
|
||||
#ifndef _XBOX
|
||||
else if(IS_JOYPAD_KEY(key.Bind.nKey))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
#else // _XBOX
|
||||
else if(IS_GAMEPAD_KEY(key.Bind.nKey))
|
||||
{
|
||||
return m_pInput->GetIGamepad()->KeyDown(key.Bind.nKey);
|
||||
}
|
||||
#endif //_XBOX
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void CXActionMapManager::Enable()
|
||||
{
|
||||
m_bEnabled = 1;
|
||||
}
|
||||
|
||||
void CXActionMapManager::Disable()
|
||||
{
|
||||
m_bEnabled = 0;
|
||||
}
|
||||
|
||||
bool CXActionMapManager::IsEnabled()
|
||||
{
|
||||
return m_bEnabled;
|
||||
}
|
||||
|
||||
void CXActionMapManager::Reset()
|
||||
{
|
||||
if(m_pCurrentActionMap)
|
||||
m_pCurrentActionMap->Reset();
|
||||
}
|
||||
|
||||
void CXActionMapManager::Release()
|
||||
{
|
||||
delete this;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool CXActionMapManager::OnInputEvent( const SInputEvent &event )
|
||||
{
|
||||
if(m_pCurrentActionMap)
|
||||
m_pCurrentActionMap->ProcessInputEvent( event );
|
||||
|
||||
return false;
|
||||
}
|
||||
214
CryInput/XActionMapManager.h
Normal file
214
CryInput/XActionMapManager.h
Normal file
@@ -0,0 +1,214 @@
|
||||
// XActionMapManager.h: interface for the CXActionMapManager class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_XACTIONMAPMANAGER_H__62E67F42_D4C6_4DE9_AE51_6562CCCDAD04__INCLUDED_)
|
||||
#define AFX_XACTIONMAPMANAGER_H__62E67F42_D4C6_4DE9_AE51_6562CCCDAD04__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
struct IActionMap;
|
||||
class CXActionMap;
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
struct XActionBind
|
||||
{
|
||||
//
|
||||
XActionBind()
|
||||
{
|
||||
memset(keys,0,sizeof(keys));
|
||||
}
|
||||
XActionBind( const XActionBind &a ) { *this = a; }
|
||||
XActionBind& operator=( const XActionBind &a )
|
||||
{
|
||||
memcpy(keys,a.keys,sizeof(keys));
|
||||
return *this;
|
||||
}
|
||||
bool IsActivationModeEquivalent(XActionActivationMode aam1,XActionActivationMode aam2)
|
||||
{
|
||||
if(aam1==aam2)
|
||||
return true;
|
||||
if((aam1==aamOnPress) && (aam2==aamOnHold) ||
|
||||
(aam2==aamOnPress) && (aam1==aamOnHold)
|
||||
)return true;
|
||||
if((aam1==aamOnPressAndRelease) || (aam2==aamOnPressAndRelease))
|
||||
return true;
|
||||
return false;
|
||||
|
||||
}
|
||||
void RemoveBind(XBind &bind, XActionActivationMode aam)//int nKey,int nModifier,XActionActivationMode aam)
|
||||
{
|
||||
int n;
|
||||
for(n=0;n<MAX_BINDS_PER_ACTION;n++)
|
||||
{
|
||||
if((keys[n].Bind.nKey==bind.nKey) && (keys[n].Bind.nModifier==bind.nModifier) && IsActivationModeEquivalent(keys[n].aam,aam))
|
||||
{
|
||||
// char sTemp[1000];
|
||||
// sprintf(sTemp,"Bind removed %03d\n",keys[n].nKey);
|
||||
// ::OutputDebugString(sTemp);
|
||||
keys[n].Bind.nKey=0;
|
||||
keys[n].Bind.nModifier=0;
|
||||
keys[n].aam=aamOnPress;
|
||||
keys[n].nLastPess=0;
|
||||
}
|
||||
}
|
||||
}
|
||||
void RemoveAllBindings()
|
||||
{
|
||||
int n;
|
||||
for(n=0;n<MAX_BINDS_PER_ACTION;n++)
|
||||
{
|
||||
keys[n].Bind.nKey=0;
|
||||
keys[n].Bind.nModifier=0;
|
||||
keys[n].aam=aamOnPress;
|
||||
keys[n].nLastPess=0;
|
||||
}
|
||||
}
|
||||
|
||||
void PushBind(XBind &bind, XActionActivationMode aam)//int nKey,int nModifier,XActionActivationMode aam)
|
||||
{
|
||||
/* bool bAssigned=false;
|
||||
int n;
|
||||
for(n=0;n<MAX_BINDS_PER_ACTION;n++)
|
||||
{
|
||||
if(keys[n].Bind.nKey==0)
|
||||
{
|
||||
bAssigned=true;
|
||||
// keys[n].nKey=bind.nKey;
|
||||
// keys[n].nModifier=bind.nModifier;
|
||||
keys[n].Bind=bind;
|
||||
keys[n].aam=aam;
|
||||
keys[n].nLastPess=0;
|
||||
// char sTemp[1000];
|
||||
// sprintf(sTemp,"Bind added %03d\n",keys[n].nKey);
|
||||
// ::OutputDebugString(sTemp);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(bAssigned==false)*/
|
||||
{
|
||||
int n=MAX_BINDS_PER_ACTION-1;
|
||||
while(n>=1)
|
||||
{
|
||||
keys[n]=keys[n-1];
|
||||
n--;
|
||||
}
|
||||
// keys[0].nKey=bind.nKey;
|
||||
// keys[0].nModifier=bind.nModifier;
|
||||
keys[0].Bind=bind;
|
||||
keys[0].aam=aam;
|
||||
keys[0].nLastPess=0;
|
||||
// char sTemp[1000];
|
||||
// sprintf(sTemp,"Bind added %03d\n",keys[n].nKey);
|
||||
// ::OutputDebugString(sTemp);
|
||||
}
|
||||
}
|
||||
|
||||
void SetBind(int iKeyPos, XBind &bind, XActionActivationMode aam)
|
||||
{
|
||||
if (iKeyPos >= 0 && iKeyPos < MAX_BINDS_PER_ACTION)
|
||||
{
|
||||
keys[iKeyPos].Bind=bind;
|
||||
keys[iKeyPos].aam=aam;
|
||||
keys[iKeyPos].nLastPess=0;
|
||||
}
|
||||
}
|
||||
//
|
||||
struct tagKey
|
||||
{
|
||||
XBind Bind;
|
||||
// int nKey;
|
||||
// int nModifier;
|
||||
XActionActivationMode aam;
|
||||
unsigned int nLastPess;
|
||||
}keys[MAX_BINDS_PER_ACTION];
|
||||
|
||||
|
||||
};
|
||||
|
||||
typedef std::map<XACTIONID,XActionActivationMode> ActionIDsMap;
|
||||
typedef ActionIDsMap::iterator ActionIDsMapItor;
|
||||
|
||||
typedef std::map<string,XACTIONID> ActionNamesMap;
|
||||
typedef ActionNamesMap::iterator ActionNamesMapItor;
|
||||
|
||||
typedef std::map<string,CXActionMap *> ActionMapMap;
|
||||
typedef ActionMapMap::iterator ActionMapMapItor;
|
||||
|
||||
class CInput;
|
||||
|
||||
class CXActionMapManager : public IActionMapManager,public IInputEventListener
|
||||
{
|
||||
public:
|
||||
CXActionMapManager(CInput *pInput);
|
||||
virtual ~CXActionMapManager();
|
||||
public:
|
||||
//!IActionMapManager
|
||||
//@{
|
||||
void SetSink(IActionMapSink *pSink);
|
||||
void CreateAction(XACTIONID nActionID,const char *sActionName,XActionActivationMode aam=aamOnPress);
|
||||
|
||||
void SetInvertedMouse(bool bEnable);
|
||||
bool GetInvertedMouse();
|
||||
|
||||
IActionMap *CreateActionMap(const char *s);
|
||||
IActionMap *GetActionMap(const char *s);
|
||||
|
||||
void ResetAllBindings();
|
||||
|
||||
void SetActionMap(const char *s);
|
||||
|
||||
void GetActionMaps(IActionMapDumpSink *pCallback);
|
||||
|
||||
void RemoveBind(XACTIONID nActionID, XBind &NewBind, XActionActivationMode aam);
|
||||
|
||||
bool CheckActionMap(XACTIONID nActionID);
|
||||
bool CheckActionMap(const char *sActionName);
|
||||
void Reset();
|
||||
void Update(unsigned int nTimeMSec);
|
||||
void Release();
|
||||
//@}
|
||||
///////////////////////////////////////////
|
||||
bool CheckBind(XActionBind &bind,float &fVal,XActivationEvent &ae);
|
||||
bool CheckKey(struct XActionBind::tagKey &key,XActivationEvent &ae);
|
||||
bool CheckPressedKey(struct XActionBind::tagKey &key);
|
||||
bool CheckDoublePressedKey(struct XActionBind::tagKey &key);
|
||||
bool CheckReleasedKey(struct XActionBind::tagKey &key);
|
||||
bool CheckHoldKey(struct XActionBind::tagKey &key);
|
||||
|
||||
void Enable();
|
||||
void Disable();
|
||||
bool IsEnabled();
|
||||
|
||||
XActionActivationMode GetActionActivationMode(XACTIONID nActionID);
|
||||
void Notify(XACTIONID nActionID,float fValue,XActivationEvent ae)
|
||||
{
|
||||
if((m_pSink) && (m_bEnabled))
|
||||
m_pSink->OnAction(nActionID,fValue,ae);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Implements input event.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
virtual bool OnInputEvent( const SInputEvent &event );
|
||||
|
||||
CInput *m_pInput;
|
||||
private:
|
||||
|
||||
ActionIDsMap m_mapActionIDs;
|
||||
ActionNamesMap m_mapActionNames;
|
||||
ActionMapMap m_mapActionMaps;
|
||||
CXActionMap *m_pCurrentActionMap;
|
||||
IActionMapSink *m_pSink;
|
||||
unsigned int m_nCurrentTime;
|
||||
bool m_bInvertedMouse;
|
||||
bool m_bEnabled;
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_XACTIONMAPMANAGER_H__62E67F42_D4C6_4DE9_AE51_6562CCCDAD04__INCLUDED_)
|
||||
1055
CryInput/XDebugKeyboard.cpp
Normal file
1055
CryInput/XDebugKeyboard.cpp
Normal file
File diff suppressed because it is too large
Load Diff
256
CryInput/XDebugKeyboard.h
Normal file
256
CryInput/XDebugKeyboard.h
Normal file
@@ -0,0 +1,256 @@
|
||||
// XDebugKeyboard.h
|
||||
// XBox Debug Keyboard
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _XDEBUGKEYBOARD_H_
|
||||
#define _XDEBUGKEYBOARD_H_
|
||||
|
||||
#include "Input.h"
|
||||
|
||||
|
||||
#define DIK_ESCAPE 0x01
|
||||
#define DIK_1 0x02
|
||||
#define DIK_2 0x03
|
||||
#define DIK_3 0x04
|
||||
#define DIK_4 0x05
|
||||
#define DIK_5 0x06
|
||||
#define DIK_6 0x07
|
||||
#define DIK_7 0x08
|
||||
#define DIK_8 0x09
|
||||
#define DIK_9 0x0A
|
||||
#define DIK_0 0x0B
|
||||
#define DIK_MINUS 0x0C /* - on main keyboard */
|
||||
#define DIK_EQUALS 0x0D
|
||||
#define DIK_BACK 0x0E /* backspace */
|
||||
#define DIK_TAB 0x0F
|
||||
#define DIK_Q 0x10
|
||||
#define DIK_W 0x11
|
||||
#define DIK_E 0x12
|
||||
#define DIK_R 0x13
|
||||
#define DIK_T 0x14
|
||||
#define DIK_Y 0x15
|
||||
#define DIK_U 0x16
|
||||
#define DIK_I 0x17
|
||||
#define DIK_O 0x18
|
||||
#define DIK_P 0x19
|
||||
#define DIK_LBRACKET 0x1A
|
||||
#define DIK_RBRACKET 0x1B
|
||||
#define DIK_RETURN 0x1C /* Enter on main keyboard */
|
||||
#define DIK_LCONTROL 0x1D
|
||||
#define DIK_A 0x1E
|
||||
#define DIK_S 0x1F
|
||||
#define DIK_D 0x20
|
||||
#define DIK_F 0x21
|
||||
#define DIK_G 0x22
|
||||
#define DIK_H 0x23
|
||||
#define DIK_J 0x24
|
||||
#define DIK_K 0x25
|
||||
#define DIK_L 0x26
|
||||
#define DIK_SEMICOLON 0x27
|
||||
#define DIK_APOSTROPHE 0x28
|
||||
#define DIK_GRAVE 0x29 /* accent grave */
|
||||
#define DIK_LSHIFT 0x2A
|
||||
#define DIK_BACKSLASH 0x2B
|
||||
#define DIK_Z 0x2C
|
||||
#define DIK_X 0x2D
|
||||
#define DIK_C 0x2E
|
||||
#define DIK_V 0x2F
|
||||
#define DIK_B 0x30
|
||||
#define DIK_N 0x31
|
||||
#define DIK_M 0x32
|
||||
#define DIK_COMMA 0x33
|
||||
#define DIK_PERIOD 0x34 /* . on main keyboard */
|
||||
#define DIK_SLASH 0x35 /* / on main keyboard */
|
||||
#define DIK_RSHIFT 0x36
|
||||
#define DIK_MULTIPLY 0x37 /* * on numeric keypad */
|
||||
#define DIK_LMENU 0x38 /* left Alt */
|
||||
#define DIK_SPACE 0x39
|
||||
#define DIK_CAPITAL 0x3A
|
||||
#define DIK_F1 0x3B
|
||||
#define DIK_F2 0x3C
|
||||
#define DIK_F3 0x3D
|
||||
#define DIK_F4 0x3E
|
||||
#define DIK_F5 0x3F
|
||||
#define DIK_F6 0x40
|
||||
#define DIK_F7 0x41
|
||||
#define DIK_F8 0x42
|
||||
#define DIK_F9 0x43
|
||||
#define DIK_F10 0x44
|
||||
#define DIK_NUMLOCK 0x45
|
||||
#define DIK_SCROLL 0x46 /* Scroll Lock */
|
||||
#define DIK_NUMPAD7 0x47
|
||||
#define DIK_NUMPAD8 0x48
|
||||
#define DIK_NUMPAD9 0x49
|
||||
#define DIK_SUBTRACT 0x4A /* - on numeric keypad */
|
||||
#define DIK_NUMPAD4 0x4B
|
||||
#define DIK_NUMPAD5 0x4C
|
||||
#define DIK_NUMPAD6 0x4D
|
||||
#define DIK_ADD 0x4E /* + on numeric keypad */
|
||||
#define DIK_NUMPAD1 0x4F
|
||||
#define DIK_NUMPAD2 0x50
|
||||
#define DIK_NUMPAD3 0x51
|
||||
#define DIK_NUMPAD0 0x52
|
||||
#define DIK_DECIMAL 0x53 /* . on numeric keypad */
|
||||
#define DIK_OEM_102 0x56 /* <> or \| on RT 102-key keyboard (Non-U.S.) */
|
||||
#define DIK_F11 0x57
|
||||
#define DIK_F12 0x58
|
||||
#define DIK_F13 0x64 /* (NEC PC98) */
|
||||
#define DIK_F14 0x65 /* (NEC PC98) */
|
||||
#define DIK_F15 0x66 /* (NEC PC98) */
|
||||
#define DIK_KANA 0x70 /* (Japanese keyboard) */
|
||||
#define DIK_ABNT_C1 0x73 /* /? on Brazilian keyboard */
|
||||
#define DIK_CONVERT 0x79 /* (Japanese keyboard) */
|
||||
#define DIK_NOCONVERT 0x7B /* (Japanese keyboard) */
|
||||
#define DIK_YEN 0x7D /* (Japanese keyboard) */
|
||||
#define DIK_ABNT_C2 0x7E /* Numpad . on Brazilian keyboard */
|
||||
#define DIK_NUMPADEQUALS 0x8D /* = on numeric keypad (NEC PC98) */
|
||||
#define DIK_PREVTRACK 0x90 /* Previous Track (DIK_CIRCUMFLEX on Japanese keyboard) */
|
||||
#define DIK_AT 0x91 /* (NEC PC98) */
|
||||
#define DIK_COLON 0x92 /* (NEC PC98) */
|
||||
#define DIK_UNDERLINE 0x93 /* (NEC PC98) */
|
||||
#define DIK_KANJI 0x94 /* (Japanese keyboard) */
|
||||
#define DIK_STOP 0x95 /* (NEC PC98) */
|
||||
#define DIK_AX 0x96 /* (Japan AX) */
|
||||
#define DIK_UNLABELED 0x97 /* (J3100) */
|
||||
#define DIK_NEXTTRACK 0x99 /* Next Track */
|
||||
#define DIK_NUMPADENTER 0x9C /* Enter on numeric keypad */
|
||||
#define DIK_RCONTROL 0x9D
|
||||
#define DIK_MUTE 0xA0 /* Mute */
|
||||
#define DIK_CALCULATOR 0xA1 /* Calculator */
|
||||
#define DIK_PLAYPAUSE 0xA2 /* Play / Pause */
|
||||
#define DIK_MEDIASTOP 0xA4 /* Media Stop */
|
||||
#define DIK_VOLUMEDOWN 0xAE /* Volume - */
|
||||
#define DIK_VOLUMEUP 0xB0 /* Volume + */
|
||||
#define DIK_WEBHOME 0xB2 /* Web home */
|
||||
#define DIK_NUMPADCOMMA 0xB3 /* , on numeric keypad (NEC PC98) */
|
||||
#define DIK_DIVIDE 0xB5 /* / on numeric keypad */
|
||||
#define DIK_SYSRQ 0xB7
|
||||
#define DIK_RMENU 0xB8 /* right Alt */
|
||||
#define DIK_PAUSE 0xC5 /* Pause */
|
||||
#define DIK_HOME 0xC7 /* Home on arrow keypad */
|
||||
#define DIK_UP 0xC8 /* UpArrow on arrow keypad */
|
||||
#define DIK_PRIOR 0xC9 /* PgUp on arrow keypad */
|
||||
#define DIK_LEFT 0xCB /* LeftArrow on arrow keypad */
|
||||
#define DIK_RIGHT 0xCD /* RightArrow on arrow keypad */
|
||||
#define DIK_END 0xCF /* End on arrow keypad */
|
||||
#define DIK_DOWN 0xD0 /* DownArrow on arrow keypad */
|
||||
#define DIK_NEXT 0xD1 /* PgDn on arrow keypad */
|
||||
#define DIK_INSERT 0xD2 /* Insert on arrow keypad */
|
||||
#define DIK_DELETE 0xD3 /* Delete on arrow keypad */
|
||||
#define DIK_LWIN 0xDB /* Left Windows key */
|
||||
#define DIK_RWIN 0xDC /* Right Windows key */
|
||||
#define DIK_APPS 0xDD /* AppMenu key */
|
||||
#define DIK_POWER 0xDE /* System Power */
|
||||
#define DIK_SLEEP 0xDF /* System Sleep */
|
||||
#define DIK_WAKE 0xE3 /* System Wake */
|
||||
#define DIK_WEBSEARCH 0xE5 /* Web Search */
|
||||
#define DIK_WEBFAVORITES 0xE6 /* Web Favorites */
|
||||
#define DIK_WEBREFRESH 0xE7 /* Web Refresh */
|
||||
#define DIK_WEBSTOP 0xE8 /* Web Stop */
|
||||
#define DIK_WEBFORWARD 0xE9 /* Web Forward */
|
||||
#define DIK_WEBBACK 0xEA /* Web Back */
|
||||
#define DIK_MYCOMPUTER 0xEB /* My Computer */
|
||||
#define DIK_MAIL 0xEC /* Mail */
|
||||
#define DIK_MEDIASELECT 0xED /* Media Select */
|
||||
|
||||
/*
|
||||
* Alternate names for keys, to facilitate transition from DOS.
|
||||
*/
|
||||
#define DIK_BACKSPACE DIK_BACK /* backspace */
|
||||
#define DIK_NUMPADSTAR DIK_MULTIPLY /* * on numeric keypad */
|
||||
#define DIK_LALT DIK_LMENU /* left Alt */
|
||||
#define DIK_CAPSLOCK DIK_CAPITAL /* CapsLock */
|
||||
#define DIK_NUMPADMINUS DIK_SUBTRACT /* - on numeric keypad */
|
||||
#define DIK_NUMPADPLUS DIK_ADD /* + on numeric keypad */
|
||||
#define DIK_NUMPADPERIOD DIK_DECIMAL /* . on numeric keypad */
|
||||
#define DIK_NUMPADSLASH DIK_DIVIDE /* / on numeric keypad */
|
||||
#define DIK_RALT DIK_RMENU /* right Alt */
|
||||
#define DIK_UPARROW DIK_UP /* UpArrow on arrow keypad */
|
||||
#define DIK_PGUP DIK_PRIOR /* PgUp on arrow keypad */
|
||||
#define DIK_LEFTARROW DIK_LEFT /* LeftArrow on arrow keypad */
|
||||
#define DIK_RIGHTARROW DIK_RIGHT /* RightArrow on arrow keypad */
|
||||
#define DIK_DOWNARROW DIK_DOWN /* DownArrow on arrow keypad */
|
||||
#define DIK_PGDN DIK_NEXT /* PgDn on arrow keypad */
|
||||
|
||||
|
||||
|
||||
struct XAsciiKey
|
||||
{
|
||||
char lc[32]; //lowercase
|
||||
char uc[32]; //uppercase
|
||||
};
|
||||
|
||||
|
||||
struct ILog;
|
||||
|
||||
#define KEYFLAG_BUFFERSIZE 32
|
||||
class CInput;
|
||||
|
||||
class CXDebugKeyboard : public IKeyboard
|
||||
{
|
||||
public:
|
||||
bool Init(CInput * pInput, ILog *pLog);
|
||||
|
||||
CXDebugKeyboard();
|
||||
virtual ~CXDebugKeyboard();
|
||||
////////////////////////////////////////////////////////////
|
||||
void ShutDown();
|
||||
//! allow to force a key code value
|
||||
void SetKey(int p_key, int value);
|
||||
//! allow to force a key code value
|
||||
void SetPrevKey(int p_key, int value);
|
||||
//! check for key pressed and held
|
||||
bool KeyDown(int p_key);
|
||||
//! check for key pressed only once
|
||||
bool KeyPressed(int p_key);
|
||||
//! check if the key has been released
|
||||
bool KeyReleased(int p_key);
|
||||
//! clear the key status
|
||||
void ClearKey(int p_key);
|
||||
//! return the code of the key pressed
|
||||
int GetKeyPressedCode();
|
||||
//! return the name of the key pressed
|
||||
const char *GetKeyPressedName();
|
||||
//! return the code of the key down
|
||||
int GetKeyDownCode();
|
||||
//! return the name of the key down
|
||||
const char *GetKeyDownName();
|
||||
//! return the name (key name list) of the key specified in kKeyCode
|
||||
const char *EnumerateKey(int nKeyCode);
|
||||
//! set/unset directinput to exclusive mode
|
||||
void SetExclusive(bool value,void *hwnd=0);
|
||||
//! wait for a key pressed
|
||||
void WaitForKey();
|
||||
//! clear the key (pressed) state
|
||||
void ClearKeyState();
|
||||
//! return the name (ascii name mapped to the virtual keyboard layout) of the key specified in kKeyCode
|
||||
//const char *GetKeyName(unsigned short nKey);
|
||||
//!
|
||||
void Update();
|
||||
/////////////////////////////////////////////////////////////
|
||||
private:
|
||||
static XAsciiKey m_AsciiTable[256];
|
||||
|
||||
public:
|
||||
unsigned short DIK2XKEY(unsigned char cCode);
|
||||
unsigned char XKEY2DIK(unsigned short nCode);
|
||||
unsigned char XKEY2ASCII(unsigned short nCode);
|
||||
|
||||
protected:
|
||||
//bool Acquire();
|
||||
//bool UnAcquire();
|
||||
void SetupKeyNames();
|
||||
unsigned char m_cKeysState[0x0000011F];
|
||||
unsigned char m_cOldKeysState[0x0000011F];
|
||||
|
||||
private:
|
||||
ILog *m_pLog;
|
||||
|
||||
CInput * m_pInput;
|
||||
|
||||
HANDLE m_hDebugKeyboard;
|
||||
bool m_bKeys[256];
|
||||
};
|
||||
|
||||
#endif // _XDEBUGKEYBOARD_H_
|
||||
548
CryInput/XGamepad.cpp
Normal file
548
CryInput/XGamepad.cpp
Normal file
@@ -0,0 +1,548 @@
|
||||
#include "stdafx.h"
|
||||
#include "Input.h"
|
||||
#include <ILog.h>
|
||||
|
||||
#include <Xtl.h>
|
||||
|
||||
#include "XGamepad.h"
|
||||
|
||||
namespace{
|
||||
const DWORD g_dwNumToPort[] = {XDEVICE_PORT0, XDEVICE_PORT1, XDEVICE_PORT2, XDEVICE_PORT3};
|
||||
}
|
||||
|
||||
#define NumToPort(X) g_dwNumToPort[X]
|
||||
|
||||
|
||||
CXGamepad::CXGamepad()
|
||||
{
|
||||
memset(m_hGamepads, NULL, sizeof(HANDLE) * MAX_XBOX_CONTROLLERS);
|
||||
memset(m_xbStatus, NULL, sizeof(XINPUT_STATE) * MAX_XBOX_CONTROLLERS);
|
||||
memset(m_xbLastStatus, NULL, sizeof(XINPUT_STATE) * MAX_XBOX_CONTROLLERS);
|
||||
//memset(m_bKeys, false, sizeof(bool) * 256);
|
||||
//m_hDebugKeyboard = NULL;
|
||||
m_bExponentialStick = true;
|
||||
m_fLX = m_fLY = m_fRX = m_fRY = 0.0f;
|
||||
}
|
||||
|
||||
|
||||
CXGamepad::~CXGamepad()
|
||||
{
|
||||
ShutDown();
|
||||
}
|
||||
|
||||
|
||||
bool CXGamepad::Init(ILog *pLog)
|
||||
{
|
||||
XDEVICE_PREALLOC_TYPE sDeviceTypes[] =
|
||||
{
|
||||
{ XDEVICE_TYPE_GAMEPAD, MAX_XBOX_CONTROLLERS },
|
||||
#ifdef DEBUG_KEYBOARD
|
||||
{ XDEVICE_TYPE_DEBUG_KEYBOARD, 1 },
|
||||
#endif //DEBUG_KEYBOARD
|
||||
};
|
||||
|
||||
// Initialize all four gamepads and the debug keyboard
|
||||
XInitDevices(sizeof(sDeviceTypes) / sizeof(XDEVICE_PREALLOC_TYPE), sDeviceTypes);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void CXGamepad::ShutDown()
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
// Close all opened gamepad handles
|
||||
for (i=0; i<sizeof(m_hGamepads) / sizeof(HANDLE); i++)
|
||||
{
|
||||
if (m_hGamepads[i])
|
||||
XInputClose(m_hGamepads[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CXGamepad::Update()
|
||||
{
|
||||
BOOL bReturn;
|
||||
DWORD dwInsertions = 0, dwRemovals = 0;
|
||||
unsigned int i;
|
||||
#ifdef _DEBUG
|
||||
char szBuffer[10024 /*256*/];
|
||||
#endif
|
||||
DWORD dwReturn;
|
||||
|
||||
// Query controller changes
|
||||
bReturn = XGetDeviceChanges(XDEVICE_TYPE_GAMEPAD, &dwInsertions, &dwRemovals);
|
||||
|
||||
// Detect controler insertion
|
||||
for (i=0; i<MAX_XBOX_CONTROLLERS; i++)
|
||||
{
|
||||
if (dwInsertions & (1 << i))
|
||||
{
|
||||
// A controller was inserted
|
||||
#ifdef _DEBUG
|
||||
sprintf(szBuffer, "INPUT: Controller %i inserted\n", i);
|
||||
OutputDebugString(szBuffer);
|
||||
#endif
|
||||
|
||||
// Open the device on the port
|
||||
m_hGamepads[i] = XInputOpen(XDEVICE_TYPE_GAMEPAD, NumToPort(i), XDEVICE_NO_SLOT, NULL);
|
||||
|
||||
#ifdef _DEBUG
|
||||
if (m_hGamepads[i] != NULL)
|
||||
{
|
||||
sprintf(szBuffer, "INPUT: Controller %i successfully opened\n", i);
|
||||
OutputDebugString(szBuffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(szBuffer, "INPUT: ERROR: Can't open controller %i\n", i);
|
||||
OutputDebugString(szBuffer);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
// Detect controller removal
|
||||
for (i=0; i<MAX_XBOX_CONTROLLERS; i++)
|
||||
{
|
||||
if (dwRemovals & (1 << i))
|
||||
{
|
||||
// A controller was removed
|
||||
#ifdef _DEBUG
|
||||
sprintf(szBuffer, "INPUT: Controller %i removed\n", i);
|
||||
OutputDebugString(szBuffer);
|
||||
#endif
|
||||
// Close the controller
|
||||
XInputClose(m_hGamepads[i]);
|
||||
m_hGamepads[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
// Retrieve the state
|
||||
for (i=0; i<MAX_XBOX_CONTROLLERS; i++)
|
||||
{
|
||||
if (IsControllerReady(i))
|
||||
{
|
||||
// Save the old state
|
||||
m_xbLastStatus[i] = m_xbStatus[i];
|
||||
|
||||
// Get the new one
|
||||
dwReturn = XInputGetState(m_hGamepads[i], &m_xbStatus[i]);
|
||||
|
||||
#ifdef _DEBUG
|
||||
if (dwReturn == ERROR_DEVICE_NOT_CONNECTED)
|
||||
{
|
||||
sprintf(szBuffer, "INPUT: Can't get state of controller %i because it was" \
|
||||
" removed and the removal has not been handled yet\n", i);
|
||||
OutputDebugString(szBuffer);
|
||||
}
|
||||
else if (dwReturn != ERROR_SUCCESS)
|
||||
{
|
||||
sprintf(szBuffer, "INPUT: ERROR: Can't get state of controller %i" \
|
||||
", error %i\n", i, dwReturn);
|
||||
OutputDebugString(szBuffer);
|
||||
}
|
||||
|
||||
/*
|
||||
if (m_xbLastStatus[i].dwPacketNumber != m_xbStatus[i].dwPacketNumber)
|
||||
{
|
||||
//ASH: get rid of this.
|
||||
sprintf(szBuffer, "packet: %d\n"
|
||||
"got input: controller - %d\n"
|
||||
"up: %d, down: %d, left: %d, right: %d\n"
|
||||
"start: %d, back: %d, left thumb: %d, right thumb: %d\n"
|
||||
"a: %d, b: %d, x: %d, y: %d, black: %d, white: %d\n"
|
||||
"left trigger: %d, right trigger: %d\n"
|
||||
"LX: %d, LY: %d, RX: %d, RY: %d\n",
|
||||
(int) (m_xbStatus[i].dwPacketNumber),
|
||||
i,
|
||||
(int) (m_xbStatus[i].Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_UP),
|
||||
(int) (m_xbStatus[i].Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_DOWN),
|
||||
(int) (m_xbStatus[i].Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_LEFT),
|
||||
(int) (m_xbStatus[i].Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_RIGHT),
|
||||
(int) (m_xbStatus[i].Gamepad.wButtons & XINPUT_GAMEPAD_START),
|
||||
(int) (m_xbStatus[i].Gamepad.wButtons & XINPUT_GAMEPAD_BACK),
|
||||
(int) (m_xbStatus[i].Gamepad.wButtons & XINPUT_GAMEPAD_LEFT_THUMB),
|
||||
(int) (m_xbStatus[i].Gamepad.wButtons & XINPUT_GAMEPAD_RIGHT_THUMB),
|
||||
(int) (m_xbStatus[i].Gamepad.bAnalogButtons[XINPUT_GAMEPAD_A]),
|
||||
(int) (m_xbStatus[i].Gamepad.bAnalogButtons[XINPUT_GAMEPAD_B]),
|
||||
(int) (m_xbStatus[i].Gamepad.bAnalogButtons[XINPUT_GAMEPAD_X]),
|
||||
(int) (m_xbStatus[i].Gamepad.bAnalogButtons[XINPUT_GAMEPAD_Y]),
|
||||
(int) (m_xbStatus[i].Gamepad.bAnalogButtons[XINPUT_GAMEPAD_BLACK]),
|
||||
(int) (m_xbStatus[i].Gamepad.bAnalogButtons[XINPUT_GAMEPAD_WHITE]),
|
||||
(int) (m_xbStatus[i].Gamepad.bAnalogButtons[XINPUT_GAMEPAD_LEFT_TRIGGER]),
|
||||
(int) (m_xbStatus[i].Gamepad.bAnalogButtons[XINPUT_GAMEPAD_RIGHT_TRIGGER]),
|
||||
(int) (m_xbStatus[i].Gamepad.sThumbLX),
|
||||
(int) (m_xbStatus[i].Gamepad.sThumbLY),
|
||||
(int) (m_xbStatus[i].Gamepad.sThumbRX),
|
||||
(int) (m_xbStatus[i].Gamepad.sThumbRY));
|
||||
OutputDebugString(szBuffer);
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool CXGamepad::IsDigitalButtonPressed(const eDigitalButton eWhichButton, const bool bOnce,
|
||||
const eController eWhichController) const
|
||||
{
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Returns the status of a digital button
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
unsigned int i, iLastController = eWhichController;
|
||||
bool bPressed = false;
|
||||
|
||||
if (!AnyControllersReady())
|
||||
return false;
|
||||
|
||||
if (eWhichButton == NULL)
|
||||
return false;
|
||||
|
||||
// Should we check all controllers ?
|
||||
if (eWhichController == eAll)
|
||||
{
|
||||
for (i=0; i<MAX_XBOX_CONTROLLERS; i++)
|
||||
{
|
||||
if (IsControllerReady(i))
|
||||
{
|
||||
// Button eWhichButton pressed on controller i ?
|
||||
if (m_xbStatus[i].Gamepad.wButtons & eWhichButton)
|
||||
{
|
||||
// Button pressed, save the current controller as the last one
|
||||
iLastController = i;
|
||||
bPressed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Should we check the primary controller ?
|
||||
if (eWhichController == ePrimary)
|
||||
{
|
||||
// Query the key state on the primary controller and prepare to check
|
||||
// if the key was already pressed during the last update
|
||||
iLastController = GetPrimaryController();
|
||||
bPressed = (m_xbStatus[GetPrimaryController()].Gamepad.wButtons & eWhichButton) != NULL;
|
||||
}
|
||||
else if (eWhichController != eAll)
|
||||
{
|
||||
// Check the specified controller
|
||||
if (IsControllerReady(eWhichController))
|
||||
bPressed = (m_xbStatus[eWhichController].Gamepad.wButtons & eWhichButton) != NULL;
|
||||
else
|
||||
// Specified controller not ready
|
||||
bPressed = false;
|
||||
}
|
||||
|
||||
// We can just return if we are not in single trigger mode or the value is false
|
||||
if (bPressed == false || bOnce == false)
|
||||
return bPressed;
|
||||
|
||||
if (bOnce)
|
||||
{
|
||||
// Key is pressed and we are in single trigger mode
|
||||
if ((m_xbLastStatus[iLastController].Gamepad.wButtons & eWhichButton) != NULL)
|
||||
// Button press already processed
|
||||
bPressed = false;
|
||||
}
|
||||
|
||||
return bPressed;
|
||||
}
|
||||
|
||||
|
||||
|
||||
float CXGamepad::GetAnalogButtonValue(const eAnalogButton eWhichButton,
|
||||
const eController eWhichController) const
|
||||
{
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Returns the status of an analog button as a value between 0 and 1
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
unsigned int i;
|
||||
float fAccumValue = 0.0f;
|
||||
|
||||
if (!AnyControllersReady())
|
||||
return 0.0f;
|
||||
|
||||
// Should we check all controllers ?
|
||||
if (eWhichController == eAll)
|
||||
{
|
||||
for (i=0; i<MAX_XBOX_CONTROLLERS; i++)
|
||||
{
|
||||
// Add the value of the button if the controller is ready
|
||||
if (IsControllerReady(i))
|
||||
fAccumValue += (float) m_xbStatus[i].Gamepad.bAnalogButtons[eWhichButton] / 255.0f;
|
||||
}
|
||||
|
||||
// Return clamped value
|
||||
return __min(fAccumValue, 1.0f);
|
||||
}
|
||||
|
||||
// Should we check the primary controller ?
|
||||
if (eWhichController == ePrimary)
|
||||
return m_xbStatus[GetPrimaryController()].Gamepad.bAnalogButtons[eWhichButton] / 255.0f;
|
||||
|
||||
// Check the specified controller
|
||||
if (IsControllerReady(eWhichController))
|
||||
return m_xbStatus[eWhichController].Gamepad.bAnalogButtons[eWhichButton] / 255.0f;
|
||||
else
|
||||
// Specified controller not ready
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CXGamepad::GetAnalogStickValue(float& fX, float& fY, const eSide eWhichStick,
|
||||
const eController eWhichController) const
|
||||
{
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Check the axis of an analog stick, value is between -1 and +1
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
unsigned int i;
|
||||
float fAccumValueX = 0.0f;
|
||||
float fAccumValueY = 0.0f;
|
||||
//float fValX, fValY;
|
||||
|
||||
if (!AnyControllersReady())
|
||||
{
|
||||
fX = 0.0f;
|
||||
fY = 0.0f;
|
||||
return;
|
||||
}
|
||||
|
||||
// Should we check all controllers ?
|
||||
if (eWhichController == eAll)
|
||||
{
|
||||
for (i=0; i<MAX_XBOX_CONTROLLERS; i++)
|
||||
{
|
||||
// Add the value of the button if the controller is ready
|
||||
if (IsControllerReady(i))
|
||||
{
|
||||
if (eWhichStick == eLeft)
|
||||
{
|
||||
// Left stick
|
||||
fAccumValueX += Ignore(m_xbStatus[i].Gamepad.sThumbLX) / 32768.0f;
|
||||
fAccumValueY += Ignore(m_xbStatus[i].Gamepad.sThumbLY) / 32768.0f;
|
||||
}
|
||||
else if (eWhichStick == eRight)
|
||||
{
|
||||
// Right stick
|
||||
fAccumValueX += Ignore(m_xbStatus[i].Gamepad.sThumbRX) / 32768.0f;
|
||||
fAccumValueY += Ignore(m_xbStatus[i].Gamepad.sThumbRY) / 32768.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Clamp
|
||||
if (fAccumValueX < -1.0f)
|
||||
fAccumValueX = -1.0;
|
||||
if (fAccumValueX > 1.0f)
|
||||
fAccumValueX = 1.0;
|
||||
if (fAccumValueY < -1.0f)
|
||||
fAccumValueY = -1.0;
|
||||
if (fAccumValueY > 1.0f)
|
||||
fAccumValueY = 1.0;
|
||||
|
||||
// Return clamped value
|
||||
fX = fAccumValueX;
|
||||
fY = fAccumValueY;
|
||||
return;
|
||||
}
|
||||
|
||||
// Should we check the primary controller ?
|
||||
if (eWhichController == ePrimary)
|
||||
{
|
||||
// Read out the controller
|
||||
ReadAnalogStickValue(GetPrimaryController(), eWhichStick,
|
||||
m_bExponentialStick, fX, fY);
|
||||
return;
|
||||
}
|
||||
|
||||
// Check the specified controller
|
||||
if (IsControllerReady(eWhichController))
|
||||
{
|
||||
if (eWhichStick == eLeft)
|
||||
{
|
||||
// Left stick
|
||||
fX = Ignore(m_xbStatus[eWhichController].Gamepad.sThumbLX) / 32768.0f;
|
||||
fY = Ignore(m_xbStatus[eWhichController].Gamepad.sThumbLY) / 32768.0f;
|
||||
}
|
||||
else if (eWhichStick == eRight)
|
||||
{
|
||||
// Right stick
|
||||
fX = Ignore(m_xbStatus[eWhichController].Gamepad.sThumbRX) / 32768.0f;
|
||||
fY = Ignore(m_xbStatus[eWhichController].Gamepad.sThumbRY) / 32768.0f;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Specified controller not ready
|
||||
fX = 0.0f;
|
||||
fY = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CXGamepad::ReadAnalogStickValue(const unsigned __int8 iControllerID,
|
||||
const eSide eWhichSide,
|
||||
const bool bExponential,
|
||||
float& fX, float& fY) const
|
||||
{
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Read the axis values of one of the analog sticks. Perform linear
|
||||
// or exponential attenuation, take deadzone into account
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
float fValX, fValY;
|
||||
|
||||
// Abort when controller is not inserted / opened
|
||||
if (iControllerID + 1 >= MAX_XBOX_CONTROLLERS || IsControllerReady(iControllerID) == false)
|
||||
{
|
||||
fX = 0.0f;
|
||||
fY = 0.0f;
|
||||
return;
|
||||
}
|
||||
|
||||
if (bExponential)
|
||||
{
|
||||
// Exponential change of intensity
|
||||
|
||||
if (eWhichSide == eRight)
|
||||
{
|
||||
// Read values from the right stick and scale to 0 - 50
|
||||
fValX = Ignore(m_xbStatus[iControllerID].Gamepad.sThumbRX) / 32768.0f * 50.0f;
|
||||
fValY = Ignore(m_xbStatus[iControllerID].Gamepad.sThumbRY) / 32768.0f * 50.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Read values from the left stick and scale to 0 - 50
|
||||
fValX = Ignore(m_xbStatus[iControllerID].Gamepad.sThumbLX) / 32768.0f * 50.0f;
|
||||
fValY = Ignore(m_xbStatus[iControllerID].Gamepad.sThumbLY) / 32768.0f * 50.0f;
|
||||
}
|
||||
|
||||
// Attenuate
|
||||
fX = fValX * fValX / 2500.0f;
|
||||
fY = fValY * fValY / 2500.0f;
|
||||
|
||||
// Restore sign
|
||||
if (fValX < 0.0f)
|
||||
fX = -fX;
|
||||
if (fValY < 0.0f)
|
||||
fY = -fY;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Linear change of intensity
|
||||
|
||||
if (eWhichSide == eRight)
|
||||
{
|
||||
// Read from the right side
|
||||
fX = Ignore(m_xbStatus[iControllerID].Gamepad.sThumbRX) / 32768.0f;
|
||||
fY = Ignore(m_xbStatus[iControllerID].Gamepad.sThumbRY) / 32768.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Read from the left side
|
||||
fX = Ignore(m_xbStatus[iControllerID].Gamepad.sThumbLX) / 32768.0f;
|
||||
fY = Ignore(m_xbStatus[iControllerID].Gamepad.sThumbLY) / 32768.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
namespace{
|
||||
eDigitalButton but_dig[] = { eDigitalUp, eDigitalDown, eDigitalLeft, eDigitalRight, eStart, eBack, eLeftStick, eRightStick };
|
||||
eAnalogButton but_an[] = {eA,eB,eX,eY, eBlack, eWhite, eLeftTrigger, eRightTrigger };
|
||||
}
|
||||
|
||||
bool CXGamepad::KeyDown(int p_key)
|
||||
{
|
||||
if(p_key == XKEY_MAXIS_X || p_key == XKEY_MAXIS_Y)
|
||||
return true;
|
||||
|
||||
if(XKEY_GP_A <= p_key && p_key <= XKEY_GP_RIGHT_TRIGGER)
|
||||
{
|
||||
int b = ( p_key>> 24) - (XKEY_GP_A >> 24);
|
||||
return (GetAnalogButtonValue(but_an[b], eAll) > 0.4f);
|
||||
}
|
||||
|
||||
if(XKEY_GP_DPAD_UP <= p_key && p_key <= XKEY_GP_RIGHT_THUMB)
|
||||
{
|
||||
int b = ( p_key>> 24) - (XKEY_GP_DPAD_UP >> 24);
|
||||
return IsDigitalButtonPressed(but_dig[b], false, eAll);
|
||||
}
|
||||
|
||||
if(XKEY_GP_STHUMBLUP <= p_key && p_key <= XKEY_GP_STHUMBLRIGHT)
|
||||
{
|
||||
if (m_xbLastStatus[0].dwPacketNumber != m_xbStatus[0].dwPacketNumber)
|
||||
GetAnalogStickValue(m_fRX, m_fRY, eLeft, eAll);
|
||||
switch(p_key)
|
||||
{
|
||||
case XKEY_GP_STHUMBLUP:
|
||||
return (m_fRY > 0.4f);
|
||||
case XKEY_GP_STHUMBLDOWN:
|
||||
return (m_fRY < -0.4f);
|
||||
case XKEY_GP_STHUMBLLEFT:
|
||||
return (m_fRX < -0.4f);
|
||||
case XKEY_GP_STHUMBLRIGHT:
|
||||
return (m_fRX > 0.4f);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bool CXGamepad::KeyPressed(int p_key)
|
||||
{
|
||||
if(XKEY_GP_A <= p_key && p_key <= XKEY_GP_RIGHT_TRIGGER)
|
||||
{
|
||||
int b = ( p_key>> 24) - (XKEY_GP_A >> 24);
|
||||
return (GetAnalogButtonValue(but_an[b], eAll) > 0.4f);
|
||||
}
|
||||
|
||||
if(XKEY_GP_DPAD_UP <= p_key && p_key <= XKEY_GP_RIGHT_THUMB)
|
||||
{
|
||||
int b = ( p_key>> 24) - (XKEY_GP_DPAD_UP >> 24);
|
||||
return IsDigitalButtonPressed(but_dig[b], true, eAll);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool CXGamepad::KeyReleased(int p_key)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
float CXGamepad::GetDeltaX()
|
||||
{
|
||||
if (m_xbLastStatus[0].dwPacketNumber != m_xbStatus[0].dwPacketNumber)
|
||||
GetAnalogStickValue(m_fLX, m_fLY, eRight, eAll);
|
||||
return m_fLX * 5;
|
||||
}
|
||||
|
||||
float CXGamepad::GetDeltaY()
|
||||
{
|
||||
if (m_xbLastStatus[0].dwPacketNumber != m_xbStatus[0].dwPacketNumber)
|
||||
GetAnalogStickValue(m_fLX, m_fLY, eRight, eAll);
|
||||
return m_fLY * 5;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
130
CryInput/XGamepad.h
Normal file
130
CryInput/XGamepad.h
Normal file
@@ -0,0 +1,130 @@
|
||||
// XGamepad.h: interface for the CXGamepad class.
|
||||
// Sergiy Shaykin (sergiys@crytek.de)
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _XGAMEPAD_H_
|
||||
#define _XGAMEPAD_H_
|
||||
|
||||
#include <IInput.h>
|
||||
|
||||
struct ILog;
|
||||
|
||||
class CInput;
|
||||
|
||||
class CXGamepad : public IGamepad
|
||||
{
|
||||
public:
|
||||
bool Init(ILog *pLog);
|
||||
|
||||
CXGamepad();
|
||||
virtual ~CXGamepad();
|
||||
////////////////////////////////////////////////////////////
|
||||
void ShutDown();
|
||||
//! allow to force a key code value
|
||||
void SetKey(int p_key, int value);
|
||||
//! allow to force a key code value
|
||||
void SetPrevKey(int p_key, int value);
|
||||
//! check for key pressed and held
|
||||
bool KeyDown(int p_key);
|
||||
//! check for key pressed only once
|
||||
bool KeyPressed(int p_key);
|
||||
//! check if the key has been released
|
||||
bool KeyReleased(int p_key);
|
||||
//! clear the key status
|
||||
void ClearKey(int p_key);
|
||||
//! return the code of the key pressed
|
||||
int GetKeyPressedCode();
|
||||
//! return the name of the key pressed
|
||||
const char *GetKeyPressedName();
|
||||
//! return the code of the key down
|
||||
int GetKeyDownCode();
|
||||
//! return the name of the key down
|
||||
const char *GetKeyDownName();
|
||||
//! return the name (key name list) of the key specified in kKeyCode
|
||||
const char *EnumerateKey(int nKeyCode);
|
||||
//! set/unset directinput to exclusive mode
|
||||
void SetExclusive(bool value,void *hwnd=0);
|
||||
//! wait for a key pressed
|
||||
void WaitForKey();
|
||||
//! clear the key (pressed) state
|
||||
void ClearKeyState();
|
||||
//! return the name (ascii name mapped to the virtual keyboard layout) of the key specified in kKeyCode
|
||||
//const char *GetKeyName(unsigned short nKey);
|
||||
//!
|
||||
void Update();
|
||||
|
||||
float GetDeltaX();
|
||||
float GetDeltaY();
|
||||
|
||||
/////////////////////////////////////////////////////////////
|
||||
private:
|
||||
|
||||
bool IsControllerReady(UINT iNumController) const
|
||||
{ assert(iNumController < MAX_XBOX_CONTROLLERS); return m_hGamepads[iNumController] != NULL; };
|
||||
|
||||
bool AnyControllersReady() const
|
||||
{ UINT i; for (i=0; i<MAX_XBOX_CONTROLLERS; i++) if (m_hGamepads[i]) return true; return false; };
|
||||
|
||||
int GetPrimaryController() const
|
||||
{ UINT i; for (i=0; i<MAX_XBOX_CONTROLLERS; i++) if (m_hGamepads[i]) return i; return -1; };
|
||||
|
||||
SHORT Ignore(SHORT iVal) const
|
||||
{
|
||||
if (abs(iVal) < XBOX_ANALOGSTICK_DEADZONE)
|
||||
return 0;
|
||||
else
|
||||
{
|
||||
if(iVal < 0)
|
||||
return iVal + XBOX_ANALOGSTICK_DEADZONE;
|
||||
else
|
||||
return iVal - XBOX_ANALOGSTICK_DEADZONE;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
bool IsDigitalButtonPressed(const eDigitalButton eWhichButton, const bool bOnce,
|
||||
const eController eWhichController) const;
|
||||
|
||||
float GetAnalogButtonValue(const eAnalogButton eWhichButton, const eController eWhichController) const;
|
||||
|
||||
void GetAnalogStickValue(float& fX, float& fY, const eSide eWhichStick,
|
||||
const eController eWhichController) const;
|
||||
|
||||
void ReadAnalogStickValue(const unsigned __int8 iControllerID, const eSide eWhichSide,
|
||||
const bool bExponential, float& fX, float& fY) const;
|
||||
|
||||
//static XAsciiKey m_AsciiTable[256];
|
||||
|
||||
|
||||
|
||||
XINPUT_STATE m_xbStatus[MAX_XBOX_CONTROLLERS];
|
||||
XINPUT_STATE m_xbLastStatus[MAX_XBOX_CONTROLLERS];
|
||||
float m_fLX, m_fLY, m_fRX, m_fRY;
|
||||
|
||||
|
||||
|
||||
public:
|
||||
//unsigned short DIK2XKEY(unsigned char cCode);
|
||||
//unsigned char XKEY2DIK(unsigned short nCode);
|
||||
//unsigned char XKEY2ASCII(unsigned short nCode);
|
||||
|
||||
protected:
|
||||
/*
|
||||
bool Acquire();
|
||||
bool UnAcquire();
|
||||
void SetupKeyNames();
|
||||
*/
|
||||
|
||||
HANDLE m_hGamepads[MAX_XBOX_CONTROLLERS];
|
||||
|
||||
unsigned char m_cKeysState[256];
|
||||
unsigned char m_cOldKeysState[256];
|
||||
CInput *m_pInput;
|
||||
|
||||
bool m_bExponentialStick;
|
||||
|
||||
bool m_bExclusiveMode;
|
||||
ILog *m_pLog;
|
||||
};
|
||||
|
||||
#endif _XGAMEPAD_H_
|
||||
1548
CryInput/XKeyboard.cpp
Normal file
1548
CryInput/XKeyboard.cpp
Normal file
File diff suppressed because it is too large
Load Diff
168
CryInput/XKeyboard.h
Normal file
168
CryInput/XKeyboard.h
Normal file
@@ -0,0 +1,168 @@
|
||||
// XKeyboard.h: interface for the CXKeyboard class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_XKEYBOARD_H__9C0FD463_ECC8_42DA_8019_378651B00771__INCLUDED_)
|
||||
#define AFX_XKEYBOARD_H__9C0FD463_ECC8_42DA_8019_378651B00771__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
#include <IInput.h>
|
||||
|
||||
#ifdef PS2
|
||||
|
||||
#include "Joystick.h"
|
||||
#include <libusbkb.h>
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
struct ILog;
|
||||
struct ICVar;
|
||||
|
||||
struct XAsciiKey
|
||||
{
|
||||
char lc[4]; // lowercase
|
||||
char uc[4]; // uppercase
|
||||
char ac[4]; // alt gr
|
||||
char cl[4]; // caps lock (differs slightly from uppercase)
|
||||
};
|
||||
|
||||
#define TOGGLE_CAPSLOCK (1 << 0)
|
||||
#define TOGGLE_NUMLOCK (1 << 1)
|
||||
#define TOGGLE_SCROLLLOCK (1 << 2)
|
||||
|
||||
|
||||
#define KEYFLAG_BUFFERSIZE 32
|
||||
class CInput;
|
||||
|
||||
|
||||
class CXKeyboard :
|
||||
public IKeyboard
|
||||
{
|
||||
public:
|
||||
#ifndef PS2
|
||||
//bool Init(CInput *,ILog *pLog, LPDIRECTINPUT8 &g_pdi,HINSTANCE hinst,HWND hwnd3);
|
||||
bool Init(CInput *,ISystem *pSystem, LPDIRECTINPUT8 &g_pdi,HINSTANCE hinst,HWND hwnd3);
|
||||
#else
|
||||
bool Init(ILog *pLog);
|
||||
#endif
|
||||
|
||||
CXKeyboard();
|
||||
virtual ~CXKeyboard();
|
||||
////////////////////////////////////////////////////////////
|
||||
void ShutDown();
|
||||
//! allow to force a key code value
|
||||
void SetKey(int p_key, int value);
|
||||
//! allow to force a key code value
|
||||
void SetPrevKey(int p_key, int value);
|
||||
//! check for key pressed and held
|
||||
bool KeyDown(int p_key);
|
||||
//! check for key pressed only once
|
||||
bool KeyPressed(int p_key);
|
||||
//! check if the key has been released
|
||||
bool KeyReleased(int p_key);
|
||||
//! clear the key status
|
||||
void ClearKey(int p_key);
|
||||
//! return the code of the key pressed
|
||||
int GetKeyPressedCode();
|
||||
//! return the name of the key pressed
|
||||
const char *GetKeyPressedName();
|
||||
//! return the code of the key down
|
||||
int GetKeyDownCode();
|
||||
//! return the name of the key down
|
||||
const char *GetKeyDownName();
|
||||
//! set/unset directinput to exclusive mode
|
||||
void SetExclusive(bool value,void *hwnd=0);
|
||||
//! wait for a key pressed
|
||||
void WaitForKey();
|
||||
//! clear the key (pressed) state
|
||||
void ClearKeyState();
|
||||
//! get the key state
|
||||
unsigned char GetKeyState(int nKey);
|
||||
//! return the name (ascii name mapped to the virtual keyboard layout) of the key specified in kKeyCode
|
||||
//!
|
||||
void Update();
|
||||
/////////////////////////////////////////////////////////////
|
||||
int GetModifiers() const { return m_modifiers; };
|
||||
|
||||
private:
|
||||
static XAsciiKey m_AsciiTable[256];
|
||||
public:
|
||||
unsigned short DIK2XKEY(unsigned char cCode);
|
||||
unsigned char XKEY2DIK(unsigned short nCode);
|
||||
unsigned char XKEY2ASCII(unsigned short nCode,int modifiers);
|
||||
bool GetOSKeyName(int nKey, wchar_t *szwKeyName, int iBufSize);
|
||||
|
||||
void FeedVirtualKey(int nVirtualKey,long lParam,bool bDown);
|
||||
|
||||
protected:
|
||||
bool Acquire();
|
||||
bool UnAcquire();
|
||||
void SetupKeyNames();
|
||||
void ProcessKey(int nKey,bool bPressed,unsigned char *cTempKeys);
|
||||
unsigned char m_cKeysState[256];
|
||||
unsigned char m_cOldKeysState[256];
|
||||
unsigned char m_cTempKeys[256];
|
||||
CInput *m_pInput;
|
||||
#ifdef WIN32
|
||||
LPDIRECTINPUTDEVICE8 m_pKeyboard;
|
||||
HINSTANCE m_hinst;
|
||||
HWND m_hwnd;
|
||||
int m_iToggleState;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////
|
||||
////////PS2 SPECIFIC DATA /////////////////
|
||||
///////////////////////////////////////////
|
||||
|
||||
#ifdef PS2
|
||||
|
||||
///??
|
||||
void *m_pKeyboard;
|
||||
|
||||
//Keyboard's ID
|
||||
int m_KeyboardNumber;
|
||||
|
||||
unsigned char ASCIPRESSED[255];
|
||||
unsigned char ASCIPRESSEDOLD[255];
|
||||
|
||||
//Just one key pressed a time (as the PC version) to be updated
|
||||
char m_KeyPressedName;
|
||||
|
||||
//Keyboard info
|
||||
USBKBINFO_t keyinfo;
|
||||
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////
|
||||
///////////////////////////////////////////
|
||||
///////////////////////////////////////////
|
||||
|
||||
bool m_bExclusiveMode;
|
||||
ISystem *m_pSystem;
|
||||
ILog *m_pLog;
|
||||
|
||||
ICVar *m_cvBufferedKeys;
|
||||
ICVar *m_cvDirectInputKeys;
|
||||
int m_modifiers;
|
||||
|
||||
#ifdef PS2
|
||||
public:
|
||||
bool m_Initialized;
|
||||
|
||||
bool IsInit(){return m_Initialized;}
|
||||
void SetPad(CJoystick *pJoy){m_pJoy=pJoy;}
|
||||
private:
|
||||
CJoystick *m_pJoy;
|
||||
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_XKEYBOARD_H__9C0FD463_ECC8_42DA_8019_378651B00771__INCLUDED_)
|
||||
1518
CryInput/XMouse.cpp
Normal file
1518
CryInput/XMouse.cpp
Normal file
File diff suppressed because it is too large
Load Diff
213
CryInput/XMouse.h
Normal file
213
CryInput/XMouse.h
Normal file
@@ -0,0 +1,213 @@
|
||||
// XMouse.h: interface for the CXMouse class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_XMOUSE_H__E79C3125_5BF0_499D_B76E_6C1070554E8F__INCLUDED_)
|
||||
#define AFX_XMOUSE_H__E79C3125_5BF0_499D_B76E_6C1070554E8F__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#include <IInput.h>
|
||||
struct ITimer;
|
||||
struct ILog;
|
||||
|
||||
#ifdef PS2
|
||||
#include "Joystick.h"
|
||||
#endif
|
||||
|
||||
struct ICVar;
|
||||
|
||||
#define XMOUSE_MAX_MOUSE_EVENTS 12 // e.g. mouse buttons, axis, ..
|
||||
|
||||
class CXMouse :
|
||||
public IMouse
|
||||
{
|
||||
public:
|
||||
CXMouse()
|
||||
{
|
||||
m_exmode=false;
|
||||
m_pMouse = NULL;
|
||||
m_kInertia=0;
|
||||
m_fAccelerationScale=0.5f;
|
||||
m_bAcceleration=false;
|
||||
i_mouse_buffered = NULL;
|
||||
}
|
||||
virtual ~CXMouse(){
|
||||
}
|
||||
|
||||
class CInput* m_pInput;
|
||||
|
||||
#ifdef WIN32
|
||||
bool Init(ISystem *pSystem,LPDIRECTINPUT8 &g_pdi,HINSTANCE hinst,HWND hwnd,bool dinput);
|
||||
#else
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
///////////////PS2 SPECIFIC INIT ///////////////////
|
||||
////////////////////////////////////////////////////
|
||||
#ifdef PS2
|
||||
|
||||
bool m_Initialized;
|
||||
|
||||
bool Init(ISystem *pSystem);
|
||||
bool IsInit(){return m_Initialized;}
|
||||
|
||||
#endif
|
||||
////////////////////////////////////////////////////
|
||||
///////////////END PS2 SPECIFIC ////////////////////
|
||||
////////////////////////////////////////////////////
|
||||
|
||||
#endif
|
||||
|
||||
void Shutdown();
|
||||
void Update(bool bPrevFocus);
|
||||
|
||||
void ClearKeyState();
|
||||
|
||||
bool MouseDown(int p_numButton);
|
||||
bool MousePressed(int p_numButton);
|
||||
bool MouseDblClick(int p_numButton);
|
||||
bool MouseReleased(int p_numButton);
|
||||
bool GetOSKeyName(int nKey, wchar_t *szwKeyName, int iBufSize);
|
||||
|
||||
// int GetMouseWheelRotation(bool reset = true); // get wheel state for aplication
|
||||
void SetMouseWheelRotation(int value); // set wheel state from app message loop
|
||||
|
||||
bool SetExclusive(bool value,void *hwnd=0);
|
||||
|
||||
inline float GetDeltaX() { return m_Deltas[0]*(m_fSensitivity*m_fSensitivityScale); }
|
||||
inline float GetDeltaY() { return m_Deltas[1]*(m_fSensitivity*m_fSensitivityScale); }
|
||||
inline float GetDeltaZ()
|
||||
{
|
||||
m_wheelChecked = true;
|
||||
return m_Deltas[2]*(m_fSensitivity*m_fSensitivityScale);
|
||||
}
|
||||
|
||||
void SetSensitvity(float fSensitivity)
|
||||
{
|
||||
if(fSensitivity>0)
|
||||
m_fSensitivity=fSensitivity/100;
|
||||
else
|
||||
m_fSensitivity=0.0f;
|
||||
}
|
||||
float GetSensitvity()
|
||||
{
|
||||
return m_fSensitivity*100;
|
||||
}
|
||||
void SetSensitvityScale(float fSensScale)
|
||||
{
|
||||
m_fSensitivityScale=fSensScale;
|
||||
}
|
||||
float GetSensitvityScale()
|
||||
{
|
||||
return m_fSensitivityScale;
|
||||
}
|
||||
inline void SetInertia(float kinertia) { m_kInertia=kinertia; }
|
||||
|
||||
void SetVScreenX(float fX);
|
||||
void SetVScreenY(float fY);
|
||||
float GetVScreenX();
|
||||
float GetVScreenY();
|
||||
private:
|
||||
bool Acquire();
|
||||
bool UnAcquire();
|
||||
int XKEY2IDX(int nKey);
|
||||
|
||||
void PostEvent( int key,SInputEvent::EType type,float value=0,unsigned int timestamp=0 );
|
||||
|
||||
//smooth movement & mouse accel
|
||||
void CapDeltas(float cap);
|
||||
void SmoothDeltas(float accel,float decel=0.0f);
|
||||
|
||||
#ifdef WIN32
|
||||
LPDIRECTINPUTDEVICE8 m_pMouse;
|
||||
#else
|
||||
void * m_pMouse;
|
||||
#endif
|
||||
|
||||
HINSTANCE m_hinst;
|
||||
HWND m_hwnd;
|
||||
|
||||
#ifndef PS2
|
||||
POINT m_previouspoint;
|
||||
#endif
|
||||
|
||||
ICVar * i_mouse_buffered;
|
||||
//! mouse accel cvars
|
||||
ICVar * i_mouse_accel;
|
||||
ICVar * i_mouse_accel_max;
|
||||
//! mouse smooth cvar
|
||||
ICVar * i_mouse_smooth;
|
||||
//! mouse mirror cvar
|
||||
ICVar * i_mouse_mirror;
|
||||
|
||||
float m_fDblClickTime;
|
||||
|
||||
float m_Deltas[5];
|
||||
float m_OldDeltas[2];//!< just old x,y, to smooth movement.
|
||||
|
||||
float m_DeltasInertia[2];
|
||||
float m_kInertia;
|
||||
unsigned char m_Events[XMOUSE_MAX_MOUSE_EVENTS]; //!<
|
||||
unsigned char m_oldEvents[XMOUSE_MAX_MOUSE_EVENTS]; //!<
|
||||
float m_fLastRelease[XMOUSE_MAX_MOUSE_EVENTS]; //!<
|
||||
bool m_bDblClick[XMOUSE_MAX_MOUSE_EVENTS]; //!<
|
||||
|
||||
bool m_exmode;
|
||||
bool m_dinput;
|
||||
bool m_wheelChecked;
|
||||
|
||||
float m_fVScreenX;
|
||||
float m_fVScreenY;
|
||||
|
||||
ILog * m_pLog;
|
||||
ITimer * m_pTimer;
|
||||
ISystem * m_pSystem;
|
||||
|
||||
float m_fSensitivity;
|
||||
float m_fSensitivityScale;
|
||||
float m_fAccelerationScale;
|
||||
bool m_bAcceleration;
|
||||
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
//////////////PS2 SPECIFIC////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef PS2
|
||||
|
||||
int m_MousePort;
|
||||
|
||||
|
||||
int XPos;
|
||||
int YPos;
|
||||
int XOldPos;
|
||||
int YOldPos;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//Used to simulate mouse input with pad (if needed)
|
||||
void SetPad(CJoystick *pJoy){m_pJoy=pJoy;}
|
||||
|
||||
private:
|
||||
|
||||
//If no mouse connected, use pad to simulate it
|
||||
CJoystick *m_pJoy;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
//////////////END PS2 SPECIFIC////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_XMOUSE_H__E79C3125_5BF0_499D_B76E_6C1070554E8F__INCLUDED_)
|
||||
Reference in New Issue
Block a user