Merge pull request #11609 from AdmiralCurtiss/sd-size-select
Add SD card size option for converting folder -> file.
This commit is contained in:
commit
ca484c7a65
|
@ -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<bool()>& 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);
|
||||
|
|
|
@ -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<bool>& GetInfoForSimulateKonga(int channel)
|
|||
const Info<bool> MAIN_WII_SD_CARD{{System::Main, "Core", "WiiSDCard"}, true};
|
||||
const Info<bool> MAIN_WII_SD_CARD_ENABLE_FOLDER_SYNC{
|
||||
{System::Main, "Core", "WiiSDCardEnableFolderSync"}, false};
|
||||
const Info<u64> MAIN_WII_SD_CARD_FILESIZE{{System::Main, "Core", "WiiSDCardFilesize"}, 0};
|
||||
const Info<bool> MAIN_WII_KEYBOARD{{System::Main, "Core", "WiiKeyboard"}, false};
|
||||
const Info<bool> MAIN_WIIMOTE_CONTINUOUS_SCANNING{
|
||||
{System::Main, "Core", "WiimoteContinuousScanning"}, false};
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <utility>
|
||||
|
||||
#include "Common/Common.h"
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Common/Config/Config.h"
|
||||
#include "DiscIO/Enums.h"
|
||||
|
||||
|
@ -98,6 +99,7 @@ const Info<bool>& GetInfoForAdapterRumble(int channel);
|
|||
const Info<bool>& GetInfoForSimulateKonga(int channel);
|
||||
extern const Info<bool> MAIN_WII_SD_CARD;
|
||||
extern const Info<bool> MAIN_WII_SD_CARD_ENABLE_FOLDER_SYNC;
|
||||
extern const Info<u64> MAIN_WII_SD_CARD_FILESIZE;
|
||||
extern const Info<bool> MAIN_WII_KEYBOARD;
|
||||
extern const Info<bool> MAIN_WIIMOTE_CONTINUOUS_SCANNING;
|
||||
extern const Info<bool> MAIN_WIIMOTE_ENABLE_SPEAKER;
|
||||
|
|
|
@ -3,7 +3,9 @@
|
|||
|
||||
#include "DolphinQt/Settings/WiiPane.h"
|
||||
|
||||
#include <array>
|
||||
#include <future>
|
||||
#include <utility>
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QComboBox>
|
||||
|
@ -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<int>(&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<int>(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<size_t>(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()
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue