diff options
-rw-r--r-- | CMakeLists.txt | 8 | ||||
-rw-r--r-- | src/common/file_util.h | 2 | ||||
-rw-r--r-- | src/common/string_util.cpp | 134 | ||||
-rw-r--r-- | src/common/string_util.h | 21 | ||||
-rw-r--r-- | src/core/file_sys/card_image.cpp | 4 | ||||
-rw-r--r-- | src/core/file_sys/submission_package.cpp | 169 | ||||
-rw-r--r-- | src/core/file_sys/submission_package.h | 5 | ||||
-rw-r--r-- | src/core/hle/service/filesystem/fsp_srv.cpp | 2 | ||||
-rw-r--r-- | src/core/hle/service/lbl/lbl.cpp | 38 | ||||
-rw-r--r-- | src/yuzu/configuration/configure_audio.cpp | 47 | ||||
-rw-r--r-- | src/yuzu/configuration/configure_audio.h | 3 | ||||
-rw-r--r-- | src/yuzu/configuration/configure_graphics.cpp | 44 | ||||
-rw-r--r-- | src/yuzu/configuration/configure_input.cpp | 6 |
13 files changed, 192 insertions, 291 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index cd990188e..92c3e855c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -344,14 +344,6 @@ ELSEIF (CMAKE_SYSTEM_NAME MATCHES "^(Linux|kFreeBSD|GNU|SunOS)$") set(PLATFORM_LIBRARIES rt) ENDIF (APPLE) -# MINGW: GCC does not support codecvt, so use iconv instead -if (UNIX OR MINGW) - find_library(ICONV_LIBRARY NAMES iconv) - if (ICONV_LIBRARY) - list(APPEND PLATFORM_LIBRARIES ${ICONV_LIBRARY}) - endif() -endif() - # Setup a custom clang-format target (if clang-format can be found) that will run # against all the src files. This should be used before making a pull request. # ======================================================================= diff --git a/src/common/file_util.h b/src/common/file_util.h index 3d8fe6264..571503d2a 100644 --- a/src/common/file_util.h +++ b/src/common/file_util.h @@ -285,7 +285,7 @@ private: template <typename T> void OpenFStream(T& fstream, const std::string& filename, std::ios_base::openmode openmode) { #ifdef _MSC_VER - fstream.open(Common::UTF8ToTStr(filename).c_str(), openmode); + fstream.open(Common::UTF8ToUTF16W(filename).c_str(), openmode); #else fstream.open(filename.c_str(), openmode); #endif diff --git a/src/common/string_util.cpp b/src/common/string_util.cpp index c9a5425a7..731d1db34 100644 --- a/src/common/string_util.cpp +++ b/src/common/string_util.cpp @@ -5,6 +5,7 @@ #include <algorithm> #include <cctype> #include <cerrno> +#include <codecvt> #include <cstdio> #include <cstdlib> #include <cstring> @@ -13,11 +14,7 @@ #include "common/string_util.h" #ifdef _WIN32 -#include <codecvt> #include <windows.h> -#include "common/common_funcs.h" -#else -#include <iconv.h> #endif namespace Common { @@ -195,11 +192,9 @@ std::string ReplaceAll(std::string result, const std::string& src, const std::st return result; } -#ifdef _WIN32 - std::string UTF16ToUTF8(const std::u16string& input) { -#if _MSC_VER >= 1900 - // Workaround for missing char16_t/char32_t instantiations in MSVC2015 +#ifdef _MSC_VER + // Workaround for missing char16_t/char32_t instantiations in MSVC2017 std::wstring_convert<std::codecvt_utf8_utf16<__int16>, __int16> convert; std::basic_string<__int16> tmp_buffer(input.cbegin(), input.cend()); return convert.to_bytes(tmp_buffer); @@ -210,8 +205,8 @@ std::string UTF16ToUTF8(const std::u16string& input) { } std::u16string UTF8ToUTF16(const std::string& input) { -#if _MSC_VER >= 1900 - // Workaround for missing char16_t/char32_t instantiations in MSVC2015 +#ifdef _MSC_VER + // Workaround for missing char16_t/char32_t instantiations in MSVC2017 std::wstring_convert<std::codecvt_utf8_utf16<__int16>, __int16> convert; auto tmp_buffer = convert.from_bytes(input); return std::u16string(tmp_buffer.cbegin(), tmp_buffer.cend()); @@ -221,6 +216,7 @@ std::u16string UTF8ToUTF16(const std::string& input) { #endif } +#ifdef _WIN32 static std::wstring CPToUTF16(u32 code_page, const std::string& input) { const auto size = MultiByteToWideChar(code_page, 0, input.data(), static_cast<int>(input.size()), nullptr, 0); @@ -261,124 +257,6 @@ std::wstring UTF8ToUTF16W(const std::string& input) { return CPToUTF16(CP_UTF8, input); } -std::string SHIFTJISToUTF8(const std::string& input) { - return UTF16ToUTF8(CPToUTF16(932, input)); -} - -std::string CP1252ToUTF8(const std::string& input) { - return UTF16ToUTF8(CPToUTF16(1252, input)); -} - -#else - -template <typename T> -static std::string CodeToUTF8(const char* fromcode, const std::basic_string<T>& input) { - iconv_t const conv_desc = iconv_open("UTF-8", fromcode); - if ((iconv_t)(-1) == conv_desc) { - LOG_ERROR(Common, "Iconv initialization failure [{}]: {}", fromcode, strerror(errno)); - iconv_close(conv_desc); - return {}; - } - - const std::size_t in_bytes = sizeof(T) * input.size(); - // Multiply by 4, which is the max number of bytes to encode a codepoint - const std::size_t out_buffer_size = 4 * in_bytes; - - std::string out_buffer(out_buffer_size, '\0'); - - auto src_buffer = &input[0]; - std::size_t src_bytes = in_bytes; - auto dst_buffer = &out_buffer[0]; - std::size_t dst_bytes = out_buffer.size(); - - while (0 != src_bytes) { - std::size_t const iconv_result = - iconv(conv_desc, (char**)(&src_buffer), &src_bytes, &dst_buffer, &dst_bytes); - - if (static_cast<std::size_t>(-1) == iconv_result) { - if (EILSEQ == errno || EINVAL == errno) { - // Try to skip the bad character - if (0 != src_bytes) { - --src_bytes; - ++src_buffer; - } - } else { - LOG_ERROR(Common, "iconv failure [{}]: {}", fromcode, strerror(errno)); - break; - } - } - } - - std::string result; - out_buffer.resize(out_buffer_size - dst_bytes); - out_buffer.swap(result); - - iconv_close(conv_desc); - - return result; -} - -std::u16string UTF8ToUTF16(const std::string& input) { - iconv_t const conv_desc = iconv_open("UTF-16LE", "UTF-8"); - if ((iconv_t)(-1) == conv_desc) { - LOG_ERROR(Common, "Iconv initialization failure [UTF-8]: {}", strerror(errno)); - iconv_close(conv_desc); - return {}; - } - - const std::size_t in_bytes = sizeof(char) * input.size(); - // Multiply by 4, which is the max number of bytes to encode a codepoint - const std::size_t out_buffer_size = 4 * sizeof(char16_t) * in_bytes; - - std::u16string out_buffer(out_buffer_size, char16_t{}); - - char* src_buffer = const_cast<char*>(&input[0]); - std::size_t src_bytes = in_bytes; - char* dst_buffer = (char*)(&out_buffer[0]); - std::size_t dst_bytes = out_buffer.size(); - - while (0 != src_bytes) { - std::size_t const iconv_result = - iconv(conv_desc, &src_buffer, &src_bytes, &dst_buffer, &dst_bytes); - - if (static_cast<std::size_t>(-1) == iconv_result) { - if (EILSEQ == errno || EINVAL == errno) { - // Try to skip the bad character - if (0 != src_bytes) { - --src_bytes; - ++src_buffer; - } - } else { - LOG_ERROR(Common, "iconv failure [UTF-8]: {}", strerror(errno)); - break; - } - } - } - - std::u16string result; - out_buffer.resize(out_buffer_size - dst_bytes); - out_buffer.swap(result); - - iconv_close(conv_desc); - - return result; -} - -std::string UTF16ToUTF8(const std::u16string& input) { - return CodeToUTF8("UTF-16LE", input); -} - -std::string CP1252ToUTF8(const std::string& input) { - // return CodeToUTF8("CP1252//TRANSLIT", input); - // return CodeToUTF8("CP1252//IGNORE", input); - return CodeToUTF8("CP1252", input); -} - -std::string SHIFTJISToUTF8(const std::string& input) { - // return CodeToUTF8("CP932", input); - return CodeToUTF8("SJIS", input); -} - #endif std::string StringFromFixedZeroTerminatedBuffer(const char* buffer, std::size_t max_len) { diff --git a/src/common/string_util.h b/src/common/string_util.h index dcca6bc38..32bf6a19c 100644 --- a/src/common/string_util.h +++ b/src/common/string_util.h @@ -72,31 +72,10 @@ std::string ReplaceAll(std::string result, const std::string& src, const std::st std::string UTF16ToUTF8(const std::u16string& input); std::u16string UTF8ToUTF16(const std::string& input); -std::string CP1252ToUTF8(const std::string& str); -std::string SHIFTJISToUTF8(const std::string& str); - #ifdef _WIN32 std::string UTF16ToUTF8(const std::wstring& input); std::wstring UTF8ToUTF16W(const std::string& str); -#ifdef _UNICODE -inline std::string TStrToUTF8(const std::wstring& str) { - return UTF16ToUTF8(str); -} - -inline std::wstring UTF8ToTStr(const std::string& str) { - return UTF8ToUTF16W(str); -} -#else -inline std::string TStrToUTF8(const std::string& str) { - return str; -} - -inline std::string UTF8ToTStr(const std::string& str) { - return str; -} -#endif - #endif /** diff --git a/src/core/file_sys/card_image.cpp b/src/core/file_sys/card_image.cpp index edfc1bbd4..8f5142a07 100644 --- a/src/core/file_sys/card_image.cpp +++ b/src/core/file_sys/card_image.cpp @@ -20,7 +20,9 @@ namespace FileSys { constexpr std::array<const char*, 0x4> partition_names = {"update", "normal", "secure", "logo"}; -XCI::XCI(VirtualFile file_) : file(std::move(file_)), partitions(0x4) { +XCI::XCI(VirtualFile file_) + : file(std::move(file_)), program_nca_status{Loader::ResultStatus::ErrorXCIMissingProgramNCA}, + partitions(0x4) { if (file->ReadObject(&header) != sizeof(GamecardHeader)) { status = Loader::ResultStatus::ErrorBadXCIHeader; return; diff --git a/src/core/file_sys/submission_package.cpp b/src/core/file_sys/submission_package.cpp index 11264878d..09bf077cd 100644 --- a/src/core/file_sys/submission_package.cpp +++ b/src/core/file_sys/submission_package.cpp @@ -18,6 +18,39 @@ #include "core/loader/loader.h" namespace FileSys { +namespace { +void SetTicketKeys(const std::vector<VirtualFile>& files) { + Core::Crypto::KeyManager keys; + + for (const auto& ticket_file : files) { + if (ticket_file == nullptr) { + continue; + } + + if (ticket_file->GetExtension() != "tik") { + continue; + } + + if (ticket_file->GetSize() < + Core::Crypto::TICKET_FILE_TITLEKEY_OFFSET + sizeof(Core::Crypto::Key128)) { + continue; + } + + Core::Crypto::Key128 key{}; + ticket_file->Read(key.data(), key.size(), Core::Crypto::TICKET_FILE_TITLEKEY_OFFSET); + + // We get the name without the extension in order to create the rights ID. + std::string name_only(ticket_file->GetName()); + name_only.erase(name_only.size() - 4); + + const auto rights_id_raw = Common::HexStringToArray<16>(name_only); + u128 rights_id; + std::memcpy(rights_id.data(), rights_id_raw.data(), sizeof(u128)); + keys.SetKey(Core::Crypto::S128KeyType::Titlekey, key, rights_id[1], rights_id[0]); + } +} +} // Anonymous namespace + NSP::NSP(VirtualFile file_) : file(std::move(file_)), status{Loader::ResultStatus::Success}, pfs(std::make_shared<PartitionFilesystem>(file)) { @@ -26,83 +59,16 @@ NSP::NSP(VirtualFile file_) return; } + const auto files = pfs->GetFiles(); + if (IsDirectoryExeFS(pfs)) { extracted = true; - exefs = pfs; - - const auto& files = pfs->GetFiles(); - const auto romfs_iter = - std::find_if(files.begin(), files.end(), [](const FileSys::VirtualFile& file) { - return file->GetName().find(".romfs") != std::string::npos; - }); - if (romfs_iter != files.end()) - romfs = *romfs_iter; + InitializeExeFSAndRomFS(files); return; } - extracted = false; - const auto files = pfs->GetFiles(); - - Core::Crypto::KeyManager keys; - for (const auto& ticket_file : files) { - if (ticket_file->GetExtension() == "tik") { - if (ticket_file == nullptr || - ticket_file->GetSize() < - Core::Crypto::TICKET_FILE_TITLEKEY_OFFSET + sizeof(Core::Crypto::Key128)) { - continue; - } - - Core::Crypto::Key128 key{}; - ticket_file->Read(key.data(), key.size(), Core::Crypto::TICKET_FILE_TITLEKEY_OFFSET); - std::string_view name_only(ticket_file->GetName()); - name_only.remove_suffix(4); - const auto rights_id_raw = Common::HexStringToArray<16>(name_only); - u128 rights_id; - std::memcpy(rights_id.data(), rights_id_raw.data(), sizeof(u128)); - keys.SetKey(Core::Crypto::S128KeyType::Titlekey, key, rights_id[1], rights_id[0]); - } - } - - for (const auto& outer_file : files) { - if (outer_file->GetName().substr(outer_file->GetName().size() - 9) == ".cnmt.nca") { - const auto nca = std::make_shared<NCA>(outer_file); - if (nca->GetStatus() != Loader::ResultStatus::Success) { - program_status[nca->GetTitleId()] = nca->GetStatus(); - continue; - } - - const auto section0 = nca->GetSubdirectories()[0]; - - for (const auto& inner_file : section0->GetFiles()) { - if (inner_file->GetExtension() != "cnmt") - continue; - - const CNMT cnmt(inner_file); - auto& ncas_title = ncas[cnmt.GetTitleID()]; - - ncas_title[ContentRecordType::Meta] = nca; - for (const auto& rec : cnmt.GetContentRecords()) { - const auto id_string = Common::HexArrayToString(rec.nca_id, false); - const auto next_file = pfs->GetFile(fmt::format("{}.nca", id_string)); - if (next_file == nullptr) { - LOG_WARNING(Service_FS, - "NCA with ID {}.nca is listed in content metadata, but cannot " - "be found in PFS. NSP appears to be corrupted.", - id_string); - continue; - } - - auto next_nca = std::make_shared<NCA>(next_file); - if (next_nca->GetType() == NCAContentType::Program) - program_status[cnmt.GetTitleID()] = next_nca->GetStatus(); - if (next_nca->GetStatus() == Loader::ResultStatus::Success) - ncas_title[rec.type] = std::move(next_nca); - } - - break; - } - } - } + SetTicketKeys(files); + ReadNCAs(files); } NSP::~NSP() = default; @@ -242,4 +208,63 @@ VirtualDir NSP::GetParentDirectory() const { bool NSP::ReplaceFileWithSubdirectory(VirtualFile file, VirtualDir dir) { return false; } + +void NSP::InitializeExeFSAndRomFS(const std::vector<VirtualFile>& files) { + exefs = pfs; + + const auto romfs_iter = std::find_if(files.begin(), files.end(), [](const VirtualFile& file) { + return file->GetName().rfind(".romfs") != std::string::npos; + }); + + if (romfs_iter == files.end()) { + return; + } + + romfs = *romfs_iter; +} + +void NSP::ReadNCAs(const std::vector<VirtualFile>& files) { + for (const auto& outer_file : files) { + if (outer_file->GetName().substr(outer_file->GetName().size() - 9) != ".cnmt.nca") { + continue; + } + + const auto nca = std::make_shared<NCA>(outer_file); + if (nca->GetStatus() != Loader::ResultStatus::Success) { + program_status[nca->GetTitleId()] = nca->GetStatus(); + continue; + } + + const auto section0 = nca->GetSubdirectories()[0]; + + for (const auto& inner_file : section0->GetFiles()) { + if (inner_file->GetExtension() != "cnmt") + continue; + + const CNMT cnmt(inner_file); + auto& ncas_title = ncas[cnmt.GetTitleID()]; + + ncas_title[ContentRecordType::Meta] = nca; + for (const auto& rec : cnmt.GetContentRecords()) { + const auto id_string = Common::HexArrayToString(rec.nca_id, false); + const auto next_file = pfs->GetFile(fmt::format("{}.nca", id_string)); + if (next_file == nullptr) { + LOG_WARNING(Service_FS, + "NCA with ID {}.nca is listed in content metadata, but cannot " + "be found in PFS. NSP appears to be corrupted.", + id_string); + continue; + } + + auto next_nca = std::make_shared<NCA>(next_file); + if (next_nca->GetType() == NCAContentType::Program) + program_status[cnmt.GetTitleID()] = next_nca->GetStatus(); + if (next_nca->GetStatus() == Loader::ResultStatus::Success) + ncas_title[rec.type] = std::move(next_nca); + } + + break; + } + } +} } // namespace FileSys diff --git a/src/core/file_sys/submission_package.h b/src/core/file_sys/submission_package.h index e85a2b76e..da3dc5e9f 100644 --- a/src/core/file_sys/submission_package.h +++ b/src/core/file_sys/submission_package.h @@ -59,9 +59,12 @@ protected: bool ReplaceFileWithSubdirectory(VirtualFile file, VirtualDir dir) override; private: + void InitializeExeFSAndRomFS(const std::vector<VirtualFile>& files); + void ReadNCAs(const std::vector<VirtualFile>& files); + VirtualFile file; - bool extracted; + bool extracted = false; Loader::ResultStatus status; std::map<u64, Loader::ResultStatus> program_status; diff --git a/src/core/hle/service/filesystem/fsp_srv.cpp b/src/core/hle/service/filesystem/fsp_srv.cpp index cabaf5a55..d5dced429 100644 --- a/src/core/hle/service/filesystem/fsp_srv.cpp +++ b/src/core/hle/service/filesystem/fsp_srv.cpp @@ -468,6 +468,7 @@ FSP_SRV::FSP_SRV() : ServiceFramework("fsp-srv") { {80, nullptr, "OpenSaveDataMetaFile"}, {81, nullptr, "OpenSaveDataTransferManager"}, {82, nullptr, "OpenSaveDataTransferManagerVersion2"}, + {83, nullptr, "OpenSaveDataTransferProhibiterForCloudBackUp"}, {100, nullptr, "OpenImageDirectoryFileSystem"}, {110, nullptr, "OpenContentStorageFileSystem"}, {200, &FSP_SRV::OpenDataStorageByCurrentProcess, "OpenDataStorageByCurrentProcess"}, @@ -495,6 +496,7 @@ FSP_SRV::FSP_SRV() : ServiceFramework("fsp-srv") { {613, nullptr, "VerifySaveDataFileSystemBySaveDataSpaceId"}, {614, nullptr, "CorruptSaveDataFileSystemBySaveDataSpaceId"}, {615, nullptr, "QuerySaveDataInternalStorageTotalSize"}, + {616, nullptr, "GetSaveDataCommitId"}, {620, nullptr, "SetSdCardEncryptionSeed"}, {630, nullptr, "SetSdCardAccessibility"}, {631, nullptr, "IsSdCardAccessible"}, diff --git a/src/core/hle/service/lbl/lbl.cpp b/src/core/hle/service/lbl/lbl.cpp index 8fc8b1057..7321584e1 100644 --- a/src/core/hle/service/lbl/lbl.cpp +++ b/src/core/hle/service/lbl/lbl.cpp @@ -21,29 +21,29 @@ public: {0, nullptr, "Unknown1"}, {1, nullptr, "Unknown2"}, {2, nullptr, "Unknown3"}, - {3, nullptr, "Unknown4"}, - {4, nullptr, "Unknown5"}, - {5, nullptr, "Unknown6"}, + {3, nullptr, "GetCurrentBacklightLevel"}, + {4, nullptr, "Unknown4"}, + {5, nullptr, "GetAlsComputedBacklightLevel"}, {6, nullptr, "TurnOffBacklight"}, {7, nullptr, "TurnOnBacklight"}, {8, nullptr, "GetBacklightStatus"}, - {9, nullptr, "Unknown7"}, - {10, nullptr, "Unknown8"}, - {11, nullptr, "Unknown9"}, - {12, nullptr, "Unknown10"}, - {13, nullptr, "Unknown11"}, - {14, nullptr, "Unknown12"}, - {15, nullptr, "Unknown13"}, + {9, nullptr, "Unknown5"}, + {10, nullptr, "Unknown6"}, + {11, nullptr, "Unknown7"}, + {12, nullptr, "Unknown8"}, + {13, nullptr, "Unknown9"}, + {14, nullptr, "Unknown10"}, + {15, nullptr, "GetAutoBrightnessSetting"}, {16, nullptr, "ReadRawLightSensor"}, - {17, nullptr, "Unknown14"}, - {18, nullptr, "Unknown15"}, - {19, nullptr, "Unknown16"}, - {20, nullptr, "Unknown17"}, - {21, nullptr, "Unknown18"}, - {22, nullptr, "Unknown19"}, - {23, nullptr, "Unknown20"}, - {24, nullptr, "Unknown21"}, - {25, nullptr, "Unknown22"}, + {17, nullptr, "Unknown11"}, + {18, nullptr, "Unknown12"}, + {19, nullptr, "Unknown13"}, + {20, nullptr, "Unknown14"}, + {21, nullptr, "Unknown15"}, + {22, nullptr, "Unknown16"}, + {23, nullptr, "Unknown17"}, + {24, nullptr, "Unknown18"}, + {25, nullptr, "Unknown19"}, {26, &LBL::EnableVrMode, "EnableVrMode"}, {27, &LBL::DisableVrMode, "DisableVrMode"}, {28, &LBL::GetVrMode, "GetVrMode"}, diff --git a/src/yuzu/configuration/configure_audio.cpp b/src/yuzu/configuration/configure_audio.cpp index 6ea59f2a3..eb1da0f9e 100644 --- a/src/yuzu/configuration/configure_audio.cpp +++ b/src/yuzu/configuration/configure_audio.cpp @@ -21,9 +21,8 @@ ConfigureAudio::ConfigureAudio(QWidget* parent) ui->output_sink_combo_box->addItem(sink_detail.id); } - connect(ui->volume_slider, &QSlider::valueChanged, [this] { - ui->volume_indicator->setText(tr("%1 %").arg(ui->volume_slider->sliderPosition())); - }); + connect(ui->volume_slider, &QSlider::valueChanged, this, + &ConfigureAudio::setVolumeIndicatorText); this->setConfiguration(); connect(ui->output_sink_combo_box, @@ -37,32 +36,48 @@ ConfigureAudio::ConfigureAudio(QWidget* parent) ConfigureAudio::~ConfigureAudio() = default; void ConfigureAudio::setConfiguration() { + setOutputSinkFromSinkID(); + + // The device list cannot be pre-populated (nor listed) until the output sink is known. + updateAudioDevices(ui->output_sink_combo_box->currentIndex()); + + setAudioDeviceFromDeviceID(); + + ui->toggle_audio_stretching->setChecked(Settings::values.enable_audio_stretching); + ui->volume_slider->setValue(Settings::values.volume * ui->volume_slider->maximum()); + setVolumeIndicatorText(ui->volume_slider->sliderPosition()); +} + +void ConfigureAudio::setOutputSinkFromSinkID() { int new_sink_index = 0; + + const QString sink_id = QString::fromStdString(Settings::values.sink_id); for (int index = 0; index < ui->output_sink_combo_box->count(); index++) { - if (ui->output_sink_combo_box->itemText(index).toStdString() == Settings::values.sink_id) { + if (ui->output_sink_combo_box->itemText(index) == sink_id) { new_sink_index = index; break; } } - ui->output_sink_combo_box->setCurrentIndex(new_sink_index); - ui->toggle_audio_stretching->setChecked(Settings::values.enable_audio_stretching); - - // The device list cannot be pre-populated (nor listed) until the output sink is known. - updateAudioDevices(new_sink_index); + ui->output_sink_combo_box->setCurrentIndex(new_sink_index); +} +void ConfigureAudio::setAudioDeviceFromDeviceID() { int new_device_index = -1; + + const QString device_id = QString::fromStdString(Settings::values.audio_device_id); for (int index = 0; index < ui->audio_device_combo_box->count(); index++) { - if (ui->audio_device_combo_box->itemText(index).toStdString() == - Settings::values.audio_device_id) { + if (ui->audio_device_combo_box->itemText(index) == device_id) { new_device_index = index; break; } } + ui->audio_device_combo_box->setCurrentIndex(new_device_index); +} - ui->volume_slider->setValue(Settings::values.volume * ui->volume_slider->maximum()); - ui->volume_indicator->setText(tr("%1 %").arg(ui->volume_slider->sliderPosition())); +void ConfigureAudio::setVolumeIndicatorText(int percentage) { + ui->volume_indicator->setText(tr("%1%", "Volume percentage (e.g. 50%)").arg(percentage)); } void ConfigureAudio::applyConfiguration() { @@ -81,10 +96,10 @@ void ConfigureAudio::updateAudioDevices(int sink_index) { ui->audio_device_combo_box->clear(); ui->audio_device_combo_box->addItem(AudioCore::auto_device_name); - std::string sink_id = ui->output_sink_combo_box->itemText(sink_index).toStdString(); - std::vector<std::string> device_list = AudioCore::GetSinkDetails(sink_id).list_devices(); + const std::string sink_id = ui->output_sink_combo_box->itemText(sink_index).toStdString(); + const std::vector<std::string> device_list = AudioCore::GetSinkDetails(sink_id).list_devices(); for (const auto& device : device_list) { - ui->audio_device_combo_box->addItem(device.c_str()); + ui->audio_device_combo_box->addItem(QString::fromStdString(device)); } } diff --git a/src/yuzu/configuration/configure_audio.h b/src/yuzu/configuration/configure_audio.h index 4f0af4163..207f9dfb3 100644 --- a/src/yuzu/configuration/configure_audio.h +++ b/src/yuzu/configuration/configure_audio.h @@ -26,6 +26,9 @@ public slots: private: void setConfiguration(); + void setOutputSinkFromSinkID(); + void setAudioDeviceFromDeviceID(); + void setVolumeIndicatorText(int percentage); std::unique_ptr<Ui::ConfigureAudio> ui; }; diff --git a/src/yuzu/configuration/configure_graphics.cpp b/src/yuzu/configuration/configure_graphics.cpp index 839d58f59..cd1549462 100644 --- a/src/yuzu/configuration/configure_graphics.cpp +++ b/src/yuzu/configuration/configure_graphics.cpp @@ -8,27 +8,7 @@ #include "ui_configure_graphics.h" #include "yuzu/configuration/configure_graphics.h" -ConfigureGraphics::ConfigureGraphics(QWidget* parent) - : QWidget(parent), ui(new Ui::ConfigureGraphics) { - - ui->setupUi(this); - this->setConfiguration(); - - ui->frame_limit->setEnabled(Settings::values.use_frame_limit); - connect(ui->toggle_frame_limit, &QCheckBox::stateChanged, ui->frame_limit, - &QSpinBox::setEnabled); - connect(ui->bg_button, &QPushButton::clicked, this, [this] { - const QColor new_bg_color = QColorDialog::getColor(bg_color); - if (!new_bg_color.isValid()) - return; - bg_color = new_bg_color; - ui->bg_button->setStyleSheet( - QString("QPushButton { background-color: %1 }").arg(bg_color.name())); - }); -} - -ConfigureGraphics::~ConfigureGraphics() = default; - +namespace { enum class Resolution : int { Auto, Scale1x, @@ -67,6 +47,28 @@ Resolution FromResolutionFactor(float factor) { } return Resolution::Auto; } +} // Anonymous namespace + +ConfigureGraphics::ConfigureGraphics(QWidget* parent) + : QWidget(parent), ui(new Ui::ConfigureGraphics) { + + ui->setupUi(this); + this->setConfiguration(); + + ui->frame_limit->setEnabled(Settings::values.use_frame_limit); + connect(ui->toggle_frame_limit, &QCheckBox::stateChanged, ui->frame_limit, + &QSpinBox::setEnabled); + connect(ui->bg_button, &QPushButton::clicked, this, [this] { + const QColor new_bg_color = QColorDialog::getColor(bg_color); + if (!new_bg_color.isValid()) + return; + bg_color = new_bg_color; + ui->bg_button->setStyleSheet( + QString("QPushButton { background-color: %1 }").arg(bg_color.name())); + }); +} + +ConfigureGraphics::~ConfigureGraphics() = default; void ConfigureGraphics::setConfiguration() { ui->resolution_factor_combobox->setCurrentIndex( diff --git a/src/yuzu/configuration/configure_input.cpp b/src/yuzu/configuration/configure_input.cpp index d29abb74b..473937ea9 100644 --- a/src/yuzu/configuration/configure_input.cpp +++ b/src/yuzu/configuration/configure_input.cpp @@ -152,9 +152,9 @@ ConfigureInput::ConfigureInput(QWidget* parent) } } connect(analog_map_stick[analog_id], &QPushButton::released, [=]() { - QMessageBox::information( - this, "Information", - "After pressing OK, first move your joystick horizontally, and then vertically."); + QMessageBox::information(this, tr("Information"), + tr("After pressing OK, first move your joystick horizontally, " + "and then vertically.")); handleClick( analog_map_stick[analog_id], [=](const Common::ParamPackage& params) { analogs_param[analog_id] = params; }, |