summaryrefslogtreecommitdiff
path: root/src/yuzu
diff options
context:
space:
mode:
Diffstat (limited to 'src/yuzu')
-rw-r--r--src/yuzu/configuration/configure_ringcon.cpp2
-rw-r--r--src/yuzu/configuration/configure_system.cpp57
-rw-r--r--src/yuzu/configuration/configure_system.h6
-rw-r--r--src/yuzu/configuration/shared_translation.cpp4
-rw-r--r--src/yuzu/debugger/console.h2
-rw-r--r--src/yuzu/main.cpp125
-rw-r--r--src/yuzu/main.h8
-rw-r--r--src/yuzu/main.ui5
8 files changed, 75 insertions, 134 deletions
diff --git a/src/yuzu/configuration/configure_ringcon.cpp b/src/yuzu/configuration/configure_ringcon.cpp
index 3a7f6101d..9fd094ab6 100644
--- a/src/yuzu/configuration/configure_ringcon.cpp
+++ b/src/yuzu/configuration/configure_ringcon.cpp
@@ -494,4 +494,4 @@ QString ConfigureRingController::AnalogToText(const Common::ParamPackage& param,
}
return QObject::tr("[unknown]");
-} \ No newline at end of file
+}
diff --git a/src/yuzu/configuration/configure_system.cpp b/src/yuzu/configuration/configure_system.cpp
index b0b84f967..e193b5f95 100644
--- a/src/yuzu/configuration/configure_system.cpp
+++ b/src/yuzu/configuration/configure_system.cpp
@@ -12,9 +12,10 @@
#include <QGraphicsItem>
#include <QLineEdit>
#include <QMessageBox>
+#include <QSpinBox>
+
#include "common/settings.h"
#include "core/core.h"
-#include "core/hle/service/time/time_manager.h"
#include "ui_configure_system.h"
#include "yuzu/configuration/configuration_shared.h"
#include "yuzu/configuration/configure_system.h"
@@ -49,6 +50,11 @@ ConfigureSystem::ConfigureSystem(Core::System& system_,
: Tab(group_, parent), ui{std::make_unique<Ui::ConfigureSystem>()}, system{system_} {
ui->setupUi(this);
+ const auto posix_time = std::chrono::system_clock::now().time_since_epoch();
+ const auto current_time_s =
+ std::chrono::duration_cast<std::chrono::seconds>(posix_time).count();
+ previous_time = current_time_s + Settings::values.custom_rtc_offset.GetValue();
+
Setup(builder);
const auto locale_check = [this]() {
@@ -64,13 +70,28 @@ ConfigureSystem::ConfigureSystem(Core::System& system_,
}
};
+ const auto update_date_offset = [this]() {
+ if (!checkbox_rtc->isChecked()) {
+ return;
+ }
+ auto offset = date_rtc_offset->value();
+ offset += date_rtc->dateTime().toSecsSinceEpoch() - previous_time;
+ previous_time = date_rtc->dateTime().toSecsSinceEpoch();
+ date_rtc_offset->setValue(offset);
+ };
+ const auto update_rtc_date = [this]() { UpdateRtcTime(); };
+
connect(combo_language, qOverload<int>(&QComboBox::currentIndexChanged), this, locale_check);
connect(combo_region, qOverload<int>(&QComboBox::currentIndexChanged), this, locale_check);
+ connect(checkbox_rtc, qOverload<int>(&QCheckBox::stateChanged), this, update_rtc_date);
+ connect(date_rtc_offset, qOverload<int>(&QSpinBox::valueChanged), this, update_rtc_date);
+ connect(date_rtc, &QDateTimeEdit::dateTimeChanged, this, update_date_offset);
ui->label_warn_invalid_locale->setVisible(false);
locale_check();
SetConfiguration();
+ UpdateRtcTime();
}
ConfigureSystem::~ConfigureSystem() = default;
@@ -120,14 +141,28 @@ void ConfigureSystem::Setup(const ConfigurationShared::Builder& builder) {
continue;
}
+ // Keep track of the region_index (and language_index) combobox to validate the selected
+ // settings
if (setting->Id() == Settings::values.region_index.Id()) {
- // Keep track of the region_index (and language_index) combobox to validate the selected
- // settings
combo_region = widget->combobox;
- } else if (setting->Id() == Settings::values.language_index.Id()) {
+ }
+
+ if (setting->Id() == Settings::values.language_index.Id()) {
combo_language = widget->combobox;
}
+ if (setting->Id() == Settings::values.custom_rtc.Id()) {
+ checkbox_rtc = widget->checkbox;
+ }
+
+ if (setting->Id() == Settings::values.custom_rtc.Id()) {
+ date_rtc = widget->date_time_edit;
+ }
+
+ if (setting->Id() == Settings::values.custom_rtc_offset.Id()) {
+ date_rtc_offset = widget->spinbox;
+ }
+
switch (setting->GetCategory()) {
case Settings::Category::Core:
core_hold.emplace(setting->Id(), widget);
@@ -147,6 +182,19 @@ void ConfigureSystem::Setup(const ConfigurationShared::Builder& builder) {
}
}
+void ConfigureSystem::UpdateRtcTime() {
+ const auto posix_time = std::chrono::system_clock::now().time_since_epoch();
+ previous_time = std::chrono::duration_cast<std::chrono::seconds>(posix_time).count();
+ date_rtc_offset->setEnabled(checkbox_rtc->isChecked());
+
+ if (checkbox_rtc->isChecked()) {
+ previous_time += date_rtc_offset->value();
+ }
+
+ const auto date = QDateTime::fromSecsSinceEpoch(previous_time);
+ date_rtc->setDateTime(date);
+}
+
void ConfigureSystem::SetConfiguration() {}
void ConfigureSystem::ApplyConfiguration() {
@@ -154,4 +202,5 @@ void ConfigureSystem::ApplyConfiguration() {
for (const auto& func : apply_funcs) {
func(powered_on);
}
+ UpdateRtcTime();
}
diff --git a/src/yuzu/configuration/configure_system.h b/src/yuzu/configuration/configure_system.h
index eab99a48a..4334211f9 100644
--- a/src/yuzu/configuration/configure_system.h
+++ b/src/yuzu/configuration/configure_system.h
@@ -43,6 +43,8 @@ private:
void Setup(const ConfigurationShared::Builder& builder);
+ void UpdateRtcTime();
+
std::vector<std::function<void(bool)>> apply_funcs{};
std::unique_ptr<Ui::ConfigureSystem> ui;
@@ -52,4 +54,8 @@ private:
QComboBox* combo_region;
QComboBox* combo_language;
+ QCheckBox* checkbox_rtc;
+ QDateTimeEdit* date_rtc;
+ QSpinBox* date_rtc_offset;
+ u64 previous_time;
};
diff --git a/src/yuzu/configuration/shared_translation.cpp b/src/yuzu/configuration/shared_translation.cpp
index 922eb1b1a..ed9c7d859 100644
--- a/src/yuzu/configuration/shared_translation.cpp
+++ b/src/yuzu/configuration/shared_translation.cpp
@@ -143,8 +143,10 @@ std::unique_ptr<TranslationMap> InitializeTranslations(QWidget* parent) {
INSERT(Settings, rng_seed, tr("RNG Seed"), QStringLiteral());
INSERT(Settings, rng_seed_enabled, QStringLiteral(), QStringLiteral());
INSERT(Settings, device_name, tr("Device Name"), QStringLiteral());
- INSERT(Settings, custom_rtc, tr("Custom RTC"), QStringLiteral());
+ INSERT(Settings, custom_rtc, tr("Custom RTC Date:"), QStringLiteral());
INSERT(Settings, custom_rtc_enabled, QStringLiteral(), QStringLiteral());
+ INSERT(Settings, custom_rtc_offset, QStringLiteral(" "),
+ QStringLiteral("The number of seconds from the current unix time"));
INSERT(Settings, language_index, tr("Language:"),
tr("Note: this can be overridden when region setting is auto-select"));
INSERT(Settings, region_index, tr("Region:"), QStringLiteral());
diff --git a/src/yuzu/debugger/console.h b/src/yuzu/debugger/console.h
index fdb7d174c..2491d1ec1 100644
--- a/src/yuzu/debugger/console.h
+++ b/src/yuzu/debugger/console.h
@@ -10,4 +10,4 @@ namespace Debugger {
* get a real qt logging window which would work for all platforms.
*/
void ToggleConsole();
-} // namespace Debugger \ No newline at end of file
+} // namespace Debugger
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp
index d8b0beadf..e14410f7d 100644
--- a/src/yuzu/main.cpp
+++ b/src/yuzu/main.cpp
@@ -423,7 +423,7 @@ GMainWindow::GMainWindow(std::unique_ptr<QtConfig> config_, bool has_broken_vulk
RemoveCachedContents();
// Gen keys if necessary
- OnReinitializeKeys(ReinitializeKeyBehavior::NoWarning);
+ OnCheckFirmwareDecryption();
game_list->LoadCompatibilityList();
game_list->PopulateAsync(UISettings::values.game_dirs);
@@ -1574,8 +1574,6 @@ void GMainWindow::ConnectMenuEvents() {
connect(multiplayer_state, &MultiplayerState::SaveConfig, this, &GMainWindow::OnSaveConfig);
// Tools
- connect_menu(ui->action_Rederive, std::bind(&GMainWindow::OnReinitializeKeys, this,
- ReinitializeKeyBehavior::Warning));
connect_menu(ui->action_Load_Album, &GMainWindow::OnAlbum);
connect_menu(ui->action_Load_Cabinet_Nickname_Owner,
[this]() { OnCabinet(Service::NFP::CabinetMode::StartNicknameAndOwnerSettings); });
@@ -2501,7 +2499,7 @@ void GMainWindow::RemoveUpdateContent(u64 program_id, InstalledEntryType type) {
}
void GMainWindow::RemoveAddOnContent(u64 program_id, InstalledEntryType type) {
- const size_t count = ContentManager::RemoveAllDLC(system.get(), program_id);
+ const size_t count = ContentManager::RemoveAllDLC(*system, program_id);
if (count == 0) {
QMessageBox::warning(this, GetGameListErrorRemoving(type),
tr("There are no DLC installed for this title."));
@@ -2798,8 +2796,7 @@ void GMainWindow::OnGameListVerifyIntegrity(const std::string& game_path) {
return progress.wasCanceled();
};
- const auto result =
- ContentManager::VerifyGameContents(system.get(), game_path, QtProgressCallback);
+ const auto result = ContentManager::VerifyGameContents(*system, game_path, QtProgressCallback);
progress.close();
switch (result) {
case ContentManager::GameVerificationResult::Success:
@@ -3268,7 +3265,7 @@ void GMainWindow::OnMenuInstallToNAND() {
return false;
};
future = QtConcurrent::run([this, &file, progress_callback] {
- return ContentManager::InstallNSP(system.get(), vfs.get(), file.toStdString(),
+ return ContentManager::InstallNSP(*system, *vfs, file.toStdString(),
progress_callback);
});
@@ -3371,7 +3368,7 @@ ContentManager::InstallResult GMainWindow::InstallNCA(const QString& filename) {
}
return false;
};
- return ContentManager::InstallNCA(vfs.get(), filename.toStdString(), registered_cache,
+ return ContentManager::InstallNCA(*vfs, filename.toStdString(), *registered_cache,
static_cast<FileSys::TitleType>(index), progress_callback);
}
@@ -4121,7 +4118,7 @@ void GMainWindow::OnVerifyInstalledContents() {
};
const std::vector<std::string> result =
- ContentManager::VerifyInstalledContents(system.get(), provider.get(), QtProgressCallback);
+ ContentManager::VerifyInstalledContents(*system, *provider, QtProgressCallback);
progress.close();
if (result.empty()) {
@@ -4551,122 +4548,20 @@ void GMainWindow::OnMouseActivity() {
}
}
-void GMainWindow::OnReinitializeKeys(ReinitializeKeyBehavior behavior) {
- if (behavior == ReinitializeKeyBehavior::Warning) {
- const auto res = QMessageBox::information(
- this, tr("Confirm Key Rederivation"),
- tr("You are about to force rederive all of your keys. \nIf you do not know what "
- "this "
- "means or what you are doing, \nthis is a potentially destructive action. "
- "\nPlease "
- "make sure this is what you want \nand optionally make backups.\n\nThis will "
- "delete "
- "your autogenerated key files and re-run the key derivation module."),
- QMessageBox::StandardButtons{QMessageBox::Ok, QMessageBox::Cancel});
-
- if (res == QMessageBox::Cancel)
- return;
-
- const auto keys_dir = Common::FS::GetYuzuPath(Common::FS::YuzuPath::KeysDir);
-
- Common::FS::RemoveFile(keys_dir / "prod.keys_autogenerated");
- Common::FS::RemoveFile(keys_dir / "console.keys_autogenerated");
- Common::FS::RemoveFile(keys_dir / "title.keys_autogenerated");
- }
-
- Core::Crypto::KeyManager& keys = Core::Crypto::KeyManager::Instance();
- bool all_keys_present{true};
-
- if (keys.BaseDeriveNecessary()) {
- Core::Crypto::PartitionDataManager pdm{vfs->OpenDirectory("", FileSys::Mode::Read)};
-
- const auto function = [this, &keys, &pdm] {
- keys.PopulateFromPartitionData(pdm);
-
- system->GetFileSystemController().CreateFactories(*vfs);
- keys.DeriveETicket(pdm, system->GetContentProvider());
- };
-
- QString errors;
- if (!pdm.HasFuses()) {
- errors += tr("Missing fuses");
- }
- if (!pdm.HasBoot0()) {
- errors += tr(" - Missing BOOT0");
- }
- if (!pdm.HasPackage2()) {
- errors += tr(" - Missing BCPKG2-1-Normal-Main");
- }
- if (!pdm.HasProdInfo()) {
- errors += tr(" - Missing PRODINFO");
- }
- if (!errors.isEmpty()) {
- all_keys_present = false;
- QMessageBox::warning(
- this, tr("Derivation Components Missing"),
- tr("Encryption keys are missing. "
- "<br>Please follow <a href='https://yuzu-emu.org/help/quickstart/'>the yuzu "
- "quickstart guide</a> to get all your keys, firmware and "
- "games.<br><br><small>(%1)</small>")
- .arg(errors));
- }
-
- QProgressDialog prog(this);
- prog.setRange(0, 0);
- prog.setLabelText(tr("Deriving keys...\nThis may take up to a minute depending \non your "
- "system's performance."));
- prog.setWindowTitle(tr("Deriving Keys"));
-
- prog.show();
-
- auto future = QtConcurrent::run(function);
- while (!future.isFinished()) {
- QCoreApplication::processEvents();
- }
-
- prog.close();
- }
-
+void GMainWindow::OnCheckFirmwareDecryption() {
system->GetFileSystemController().CreateFactories(*vfs);
-
- if (all_keys_present && !this->CheckSystemArchiveDecryption()) {
- LOG_WARNING(Frontend, "Mii model decryption failed");
+ if (!ContentManager::AreKeysPresent()) {
QMessageBox::warning(
- this, tr("System Archive Decryption Failed"),
- tr("Encryption keys failed to decrypt firmware. "
+ this, tr("Derivation Components Missing"),
+ tr("Encryption keys are missing. "
"<br>Please follow <a href='https://yuzu-emu.org/help/quickstart/'>the yuzu "
"quickstart guide</a> to get all your keys, firmware and "
"games."));
}
-
SetFirmwareVersion();
-
- if (behavior == ReinitializeKeyBehavior::Warning) {
- game_list->PopulateAsync(UISettings::values.game_dirs);
- }
-
UpdateMenuState();
}
-bool GMainWindow::CheckSystemArchiveDecryption() {
- constexpr u64 MiiModelId = 0x0100000000000802;
-
- auto bis_system = system->GetFileSystemController().GetSystemNANDContents();
- if (!bis_system) {
- // Not having system BIS files is not an error.
- return true;
- }
-
- auto mii_nca = bis_system->GetEntry(MiiModelId, FileSys::ContentRecordType::Data);
- if (!mii_nca) {
- // Not having the Mii model is not an error.
- return true;
- }
-
- // Return whether we are able to decrypt the RomFS of the Mii model.
- return mii_nca->GetRomFS().get() != nullptr;
-}
-
bool GMainWindow::CheckFirmwarePresence() {
constexpr u64 MiiEditId = static_cast<u64>(Service::AM::Applets::AppletProgramId::MiiEdit);
diff --git a/src/yuzu/main.h b/src/yuzu/main.h
index 280fae5c3..6b72094ff 100644
--- a/src/yuzu/main.h
+++ b/src/yuzu/main.h
@@ -125,11 +125,6 @@ enum class EmulatedDirectoryTarget {
SDMC,
};
-enum class ReinitializeKeyBehavior {
- NoWarning,
- Warning,
-};
-
namespace VkDeviceInfo {
class Record;
}
@@ -400,7 +395,7 @@ private slots:
void OnMiiEdit();
void OnOpenControllerMenu();
void OnCaptureScreenshot();
- void OnReinitializeKeys(ReinitializeKeyBehavior behavior);
+ void OnCheckFirmwareDecryption();
void OnLanguageChanged(const QString& locale);
void OnMouseActivity();
bool OnShutdownBegin();
@@ -441,7 +436,6 @@ private:
void LoadTranslation();
void OpenPerGameConfiguration(u64 title_id, const std::string& file_name);
bool CheckDarkMode();
- bool CheckSystemArchiveDecryption();
bool CheckFirmwarePresence();
void SetFirmwareVersion();
void ConfigureFilesystemProvider(const std::string& filepath);
diff --git a/src/yuzu/main.ui b/src/yuzu/main.ui
index e53f9951e..6a6b0821f 100644
--- a/src/yuzu/main.ui
+++ b/src/yuzu/main.ui
@@ -224,11 +224,6 @@
<string>&amp;Stop</string>
</property>
</action>
- <action name="action_Rederive">
- <property name="text">
- <string>&amp;Reinitialize keys...</string>
- </property>
- </action>
<action name="action_Verify_installed_contents">
<property name="text">
<string>&amp;Verify Installed Contents</string>