diff options
Diffstat (limited to 'src/yuzu')
| -rw-r--r-- | src/yuzu/CMakeLists.txt | 14 | ||||
| -rw-r--r-- | src/yuzu/bootmanager.cpp | 24 | ||||
| -rw-r--r-- | src/yuzu/bootmanager.h | 2 | ||||
| -rw-r--r-- | src/yuzu/configuration/config.cpp | 73 | ||||
| -rw-r--r-- | src/yuzu/configuration/config.h | 2 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_graphics.cpp | 7 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_graphics.ui | 5 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_input_per_game.cpp | 115 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_input_per_game.h | 45 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_input_per_game.ui | 333 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_input_player.cpp | 8 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_input_player.h | 2 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_per_game.cpp | 5 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_per_game.h | 6 | ||||
| -rw-r--r-- | src/yuzu/main.cpp | 76 | ||||
| -rw-r--r-- | src/yuzu/main.h | 2 | ||||
| -rw-r--r-- | src/yuzu/multiplayer/chat_room.h | 1 | ||||
| -rw-r--r-- | src/yuzu/precompiled_headers.h | 6 | ||||
| -rw-r--r-- | src/yuzu/startup_checks.cpp | 2 | 
19 files changed, 672 insertions, 56 deletions
| diff --git a/src/yuzu/CMakeLists.txt b/src/yuzu/CMakeLists.txt index 060de0259..9971bdfab 100644 --- a/src/yuzu/CMakeLists.txt +++ b/src/yuzu/CMakeLists.txt @@ -88,6 +88,9 @@ add_executable(yuzu      configuration/configure_input_advanced.cpp      configuration/configure_input_advanced.h      configuration/configure_input_advanced.ui +    configuration/configure_input_per_game.cpp +    configuration/configure_input_per_game.h +    configuration/configure_input_per_game.ui      configuration/configure_input_player.cpp      configuration/configure_input_player.h      configuration/configure_input_player.ui @@ -186,6 +189,7 @@ add_executable(yuzu      multiplayer/state.cpp      multiplayer/state.h      multiplayer/validation.h +    precompiled_headers.h      startup_checks.cpp      startup_checks.h      uisettings.cpp @@ -314,7 +318,7 @@ target_link_libraries(yuzu PRIVATE common core input_common network video_core)  target_link_libraries(yuzu PRIVATE Boost::boost glad Qt${QT_MAJOR_VERSION}::Widgets)  target_link_libraries(yuzu PRIVATE ${PLATFORM_LIBRARIES} Threads::Threads) -target_include_directories(yuzu PRIVATE ../../externals/Vulkan-Headers/include) +target_link_libraries(yuzu PRIVATE Vulkan::Headers)  if (NOT WIN32)      target_include_directories(yuzu PRIVATE ${Qt${QT_MAJOR_VERSION}Gui_PRIVATE_INCLUDE_DIRS})  endif() @@ -350,7 +354,7 @@ if (USE_DISCORD_PRESENCE)          discord_impl.cpp          discord_impl.h      ) -    target_link_libraries(yuzu PRIVATE discord-rpc) +    target_link_libraries(yuzu PRIVATE DiscordRPC::discord-rpc)      target_compile_definitions(yuzu PRIVATE -DUSE_DISCORD_PRESENCE)  endif() @@ -407,5 +411,9 @@ if (NOT APPLE)  endif()  if (ARCHITECTURE_x86_64 OR ARCHITECTURE_arm64) -    target_link_libraries(yuzu PRIVATE dynarmic) +    target_link_libraries(yuzu PRIVATE dynarmic::dynarmic) +endif() + +if (YUZU_USE_PRECOMPILED_HEADERS) +    target_precompile_headers(yuzu PRIVATE precompiled_headers.h)  endif() diff --git a/src/yuzu/bootmanager.cpp b/src/yuzu/bootmanager.cpp index c934069dd..5b5b6fed8 100644 --- a/src/yuzu/bootmanager.cpp +++ b/src/yuzu/bootmanager.cpp @@ -118,7 +118,7 @@ void EmuThread::run() {              }          } else {              std::unique_lock lock{running_mutex}; -            running_cv.wait(lock, stop_token, [this] { return IsRunning(); }); +            Common::CondvarWait(running_cv, lock, stop_token, [&] { return IsRunning(); });          }      } @@ -237,8 +237,7 @@ private:      GRenderWindow* render_window;  }; -class OpenGLRenderWidget : public RenderWidget { -public: +struct OpenGLRenderWidget : public RenderWidget {      explicit OpenGLRenderWidget(GRenderWindow* parent) : RenderWidget(parent) {          windowHandle()->setSurfaceType(QWindow::OpenGLSurface);      } @@ -251,13 +250,16 @@ private:      std::unique_ptr<Core::Frontend::GraphicsContext> context;  }; -class VulkanRenderWidget : public RenderWidget { -public: +struct VulkanRenderWidget : public RenderWidget {      explicit VulkanRenderWidget(GRenderWindow* parent) : RenderWidget(parent) {          windowHandle()->setSurfaceType(QWindow::VulkanSurface);      }  }; +struct NullRenderWidget : public RenderWidget { +    explicit NullRenderWidget(GRenderWindow* parent) : RenderWidget(parent) {} +}; +  static Core::Frontend::WindowSystemType GetWindowSystemType() {      // Determine WSI type based on Qt platform.      QString platform_name = QGuiApplication::platformName(); @@ -267,6 +269,10 @@ static Core::Frontend::WindowSystemType GetWindowSystemType() {          return Core::Frontend::WindowSystemType::X11;      else if (platform_name == QStringLiteral("wayland"))          return Core::Frontend::WindowSystemType::Wayland; +    else if (platform_name == QStringLiteral("cocoa")) +        return Core::Frontend::WindowSystemType::Cocoa; +    else if (platform_name == QStringLiteral("android")) +        return Core::Frontend::WindowSystemType::Android;      LOG_CRITICAL(Frontend, "Unknown Qt platform!");      return Core::Frontend::WindowSystemType::Windows; @@ -874,6 +880,9 @@ bool GRenderWindow::InitRenderTarget() {              return false;          }          break; +    case Settings::RendererBackend::Null: +        InitializeNull(); +        break;      }      // Update the Window System information with the new render target @@ -970,6 +979,11 @@ bool GRenderWindow::InitializeVulkan() {      return true;  } +void GRenderWindow::InitializeNull() { +    child_widget = new NullRenderWidget(this); +    main_context = std::make_unique<DummyContext>(); +} +  bool GRenderWindow::LoadOpenGL() {      auto context = CreateSharedContext();      auto scope = context->Acquire(); diff --git a/src/yuzu/bootmanager.h b/src/yuzu/bootmanager.h index 4a01481cd..f4deae4ee 100644 --- a/src/yuzu/bootmanager.h +++ b/src/yuzu/bootmanager.h @@ -14,6 +14,7 @@  #include <QTouchEvent>  #include <QWidget> +#include "common/polyfill_thread.h"  #include "common/thread.h"  #include "core/frontend/emu_window.h" @@ -218,6 +219,7 @@ private:      bool InitializeOpenGL();      bool InitializeVulkan(); +    void InitializeNull();      bool LoadOpenGL();      QStringList GetUnsupportedGLExtensions() const; diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp index 0c93df428..c11d1c8b3 100644 --- a/src/yuzu/configuration/config.cpp +++ b/src/yuzu/configuration/config.cpp @@ -124,6 +124,10 @@ void Config::Initialize(const std::string& config_name) {      }  } +bool Config::IsCustomConfig() { +    return type == ConfigType::PerGameConfig; +} +  /* {Read,Write}BasicSetting and WriteGlobalSetting templates must be defined here before their   * usages later in this file. This allows explicit definition of some types that don't work   * nicely with the general version. @@ -194,8 +198,20 @@ void Config::ReadPlayerValue(std::size_t player_index) {      }();      auto& player = Settings::values.players.GetValue()[player_index]; +    if (IsCustomConfig()) { +        const auto profile_name = +            qt_config->value(QStringLiteral("%1profile_name").arg(player_prefix), QString{}) +                .toString() +                .toStdString(); +        if (profile_name.empty()) { +            // Use the global input config +            player = Settings::values.players.GetValue(true)[player_index]; +            return; +        } +        player.profile_name = profile_name; +    } -    if (player_prefix.isEmpty()) { +    if (player_prefix.isEmpty() && Settings::IsConfiguringGlobal()) {          const auto controller = static_cast<Settings::ControllerType>(              qt_config                  ->value(QStringLiteral("%1type").arg(player_prefix), @@ -388,9 +404,26 @@ void Config::ReadAudioValues() {  void Config::ReadControlValues() {      qt_config->beginGroup(QStringLiteral("Controls")); +    Settings::values.players.SetGlobal(!IsCustomConfig());      for (std::size_t p = 0; p < Settings::values.players.GetValue().size(); ++p) {          ReadPlayerValue(p);      } +    ReadGlobalSetting(Settings::values.use_docked_mode); + +    // Disable docked mode if handheld is selected +    const auto controller_type = Settings::values.players.GetValue()[0].controller_type; +    if (controller_type == Settings::ControllerType::Handheld) { +        Settings::values.use_docked_mode.SetGlobal(!IsCustomConfig()); +        Settings::values.use_docked_mode.SetValue(false); +    } + +    ReadGlobalSetting(Settings::values.vibration_enabled); +    ReadGlobalSetting(Settings::values.enable_accurate_vibrations); +    ReadGlobalSetting(Settings::values.motion_enabled); +    if (IsCustomConfig()) { +        qt_config->endGroup(); +        return; +    }      ReadDebugValues();      ReadKeyboardValues();      ReadMouseValues(); @@ -412,18 +445,6 @@ void Config::ReadControlValues() {      ReadBasicSetting(Settings::values.tas_loop);      ReadBasicSetting(Settings::values.pause_tas_on_load); -    ReadGlobalSetting(Settings::values.use_docked_mode); - -    // Disable docked mode if handheld is selected -    const auto controller_type = Settings::values.players.GetValue()[0].controller_type; -    if (controller_type == Settings::ControllerType::Handheld) { -        Settings::values.use_docked_mode.SetValue(false); -    } - -    ReadGlobalSetting(Settings::values.vibration_enabled); -    ReadGlobalSetting(Settings::values.enable_accurate_vibrations); -    ReadGlobalSetting(Settings::values.motion_enabled); -      ReadBasicSetting(Settings::values.controller_navigation);      qt_config->endGroup(); @@ -905,7 +926,6 @@ void Config::ReadMultiplayerValues() {  void Config::ReadValues() {      if (global) { -        ReadControlValues();          ReadDataStorageValues();          ReadDebuggingValues();          ReadDisabledAddOnValues(); @@ -914,6 +934,7 @@ void Config::ReadValues() {          ReadWebServiceValues();          ReadMiscellaneousValues();      } +    ReadControlValues();      ReadCoreValues();      ReadCpuValues();      ReadRendererValues(); @@ -932,12 +953,20 @@ void Config::SavePlayerValue(std::size_t player_index) {      }();      const auto& player = Settings::values.players.GetValue()[player_index]; +    if (IsCustomConfig()) { +        if (player.profile_name.empty()) { +            // No custom profile selected +            return; +        } +        WriteSetting(QStringLiteral("%1profile_name").arg(player_prefix), +                     QString::fromStdString(player.profile_name), QString{}); +    }      WriteSetting(QStringLiteral("%1type").arg(player_prefix),                   static_cast<u8>(player.controller_type),                   static_cast<u8>(Settings::ControllerType::ProController)); -    if (!player_prefix.isEmpty()) { +    if (!player_prefix.isEmpty() || !Settings::IsConfiguringGlobal()) {          WriteSetting(QStringLiteral("%1connected").arg(player_prefix), player.connected,                       player_index == 0);          WriteSetting(QStringLiteral("%1vibration_enabled").arg(player_prefix), @@ -1055,7 +1084,6 @@ void Config::SaveIrCameraValues() {  void Config::SaveValues() {      if (global) { -        SaveControlValues();          SaveDataStorageValues();          SaveDebuggingValues();          SaveDisabledAddOnValues(); @@ -1064,6 +1092,7 @@ void Config::SaveValues() {          SaveWebServiceValues();          SaveMiscellaneousValues();      } +    SaveControlValues();      SaveCoreValues();      SaveCpuValues();      SaveRendererValues(); @@ -1088,9 +1117,14 @@ void Config::SaveAudioValues() {  void Config::SaveControlValues() {      qt_config->beginGroup(QStringLiteral("Controls")); +    Settings::values.players.SetGlobal(!IsCustomConfig());      for (std::size_t p = 0; p < Settings::values.players.GetValue().size(); ++p) {          SavePlayerValue(p);      } +    if (IsCustomConfig()) { +        qt_config->endGroup(); +        return; +    }      SaveDebugValues();      SaveMouseValues();      SaveTouchscreenValues(); @@ -1579,6 +1613,13 @@ void Config::SaveControlPlayerValue(std::size_t player_index) {      qt_config->endGroup();  } +void Config::ClearControlPlayerValues() { +    qt_config->beginGroup(QStringLiteral("Controls")); +    // If key is an empty string, all keys in the current group() are removed. +    qt_config->remove(QString{}); +    qt_config->endGroup(); +} +  const std::string& Config::GetConfigFilePath() const {      return qt_config_loc;  } diff --git a/src/yuzu/configuration/config.h b/src/yuzu/configuration/config.h index 06fa7d2d0..7d26e9ab6 100644 --- a/src/yuzu/configuration/config.h +++ b/src/yuzu/configuration/config.h @@ -34,6 +34,7 @@ public:      void ReadControlPlayerValue(std::size_t player_index);      void SaveControlPlayerValue(std::size_t player_index); +    void ClearControlPlayerValues();      const std::string& GetConfigFilePath() const; @@ -58,6 +59,7 @@ public:  private:      void Initialize(const std::string& config_name); +    bool IsCustomConfig();      void ReadValues();      void ReadPlayerValue(std::size_t player_index); diff --git a/src/yuzu/configuration/configure_graphics.cpp b/src/yuzu/configuration/configure_graphics.cpp index f1385e972..8ca683966 100644 --- a/src/yuzu/configuration/configure_graphics.cpp +++ b/src/yuzu/configuration/configure_graphics.cpp @@ -260,6 +260,7 @@ void ConfigureGraphics::ApplyConfiguration() {              Settings::values.renderer_backend.SetValue(GetCurrentGraphicsBackend());              switch (GetCurrentGraphicsBackend()) {              case Settings::RendererBackend::OpenGL: +            case Settings::RendererBackend::Null:                  Settings::values.shader_backend.SetGlobal(false);                  Settings::values.vulkan_device.SetGlobal(true);                  Settings::values.shader_backend.SetValue(shader_backend); @@ -348,6 +349,10 @@ void ConfigureGraphics::UpdateAPILayout() {          ui->device_widget->setVisible(true);          ui->backend_widget->setVisible(false);          break; +    case Settings::RendererBackend::Null: +        ui->device_widget->setVisible(false); +        ui->backend_widget->setVisible(false); +        break;      }  } @@ -360,7 +365,7 @@ void ConfigureGraphics::RetrieveVulkanDevices() try {      vk::InstanceDispatch dld;      const Common::DynamicLibrary library = OpenLibrary(); -    const vk::Instance instance = CreateInstance(library, dld, VK_API_VERSION_1_0); +    const vk::Instance instance = CreateInstance(library, dld, VK_API_VERSION_1_1);      const std::vector<VkPhysicalDevice> physical_devices = instance.EnumeratePhysicalDevices();      vulkan_devices.clear(); diff --git a/src/yuzu/configuration/configure_graphics.ui b/src/yuzu/configuration/configure_graphics.ui index 37271f956..f78396690 100644 --- a/src/yuzu/configuration/configure_graphics.ui +++ b/src/yuzu/configuration/configure_graphics.ui @@ -139,6 +139,11 @@                    <string notr="true">Vulkan</string>                   </property>                  </item> +                <item> +                 <property name="text"> +                  <string>None</string> +                 </property> +                </item>                 </widget>                </item>               </layout> diff --git a/src/yuzu/configuration/configure_input_per_game.cpp b/src/yuzu/configuration/configure_input_per_game.cpp new file mode 100644 index 000000000..78e65d468 --- /dev/null +++ b/src/yuzu/configuration/configure_input_per_game.cpp @@ -0,0 +1,115 @@ +// SPDX-FileCopyrightText: 2022 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "common/settings.h" +#include "core/core.h" +#include "core/hid/emulated_controller.h" +#include "core/hid/hid_core.h" +#include "ui_configure_input_per_game.h" +#include "yuzu/configuration/config.h" +#include "yuzu/configuration/configure_input_per_game.h" +#include "yuzu/configuration/input_profiles.h" + +ConfigureInputPerGame::ConfigureInputPerGame(Core::System& system_, Config* config_, +                                             QWidget* parent) +    : QWidget(parent), ui(std::make_unique<Ui::ConfigureInputPerGame>()), +      profiles(std::make_unique<InputProfiles>()), system{system_}, config{config_} { +    ui->setupUi(this); +    const std::array labels = { +        ui->label_player_1, ui->label_player_2, ui->label_player_3, ui->label_player_4, +        ui->label_player_5, ui->label_player_6, ui->label_player_7, ui->label_player_8, +    }; +    profile_comboboxes = { +        ui->profile_player_1, ui->profile_player_2, ui->profile_player_3, ui->profile_player_4, +        ui->profile_player_5, ui->profile_player_6, ui->profile_player_7, ui->profile_player_8, +    }; + +    Settings::values.players.SetGlobal(false); + +    const auto& profile_names = profiles->GetInputProfileNames(); +    const auto populate_profiles = [this, &profile_names](size_t player_index) { +        const auto previous_profile = +            Settings::values.players.GetValue()[player_index].profile_name; + +        auto* const player_combobox = profile_comboboxes[player_index]; +        player_combobox->addItem(tr("Use global input configuration")); + +        for (size_t index = 0; index < profile_names.size(); ++index) { +            const auto& profile_name = profile_names[index]; +            player_combobox->addItem(QString::fromStdString(profile_name)); +            if (profile_name == previous_profile) { +                // offset by 1 since the first element is the global config +                player_combobox->setCurrentIndex(static_cast<int>(index + 1)); +            } +        } +    }; +    for (size_t index = 0; index < profile_comboboxes.size(); ++index) { +        labels[index]->setText(tr("Player %1 profile").arg(index + 1)); +        populate_profiles(index); +    } + +    LoadConfiguration(); +} + +void ConfigureInputPerGame::ApplyConfiguration() { +    LoadConfiguration(); +    SaveConfiguration(); +} + +void ConfigureInputPerGame::LoadConfiguration() { +    static constexpr size_t HANDHELD_INDEX = 8; + +    auto& hid_core = system.HIDCore(); +    for (size_t player_index = 0; player_index < profile_comboboxes.size(); ++player_index) { +        Settings::values.players.SetGlobal(false); + +        auto* emulated_controller = hid_core.GetEmulatedControllerByIndex(player_index); +        auto* const player_combobox = profile_comboboxes[player_index]; + +        const auto selection_index = player_combobox->currentIndex(); +        if (selection_index == 0) { +            Settings::values.players.GetValue()[player_index].profile_name = ""; +            if (player_index == 0) { +                Settings::values.players.GetValue()[HANDHELD_INDEX] = {}; +            } +            Settings::values.players.SetGlobal(true); +            emulated_controller->ReloadFromSettings(); +            continue; +        } +        const auto profile_name = player_combobox->itemText(selection_index).toStdString(); +        if (profile_name.empty()) { +            continue; +        } +        auto& player = Settings::values.players.GetValue()[player_index]; +        player.profile_name = profile_name; +        // Read from the profile into the custom player settings +        profiles->LoadProfile(profile_name, player_index); +        // Make sure the controller is connected +        player.connected = true; + +        emulated_controller->ReloadFromSettings(); + +        if (player_index > 0) { +            continue; +        } +        // Handle Handheld cases +        auto& handheld_player = Settings::values.players.GetValue()[HANDHELD_INDEX]; +        auto* handheld_controller = hid_core.GetEmulatedController(Core::HID::NpadIdType::Handheld); +        if (player.controller_type == Settings::ControllerType::Handheld) { +            handheld_player = player; +        } else { +            handheld_player = {}; +        } +        handheld_controller->ReloadFromSettings(); +    } +} + +void ConfigureInputPerGame::SaveConfiguration() { +    Settings::values.players.SetGlobal(false); + +    // Clear all controls from the config in case the user reverted back to globals +    config->ClearControlPlayerValues(); +    for (size_t index = 0; index < Settings::values.players.GetValue().size(); ++index) { +        config->SaveControlPlayerValue(index); +    } +} diff --git a/src/yuzu/configuration/configure_input_per_game.h b/src/yuzu/configuration/configure_input_per_game.h new file mode 100644 index 000000000..660faf574 --- /dev/null +++ b/src/yuzu/configuration/configure_input_per_game.h @@ -0,0 +1,45 @@ +// SPDX-FileCopyrightText: 2022 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include <memory> + +#include <QWidget> + +#include "ui_configure_input_per_game.h" +#include "yuzu/configuration/input_profiles.h" + +class QComboBox; + +namespace Core { +class System; +} // namespace Core + +class Config; + +class ConfigureInputPerGame : public QWidget { +    Q_OBJECT + +public: +    explicit ConfigureInputPerGame(Core::System& system_, Config* config_, +                                   QWidget* parent = nullptr); + +    /// Load and Save configurations to settings file. +    void ApplyConfiguration(); + +private: +    /// Load configuration from settings file. +    void LoadConfiguration(); + +    /// Save configuration to settings file. +    void SaveConfiguration(); + +    std::unique_ptr<Ui::ConfigureInputPerGame> ui; +    std::unique_ptr<InputProfiles> profiles; + +    std::array<QComboBox*, 8> profile_comboboxes; + +    Core::System& system; +    Config* config; +}; diff --git a/src/yuzu/configuration/configure_input_per_game.ui b/src/yuzu/configuration/configure_input_per_game.ui new file mode 100644 index 000000000..fbd8eab1c --- /dev/null +++ b/src/yuzu/configuration/configure_input_per_game.ui @@ -0,0 +1,333 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>ConfigureInputPerGame</class> + <widget class="QWidget" name="PerGameInput"> +  <property name="geometry"> +   <rect> +    <x>0</x> +    <y>0</y> +    <width>541</width> +    <height>759</height> +   </rect> +  </property> +  <property name="windowTitle"> +   <string>Form</string> +  </property> +  <property name="accessibleName"> +   <string>Graphics</string> +  </property> +  <layout class="QVBoxLayout" name="verticalLayout_1"> +   <item> +    <layout class="QVBoxLayout" name="verticalLayout_2"> +     <property name="spacing"> +      <number>0</number> +     </property> +     <item> +      <widget class="QGroupBox" name="groupBox"> +       <property name="title"> +        <string>Input Profiles</string> +       </property> +       <layout class="QVBoxLayout" name="verticalLayout_4"> +        <item> +         <widget class="QWidget" name="player_1" native="true"> +          <layout class="QHBoxLayout" name="input_profile_layout_1"> +           <property name="leftMargin"> +            <number>0</number> +           </property> +           <property name="topMargin"> +            <number>0</number> +           </property> +           <property name="rightMargin"> +            <number>0</number> +           </property> +           <property name="bottomMargin"> +            <number>0</number> +           </property> +           <item> +            <widget class="QLabel" name="label_player_1"> +             <property name="text"> +              <string>Player 1 Profile</string> +             </property> +            </widget> +           </item> +           <item> +            <widget class="QComboBox" name="profile_player_1"> +             <property name="sizePolicy"> +              <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> +               <horstretch>0</horstretch> +               <verstretch>0</verstretch> +              </sizepolicy> +             </property> +            </widget> +           </item> +          </layout> +         </widget> +        </item> +        <item> +         <widget class="QWidget" name="player_2" native="true"> +          <layout class="QHBoxLayout" name="input_profile_layout_2"> +           <property name="leftMargin"> +            <number>0</number> +           </property> +           <property name="topMargin"> +            <number>0</number> +           </property> +           <property name="rightMargin"> +            <number>0</number> +           </property> +           <property name="bottomMargin"> +            <number>0</number> +           </property> +           <item> +            <widget class="QLabel" name="label_player_2"> +             <property name="text"> +              <string>Player 2 Profile</string> +             </property> +            </widget> +           </item> +           <item> +            <widget class="QComboBox" name="profile_player_2"> +             <property name="sizePolicy"> +              <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> +               <horstretch>0</horstretch> +               <verstretch>0</verstretch> +              </sizepolicy> +             </property> +            </widget> +           </item> +          </layout> +         </widget> +        </item> +        <item> +         <widget class="QWidget" name="player_3" native="true"> +          <layout class="QHBoxLayout" name="input_profile_layout_3"> +           <property name="leftMargin"> +            <number>0</number> +           </property> +           <property name="topMargin"> +            <number>0</number> +           </property> +           <property name="rightMargin"> +            <number>0</number> +           </property> +           <property name="bottomMargin"> +            <number>0</number> +           </property> +           <item> +            <widget class="QLabel" name="label_player_3"> +             <property name="text"> +              <string>Player 3 Profile</string> +             </property> +            </widget> +           </item> +           <item> +            <widget class="QComboBox" name="profile_player_3"> +             <property name="sizePolicy"> +              <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> +               <horstretch>0</horstretch> +               <verstretch>0</verstretch> +              </sizepolicy> +             </property> +            </widget> +           </item> +          </layout> +         </widget> +        </item> +        <item> +         <widget class="QWidget" name="player_4" native="true"> +          <layout class="QHBoxLayout" name="input_profile_layout_4"> +           <property name="leftMargin"> +            <number>0</number> +           </property> +           <property name="topMargin"> +            <number>0</number> +           </property> +           <property name="rightMargin"> +            <number>0</number> +           </property> +           <property name="bottomMargin"> +            <number>0</number> +           </property> +           <item> +            <widget class="QLabel" name="label_player_4"> +             <property name="text"> +              <string>Player 4 Profile</string> +             </property> +            </widget> +           </item> +           <item> +            <widget class="QComboBox" name="profile_player_4"> +             <property name="sizePolicy"> +              <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> +               <horstretch>0</horstretch> +               <verstretch>0</verstretch> +              </sizepolicy> +             </property> +            </widget> +           </item> +          </layout> +         </widget> +        </item> +        <item> +         <widget class="QWidget" name="player_5" native="true"> +          <layout class="QHBoxLayout" name="input_profile_layout_5"> +           <property name="leftMargin"> +            <number>0</number> +           </property> +           <property name="topMargin"> +            <number>0</number> +           </property> +           <property name="rightMargin"> +            <number>0</number> +           </property> +           <property name="bottomMargin"> +            <number>0</number> +           </property> +           <item> +            <widget class="QLabel" name="label_player_5"> +             <property name="text"> +              <string>Player 5 Profile</string> +             </property> +            </widget> +           </item> +           <item> +            <widget class="QComboBox" name="profile_player_5"> +             <property name="sizePolicy"> +              <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> +               <horstretch>0</horstretch> +               <verstretch>0</verstretch> +              </sizepolicy> +             </property> +            </widget> +           </item> +          </layout> +         </widget> +        </item> +        <item> +         <widget class="QWidget" name="player_6" native="true"> +          <layout class="QHBoxLayout" name="input_profile_layout_6"> +           <property name="leftMargin"> +            <number>0</number> +           </property> +           <property name="topMargin"> +            <number>0</number> +           </property> +           <property name="rightMargin"> +            <number>0</number> +           </property> +           <property name="bottomMargin"> +            <number>0</number> +           </property> +           <item> +            <widget class="QLabel" name="label_player_6"> +             <property name="text"> +              <string>Player 6 Profile</string> +             </property> +            </widget> +           </item> +           <item> +            <widget class="QComboBox" name="profile_player_6"> +             <property name="sizePolicy"> +              <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> +               <horstretch>0</horstretch> +               <verstretch>0</verstretch> +              </sizepolicy> +             </property> +            </widget> +           </item> +          </layout> +         </widget> +        </item> +        <item> +         <widget class="QWidget" name="player_7" native="true"> +          <layout class="QHBoxLayout" name="input_profile_layout_7"> +           <property name="leftMargin"> +            <number>0</number> +           </property> +           <property name="topMargin"> +            <number>0</number> +           </property> +           <property name="rightMargin"> +            <number>0</number> +           </property> +           <property name="bottomMargin"> +            <number>0</number> +           </property> +           <item> +            <widget class="QLabel" name="label_player_7"> +             <property name="text"> +              <string>Player 7 Profile</string> +             </property> +            </widget> +           </item> +           <item> +            <widget class="QComboBox" name="profile_player_7"> +             <property name="sizePolicy"> +              <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> +               <horstretch>0</horstretch> +               <verstretch>0</verstretch> +              </sizepolicy> +             </property> +            </widget> +           </item> +          </layout> +         </widget> +        </item> +        <item> +         <widget class="QWidget" name="player_8" native="true"> +          <layout class="QHBoxLayout" name="input_profile_layout_8"> +           <property name="leftMargin"> +            <number>0</number> +           </property> +           <property name="topMargin"> +            <number>0</number> +           </property> +           <property name="rightMargin"> +            <number>0</number> +           </property> +           <property name="bottomMargin"> +            <number>0</number> +           </property> +           <item> +            <widget class="QLabel" name="label_player_8"> +             <property name="text"> +              <string>Player 8 Profile</string> +             </property> +            </widget> +           </item> +           <item> +            <widget class="QComboBox" name="profile_player_8"> +             <property name="sizePolicy"> +              <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> +               <horstretch>0</horstretch> +               <verstretch>0</verstretch> +              </sizepolicy> +             </property> +            </widget> +           </item> +          </layout> +         </widget> +        </item> +       </layout> +      </widget> +     </item> +    </layout> +   </item> +   <item> +    <spacer name="verticalSpacer"> +     <property name="orientation"> +      <enum>Qt::Vertical</enum> +     </property> +     <property name="sizeHint" stdset="0"> +      <size> +       <width>20</width> +       <height>40</height> +      </size> +     </property> +    </spacer> +   </item> +  </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/src/yuzu/configuration/configure_input_player.cpp b/src/yuzu/configuration/configure_input_player.cpp index 9e5a40fe7..ed21f4b92 100644 --- a/src/yuzu/configuration/configure_input_player.cpp +++ b/src/yuzu/configuration/configure_input_player.cpp @@ -1553,6 +1553,7 @@ void ConfigureInputPlayer::LoadProfile() {  }  void ConfigureInputPlayer::SaveProfile() { +    static constexpr size_t HANDHELD_INDEX = 8;      const QString profile_name = ui->comboProfiles->itemText(ui->comboProfiles->currentIndex());      if (profile_name.isEmpty()) { @@ -1561,7 +1562,12 @@ void ConfigureInputPlayer::SaveProfile() {      ApplyConfiguration(); -    if (!profiles->SaveProfile(profile_name.toStdString(), player_index)) { +    // When we're in handheld mode, only the handheld emulated controller bindings are updated +    const bool is_handheld = player_index == 0 && emulated_controller->GetNpadIdType() == +                                                      Core::HID::NpadIdType::Handheld; +    const auto profile_player_index = is_handheld ? HANDHELD_INDEX : player_index; + +    if (!profiles->SaveProfile(profile_name.toStdString(), profile_player_index)) {          QMessageBox::critical(this, tr("Save Input Profile"),                                tr("Failed to save the input profile \"%1\"").arg(profile_name));          UpdateInputProfiles(); diff --git a/src/yuzu/configuration/configure_input_player.h b/src/yuzu/configuration/configure_input_player.h index 79434fdd8..26f60d121 100644 --- a/src/yuzu/configuration/configure_input_player.h +++ b/src/yuzu/configuration/configure_input_player.h @@ -38,7 +38,7 @@ enum class InputType;  namespace Ui {  class ConfigureInputPlayer; -} +} // namespace Ui  namespace Core::HID {  class HIDCore; diff --git a/src/yuzu/configuration/configure_per_game.cpp b/src/yuzu/configuration/configure_per_game.cpp index c3cb8f61d..93db47cfd 100644 --- a/src/yuzu/configuration/configure_per_game.cpp +++ b/src/yuzu/configuration/configure_per_game.cpp @@ -28,7 +28,7 @@  #include "yuzu/configuration/configure_general.h"  #include "yuzu/configuration/configure_graphics.h"  #include "yuzu/configuration/configure_graphics_advanced.h" -#include "yuzu/configuration/configure_input.h" +#include "yuzu/configuration/configure_input_per_game.h"  #include "yuzu/configuration/configure_per_game.h"  #include "yuzu/configuration/configure_per_game_addons.h"  #include "yuzu/configuration/configure_system.h" @@ -50,6 +50,7 @@ ConfigurePerGame::ConfigurePerGame(QWidget* parent, u64 title_id_, const std::st      general_tab = std::make_unique<ConfigureGeneral>(system_, this);      graphics_tab = std::make_unique<ConfigureGraphics>(system_, this);      graphics_advanced_tab = std::make_unique<ConfigureGraphicsAdvanced>(system_, this); +    input_tab = std::make_unique<ConfigureInputPerGame>(system_, game_config.get(), this);      system_tab = std::make_unique<ConfigureSystem>(system_, this);      ui->setupUi(this); @@ -61,6 +62,7 @@ ConfigurePerGame::ConfigurePerGame(QWidget* parent, u64 title_id_, const std::st      ui->tabWidget->addTab(graphics_tab.get(), tr("Graphics"));      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"));      setFocusPolicy(Qt::ClickFocus);      setWindowTitle(tr("Properties")); @@ -91,6 +93,7 @@ void ConfigurePerGame::ApplyConfiguration() {      graphics_tab->ApplyConfiguration();      graphics_advanced_tab->ApplyConfiguration();      audio_tab->ApplyConfiguration(); +    input_tab->ApplyConfiguration();      system.ApplySettings();      Settings::LogSettings(); diff --git a/src/yuzu/configuration/configure_per_game.h b/src/yuzu/configuration/configure_per_game.h index 17a98a0f3..4ecc43541 100644 --- a/src/yuzu/configuration/configure_per_game.h +++ b/src/yuzu/configuration/configure_per_game.h @@ -16,12 +16,17 @@ namespace Core {  class System;  } +namespace InputCommon { +class InputSubsystem; +} +  class ConfigurePerGameAddons;  class ConfigureAudio;  class ConfigureCpu;  class ConfigureGeneral;  class ConfigureGraphics;  class ConfigureGraphicsAdvanced; +class ConfigureInputPerGame;  class ConfigureSystem;  class QGraphicsScene; @@ -72,5 +77,6 @@ private:      std::unique_ptr<ConfigureGeneral> general_tab;      std::unique_ptr<ConfigureGraphics> graphics_tab;      std::unique_ptr<ConfigureGraphicsAdvanced> graphics_advanced_tab; +    std::unique_ptr<ConfigureInputPerGame> input_tab;      std::unique_ptr<ConfigureSystem> system_tab;  }; diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index c21153560..c0afb2e5f 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -126,6 +126,7 @@ static FileSys::VirtualFile VfsDirectoryCreateFileWrapper(const FileSys::Virtual  #include "yuzu/compatibility_list.h"  #include "yuzu/configuration/config.h"  #include "yuzu/configuration/configure_dialog.h" +#include "yuzu/configuration/configure_input_per_game.h"  #include "yuzu/debugger/console.h"  #include "yuzu/debugger/controller.h"  #include "yuzu/debugger/profiler.h" @@ -1012,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); @@ -1676,6 +1659,11 @@ void GMainWindow::BootGame(const QString& filename, u64 program_id, std::size_t      LOG_INFO(Frontend, "yuzu starting...");      StoreRecentFile(filename); // Put the filename on top of the list +    // Save configurations +    UpdateUISettings(); +    game_list->SaveInterfaceLayout(); +    config->Save(); +      u64 title_id{0};      last_filename_booted = filename; @@ -1692,14 +1680,10 @@ void GMainWindow::BootGame(const QString& filename, u64 program_id, std::size_t                                            ? Common::FS::PathToUTF8String(file_path.filename())                                            : fmt::format("{:016X}", title_id);          Config per_game_config(config_file_name, Config::ConfigType::PerGameConfig); +        system->HIDCore().ReloadInputDevices();          system->ApplySettings();      } -    // Save configurations -    UpdateUISettings(); -    game_list->SaveInterfaceLayout(); -    config->Save(); -      Settings::LogSettings();      if (UISettings::values.select_user_on_boot) { @@ -2820,6 +2804,7 @@ void GMainWindow::OnStopGame() {      ShutdownGame();      Settings::RestoreGlobalState(system->IsPoweredOn()); +    system->HIDCore().ReloadInputDevices();      UpdateStatusButtons();  } @@ -2850,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(); @@ -2876,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) { @@ -3253,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()); @@ -3281,6 +3284,7 @@ void GMainWindow::OpenPerGameConfiguration(u64 title_id, const std::string& file      // Do not cause the global config to write local settings into the config file      const bool is_powered_on = system->IsPoweredOn();      Settings::RestoreGlobalState(is_powered_on); +    system->HIDCore().ReloadInputDevices();      UISettings::values.configuration_applied = false; @@ -3573,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) { @@ -3618,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(); @@ -3748,6 +3768,7 @@ void GMainWindow::OnCoreError(Core::SystemResultStatus result, std::string detai              ShutdownGame();              Settings::RestoreGlobalState(system->IsPoweredOn()); +            system->HIDCore().ReloadInputDevices();              UpdateStatusButtons();          }      } else { @@ -3899,18 +3920,19 @@ void GMainWindow::closeEvent(QCloseEvent* event) {      // Unload controllers early      controller_dialog->UnloadController();      game_list->UnloadController(); -    system->HIDCore().UnloadInputDevices();      // Shutdown session if the emu thread is active...      if (emu_thread != nullptr) {          ShutdownGame();          Settings::RestoreGlobalState(system->IsPoweredOn()); +        system->HIDCore().ReloadInputDevices();          UpdateStatusButtons();      }      render_window->close();      multiplayer_state->Close(); +    system->HIDCore().UnloadInputDevices();      system->GetRoomNetwork().Shutdown();      QWidget::closeEvent(event); diff --git a/src/yuzu/main.h b/src/yuzu/main.h index 4f9c3b450..62d629973 100644 --- a/src/yuzu/main.h +++ b/src/yuzu/main.h @@ -307,6 +307,7 @@ private slots:      void OnTasStartStop();      void OnTasRecord();      void OnTasReset(); +    void OnToggleGraphicsAPI();      void OnToggleDockedMode();      void OnToggleGpuAccuracy();      void OnToggleAdaptingFilter(); @@ -347,6 +348,7 @@ private:      void UpdateWindowTitle(std::string_view title_name = {}, std::string_view title_version = {},                             std::string_view gpu_vendor = {});      void UpdateDockedButton(); +    void UpdateAPIText();      void UpdateFilterText();      void UpdateAAText();      void UpdateStatusBar(); diff --git a/src/yuzu/multiplayer/chat_room.h b/src/yuzu/multiplayer/chat_room.h index 01c70fad0..dd71ea4cd 100644 --- a/src/yuzu/multiplayer/chat_room.h +++ b/src/yuzu/multiplayer/chat_room.h @@ -4,6 +4,7 @@  #pragma once  #include <memory> +#include <unordered_map>  #include <unordered_set>  #include <QDialog>  #include <QSortFilterProxyModel> diff --git a/src/yuzu/precompiled_headers.h b/src/yuzu/precompiled_headers.h new file mode 100644 index 000000000..aabae730b --- /dev/null +++ b/src/yuzu/precompiled_headers.h @@ -0,0 +1,6 @@ +// SPDX-FileCopyrightText: 2022 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include "common/common_precompiled_headers.h" diff --git a/src/yuzu/startup_checks.cpp b/src/yuzu/startup_checks.cpp index ccdcf10fa..563818362 100644 --- a/src/yuzu/startup_checks.cpp +++ b/src/yuzu/startup_checks.cpp @@ -27,7 +27,7 @@ void CheckVulkan() {          Vulkan::vk::InstanceDispatch dld;          const Common::DynamicLibrary library = Vulkan::OpenLibrary();          const Vulkan::vk::Instance instance = -            Vulkan::CreateInstance(library, dld, VK_API_VERSION_1_0); +            Vulkan::CreateInstance(library, dld, VK_API_VERSION_1_1);      } catch (const Vulkan::vk::Exception& exception) {          fmt::print(stderr, "Failed to initialize Vulkan: {}\n", exception.what()); | 
