diff --git a/data/inputprofiles/DualShock 4.ini b/data/inputprofiles/DualShock 4.ini index f21057e1e..fdfc31194 100644 --- a/data/inputprofiles/DualShock 4.ini +++ b/data/inputprofiles/DualShock 4.ini @@ -1,22 +1,24 @@ [Controller1] -Type=AnalogController -ButtonUp=Controller0/Button11 -ButtonDown=Controller0/Button12 -ButtonLeft=Controller0/Button13 -ButtonRight=Controller0/Button14 -ButtonSelect=Controller0/Button4 -ButtonStart=Controller0/Button6 -ButtonTriangle=Controller0/Button3 -ButtonCross=Controller0/Button0 -ButtonCircle=Controller0/Button1 -ButtonSquare=Controller0/Button2 -ButtonL1=Controller0/Button9 -ButtonL2=Controller0/+Axis4 -ButtonR1=Controller0/Button10 -ButtonR2=Controller0/+Axis5 -ButtonL3=Controller0/Button7 -ButtonR3=Controller0/Button8 -AxisLeftX=Controller0/Axis0 -AxisLeftY=Controller0/Axis1 -AxisRightX=Controller0/Axis2 -AxisRightY=Controller0/Axis3 +Type = AnalogController +ButtonUp = Controller0/Button11 +ButtonDown = Controller0/Button12 +ButtonLeft = Controller0/Button13 +ButtonRight = Controller0/Button14 +ButtonSelect = Controller0/Button4 +ButtonStart = Controller0/Button6 +ButtonTriangle = Controller0/Button3 +ButtonCross = Controller0/Button0 +ButtonCircle = Controller0/Button1 +ButtonSquare = Controller0/Button2 +ButtonL1 = Controller0/Button9 +ButtonL2 = Controller0/+Axis4 +ButtonR1 = Controller0/Button10 +ButtonR2 = Controller0/+Axis5 +ButtonL3 = Controller0/Button7 +ButtonR3 = Controller0/Button8 +ButtonAnalog = Controller0/Button5 +AxisLeftX = Controller0/Axis0 +AxisLeftY = Controller0/Axis1 +AxisRightX = Controller0/Axis2 +AxisRightY = Controller0/Axis3 +Rumble = Controller0 diff --git a/data/inputprofiles/PlayStation Classic Controller.ini b/data/inputprofiles/PlayStation Classic Controller.ini new file mode 100644 index 000000000..7c7728f30 --- /dev/null +++ b/data/inputprofiles/PlayStation Classic Controller.ini @@ -0,0 +1,16 @@ +[Controller1] +Type = DigitalController +ButtonUp = Controller0/-Axis1 +ButtonDown = Controller0/+Axis1 +ButtonLeft = Controller0/-Axis0 +ButtonRight = Controller0/+Axis0 +ButtonSelect = Controller0/Button4 +ButtonStart = Controller0/Button6 +ButtonTriangle = Controller0/Button3 +ButtonCross = Controller0/Button0 +ButtonCircle = Controller0/Button1 +ButtonSquare = Controller0/Button2 +ButtonL1 = Controller0/Button9 +ButtonL2 = Controller0/+Axis4 +ButtonR1 = Controller0/Button10 +ButtonR2 = Controller0/+Axis5 diff --git a/src/core/analog_controller.cpp b/src/core/analog_controller.cpp index 33a9d1568..808f7906f 100644 --- a/src/core/analog_controller.cpp +++ b/src/core/analog_controller.cpp @@ -67,7 +67,7 @@ std::optional AnalogController::GetButtonCodeByName(std::string_view button void AnalogController::SetAxisState(s32 axis_code, float value) { - if (axis_code < 0 || axis_code >= static_cast(Button::Count)) + if (axis_code < 0 || axis_code >= static_cast(Axis::Count)) return; // -1..1 -> 0..255 diff --git a/src/frontend-common/common_host_interface.cpp b/src/frontend-common/common_host_interface.cpp index 246128198..97849586b 100644 --- a/src/frontend-common/common_host_interface.cpp +++ b/src/frontend-common/common_host_interface.cpp @@ -1068,15 +1068,12 @@ void CommonHostInterface::ApplyInputProfile(const char* profile_path, SettingsIn bool CommonHostInterface::SaveInputProfile(const char* profile_path, SettingsInterface& si) { if (FileSystem::FileExists(profile_path)) - { - if (!FileSystem::DeleteFile(profile_path)) - { - Log_ErrorPrintf("Failed to delete existing input profile '%s' when saving", profile_path); - return false; - } - } + Log_WarningPrintf("Existing input profile at '%s' will be overwritten", profile_path); + else + Log_WarningPrintf("Input profile at '%s' does not exist, new input profile will be created", profile_path); INISettingsInterface profile(profile_path); + profile.Clear(); for (u32 controller_index = 1; controller_index <= NUM_CONTROLLER_AND_CARD_PORTS; controller_index++) { @@ -1109,7 +1106,13 @@ bool CommonHostInterface::SaveInputProfile(const char* profile_path, SettingsInt profile.SetStringValue(section_name, "Rumble", rumble_value.c_str()); } - profile.Save(); + if(!profile.Save()) + { + Log_ErrorPrintf("Failed to save input profile to '%s'", profile_path); + return false; + } + + Log_SuccessPrintf("Input profile saved to '%s'", profile_path); return true; } diff --git a/src/frontend-common/ini_settings_interface.cpp b/src/frontend-common/ini_settings_interface.cpp index 24f7a14bf..5c1daebea 100644 --- a/src/frontend-common/ini_settings_interface.cpp +++ b/src/frontend-common/ini_settings_interface.cpp @@ -16,13 +16,17 @@ INISettingsInterface::~INISettingsInterface() Save(); } -void INISettingsInterface::Save() +bool INISettingsInterface::Save() { SI_Error err = m_ini.SaveFile(m_filename.c_str(), false); if (err != SI_OK) + { Log_WarningPrintf("Failed to save settings to '%s'.", m_filename.c_str()); - else - m_dirty = false; + return false; + } + + m_dirty = false; + return true; } void INISettingsInterface::Clear() diff --git a/src/frontend-common/ini_settings_interface.h b/src/frontend-common/ini_settings_interface.h index 88dac946f..592c99d75 100644 --- a/src/frontend-common/ini_settings_interface.h +++ b/src/frontend-common/ini_settings_interface.h @@ -9,7 +9,7 @@ public: INISettingsInterface(std::string filename); ~INISettingsInterface(); - void Save(); + bool Save(); void Clear() override;