MCPcopy Create free account
hub / github.com/PCSX2/pcsx2 / LoadConfig

Method LoadConfig

pcsx2/SIO/Pad/Pad.cpp:90–150  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

88}
89
90void Pad::LoadConfig(const SettingsInterface& si)
91{
92 s_macro_buttons = {};
93
94 const bool mtapPort0Changed = EmuConfig.Pad.MultitapPort0_Enabled != Pad::mtapPort0LastState;
95 const bool mtapPort1Changed = EmuConfig.Pad.MultitapPort1_Enabled != Pad::mtapPort1LastState;
96
97 for (u32 i = 0; i < Pad::NUM_CONTROLLER_PORTS; i++)
98 {
99 const std::string section = GetConfigSection(i);
100 const ControllerInfo* ci = GetControllerInfo(EmuConfig.Pad.Ports[i].Type);
101 pxAssert(ci);
102
103 PadBase* pad = Pad::GetPad(i);
104
105 // If pad pointer is not occupied yet, type in settings no longer matches the current type, or a multitap was slotted in/out,
106 // then reconstruct a new pad.
107 if (!pad || pad->GetType() != ci->type || (mtapPort0Changed && (i <= 4 && i != 1)) || (mtapPort1Changed && (i >= 5 || i == 1)))
108 {
109 // If the slot is a multitap slot, and the multitap is not plugged in, then the pad should be forced to Not Connected.
110 if (i > 1 && ((i <= 4 && !EmuConfig.Pad.MultitapPort0_Enabled) || (i > 4 && !EmuConfig.Pad.MultitapPort1_Enabled)))
111 {
112 pad = Pad::CreatePad(i, Pad::ControllerType::NotConnected, (VMManager::GetState() != VMState::Shutdown ? Pad::DEFAULT_EJECT_TICKS : 0));
113 }
114 else
115 {
116 // Create the new pad. If the VM is in any kind of running state at all, set eject ticks so the PS2 will think
117 // there was some kind of pad ejection event and properly detect the new one, and properly initiate its config sequence.
118 pad = Pad::CreatePad(i, ci->type, (VMManager::GetState() != VMState::Shutdown ? Pad::DEFAULT_EJECT_TICKS : 0));
119 }
120
121 pxAssert(pad);
122 }
123
124 const float axis_deadzone = si.GetFloatValue(section.c_str(), "Deadzone", Pad::DEFAULT_STICK_DEADZONE);
125 const float axis_scale = si.GetFloatValue(section.c_str(), "AxisScale", Pad::DEFAULT_STICK_SCALE);
126 const float button_deadzone = si.GetFloatValue(section.c_str(), "ButtonDeadzone", Pad::DEFAULT_BUTTON_DEADZONE);
127 pad->SetAxisScale(axis_deadzone, axis_scale);
128 pad->SetButtonDeadzone(button_deadzone);
129
130 if (ci->vibration_caps != Pad::VibrationCapabilities::NoVibration)
131 {
132 const float large_motor_scale = si.GetFloatValue(section.c_str(), "LargeMotorScale", Pad::DEFAULT_MOTOR_SCALE);
133 const float small_motor_scale = si.GetFloatValue(section.c_str(), "SmallMotorScale", Pad::DEFAULT_MOTOR_SCALE);
134 pad->SetVibrationScale(0, large_motor_scale);
135 pad->SetVibrationScale(1, small_motor_scale);
136 }
137
138 const float pressure_modifier = si.GetFloatValue(section.c_str(), "PressureModifier", 1.0f);
139 pad->SetPressureModifier(pressure_modifier);
140
141 const int invert_l = si.GetIntValue(section.c_str(), "InvertL", 0);
142 const int invert_r = si.GetIntValue(section.c_str(), "InvertR", 0);
143 pad->SetAnalogInvertL((invert_l & 1) != 0, (invert_l & 2) != 0);
144 pad->SetAnalogInvertR((invert_r & 1) != 0, (invert_r & 2) != 0);
145 LoadMacroButtonConfig(si, i, ci, section);
146 }
147

Callers

nothing calls this directly

Calls 10

GetTypeMethod · 0.45
GetFloatValueMethod · 0.45
c_strMethod · 0.45
SetAxisScaleMethod · 0.45
SetButtonDeadzoneMethod · 0.45
SetVibrationScaleMethod · 0.45
SetPressureModifierMethod · 0.45
GetIntValueMethod · 0.45
SetAnalogInvertLMethod · 0.45
SetAnalogInvertRMethod · 0.45

Tested by

no test coverage detected