From 09a56f2db3504de57300afdc1375b5b245de14a9 Mon Sep 17 00:00:00 2001 From: pineappleEA Date: Wed, 2 Feb 2022 05:57:17 +0100 Subject: [PATCH] early-access version 2465 --- README.md | 2 +- src/common/wall_clock.cpp | 16 ++++++---- src/common/wall_clock.h | 8 +++-- src/common/x64/native_clock.cpp | 6 ++-- src/input_common/input_engine.h | 2 +- src/yuzu/configuration/configure_dialog.cpp | 2 +- .../configuration/configure_filesystem.cpp | 16 +++++++--- src/yuzu/configuration/configure_filesystem.h | 8 +++-- src/yuzu/configuration/configure_hotkeys.cpp | 32 +++++++++---------- 9 files changed, 55 insertions(+), 37 deletions(-) diff --git a/README.md b/README.md index d31349160..84d982dd8 100755 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ yuzu emulator early access ============= -This is the source code for early-access 2462. +This is the source code for early-access 2465. ## Legal Notice diff --git a/src/common/wall_clock.cpp b/src/common/wall_clock.cpp index ffa282e88..9acf7551e 100755 --- a/src/common/wall_clock.cpp +++ b/src/common/wall_clock.cpp @@ -65,16 +65,20 @@ private: #ifdef ARCHITECTURE_x86_64 -std::unique_ptr CreateBestMatchingClock(u32 emulated_cpu_frequency, - u32 emulated_clock_frequency) { +std::unique_ptr CreateBestMatchingClock(u64 emulated_cpu_frequency, + u64 emulated_clock_frequency) { const auto& caps = GetCPUCaps(); u64 rtsc_frequency = 0; if (caps.invariant_tsc) { rtsc_frequency = EstimateRDTSCFrequency(); } - // Fallback to StandardWallClock if rtsc period is higher than a nano second - if (rtsc_frequency <= 1000000000) { + // Fallback to StandardWallClock if the hardware TSC does not have the precision greater than: + // - A nanosecond + // - The emulated CPU frequency + // - The emulated clock counter frequency (CNTFRQ) + if (rtsc_frequency <= WallClock::NS_RATIO || rtsc_frequency <= emulated_cpu_frequency || + rtsc_frequency <= emulated_clock_frequency) { return std::make_unique(emulated_cpu_frequency, emulated_clock_frequency); } else { @@ -85,8 +89,8 @@ std::unique_ptr CreateBestMatchingClock(u32 emulated_cpu_frequency, #else -std::unique_ptr CreateBestMatchingClock(u32 emulated_cpu_frequency, - u32 emulated_clock_frequency) { +std::unique_ptr CreateBestMatchingClock(u64 emulated_cpu_frequency, + u64 emulated_clock_frequency) { return std::make_unique(emulated_cpu_frequency, emulated_clock_frequency); } diff --git a/src/common/wall_clock.h b/src/common/wall_clock.h index cef3e9499..874448c27 100755 --- a/src/common/wall_clock.h +++ b/src/common/wall_clock.h @@ -13,6 +13,10 @@ namespace Common { class WallClock { public: + static constexpr u64 NS_RATIO = 1'000'000'000; + static constexpr u64 US_RATIO = 1'000'000; + static constexpr u64 MS_RATIO = 1'000; + virtual ~WallClock() = default; /// Returns current wall time in nanoseconds @@ -49,7 +53,7 @@ private: bool is_native; }; -[[nodiscard]] std::unique_ptr CreateBestMatchingClock(u32 emulated_cpu_frequency, - u32 emulated_clock_frequency); +[[nodiscard]] std::unique_ptr CreateBestMatchingClock(u64 emulated_cpu_frequency, + u64 emulated_clock_frequency); } // namespace Common diff --git a/src/common/x64/native_clock.cpp b/src/common/x64/native_clock.cpp index 82ee2c8a1..91b842829 100755 --- a/src/common/x64/native_clock.cpp +++ b/src/common/x64/native_clock.cpp @@ -47,9 +47,9 @@ NativeClock::NativeClock(u64 emulated_cpu_frequency_, u64 emulated_clock_frequen _mm_mfence(); time_point.inner.last_measure = __rdtsc(); time_point.inner.accumulated_ticks = 0U; - ns_rtsc_factor = GetFixedPoint64Factor(1000000000, rtsc_frequency); - us_rtsc_factor = GetFixedPoint64Factor(1000000, rtsc_frequency); - ms_rtsc_factor = GetFixedPoint64Factor(1000, rtsc_frequency); + ns_rtsc_factor = GetFixedPoint64Factor(NS_RATIO, rtsc_frequency); + us_rtsc_factor = GetFixedPoint64Factor(US_RATIO, rtsc_frequency); + ms_rtsc_factor = GetFixedPoint64Factor(MS_RATIO, rtsc_frequency); clock_rtsc_factor = GetFixedPoint64Factor(emulated_clock_frequency, rtsc_frequency); cpu_rtsc_factor = GetFixedPoint64Factor(emulated_cpu_frequency, rtsc_frequency); } diff --git a/src/input_common/input_engine.h b/src/input_common/input_engine.h index fe2faee5a..4f620b229 100755 --- a/src/input_common/input_engine.h +++ b/src/input_common/input_engine.h @@ -217,7 +217,7 @@ private: int index) const; mutable std::mutex mutex; - mutable std::mutex mutex_callback; + mutable std::recursive_mutex mutex_callback; bool configuring{false}; const std::string input_engine; int last_callback_key = 0; diff --git a/src/yuzu/configuration/configure_dialog.cpp b/src/yuzu/configuration/configure_dialog.cpp index 464e7a489..19133ccf5 100755 --- a/src/yuzu/configuration/configure_dialog.cpp +++ b/src/yuzu/configuration/configure_dialog.cpp @@ -109,7 +109,7 @@ void ConfigureDialog::ApplyConfiguration() { ui_tab->ApplyConfiguration(); system_tab->ApplyConfiguration(); profile_tab->ApplyConfiguration(); - filesystem_tab->applyConfiguration(); + filesystem_tab->ApplyConfiguration(); input_tab->ApplyConfiguration(); hotkeys_tab->ApplyConfiguration(registry); cpu_tab->ApplyConfiguration(); diff --git a/src/yuzu/configuration/configure_filesystem.cpp b/src/yuzu/configuration/configure_filesystem.cpp index 9cb317822..d6fb43f8b 100755 --- a/src/yuzu/configuration/configure_filesystem.cpp +++ b/src/yuzu/configuration/configure_filesystem.cpp @@ -14,7 +14,7 @@ ConfigureFilesystem::ConfigureFilesystem(QWidget* parent) : QWidget(parent), ui(std::make_unique()) { ui->setupUi(this); - this->setConfiguration(); + SetConfiguration(); connect(ui->nand_directory_button, &QToolButton::pressed, this, [this] { SetDirectory(DirectoryTarget::NAND, ui->nand_directory_edit); }); @@ -38,7 +38,15 @@ ConfigureFilesystem::ConfigureFilesystem(QWidget* parent) ConfigureFilesystem::~ConfigureFilesystem() = default; -void ConfigureFilesystem::setConfiguration() { +void ConfigureFilesystem::changeEvent(QEvent* event) { + if (event->type() == QEvent::LanguageChange) { + RetranslateUI(); + } + + QWidget::changeEvent(event); +} + +void ConfigureFilesystem::SetConfiguration() { ui->nand_directory_edit->setText( QString::fromStdString(Common::FS::GetYuzuPathString(Common::FS::YuzuPath::NANDDir))); ui->sdmc_directory_edit->setText( @@ -60,7 +68,7 @@ void ConfigureFilesystem::setConfiguration() { UpdateEnabledControls(); } -void ConfigureFilesystem::applyConfiguration() { +void ConfigureFilesystem::ApplyConfiguration() { Common::FS::SetYuzuPath(Common::FS::YuzuPath::NANDDir, ui->nand_directory_edit->text().toStdString()); Common::FS::SetYuzuPath(Common::FS::YuzuPath::SDMCDir, @@ -143,6 +151,6 @@ void ConfigureFilesystem::UpdateEnabledControls() { !ui->gamecard_current_game->isChecked()); } -void ConfigureFilesystem::retranslateUi() { +void ConfigureFilesystem::RetranslateUI() { ui->retranslateUi(this); } diff --git a/src/yuzu/configuration/configure_filesystem.h b/src/yuzu/configuration/configure_filesystem.h index 2147cd405..b4f9355eb 100755 --- a/src/yuzu/configuration/configure_filesystem.h +++ b/src/yuzu/configuration/configure_filesystem.h @@ -20,11 +20,13 @@ public: explicit ConfigureFilesystem(QWidget* parent = nullptr); ~ConfigureFilesystem() override; - void applyConfiguration(); - void retranslateUi(); + void ApplyConfiguration(); private: - void setConfiguration(); + void changeEvent(QEvent* event) override; + + void RetranslateUI(); + void SetConfiguration(); enum class DirectoryTarget { NAND, diff --git a/src/yuzu/configuration/configure_hotkeys.cpp b/src/yuzu/configuration/configure_hotkeys.cpp index be10e0a31..53e629a5e 100755 --- a/src/yuzu/configuration/configure_hotkeys.cpp +++ b/src/yuzu/configuration/configure_hotkeys.cpp @@ -178,52 +178,52 @@ void ConfigureHotkeys::SetPollingResult(Core::HID::NpadButton button, const bool QString ConfigureHotkeys::GetButtonName(Core::HID::NpadButton button) const { Core::HID::NpadButtonState state{button}; if (state.a) { - return tr("A"); + return QStringLiteral("A"); } if (state.b) { - return tr("B"); + return QStringLiteral("B"); } if (state.x) { - return tr("X"); + return QStringLiteral("X"); } if (state.y) { - return tr("Y"); + return QStringLiteral("Y"); } if (state.l || state.right_sl || state.left_sl) { - return tr("L"); + return QStringLiteral("L"); } if (state.r || state.right_sr || state.left_sr) { - return tr("R"); + return QStringLiteral("R"); } if (state.zl) { - return tr("ZL"); + return QStringLiteral("ZL"); } if (state.zr) { - return tr("ZR"); + return QStringLiteral("ZR"); } if (state.left) { - return tr("Dpad_Left"); + return QStringLiteral("Dpad_Left"); } if (state.right) { - return tr("Dpad_Right"); + return QStringLiteral("Dpad_Right"); } if (state.up) { - return tr("Dpad_Up"); + return QStringLiteral("Dpad_Up"); } if (state.down) { - return tr("Dpad_Down"); + return QStringLiteral("Dpad_Down"); } if (state.stick_l) { - return tr("Left_Stick"); + return QStringLiteral("Left_Stick"); } if (state.stick_r) { - return tr("Right_Stick"); + return QStringLiteral("Right_Stick"); } if (state.minus) { - return tr("Minus"); + return QStringLiteral("Minus"); } if (state.plus) { - return tr("Plus"); + return QStringLiteral("Plus"); } return tr("Invalid"); }