mirror of
https://github.com/PrimeDecomp/prime.git
synced 2026-07-12 18:18:56 -07:00
Add CControlMapper
This commit is contained in:
File diff suppressed because it is too large
Load Diff
+1
-1
@@ -40,7 +40,7 @@ LIBS = [
|
||||
["MetroidPrime/main", False],
|
||||
"MetroidPrime/IRenderer",
|
||||
"MetroidPrime/Cameras/CCameraManager",
|
||||
"MetroidPrime/CControlMapper",
|
||||
["MetroidPrime/CControlMapper", False],
|
||||
"MetroidPrime/Cameras/CFirstPersonCamera",
|
||||
["MetroidPrime/CObjectList", True],
|
||||
"MetroidPrime/Player/CPlayer",
|
||||
|
||||
@@ -42,6 +42,142 @@ public:
|
||||
|
||||
CFinalInput ScaleAnalogueSticks(float leftDiv, float rightDiv) const;
|
||||
|
||||
float ALAUp() const { return xc_anaLeftY > 0.f ? xc_anaLeftY : 0.f; }
|
||||
|
||||
float ALADown() const { return xc_anaLeftY < 0.f ? -xc_anaLeftY : 0.f; }
|
||||
|
||||
float ALALeft() const { return x8_anaLeftX < 0.f ? -x8_anaLeftX : 0.f; }
|
||||
|
||||
float ALARight() const { return x8_anaLeftX > 0.f ? x8_anaLeftX : 0.f; }
|
||||
|
||||
float ARAUp() const { return x14_anaRightY > 0.f ? x14_anaRightY : 0.f; }
|
||||
|
||||
float ARADown() const { return x14_anaRightY < 0.f ? -x14_anaRightY : 0.f; }
|
||||
|
||||
float ARALeft() const { return x10_anaRightX < 0.f ? -x10_anaRightX : 0.f; }
|
||||
|
||||
float ARARight() const { return x10_anaRightX > 0.f ? x10_anaRightX : 0.f; }
|
||||
|
||||
float ALTrigger() const { return x18_anaLeftTrigger; }
|
||||
|
||||
float ARTrigger() const { return x1c_anaRightTrigger; }
|
||||
|
||||
float ADPUp() const { return x2c_b31_DPUp ? 1.f : 0.f; }
|
||||
|
||||
float ADPDown() const { return x2d_b25_DPDown ? 1.f : 0.f; }
|
||||
|
||||
float ADPLeft() const { return x2d_b26_DPLeft ? 1.f : 0.f; }
|
||||
|
||||
float ADPRight() const { return x2d_b24_DPRight ? 1.f : 0.f; }
|
||||
|
||||
float AA() const { return x2c_b24_A ? 1.f : 0.f; }
|
||||
|
||||
float AB() const { return x2c_b25_B ? 1.f : 0.f; }
|
||||
|
||||
float AX() const { return x2c_b26_X ? 1.f : 0.f; }
|
||||
|
||||
float AY() const { return x2c_b27_Y ? 1.f : 0.f; }
|
||||
|
||||
float AZ() const { return x2c_b28_Z ? 1.f : 0.f; }
|
||||
|
||||
float AL() const { return x2c_b29_L ? 1.f : 0.f; }
|
||||
|
||||
float AR() const { return x2c_b30_R ? 1.f : 0.f; }
|
||||
|
||||
float AStart() const { return x2d_b27_Start ? 1.f : 0.f; }
|
||||
|
||||
bool DLAUp() const { return kInput_AnalogOnThreshhold < xc_anaLeftY ? true : false; }
|
||||
|
||||
bool DLADown() const { return -kInput_AnalogOnThreshhold > xc_anaLeftY ? true : false; }
|
||||
|
||||
bool DLALeft() const { return -kInput_AnalogOnThreshhold > x8_anaLeftX ? true : false; }
|
||||
|
||||
bool DLARight() const { return kInput_AnalogOnThreshhold < x8_anaLeftX ? true : false; }
|
||||
|
||||
bool DRAUp() const { return kInput_AnalogOnThreshhold < x14_anaRightY ? true : false; }
|
||||
|
||||
bool DRADown() const { return -kInput_AnalogOnThreshhold > x14_anaRightY ? true : false; }
|
||||
|
||||
bool DRALeft() const { return -kInput_AnalogOnThreshhold > x10_anaRightX ? true : false; }
|
||||
|
||||
bool DRARight() const { return kInput_AnalogOnThreshhold < x10_anaRightX ? true : false; }
|
||||
|
||||
bool DLTrigger() const {
|
||||
return kInput_AnalogTriggerOnThreshhold < x18_anaLeftTrigger ? true : false;
|
||||
}
|
||||
|
||||
bool DRTrigger() const {
|
||||
return kInput_AnalogTriggerOnThreshhold < x1c_anaRightTrigger ? true : false;
|
||||
}
|
||||
|
||||
bool DDPUp() const { return x2c_b31_DPUp; }
|
||||
|
||||
bool DDPDown() const { return x2d_b25_DPDown; }
|
||||
|
||||
bool DDPLeft() const { return x2d_b26_DPLeft; }
|
||||
|
||||
bool DDPRight() const { return x2d_b24_DPRight; }
|
||||
|
||||
bool DA() const { return x2c_b24_A; }
|
||||
|
||||
bool DB() const { return x2c_b25_B; }
|
||||
|
||||
bool DX() const { return x2c_b26_X; }
|
||||
|
||||
bool DY() const { return x2c_b27_Y; }
|
||||
|
||||
bool DZ() const { return x2c_b28_Z; }
|
||||
|
||||
bool DL() const { return x2c_b29_L; }
|
||||
|
||||
bool DR() const { return x2c_b30_R; }
|
||||
|
||||
bool DStart() const { return x2d_b27_Start; }
|
||||
|
||||
bool PLAUp() const { return kInput_AnalogOnThreshhold < xc_anaLeftY && x21_enableAnaLeftYP ? true : false; }
|
||||
|
||||
bool PLADown() const { return -kInput_AnalogOnThreshhold > xc_anaLeftY && x21_enableAnaLeftYP ? true : false; }
|
||||
|
||||
bool PLALeft() const { return -kInput_AnalogOnThreshhold > x8_anaLeftX && x20_enableAnaLeftXP ? true : false; }
|
||||
|
||||
bool PLARight() const { return kInput_AnalogOnThreshhold < x8_anaLeftX && x20_enableAnaLeftXP ? true : false; }
|
||||
|
||||
bool PRAUp() const { return kInput_AnalogOnThreshhold < x14_anaRightY && x23_enableAnaRightYP ? true : false; }
|
||||
|
||||
bool PRADown() const { return -kInput_AnalogOnThreshhold > x14_anaRightY && x23_enableAnaRightYP ? true : false; }
|
||||
|
||||
bool PRALeft() const { return -kInput_AnalogOnThreshhold > x10_anaRightX && x22_enableAnaRightXP ? true : false; }
|
||||
|
||||
bool PRARight() const { return kInput_AnalogOnThreshhold < x10_anaRightX && x22_enableAnaRightXP ? true : false; }
|
||||
|
||||
bool PLTrigger() const { return kInput_AnalogTriggerOnThreshhold < x24_anaLeftTriggerP ? true : false; }
|
||||
|
||||
bool PRTrigger() const { return kInput_AnalogTriggerOnThreshhold < x28_anaRightTriggerP ? true : false; }
|
||||
|
||||
bool PDPUp() const { return x2e_b27_PDPUp; }
|
||||
|
||||
bool PDPDown() const { return x2e_b29_PDPDown; }
|
||||
|
||||
bool PDPLeft() const { return x2e_b30_PDPLeft; }
|
||||
|
||||
bool PDPRight() const { return x2e_b28_PDPRight; }
|
||||
|
||||
bool PA() const { return x2d_b28_PA; }
|
||||
|
||||
bool PB() const { return x2d_b29_PB; }
|
||||
|
||||
bool PX() const { return x2d_b30_PX; }
|
||||
|
||||
bool PY() const { return x2d_b31_PY; }
|
||||
|
||||
bool PZ() const { return x2e_b24_PZ; }
|
||||
|
||||
bool PL() const { return x2e_b25_PL; }
|
||||
|
||||
bool PR() const { return x2e_b26_PR; }
|
||||
|
||||
bool PStart() const { return x2e_b31_PStart; }
|
||||
|
||||
private:
|
||||
float x0_dt;
|
||||
uint x4_controllerIdx;
|
||||
|
||||
@@ -1,6 +1,14 @@
|
||||
#ifndef _CCONTROLMAPPER
|
||||
#define _CCONTROLMAPPER
|
||||
|
||||
#include "rstl/reserved_vector.hpp"
|
||||
|
||||
class CFinalInput;
|
||||
|
||||
|
||||
typedef float (CFinalInput::*FAnalogInput)() const;
|
||||
typedef bool (CFinalInput::*FDigitalInput)() const;
|
||||
|
||||
class ControlMapper {
|
||||
public:
|
||||
enum ECommands {
|
||||
@@ -56,13 +64,13 @@ public:
|
||||
kC_ChaseCamera,
|
||||
kC_XrayVisor = 50,
|
||||
kC_ThermoVisor = 51,
|
||||
kC_InviroVisor = 52,
|
||||
kC_EnviroVisor = 52,
|
||||
kC_NoVisor = 53,
|
||||
kC_VisorMenu,
|
||||
kC_VisorUp,
|
||||
kC_VisorDown,
|
||||
kC_ShowCrosshairs,
|
||||
kC_UseSheild = 0x3B,
|
||||
kC_UseShield = 0x3B,
|
||||
kC_ScanItem = 0x3C,
|
||||
kC_PreviousPauseScreen = 0x41,
|
||||
kC_NextPauseScreen = 0x42,
|
||||
@@ -95,9 +103,21 @@ public:
|
||||
kFL_LeftTriggerPress,
|
||||
kFL_RightTriggerPress,
|
||||
kFL_Start,
|
||||
kFL_MAX // default case
|
||||
kFL_MAX // default casegDigitalInputs
|
||||
};
|
||||
|
||||
static const FAnalogInput gAnalogInputs[];
|
||||
static const FDigitalInput gDigitalInputs[];
|
||||
static const FDigitalInput gPressInputs[];
|
||||
|
||||
static rstl::reserved_vector<bool, 67> gCommandFilterFlag;
|
||||
|
||||
static const char* GetDescriptionForFunction(EFunctionList function);
|
||||
static const char* GetDescriptionForCommand(ECommands function);
|
||||
static float GetAnalogInput(ECommands command, const CFinalInput& input);
|
||||
static bool GetDigitalInput(ECommands command, const CFinalInput& input);
|
||||
static bool GetPressInput(ECommands command, const CFinalInput& input);
|
||||
static void ResetCommandFilters();
|
||||
static void SetCommandFiltered(ECommands cmd, bool filtered);
|
||||
};
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "rstl/reserved_vector.hpp"
|
||||
|
||||
class ITweakObject;
|
||||
class CTweakPlayerControl;
|
||||
|
||||
class CTweaks {
|
||||
public:
|
||||
@@ -21,4 +22,6 @@ private:
|
||||
};
|
||||
CHECK_SIZEOF(CTweaks, 0x64)
|
||||
|
||||
extern CTweakPlayerControl* gpTweakPlayerControlCurrent;
|
||||
|
||||
#endif // _CTWEAKS
|
||||
|
||||
@@ -0,0 +1,305 @@
|
||||
#include "MetroidPrime/CControlMapper.hpp"
|
||||
|
||||
#include "MetroidPrime/Tweaks/CTweaks.hpp"
|
||||
|
||||
#include "MetroidPrime/Tweaks/CTweakPlayerControl.hpp"
|
||||
|
||||
#include "Kyoto/Input/CFinalInput.hpp"
|
||||
|
||||
rstl::reserved_vector< bool, 67 > ControlMapper::gCommandFilterFlag(true);
|
||||
|
||||
const FAnalogInput ControlMapper::gAnalogInputs[] = {
|
||||
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,
|
||||
};
|
||||
|
||||
const FDigitalInput ControlMapper::gDigitalInputs[] = {
|
||||
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,
|
||||
};
|
||||
|
||||
const FDigitalInput ControlMapper::gPressInputs[] = {
|
||||
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,
|
||||
};
|
||||
|
||||
const char* ControlMapper::GetDescriptionForFunction(EFunctionList function) {
|
||||
switch (function) {
|
||||
case kFL_None:
|
||||
return "None";
|
||||
case kFL_LeftStickUp:
|
||||
return "Left Stick Up";
|
||||
case kFL_LeftStickDown:
|
||||
return "Left Stick Down";
|
||||
case kFL_LeftStickLeft:
|
||||
return "Left Stick Left";
|
||||
case kFL_LeftStickRight:
|
||||
return "Left Stick Right";
|
||||
case kFL_RightStickUp:
|
||||
return "Right Stick Up";
|
||||
case kFL_RightStickDown:
|
||||
return "Right Stick Down";
|
||||
case kFL_RightStickLeft:
|
||||
return "Right Stick Left";
|
||||
case kFL_RightStickRight:
|
||||
return "Right Stick Right";
|
||||
case kFL_LeftTrigger:
|
||||
return "Left Trigger";
|
||||
case kFL_RightTrigger:
|
||||
return "Right Trigger";
|
||||
case kFL_DPadUp:
|
||||
return "D-Pad Up ";
|
||||
case kFL_DPadDown:
|
||||
return "D-Pad Down ";
|
||||
case kFL_DPadLeft:
|
||||
return "D-Pad Left ";
|
||||
case kFL_DPadRight:
|
||||
return "D-Pad Right";
|
||||
case kFL_AButton:
|
||||
return "A Button";
|
||||
case kFL_BButton:
|
||||
return "B Button";
|
||||
case kFL_XButton:
|
||||
return "X Button";
|
||||
case kFL_YButton:
|
||||
return "Y Button";
|
||||
case kFL_ZButton:
|
||||
return "Z Button";
|
||||
case kFL_LeftTriggerPress:
|
||||
return "Left Trigger Press";
|
||||
case kFL_RightTriggerPress:
|
||||
return "Right Trigger Press";
|
||||
case kFL_Start:
|
||||
return "Start";
|
||||
}
|
||||
|
||||
return "UNKNOWN";
|
||||
}
|
||||
|
||||
const char* ControlMapper::GetDescriptionForCommand(ECommands command) {
|
||||
switch (command) {
|
||||
case kC_Forward:
|
||||
return "Forward";
|
||||
case kC_Backward:
|
||||
return "Backward";
|
||||
case kC_TurnLeft:
|
||||
return "Turn Left";
|
||||
case kC_TurnRight:
|
||||
return "Turn Right";
|
||||
case kC_StrafeLeft:
|
||||
return "Strafe Left";
|
||||
case kC_StrafeRight:
|
||||
return "Strafe Right";
|
||||
case kC_LookLeft:
|
||||
return "Look Left";
|
||||
case kC_LookRight:
|
||||
return "Look Right";
|
||||
case kC_LookUp:
|
||||
return "Look Up";
|
||||
case kC_LookDown:
|
||||
return "Look Down";
|
||||
case kC_JumpOrBoost:
|
||||
return "Jump/Boost";
|
||||
case kC_FireOrBomb:
|
||||
return "Fire/Bomb";
|
||||
case kC_MissileOrPowerBomb:
|
||||
return "Missile/PowerBomb";
|
||||
case kC_Morph:
|
||||
return "Morph";
|
||||
case kC_AimUp:
|
||||
return "Aim Up";
|
||||
case kC_AimDown:
|
||||
return "Aim Down";
|
||||
case kC_CycleBeamUp:
|
||||
return "Cycle Beam Up";
|
||||
case kC_CycleBeamDown:
|
||||
return "Cycle Beam Down";
|
||||
case kC_CycleItem:
|
||||
return "Cycle Item";
|
||||
case kC_PowerBeam:
|
||||
return "Power Beam";
|
||||
case kC_IceBeam:
|
||||
return "Ice Beam";
|
||||
case kC_WaveBeam:
|
||||
return "Wave Beam";
|
||||
case kC_PlasmaBeam:
|
||||
return "Plasma Beam";
|
||||
case kC_ToggleHolster:
|
||||
return "Toggle Holster";
|
||||
case kC_OrbitClose:
|
||||
return "Orbit Close";
|
||||
case kC_OrbitFar:
|
||||
return "Orbit Far";
|
||||
case kC_OrbitObject:
|
||||
return "Orbit Object";
|
||||
case kC_OrbitSelect:
|
||||
return "Orbit Select";
|
||||
case kC_OrbitConfirm:
|
||||
return "Orbit Confirm";
|
||||
case kC_OrbitLeft:
|
||||
return "Orbit Left";
|
||||
case kC_OrbitRight:
|
||||
return "Orbit Right";
|
||||
case kC_OrbitUp:
|
||||
return "Orbit Up";
|
||||
case kC_OrbitDown:
|
||||
return "Orbit Down";
|
||||
case kC_LookHold1:
|
||||
return "Look Hold1";
|
||||
case kC_LookHold2:
|
||||
return "Look Hold2";
|
||||
case kC_LookZoomIn:
|
||||
return "Look Zoom In";
|
||||
case kC_LookZoomOut:
|
||||
return "Look Zoom Out";
|
||||
case kC_AimHold:
|
||||
return "Aim Hold";
|
||||
case kC_MapCircleUp:
|
||||
return "Map Circle Up";
|
||||
case kC_MapCircleDown:
|
||||
return "Map Circle Down";
|
||||
case kC_MapCircleLeft:
|
||||
return "Map Circle Left";
|
||||
case kC_MapCircleRight:
|
||||
return "Map Circle Right";
|
||||
case kC_MapMoveForward:
|
||||
return "Map Move Forward";
|
||||
case kC_MapMoveBack:
|
||||
return "Map Move Back";
|
||||
case kC_MapMoveLeft:
|
||||
return "Map Move Left";
|
||||
case kC_MapMoveRight:
|
||||
return "Map Move Right";
|
||||
case kC_MapZoomIn:
|
||||
return "Map Zoom In";
|
||||
case kC_MapZoomOut:
|
||||
return "Map Zoom Out";
|
||||
case kC_SpiderBall:
|
||||
return "SpiderBall";
|
||||
case kC_ChaseCamera:
|
||||
return "Chase Camera";
|
||||
case kC_XrayVisor:
|
||||
return "XRay Visor";
|
||||
case kC_ThermoVisor:
|
||||
return "Thermo Visor";
|
||||
case kC_EnviroVisor:
|
||||
return "Enviro Visor";
|
||||
case kC_NoVisor:
|
||||
return "No Visor";
|
||||
case kC_VisorMenu:
|
||||
return "Visor Menu";
|
||||
case kC_VisorUp:
|
||||
return "Visor Up";
|
||||
case kC_VisorDown:
|
||||
return "Visor Down";
|
||||
case kC_UseShield:
|
||||
return "Use Shield";
|
||||
case kC_ScanItem:
|
||||
return "Scan Item";
|
||||
}
|
||||
|
||||
return "UNKNOWN";
|
||||
}
|
||||
|
||||
float ControlMapper::GetAnalogInput(ECommands command, const CFinalInput& input) {
|
||||
if (gCommandFilterFlag[command]) {
|
||||
if (gAnalogInputs[gpTweakPlayerControlCurrent->GetMapping(command)] != nullptr) {
|
||||
return (input.*gAnalogInputs[gpTweakPlayerControlCurrent->GetMapping(command)])();
|
||||
}
|
||||
}
|
||||
return 0.f;
|
||||
}
|
||||
|
||||
bool ControlMapper::GetDigitalInput(ECommands command, const CFinalInput& input) {
|
||||
if (gCommandFilterFlag[command]) {
|
||||
if (gDigitalInputs[gpTweakPlayerControlCurrent->GetMapping(command)] != nullptr) {
|
||||
return (input.*gDigitalInputs[gpTweakPlayerControlCurrent->GetMapping(command)])();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ControlMapper::GetPressInput(ECommands command, const CFinalInput& input) {
|
||||
if (gCommandFilterFlag[command]) {
|
||||
if (gPressInputs[gpTweakPlayerControlCurrent->GetMapping(command)] != nullptr) {
|
||||
return (input.*gPressInputs[gpTweakPlayerControlCurrent->GetMapping(command)])();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void ControlMapper::ResetCommandFilters() {
|
||||
for (int i = 0; i < gCommandFilterFlag.size(); ++i) {
|
||||
gCommandFilterFlag[i] = true;
|
||||
}
|
||||
}
|
||||
|
||||
void ControlMapper::SetCommandFiltered(ECommands cmd, bool filtered) {
|
||||
gCommandFilterFlag[cmd] = filtered;
|
||||
}
|
||||
Reference in New Issue
Block a user