2015-08-28 00:11:31 +00:00
|
|
|
#include "../RetroTypes.hpp"
|
|
|
|
#include "ControlMapper.hpp"
|
|
|
|
#include "CFinalInput.hpp"
|
|
|
|
#include "DataSpec/DNACommon/Tweaks/ITweakPlayerControl.hpp"
|
|
|
|
#include "../GameGlobalObjects.hpp"
|
|
|
|
|
2016-03-04 23:04:53 +00:00
|
|
|
namespace urde
|
2015-08-28 00:11:31 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
static const char* skCommandDescs[] =
|
|
|
|
{
|
|
|
|
"Forward",
|
|
|
|
"Backward",
|
|
|
|
"Turn Left",
|
|
|
|
"Turn Right",
|
|
|
|
"Strafe Left",
|
|
|
|
"Strafe Right",
|
|
|
|
"Look Left",
|
|
|
|
"Look Right",
|
|
|
|
"Look Up",
|
|
|
|
"Look Down",
|
|
|
|
"Jump/Boost",
|
|
|
|
"Fire/Bomb",
|
|
|
|
"Missile/PowerBomb",
|
|
|
|
"Morph",
|
|
|
|
"Aim Up",
|
|
|
|
"Aim Down",
|
|
|
|
"Cycle Beam Up",
|
|
|
|
"Cycle Beam Down",
|
|
|
|
"Cycle Item",
|
|
|
|
"Power Beam",
|
|
|
|
"Ice Beam",
|
|
|
|
"Wave Beam",
|
|
|
|
"Plasma Beam",
|
|
|
|
"Toggle Holster",
|
|
|
|
"Orbit Close",
|
|
|
|
"Orbit Far",
|
|
|
|
"Orbit Object",
|
|
|
|
"Orbit Select",
|
|
|
|
"Orbit Confirm",
|
|
|
|
"Orbit Left",
|
|
|
|
"Orbit Right",
|
|
|
|
"Orbit Up",
|
|
|
|
"Orbit Down",
|
|
|
|
"Look Hold1",
|
|
|
|
"Look Hold2",
|
|
|
|
"Look Zoom In",
|
|
|
|
"Look Zoom Out",
|
|
|
|
"Aim Hold",
|
|
|
|
"Map Circle Up",
|
|
|
|
"Map Circle Down",
|
|
|
|
"Map Circle Left",
|
|
|
|
"Map Circle Right",
|
|
|
|
"Map Move Forward",
|
|
|
|
"Map Move Back",
|
|
|
|
"Map Move Left",
|
|
|
|
"Map Move Right",
|
|
|
|
"Map Zoom In",
|
|
|
|
"Map Zoom Out",
|
|
|
|
"SpiderBall",
|
|
|
|
"Chase Camera",
|
|
|
|
"XRay Visor",
|
|
|
|
"Thermo Visor",
|
|
|
|
"Enviro Visor",
|
|
|
|
"No Visor",
|
|
|
|
"Visor Menu",
|
|
|
|
"Visor Up",
|
|
|
|
"Visor Down",
|
2015-10-01 02:35:47 +00:00
|
|
|
"UNKNOWN",
|
|
|
|
"UNKNOWN",
|
2015-08-28 00:11:31 +00:00
|
|
|
"Use Shield",
|
|
|
|
"Scan Item",
|
|
|
|
"UNKNOWN"
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
static const char* skFunctionDescs[] =
|
|
|
|
{
|
|
|
|
"None",
|
|
|
|
"Left Stick Up",
|
|
|
|
"Left Stick Down",
|
|
|
|
"Left Stick Left",
|
|
|
|
"Left Stick Right",
|
|
|
|
"Right Stick Up",
|
|
|
|
"Right Stick Down",
|
|
|
|
"Right Stick Left",
|
|
|
|
"Right Stick Right",
|
|
|
|
"Left Trigger",
|
|
|
|
"Right Trigger",
|
|
|
|
"D-Pad Up ",
|
|
|
|
"D-Pad Down ",
|
|
|
|
"D-Pad Left ",
|
|
|
|
"D-Pad Right",
|
|
|
|
"A Button",
|
|
|
|
"B Button",
|
|
|
|
"X Button",
|
|
|
|
"Y Button",
|
|
|
|
"Z Button",
|
|
|
|
"Left Trigger Press",
|
|
|
|
"Right Trigger Press",
|
|
|
|
"Start"
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef bool (CFinalInput::*BoolReturnFn)() const;
|
|
|
|
typedef float (CFinalInput::*FloatReturnFn)() const;
|
|
|
|
|
|
|
|
static BoolReturnFn skPressFuncs[] =
|
|
|
|
{
|
|
|
|
nullptr,
|
|
|
|
&CFinalInput::PLAUp,
|
|
|
|
&CFinalInput::PLADown,
|
|
|
|
&CFinalInput::PLALeft,
|
|
|
|
&CFinalInput::PLARight,
|
|
|
|
&CFinalInput::PRAUp,
|
|
|
|
&CFinalInput::PRADown,
|
|
|
|
&CFinalInput::PRALeft,
|
|
|
|
&CFinalInput::PRARight,
|
|
|
|
&CFinalInput::PLTrigger,
|
|
|
|
&CFinalInput::PRTrigger,
|
|
|
|
&CFinalInput::PDPUp,
|
|
|
|
&CFinalInput::PDPDown,
|
|
|
|
&CFinalInput::PDPLeft,
|
|
|
|
&CFinalInput::PDPRight,
|
|
|
|
&CFinalInput::PA,
|
|
|
|
&CFinalInput::PB,
|
|
|
|
&CFinalInput::PX,
|
|
|
|
&CFinalInput::PY,
|
|
|
|
&CFinalInput::PZ,
|
|
|
|
&CFinalInput::PL,
|
|
|
|
&CFinalInput::PR,
|
|
|
|
&CFinalInput::PStart,
|
|
|
|
nullptr
|
|
|
|
};
|
|
|
|
|
|
|
|
static BoolReturnFn skDigitalFuncs[] =
|
|
|
|
{
|
|
|
|
nullptr,
|
|
|
|
&CFinalInput::DLAUp,
|
|
|
|
&CFinalInput::DLADown,
|
|
|
|
&CFinalInput::DLALeft,
|
|
|
|
&CFinalInput::DLARight,
|
|
|
|
&CFinalInput::DRAUp,
|
|
|
|
&CFinalInput::DRADown,
|
|
|
|
&CFinalInput::DRALeft,
|
|
|
|
&CFinalInput::DRARight,
|
|
|
|
&CFinalInput::DLTrigger,
|
|
|
|
&CFinalInput::DRTrigger,
|
|
|
|
&CFinalInput::DDPUp,
|
|
|
|
&CFinalInput::DDPDown,
|
|
|
|
&CFinalInput::DDPLeft,
|
|
|
|
&CFinalInput::DDPRight,
|
|
|
|
&CFinalInput::DA,
|
|
|
|
&CFinalInput::DB,
|
|
|
|
&CFinalInput::DX,
|
|
|
|
&CFinalInput::DY,
|
|
|
|
&CFinalInput::DZ,
|
|
|
|
&CFinalInput::DL,
|
|
|
|
&CFinalInput::DR,
|
|
|
|
&CFinalInput::DStart,
|
|
|
|
nullptr
|
|
|
|
};
|
|
|
|
|
|
|
|
static FloatReturnFn skAnalogFuncs[] =
|
|
|
|
{
|
|
|
|
nullptr,
|
|
|
|
&CFinalInput::ALAUp,
|
|
|
|
&CFinalInput::ALADown,
|
|
|
|
&CFinalInput::ALALeft,
|
|
|
|
&CFinalInput::ALARight,
|
|
|
|
&CFinalInput::ARAUp,
|
|
|
|
&CFinalInput::ARADown,
|
|
|
|
&CFinalInput::ARALeft,
|
|
|
|
&CFinalInput::ARARight,
|
|
|
|
&CFinalInput::ALTrigger,
|
|
|
|
&CFinalInput::ARTrigger,
|
|
|
|
&CFinalInput::ADPUp,
|
|
|
|
&CFinalInput::ADPDown,
|
|
|
|
&CFinalInput::ADPLeft,
|
|
|
|
&CFinalInput::ADPRight,
|
|
|
|
&CFinalInput::AA,
|
|
|
|
&CFinalInput::AB,
|
|
|
|
&CFinalInput::AX,
|
|
|
|
&CFinalInput::AY,
|
|
|
|
&CFinalInput::AZ,
|
|
|
|
&CFinalInput::AL,
|
|
|
|
&CFinalInput::AR,
|
|
|
|
&CFinalInput::AStart,
|
|
|
|
nullptr
|
|
|
|
};
|
|
|
|
|
|
|
|
#define kCommandFilterCount 65
|
|
|
|
static bool skCommandFilterFlag[kCommandFilterCount];
|
|
|
|
|
|
|
|
void ControlMapper::SetCommandFiltered(ECommands cmd, bool filtered)
|
|
|
|
{
|
2015-11-21 01:16:07 +00:00
|
|
|
skCommandFilterFlag[int(cmd)] = filtered;
|
2015-08-28 00:11:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ControlMapper::ResetCommandFilters()
|
|
|
|
{
|
|
|
|
for (int i=0 ; i<kCommandFilterCount ; ++i)
|
|
|
|
skCommandFilterFlag[i] = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ControlMapper::GetPressInput(ECommands cmd, const CFinalInput& input)
|
|
|
|
{
|
2015-11-21 01:16:07 +00:00
|
|
|
if (!skCommandFilterFlag[int(cmd)])
|
2015-08-28 00:11:31 +00:00
|
|
|
return false;
|
2017-01-07 01:58:05 +00:00
|
|
|
EFunctionList func = EFunctionList(g_currentPlayerControl->GetMapping(atUint32(cmd)));
|
2015-11-21 01:16:07 +00:00
|
|
|
if (func > EFunctionList::MAX)
|
2015-08-28 00:11:31 +00:00
|
|
|
return false;
|
2015-11-21 01:16:07 +00:00
|
|
|
BoolReturnFn fn = skPressFuncs[int(func)];
|
2015-08-28 00:11:31 +00:00
|
|
|
if (!fn)
|
|
|
|
return false;
|
|
|
|
return (input.*fn)();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ControlMapper::GetDigitalInput(ECommands cmd, const CFinalInput& input)
|
|
|
|
{
|
2015-11-21 01:16:07 +00:00
|
|
|
if (!skCommandFilterFlag[int(cmd)])
|
2015-08-28 00:11:31 +00:00
|
|
|
return false;
|
2017-01-07 01:58:05 +00:00
|
|
|
EFunctionList func = EFunctionList(g_currentPlayerControl->GetMapping(atUint32(cmd)));
|
2015-11-21 01:16:07 +00:00
|
|
|
if (func > EFunctionList::MAX)
|
2015-08-28 00:11:31 +00:00
|
|
|
return false;
|
2015-11-21 01:16:07 +00:00
|
|
|
BoolReturnFn fn = skDigitalFuncs[int(func)];
|
2015-08-28 00:11:31 +00:00
|
|
|
if (!fn)
|
|
|
|
return false;
|
|
|
|
return (input.*fn)();
|
|
|
|
}
|
|
|
|
|
|
|
|
float ControlMapper::GetAnalogInput(ECommands cmd, const CFinalInput& input)
|
|
|
|
{
|
2015-11-21 01:16:07 +00:00
|
|
|
if (!skCommandFilterFlag[int(cmd)])
|
2015-08-28 00:11:31 +00:00
|
|
|
return 0.0;
|
2017-01-07 01:58:05 +00:00
|
|
|
EFunctionList func = EFunctionList(g_currentPlayerControl->GetMapping(atUint32(cmd)));
|
2015-11-21 01:16:07 +00:00
|
|
|
if (func > EFunctionList::MAX)
|
2015-08-28 00:11:31 +00:00
|
|
|
return 0.0;
|
2015-11-21 01:16:07 +00:00
|
|
|
FloatReturnFn fn = skAnalogFuncs[int(func)];
|
2015-08-28 00:11:31 +00:00
|
|
|
if (!fn)
|
|
|
|
return 0.0;
|
|
|
|
return (input.*fn)();
|
|
|
|
}
|
|
|
|
|
|
|
|
const char* ControlMapper::GetDescriptionForCommand(ECommands cmd)
|
|
|
|
{
|
2015-11-21 01:16:07 +00:00
|
|
|
if (cmd > ECommands::MAX)
|
2015-08-28 00:11:31 +00:00
|
|
|
return nullptr;
|
2015-11-21 01:16:07 +00:00
|
|
|
return skCommandDescs[int(cmd)];
|
2015-08-28 00:11:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const char* ControlMapper::GetDescriptionForFunction(EFunctionList func)
|
|
|
|
{
|
2015-11-21 01:16:07 +00:00
|
|
|
if (func > EFunctionList::MAX)
|
2015-08-28 00:11:31 +00:00
|
|
|
return nullptr;
|
2015-11-21 01:16:07 +00:00
|
|
|
return skFunctionDescs[int(func)];
|
2015-08-28 00:11:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|