diff options
Diffstat (limited to 'src/yuzu/main.cpp')
-rw-r--r-- | src/yuzu/main.cpp | 102 |
1 files changed, 79 insertions, 23 deletions
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 21983a799..c0afb2e5f 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -15,6 +15,7 @@ #endif // VFS includes must be before glad as they will conflict with Windows file api, which uses defines. +#include "applets/qt_amiibo_settings.h" #include "applets/qt_controller.h" #include "applets/qt_error.h" #include "applets/qt_profile_select.h" @@ -26,6 +27,7 @@ #include "configuration/configure_tas.h" #include "core/file_sys/vfs.h" #include "core/file_sys/vfs_real.h" +#include "core/frontend/applets/cabinet.h" #include "core/frontend/applets/controller.h" #include "core/frontend/applets/general_frontend.h" #include "core/frontend/applets/mii_edit.h" @@ -166,6 +168,7 @@ __declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1; constexpr int default_mouse_hide_timeout = 2500; constexpr int default_mouse_center_timeout = 10; +constexpr int default_input_update_timeout = 1; /** * "Callouts" are one-time instructional messages shown to the user. In the config settings, there @@ -236,6 +239,7 @@ static void LogRuntimes() { LOG_INFO(Frontend, "Unable to inspect {}", runtime_dll_name); } #endif + LOG_INFO(Frontend, "Qt Compile: {} Runtime: {}", QT_VERSION_STR, qVersion()); } static QString PrettyProductName() { @@ -403,6 +407,10 @@ GMainWindow::GMainWindow(std::unique_ptr<Config> config_, bool has_broken_vulkan mouse_center_timer.setInterval(default_mouse_center_timeout); connect(&mouse_center_timer, &QTimer::timeout, this, &GMainWindow::CenterMouseCursor); + update_input_timer.setInterval(default_input_update_timeout); + connect(&update_input_timer, &QTimer::timeout, this, &GMainWindow::UpdateInputDrivers); + update_input_timer.start(); + MigrateConfigFiles(); if (has_broken_vulkan) { @@ -549,6 +557,11 @@ void GMainWindow::RegisterMetaTypes() { // Register applet types + // Cabinet Applet + qRegisterMetaType<Core::Frontend::CabinetParameters>("Core::Frontend::CabinetParameters"); + qRegisterMetaType<std::shared_ptr<Service::NFP::NfpDevice>>( + "std::shared_ptr<Service::NFP::NfpDevice>"); + // Controller Applet qRegisterMetaType<Core::Frontend::ControllerParameters>("Core::Frontend::ControllerParameters"); @@ -570,6 +583,21 @@ void GMainWindow::RegisterMetaTypes() { qRegisterMetaType<Core::SystemResultStatus>("Core::SystemResultStatus"); } +void GMainWindow::AmiiboSettingsShowDialog(const Core::Frontend::CabinetParameters& parameters, + std::shared_ptr<Service::NFP::NfpDevice> nfp_device) { + QtAmiiboSettingsDialog dialog(this, parameters, input_subsystem.get(), nfp_device); + + dialog.setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint | + Qt::WindowTitleHint | Qt::WindowSystemMenuHint); + dialog.setWindowModality(Qt::WindowModal); + if (dialog.exec() == QDialog::Rejected) { + emit AmiiboSettingsFinished(false, {}); + return; + } + + emit AmiiboSettingsFinished(true, dialog.GetName()); +} + void GMainWindow::ControllerSelectorReconfigureControllers( const Core::Frontend::ControllerParameters& parameters) { QtControllerSelectorDialog dialog(this, parameters, input_subsystem.get(), *system); @@ -985,29 +1013,11 @@ void GMainWindow::InitializeWidgets() { renderer_status_button->setObjectName(QStringLiteral("RendererStatusBarButton")); renderer_status_button->setCheckable(true); renderer_status_button->setFocusPolicy(Qt::NoFocus); - connect(renderer_status_button, &QPushButton::toggled, [this](bool checked) { - renderer_status_button->setText(checked ? tr("VULKAN") : tr("OPENGL")); - }); - renderer_status_button->toggle(); - + connect(renderer_status_button, &QPushButton::clicked, this, &GMainWindow::OnToggleGraphicsAPI); + UpdateAPIText(); + renderer_status_button->setCheckable(true); renderer_status_button->setChecked(Settings::values.renderer_backend.GetValue() == Settings::RendererBackend::Vulkan); - connect(renderer_status_button, &QPushButton::clicked, [this] { - if (emulation_running) { - return; - } - if (renderer_status_button->isChecked()) { - Settings::values.renderer_backend.SetValue(Settings::RendererBackend::Vulkan); - } else { - Settings::values.renderer_backend.SetValue(Settings::RendererBackend::OpenGL); - if (Settings::values.scaling_filter.GetValue() == Settings::ScalingFilter::Fsr) { - Settings::values.scaling_filter.SetValue(Settings::ScalingFilter::NearestNeighbor); - UpdateFilterText(); - } - } - - system->ApplySettings(); - }); statusBar()->insertPermanentWidget(0, renderer_status_button); statusBar()->setVisible(true); @@ -1547,6 +1557,7 @@ bool GMainWindow::LoadROM(const QString& filename, u64 program_id, std::size_t p system->SetFilesystem(vfs); system->SetAppletFrontendSet({ + std::make_unique<QtAmiiboSettings>(*this), // Amiibo Settings std::make_unique<QtControllerSelector>(*this), // Controller Selector std::make_unique<QtErrorDisplay>(*this), // Error Display nullptr, // Mii Editor @@ -1958,6 +1969,7 @@ void GMainWindow::OnGameListOpenFolder(u64 program_id, GameListOpenTarget target } default: UNIMPLEMENTED(); + break; } const QString qpath = QString::fromStdString(Common::FS::PathToUTF8String(path)); @@ -2823,6 +2835,7 @@ void GMainWindow::ErrorDisplayDisplayError(QString error_code, QString error_tex } void GMainWindow::OnMenuReportCompatibility() { +#if defined(ARCHITECTURE_x86_64) && !defined(__APPLE__) const auto& caps = Common::GetCPUCaps(); const bool has_fma = caps.fma || caps.fma4; const auto processor_count = std::thread::hardware_concurrency(); @@ -2849,6 +2862,11 @@ void GMainWindow::OnMenuReportCompatibility() { "> " "Web.")); } +#else + QMessageBox::critical(this, tr("Hardware requirements not met"), + tr("Your system does not meet the recommended hardware requirements. " + "Compatibility reporting has been disabled.")); +#endif } void GMainWindow::OpenURL(const QUrl& url) { @@ -3202,6 +3220,7 @@ void GMainWindow::OnToggleGpuAccuracy() { case Settings::GPUAccuracy::Extreme: default: { Settings::values.gpu_accuracy.SetValue(Settings::GPUAccuracy::High); + break; } } @@ -3225,6 +3244,18 @@ void GMainWindow::OnToggleAdaptingFilter() { UpdateFilterText(); } +void GMainWindow::OnToggleGraphicsAPI() { + auto api = Settings::values.renderer_backend.GetValue(); + if (api == Settings::RendererBackend::OpenGL) { + api = Settings::RendererBackend::Vulkan; + } else { + api = Settings::RendererBackend::OpenGL; + } + Settings::values.renderer_backend.SetValue(api); + renderer_status_button->setChecked(api == Settings::RendererBackend::Vulkan); + UpdateAPIText(); +} + void GMainWindow::OnConfigurePerGame() { const u64 title_id = system->GetCurrentProcessProgramID(); OpenPerGameConfiguration(title_id, current_game_path.toStdString()); @@ -3535,6 +3566,7 @@ void GMainWindow::UpdateGPUAccuracyButton() { default: { gpu_accuracy_button->setText(tr("GPU ERROR")); gpu_accuracy_button->setChecked(true); + break; } } } @@ -3545,6 +3577,21 @@ void GMainWindow::UpdateDockedButton() { dock_status_button->setText(is_docked ? tr("DOCKED") : tr("HANDHELD")); } +void GMainWindow::UpdateAPIText() { + const auto api = Settings::values.renderer_backend.GetValue(); + switch (api) { + case Settings::RendererBackend::OpenGL: + renderer_status_button->setText(tr("OPENGL")); + break; + case Settings::RendererBackend::Vulkan: + renderer_status_button->setText(tr("VULKAN")); + break; + case Settings::RendererBackend::Null: + renderer_status_button->setText(tr("NULL")); + break; + } +} + void GMainWindow::UpdateFilterText() { const auto filter = Settings::values.scaling_filter.GetValue(); switch (filter) { @@ -3590,6 +3637,7 @@ void GMainWindow::UpdateAAText() { void GMainWindow::UpdateStatusButtons() { renderer_status_button->setChecked(Settings::values.renderer_backend.GetValue() == Settings::RendererBackend::Vulkan); + UpdateAPIText(); UpdateGPUAccuracyButton(); UpdateDockedButton(); UpdateFilterText(); @@ -3614,6 +3662,13 @@ void GMainWindow::UpdateUISettings() { UISettings::values.first_start = false; } +void GMainWindow::UpdateInputDrivers() { + if (!input_subsystem) { + return; + } + input_subsystem->PumpEvents(); +} + void GMainWindow::HideMouseCursor() { if (emu_thread == nullptr && UISettings::values.hide_mouse) { mouse_hide_timer.stop(); @@ -4016,7 +4071,6 @@ void GMainWindow::UpdateUITheme() { const QString default_theme = QString::fromUtf8(UISettings::themes[static_cast<size_t>(Config::default_theme)].second); QString current_theme = UISettings::values.theme; - QStringList theme_paths(default_theme_paths); if (current_theme.isEmpty()) { current_theme = default_theme; @@ -4029,7 +4083,7 @@ void GMainWindow::UpdateUITheme() { if (current_theme == QStringLiteral("default") || current_theme == QStringLiteral("colorful")) { QIcon::setThemeName(current_theme == QStringLiteral("colorful") ? current_theme : startup_icon_theme); - QIcon::setThemeSearchPaths(theme_paths); + QIcon::setThemeSearchPaths(QStringList(default_theme_paths)); if (CheckDarkMode()) { current_theme = QStringLiteral("default_dark"); } @@ -4197,10 +4251,12 @@ int main(int argc, char* argv[]) { // so we can see if we get \u3008 instead // TL;DR all other number formats are consecutive in unicode code points // This bug is fixed in Qt6, specifically 6.0.0-alpha1 +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) const QLocale locale = QLocale::system(); if (QStringLiteral("\u3008") == locale.toString(1)) { QLocale::setDefault(QLocale::system().name()); } +#endif // Qt changes the locale and causes issues in float conversion using std::to_string() when // generating shaders |