From e231b8b6f5cecc2727bf0aeba7757e6a1c8a2f77 Mon Sep 17 00:00:00 2001 From: flodavid Date: Tue, 2 Jan 2024 19:59:03 +0100 Subject: yuzu: Add per-game linux gamemode configuration --- src/yuzu/CMakeLists.txt | 3 + src/yuzu/configuration/configure_audio.h | 2 + src/yuzu/configuration/configure_cpu.h | 2 + src/yuzu/configuration/configure_general.h | 2 + src/yuzu/configuration/configure_graphics.h | 2 + .../configuration/configure_graphics_advanced.h | 2 + src/yuzu/configuration/configure_linux_tab.cpp | 75 ++++++++++++++++++++++ src/yuzu/configuration/configure_linux_tab.h | 44 +++++++++++++ src/yuzu/configuration/configure_linux_tab.ui | 53 +++++++++++++++ src/yuzu/configuration/configure_motion_touch.h | 1 + src/yuzu/configuration/configure_mouse_panning.h | 1 + src/yuzu/configuration/configure_per_game.cpp | 6 ++ src/yuzu/configuration/configure_per_game.h | 2 + src/yuzu/configuration/configure_system.h | 2 + 14 files changed, 197 insertions(+) create mode 100644 src/yuzu/configuration/configure_linux_tab.cpp create mode 100644 src/yuzu/configuration/configure_linux_tab.h create mode 100644 src/yuzu/configuration/configure_linux_tab.ui (limited to 'src') diff --git a/src/yuzu/CMakeLists.txt b/src/yuzu/CMakeLists.txt index 90278052a..6a87b0811 100644 --- a/src/yuzu/CMakeLists.txt +++ b/src/yuzu/CMakeLists.txt @@ -96,6 +96,9 @@ add_executable(yuzu configuration/configure_input_profile_dialog.cpp configuration/configure_input_profile_dialog.h configuration/configure_input_profile_dialog.ui + configuration/configure_linux_tab.cpp + configuration/configure_linux_tab.h + configuration/configure_linux_tab.ui configuration/configure_mouse_panning.cpp configuration/configure_mouse_panning.h configuration/configure_mouse_panning.ui diff --git a/src/yuzu/configuration/configure_audio.h b/src/yuzu/configuration/configure_audio.h index 79538e81c..82d7f6524 100644 --- a/src/yuzu/configuration/configure_audio.h +++ b/src/yuzu/configuration/configure_audio.h @@ -24,6 +24,8 @@ class Builder; } class ConfigureAudio : public ConfigurationShared::Tab { + Q_OBJECT + public: explicit ConfigureAudio(const Core::System& system_, std::shared_ptr> group, diff --git a/src/yuzu/configuration/configure_cpu.h b/src/yuzu/configuration/configure_cpu.h index a102b4c1f..7bbeac496 100644 --- a/src/yuzu/configuration/configure_cpu.h +++ b/src/yuzu/configuration/configure_cpu.h @@ -24,6 +24,8 @@ class Builder; } class ConfigureCpu : public ConfigurationShared::Tab { + Q_OBJECT + public: explicit ConfigureCpu(const Core::System& system_, std::shared_ptr> group, diff --git a/src/yuzu/configuration/configure_general.h b/src/yuzu/configuration/configure_general.h index 2d953f679..ada6526a6 100644 --- a/src/yuzu/configuration/configure_general.h +++ b/src/yuzu/configuration/configure_general.h @@ -25,6 +25,8 @@ class Builder; } class ConfigureGeneral : public ConfigurationShared::Tab { + Q_OBJECT + public: explicit ConfigureGeneral(const Core::System& system_, std::shared_ptr> group, diff --git a/src/yuzu/configuration/configure_graphics.h b/src/yuzu/configuration/configure_graphics.h index 5c8286836..b92b4496b 100644 --- a/src/yuzu/configuration/configure_graphics.h +++ b/src/yuzu/configuration/configure_graphics.h @@ -43,6 +43,8 @@ class Builder; } class ConfigureGraphics : public ConfigurationShared::Tab { + Q_OBJECT + public: explicit ConfigureGraphics( const Core::System& system_, std::vector& records, diff --git a/src/yuzu/configuration/configure_graphics_advanced.h b/src/yuzu/configuration/configure_graphics_advanced.h index 78b5389c3..82431987e 100644 --- a/src/yuzu/configuration/configure_graphics_advanced.h +++ b/src/yuzu/configuration/configure_graphics_advanced.h @@ -21,6 +21,8 @@ class Builder; } class ConfigureGraphicsAdvanced : public ConfigurationShared::Tab { + Q_OBJECT + public: explicit ConfigureGraphicsAdvanced( const Core::System& system_, std::shared_ptr> group, diff --git a/src/yuzu/configuration/configure_linux_tab.cpp b/src/yuzu/configuration/configure_linux_tab.cpp new file mode 100644 index 000000000..ab3d18816 --- /dev/null +++ b/src/yuzu/configuration/configure_linux_tab.cpp @@ -0,0 +1,75 @@ +// SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "common/settings.h" +#include "core/core.h" +#include "ui_configure_linux_tab.h" +#include "yuzu/configuration/configuration_shared.h" +#include "yuzu/configuration/configure_linux_tab.h" +#include "yuzu/configuration/shared_widget.h" + +ConfigureLinuxTab::ConfigureLinuxTab(const Core::System& system_, + std::shared_ptr> group_, + const ConfigurationShared::Builder& builder, QWidget* parent) + : Tab(group_, parent), ui(std::make_unique()), system{system_} { + ui->setupUi(this); + + Setup(builder); + + SetConfiguration(); +} + +ConfigureLinuxTab::~ConfigureLinuxTab() = default; + +void ConfigureLinuxTab::SetConfiguration() {} +void ConfigureLinuxTab::Setup(const ConfigurationShared::Builder& builder) { + QLayout& linux_layout = *ui->linux_widget->layout(); + + std::map linux_hold{}; + + std::vector settings; + const auto push = [&](Settings::Category category) { + for (const auto setting : Settings::values.linkage.by_category[category]) { + settings.push_back(setting); + } + }; + + push(Settings::Category::Linux); + + for (auto* setting : settings) { + auto* widget = builder.BuildWidget(setting, apply_funcs); + + if (widget == nullptr) { + continue; + } + if (!widget->Valid()) { + widget->deleteLater(); + continue; + } + + linux_hold.insert({setting->Id(), widget}); + } + + for (const auto& [id, widget] : linux_hold) { + linux_layout.addWidget(widget); + } +} + +void ConfigureLinuxTab::ApplyConfiguration() { + const bool is_powered_on = system.IsPoweredOn(); + for (const auto& apply_func : apply_funcs) { + apply_func(is_powered_on); + } +} + +void ConfigureLinuxTab::changeEvent(QEvent* event) { + if (event->type() == QEvent::LanguageChange) { + RetranslateUI(); + } + + QWidget::changeEvent(event); +} + +void ConfigureLinuxTab::RetranslateUI() { + ui->retranslateUi(this); +} diff --git a/src/yuzu/configuration/configure_linux_tab.h b/src/yuzu/configuration/configure_linux_tab.h new file mode 100644 index 000000000..2f402079c --- /dev/null +++ b/src/yuzu/configuration/configure_linux_tab.h @@ -0,0 +1,44 @@ +// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include + +namespace Core { +class System; +} + +namespace Ui { +class ConfigureLinuxTab; +} + +namespace ConfigurationShared { +class Builder; +} + +class ConfigureLinuxTab : public ConfigurationShared::Tab { + Q_OBJECT + +public: + explicit ConfigureLinuxTab(const Core::System& system_, + std::shared_ptr> group, + const ConfigurationShared::Builder& builder, + QWidget* parent = nullptr); + ~ConfigureLinuxTab() override; + + void ApplyConfiguration() override; + void SetConfiguration() override; + +private: + void changeEvent(QEvent* event) override; + void RetranslateUI(); + + void Setup(const ConfigurationShared::Builder& builder); + + std::unique_ptr ui; + + const Core::System& system; + + std::vector> apply_funcs{}; +}; diff --git a/src/yuzu/configuration/configure_linux_tab.ui b/src/yuzu/configuration/configure_linux_tab.ui new file mode 100644 index 000000000..f8e07f581 --- /dev/null +++ b/src/yuzu/configuration/configure_linux_tab.ui @@ -0,0 +1,53 @@ + + + ConfigureLinuxTab + + + Linux + + + + + + Linux + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + diff --git a/src/yuzu/configuration/configure_motion_touch.h b/src/yuzu/configuration/configure_motion_touch.h index 7dcc9318e..a5db0de51 100644 --- a/src/yuzu/configuration/configure_motion_touch.h +++ b/src/yuzu/configuration/configure_motion_touch.h @@ -26,6 +26,7 @@ class ConfigureMotionTouch; /// A dialog for touchpad calibration configuration. class CalibrationConfigurationDialog : public QDialog { Q_OBJECT + public: explicit CalibrationConfigurationDialog(QWidget* parent, const std::string& host, u16 port); ~CalibrationConfigurationDialog() override; diff --git a/src/yuzu/configuration/configure_mouse_panning.h b/src/yuzu/configuration/configure_mouse_panning.h index 08c6e1f62..f5e62ee13 100644 --- a/src/yuzu/configuration/configure_mouse_panning.h +++ b/src/yuzu/configuration/configure_mouse_panning.h @@ -16,6 +16,7 @@ class ConfigureMousePanning; class ConfigureMousePanning : public QDialog { Q_OBJECT + public: explicit ConfigureMousePanning(QWidget* parent, InputCommon::InputSubsystem* input_subsystem_, float right_stick_deadzone, float right_stick_range); diff --git a/src/yuzu/configuration/configure_per_game.cpp b/src/yuzu/configuration/configure_per_game.cpp index b274a3321..9d38ab812 100644 --- a/src/yuzu/configuration/configure_per_game.cpp +++ b/src/yuzu/configuration/configure_per_game.cpp @@ -33,6 +33,7 @@ #include "yuzu/configuration/configure_graphics.h" #include "yuzu/configuration/configure_graphics_advanced.h" #include "yuzu/configuration/configure_input_per_game.h" +#include "yuzu/configuration/configure_linux_tab.h" #include "yuzu/configuration/configure_per_game.h" #include "yuzu/configuration/configure_per_game_addons.h" #include "yuzu/configuration/configure_system.h" @@ -60,6 +61,7 @@ ConfigurePerGame::ConfigurePerGame(QWidget* parent, u64 title_id_, const std::st system_, vk_device_records, [&]() { graphics_advanced_tab->ExposeComputeOption(); }, [](Settings::AspectRatio, Settings::ResolutionSetup) {}, tab_group, *builder, this); input_tab = std::make_unique(system_, game_config.get(), this); + linux_tab = std::make_unique(system_, tab_group, *builder, this); system_tab = std::make_unique(system_, tab_group, *builder, this); ui->setupUi(this); @@ -71,6 +73,10 @@ ConfigurePerGame::ConfigurePerGame(QWidget* parent, u64 title_id_, const std::st ui->tabWidget->addTab(graphics_advanced_tab.get(), tr("Adv. Graphics")); ui->tabWidget->addTab(audio_tab.get(), tr("Audio")); ui->tabWidget->addTab(input_tab.get(), tr("Input Profiles")); + // Only show Linux tab on Unix +#ifdef __unix__ + ui->tabWidget->addTab(linux_tab.get(), tr("Linux")); +#endif setFocusPolicy(Qt::ClickFocus); setWindowTitle(tr("Properties")); diff --git a/src/yuzu/configuration/configure_per_game.h b/src/yuzu/configuration/configure_per_game.h index c8ee46c04..805bd47c0 100644 --- a/src/yuzu/configuration/configure_per_game.h +++ b/src/yuzu/configuration/configure_per_game.h @@ -32,6 +32,7 @@ class ConfigureCpu; class ConfigureGraphics; class ConfigureGraphicsAdvanced; class ConfigureInputPerGame; +class ConfigureLinuxTab; class ConfigureSystem; class QGraphicsScene; @@ -85,5 +86,6 @@ private: std::unique_ptr graphics_advanced_tab; std::unique_ptr graphics_tab; std::unique_ptr input_tab; + std::unique_ptr linux_tab; std::unique_ptr system_tab; }; diff --git a/src/yuzu/configuration/configure_system.h b/src/yuzu/configuration/configure_system.h index eab99a48a..c606c32f5 100644 --- a/src/yuzu/configuration/configure_system.h +++ b/src/yuzu/configuration/configure_system.h @@ -27,6 +27,8 @@ class Builder; } class ConfigureSystem : public ConfigurationShared::Tab { + Q_OBJECT + public: explicit ConfigureSystem(Core::System& system_, std::shared_ptr> group, -- cgit v1.2.3