From d861b8caca1f4a8725ae72f936c492faf9c37502 Mon Sep 17 00:00:00 2001 From: "Admiral H. Curtiss" Date: Sun, 26 Feb 2023 22:45:55 +0100 Subject: [PATCH 1/2] Config: Add setting for SD card file size when converting. --- Source/Core/Common/FatFsUtil.cpp | 12 +++++++++--- Source/Core/Core/Config/MainSettings.cpp | 2 ++ Source/Core/Core/Config/MainSettings.h | 2 ++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Source/Core/Common/FatFsUtil.cpp b/Source/Core/Common/FatFsUtil.cpp index f194dc22a3..88d746e8ea 100644 --- a/Source/Core/Common/FatFsUtil.cpp +++ b/Source/Core/Common/FatFsUtil.cpp @@ -26,6 +26,8 @@ #include "Common/ScopeGuard.h" #include "Common/StringUtil.h" +#include "Core/Config/MainSettings.h" + enum : u32 { SECTOR_SIZE = 512, @@ -513,9 +515,13 @@ bool SyncSDFolderToSDImage(const std::function& cancelled, bool determin if (!CheckIfFATCompatible(root)) return false; - u64 size = GetSize(root); - // Allocate a reasonable amount of free space - size += std::clamp(size / 2, MebibytesToBytes(512), GibibytesToBytes(8)); + u64 size = Config::Get(Config::MAIN_WII_SD_CARD_FILESIZE); + if (size == 0) + { + size = GetSize(root); + // Allocate a reasonable amount of free space + size += std::clamp(size / 2, MebibytesToBytes(512), GibibytesToBytes(8)); + } size = AlignUp(size, MAX_CLUSTER_SIZE); std::lock_guard lk(s_fatfs_mutex); diff --git a/Source/Core/Core/Config/MainSettings.cpp b/Source/Core/Core/Config/MainSettings.cpp index 1a7c523d6e..7023ec411b 100644 --- a/Source/Core/Core/Config/MainSettings.cpp +++ b/Source/Core/Core/Config/MainSettings.cpp @@ -10,6 +10,7 @@ #include "AudioCommon/AudioCommon.h" #include "Common/Assert.h" #include "Common/CommonPaths.h" +#include "Common/CommonTypes.h" #include "Common/Config/Config.h" #include "Common/EnumMap.h" #include "Common/FileUtil.h" @@ -175,6 +176,7 @@ const Info& GetInfoForSimulateKonga(int channel) const Info MAIN_WII_SD_CARD{{System::Main, "Core", "WiiSDCard"}, true}; const Info MAIN_WII_SD_CARD_ENABLE_FOLDER_SYNC{ {System::Main, "Core", "WiiSDCardEnableFolderSync"}, false}; +const Info MAIN_WII_SD_CARD_FILESIZE{{System::Main, "Core", "WiiSDCardFilesize"}, 0}; const Info MAIN_WII_KEYBOARD{{System::Main, "Core", "WiiKeyboard"}, false}; const Info MAIN_WIIMOTE_CONTINUOUS_SCANNING{ {System::Main, "Core", "WiimoteContinuousScanning"}, false}; diff --git a/Source/Core/Core/Config/MainSettings.h b/Source/Core/Core/Config/MainSettings.h index 546696476f..dd8f1632f8 100644 --- a/Source/Core/Core/Config/MainSettings.h +++ b/Source/Core/Core/Config/MainSettings.h @@ -9,6 +9,7 @@ #include #include "Common/Common.h" +#include "Common/CommonTypes.h" #include "Common/Config/Config.h" #include "DiscIO/Enums.h" @@ -98,6 +99,7 @@ const Info& GetInfoForAdapterRumble(int channel); const Info& GetInfoForSimulateKonga(int channel); extern const Info MAIN_WII_SD_CARD; extern const Info MAIN_WII_SD_CARD_ENABLE_FOLDER_SYNC; +extern const Info MAIN_WII_SD_CARD_FILESIZE; extern const Info MAIN_WII_KEYBOARD; extern const Info MAIN_WIIMOTE_CONTINUOUS_SCANNING; extern const Info MAIN_WIIMOTE_ENABLE_SPEAKER; From 9600bf1af98c090329d13c7193ff43cab5143f76 Mon Sep 17 00:00:00 2001 From: "Admiral H. Curtiss" Date: Sun, 26 Feb 2023 22:46:05 +0100 Subject: [PATCH 2/2] Qt/WiiPane: Add setting for SD card file size when converting. --- Source/Core/DolphinQt/Settings/WiiPane.cpp | 56 ++++++++++++++++++++++ Source/Core/DolphinQt/Settings/WiiPane.h | 1 + 2 files changed, 57 insertions(+) diff --git a/Source/Core/DolphinQt/Settings/WiiPane.cpp b/Source/Core/DolphinQt/Settings/WiiPane.cpp index 40674ece3a..959a4aa1fc 100644 --- a/Source/Core/DolphinQt/Settings/WiiPane.cpp +++ b/Source/Core/DolphinQt/Settings/WiiPane.cpp @@ -3,7 +3,9 @@ #include "DolphinQt/Settings/WiiPane.h" +#include #include +#include #include #include @@ -53,6 +55,36 @@ static int TranslateSensorBarPosition(int position) return position; } +namespace +{ +struct SDSizeComboEntry +{ + u64 size; + const char* name; +}; +static constexpr u64 MebibytesToBytes(u64 mebibytes) +{ + return mebibytes * 1024u * 1024u; +} +static constexpr u64 GibibytesToBytes(u64 gibibytes) +{ + return MebibytesToBytes(gibibytes * 1024u); +} +constexpr std::array sd_size_combo_entries{ + SDSizeComboEntry{0, _trans("Auto")}, + SDSizeComboEntry{MebibytesToBytes(64), _trans("64 MiB")}, + SDSizeComboEntry{MebibytesToBytes(128), _trans("128 MiB")}, + SDSizeComboEntry{MebibytesToBytes(256), _trans("256 MiB")}, + SDSizeComboEntry{MebibytesToBytes(512), _trans("512 MiB")}, + SDSizeComboEntry{GibibytesToBytes(1), _trans("1 GiB")}, + SDSizeComboEntry{GibibytesToBytes(2), _trans("2 GiB")}, + SDSizeComboEntry{GibibytesToBytes(4), _trans("4 GiB (SDHC)")}, + SDSizeComboEntry{GibibytesToBytes(8), _trans("8 GiB (SDHC)")}, + SDSizeComboEntry{GibibytesToBytes(16), _trans("16 GiB (SDHC)")}, + SDSizeComboEntry{GibibytesToBytes(32), _trans("32 GiB (SDHC)")}, +}; +} // namespace + WiiPane::WiiPane(QWidget* parent) : QWidget(parent) { CreateLayout(); @@ -94,6 +126,8 @@ void WiiPane::ConnectLayout() connect(m_sd_card_checkbox, &QCheckBox::toggled, this, &WiiPane::OnSaveConfig); connect(m_allow_sd_writes_checkbox, &QCheckBox::toggled, this, &WiiPane::OnSaveConfig); connect(m_sync_sd_folder_checkbox, &QCheckBox::toggled, this, &WiiPane::OnSaveConfig); + connect(m_sd_card_size_combo, qOverload(&QComboBox::currentIndexChanged), this, + &WiiPane::OnSaveConfig); // Whitelisted USB Passthrough Devices connect(m_whitelist_usb_list, &QListWidget::itemClicked, this, &WiiPane::ValidateSelectionState); @@ -219,6 +253,13 @@ void WiiPane::CreateSDCard() ++row; } + m_sd_card_size_combo = new QComboBox(); + for (size_t i = 0; i < sd_size_combo_entries.size(); ++i) + m_sd_card_size_combo->addItem(tr(sd_size_combo_entries[i].name)); + sd_settings_group_layout->addWidget(new QLabel(tr("SD Card File Size:")), row, 0); + sd_settings_group_layout->addWidget(m_sd_card_size_combo, row, 1); + ++row; + m_sd_pack_button = new NonDefaultQPushButton(tr("Convert Folder to File Now")); m_sd_unpack_button = new NonDefaultQPushButton(tr("Convert File to Folder Now")); connect(m_sd_pack_button, &QPushButton::clicked, [this] { @@ -360,6 +401,13 @@ void WiiPane::LoadConfig() m_allow_sd_writes_checkbox->setChecked(Config::Get(Config::MAIN_ALLOW_SD_WRITES)); m_sync_sd_folder_checkbox->setChecked(Config::Get(Config::MAIN_WII_SD_CARD_ENABLE_FOLDER_SYNC)); + const u64 sd_card_size = Config::Get(Config::MAIN_WII_SD_CARD_FILESIZE); + for (size_t i = 0; i < sd_size_combo_entries.size(); ++i) + { + if (sd_size_combo_entries[i].size == sd_card_size) + m_sd_card_size_combo->setCurrentIndex(static_cast(i)); + } + PopulateUSBPassthroughListWidget(); m_wiimote_ir_sensor_position->setCurrentIndex( @@ -390,6 +438,14 @@ void WiiPane::OnSaveConfig() Config::SetBase(Config::MAIN_ALLOW_SD_WRITES, m_allow_sd_writes_checkbox->isChecked()); Config::SetBase(Config::MAIN_WII_SD_CARD_ENABLE_FOLDER_SYNC, m_sync_sd_folder_checkbox->isChecked()); + + const int sd_card_size_index = m_sd_card_size_combo->currentIndex(); + if (sd_card_size_index >= 0 && + static_cast(sd_card_size_index) < sd_size_combo_entries.size()) + { + Config::SetBase(Config::MAIN_WII_SD_CARD_FILESIZE, + sd_size_combo_entries[sd_card_size_index].size); + } } void WiiPane::ValidateSelectionState() diff --git a/Source/Core/DolphinQt/Settings/WiiPane.h b/Source/Core/DolphinQt/Settings/WiiPane.h index dbceeed907..6f4b3fe8de 100644 --- a/Source/Core/DolphinQt/Settings/WiiPane.h +++ b/Source/Core/DolphinQt/Settings/WiiPane.h @@ -62,6 +62,7 @@ private: QCheckBox* m_sd_card_checkbox; QCheckBox* m_allow_sd_writes_checkbox; QCheckBox* m_sync_sd_folder_checkbox; + QComboBox* m_sd_card_size_combo; QLineEdit* m_sd_raw_edit; QLineEdit* m_sd_sync_folder_edit; QPushButton* m_sd_pack_button;