Skip to content

Commit

Permalink
RMG-Input: add 'Use Game I.D. Instead Of MD5 For Game Profiles' option
Browse files Browse the repository at this point in the history
  • Loading branch information
Rosalie241 committed May 8, 2024
1 parent cda5ff6 commit ce498b6
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 3 deletions.
2 changes: 2 additions & 0 deletions Source/RMG-Input/UserInterface/OptionsDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ OptionsDialog::OptionsDialog(QWidget* parent, OptionsDialogSettings settings,
this->removeDuplicateMappingsCheckbox->setChecked(settings.RemoveDuplicateMappings);
this->filterEventsForButtonsCheckBox->setChecked(settings.FilterEventsForButtons);
this->filterEventsForAxisCheckBox->setChecked(settings.FilterEventsForAxis);
this->useGameIDCheckBox->setChecked(settings.UseGameIDInsteadOfMD5);

if (!CoreIsEmulationRunning() && !CoreIsEmulationPaused())
{
Expand Down Expand Up @@ -85,6 +86,7 @@ void OptionsDialog::accept()
this->settings.RemoveDuplicateMappings = this->removeDuplicateMappingsCheckbox->isChecked();
this->settings.FilterEventsForButtons = this->filterEventsForButtonsCheckBox->isChecked();
this->settings.FilterEventsForAxis = this->filterEventsForAxisCheckBox->isChecked();
this->settings.UseGameIDInsteadOfMD5 = this->useGameIDCheckBox->isChecked();

QDialog::accept();
}
Expand Down
3 changes: 3 additions & 0 deletions Source/RMG-Input/UserInterface/OptionsDialog.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ struct OptionsDialogSettings
bool RemoveDuplicateMappings = false;
bool FilterEventsForButtons = true;
bool FilterEventsForAxis = true;

// Advanced settings
bool UseGameIDInsteadOfMD5 = false;
};

namespace UserInterface
Expand Down
27 changes: 27 additions & 0 deletions Source/RMG-Input/UserInterface/OptionsDialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,33 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="advancedTab">
<attribute name="title">
<string>Advanced</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<widget class="QCheckBox" name="useGameIDCheckBox">
<property name="text">
<string>Use Game I.D. Instead Of MD5 For Game Profiles</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_4">
<property name="orientation">
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>334</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
</item>
<item>
Expand Down
15 changes: 14 additions & 1 deletion Source/RMG-Input/UserInterface/Widget/ControllerWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1463,6 +1463,8 @@ void ControllerWidget::LoadSettings()
this->SaveDefaultSettings();
}

this->optionsDialogSettings.UseGameIDInsteadOfMD5 = CoreSettingsGetBoolValue(SettingsID::Input_UseGameID);

// try to retrieve the current rom's settings & header,
// if that succeeds, we know we're ingame
// and then we'll add a game specific profile to the combobox
Expand All @@ -1471,7 +1473,16 @@ void ControllerWidget::LoadSettings()
if (CoreGetCurrentRomSettings(romSettings) &&
CoreGetCurrentRomHeader(romHeader))
{
this->gameSection = section + " Game " + QString::fromStdString(romSettings.MD5);
this->gameSection = section + " Game ";
if (this->optionsDialogSettings.UseGameIDInsteadOfMD5 &&
romHeader.GameID != "????")
{ // GameID
section += QString::fromStdString(romHeader.GameID);
}
else
{ // MD5
section += QString::fromStdString(romSettings.MD5);
}

// use internal rom name
QString internalName = QString::fromStdString(romHeader.Name);
Expand Down Expand Up @@ -1792,6 +1803,8 @@ void ControllerWidget::SaveSettings(QString section)

this->GetCurrentInputDevice(deviceName, deviceNum, true);

CoreSettingsSetValue(SettingsID::Input_UseGameID, this->optionsDialogSettings.UseGameIDInsteadOfMD5);

CoreSettingsSetValue(SettingsID::Input_PluggedIn, sectionStr, this->IsPluggedIn());
CoreSettingsSetValue(SettingsID::Input_DeviceName, sectionStr, deviceName.toStdString());
CoreSettingsSetValue(SettingsID::Input_DeviceNum, sectionStr, deviceNum);
Expand Down
17 changes: 15 additions & 2 deletions Source/RMG-Input/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,16 +220,29 @@ static void load_inputmapping_settings(InputMapping* mapping, std::string sectio
static void load_settings(void)
{
std::string gameId;
CoreRomHeader romHeader;
CoreRomSettings romSettings;

std::string userProfileSectionBase = "Rosalie's Mupen GUI - Input Plugin User Profile";
std::vector<std::string> userProfiles;
std::vector<std::string>::iterator userProfilesIter;
bool useGameIDForGameProfiles = false;

useGameIDForGameProfiles = CoreSettingsGetBoolValue(SettingsID::Input_UseGameID);

// try to retrieve current ROM settings
if (CoreGetCurrentRomSettings(romSettings))
if (CoreGetCurrentRomHeader(romHeader) &&
CoreGetCurrentRomSettings(romSettings))
{
gameId = romSettings.MD5;
if (useGameIDForGameProfiles &&
romHeader.GameID != "????")
{ // GameID
gameId = romHeader.GameID;
}
else
{ // MD5
gameId = romSettings.MD5;
}
}

// retrieve all user profiles
Expand Down

0 comments on commit ce498b6

Please sign in to comment.