Big Picture: Remove ability to make per-game controls

Replace with profile selector instead
This commit is contained in:
RedPanda4552 2024-08-23 16:48:26 -04:00 committed by Ty
parent 04168a0359
commit 27fb7dc26e
2 changed files with 36 additions and 44 deletions

View File

@ -2808,12 +2808,12 @@ void FullscreenUI::DrawSettingsWindow()
static constexpr const char* global_icons[] = {ICON_FA_TV, ICON_PF_MICROCHIP, ICON_PF_GEARS_OPTIONS_SETTINGS, ICON_PF_PICTURE, static constexpr const char* global_icons[] = {ICON_FA_TV, ICON_PF_MICROCHIP, ICON_PF_GEARS_OPTIONS_SETTINGS, ICON_PF_PICTURE,
ICON_PF_SOUND, ICON_PF_MEMORY_CARD, ICON_PF_GAMEPAD_ALT, ICON_PF_KEYBOARD_ALT, ICON_FA_TROPHY, ICON_FA_FOLDER_OPEN, ICON_FA_EXCLAMATION_TRIANGLE}; ICON_PF_SOUND, ICON_PF_MEMORY_CARD, ICON_PF_GAMEPAD_ALT, ICON_PF_KEYBOARD_ALT, ICON_FA_TROPHY, ICON_FA_FOLDER_OPEN, ICON_FA_EXCLAMATION_TRIANGLE};
static constexpr const char* per_game_icons[] = {ICON_FA_INFO, ICON_PF_GEARS_OPTIONS_SETTINGS, ICON_FA_BAND_AID, ICON_PF_INFINITY, static constexpr const char* per_game_icons[] = {ICON_FA_INFO, ICON_PF_GEARS_OPTIONS_SETTINGS, ICON_FA_BAND_AID, ICON_PF_INFINITY,
ICON_PF_PICTURE, ICON_PF_SOUND, ICON_PF_MEMORY_CARD, ICON_PF_GAMEPAD_ALT, ICON_FA_EXCLAMATION_TRIANGLE}; ICON_PF_PICTURE, ICON_PF_SOUND, ICON_PF_MEMORY_CARD, ICON_FA_EXCLAMATION_TRIANGLE};
static constexpr SettingsPage global_pages[] = {SettingsPage::Interface, SettingsPage::BIOS, SettingsPage::Emulation, static constexpr SettingsPage global_pages[] = {SettingsPage::Interface, SettingsPage::BIOS, SettingsPage::Emulation,
SettingsPage::Graphics, SettingsPage::Audio, SettingsPage::MemoryCard, SettingsPage::Controller, SettingsPage::Hotkey, SettingsPage::Graphics, SettingsPage::Audio, SettingsPage::MemoryCard, SettingsPage::Controller, SettingsPage::Hotkey,
SettingsPage::Achievements, SettingsPage::Folders, SettingsPage::Advanced}; SettingsPage::Achievements, SettingsPage::Folders, SettingsPage::Advanced};
static constexpr SettingsPage per_game_pages[] = {SettingsPage::Summary, SettingsPage::Emulation, SettingsPage::Patches, static constexpr SettingsPage per_game_pages[] = {SettingsPage::Summary, SettingsPage::Emulation, SettingsPage::Patches,
SettingsPage::Cheats, SettingsPage::Graphics, SettingsPage::Audio, SettingsPage::MemoryCard, SettingsPage::Controller, SettingsPage::Cheats, SettingsPage::Graphics, SettingsPage::Audio, SettingsPage::MemoryCard,
SettingsPage::GameFixes}; SettingsPage::GameFixes};
static constexpr const char* titles[] = {FSUI_NSTR("Summary"), FSUI_NSTR("Interface Settings"), FSUI_NSTR("BIOS Settings"), static constexpr const char* titles[] = {FSUI_NSTR("Summary"), FSUI_NSTR("Interface Settings"), FSUI_NSTR("BIOS Settings"),
FSUI_NSTR("Emulation Settings"), FSUI_NSTR("Graphics Settings"), FSUI_NSTR("Audio Settings"), FSUI_NSTR("Memory Card Settings"), FSUI_NSTR("Emulation Settings"), FSUI_NSTR("Graphics Settings"), FSUI_NSTR("Audio Settings"), FSUI_NSTR("Memory Card Settings"),
@ -3058,6 +3058,37 @@ void FullscreenUI::DrawSummarySettingsPage()
OpenFileSelector(FSUI_ICONSTR(ICON_FA_COMPACT_DISC, "Select Disc Path"), false, std::move(callback), GetDiscImageFilters()); OpenFileSelector(FSUI_ICONSTR(ICON_FA_COMPACT_DISC, "Select Disc Path"), false, std::move(callback), GetDiscImageFilters());
} }
} }
const std::optional<SmallString> value = bsi->GetOptionalSmallStringValue("EmuCore", "InputProfileName", "Shared");
if (MenuButtonWithValue(FSUI_ICONSTR_S(ICON_PF_GAMEPAD_ALT, "Input Profile", "input_profile"),
FSUI_CSTR("The selected input profile will be used for this game."),
value.has_value() ? value->c_str() : FSUI_CSTR("Shared"), true))
{
ImGuiFullscreen::ChoiceDialogOptions options;
std::vector<std::string> names;
options.emplace_back(fmt::format(FSUI_FSTR("Shared")), (value.has_value() && !value->empty() && value == "Shared") ? true : false);
names.emplace_back("Shared");
for (const std::string& name : Pad::GetInputProfileNames())
{
options.emplace_back(fmt::format(FSUI_FSTR(name)), (value.has_value() && !value->empty() && value == name) ? true : false);
names.push_back(std::move(name));
}
OpenChoiceDialog(FSUI_CSTR("Input Profile"), false, options,
[game_settings = IsEditingGameSettings(bsi), names = std::move(names)](s32 index, const std::string& title, bool checked) {
if (index < 0)
return;
auto lock = Host::GetSettingsLock();
SettingsInterface* bsi = GetEditingSettingsInterface(game_settings);
bsi->SetStringValue("EmuCore", "InputProfileName", names[index].c_str());
SetSettingsChanged(bsi);
CloseChoiceDialog();
});
}
} }
else else
{ {
@ -4235,45 +4266,11 @@ void FullscreenUI::DrawControllerSettingsPage()
MenuHeading(FSUI_CSTR("Configuration")); MenuHeading(FSUI_CSTR("Configuration"));
if (IsEditingGameSettings(bsi))
{
if (DrawToggleSetting(bsi, FSUI_ICONSTR(ICON_FA_COG, "Per-Game Configuration"),
FSUI_CSTR("Uses game-specific settings for controllers for this game."), "Pad", "UseGameSettingsForController", false,
IsEditingGameSettings(bsi), false))
{
// did we just enable per-game for the first time?
if (bsi->GetBoolValue("Pad", "UseGameSettingsForController", false) &&
!bsi->GetBoolValue("Pad", "GameSettingsInitialized", false))
{
bsi->SetBoolValue("Pad", "GameSettingsInitialized", true);
CopyGlobalControllerSettingsToGame();
}
}
}
if (IsEditingGameSettings(bsi) && !bsi->GetBoolValue("Pad", "UseGameSettingsForController", false))
{
// nothing to edit..
EndMenuButtons();
return;
}
if (IsEditingGameSettings(bsi))
{
if (MenuButton(
FSUI_ICONSTR(ICON_FA_COPY, "Copy Global Settings"), FSUI_CSTR("Copies the global controller configuration to this game.")))
{
CopyGlobalControllerSettingsToGame();
}
}
else
{
if (MenuButton(FSUI_ICONSTR(ICON_FA_DUMPSTER_FIRE, "Reset Settings"), if (MenuButton(FSUI_ICONSTR(ICON_FA_DUMPSTER_FIRE, "Reset Settings"),
FSUI_CSTR("Resets all configuration to defaults (including bindings)."))) FSUI_CSTR("Resets all configuration to defaults (including bindings).")))
{ {
ResetControllerSettings(); ResetControllerSettings();
} }
}
if (MenuButton( if (MenuButton(
FSUI_ICONSTR(ICON_FA_FOLDER_OPEN, "Load Profile"), FSUI_CSTR("Replaces these settings with a previously saved input profile."))) FSUI_ICONSTR(ICON_FA_FOLDER_OPEN, "Load Profile"), FSUI_CSTR("Replaces these settings with a previously saved input profile.")))

View File

@ -660,11 +660,6 @@ void VMManager::LoadInputBindings(SettingsInterface& si, std::unique_lock<std::m
Host::Internal::SetInputSettingsLayer(s_input_settings_interface.get(), lock); Host::Internal::SetInputSettingsLayer(s_input_settings_interface.get(), lock);
} }
} }
else if (SettingsInterface* gsi = Host::Internal::GetGameSettingsLayer();
gsi && gsi->GetBoolValue("Pad", "UseGameSettingsForController", false))
{
InputManager::ReloadBindings(si, *gsi, si);
}
else else
{ {
InputManager::ReloadBindings(si, si, si); InputManager::ReloadBindings(si, si, si);