summaryrefslogtreecommitdiff
path: root/src/yuzu
diff options
context:
space:
mode:
Diffstat (limited to 'src/yuzu')
-rw-r--r--src/yuzu/CMakeLists.txt94
-rw-r--r--src/yuzu/Info.plist6
-rw-r--r--src/yuzu/about_dialog.cpp11
-rw-r--r--src/yuzu/about_dialog.h5
-rw-r--r--src/yuzu/aboutdialog.ui23
-rw-r--r--src/yuzu/applets/qt_controller.cpp12
-rw-r--r--src/yuzu/applets/qt_controller.h5
-rw-r--r--src/yuzu/applets/qt_error.cpp11
-rw-r--r--src/yuzu/applets/qt_error.h11
-rw-r--r--src/yuzu/applets/qt_profile_select.cpp7
-rw-r--r--src/yuzu/applets/qt_profile_select.h7
-rw-r--r--src/yuzu/applets/qt_software_keyboard.cpp71
-rw-r--r--src/yuzu/applets/qt_software_keyboard.h7
-rw-r--r--src/yuzu/applets/qt_software_keyboard.ui38
-rw-r--r--src/yuzu/applets/qt_web_browser.cpp27
-rw-r--r--src/yuzu/applets/qt_web_browser.h6
-rw-r--r--src/yuzu/applets/qt_web_browser_scripts.h5
-rw-r--r--src/yuzu/bootmanager.cpp185
-rw-r--r--src/yuzu/bootmanager.h46
-rw-r--r--src/yuzu/compatdb.cpp5
-rw-r--r--src/yuzu/compatdb.h5
-rw-r--r--src/yuzu/compatdb.ui2
-rw-r--r--src/yuzu/compatibility_list.cpp5
-rw-r--r--src/yuzu/compatibility_list.h5
-rw-r--r--src/yuzu/configuration/config.cpp223
-rw-r--r--src/yuzu/configuration/config.h32
-rw-r--r--src/yuzu/configuration/configuration_shared.cpp12
-rw-r--r--src/yuzu/configuration/configuration_shared.h22
-rw-r--r--src/yuzu/configuration/configure_audio.cpp102
-rw-r--r--src/yuzu/configuration/configure_audio.h9
-rw-r--r--src/yuzu/configuration/configure_audio.ui32
-rw-r--r--src/yuzu/configuration/configure_camera.cpp156
-rw-r--r--src/yuzu/configuration/configure_camera.h54
-rw-r--r--src/yuzu/configuration/configure_camera.ui170
-rw-r--r--src/yuzu/configuration/configure_cpu.cpp18
-rw-r--r--src/yuzu/configuration/configure_cpu.h7
-rw-r--r--src/yuzu/configuration/configure_cpu.ui17
-rw-r--r--src/yuzu/configuration/configure_cpu_debug.cpp17
-rw-r--r--src/yuzu/configuration/configure_cpu_debug.h5
-rw-r--r--src/yuzu/configuration/configure_cpu_debug.ui29
-rw-r--r--src/yuzu/configuration/configure_debug.cpp50
-rw-r--r--src/yuzu/configuration/configure_debug.h11
-rw-r--r--src/yuzu/configuration/configure_debug.ui192
-rw-r--r--src/yuzu/configuration/configure_debug_controller.cpp5
-rw-r--r--src/yuzu/configuration/configure_debug_controller.h5
-rw-r--r--src/yuzu/configuration/configure_debug_tab.cpp5
-rw-r--r--src/yuzu/configuration/configure_debug_tab.h5
-rw-r--r--src/yuzu/configuration/configure_dialog.cpp24
-rw-r--r--src/yuzu/configuration/configure_dialog.h10
-rw-r--r--src/yuzu/configuration/configure_filesystem.cpp5
-rw-r--r--src/yuzu/configuration/configure_filesystem.h5
-rw-r--r--src/yuzu/configuration/configure_general.cpp41
-rw-r--r--src/yuzu/configuration/configure_general.h6
-rw-r--r--src/yuzu/configuration/configure_general.ui88
-rw-r--r--src/yuzu/configuration/configure_graphics.cpp15
-rw-r--r--src/yuzu/configuration/configure_graphics.h5
-rw-r--r--src/yuzu/configuration/configure_graphics.ui84
-rw-r--r--src/yuzu/configuration/configure_graphics_advanced.cpp13
-rw-r--r--src/yuzu/configuration/configure_graphics_advanced.h6
-rw-r--r--src/yuzu/configuration/configure_graphics_advanced.ui12
-rw-r--r--src/yuzu/configuration/configure_hotkeys.cpp34
-rw-r--r--src/yuzu/configuration/configure_hotkeys.h5
-rw-r--r--src/yuzu/configuration/configure_input.cpp20
-rw-r--r--src/yuzu/configuration/configure_input.h5
-rw-r--r--src/yuzu/configuration/configure_input.ui2
-rw-r--r--src/yuzu/configuration/configure_input_advanced.cpp17
-rw-r--r--src/yuzu/configuration/configure_input_advanced.h7
-rw-r--r--src/yuzu/configuration/configure_input_advanced.ui28
-rw-r--r--src/yuzu/configuration/configure_input_player.cpp179
-rw-r--r--src/yuzu/configuration/configure_input_player.h5
-rw-r--r--src/yuzu/configuration/configure_input_player.ui8
-rw-r--r--src/yuzu/configuration/configure_input_player_widget.cpp5
-rw-r--r--src/yuzu/configuration/configure_input_player_widget.h5
-rw-r--r--src/yuzu/configuration/configure_input_profile_dialog.cpp5
-rw-r--r--src/yuzu/configuration/configure_input_profile_dialog.h5
-rw-r--r--src/yuzu/configuration/configure_motion_touch.cpp12
-rw-r--r--src/yuzu/configuration/configure_motion_touch.h6
-rw-r--r--src/yuzu/configuration/configure_motion_touch.ui19
-rw-r--r--src/yuzu/configuration/configure_network.cpp18
-rw-r--r--src/yuzu/configuration/configure_network.h9
-rw-r--r--src/yuzu/configuration/configure_per_game.cpp24
-rw-r--r--src/yuzu/configuration/configure_per_game.h10
-rw-r--r--src/yuzu/configuration/configure_per_game_addons.cpp16
-rw-r--r--src/yuzu/configuration/configure_per_game_addons.h7
-rw-r--r--src/yuzu/configuration/configure_profile_manager.cpp7
-rw-r--r--src/yuzu/configuration/configure_profile_manager.h5
-rw-r--r--src/yuzu/configuration/configure_ringcon.cpp423
-rw-r--r--src/yuzu/configuration/configure_ringcon.h84
-rw-r--r--src/yuzu/configuration/configure_ringcon.ui278
-rw-r--r--src/yuzu/configuration/configure_system.cpp13
-rw-r--r--src/yuzu/configuration/configure_system.h6
-rw-r--r--src/yuzu/configuration/configure_system.ui3
-rw-r--r--src/yuzu/configuration/configure_tas.cpp5
-rw-r--r--src/yuzu/configuration/configure_tas.h7
-rw-r--r--src/yuzu/configuration/configure_tas.ui3
-rw-r--r--src/yuzu/configuration/configure_touch_from_button.cpp13
-rw-r--r--src/yuzu/configuration/configure_touch_from_button.h7
-rw-r--r--src/yuzu/configuration/configure_touch_widget.h5
-rw-r--r--src/yuzu/configuration/configure_touchscreen_advanced.cpp5
-rw-r--r--src/yuzu/configuration/configure_touchscreen_advanced.h5
-rw-r--r--src/yuzu/configuration/configure_ui.cpp79
-rw-r--r--src/yuzu/configuration/configure_ui.h5
-rw-r--r--src/yuzu/configuration/configure_vibration.cpp11
-rw-r--r--src/yuzu/configuration/configure_vibration.h5
-rw-r--r--src/yuzu/configuration/configure_web.cpp31
-rw-r--r--src/yuzu/configuration/configure_web.h6
-rw-r--r--src/yuzu/configuration/configure_web.ui10
-rw-r--r--src/yuzu/configuration/input_profiles.cpp16
-rw-r--r--src/yuzu/configuration/input_profiles.h10
-rw-r--r--src/yuzu/debugger/console.cpp6
-rw-r--r--src/yuzu/debugger/console.h5
-rw-r--r--src/yuzu/debugger/controller.cpp5
-rw-r--r--src/yuzu/debugger/controller.h5
-rw-r--r--src/yuzu/debugger/profiler.cpp5
-rw-r--r--src/yuzu/debugger/profiler.h5
-rw-r--r--src/yuzu/debugger/wait_tree.cpp23
-rw-r--r--src/yuzu/debugger/wait_tree.h14
-rw-r--r--src/yuzu/discord.h5
-rw-r--r--src/yuzu/discord_impl.cpp5
-rw-r--r--src/yuzu/discord_impl.h5
-rw-r--r--src/yuzu/game_list.cpp83
-rw-r--r--src/yuzu/game_list.h28
-rw-r--r--src/yuzu/game_list_p.h23
-rw-r--r--src/yuzu/game_list_worker.cpp18
-rw-r--r--src/yuzu/game_list_worker.h17
-rw-r--r--src/yuzu/hotkeys.cpp6
-rw-r--r--src/yuzu/hotkeys.h5
-rw-r--r--src/yuzu/install_dialog.cpp6
-rw-r--r--src/yuzu/install_dialog.h5
-rw-r--r--src/yuzu/loading_screen.cpp18
-rw-r--r--src/yuzu/loading_screen.h8
-rw-r--r--src/yuzu/main.cpp647
-rw-r--r--src/yuzu/main.h46
-rw-r--r--src/yuzu/main.ui54
-rw-r--r--src/yuzu/mini_dump.cpp202
-rw-r--r--src/yuzu/mini_dump.h19
-rw-r--r--src/yuzu/multiplayer/chat_room.cpp508
-rw-r--r--src/yuzu/multiplayer/chat_room.h75
-rw-r--r--src/yuzu/multiplayer/chat_room.ui59
-rw-r--r--src/yuzu/multiplayer/client_room.cpp115
-rw-r--r--src/yuzu/multiplayer/client_room.h39
-rw-r--r--src/yuzu/multiplayer/client_room.ui80
-rw-r--r--src/yuzu/multiplayer/direct_connect.cpp143
-rw-r--r--src/yuzu/multiplayer/direct_connect.h49
-rw-r--r--src/yuzu/multiplayer/direct_connect.ui168
-rw-r--r--src/yuzu/multiplayer/host_room.cpp260
-rw-r--r--src/yuzu/multiplayer/host_room.h80
-rw-r--r--src/yuzu/multiplayer/host_room.ui207
-rw-r--r--src/yuzu/multiplayer/lobby.cpp410
-rw-r--r--src/yuzu/multiplayer/lobby.h141
-rw-r--r--src/yuzu/multiplayer/lobby.ui123
-rw-r--r--src/yuzu/multiplayer/lobby_p.h244
-rw-r--r--src/yuzu/multiplayer/message.cpp85
-rw-r--r--src/yuzu/multiplayer/message.h72
-rw-r--r--src/yuzu/multiplayer/moderation_dialog.cpp112
-rw-r--r--src/yuzu/multiplayer/moderation_dialog.h43
-rw-r--r--src/yuzu/multiplayer/moderation_dialog.ui84
-rw-r--r--src/yuzu/multiplayer/state.cpp336
-rw-r--r--src/yuzu/multiplayer/state.h111
-rw-r--r--src/yuzu/multiplayer/validation.h48
-rw-r--r--src/yuzu/startup_checks.cpp158
-rw-r--r--src/yuzu/startup_checks.h20
-rw-r--r--src/yuzu/uisettings.cpp13
-rw-r--r--src/yuzu/uisettings.h70
-rw-r--r--src/yuzu/util/clickable_label.cpp11
-rw-r--r--src/yuzu/util/clickable_label.h21
-rw-r--r--src/yuzu/util/controller_navigation.cpp7
-rw-r--r--src/yuzu/util/controller_navigation.h5
-rw-r--r--src/yuzu/util/limitable_input_dialog.cpp5
-rw-r--r--src/yuzu/util/limitable_input_dialog.h5
-rw-r--r--src/yuzu/util/overlay_dialog.cpp5
-rw-r--r--src/yuzu/util/overlay_dialog.h6
-rw-r--r--src/yuzu/util/sequence_dialog/sequence_dialog.cpp5
-rw-r--r--src/yuzu/util/sequence_dialog/sequence_dialog.h5
-rw-r--r--src/yuzu/util/url_request_interceptor.cpp5
-rw-r--r--src/yuzu/util/url_request_interceptor.h5
-rw-r--r--src/yuzu/util/util.cpp5
-rw-r--r--src/yuzu/util/util.h5
-rw-r--r--src/yuzu/yuzu.qrc5
-rw-r--r--src/yuzu/yuzu.rc3
180 files changed, 7596 insertions, 1212 deletions
diff --git a/src/yuzu/CMakeLists.txt b/src/yuzu/CMakeLists.txt
index 30902101d..29d506c47 100644
--- a/src/yuzu/CMakeLists.txt
+++ b/src/yuzu/CMakeLists.txt
@@ -1,3 +1,6 @@
+# SPDX-FileCopyrightText: 2018 yuzu Emulator Project
+# SPDX-License-Identifier: GPL-2.0-or-later
+
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
@@ -41,6 +44,9 @@ add_executable(yuzu
configuration/configure_audio.cpp
configuration/configure_audio.h
configuration/configure_audio.ui
+ configuration/configure_camera.cpp
+ configuration/configure_camera.h
+ configuration/configure_camera.ui
configuration/configure_cpu.cpp
configuration/configure_cpu.h
configuration/configure_cpu.ui
@@ -99,6 +105,9 @@ add_executable(yuzu
configuration/configure_profile_manager.cpp
configuration/configure_profile_manager.h
configuration/configure_profile_manager.ui
+ configuration/configure_ringcon.cpp
+ configuration/configure_ringcon.h
+ configuration/configure_ringcon.ui
configuration/configure_network.cpp
configuration/configure_network.h
configuration/configure_network.ui
@@ -150,8 +159,36 @@ add_executable(yuzu
main.cpp
main.h
main.ui
+ multiplayer/chat_room.cpp
+ multiplayer/chat_room.h
+ multiplayer/chat_room.ui
+ multiplayer/client_room.h
+ multiplayer/client_room.cpp
+ multiplayer/client_room.ui
+ multiplayer/direct_connect.cpp
+ multiplayer/direct_connect.h
+ multiplayer/direct_connect.ui
+ multiplayer/host_room.cpp
+ multiplayer/host_room.h
+ multiplayer/host_room.ui
+ multiplayer/lobby.cpp
+ multiplayer/lobby.h
+ multiplayer/lobby.ui
+ multiplayer/lobby_p.h
+ multiplayer/message.cpp
+ multiplayer/message.h
+ multiplayer/moderation_dialog.cpp
+ multiplayer/moderation_dialog.h
+ multiplayer/moderation_dialog.ui
+ multiplayer/state.cpp
+ multiplayer/state.h
+ multiplayer/validation.h
+ startup_checks.cpp
+ startup_checks.h
uisettings.cpp
uisettings.h
+ util/clickable_label.cpp
+ util/clickable_label.h
util/controller_navigation.cpp
util/controller_navigation.h
util/limitable_input_dialog.cpp
@@ -171,6 +208,16 @@ add_executable(yuzu
yuzu.rc
)
+if (WIN32 AND YUZU_CRASH_DUMPS)
+ target_sources(yuzu PRIVATE
+ mini_dump.cpp
+ mini_dump.h
+ )
+
+ target_link_libraries(yuzu PRIVATE ${DBGHELP_LIBRARY})
+ target_compile_definitions(yuzu PRIVATE -DYUZU_DBGHELP)
+endif()
+
file(GLOB COMPAT_LIST
${PROJECT_BINARY_DIR}/dist/compatibility_list/compatibility_list.qrc
${PROJECT_BINARY_DIR}/dist/compatibility_list/compatibility_list.json)
@@ -184,7 +231,10 @@ if (ENABLE_QT_TRANSLATION)
# Update source TS file if enabled
if (GENERATE_QT_TRANSLATION)
get_target_property(SRCS yuzu SOURCES)
- qt5_create_translation(QM_FILES
+ # these calls to qt_create_translation also creates a rule to generate en.qm which conflicts with providing english plurals
+ # so we have to set a OUTPUT_LOCATION so that we don't have multiple rules to generate en.qm
+ set_source_files_properties(${YUZU_QT_LANGUAGES}/en.ts PROPERTIES OUTPUT_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/translations")
+ qt_create_translation(QM_FILES
${SRCS}
${UIS}
${YUZU_QT_LANGUAGES}/en.ts
@@ -192,7 +242,13 @@ if (ENABLE_QT_TRANSLATION)
-source-language en_US
-target-language en_US
)
- add_custom_target(translation ALL DEPENDS ${YUZU_QT_LANGUAGES}/en.ts)
+
+ # Generate plurals into dist/english_plurals/generated_en.ts so it can be used to revise dist/english_plurals/en.ts
+ set(GENERATED_PLURALS_FILE ${PROJECT_SOURCE_DIR}/dist/english_plurals/generated_en.ts)
+ set_source_files_properties(${GENERATED_PLURALS_FILE} PROPERTIES OUTPUT_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/plurals")
+ qt_create_translation(QM_FILES ${SRCS} ${UIS} ${GENERATED_PLURALS_FILE} OPTIONS -pluralonly -source-language en_US -target-language en_US)
+
+ add_custom_target(translation ALL DEPENDS ${YUZU_QT_LANGUAGES}/en.ts ${GENERATED_PLURALS_FILE})
endif()
# Find all TS files except en.ts
@@ -200,7 +256,10 @@ if (ENABLE_QT_TRANSLATION)
list(REMOVE_ITEM LANGUAGES_TS ${YUZU_QT_LANGUAGES}/en.ts)
# Compile TS files to QM files
- qt5_add_translation(LANGUAGES_QM ${LANGUAGES_TS})
+ qt_add_translation(LANGUAGES_QM ${LANGUAGES_TS})
+
+ # Compile english plurals TS file to en.qm
+ qt_add_translation(LANGUAGES_QM ${PROJECT_SOURCE_DIR}/dist/english_plurals/en.ts)
# Build a QRC file from the QM file list
set(LANGUAGES_QRC ${CMAKE_CURRENT_BINARY_DIR}/languages.qrc)
@@ -212,7 +271,7 @@ if (ENABLE_QT_TRANSLATION)
file(APPEND ${LANGUAGES_QRC} "</qresource></RCC>")
# Add the QRC file to package in all QM files
- qt5_add_resources(LANGUAGES ${LANGUAGES_QRC})
+ qt_add_resources(LANGUAGES ${LANGUAGES_QRC})
else()
set(LANGUAGES)
endif()
@@ -233,18 +292,23 @@ if (APPLE)
set_target_properties(yuzu PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist)
elseif(WIN32)
# compile as a win32 gui application instead of a console application
- target_link_libraries(yuzu PRIVATE Qt5::WinMain)
+ if (QT_VERSION VERSION_GREATER 6)
+ target_link_libraries(yuzu PRIVATE Qt6::EntryPointPrivate)
+ else()
+ target_link_libraries(yuzu PRIVATE Qt5::WinMain)
+ endif()
if(MSVC)
+ target_link_libraries(yuzu PRIVATE version.lib)
set_target_properties(yuzu PROPERTIES LINK_FLAGS_RELEASE "/SUBSYSTEM:WINDOWS")
elseif(MINGW)
- set_target_properties(yuzu PROPERTIES LINK_FLAGS_RELEASE "-mwindows")
+ set_target_properties(yuzu PROPERTIES LINK_FLAGS_RELEASE "-Wl,--subsystem,windows")
endif()
endif()
create_target_directory_groups(yuzu)
-target_link_libraries(yuzu PRIVATE common core input_common video_core)
-target_link_libraries(yuzu PRIVATE Boost::boost glad Qt5::Widgets)
+target_link_libraries(yuzu PRIVATE common core input_common network video_core)
+target_link_libraries(yuzu PRIVATE Boost::boost glad Qt::Widgets Qt::Multimedia)
target_link_libraries(yuzu PRIVATE ${PLATFORM_LIBRARIES} Threads::Threads)
target_include_directories(yuzu PRIVATE ../../externals/Vulkan-Headers/include)
@@ -252,7 +316,7 @@ if (NOT WIN32)
target_include_directories(yuzu PRIVATE ${Qt5Gui_PRIVATE_INCLUDE_DIRS})
endif()
if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
- target_link_libraries(yuzu PRIVATE Qt5::DBus)
+ target_link_libraries(yuzu PRIVATE Qt::DBus)
endif()
target_compile_definitions(yuzu PRIVATE
@@ -287,13 +351,17 @@ if (USE_DISCORD_PRESENCE)
target_compile_definitions(yuzu PRIVATE -DUSE_DISCORD_PRESENCE)
endif()
+if (ENABLE_WEB_SERVICE)
+ target_compile_definitions(yuzu PRIVATE -DENABLE_WEB_SERVICE)
+endif()
+
if (YUZU_USE_QT_WEB_ENGINE)
- target_link_libraries(yuzu PRIVATE Qt5::WebEngineCore Qt5::WebEngineWidgets)
+ target_link_libraries(yuzu PRIVATE Qt::WebEngineCore Qt::WebEngineWidgets)
target_compile_definitions(yuzu PRIVATE -DYUZU_USE_QT_WEB_ENGINE)
endif ()
if(UNIX AND NOT APPLE)
- install(TARGETS yuzu RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}/bin")
+ install(TARGETS yuzu)
endif()
if (YUZU_USE_BUNDLED_QT)
@@ -316,3 +384,7 @@ endif()
if (NOT APPLE)
target_compile_definitions(yuzu PRIVATE HAS_OPENGL)
endif()
+
+if (ARCHITECTURE_x86_64)
+ target_link_libraries(yuzu PRIVATE dynarmic)
+endif()
diff --git a/src/yuzu/Info.plist b/src/yuzu/Info.plist
index 5f1c95d54..0eb377926 100644
--- a/src/yuzu/Info.plist
+++ b/src/yuzu/Info.plist
@@ -1,4 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+SPDX-FileCopyrightText: 2015 Pierre de La Morinerie <kemenaran@gmail.com>
+SPDX-License-Identifier: GPL-2.0-or-later
+-->
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
diff --git a/src/yuzu/about_dialog.cpp b/src/yuzu/about_dialog.cpp
index 04ab4ae21..eeff54359 100644
--- a/src/yuzu/about_dialog.cpp
+++ b/src/yuzu/about_dialog.cpp
@@ -1,6 +1,5 @@
-// Copyright 2018 yuzu Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#include <QIcon>
#include <fmt/format.h>
@@ -20,7 +19,11 @@ AboutDialog::AboutDialog(QWidget* parent)
const auto yuzu_build_version = override_build.empty() ? yuzu_build : override_build;
ui->setupUi(this);
- ui->labelLogo->setPixmap(QIcon::fromTheme(QStringLiteral("yuzu")).pixmap(200));
+ // Try and request the icon from Qt theme (Linux?)
+ const QIcon yuzu_logo = QIcon::fromTheme(QStringLiteral("org.yuzu_emu.yuzu"));
+ if (!yuzu_logo.isNull()) {
+ ui->labelLogo->setPixmap(yuzu_logo.pixmap(200));
+ }
ui->labelBuildInfo->setText(
ui->labelBuildInfo->text().arg(QString::fromStdString(yuzu_build_version),
QString::fromUtf8(Common::g_build_date).left(10)));
diff --git a/src/yuzu/about_dialog.h b/src/yuzu/about_dialog.h
index 18e8c11a7..3c4e71ee6 100644
--- a/src/yuzu/about_dialog.h
+++ b/src/yuzu/about_dialog.h
@@ -1,6 +1,5 @@
-// Copyright 2018 yuzu Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
diff --git a/src/yuzu/aboutdialog.ui b/src/yuzu/aboutdialog.ui
index 27d81cd13..aea82809d 100644
--- a/src/yuzu/aboutdialog.ui
+++ b/src/yuzu/aboutdialog.ui
@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>616</width>
- <height>261</height>
+ <height>294</height>
</rect>
</property>
<property name="windowTitle">
@@ -26,8 +26,20 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
+ <property name="maximumSize">
+ <size>
+ <width>200</width>
+ <height>200</height>
+ </size>
+ </property>
<property name="text">
- <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;img src=&quot;:/icons/yuzu.png&quot;/&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+ <string/>
+ </property>
+ <property name="pixmap">
+ <pixmap resource="../../dist/qt_themes/default/default.qrc">:/icons/default/256x256/yuzu.png</pixmap>
+ </property>
+ <property name="scaledContents">
+ <bool>true</bool>
</property>
</widget>
</item>
@@ -87,7 +99,7 @@
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;&quot;&gt;
-&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:12pt;&quot;&gt;yuzu is an experimental open-source emulator for the Nintendo Switch licensed under GPLv2.0.&lt;/span&gt;&lt;/p&gt;
+&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:12pt;&quot;&gt;yuzu is an experimental open-source emulator for the Nintendo Switch licensed under GPLv3.0+.&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:12pt;&quot;&gt;This software should not be used to play games you have not legally obtained.&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
@@ -115,7 +127,7 @@ p, li { white-space: pre-wrap; }
<item>
<widget class="QLabel" name="labelLinks">
<property name="text">
- <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;a href=&quot;https://yuzu-emu.org/&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#039be5;&quot;&gt;Website&lt;/span&gt;&lt;/a&gt; | &lt;a href=&quot;https://github.com/yuzu-emu&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#039be5;&quot;&gt;Source Code&lt;/span&gt;&lt;/a&gt; | &lt;a href=&quot;https://github.com/yuzu-emu/yuzu/graphs/contributors&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#039be5;&quot;&gt;Contributors&lt;/span&gt;&lt;/a&gt; | &lt;a href=&quot;https://github.com/yuzu-emu/yuzu/blob/master/license.txt&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#039be5;&quot;&gt;License&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+ <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;a href=&quot;https://yuzu-emu.org/&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#039be5;&quot;&gt;Website&lt;/span&gt;&lt;/a&gt; | &lt;a href=&quot;https://github.com/yuzu-emu&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#039be5;&quot;&gt;Source Code&lt;/span&gt;&lt;/a&gt; | &lt;a href=&quot;https://github.com/yuzu-emu/yuzu/graphs/contributors&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#039be5;&quot;&gt;Contributors&lt;/span&gt;&lt;/a&gt; | &lt;a href=&quot;https://github.com/yuzu-emu/yuzu/blob/master/LICENSE.txt&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#039be5;&quot;&gt;License&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
@@ -152,7 +164,8 @@ p, li { white-space: pre-wrap; }
</layout>
</widget>
<resources>
- <include location="../../dist/icons/icons.qrc"/>
+ <include location="../../dist/qt_themes_default/default/default.qrc"/>
+ <include location="../../dist/qt_themes/default/default.qrc"/>
</resources>
<connections>
<connection>
diff --git a/src/yuzu/applets/qt_controller.cpp b/src/yuzu/applets/qt_controller.cpp
index 4104928d1..12efdc216 100644
--- a/src/yuzu/applets/qt_controller.cpp
+++ b/src/yuzu/applets/qt_controller.cpp
@@ -1,12 +1,10 @@
-// Copyright 2020 yuzu Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#include <algorithm>
#include <thread>
#include "common/assert.h"
-#include "common/param_package.h"
#include "common/string_util.h"
#include "core/core.h"
#include "core/hid/emulated_controller.h"
@@ -65,7 +63,7 @@ QtControllerSelectorDialog::QtControllerSelectorDialog(
InputCommon::InputSubsystem* input_subsystem_, Core::System& system_)
: QDialog(parent), ui(std::make_unique<Ui::QtControllerSelectorDialog>()),
parameters(std::move(parameters_)), input_subsystem{input_subsystem_},
- input_profiles(std::make_unique<InputProfiles>(system_)), system{system_} {
+ input_profiles(std::make_unique<InputProfiles>()), system{system_} {
ui->setupUi(this);
player_widgets = {
@@ -293,7 +291,7 @@ bool QtControllerSelectorDialog::CheckIfParametersMet() {
// Here, we check and validate the current configuration against all applicable parameters.
const auto num_connected_players = static_cast<int>(
std::count_if(player_groupboxes.begin(), player_groupboxes.end(),
- [this](const QGroupBox* player) { return player->isChecked(); }));
+ [](const QGroupBox* player) { return player->isChecked(); }));
const auto min_supported_players = parameters.enable_single_mode ? 1 : parameters.min_players;
const auto max_supported_players = parameters.enable_single_mode ? 1 : parameters.max_players;
@@ -633,7 +631,7 @@ void QtControllerSelectorDialog::DisableUnsupportedPlayers() {
switch (max_supported_players) {
case 0:
default:
- UNREACHABLE();
+ ASSERT(false);
return;
case 1:
ui->widgetSpacer->hide();
diff --git a/src/yuzu/applets/qt_controller.h b/src/yuzu/applets/qt_controller.h
index 7ab9ced3d..cf948d2b5 100644
--- a/src/yuzu/applets/qt_controller.h
+++ b/src/yuzu/applets/qt_controller.h
@@ -1,6 +1,5 @@
-// Copyright 2020 yuzu Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
diff --git a/src/yuzu/applets/qt_error.cpp b/src/yuzu/applets/qt_error.cpp
index 879e73660..367d5352d 100644
--- a/src/yuzu/applets/qt_error.cpp
+++ b/src/yuzu/applets/qt_error.cpp
@@ -1,6 +1,5 @@
-// Copyright 2019 yuzu Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#include <QDateTime>
#include "yuzu/applets/qt_error.h"
@@ -15,7 +14,7 @@ QtErrorDisplay::QtErrorDisplay(GMainWindow& parent) {
QtErrorDisplay::~QtErrorDisplay() = default;
-void QtErrorDisplay::ShowError(ResultCode error, std::function<void()> finished) const {
+void QtErrorDisplay::ShowError(Result error, std::function<void()> finished) const {
callback = std::move(finished);
emit MainWindowDisplayError(
tr("Error Code: %1-%2 (0x%3)")
@@ -25,7 +24,7 @@ void QtErrorDisplay::ShowError(ResultCode error, std::function<void()> finished)
tr("An error has occurred.\nPlease try again or contact the developer of the software."));
}
-void QtErrorDisplay::ShowErrorWithTimestamp(ResultCode error, std::chrono::seconds time,
+void QtErrorDisplay::ShowErrorWithTimestamp(Result error, std::chrono::seconds time,
std::function<void()> finished) const {
callback = std::move(finished);
@@ -41,7 +40,7 @@ void QtErrorDisplay::ShowErrorWithTimestamp(ResultCode error, std::chrono::secon
.arg(date_time.toString(QStringLiteral("h:mm:ss A"))));
}
-void QtErrorDisplay::ShowCustomErrorText(ResultCode error, std::string dialog_text,
+void QtErrorDisplay::ShowCustomErrorText(Result error, std::string dialog_text,
std::string fullscreen_text,
std::function<void()> finished) const {
callback = std::move(finished);
diff --git a/src/yuzu/applets/qt_error.h b/src/yuzu/applets/qt_error.h
index 8bd895a32..eb4107c7e 100644
--- a/src/yuzu/applets/qt_error.h
+++ b/src/yuzu/applets/qt_error.h
@@ -1,6 +1,5 @@
-// Copyright 2019 yuzu Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
@@ -17,10 +16,10 @@ public:
explicit QtErrorDisplay(GMainWindow& parent);
~QtErrorDisplay() override;
- void ShowError(ResultCode error, std::function<void()> finished) const override;
- void ShowErrorWithTimestamp(ResultCode error, std::chrono::seconds time,
+ void ShowError(Result error, std::function<void()> finished) const override;
+ void ShowErrorWithTimestamp(Result error, std::chrono::seconds time,
std::function<void()> finished) const override;
- void ShowCustomErrorText(ResultCode error, std::string dialog_text, std::string fullscreen_text,
+ void ShowCustomErrorText(Result error, std::string dialog_text, std::string fullscreen_text,
std::function<void()> finished) const override;
signals:
diff --git a/src/yuzu/applets/qt_profile_select.cpp b/src/yuzu/applets/qt_profile_select.cpp
index 4cd8f7784..c8bcfb223 100644
--- a/src/yuzu/applets/qt_profile_select.cpp
+++ b/src/yuzu/applets/qt_profile_select.cpp
@@ -1,6 +1,5 @@
-// Copyright 2018 yuzu Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#include <mutex>
#include <QApplication>
@@ -10,6 +9,7 @@
#include <QLineEdit>
#include <QScrollArea>
#include <QStandardItemModel>
+#include <QTreeView>
#include <QVBoxLayout>
#include "common/fs/path_util.h"
#include "common/string_util.h"
@@ -100,6 +100,7 @@ QtProfileSelectionDialog::QtProfileSelectionDialog(Core::HID::HIDCore& hid_core,
}
QKeyEvent* event = new QKeyEvent(QEvent::KeyPress, key, Qt::NoModifier);
QCoreApplication::postEvent(tree_view, event);
+ SelectUser(tree_view->currentIndex());
});
const auto& profiles = profile_manager->GetAllUsers();
diff --git a/src/yuzu/applets/qt_profile_select.h b/src/yuzu/applets/qt_profile_select.h
index 56496ed31..124f2cdbd 100644
--- a/src/yuzu/applets/qt_profile_select.h
+++ b/src/yuzu/applets/qt_profile_select.h
@@ -1,13 +1,11 @@
-// Copyright 2018 yuzu Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include <vector>
#include <QDialog>
#include <QList>
-#include <QTreeView>
#include "core/frontend/applets/profile_select.h"
#include "core/hle/service/acc/profile_manager.h"
@@ -19,6 +17,7 @@ class QLabel;
class QScrollArea;
class QStandardItem;
class QStandardItemModel;
+class QTreeView;
class QVBoxLayout;
namespace Core::HID {
diff --git a/src/yuzu/applets/qt_software_keyboard.cpp b/src/yuzu/applets/qt_software_keyboard.cpp
index c3857fc98..e60506197 100644
--- a/src/yuzu/applets/qt_software_keyboard.cpp
+++ b/src/yuzu/applets/qt_software_keyboard.cpp
@@ -1,6 +1,5 @@
-// Copyright 2021 yuzu Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#include <QCursor>
#include <QKeyEvent>
@@ -214,9 +213,9 @@ QtSoftwareKeyboardDialog::QtSoftwareKeyboardDialog(
ui->button_ok_num,
},
{
- nullptr,
+ ui->button_left_optional_num,
ui->button_0_num,
- nullptr,
+ ui->button_right_optional_num,
ui->button_ok_num,
},
}};
@@ -331,7 +330,9 @@ QtSoftwareKeyboardDialog::QtSoftwareKeyboardDialog(
ui->button_7_num,
ui->button_8_num,
ui->button_9_num,
+ ui->button_left_optional_num,
ui->button_0_num,
+ ui->button_right_optional_num,
};
SetupMouseHover();
@@ -343,6 +344,9 @@ QtSoftwareKeyboardDialog::QtSoftwareKeyboardDialog(
ui->label_header->setText(QString::fromStdU16String(initialize_parameters.header_text));
ui->label_sub->setText(QString::fromStdU16String(initialize_parameters.sub_text));
+ ui->button_left_optional_num->setText(QChar{initialize_parameters.left_optional_symbol_key});
+ ui->button_right_optional_num->setText(QChar{initialize_parameters.right_optional_symbol_key});
+
current_text = initialize_parameters.initial_text;
cursor_position = initialize_parameters.initial_cursor_position;
@@ -412,11 +416,11 @@ void QtSoftwareKeyboardDialog::ShowTextCheckDialog(
break;
}
- auto text = ui->topOSK->currentIndex() == 1
- ? ui->text_edit_osk->toPlainText().toStdU16String()
- : ui->line_edit_osk->text().toStdU16String();
+ const auto text = ui->topOSK->currentIndex() == 1 ? ui->text_edit_osk->toPlainText()
+ : ui->line_edit_osk->text();
+ auto text_str = Common::U16StringFromBuffer(text.utf16(), text.size());
- emit SubmitNormalText(SwkbdResult::Ok, std::move(text), true);
+ emit SubmitNormalText(SwkbdResult::Ok, std::move(text_str), true);
break;
}
}
@@ -563,7 +567,7 @@ void QtSoftwareKeyboardDialog::keyPressEvent(QKeyEvent* event) {
return;
}
- InlineTextInsertString(entered_text.toStdU16String());
+ InlineTextInsertString(Common::U16StringFromBuffer(entered_text.utf16(), entered_text.size()));
}
void QtSoftwareKeyboardDialog::MoveAndResizeWindow(QPoint pos, QSize size) {
@@ -933,6 +937,15 @@ void QtSoftwareKeyboardDialog::DisableKeyboardButtons() {
button->setEnabled(true);
}
}
+
+ const auto enable_left_optional = initialize_parameters.left_optional_symbol_key != '\0';
+ const auto enable_right_optional = initialize_parameters.right_optional_symbol_key != '\0';
+
+ ui->button_left_optional_num->setEnabled(enable_left_optional);
+ ui->button_left_optional_num->setVisible(enable_left_optional);
+
+ ui->button_right_optional_num->setEnabled(enable_right_optional);
+ ui->button_right_optional_num->setVisible(enable_right_optional);
break;
}
}
@@ -1020,7 +1033,10 @@ bool QtSoftwareKeyboardDialog::ValidateInputText(const QString& input_text) {
}
if (bottom_osk_index == BottomOSKIndex::NumberPad &&
- std::any_of(input_text.begin(), input_text.end(), [](QChar c) { return !c.isDigit(); })) {
+ std::any_of(input_text.begin(), input_text.end(), [this](QChar c) {
+ return !c.isDigit() && c != QChar{initialize_parameters.left_optional_symbol_key} &&
+ c != QChar{initialize_parameters.right_optional_symbol_key};
+ })) {
return false;
}
@@ -1120,11 +1136,11 @@ void QtSoftwareKeyboardDialog::NormalKeyboardButtonClicked(QPushButton* button)
}
if (button == ui->button_ok || button == ui->button_ok_shift || button == ui->button_ok_num) {
- auto text = ui->topOSK->currentIndex() == 1
- ? ui->text_edit_osk->toPlainText().toStdU16String()
- : ui->line_edit_osk->text().toStdU16String();
+ const auto text = ui->topOSK->currentIndex() == 1 ? ui->text_edit_osk->toPlainText()
+ : ui->line_edit_osk->text();
+ auto text_str = Common::U16StringFromBuffer(text.utf16(), text.size());
- emit SubmitNormalText(SwkbdResult::Ok, std::move(text));
+ emit SubmitNormalText(SwkbdResult::Ok, std::move(text_str));
return;
}
@@ -1190,7 +1206,8 @@ void QtSoftwareKeyboardDialog::InlineKeyboardButtonClicked(QPushButton* button)
return;
}
- InlineTextInsertString(button->text().toStdU16String());
+ const auto button_text = button->text();
+ InlineTextInsertString(Common::U16StringFromBuffer(button_text.utf16(), button_text.size()));
// Revert the keyboard to lowercase if the shift key is active.
if (bottom_osk_index == BottomOSKIndex::UpperCase && !caps_lock_enabled) {
@@ -1283,11 +1300,11 @@ void QtSoftwareKeyboardDialog::TranslateButtonPress(Core::HID::NpadButton button
if (is_inline) {
emit SubmitInlineText(SwkbdReplyType::DecidedCancel, current_text, cursor_position);
} else {
- auto text = ui->topOSK->currentIndex() == 1
- ? ui->text_edit_osk->toPlainText().toStdU16String()
- : ui->line_edit_osk->text().toStdU16String();
+ const auto text = ui->topOSK->currentIndex() == 1 ? ui->text_edit_osk->toPlainText()
+ : ui->line_edit_osk->text();
+ auto text_str = Common::U16StringFromBuffer(text.utf16(), text.size());
- emit SubmitNormalText(SwkbdResult::Cancel, std::move(text));
+ emit SubmitNormalText(SwkbdResult::Cancel, std::move(text_str));
}
break;
case Core::HID::NpadButton::Y:
@@ -1384,6 +1401,10 @@ void QtSoftwareKeyboardDialog::MoveButtonDirection(Direction direction) {
}
};
+ // Store the initial row and column.
+ const auto initial_row = row;
+ const auto initial_column = column;
+
switch (bottom_osk_index) {
case BottomOSKIndex::LowerCase:
case BottomOSKIndex::UpperCase: {
@@ -1394,6 +1415,11 @@ void QtSoftwareKeyboardDialog::MoveButtonDirection(Direction direction) {
auto* curr_button = keyboard_buttons[index][row][column];
while (!curr_button || !curr_button->isEnabled() || curr_button == prev_button) {
+ // If we returned back to where we started from, break the loop.
+ if (row == initial_row && column == initial_column) {
+ break;
+ }
+
move_direction(NUM_ROWS_NORMAL, NUM_COLUMNS_NORMAL);
curr_button = keyboard_buttons[index][row][column];
}
@@ -1408,6 +1434,11 @@ void QtSoftwareKeyboardDialog::MoveButtonDirection(Direction direction) {
auto* curr_button = numberpad_buttons[row][column];
while (!curr_button || !curr_button->isEnabled() || curr_button == prev_button) {
+ // If we returned back to where we started from, break the loop.
+ if (row == initial_row && column == initial_column) {
+ break;
+ }
+
move_direction(NUM_ROWS_NUMPAD, NUM_COLUMNS_NUMPAD);
curr_button = numberpad_buttons[row][column];
}
diff --git a/src/yuzu/applets/qt_software_keyboard.h b/src/yuzu/applets/qt_software_keyboard.h
index b030cdcf7..35d4ee2ef 100644
--- a/src/yuzu/applets/qt_software_keyboard.h
+++ b/src/yuzu/applets/qt_software_keyboard.h
@@ -1,6 +1,5 @@
-// Copyright 2021 yuzu Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
@@ -212,7 +211,7 @@ private:
std::array<std::array<QPushButton*, NUM_COLUMNS_NUMPAD>, NUM_ROWS_NUMPAD> numberpad_buttons;
// Contains a set of all buttons used in keyboard_buttons and numberpad_buttons.
- std::array<QPushButton*, 110> all_buttons;
+ std::array<QPushButton*, 112> all_buttons;
std::size_t row{0};
std::size_t column{0};
diff --git a/src/yuzu/applets/qt_software_keyboard.ui b/src/yuzu/applets/qt_software_keyboard.ui
index b0a1fcde9..9661cb260 100644
--- a/src/yuzu/applets/qt_software_keyboard.ui
+++ b/src/yuzu/applets/qt_software_keyboard.ui
@@ -3298,6 +3298,24 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
+ <item row="4" column="2">
+ <widget class="QPushButton" name="button_left_optional_num">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
+ <horstretch>1</horstretch>
+ <verstretch>1</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="font">
+ <font>
+ <pointsize>28</pointsize>
+ </font>
+ </property>
+ <property name="text">
+ <string notr="true"></string>
+ </property>
+ </widget>
+ </item>
<item row="4" column="3">
<widget class="QPushButton" name="button_0_num">
<property name="sizePolicy">
@@ -3316,6 +3334,24 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
+ <item row="4" column="4">
+ <widget class="QPushButton" name="button_right_optional_num">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
+ <horstretch>1</horstretch>
+ <verstretch>1</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="font">
+ <font>
+ <pointsize>28</pointsize>
+ </font>
+ </property>
+ <property name="text">
+ <string notr="true"></string>
+ </property>
+ </widget>
+ </item>
<item row="1" column="4">
<widget class="QPushButton" name="button_3_num">
<property name="sizePolicy">
@@ -3494,7 +3530,9 @@ p, li { white-space: pre-wrap; }
<tabstop>button_7_num</tabstop>
<tabstop>button_8_num</tabstop>
<tabstop>button_9_num</tabstop>
+ <tabstop>button_left_optional_num</tabstop>
<tabstop>button_0_num</tabstop>
+ <tabstop>button_right_optional_num</tabstop>
</tabstops>
<resources>
<include location="../../../dist/icons/overlay/overlay.qrc"/>
diff --git a/src/yuzu/applets/qt_web_browser.cpp b/src/yuzu/applets/qt_web_browser.cpp
index cb3c5d826..89bd482e0 100644
--- a/src/yuzu/applets/qt_web_browser.cpp
+++ b/src/yuzu/applets/qt_web_browser.cpp
@@ -1,8 +1,9 @@
-// Copyright 2020 yuzu Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#ifdef YUZU_USE_QT_WEB_ENGINE
+#include <bit>
+
#include <QApplication>
#include <QKeyEvent>
@@ -11,17 +12,15 @@
#include <QWebEngineScriptCollection>
#include <QWebEngineSettings>
#include <QWebEngineUrlScheme>
+
+#include "core/hid/input_interpreter.h"
+#include "yuzu/applets/qt_web_browser_scripts.h"
#endif
#include "common/fs/path_util.h"
-#include "common/param_package.h"
#include "core/core.h"
-#include "core/hid/hid_types.h"
-#include "core/hid/input_interpreter.h"
#include "input_common/drivers/keyboard.h"
-#include "input_common/main.h"
#include "yuzu/applets/qt_web_browser.h"
-#include "yuzu/applets/qt_web_browser_scripts.h"
#include "yuzu/main.h"
#include "yuzu/util/url_request_interceptor.h"
@@ -55,8 +54,8 @@ QtNXWebEngineView::QtNXWebEngineView(QWidget* parent, Core::System& system,
: QWebEngineView(parent), input_subsystem{input_subsystem_},
url_interceptor(std::make_unique<UrlRequestInterceptor>()),
input_interpreter(std::make_unique<InputInterpreter>(system)),
- default_profile{QWebEngineProfile::defaultProfile()},
- global_settings{QWebEngineSettings::globalSettings()} {
+ default_profile{QWebEngineProfile::defaultProfile()}, global_settings{
+ default_profile->settings()} {
default_profile->setPersistentStoragePath(QString::fromStdString(Common::FS::PathToUTF8String(
Common::FS::GetYuzuPath(Common::FS::YuzuPath::YuzuDir) / "qtwebengine")));
@@ -81,7 +80,7 @@ QtNXWebEngineView::QtNXWebEngineView(QWidget* parent, Core::System& system,
default_profile->scripts()->insert(gamepad);
default_profile->scripts()->insert(window_nx);
- default_profile->setRequestInterceptor(url_interceptor.get());
+ default_profile->setUrlRequestInterceptor(url_interceptor.get());
global_settings->setAttribute(QWebEngineSettings::LocalContentCanAccessRemoteUrls, true);
global_settings->setAttribute(QWebEngineSettings::FullScreenSupportEnabled, true);
@@ -214,8 +213,10 @@ template <Core::HID::NpadButton... T>
void QtNXWebEngineView::HandleWindowFooterButtonPressedOnce() {
const auto f = [this](Core::HID::NpadButton button) {
if (input_interpreter->IsButtonPressedOnce(button)) {
+ const auto button_index = std::countr_zero(static_cast<u64>(button));
+
page()->runJavaScript(
- QStringLiteral("yuzu_key_callbacks[%1] == null;").arg(static_cast<u8>(button)),
+ QStringLiteral("yuzu_key_callbacks[%1] == null;").arg(button_index),
[this, button](const QVariant& variant) {
if (variant.toBool()) {
switch (button) {
@@ -239,7 +240,7 @@ void QtNXWebEngineView::HandleWindowFooterButtonPressedOnce() {
page()->runJavaScript(
QStringLiteral("if (yuzu_key_callbacks[%1] != null) { yuzu_key_callbacks[%1](); }")
- .arg(static_cast<u8>(button)));
+ .arg(button_index));
}
};
diff --git a/src/yuzu/applets/qt_web_browser.h b/src/yuzu/applets/qt_web_browser.h
index fa18aecac..043800853 100644
--- a/src/yuzu/applets/qt_web_browser.h
+++ b/src/yuzu/applets/qt_web_browser.h
@@ -1,11 +1,9 @@
-// Copyright 2020 yuzu Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include <atomic>
-#include <memory>
#include <thread>
#include <QObject>
diff --git a/src/yuzu/applets/qt_web_browser_scripts.h b/src/yuzu/applets/qt_web_browser_scripts.h
index c4ba8d40f..f5530c38f 100644
--- a/src/yuzu/applets/qt_web_browser_scripts.h
+++ b/src/yuzu/applets/qt_web_browser_scripts.h
@@ -1,6 +1,5 @@
-// Copyright 2020 yuzu Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
diff --git a/src/yuzu/bootmanager.cpp b/src/yuzu/bootmanager.cpp
index 114f17c06..24251247d 100644
--- a/src/yuzu/bootmanager.cpp
+++ b/src/yuzu/bootmanager.cpp
@@ -1,12 +1,12 @@
-// Copyright 2014 Citra Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: 2014 Citra Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#include <glad/glad.h>
#include <QApplication>
+#include <QCameraImageCapture>
+#include <QCameraInfo>
#include <QHBoxLayout>
-#include <QKeyEvent>
#include <QMessageBox>
#include <QPainter>
#include <QScreen>
@@ -28,17 +28,17 @@
#include "common/assert.h"
#include "common/microprofile.h"
#include "common/scm_rev.h"
-#include "common/scope_exit.h"
#include "common/settings.h"
#include "core/core.h"
+#include "core/cpu_manager.h"
#include "core/frontend/framebuffer_layout.h"
+#include "input_common/drivers/camera.h"
#include "input_common/drivers/keyboard.h"
#include "input_common/drivers/mouse.h"
#include "input_common/drivers/tas_input.h"
#include "input_common/drivers/touch_screen.h"
#include "input_common/main.h"
#include "video_core/renderer_base.h"
-#include "video_core/video_core.h"
#include "yuzu/bootmanager.h"
#include "yuzu/main.h"
@@ -47,12 +47,13 @@ EmuThread::EmuThread(Core::System& system_) : system{system_} {}
EmuThread::~EmuThread() = default;
void EmuThread::run() {
- std::string name = "yuzu:EmuControlThread";
+ std::string name = "EmuControlThread";
MicroProfileOnThreadCreate(name.c_str());
Common::SetCurrentThreadName(name.c_str());
auto& gpu = system.GPU();
auto stop_token = stop_source.get_token();
+ bool debugger_should_start = system.DebuggerEnabled();
system.RegisterHostThread();
@@ -75,6 +76,8 @@ void EmuThread::run() {
gpu.ReleaseContext();
+ system.GetCpuManager().OnGpuReady();
+
// Holds whether the cpu was running during the last iteration,
// so that the DebugModeLeft signal can be emitted before the
// next execution step
@@ -92,6 +95,12 @@ void EmuThread::run() {
this->SetRunning(false);
emit ErrorThrown(result, system.GetStatusDetails());
}
+
+ if (debugger_should_start) {
+ system.InitializeDebugger();
+ debugger_should_start = false;
+ }
+
running_wait.Wait();
result = system.Pause();
if (result != Core::SystemResultStatus::Success) {
@@ -105,11 +114,9 @@ void EmuThread::run() {
was_active = true;
emit DebugModeEntered();
}
- } else if (exec_step) {
- UNIMPLEMENTED();
} else {
std::unique_lock lock{running_mutex};
- running_cv.wait(lock, stop_token, [this] { return IsRunning() || exec_step; });
+ running_cv.wait(lock, stop_token, [this] { return IsRunning(); });
}
}
@@ -125,7 +132,7 @@ void EmuThread::run() {
class OpenGLSharedContext : public Core::Frontend::GraphicsContext {
public:
/// Create the original context that should be shared from
- explicit OpenGLSharedContext(QSurface* surface) : surface(surface) {
+ explicit OpenGLSharedContext(QSurface* surface_) : surface{surface_} {
QSurfaceFormat format;
format.setVersion(4, 6);
format.setProfile(QSurfaceFormat::CompatibilityProfile);
@@ -362,9 +369,9 @@ void GRenderWindow::RestoreGeometry() {
QWidget::restoreGeometry(geometry);
}
-void GRenderWindow::restoreGeometry(const QByteArray& geometry) {
+void GRenderWindow::restoreGeometry(const QByteArray& geometry_) {
// Make sure users of this class don't need to deal with backing up the geometry themselves
- QWidget::restoreGeometry(geometry);
+ QWidget::restoreGeometry(geometry_);
BackupGeometry();
}
@@ -750,7 +757,7 @@ void GRenderWindow::mouseMoveEvent(QMouseEvent* event) {
input_subsystem->GetMouse()->MouseMove(x, y, touch_x, touch_y, center_x, center_y);
if (Settings::values.mouse_panning && !Settings::values.mouse_enabled) {
- QCursor::setPos(mapToGlobal({center_x, center_y}));
+ QCursor::setPos(mapToGlobal(QPoint{center_x, center_y}));
}
emit MouseActivity();
@@ -775,65 +782,123 @@ void GRenderWindow::wheelEvent(QWheelEvent* event) {
void GRenderWindow::TouchBeginEvent(const QTouchEvent* event) {
QList<QTouchEvent::TouchPoint> touch_points = event->touchPoints();
for (const auto& touch_point : touch_points) {
- if (!TouchUpdate(touch_point)) {
- TouchStart(touch_point);
- }
+ const auto [x, y] = ScaleTouch(touch_point.pos());
+ const auto [touch_x, touch_y] = MapToTouchScreen(x, y);
+ input_subsystem->GetTouchScreen()->TouchPressed(touch_x, touch_y, touch_point.id());
}
}
void GRenderWindow::TouchUpdateEvent(const QTouchEvent* event) {
QList<QTouchEvent::TouchPoint> touch_points = event->touchPoints();
+ input_subsystem->GetTouchScreen()->ClearActiveFlag();
for (const auto& touch_point : touch_points) {
- if (!TouchUpdate(touch_point)) {
- TouchStart(touch_point);
- }
- }
- // Release all inactive points
- for (std::size_t id = 0; id < touch_ids.size(); ++id) {
- if (!TouchExist(touch_ids[id], touch_points)) {
- touch_ids[id] = 0;
- input_subsystem->GetTouchScreen()->TouchReleased(id);
- }
+ const auto [x, y] = ScaleTouch(touch_point.pos());
+ const auto [touch_x, touch_y] = MapToTouchScreen(x, y);
+ input_subsystem->GetTouchScreen()->TouchMoved(touch_x, touch_y, touch_point.id());
}
+ input_subsystem->GetTouchScreen()->ReleaseInactiveTouch();
}
void GRenderWindow::TouchEndEvent() {
- for (std::size_t id = 0; id < touch_ids.size(); ++id) {
- if (touch_ids[id] != 0) {
- touch_ids[id] = 0;
- input_subsystem->GetTouchScreen()->TouchReleased(id);
+ input_subsystem->GetTouchScreen()->ReleaseAllTouch();
+}
+
+void GRenderWindow::InitializeCamera() {
+ constexpr auto camera_update_ms = std::chrono::milliseconds{50}; // (50ms, 20Hz)
+ if (!Settings::values.enable_ir_sensor) {
+ return;
+ }
+
+ bool camera_found = false;
+ const QList<QCameraInfo> cameras = QCameraInfo::availableCameras();
+ for (const QCameraInfo& cameraInfo : cameras) {
+ if (Settings::values.ir_sensor_device.GetValue() == cameraInfo.deviceName().toStdString() ||
+ Settings::values.ir_sensor_device.GetValue() == "Auto") {
+ camera = std::make_unique<QCamera>(cameraInfo);
+ if (!camera->isCaptureModeSupported(QCamera::CaptureMode::CaptureViewfinder) &&
+ !camera->isCaptureModeSupported(QCamera::CaptureMode::CaptureStillImage)) {
+ LOG_ERROR(Frontend,
+ "Camera doesn't support CaptureViewfinder or CaptureStillImage");
+ continue;
+ }
+ camera_found = true;
+ break;
}
}
+
+ if (!camera_found) {
+ return;
+ }
+
+ camera_capture = std::make_unique<QCameraImageCapture>(camera.get());
+
+ if (!camera_capture->isCaptureDestinationSupported(
+ QCameraImageCapture::CaptureDestination::CaptureToBuffer)) {
+ LOG_ERROR(Frontend, "Camera doesn't support saving to buffer");
+ return;
+ }
+
+ camera_capture->setCaptureDestination(QCameraImageCapture::CaptureDestination::CaptureToBuffer);
+ connect(camera_capture.get(), &QCameraImageCapture::imageCaptured, this,
+ &GRenderWindow::OnCameraCapture);
+ camera->unload();
+ if (camera->isCaptureModeSupported(QCamera::CaptureMode::CaptureViewfinder)) {
+ camera->setCaptureMode(QCamera::CaptureViewfinder);
+ } else if (camera->isCaptureModeSupported(QCamera::CaptureMode::CaptureStillImage)) {
+ camera->setCaptureMode(QCamera::CaptureStillImage);
+ }
+ camera->load();
+ camera->start();
+
+ pending_camera_snapshots = 0;
+ is_virtual_camera = false;
+
+ camera_timer = std::make_unique<QTimer>();
+ connect(camera_timer.get(), &QTimer::timeout, [this] { RequestCameraCapture(); });
+ // This timer should be dependent of camera resolution 5ms for every 100 pixels
+ camera_timer->start(camera_update_ms);
}
-void GRenderWindow::TouchStart(const QTouchEvent::TouchPoint& touch_point) {
- for (std::size_t id = 0; id < touch_ids.size(); ++id) {
- if (touch_ids[id] == 0) {
- touch_ids[id] = touch_point.id() + 1;
- const auto [x, y] = ScaleTouch(touch_point.pos());
- const auto [touch_x, touch_y] = MapToTouchScreen(x, y);
- input_subsystem->GetTouchScreen()->TouchPressed(touch_x, touch_y, id);
- }
+void GRenderWindow::FinalizeCamera() {
+ if (camera_timer) {
+ camera_timer->stop();
+ }
+ if (camera) {
+ camera->unload();
}
}
-bool GRenderWindow::TouchUpdate(const QTouchEvent::TouchPoint& touch_point) {
- for (std::size_t id = 0; id < touch_ids.size(); ++id) {
- if (touch_ids[id] == static_cast<std::size_t>(touch_point.id() + 1)) {
- const auto [x, y] = ScaleTouch(touch_point.pos());
- const auto [touch_x, touch_y] = MapToTouchScreen(x, y);
- input_subsystem->GetTouchScreen()->TouchMoved(touch_x, touch_y, id);
- return true;
- }
+void GRenderWindow::RequestCameraCapture() {
+ if (!Settings::values.enable_ir_sensor) {
+ return;
}
- return false;
+
+ // If the camera doesn't capture, test for virtual cameras
+ if (pending_camera_snapshots > 5) {
+ is_virtual_camera = true;
+ }
+ // Virtual cameras like obs need to reset the camera every capture
+ if (is_virtual_camera) {
+ camera->stop();
+ camera->start();
+ }
+
+ pending_camera_snapshots++;
+ camera_capture->capture();
}
-bool GRenderWindow::TouchExist(std::size_t id,
- const QList<QTouchEvent::TouchPoint>& touch_points) const {
- return std::any_of(touch_points.begin(), touch_points.end(), [id](const auto& point) {
- return id == static_cast<std::size_t>(point.id() + 1);
- });
+void GRenderWindow::OnCameraCapture(int requestId, const QImage& img) {
+ constexpr std::size_t camera_width = 320;
+ constexpr std::size_t camera_height = 240;
+ const auto converted =
+ img.scaled(camera_width, camera_height, Qt::AspectRatioMode::IgnoreAspectRatio,
+ Qt::TransformationMode::SmoothTransformation)
+ .mirrored(false, true);
+ std::vector<u32> camera_data{};
+ camera_data.resize(camera_width * camera_height);
+ std::memcpy(camera_data.data(), converted.bits(), camera_width * camera_height * sizeof(u32));
+ input_subsystem->GetCamera()->SetCameraData(camera_width, camera_height, camera_data);
+ pending_camera_snapshots = 0;
}
bool GRenderWindow::event(QEvent* event) {
@@ -936,6 +1001,12 @@ void GRenderWindow::CaptureScreenshot(const QString& screenshot_path) {
auto& renderer = system.Renderer();
const f32 res_scale = Settings::values.resolution_info.up_factor;
+ if (renderer.IsScreenshotPending()) {
+ LOG_WARNING(Render,
+ "A screenshot is already requested or in progress, ignoring the request");
+ return;
+ }
+
const Layout::FramebufferLayout layout{Layout::FrameLayoutFromResolutionScale(res_scale)};
screenshot_image = QImage(QSize(layout.width, layout.height), QImage::Format_RGB32);
renderer.RequestScreenshot(
@@ -1036,8 +1107,8 @@ QStringList GRenderWindow::GetUnsupportedGLExtensions() const {
}
if (!unsupported_ext.empty()) {
- LOG_ERROR(Frontend, "GPU does not support all required extensions: {}",
- glGetString(GL_RENDERER));
+ const std::string gl_renderer{reinterpret_cast<const char*>(glGetString(GL_RENDERER))};
+ LOG_ERROR(Frontend, "GPU does not support all required extensions: {}", gl_renderer);
}
for (const QString& ext : unsupported_ext) {
LOG_ERROR(Frontend, "Unsupported GL extension: {}", ext.toStdString());
@@ -1046,8 +1117,8 @@ QStringList GRenderWindow::GetUnsupportedGLExtensions() const {
return unsupported_ext;
}
-void GRenderWindow::OnEmulationStarting(EmuThread* emu_thread) {
- this->emu_thread = emu_thread;
+void GRenderWindow::OnEmulationStarting(EmuThread* emu_thread_) {
+ emu_thread = emu_thread_;
}
void GRenderWindow::OnEmulationStopping() {
diff --git a/src/yuzu/bootmanager.h b/src/yuzu/bootmanager.h
index 92297a43b..c45ebf1a2 100644
--- a/src/yuzu/bootmanager.h
+++ b/src/yuzu/bootmanager.h
@@ -1,6 +1,5 @@
-// Copyright 2014 Citra Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: 2014 Citra Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
@@ -10,18 +9,19 @@
#include <mutex>
#include <QImage>
+#include <QStringList>
#include <QThread>
#include <QTouchEvent>
#include <QWidget>
-#include <QWindow>
#include "common/thread.h"
#include "core/frontend/emu_window.h"
class GRenderWindow;
class GMainWindow;
+class QCamera;
+class QCameraImageCapture;
class QKeyEvent;
-class QStringList;
namespace Core {
enum class SystemResultStatus : u32;
@@ -56,22 +56,13 @@ public:
void run() override;
/**
- * Steps the emulation thread by a single CPU instruction (if the CPU is not already running)
- * @note This function is thread-safe
- */
- void ExecStep() {
- exec_step = true;
- running_cv.notify_all();
- }
-
- /**
* Sets whether the emulation thread is running or not
- * @param running Boolean value, set the emulation thread to running if true
+ * @param running_ Boolean value, set the emulation thread to running if true
* @note This function is thread-safe
*/
- void SetRunning(bool running) {
+ void SetRunning(bool running_) {
std::unique_lock lock{running_mutex};
- this->running = running;
+ running = running_;
lock.unlock();
running_cv.notify_all();
if (!running) {
@@ -100,7 +91,6 @@ public:
}
private:
- bool exec_step = false;
bool running = false;
std::stop_source stop_source;
std::mutex running_mutex;
@@ -149,8 +139,8 @@ public:
void BackupGeometry();
void RestoreGeometry();
- void restoreGeometry(const QByteArray& geometry); // overridden
- QByteArray saveGeometry(); // overridden
+ void restoreGeometry(const QByteArray& geometry_); // overridden
+ QByteArray saveGeometry(); // overridden
qreal windowPixelRatio() const;
@@ -175,6 +165,9 @@ public:
void mouseReleaseEvent(QMouseEvent* event) override;
void wheelEvent(QWheelEvent* event) override;
+ void InitializeCamera();
+ void FinalizeCamera();
+
bool event(QEvent* event) override;
void focusOutEvent(QFocusEvent* event) override;
@@ -200,7 +193,7 @@ public:
void Exit();
public slots:
- void OnEmulationStarting(EmuThread* emu_thread);
+ void OnEmulationStarting(EmuThread* emu_thread_);
void OnEmulationStopping();
void OnFramebufferSizeChanged();
@@ -218,9 +211,8 @@ private:
void TouchUpdateEvent(const QTouchEvent* event);
void TouchEndEvent();
- void TouchStart(const QTouchEvent::TouchPoint& touch_point);
- bool TouchUpdate(const QTouchEvent::TouchPoint& touch_point);
- bool TouchExist(std::size_t id, const QList<QTouchEvent::TouchPoint>& touch_points) const;
+ void RequestCameraCapture();
+ void OnCameraCapture(int requestId, const QImage& img);
void OnMinimalClientAreaChangeRequest(std::pair<u32, u32> minimal_size) override;
@@ -247,7 +239,11 @@ private:
bool first_frame = false;
InputCommon::TasInput::TasState last_tas_state;
- std::array<std::size_t, 16> touch_ids{};
+ bool is_virtual_camera;
+ int pending_camera_snapshots;
+ std::unique_ptr<QCamera> camera;
+ std::unique_ptr<QCameraImageCapture> camera_capture;
+ std::unique_ptr<QTimer> camera_timer;
Core::System& system;
diff --git a/src/yuzu/compatdb.cpp b/src/yuzu/compatdb.cpp
index 2442bb3c3..f46fff340 100644
--- a/src/yuzu/compatdb.cpp
+++ b/src/yuzu/compatdb.cpp
@@ -1,6 +1,5 @@
-// Copyright 2017 Citra Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: 2017 Citra Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#include <QButtonGroup>
#include <QMessageBox>
diff --git a/src/yuzu/compatdb.h b/src/yuzu/compatdb.h
index e2b2522bd..3252fc47a 100644
--- a/src/yuzu/compatdb.h
+++ b/src/yuzu/compatdb.h
@@ -1,6 +1,5 @@
-// Copyright 2017 Citra Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: 2017 Citra Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
diff --git a/src/yuzu/compatdb.ui b/src/yuzu/compatdb.ui
index fed402176..3ca55eda6 100644
--- a/src/yuzu/compatdb.ui
+++ b/src/yuzu/compatdb.ui
@@ -86,7 +86,7 @@
<item row="4" column="0">
<widget class="QRadioButton" name="radioButton_Great">
<property name="text">
- <string>Great </string>
+ <string>Great</string>
</property>
</widget>
</item>
diff --git a/src/yuzu/compatibility_list.cpp b/src/yuzu/compatibility_list.cpp
index 2d2cfd03c..dbbe76448 100644
--- a/src/yuzu/compatibility_list.cpp
+++ b/src/yuzu/compatibility_list.cpp
@@ -1,6 +1,5 @@
-// Copyright 2018 yuzu Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#include <algorithm>
diff --git a/src/yuzu/compatibility_list.h b/src/yuzu/compatibility_list.h
index bc0175bd3..c0675d793 100644
--- a/src/yuzu/compatibility_list.h
+++ b/src/yuzu/compatibility_list.h
@@ -1,6 +1,5 @@
-// Copyright 2018 yuzu Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp
index 9ee7992e7..195074bf2 100644
--- a/src/yuzu/configuration/config.cpp
+++ b/src/yuzu/configuration/config.cpp
@@ -1,6 +1,5 @@
-// Copyright 2014 Citra Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: 2014 Citra Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#include <array>
#include <QKeySequence>
@@ -11,12 +10,12 @@
#include "core/hle/service/acc/profile_manager.h"
#include "core/hle/service/hid/controllers/npad.h"
#include "input_common/main.h"
+#include "network/network.h"
#include "yuzu/configuration/config.h"
namespace FS = Common::FS;
-Config::Config(Core::System& system_, const std::string& config_name, ConfigType config_type)
- : type(config_type), system{system_} {
+Config::Config(const std::string& config_name, ConfigType config_type) : type(config_type) {
global = config_type == ConfigType::GlobalConfig;
Initialize(config_name);
@@ -60,34 +59,39 @@ const std::array<int, 2> Config::default_stick_mod = {
0,
};
+const std::array<int, 2> Config::default_ringcon_analogs{{
+ Qt::Key_A,
+ Qt::Key_D,
+}};
+
// This shouldn't have anything except static initializers (no functions). So
// QKeySequence(...).toString() is NOT ALLOWED HERE.
// This must be in alphabetical order according to action name as it must have the same order as
// UISetting::values.shortcuts, which is alphabetically ordered.
// clang-format off
const std::array<UISettings::Shortcut, 22> Config::default_hotkeys{{
- {QStringLiteral("Audio Mute/Unmute"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+M"), QStringLiteral("Home+Dpad_Right"), Qt::WindowShortcut}},
- {QStringLiteral("Audio Volume Down"), QStringLiteral("Main Window"), {QStringLiteral("-"), QStringLiteral("Home+Dpad_Down"), Qt::ApplicationShortcut}},
- {QStringLiteral("Audio Volume Up"), QStringLiteral("Main Window"), {QStringLiteral("+"), QStringLiteral("Home+Dpad_Up"), Qt::ApplicationShortcut}},
- {QStringLiteral("Capture Screenshot"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+P"), QStringLiteral("Screenshot"), Qt::WidgetWithChildrenShortcut}},
- {QStringLiteral("Change Adapting Filter"), QStringLiteral("Main Window"), {QStringLiteral("F8"), QStringLiteral("Home+L"), Qt::ApplicationShortcut}},
- {QStringLiteral("Change Docked Mode"), QStringLiteral("Main Window"), {QStringLiteral("F10"), QStringLiteral("Home+X"), Qt::ApplicationShortcut}},
- {QStringLiteral("Change GPU Accuracy"), QStringLiteral("Main Window"), {QStringLiteral("F9"), QStringLiteral("Home+R"), Qt::ApplicationShortcut}},
- {QStringLiteral("Continue/Pause Emulation"), QStringLiteral("Main Window"), {QStringLiteral("F4"), QStringLiteral("Home+Plus"), Qt::WindowShortcut}},
- {QStringLiteral("Exit Fullscreen"), QStringLiteral("Main Window"), {QStringLiteral("Esc"), QStringLiteral(""), Qt::WindowShortcut}},
- {QStringLiteral("Exit yuzu"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+Q"), QStringLiteral("Home+Minus"), Qt::WindowShortcut}},
- {QStringLiteral("Fullscreen"), QStringLiteral("Main Window"), {QStringLiteral("F11"), QStringLiteral("Home+B"), Qt::WindowShortcut}},
- {QStringLiteral("Load Amiibo"), QStringLiteral("Main Window"), {QStringLiteral("F2"), QStringLiteral("Home+A"), Qt::WidgetWithChildrenShortcut}},
- {QStringLiteral("Load File"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+O"), QStringLiteral(""), Qt::WidgetWithChildrenShortcut}},
- {QStringLiteral("Restart Emulation"), QStringLiteral("Main Window"), {QStringLiteral("F6"), QStringLiteral(""), Qt::WindowShortcut}},
- {QStringLiteral("Stop Emulation"), QStringLiteral("Main Window"), {QStringLiteral("F5"), QStringLiteral(""), Qt::WindowShortcut}},
- {QStringLiteral("TAS Start/Stop"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+F5"), QStringLiteral(""), Qt::ApplicationShortcut}},
- {QStringLiteral("TAS Reset"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+F6"), QStringLiteral(""), Qt::ApplicationShortcut}},
- {QStringLiteral("TAS Record"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+F7"), QStringLiteral(""), Qt::ApplicationShortcut}},
- {QStringLiteral("Toggle Filter Bar"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+F"), QStringLiteral(""), Qt::WindowShortcut}},
- {QStringLiteral("Toggle Framerate Limit"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+U"), QStringLiteral("Home+Y"), Qt::ApplicationShortcut}},
- {QStringLiteral("Toggle Mouse Panning"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+F9"), QStringLiteral(""), Qt::ApplicationShortcut}},
- {QStringLiteral("Toggle Status Bar"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+S"), QStringLiteral(""), Qt::WindowShortcut}},
+ {QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Audio Mute/Unmute")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("Ctrl+M"), QStringLiteral("Home+Dpad_Right"), Qt::WindowShortcut}},
+ {QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Audio Volume Down")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("-"), QStringLiteral("Home+Dpad_Down"), Qt::ApplicationShortcut}},
+ {QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Audio Volume Up")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("="), QStringLiteral("Home+Dpad_Up"), Qt::ApplicationShortcut}},
+ {QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Capture Screenshot")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("Ctrl+P"), QStringLiteral("Screenshot"), Qt::WidgetWithChildrenShortcut}},
+ {QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Change Adapting Filter")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("F8"), QStringLiteral("Home+L"), Qt::ApplicationShortcut}},
+ {QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Change Docked Mode")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("F10"), QStringLiteral("Home+X"), Qt::ApplicationShortcut}},
+ {QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Change GPU Accuracy")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("F9"), QStringLiteral("Home+R"), Qt::ApplicationShortcut}},
+ {QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Continue/Pause Emulation")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("F4"), QStringLiteral("Home+Plus"), Qt::WindowShortcut}},
+ {QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Exit Fullscreen")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("Esc"), QStringLiteral(""), Qt::WindowShortcut}},
+ {QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Exit yuzu")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("Ctrl+Q"), QStringLiteral("Home+Minus"), Qt::WindowShortcut}},
+ {QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Fullscreen")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("F11"), QStringLiteral("Home+B"), Qt::WindowShortcut}},
+ {QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Load File")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("Ctrl+O"), QStringLiteral(""), Qt::WidgetWithChildrenShortcut}},
+ {QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Load/Remove Amiibo")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("F2"), QStringLiteral("Home+A"), Qt::WidgetWithChildrenShortcut}},
+ {QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Restart Emulation")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("F6"), QStringLiteral(""), Qt::WindowShortcut}},
+ {QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Stop Emulation")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("F5"), QStringLiteral(""), Qt::WindowShortcut}},
+ {QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "TAS Record")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("Ctrl+F7"), QStringLiteral(""), Qt::ApplicationShortcut}},
+ {QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "TAS Reset")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("Ctrl+F6"), QStringLiteral(""), Qt::ApplicationShortcut}},
+ {QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "TAS Start/Stop")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("Ctrl+F5"), QStringLiteral(""), Qt::ApplicationShortcut}},
+ {QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Toggle Filter Bar")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("Ctrl+F"), QStringLiteral(""), Qt::WindowShortcut}},
+ {QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Toggle Framerate Limit")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("Ctrl+U"), QStringLiteral("Home+Y"), Qt::ApplicationShortcut}},
+ {QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Toggle Mouse Panning")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("Ctrl+F9"), QStringLiteral(""), Qt::ApplicationShortcut}},
+ {QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Toggle Status Bar")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("Ctrl+S"), QStringLiteral(""), Qt::WindowShortcut}},
}};
// clang-format on
@@ -128,7 +132,7 @@ void Config::Initialize(const std::string& config_name) {
// Explicit std::string definition: Qt can't implicitly convert a std::string to a QVariant, nor
// can it implicitly convert a QVariant back to a {std::,Q}string
template <>
-void Config::ReadBasicSetting(Settings::BasicSetting<std::string>& setting) {
+void Config::ReadBasicSetting(Settings::Setting<std::string>& setting) {
const QString name = QString::fromStdString(setting.GetLabel());
const auto default_value = QString::fromStdString(setting.GetDefault());
if (qt_config->value(name + QStringLiteral("/default"), false).toBool()) {
@@ -138,8 +142,8 @@ void Config::ReadBasicSetting(Settings::BasicSetting<std::string>& setting) {
}
}
-template <typename Type>
-void Config::ReadBasicSetting(Settings::BasicSetting<Type>& setting) {
+template <typename Type, bool ranged>
+void Config::ReadBasicSetting(Settings::Setting<Type, ranged>& setting) {
const QString name = QString::fromStdString(setting.GetLabel());
const Type default_value = setting.GetDefault();
if (qt_config->value(name + QStringLiteral("/default"), false).toBool()) {
@@ -152,23 +156,23 @@ void Config::ReadBasicSetting(Settings::BasicSetting<Type>& setting) {
// Explicit std::string definition: Qt can't implicitly convert a std::string to a QVariant
template <>
-void Config::WriteBasicSetting(const Settings::BasicSetting<std::string>& setting) {
+void Config::WriteBasicSetting(const Settings::Setting<std::string>& setting) {
const QString name = QString::fromStdString(setting.GetLabel());
const std::string& value = setting.GetValue();
qt_config->setValue(name + QStringLiteral("/default"), value == setting.GetDefault());
qt_config->setValue(name, QString::fromStdString(value));
}
-template <typename Type>
-void Config::WriteBasicSetting(const Settings::BasicSetting<Type>& setting) {
+template <typename Type, bool ranged>
+void Config::WriteBasicSetting(const Settings::Setting<Type, ranged>& setting) {
const QString name = QString::fromStdString(setting.GetLabel());
const Type value = setting.GetValue();
qt_config->setValue(name + QStringLiteral("/default"), value == setting.GetDefault());
qt_config->setValue(name, value);
}
-template <typename Type>
-void Config::WriteGlobalSetting(const Settings::Setting<Type>& setting) {
+template <typename Type, bool ranged>
+void Config::WriteGlobalSetting(const Settings::SwitchableSetting<Type, ranged>& setting) {
const QString name = QString::fromStdString(setting.GetLabel());
const Type& value = setting.GetValue(global);
if (!global) {
@@ -346,12 +350,35 @@ void Config::ReadTouchscreenValues() {
ReadSetting(QStringLiteral("touchscreen_diameter_y"), 15).toUInt();
}
+void Config::ReadHidbusValues() {
+ Settings::values.enable_ring_controller =
+ ReadSetting(QStringLiteral("enable_ring_controller"), true).toBool();
+
+ const std::string default_param = InputCommon::GenerateAnalogParamFromKeys(
+ 0, 0, default_ringcon_analogs[0], default_ringcon_analogs[1], 0, 0.05f);
+ auto& ringcon_analogs = Settings::values.ringcon_analogs;
+
+ ringcon_analogs =
+ qt_config->value(QStringLiteral("ring_controller"), QString::fromStdString(default_param))
+ .toString()
+ .toStdString();
+ if (ringcon_analogs.empty()) {
+ ringcon_analogs = default_param;
+ }
+}
+
+void Config::ReadIrCameraValues() {
+ ReadBasicSetting(Settings::values.enable_ir_sensor);
+ ReadBasicSetting(Settings::values.ir_sensor_device);
+}
+
void Config::ReadAudioValues() {
qt_config->beginGroup(QStringLiteral("Audio"));
if (global) {
- ReadBasicSetting(Settings::values.audio_device_id);
ReadBasicSetting(Settings::values.sink_id);
+ ReadBasicSetting(Settings::values.audio_output_device_id);
+ ReadBasicSetting(Settings::values.audio_input_device_id);
}
ReadGlobalSetting(Settings::values.volume);
@@ -369,6 +396,8 @@ void Config::ReadControlValues() {
ReadMouseValues();
ReadTouchscreenValues();
ReadMotionTouchValues();
+ ReadHidbusValues();
+ ReadIrCameraValues();
#ifdef _WIN32
ReadBasicSetting(Settings::values.enable_raw_input);
@@ -445,6 +474,7 @@ void Config::ReadCoreValues() {
qt_config->beginGroup(QStringLiteral("Core"));
ReadGlobalSetting(Settings::values.use_multi_core);
+ ReadGlobalSetting(Settings::values.use_extended_memory_layout);
qt_config->endGroup();
}
@@ -501,6 +531,9 @@ void Config::ReadDebuggingValues() {
// Intentionally not using the QT default setting as this is intended to be changed in the ini
Settings::values.record_frame_times =
qt_config->value(QStringLiteral("record_frame_times"), false).toBool();
+
+ ReadBasicSetting(Settings::values.use_gdbstub);
+ ReadBasicSetting(Settings::values.gdbstub_port);
ReadBasicSetting(Settings::values.program_args);
ReadBasicSetting(Settings::values.dump_exefs);
ReadBasicSetting(Settings::values.dump_nso);
@@ -512,6 +545,8 @@ void Config::ReadDebuggingValues() {
ReadBasicSetting(Settings::values.use_debug_asserts);
ReadBasicSetting(Settings::values.use_auto_stub);
ReadBasicSetting(Settings::values.enable_all_controllers);
+ ReadBasicSetting(Settings::values.create_crash_dumps);
+ ReadBasicSetting(Settings::values.perform_vulkan_check);
qt_config->endGroup();
}
@@ -608,6 +643,7 @@ void Config::ReadCpuValues() {
ReadGlobalSetting(Settings::values.cpuopt_unsafe_ignore_standard_fpcr);
ReadGlobalSetting(Settings::values.cpuopt_unsafe_inaccurate_nan);
ReadGlobalSetting(Settings::values.cpuopt_unsafe_fastmem_check);
+ ReadGlobalSetting(Settings::values.cpuopt_unsafe_ignore_global_monitor);
if (global) {
ReadBasicSetting(Settings::values.cpu_debug_mode);
@@ -620,6 +656,8 @@ void Config::ReadCpuValues() {
ReadBasicSetting(Settings::values.cpuopt_misc_ir);
ReadBasicSetting(Settings::values.cpuopt_reduce_misalign_checks);
ReadBasicSetting(Settings::values.cpuopt_fastmem);
+ ReadBasicSetting(Settings::values.cpuopt_fastmem_exclusives);
+ ReadBasicSetting(Settings::values.cpuopt_recompile_exclusives);
}
qt_config->endGroup();
@@ -638,7 +676,6 @@ void Config::ReadRendererValues() {
ReadGlobalSetting(Settings::values.max_anisotropy);
ReadGlobalSetting(Settings::values.use_speed_limit);
ReadGlobalSetting(Settings::values.speed_limit);
- ReadGlobalSetting(Settings::values.fps_cap);
ReadGlobalSetting(Settings::values.use_disk_shader_cache);
ReadGlobalSetting(Settings::values.gpu_accuracy);
ReadGlobalSetting(Settings::values.use_asynchronous_gpu_emulation);
@@ -648,6 +685,7 @@ void Config::ReadRendererValues() {
ReadGlobalSetting(Settings::values.shader_backend);
ReadGlobalSetting(Settings::values.use_asynchronous_shaders);
ReadGlobalSetting(Settings::values.use_fast_gpu_time);
+ ReadGlobalSetting(Settings::values.use_pessimistic_flushes);
ReadGlobalSetting(Settings::values.bg_red);
ReadGlobalSetting(Settings::values.bg_green);
ReadGlobalSetting(Settings::values.bg_blue);
@@ -758,6 +796,7 @@ void Config::ReadUIValues() {
ReadPathValues();
ReadScreenshotValues();
ReadShortcutValues();
+ ReadMultiplayerValues();
ReadBasicSetting(UISettings::values.single_window_mode);
ReadBasicSetting(UISettings::values.fullscreen);
@@ -771,6 +810,7 @@ void Config::ReadUIValues() {
ReadBasicSetting(UISettings::values.pause_when_in_background);
ReadBasicSetting(UISettings::values.mute_when_in_background);
ReadBasicSetting(UISettings::values.hide_mouse);
+ ReadBasicSetting(UISettings::values.disable_web_applet);
qt_config->endGroup();
}
@@ -823,6 +863,42 @@ void Config::ReadWebServiceValues() {
qt_config->endGroup();
}
+void Config::ReadMultiplayerValues() {
+ qt_config->beginGroup(QStringLiteral("Multiplayer"));
+
+ ReadBasicSetting(UISettings::values.multiplayer_nickname);
+ ReadBasicSetting(UISettings::values.multiplayer_ip);
+ ReadBasicSetting(UISettings::values.multiplayer_port);
+ ReadBasicSetting(UISettings::values.multiplayer_room_nickname);
+ ReadBasicSetting(UISettings::values.multiplayer_room_name);
+ ReadBasicSetting(UISettings::values.multiplayer_room_port);
+ ReadBasicSetting(UISettings::values.multiplayer_host_type);
+ ReadBasicSetting(UISettings::values.multiplayer_port);
+ ReadBasicSetting(UISettings::values.multiplayer_max_player);
+ ReadBasicSetting(UISettings::values.multiplayer_game_id);
+ ReadBasicSetting(UISettings::values.multiplayer_room_description);
+
+ // Read ban list back
+ int size = qt_config->beginReadArray(QStringLiteral("username_ban_list"));
+ UISettings::values.multiplayer_ban_list.first.resize(size);
+ for (int i = 0; i < size; ++i) {
+ qt_config->setArrayIndex(i);
+ UISettings::values.multiplayer_ban_list.first[i] =
+ ReadSetting(QStringLiteral("username")).toString().toStdString();
+ }
+ qt_config->endArray();
+ size = qt_config->beginReadArray(QStringLiteral("ip_ban_list"));
+ UISettings::values.multiplayer_ban_list.second.resize(size);
+ for (int i = 0; i < size; ++i) {
+ qt_config->setArrayIndex(i);
+ UISettings::values.multiplayer_ban_list.second[i] =
+ ReadSetting(QStringLiteral("ip")).toString().toStdString();
+ }
+ qt_config->endArray();
+
+ qt_config->endGroup();
+}
+
void Config::ReadValues() {
if (global) {
ReadControlValues();
@@ -839,6 +915,7 @@ void Config::ReadValues() {
ReadRendererValues();
ReadAudioValues();
ReadSystemValues();
+ ReadMultiplayerValues();
}
void Config::SavePlayerValue(std::size_t player_index) {
@@ -957,6 +1034,21 @@ void Config::SaveMotionTouchValues() {
qt_config->endArray();
}
+void Config::SaveHidbusValues() {
+ WriteBasicSetting(Settings::values.enable_ring_controller);
+
+ const std::string default_param = InputCommon::GenerateAnalogParamFromKeys(
+ 0, 0, default_ringcon_analogs[0], default_ringcon_analogs[1], 0, 0.05f);
+ WriteSetting(QStringLiteral("ring_controller"),
+ QString::fromStdString(Settings::values.ringcon_analogs),
+ QString::fromStdString(default_param));
+}
+
+void Config::SaveIrCameraValues() {
+ WriteBasicSetting(Settings::values.enable_ir_sensor);
+ WriteBasicSetting(Settings::values.ir_sensor_device);
+}
+
void Config::SaveValues() {
if (global) {
SaveControlValues();
@@ -973,6 +1065,7 @@ void Config::SaveValues() {
SaveRendererValues();
SaveAudioValues();
SaveSystemValues();
+ SaveMultiplayerValues();
}
void Config::SaveAudioValues() {
@@ -980,7 +1073,8 @@ void Config::SaveAudioValues() {
if (global) {
WriteBasicSetting(Settings::values.sink_id);
- WriteBasicSetting(Settings::values.audio_device_id);
+ WriteBasicSetting(Settings::values.audio_output_device_id);
+ WriteBasicSetting(Settings::values.audio_input_device_id);
}
WriteGlobalSetting(Settings::values.volume);
@@ -997,6 +1091,8 @@ void Config::SaveControlValues() {
SaveMouseValues();
SaveTouchscreenValues();
SaveMotionTouchValues();
+ SaveHidbusValues();
+ SaveIrCameraValues();
WriteGlobalSetting(Settings::values.use_docked_mode);
WriteGlobalSetting(Settings::values.vibration_enabled);
@@ -1019,6 +1115,7 @@ void Config::SaveCoreValues() {
qt_config->beginGroup(QStringLiteral("Core"));
WriteGlobalSetting(Settings::values.use_multi_core);
+ WriteGlobalSetting(Settings::values.use_extended_memory_layout);
qt_config->endGroup();
}
@@ -1055,6 +1152,8 @@ void Config::SaveDebuggingValues() {
// Intentionally not using the QT default setting as this is intended to be changed in the ini
qt_config->setValue(QStringLiteral("record_frame_times"), Settings::values.record_frame_times);
+ WriteBasicSetting(Settings::values.use_gdbstub);
+ WriteBasicSetting(Settings::values.gdbstub_port);
WriteBasicSetting(Settings::values.program_args);
WriteBasicSetting(Settings::values.dump_exefs);
WriteBasicSetting(Settings::values.dump_nso);
@@ -1063,6 +1162,8 @@ void Config::SaveDebuggingValues() {
WriteBasicSetting(Settings::values.use_debug_asserts);
WriteBasicSetting(Settings::values.disable_macro_jit);
WriteBasicSetting(Settings::values.enable_all_controllers);
+ WriteBasicSetting(Settings::values.create_crash_dumps);
+ WriteBasicSetting(Settings::values.perform_vulkan_check);
qt_config->endGroup();
}
@@ -1137,6 +1238,7 @@ void Config::SaveCpuValues() {
WriteGlobalSetting(Settings::values.cpuopt_unsafe_ignore_standard_fpcr);
WriteGlobalSetting(Settings::values.cpuopt_unsafe_inaccurate_nan);
WriteGlobalSetting(Settings::values.cpuopt_unsafe_fastmem_check);
+ WriteGlobalSetting(Settings::values.cpuopt_unsafe_ignore_global_monitor);
if (global) {
WriteBasicSetting(Settings::values.cpu_debug_mode);
@@ -1149,6 +1251,8 @@ void Config::SaveCpuValues() {
WriteBasicSetting(Settings::values.cpuopt_misc_ir);
WriteBasicSetting(Settings::values.cpuopt_reduce_misalign_checks);
WriteBasicSetting(Settings::values.cpuopt_fastmem);
+ WriteBasicSetting(Settings::values.cpuopt_fastmem_exclusives);
+ WriteBasicSetting(Settings::values.cpuopt_recompile_exclusives);
}
qt_config->endGroup();
@@ -1182,7 +1286,6 @@ void Config::SaveRendererValues() {
WriteGlobalSetting(Settings::values.max_anisotropy);
WriteGlobalSetting(Settings::values.use_speed_limit);
WriteGlobalSetting(Settings::values.speed_limit);
- WriteGlobalSetting(Settings::values.fps_cap);
WriteGlobalSetting(Settings::values.use_disk_shader_cache);
WriteSetting(QString::fromStdString(Settings::values.gpu_accuracy.GetLabel()),
static_cast<u32>(Settings::values.gpu_accuracy.GetValue(global)),
@@ -1201,6 +1304,7 @@ void Config::SaveRendererValues() {
Settings::values.shader_backend.UsingGlobal());
WriteGlobalSetting(Settings::values.use_asynchronous_shaders);
WriteGlobalSetting(Settings::values.use_fast_gpu_time);
+ WriteGlobalSetting(Settings::values.use_pessimistic_flushes);
WriteGlobalSetting(Settings::values.bg_red);
WriteGlobalSetting(Settings::values.bg_green);
WriteGlobalSetting(Settings::values.bg_blue);
@@ -1287,6 +1391,7 @@ void Config::SaveUIValues() {
SavePathValues();
SaveScreenshotValues();
SaveShortcutValues();
+ SaveMultiplayerValues();
WriteBasicSetting(UISettings::values.single_window_mode);
WriteBasicSetting(UISettings::values.fullscreen);
@@ -1300,6 +1405,7 @@ void Config::SaveUIValues() {
WriteBasicSetting(UISettings::values.pause_when_in_background);
WriteBasicSetting(UISettings::values.mute_when_in_background);
WriteBasicSetting(UISettings::values.hide_mouse);
+ WriteBasicSetting(UISettings::values.disable_web_applet);
qt_config->endGroup();
}
@@ -1350,6 +1456,40 @@ void Config::SaveWebServiceValues() {
qt_config->endGroup();
}
+void Config::SaveMultiplayerValues() {
+ qt_config->beginGroup(QStringLiteral("Multiplayer"));
+
+ WriteBasicSetting(UISettings::values.multiplayer_nickname);
+ WriteBasicSetting(UISettings::values.multiplayer_ip);
+ WriteBasicSetting(UISettings::values.multiplayer_port);
+ WriteBasicSetting(UISettings::values.multiplayer_room_nickname);
+ WriteBasicSetting(UISettings::values.multiplayer_room_name);
+ WriteBasicSetting(UISettings::values.multiplayer_room_port);
+ WriteBasicSetting(UISettings::values.multiplayer_host_type);
+ WriteBasicSetting(UISettings::values.multiplayer_port);
+ WriteBasicSetting(UISettings::values.multiplayer_max_player);
+ WriteBasicSetting(UISettings::values.multiplayer_game_id);
+ WriteBasicSetting(UISettings::values.multiplayer_room_description);
+
+ // Write ban list
+ qt_config->beginWriteArray(QStringLiteral("username_ban_list"));
+ for (std::size_t i = 0; i < UISettings::values.multiplayer_ban_list.first.size(); ++i) {
+ qt_config->setArrayIndex(static_cast<int>(i));
+ WriteSetting(QStringLiteral("username"),
+ QString::fromStdString(UISettings::values.multiplayer_ban_list.first[i]));
+ }
+ qt_config->endArray();
+ qt_config->beginWriteArray(QStringLiteral("ip_ban_list"));
+ for (std::size_t i = 0; i < UISettings::values.multiplayer_ban_list.second.size(); ++i) {
+ qt_config->setArrayIndex(static_cast<int>(i));
+ WriteSetting(QStringLiteral("ip"),
+ QString::fromStdString(UISettings::values.multiplayer_ban_list.second[i]));
+ }
+ qt_config->endArray();
+
+ qt_config->endGroup();
+}
+
QVariant Config::ReadSetting(const QString& name) const {
return qt_config->value(name);
}
@@ -1364,8 +1504,8 @@ QVariant Config::ReadSetting(const QString& name, const QVariant& default_value)
return result;
}
-template <typename Type>
-void Config::ReadGlobalSetting(Settings::Setting<Type>& setting) {
+template <typename Type, bool ranged>
+void Config::ReadGlobalSetting(Settings::SwitchableSetting<Type, ranged>& setting) {
QString name = QString::fromStdString(setting.GetLabel());
const bool use_global = qt_config->value(name + QStringLiteral("/use_global"), true).toBool();
setting.SetGlobal(use_global);
@@ -1410,7 +1550,6 @@ void Config::Reload() {
ReadValues();
// To apply default value changes
SaveValues();
- system.ApplySettings();
}
void Config::Save() {
diff --git a/src/yuzu/configuration/config.h b/src/yuzu/configuration/config.h
index ae3e36a11..06fa7d2d0 100644
--- a/src/yuzu/configuration/config.h
+++ b/src/yuzu/configuration/config.h
@@ -1,6 +1,5 @@
-// Copyright 2014 Citra Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: 2014 Citra Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
@@ -26,7 +25,7 @@ public:
InputProfile,
};
- explicit Config(Core::System& system_, const std::string& config_name = "qt-config",
+ explicit Config(const std::string& config_name = "qt-config",
ConfigType config_type = ConfigType::GlobalConfig);
~Config();
@@ -42,6 +41,7 @@ public:
static const std::array<int, Settings::NativeMotion::NumMotions> default_motions;
static const std::array<std::array<int, 4>, Settings::NativeAnalog::NumAnalogs> default_analogs;
static const std::array<int, 2> default_stick_mod;
+ static const std::array<int, 2> default_ringcon_analogs;
static const std::array<int, Settings::NativeMouseButton::NumMouseButtons>
default_mouse_buttons;
static const std::array<int, Settings::NativeKeyboard::NumKeyboardKeys> default_keyboard_keys;
@@ -66,6 +66,8 @@ private:
void ReadMouseValues();
void ReadTouchscreenValues();
void ReadMotionTouchValues();
+ void ReadHidbusValues();
+ void ReadIrCameraValues();
// Read functions bases off the respective config section names.
void ReadAudioValues();
@@ -86,6 +88,7 @@ private:
void ReadUIGamelistValues();
void ReadUILayoutValues();
void ReadWebServiceValues();
+ void ReadMultiplayerValues();
void SaveValues();
void SavePlayerValue(std::size_t player_index);
@@ -93,6 +96,8 @@ private:
void SaveMouseValues();
void SaveTouchscreenValues();
void SaveMotionTouchValues();
+ void SaveHidbusValues();
+ void SaveIrCameraValues();
// Save functions based off the respective config section names.
void SaveAudioValues();
@@ -113,6 +118,7 @@ private:
void SaveUIGamelistValues();
void SaveUILayoutValues();
void SaveWebServiceValues();
+ void SaveMultiplayerValues();
/**
* Reads a setting from the qt_config.
@@ -156,8 +162,8 @@ private:
*
* @param The setting
*/
- template <typename Type>
- void ReadGlobalSetting(Settings::Setting<Type>& setting);
+ template <typename Type, bool ranged>
+ void ReadGlobalSetting(Settings::SwitchableSetting<Type, ranged>& setting);
/**
* Sets a value to the qt_config using the setting's label and default value. If the config is a
@@ -165,8 +171,8 @@ private:
*
* @param The setting
*/
- template <typename Type>
- void WriteGlobalSetting(const Settings::Setting<Type>& setting);
+ template <typename Type, bool ranged>
+ void WriteGlobalSetting(const Settings::SwitchableSetting<Type, ranged>& setting);
/**
* Reads a value from the qt_config using the setting's label and default value and applies the
@@ -174,22 +180,20 @@ private:
*
* @param The setting
*/
- template <typename Type>
- void ReadBasicSetting(Settings::BasicSetting<Type>& setting);
+ template <typename Type, bool ranged>
+ void ReadBasicSetting(Settings::Setting<Type, ranged>& setting);
/** Sets a value from the setting in the qt_config using the setting's label and default value.
*
* @param The setting
*/
- template <typename Type>
- void WriteBasicSetting(const Settings::BasicSetting<Type>& setting);
+ template <typename Type, bool ranged>
+ void WriteBasicSetting(const Settings::Setting<Type, ranged>& setting);
ConfigType type;
std::unique_ptr<QSettings> qt_config;
std::string qt_config_loc;
bool global;
-
- Core::System& system;
};
// These metatype declarations cannot be in common/settings.h because core is devoid of QT
diff --git a/src/yuzu/configuration/configuration_shared.cpp b/src/yuzu/configuration/configuration_shared.cpp
index 251aab912..97fb664bf 100644
--- a/src/yuzu/configuration/configuration_shared.cpp
+++ b/src/yuzu/configuration/configuration_shared.cpp
@@ -1,16 +1,14 @@
-// Copyright 2016 Citra Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: 2016 Citra Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#include <QCheckBox>
-#include <QComboBox>
#include <QObject>
#include <QString>
#include "common/settings.h"
#include "yuzu/configuration/configuration_shared.h"
#include "yuzu/configuration/configure_per_game.h"
-void ConfigurationShared::ApplyPerGameSetting(Settings::Setting<bool>* setting,
+void ConfigurationShared::ApplyPerGameSetting(Settings::SwitchableSetting<bool>* setting,
const QCheckBox* checkbox,
const CheckState& tracker) {
if (Settings::IsConfiguringGlobal() && setting->UsingGlobal()) {
@@ -26,7 +24,7 @@ void ConfigurationShared::ApplyPerGameSetting(Settings::Setting<bool>* setting,
}
void ConfigurationShared::SetPerGameSetting(QCheckBox* checkbox,
- const Settings::Setting<bool>* setting) {
+ const Settings::SwitchableSetting<bool>* setting) {
if (setting->UsingGlobal()) {
checkbox->setCheckState(Qt::PartiallyChecked);
} else {
@@ -46,7 +44,7 @@ void ConfigurationShared::SetHighlight(QWidget* widget, bool highlighted) {
}
void ConfigurationShared::SetColoredTristate(QCheckBox* checkbox,
- const Settings::Setting<bool>& setting,
+ const Settings::SwitchableSetting<bool>& setting,
CheckState& tracker) {
if (setting.UsingGlobal()) {
tracker = CheckState::Global;
diff --git a/src/yuzu/configuration/configuration_shared.h b/src/yuzu/configuration/configuration_shared.h
index 5423dbc92..e597dcdb5 100644
--- a/src/yuzu/configuration/configuration_shared.h
+++ b/src/yuzu/configuration/configuration_shared.h
@@ -1,12 +1,10 @@
-// Copyright 2016 Citra Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: 2016 Citra Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include <QCheckBox>
#include <QComboBox>
-#include <QString>
#include "common/settings.h"
namespace ConfigurationShared {
@@ -26,10 +24,11 @@ enum class CheckState {
// Global-aware apply and set functions
// ApplyPerGameSetting, given a Settings::Setting and a Qt UI element, properly applies a Setting
-void ApplyPerGameSetting(Settings::Setting<bool>* setting, const QCheckBox* checkbox,
+void ApplyPerGameSetting(Settings::SwitchableSetting<bool>* setting, const QCheckBox* checkbox,
const CheckState& tracker);
-template <typename Type>
-void ApplyPerGameSetting(Settings::Setting<Type>* setting, const QComboBox* combobox) {
+template <typename Type, bool ranged>
+void ApplyPerGameSetting(Settings::SwitchableSetting<Type, ranged>* setting,
+ const QComboBox* combobox) {
if (Settings::IsConfiguringGlobal() && setting->UsingGlobal()) {
setting->SetValue(static_cast<Type>(combobox->currentIndex()));
} else if (!Settings::IsConfiguringGlobal()) {
@@ -44,10 +43,11 @@ void ApplyPerGameSetting(Settings::Setting<Type>* setting, const QComboBox* comb
}
// Sets a Qt UI element given a Settings::Setting
-void SetPerGameSetting(QCheckBox* checkbox, const Settings::Setting<bool>* setting);
+void SetPerGameSetting(QCheckBox* checkbox, const Settings::SwitchableSetting<bool>* setting);
-template <typename Type>
-void SetPerGameSetting(QComboBox* combobox, const Settings::Setting<Type>* setting) {
+template <typename Type, bool ranged>
+void SetPerGameSetting(QComboBox* combobox,
+ const Settings::SwitchableSetting<Type, ranged>* setting) {
combobox->setCurrentIndex(setting->UsingGlobal() ? ConfigurationShared::USE_GLOBAL_INDEX
: static_cast<int>(setting->GetValue()) +
ConfigurationShared::USE_GLOBAL_OFFSET);
@@ -57,7 +57,7 @@ void SetPerGameSetting(QComboBox* combobox, const Settings::Setting<Type>* setti
void SetHighlight(QWidget* widget, bool highlighted);
// Sets up a QCheckBox like a tristate one, given a Setting
-void SetColoredTristate(QCheckBox* checkbox, const Settings::Setting<bool>& setting,
+void SetColoredTristate(QCheckBox* checkbox, const Settings::SwitchableSetting<bool>& setting,
CheckState& tracker);
void SetColoredTristate(QCheckBox* checkbox, bool global, bool state, bool global_state,
CheckState& tracker);
diff --git a/src/yuzu/configuration/configure_audio.cpp b/src/yuzu/configuration/configure_audio.cpp
index c33488718..19b8b15ef 100644
--- a/src/yuzu/configuration/configure_audio.cpp
+++ b/src/yuzu/configuration/configure_audio.cpp
@@ -1,13 +1,10 @@
-// Copyright 2018 yuzu Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#include <memory>
-#include <QSignalBlocker>
-
-#include "audio_core/sink.h"
-#include "audio_core/sink_details.h"
+#include "audio_core/sink/sink.h"
+#include "audio_core/sink/sink_details.h"
#include "common/settings.h"
#include "core/core.h"
#include "ui_configure_audio.h"
@@ -18,11 +15,11 @@ ConfigureAudio::ConfigureAudio(const Core::System& system_, QWidget* parent)
: QWidget(parent), ui(std::make_unique<Ui::ConfigureAudio>()), system{system_} {
ui->setupUi(this);
- InitializeAudioOutputSinkComboBox();
+ InitializeAudioSinkComboBox();
connect(ui->volume_slider, &QSlider::valueChanged, this,
&ConfigureAudio::SetVolumeIndicatorText);
- connect(ui->output_sink_combo_box, qOverload<int>(&QComboBox::currentIndexChanged), this,
+ connect(ui->sink_combo_box, qOverload<int>(&QComboBox::currentIndexChanged), this,
&ConfigureAudio::UpdateAudioDevices);
ui->volume_label->setVisible(Settings::IsConfiguringGlobal());
@@ -33,8 +30,9 @@ ConfigureAudio::ConfigureAudio(const Core::System& system_, QWidget* parent)
SetConfiguration();
const bool is_powered_on = system_.IsPoweredOn();
- ui->output_sink_combo_box->setEnabled(!is_powered_on);
- ui->audio_device_combo_box->setEnabled(!is_powered_on);
+ ui->sink_combo_box->setEnabled(!is_powered_on);
+ ui->output_combo_box->setEnabled(!is_powered_on);
+ ui->input_combo_box->setEnabled(!is_powered_on);
}
ConfigureAudio::~ConfigureAudio() = default;
@@ -43,9 +41,9 @@ void ConfigureAudio::SetConfiguration() {
SetOutputSinkFromSinkID();
// The device list cannot be pre-populated (nor listed) until the output sink is known.
- UpdateAudioDevices(ui->output_sink_combo_box->currentIndex());
+ UpdateAudioDevices(ui->sink_combo_box->currentIndex());
- SetAudioDeviceFromDeviceID();
+ SetAudioDevicesFromDeviceID();
const auto volume_value = static_cast<int>(Settings::values.volume.GetValue());
ui->volume_slider->setValue(volume_value);
@@ -65,32 +63,45 @@ void ConfigureAudio::SetConfiguration() {
}
void ConfigureAudio::SetOutputSinkFromSinkID() {
- [[maybe_unused]] const QSignalBlocker blocker(ui->output_sink_combo_box);
+ [[maybe_unused]] const QSignalBlocker blocker(ui->sink_combo_box);
int new_sink_index = 0;
const QString sink_id = QString::fromStdString(Settings::values.sink_id.GetValue());
- for (int index = 0; index < ui->output_sink_combo_box->count(); index++) {
- if (ui->output_sink_combo_box->itemText(index) == sink_id) {
+ for (int index = 0; index < ui->sink_combo_box->count(); index++) {
+ if (ui->sink_combo_box->itemText(index) == sink_id) {
new_sink_index = index;
break;
}
}
- ui->output_sink_combo_box->setCurrentIndex(new_sink_index);
+ ui->sink_combo_box->setCurrentIndex(new_sink_index);
}
-void ConfigureAudio::SetAudioDeviceFromDeviceID() {
+void ConfigureAudio::SetAudioDevicesFromDeviceID() {
int new_device_index = -1;
- const QString device_id = QString::fromStdString(Settings::values.audio_device_id.GetValue());
- for (int index = 0; index < ui->audio_device_combo_box->count(); index++) {
- if (ui->audio_device_combo_box->itemText(index) == device_id) {
+ const QString output_device_id =
+ QString::fromStdString(Settings::values.audio_output_device_id.GetValue());
+ for (int index = 0; index < ui->output_combo_box->count(); index++) {
+ if (ui->output_combo_box->itemText(index) == output_device_id) {
+ new_device_index = index;
+ break;
+ }
+ }
+
+ ui->output_combo_box->setCurrentIndex(new_device_index);
+
+ new_device_index = -1;
+ const QString input_device_id =
+ QString::fromStdString(Settings::values.audio_input_device_id.GetValue());
+ for (int index = 0; index < ui->input_combo_box->count(); index++) {
+ if (ui->input_combo_box->itemText(index) == input_device_id) {
new_device_index = index;
break;
}
}
- ui->audio_device_combo_box->setCurrentIndex(new_device_index);
+ ui->input_combo_box->setCurrentIndex(new_device_index);
}
void ConfigureAudio::SetVolumeIndicatorText(int percentage) {
@@ -98,14 +109,13 @@ void ConfigureAudio::SetVolumeIndicatorText(int percentage) {
}
void ConfigureAudio::ApplyConfiguration() {
-
if (Settings::IsConfiguringGlobal()) {
Settings::values.sink_id =
- ui->output_sink_combo_box->itemText(ui->output_sink_combo_box->currentIndex())
- .toStdString();
- Settings::values.audio_device_id.SetValue(
- ui->audio_device_combo_box->itemText(ui->audio_device_combo_box->currentIndex())
- .toStdString());
+ ui->sink_combo_box->itemText(ui->sink_combo_box->currentIndex()).toStdString();
+ Settings::values.audio_output_device_id.SetValue(
+ ui->output_combo_box->itemText(ui->output_combo_box->currentIndex()).toStdString());
+ Settings::values.audio_input_device_id.SetValue(
+ ui->input_combo_box->itemText(ui->input_combo_box->currentIndex()).toStdString());
// Guard if during game and set to game-specific value
if (Settings::values.volume.UsingGlobal()) {
@@ -132,21 +142,27 @@ void ConfigureAudio::changeEvent(QEvent* event) {
}
void ConfigureAudio::UpdateAudioDevices(int sink_index) {
- ui->audio_device_combo_box->clear();
- ui->audio_device_combo_box->addItem(QString::fromUtf8(AudioCore::auto_device_name));
+ ui->output_combo_box->clear();
+ ui->output_combo_box->addItem(QString::fromUtf8(AudioCore::Sink::auto_device_name));
+
+ const std::string sink_id = ui->sink_combo_box->itemText(sink_index).toStdString();
+ for (const auto& device : AudioCore::Sink::GetDeviceListForSink(sink_id, false)) {
+ ui->output_combo_box->addItem(QString::fromStdString(device));
+ }
- const std::string sink_id = ui->output_sink_combo_box->itemText(sink_index).toStdString();
- for (const auto& device : AudioCore::GetDeviceListForSink(sink_id)) {
- ui->audio_device_combo_box->addItem(QString::fromStdString(device));
+ ui->input_combo_box->clear();
+ ui->input_combo_box->addItem(QString::fromUtf8(AudioCore::Sink::auto_device_name));
+ for (const auto& device : AudioCore::Sink::GetDeviceListForSink(sink_id, true)) {
+ ui->input_combo_box->addItem(QString::fromStdString(device));
}
}
-void ConfigureAudio::InitializeAudioOutputSinkComboBox() {
- ui->output_sink_combo_box->clear();
- ui->output_sink_combo_box->addItem(QString::fromUtf8(AudioCore::auto_device_name));
+void ConfigureAudio::InitializeAudioSinkComboBox() {
+ ui->sink_combo_box->clear();
+ ui->sink_combo_box->addItem(QString::fromUtf8(AudioCore::Sink::auto_device_name));
- for (const char* id : AudioCore::GetSinkIDs()) {
- ui->output_sink_combo_box->addItem(QString::fromUtf8(id));
+ for (const char* id : AudioCore::Sink::GetSinkIDs()) {
+ ui->sink_combo_box->addItem(QString::fromUtf8(id));
}
}
@@ -167,8 +183,10 @@ void ConfigureAudio::SetupPerGameUI() {
ConfigurationShared::SetHighlight(ui->volume_layout, index == 1);
});
- ui->output_sink_combo_box->setVisible(false);
- ui->output_sink_label->setVisible(false);
- ui->audio_device_combo_box->setVisible(false);
- ui->audio_device_label->setVisible(false);
+ ui->sink_combo_box->setVisible(false);
+ ui->sink_label->setVisible(false);
+ ui->output_combo_box->setVisible(false);
+ ui->output_label->setVisible(false);
+ ui->input_combo_box->setVisible(false);
+ ui->input_label->setVisible(false);
}
diff --git a/src/yuzu/configuration/configure_audio.h b/src/yuzu/configuration/configure_audio.h
index 5d2d05e47..0d03aae1d 100644
--- a/src/yuzu/configuration/configure_audio.h
+++ b/src/yuzu/configuration/configure_audio.h
@@ -1,6 +1,5 @@
-// Copyright 2018 yuzu Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
@@ -32,14 +31,14 @@ public:
private:
void changeEvent(QEvent* event) override;
- void InitializeAudioOutputSinkComboBox();
+ void InitializeAudioSinkComboBox();
void RetranslateUI();
void UpdateAudioDevices(int sink_index);
void SetOutputSinkFromSinkID();
- void SetAudioDeviceFromDeviceID();
+ void SetAudioDevicesFromDeviceID();
void SetVolumeIndicatorText(int percentage);
void SetupPerGameUI();
diff --git a/src/yuzu/configuration/configure_audio.ui b/src/yuzu/configuration/configure_audio.ui
index d1ac8ad02..6034d8581 100644
--- a/src/yuzu/configuration/configure_audio.ui
+++ b/src/yuzu/configuration/configure_audio.ui
@@ -21,30 +21,44 @@
</property>
<layout class="QVBoxLayout">
<item>
- <layout class="QHBoxLayout" name="_3">
+ <layout class="QHBoxLayout" name="engine_layout">
<item>
- <widget class="QLabel" name="output_sink_label">
+ <widget class="QLabel" name="sink_label">
<property name="text">
<string>Output Engine:</string>
</property>
</widget>
</item>
<item>
- <widget class="QComboBox" name="output_sink_combo_box"/>
+ <widget class="QComboBox" name="sink_combo_box"/>
</item>
</layout>
</item>
<item>
- <layout class="QHBoxLayout" name="_2">
+ <layout class="QHBoxLayout" name="output_layout">
<item>
- <widget class="QLabel" name="audio_device_label">
+ <widget class="QLabel" name="output_label">
<property name="text">
- <string>Audio Device:</string>
+ <string>Output Device</string>
</property>
</widget>
</item>
<item>
- <widget class="QComboBox" name="audio_device_combo_box"/>
+ <widget class="QComboBox" name="output_combo_box"/>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="input_layout">
+ <item>
+ <widget class="QLabel" name="input_label">
+ <property name="text">
+ <string>Input Device</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QComboBox" name="input_combo_box"/>
</item>
</layout>
</item>
@@ -106,10 +120,10 @@
</sizepolicy>
</property>
<property name="maximum">
- <number>100</number>
+ <number>200</number>
</property>
<property name="pageStep">
- <number>10</number>
+ <number>5</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
diff --git a/src/yuzu/configuration/configure_camera.cpp b/src/yuzu/configuration/configure_camera.cpp
new file mode 100644
index 000000000..2a61de2a1
--- /dev/null
+++ b/src/yuzu/configuration/configure_camera.cpp
@@ -0,0 +1,156 @@
+// Text : Copyright 2022 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-3.0-or-later
+
+#include <memory>
+#include <QCameraImageCapture>
+#include <QCameraInfo>
+#include <QStandardItemModel>
+#include <QTimer>
+
+#include "input_common/drivers/camera.h"
+#include "input_common/main.h"
+#include "ui_configure_camera.h"
+#include "yuzu/configuration/config.h"
+#include "yuzu/configuration/configure_camera.h"
+
+ConfigureCamera::ConfigureCamera(QWidget* parent, InputCommon::InputSubsystem* input_subsystem_)
+ : QDialog(parent), input_subsystem{input_subsystem_},
+ ui(std::make_unique<Ui::ConfigureCamera>()) {
+ ui->setupUi(this);
+
+ connect(ui->restore_defaults_button, &QPushButton::clicked, this,
+ &ConfigureCamera::RestoreDefaults);
+ connect(ui->preview_button, &QPushButton::clicked, this, &ConfigureCamera::PreviewCamera);
+
+ auto blank_image = QImage(320, 240, QImage::Format::Format_RGB32);
+ blank_image.fill(Qt::black);
+ DisplayCapturedFrame(0, blank_image);
+
+ LoadConfiguration();
+ resize(0, 0);
+}
+
+ConfigureCamera::~ConfigureCamera() = default;
+
+void ConfigureCamera::PreviewCamera() {
+ const auto index = ui->ir_sensor_combo_box->currentIndex();
+ bool camera_found = false;
+ const QList<QCameraInfo> cameras = QCameraInfo::availableCameras();
+ for (const QCameraInfo& cameraInfo : cameras) {
+ if (input_devices[index] == cameraInfo.deviceName().toStdString() ||
+ input_devices[index] == "Auto") {
+ LOG_INFO(Frontend, "Selected Camera {} {}", cameraInfo.description().toStdString(),
+ cameraInfo.deviceName().toStdString());
+ camera = std::make_unique<QCamera>(cameraInfo);
+ if (!camera->isCaptureModeSupported(QCamera::CaptureMode::CaptureViewfinder) &&
+ !camera->isCaptureModeSupported(QCamera::CaptureMode::CaptureStillImage)) {
+ LOG_ERROR(Frontend,
+ "Camera doesn't support CaptureViewfinder or CaptureStillImage");
+ continue;
+ }
+ camera_found = true;
+ break;
+ }
+ }
+
+ // Clear previous frame
+ auto blank_image = QImage(320, 240, QImage::Format::Format_RGB32);
+ blank_image.fill(Qt::black);
+ DisplayCapturedFrame(0, blank_image);
+
+ if (!camera_found) {
+ return;
+ }
+
+ camera_capture = std::make_unique<QCameraImageCapture>(camera.get());
+
+ if (!camera_capture->isCaptureDestinationSupported(
+ QCameraImageCapture::CaptureDestination::CaptureToBuffer)) {
+ LOG_ERROR(Frontend, "Camera doesn't support saving to buffer");
+ return;
+ }
+
+ camera_capture->setCaptureDestination(QCameraImageCapture::CaptureDestination::CaptureToBuffer);
+ connect(camera_capture.get(), &QCameraImageCapture::imageCaptured, this,
+ &ConfigureCamera::DisplayCapturedFrame);
+ camera->unload();
+ if (camera->isCaptureModeSupported(QCamera::CaptureMode::CaptureViewfinder)) {
+ camera->setCaptureMode(QCamera::CaptureViewfinder);
+ } else if (camera->isCaptureModeSupported(QCamera::CaptureMode::CaptureStillImage)) {
+ camera->setCaptureMode(QCamera::CaptureStillImage);
+ }
+ camera->load();
+ camera->start();
+
+ pending_snapshots = 0;
+ is_virtual_camera = false;
+
+ camera_timer = std::make_unique<QTimer>();
+ connect(camera_timer.get(), &QTimer::timeout, [this] {
+ // If the camera doesn't capture, test for virtual cameras
+ if (pending_snapshots > 5) {
+ is_virtual_camera = true;
+ }
+ // Virtual cameras like obs need to reset the camera every capture
+ if (is_virtual_camera) {
+ camera->stop();
+ camera->start();
+ }
+ pending_snapshots++;
+ camera_capture->capture();
+ });
+
+ camera_timer->start(250);
+}
+
+void ConfigureCamera::DisplayCapturedFrame(int requestId, const QImage& img) {
+ LOG_INFO(Frontend, "ImageCaptured {} {}", img.width(), img.height());
+ const auto converted = img.scaled(320, 240, Qt::AspectRatioMode::IgnoreAspectRatio,
+ Qt::TransformationMode::SmoothTransformation);
+ ui->preview_box->setPixmap(QPixmap::fromImage(converted));
+ pending_snapshots = 0;
+}
+
+void ConfigureCamera::changeEvent(QEvent* event) {
+ if (event->type() == QEvent::LanguageChange) {
+ RetranslateUI();
+ }
+
+ QDialog::changeEvent(event);
+}
+
+void ConfigureCamera::RetranslateUI() {
+ ui->retranslateUi(this);
+}
+
+void ConfigureCamera::ApplyConfiguration() {
+ const auto index = ui->ir_sensor_combo_box->currentIndex();
+ Settings::values.ir_sensor_device.SetValue(input_devices[index]);
+}
+
+void ConfigureCamera::LoadConfiguration() {
+ input_devices.clear();
+ ui->ir_sensor_combo_box->clear();
+ input_devices.push_back("Auto");
+ ui->ir_sensor_combo_box->addItem(tr("Auto"));
+ const auto cameras = QCameraInfo::availableCameras();
+ for (const QCameraInfo& cameraInfo : cameras) {
+ input_devices.push_back(cameraInfo.deviceName().toStdString());
+ ui->ir_sensor_combo_box->addItem(cameraInfo.description());
+ }
+
+ const auto current_device = Settings::values.ir_sensor_device.GetValue();
+
+ const auto devices_it = std::find_if(
+ input_devices.begin(), input_devices.end(),
+ [current_device](const std::string& device) { return device == current_device; });
+ const int device_index =
+ devices_it != input_devices.end()
+ ? static_cast<int>(std::distance(input_devices.begin(), devices_it))
+ : 0;
+ ui->ir_sensor_combo_box->setCurrentIndex(device_index);
+}
+
+void ConfigureCamera::RestoreDefaults() {
+ ui->ir_sensor_combo_box->setCurrentIndex(0);
+}
diff --git a/src/yuzu/configuration/configure_camera.h b/src/yuzu/configuration/configure_camera.h
new file mode 100644
index 000000000..db9833b5c
--- /dev/null
+++ b/src/yuzu/configuration/configure_camera.h
@@ -0,0 +1,54 @@
+// Text : Copyright 2022 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-3.0-or-later
+
+#pragma once
+
+#include <memory>
+#include <QDialog>
+
+class QTimer;
+class QCamera;
+class QCameraImageCapture;
+
+namespace InputCommon {
+class InputSubsystem;
+} // namespace InputCommon
+
+namespace Ui {
+class ConfigureCamera;
+}
+
+class ConfigureCamera : public QDialog {
+ Q_OBJECT
+
+public:
+ explicit ConfigureCamera(QWidget* parent, InputCommon::InputSubsystem* input_subsystem_);
+ ~ConfigureCamera() override;
+
+ void ApplyConfiguration();
+
+private:
+ void changeEvent(QEvent* event) override;
+ void RetranslateUI();
+
+ /// Load configuration settings.
+ void LoadConfiguration();
+
+ /// Restore all buttons to their default values.
+ void RestoreDefaults();
+
+ void DisplayCapturedFrame(int requestId, const QImage& img);
+
+ /// Loads and signals the current selected camera to display a frame
+ void PreviewCamera();
+
+ InputCommon::InputSubsystem* input_subsystem;
+
+ bool is_virtual_camera;
+ int pending_snapshots;
+ std::unique_ptr<QCamera> camera;
+ std::unique_ptr<QCameraImageCapture> camera_capture;
+ std::unique_ptr<QTimer> camera_timer;
+ std::vector<std::string> input_devices;
+ std::unique_ptr<Ui::ConfigureCamera> ui;
+};
diff --git a/src/yuzu/configuration/configure_camera.ui b/src/yuzu/configuration/configure_camera.ui
new file mode 100644
index 000000000..976a9b1ec
--- /dev/null
+++ b/src/yuzu/configuration/configure_camera.ui
@@ -0,0 +1,170 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>ConfigureCamera</class>
+ <widget class="QDialog" name="ConfigureCamera">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>298</width>
+ <height>339</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Configure Infrared Camera</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QLabel" name="label_2">
+ <property name="minimumSize">
+ <size>
+ <width>280</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>Select where the image of the emulated camera comes from. It may be a virtual camera or a real camera.</string>
+ </property>
+ <property name="wordWrap">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="verticalSpacer_2">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Fixed</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="gridGroupBox">
+ <property name="title">
+ <string>Camera Image Source:</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="0">
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="0" column="1">
+ <widget class="QLabel" name="label_3">
+ <property name="text">
+ <string>Input device:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="2">
+ <widget class="QComboBox" name="ir_sensor_combo_box"/>
+ </item>
+ <item row="0" column="3">
+ <spacer name="horizontalSpacer_2">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </widget>
+ </item><item>
+ <widget class="QGroupBox" name="previewBox">
+ <property name="title">
+ <string>Preview</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_3">
+ <item>
+ <widget class="QLabel" name="preview_box">
+ <property name="minimumSize">
+ <size>
+ <width>320</width>
+ <height>240</height>
+ </size>
+ </property>
+ <property name="toolTip">
+ <string>Resolution: 320*240</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="preview_button">
+ <property name="text">
+ <string>Click to preview</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </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>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QPushButton" name="restore_defaults_button">
+ <property name="text">
+ <string>Restore Defaults</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QDialogButtonBox" name="buttonBox">
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>accepted()</signal>
+ <receiver>ConfigureCamera</receiver>
+ <slot>accept()</slot>
+ </connection>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>rejected()</signal>
+ <receiver>ConfigureCamera</receiver>
+ <slot>reject()</slot>
+ </connection>
+ </connections>
+</ui>
diff --git a/src/yuzu/configuration/configure_cpu.cpp b/src/yuzu/configuration/configure_cpu.cpp
index f66cab5d4..3d69fb03f 100644
--- a/src/yuzu/configuration/configure_cpu.cpp
+++ b/src/yuzu/configuration/configure_cpu.cpp
@@ -1,12 +1,7 @@
-// Copyright 2020 yuzu Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
-
-#include <QComboBox>
-#include <QMessageBox>
+// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#include "common/common_types.h"
-#include "common/logging/log.h"
#include "common/settings.h"
#include "core/core.h"
#include "ui_configure_cpu.h"
@@ -36,6 +31,7 @@ void ConfigureCpu::SetConfiguration() {
ui->cpuopt_unsafe_ignore_standard_fpcr->setEnabled(runtime_lock);
ui->cpuopt_unsafe_inaccurate_nan->setEnabled(runtime_lock);
ui->cpuopt_unsafe_fastmem_check->setEnabled(runtime_lock);
+ ui->cpuopt_unsafe_ignore_global_monitor->setEnabled(runtime_lock);
ui->cpuopt_unsafe_unfuse_fma->setChecked(Settings::values.cpuopt_unsafe_unfuse_fma.GetValue());
ui->cpuopt_unsafe_reduce_fp_error->setChecked(
@@ -46,6 +42,8 @@ void ConfigureCpu::SetConfiguration() {
Settings::values.cpuopt_unsafe_inaccurate_nan.GetValue());
ui->cpuopt_unsafe_fastmem_check->setChecked(
Settings::values.cpuopt_unsafe_fastmem_check.GetValue());
+ ui->cpuopt_unsafe_ignore_global_monitor->setChecked(
+ Settings::values.cpuopt_unsafe_ignore_global_monitor.GetValue());
if (Settings::IsConfiguringGlobal()) {
ui->accuracy->setCurrentIndex(static_cast<int>(Settings::values.cpu_accuracy.GetValue()));
@@ -82,6 +80,9 @@ void ConfigureCpu::ApplyConfiguration() {
ConfigurationShared::ApplyPerGameSetting(&Settings::values.cpuopt_unsafe_fastmem_check,
ui->cpuopt_unsafe_fastmem_check,
cpuopt_unsafe_fastmem_check);
+ ConfigurationShared::ApplyPerGameSetting(&Settings::values.cpuopt_unsafe_ignore_global_monitor,
+ ui->cpuopt_unsafe_ignore_global_monitor,
+ cpuopt_unsafe_ignore_global_monitor);
}
void ConfigureCpu::changeEvent(QEvent* event) {
@@ -120,4 +121,7 @@ void ConfigureCpu::SetupPerGameUI() {
ConfigurationShared::SetColoredTristate(ui->cpuopt_unsafe_fastmem_check,
Settings::values.cpuopt_unsafe_fastmem_check,
cpuopt_unsafe_fastmem_check);
+ ConfigurationShared::SetColoredTristate(ui->cpuopt_unsafe_ignore_global_monitor,
+ Settings::values.cpuopt_unsafe_ignore_global_monitor,
+ cpuopt_unsafe_ignore_global_monitor);
}
diff --git a/src/yuzu/configuration/configure_cpu.h b/src/yuzu/configuration/configure_cpu.h
index ed9af0e9f..86d928ca3 100644
--- a/src/yuzu/configuration/configure_cpu.h
+++ b/src/yuzu/configuration/configure_cpu.h
@@ -1,12 +1,10 @@
-// Copyright 2020 yuzu Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include <memory>
#include <QWidget>
-#include "common/settings.h"
namespace Core {
class System;
@@ -45,6 +43,7 @@ private:
ConfigurationShared::CheckState cpuopt_unsafe_ignore_standard_fpcr;
ConfigurationShared::CheckState cpuopt_unsafe_inaccurate_nan;
ConfigurationShared::CheckState cpuopt_unsafe_fastmem_check;
+ ConfigurationShared::CheckState cpuopt_unsafe_ignore_global_monitor;
const Core::System& system;
};
diff --git a/src/yuzu/configuration/configure_cpu.ui b/src/yuzu/configuration/configure_cpu.ui
index d8064db24..8ae569ee6 100644
--- a/src/yuzu/configuration/configure_cpu.ui
+++ b/src/yuzu/configuration/configure_cpu.ui
@@ -52,6 +52,11 @@
<string>Unsafe</string>
</property>
</item>
+ <item>
+ <property name="text">
+ <string>Paranoid (disables most optimizations)</string>
+ </property>
+ </item>
</widget>
</item>
</layout>
@@ -150,6 +155,18 @@
</property>
</widget>
</item>
+ <item>
+ <widget class="QCheckBox" name="cpuopt_unsafe_ignore_global_monitor">
+ <property name="toolTip">
+ <string>
+ &lt;div&gt;This option improves speed by relying only on the semantics of cmpxchg to ensure safety of exclusive access instructions. Please note this may result in deadlocks and other race conditions.&lt;/div&gt;
+ </string>
+ </property>
+ <property name="text">
+ <string>Ignore global monitor</string>
+ </property>
+ </widget>
+ </item>
</layout>
</widget>
</item>
diff --git a/src/yuzu/configuration/configure_cpu_debug.cpp b/src/yuzu/configuration/configure_cpu_debug.cpp
index 05a90963d..3c302ec16 100644
--- a/src/yuzu/configuration/configure_cpu_debug.cpp
+++ b/src/yuzu/configuration/configure_cpu_debug.cpp
@@ -1,11 +1,6 @@
-// Copyright 2020 yuzu Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
-#include <QComboBox>
-
-#include "common/common_types.h"
-#include "common/logging/log.h"
#include "common/settings.h"
#include "core/core.h"
#include "ui_configure_cpu_debug.h"
@@ -44,6 +39,12 @@ void ConfigureCpuDebug::SetConfiguration() {
Settings::values.cpuopt_reduce_misalign_checks.GetValue());
ui->cpuopt_fastmem->setEnabled(runtime_lock);
ui->cpuopt_fastmem->setChecked(Settings::values.cpuopt_fastmem.GetValue());
+ ui->cpuopt_fastmem_exclusives->setEnabled(runtime_lock);
+ ui->cpuopt_fastmem_exclusives->setChecked(
+ Settings::values.cpuopt_fastmem_exclusives.GetValue());
+ ui->cpuopt_recompile_exclusives->setEnabled(runtime_lock);
+ ui->cpuopt_recompile_exclusives->setChecked(
+ Settings::values.cpuopt_recompile_exclusives.GetValue());
}
void ConfigureCpuDebug::ApplyConfiguration() {
@@ -56,6 +57,8 @@ void ConfigureCpuDebug::ApplyConfiguration() {
Settings::values.cpuopt_misc_ir = ui->cpuopt_misc_ir->isChecked();
Settings::values.cpuopt_reduce_misalign_checks = ui->cpuopt_reduce_misalign_checks->isChecked();
Settings::values.cpuopt_fastmem = ui->cpuopt_fastmem->isChecked();
+ Settings::values.cpuopt_fastmem_exclusives = ui->cpuopt_fastmem_exclusives->isChecked();
+ Settings::values.cpuopt_recompile_exclusives = ui->cpuopt_recompile_exclusives->isChecked();
}
void ConfigureCpuDebug::changeEvent(QEvent* event) {
diff --git a/src/yuzu/configuration/configure_cpu_debug.h b/src/yuzu/configuration/configure_cpu_debug.h
index d06c4c63f..566ae7ecc 100644
--- a/src/yuzu/configuration/configure_cpu_debug.h
+++ b/src/yuzu/configuration/configure_cpu_debug.h
@@ -1,6 +1,5 @@
-// Copyright 2020 yuzu Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
diff --git a/src/yuzu/configuration/configure_cpu_debug.ui b/src/yuzu/configuration/configure_cpu_debug.ui
index 6e635bb2f..2bc268810 100644
--- a/src/yuzu/configuration/configure_cpu_debug.ui
+++ b/src/yuzu/configuration/configure_cpu_debug.ui
@@ -144,7 +144,34 @@
</string>
</property>
<property name="text">
- <string>Enable Host MMU Emulation</string>
+ <string>Enable Host MMU Emulation (general memory instructions)</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="cpuopt_fastmem_exclusives">
+ <property name="toolTip">
+ <string>
+ &lt;div style=&quot;white-space: nowrap&quot;&gt;This optimization speeds up exclusive memory accesses by the guest program.&lt;/div&gt;
+ &lt;div style=&quot;white-space: nowrap&quot;&gt;Enabling it causes guest exclusive memory reads/writes to be done directly into memory and make use of Host's MMU.&lt;/div&gt;
+ &lt;div style=&quot;white-space: nowrap&quot;&gt;Disabling this forces all exclusive memory accesses to use Software MMU Emulation.&lt;/div&gt;
+ </string>
+ </property>
+ <property name="text">
+ <string>Enable Host MMU Emulation (exclusive memory instructions)</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="cpuopt_recompile_exclusives">
+ <property name="toolTip">
+ <string>
+ &lt;div style=&quot;white-space: nowrap&quot;&gt;This optimization speeds up exclusive memory accesses by the guest program.&lt;/div&gt;
+ &lt;div style=&quot;white-space: nowrap&quot;&gt;Enabling it reduces the overhead of fastmem failure of exclusive memory accesses.&lt;/div&gt;
+ </string>
+ </property>
+ <property name="text">
+ <string>Enable recompilation of exclusive memory instructions</string>
</property>
</widget>
</item>
diff --git a/src/yuzu/configuration/configure_debug.cpp b/src/yuzu/configuration/configure_debug.cpp
index c1cf4050c..dacc75a20 100644
--- a/src/yuzu/configuration/configure_debug.cpp
+++ b/src/yuzu/configuration/configure_debug.cpp
@@ -1,8 +1,8 @@
-// Copyright 2016 Citra Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: 2016 Citra Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#include <QDesktopServices>
+#include <QMessageBox>
#include <QUrl>
#include "common/fs/path_util.h"
#include "common/logging/backend.h"
@@ -15,7 +15,7 @@
#include "yuzu/uisettings.h"
ConfigureDebug::ConfigureDebug(const Core::System& system_, QWidget* parent)
- : QWidget(parent), ui{std::make_unique<Ui::ConfigureDebug>()}, system{system_} {
+ : QScrollArea(parent), ui{std::make_unique<Ui::ConfigureDebug>()}, system{system_} {
ui->setupUi(this);
SetConfiguration();
@@ -24,13 +24,28 @@ ConfigureDebug::ConfigureDebug(const Core::System& system_, QWidget* parent)
QString::fromStdString(Common::FS::GetYuzuPathString(Common::FS::YuzuPath::LogDir));
QDesktopServices::openUrl(QUrl::fromLocalFile(path));
});
+
+ connect(ui->toggle_gdbstub, &QCheckBox::toggled,
+ [&]() { ui->gdbport_spinbox->setEnabled(ui->toggle_gdbstub->isChecked()); });
+
+ connect(ui->create_crash_dumps, &QCheckBox::stateChanged, [&](int) {
+ if (crash_dump_warning_shown) {
+ return;
+ }
+ QMessageBox::warning(this, tr("Restart Required"),
+ tr("yuzu is required to restart in order to apply this setting."),
+ QMessageBox::Ok, QMessageBox::Ok);
+ crash_dump_warning_shown = true;
+ });
}
ConfigureDebug::~ConfigureDebug() = default;
void ConfigureDebug::SetConfiguration() {
const bool runtime_lock = !system.IsPoweredOn();
-
+ ui->toggle_gdbstub->setChecked(Settings::values.use_gdbstub.GetValue());
+ ui->gdbport_spinbox->setEnabled(Settings::values.use_gdbstub.GetValue());
+ ui->gdbport_spinbox->setValue(Settings::values.gdbstub_port.GetValue());
ui->toggle_console->setEnabled(runtime_lock);
ui->toggle_console->setChecked(UISettings::values.show_console.GetValue());
ui->log_filter_edit->setText(QString::fromStdString(Settings::values.log_filter.GetValue()));
@@ -39,6 +54,7 @@ void ConfigureDebug::SetConfiguration() {
ui->fs_access_log->setEnabled(runtime_lock);
ui->fs_access_log->setChecked(Settings::values.enable_fs_access_log.GetValue());
ui->reporting_services->setChecked(Settings::values.reporting_services.GetValue());
+ ui->dump_audio_commands->setChecked(Settings::values.dump_audio_commands.GetValue());
ui->quest_flag->setChecked(Settings::values.quest_flag.GetValue());
ui->use_debug_asserts->setChecked(Settings::values.use_debug_asserts.GetValue());
ui->use_auto_stub->setChecked(Settings::values.use_auto_stub.GetValue());
@@ -53,20 +69,41 @@ void ConfigureDebug::SetConfiguration() {
ui->enable_nsight_aftermath->setChecked(Settings::values.enable_nsight_aftermath.GetValue());
ui->dump_shaders->setEnabled(runtime_lock);
ui->dump_shaders->setChecked(Settings::values.dump_shaders.GetValue());
+ ui->dump_macros->setEnabled(runtime_lock);
+ ui->dump_macros->setChecked(Settings::values.dump_macros.GetValue());
ui->disable_macro_jit->setEnabled(runtime_lock);
ui->disable_macro_jit->setChecked(Settings::values.disable_macro_jit.GetValue());
ui->disable_loop_safety_checks->setEnabled(runtime_lock);
ui->disable_loop_safety_checks->setChecked(
Settings::values.disable_shader_loop_safety_checks.GetValue());
ui->extended_logging->setChecked(Settings::values.extended_logging.GetValue());
+ ui->perform_vulkan_check->setChecked(Settings::values.perform_vulkan_check.GetValue());
+
+#ifdef YUZU_USE_QT_WEB_ENGINE
+ ui->disable_web_applet->setChecked(UISettings::values.disable_web_applet.GetValue());
+#else
+ ui->disable_web_applet->setEnabled(false);
+ ui->disable_web_applet->setText(tr("Web applet not compiled"));
+#endif
+
+#ifdef YUZU_DBGHELP
+ ui->create_crash_dumps->setChecked(Settings::values.create_crash_dumps.GetValue());
+#else
+ ui->create_crash_dumps->setEnabled(false);
+ ui->create_crash_dumps->setText(tr("MiniDump creation not compiled"));
+#endif
}
void ConfigureDebug::ApplyConfiguration() {
+ Settings::values.use_gdbstub = ui->toggle_gdbstub->isChecked();
+ Settings::values.gdbstub_port = ui->gdbport_spinbox->value();
UISettings::values.show_console = ui->toggle_console->isChecked();
Settings::values.log_filter = ui->log_filter_edit->text().toStdString();
Settings::values.program_args = ui->homebrew_args_edit->text().toStdString();
Settings::values.enable_fs_access_log = ui->fs_access_log->isChecked();
Settings::values.reporting_services = ui->reporting_services->isChecked();
+ Settings::values.dump_audio_commands = ui->dump_audio_commands->isChecked();
+ Settings::values.create_crash_dumps = ui->create_crash_dumps->isChecked();
Settings::values.quest_flag = ui->quest_flag->isChecked();
Settings::values.use_debug_asserts = ui->use_debug_asserts->isChecked();
Settings::values.use_auto_stub = ui->use_auto_stub->isChecked();
@@ -76,10 +113,13 @@ void ConfigureDebug::ApplyConfiguration() {
Settings::values.cpu_debug_mode = ui->enable_cpu_debugging->isChecked();
Settings::values.enable_nsight_aftermath = ui->enable_nsight_aftermath->isChecked();
Settings::values.dump_shaders = ui->dump_shaders->isChecked();
+ Settings::values.dump_macros = ui->dump_macros->isChecked();
Settings::values.disable_shader_loop_safety_checks =
ui->disable_loop_safety_checks->isChecked();
Settings::values.disable_macro_jit = ui->disable_macro_jit->isChecked();
Settings::values.extended_logging = ui->extended_logging->isChecked();
+ Settings::values.perform_vulkan_check = ui->perform_vulkan_check->isChecked();
+ UISettings::values.disable_web_applet = ui->disable_web_applet->isChecked();
Debugger::ToggleConsole();
Common::Log::Filter filter;
filter.ParseFilterString(Settings::values.log_filter.GetValue());
diff --git a/src/yuzu/configuration/configure_debug.h b/src/yuzu/configuration/configure_debug.h
index 73f71c9e3..030a0b7f7 100644
--- a/src/yuzu/configuration/configure_debug.h
+++ b/src/yuzu/configuration/configure_debug.h
@@ -1,11 +1,10 @@
-// Copyright 2016 Citra Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: 2016 Citra Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include <memory>
-#include <QWidget>
+#include <QScrollArea>
namespace Core {
class System;
@@ -15,7 +14,7 @@ namespace Ui {
class ConfigureDebug;
}
-class ConfigureDebug : public QWidget {
+class ConfigureDebug : public QScrollArea {
Q_OBJECT
public:
@@ -33,4 +32,6 @@ private:
std::unique_ptr<Ui::ConfigureDebug> ui;
const Core::System& system;
+
+ bool crash_dump_warning_shown{false};
};
diff --git a/src/yuzu/configuration/configure_debug.ui b/src/yuzu/configuration/configure_debug.ui
index 4dd870855..102c8c66c 100644
--- a/src/yuzu/configuration/configure_debug.ui
+++ b/src/yuzu/configuration/configure_debug.ui
@@ -1,56 +1,114 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ConfigureDebug</class>
- <widget class="QWidget" name="ConfigureDebug">
+ <widget class="QScrollArea" name="ConfigureDebug">
+ <property name="widgetResizable">
+ <bool>true</bool>
+ </property>
+ <widget class="QWidget">
<layout class="QVBoxLayout" name="verticalLayout_1">
<item>
- <widget class="QGroupBox" name="groupBox_2">
- <property name="title">
- <string>Logging</string>
- </property>
- <layout class="QGridLayout" name="gridLayout_1">
- <item row="0" column="0" colspan="2">
- <layout class="QHBoxLayout" name="horizontalLayout_1">
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <item>
+ <widget class="QGroupBox" name="groupBox">
+ <property name="title">
+ <string>Debugger</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_3">
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_11">
<item>
- <widget class="QLabel" name="label_1">
- <property name="text">
- <string>Global Log Filter</string>
- </property>
+ <widget class="QCheckBox" name="toggle_gdbstub">
+ <property name="text">
+ <string>Enable GDB Stub</string>
+ </property>
</widget>
</item>
<item>
- <widget class="QLineEdit" name="log_filter_edit"/>
- </item>
- </layout>
- </item>
- <item row="1" column="0">
- <widget class="QCheckBox" name="toggle_console">
- <property name="text">
- <string>Show Log in Console</string>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="QPushButton" name="open_log_button">
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QLabel" name="label_11">
<property name="text">
- <string>Open Log Location</string>
+ <string>Port:</string>
</property>
</widget>
</item>
- <item row="2" column="0">
- <widget class="QCheckBox" name="extended_logging">
- <property name="enabled">
- <bool>true</bool>
- </property>
- <property name="toolTip">
- <string>When checked, the max size of the log increases from 100 MB to 1 GB</string>
- </property>
+ <item>
+ <widget class="QSpinBox" name="gdbport_spinbox">
+ <property name="minimum">
+ <number>1024</number>
+ </property>
+ <property name="maximum">
+ <number>65535</number>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="groupBox_2">
+ <property name="title">
+ <string>Logging</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout_1">
+ <item row="0" column="0" colspan="2">
+ <layout class="QHBoxLayout" name="horizontalLayout_1">
+ <item>
+ <widget class="QLabel" name="label_1">
<property name="text">
- <string>Enable Extended Logging**</string>
+ <string>Global Log Filter</string>
</property>
- </widget>
- </item>
- </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="log_filter_edit"/>
+ </item>
+ </layout>
+ </item>
+ <item row="1" column="0">
+ <widget class="QCheckBox" name="toggle_console">
+ <property name="text">
+ <string>Show Log in Console</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QPushButton" name="open_log_button">
+ <property name="text">
+ <string>Open Log Location</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QCheckBox" name="extended_logging">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="toolTip">
+ <string>When checked, the max size of the log increases from 100 MB to 1 GB</string>
+ </property>
+ <property name="text">
+ <string>Enable Extended Logging**</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
</widget>
</item>
<item>
@@ -118,6 +176,19 @@
</property>
</widget>
</item>
+ <item row="0" column="2">
+ <widget class="QCheckBox" name="dump_macros">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="toolTip">
+ <string>When checked, it will dump all the macro programs of the GPU</string>
+ </property>
+ <property name="text">
+ <string>Dump Maxwell Macros</string>
+ </property>
+ </widget>
+ </item>
<item row="0" column="1">
<widget class="QCheckBox" name="disable_macro_jit">
<property name="enabled">
@@ -160,6 +231,13 @@
<string>Debugging</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
+ <item row="2" column="0">
+ <widget class="QCheckBox" name="reporting_services">
+ <property name="text">
+ <string>Enable Verbose Reporting Services**</string>
+ </property>
+ </widget>
+ </item>
<item row="0" column="0">
<widget class="QCheckBox" name="fs_access_log">
<property name="text">
@@ -167,10 +245,20 @@
</property>
</widget>
</item>
- <item row="1" column="0">
- <widget class="QCheckBox" name="reporting_services">
+ <item row="0" column="1">
+ <widget class="QCheckBox" name="dump_audio_commands">
+ <property name="toolTip">
+ <string>Enable this to output the latest generated audio command list to the console. Only affects games using the audio renderer.</string>
+ </property>
<property name="text">
- <string>Enable Verbose Reporting Services**</string>
+ <string>Dump Audio Commands To Console**</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QCheckBox" name="create_crash_dumps">
+ <property name="text">
+ <string>Create Minidump After Crash</string>
</property>
</widget>
</item>
@@ -183,7 +271,7 @@
<string>Advanced</string>
</property>
<layout class="QGridLayout" name="gridLayout_4">
- <item> row="0" column="0">
+ <item row="0" column="0">
<widget class="QCheckBox" name="quest_flag">
<property name="text">
<string>Kiosk (Quest) Mode</string>
@@ -214,7 +302,24 @@
<item row="1" column="1">
<widget class="QCheckBox" name="enable_all_controllers">
<property name="text">
- <string>Enable all Controller Types</string>
+ <string>Enable All Controller Types</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QCheckBox" name="disable_web_applet">
+ <property name="text">
+ <string>Disable Web Applet</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0">
+ <widget class="QCheckBox" name="perform_vulkan_check">
+ <property name="toolTip">
+ <string>Enables yuzu to check for a working Vulkan environment when the program starts up. Disable this if this is causing issues with external programs seeing yuzu.</string>
+ </property>
+ <property name="text">
+ <string>Perform Startup Vulkan Check</string>
</property>
</widget>
</item>
@@ -238,6 +343,7 @@
</item>
</layout>
</widget>
+ </widget>
<tabstops>
<tabstop>log_filter_edit</tabstop>
<tabstop>toggle_console</tabstop>
diff --git a/src/yuzu/configuration/configure_debug_controller.cpp b/src/yuzu/configuration/configure_debug_controller.cpp
index 9a8de92a1..42abe9119 100644
--- a/src/yuzu/configuration/configure_debug_controller.cpp
+++ b/src/yuzu/configuration/configure_debug_controller.cpp
@@ -1,6 +1,5 @@
-// Copyright 2020 yuzu Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#include "core/hid/hid_core.h"
#include "ui_configure_debug_controller.h"
diff --git a/src/yuzu/configuration/configure_debug_controller.h b/src/yuzu/configuration/configure_debug_controller.h
index d716edbc2..aaed717e2 100644
--- a/src/yuzu/configuration/configure_debug_controller.h
+++ b/src/yuzu/configuration/configure_debug_controller.h
@@ -1,6 +1,5 @@
-// Copyright 2020 yuzu Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
diff --git a/src/yuzu/configuration/configure_debug_tab.cpp b/src/yuzu/configuration/configure_debug_tab.cpp
index e69cca1ef..d1ca4752a 100644
--- a/src/yuzu/configuration/configure_debug_tab.cpp
+++ b/src/yuzu/configuration/configure_debug_tab.cpp
@@ -1,6 +1,5 @@
-// Copyright 2021 yuzu Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#include <memory>
#include "ui_configure_debug_tab.h"
diff --git a/src/yuzu/configuration/configure_debug_tab.h b/src/yuzu/configuration/configure_debug_tab.h
index 4f68260aa..c0fd9f73f 100644
--- a/src/yuzu/configuration/configure_debug_tab.h
+++ b/src/yuzu/configuration/configure_debug_tab.h
@@ -1,6 +1,5 @@
-// Copyright 2021 yuzu Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
diff --git a/src/yuzu/configuration/configure_dialog.cpp b/src/yuzu/configuration/configure_dialog.cpp
index 19133ccf5..4301313cf 100644
--- a/src/yuzu/configuration/configure_dialog.cpp
+++ b/src/yuzu/configuration/configure_dialog.cpp
@@ -1,15 +1,7 @@
-// Copyright 2016 Citra Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: 2016 Citra Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#include <memory>
-#include <QAbstractButton>
-#include <QDialogButtonBox>
-#include <QHash>
-#include <QListWidgetItem>
-#include <QPushButton>
-#include <QSignalBlocker>
-#include <QTabWidget>
#include "common/logging/log.h"
#include "common/settings.h"
#include "core/core.h"
@@ -32,13 +24,14 @@
#include "yuzu/configuration/configure_ui.h"
#include "yuzu/configuration/configure_web.h"
#include "yuzu/hotkeys.h"
+#include "yuzu/uisettings.h"
-ConfigureDialog::ConfigureDialog(QWidget* parent, HotkeyRegistry& registry,
+ConfigureDialog::ConfigureDialog(QWidget* parent, HotkeyRegistry& registry_,
InputCommon::InputSubsystem* input_subsystem,
- Core::System& system_)
+ Core::System& system_, bool enable_web_config)
: QDialog(parent), ui{std::make_unique<Ui::ConfigureDialog>()},
- registry(registry), system{system_}, audio_tab{std::make_unique<ConfigureAudio>(system_,
- this)},
+ registry(registry_), system{system_}, audio_tab{std::make_unique<ConfigureAudio>(system_,
+ this)},
cpu_tab{std::make_unique<ConfigureCpu>(system_, this)},
debug_tab_tab{std::make_unique<ConfigureDebugTab>(system_, this)},
filesystem_tab{std::make_unique<ConfigureFilesystem>(this)},
@@ -71,6 +64,7 @@ ConfigureDialog::ConfigureDialog(QWidget* parent, HotkeyRegistry& registry,
ui->tabWidget->addTab(ui_tab.get(), tr("Game List"));
ui->tabWidget->addTab(web_tab.get(), tr("Web"));
+ web_tab->SetWebServiceConfigEnabled(enable_web_config);
hotkeys_tab->Populate(registry);
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
@@ -176,6 +170,8 @@ void ConfigureDialog::PopulateSelectionList() {
void ConfigureDialog::OnLanguageChanged(const QString& locale) {
emit LanguageChanged(locale);
+ // Reloading the game list is needed to force retranslation.
+ UISettings::values.is_game_list_reload_pending = true;
// first apply the configuration, and then restore the display
ApplyConfiguration();
RetranslateUI();
diff --git a/src/yuzu/configuration/configure_dialog.h b/src/yuzu/configuration/configure_dialog.h
index 32ddfd4e0..1f724834a 100644
--- a/src/yuzu/configuration/configure_dialog.h
+++ b/src/yuzu/configuration/configure_dialog.h
@@ -1,6 +1,5 @@
-// Copyright 2016 Citra Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: 2016 Citra Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
@@ -40,8 +39,9 @@ class ConfigureDialog : public QDialog {
Q_OBJECT
public:
- explicit ConfigureDialog(QWidget* parent, HotkeyRegistry& registry,
- InputCommon::InputSubsystem* input_subsystem, Core::System& system_);
+ explicit ConfigureDialog(QWidget* parent, HotkeyRegistry& registry_,
+ InputCommon::InputSubsystem* input_subsystem, Core::System& system_,
+ bool enable_web_config = true);
~ConfigureDialog() override;
void ApplyConfiguration();
diff --git a/src/yuzu/configuration/configure_filesystem.cpp b/src/yuzu/configuration/configure_filesystem.cpp
index d6fb43f8b..ad1951754 100644
--- a/src/yuzu/configuration/configure_filesystem.cpp
+++ b/src/yuzu/configuration/configure_filesystem.cpp
@@ -1,6 +1,5 @@
-// Copyright 2019 yuzu Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#include <QFileDialog>
#include <QMessageBox>
diff --git a/src/yuzu/configuration/configure_filesystem.h b/src/yuzu/configuration/configure_filesystem.h
index b4f9355eb..31d2f1d56 100644
--- a/src/yuzu/configuration/configure_filesystem.h
+++ b/src/yuzu/configuration/configure_filesystem.h
@@ -1,6 +1,5 @@
-// Copyright 2019 yuzu Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
diff --git a/src/yuzu/configuration/configure_general.cpp b/src/yuzu/configuration/configure_general.cpp
index 978a29fe6..7ade01ba6 100644
--- a/src/yuzu/configuration/configure_general.cpp
+++ b/src/yuzu/configuration/configure_general.cpp
@@ -1,16 +1,12 @@
-// Copyright 2016 Citra Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: 2016 Citra Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#include <functional>
#include <utility>
-#include <QCheckBox>
#include <QMessageBox>
-#include <QSpinBox>
#include "common/settings.h"
#include "core/core.h"
#include "ui_configure_general.h"
-#include "yuzu/configuration/config.h"
#include "yuzu/configuration/configuration_shared.h"
#include "yuzu/configuration/configure_general.h"
#include "yuzu/uisettings.h"
@@ -30,9 +26,6 @@ ConfigureGeneral::ConfigureGeneral(const Core::System& system_, QWidget* parent)
connect(ui->button_reset_defaults, &QPushButton::clicked, this,
&ConfigureGeneral::ResetDefaults);
-
- ui->fps_cap_label->setVisible(Settings::IsConfiguringGlobal());
- ui->fps_cap_combobox->setVisible(!Settings::IsConfiguringGlobal());
}
ConfigureGeneral::~ConfigureGeneral() = default;
@@ -42,6 +35,9 @@ void ConfigureGeneral::SetConfiguration() {
ui->use_multi_core->setEnabled(runtime_lock);
ui->use_multi_core->setChecked(Settings::values.use_multi_core.GetValue());
+ ui->use_extended_memory_layout->setEnabled(runtime_lock);
+ ui->use_extended_memory_layout->setChecked(
+ Settings::values.use_extended_memory_layout.GetValue());
ui->toggle_check_exit->setChecked(UISettings::values.confirm_before_closing.GetValue());
ui->toggle_user_on_boot->setChecked(UISettings::values.select_user_on_boot.GetValue());
@@ -52,8 +48,6 @@ void ConfigureGeneral::SetConfiguration() {
ui->toggle_speed_limit->setChecked(Settings::values.use_speed_limit.GetValue());
ui->speed_limit->setValue(Settings::values.speed_limit.GetValue());
- ui->fps_cap->setValue(Settings::values.fps_cap.GetValue());
-
ui->button_reset_defaults->setEnabled(runtime_lock);
if (Settings::IsConfiguringGlobal()) {
@@ -61,11 +55,6 @@ void ConfigureGeneral::SetConfiguration() {
} else {
ui->speed_limit->setEnabled(Settings::values.use_speed_limit.GetValue() &&
use_speed_limit != ConfigurationShared::CheckState::Global);
-
- ui->fps_cap_combobox->setCurrentIndex(Settings::values.fps_cap.UsingGlobal() ? 0 : 1);
- ui->fps_cap->setEnabled(!Settings::values.fps_cap.UsingGlobal());
- ConfigurationShared::SetHighlight(ui->fps_cap_layout,
- !Settings::values.fps_cap.UsingGlobal());
}
}
@@ -91,6 +80,9 @@ void ConfigureGeneral::ResetDefaults() {
void ConfigureGeneral::ApplyConfiguration() {
ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_multi_core, ui->use_multi_core,
use_multi_core);
+ ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_extended_memory_layout,
+ ui->use_extended_memory_layout,
+ use_extended_memory_layout);
if (Settings::IsConfiguringGlobal()) {
UISettings::values.confirm_before_closing = ui->toggle_check_exit->isChecked();
@@ -99,8 +91,6 @@ void ConfigureGeneral::ApplyConfiguration() {
UISettings::values.mute_when_in_background = ui->toggle_background_mute->isChecked();
UISettings::values.hide_mouse = ui->toggle_hide_mouse->isChecked();
- Settings::values.fps_cap.SetValue(ui->fps_cap->value());
-
// Guard if during game and set to game-specific value
if (Settings::values.use_speed_limit.UsingGlobal()) {
Settings::values.use_speed_limit.SetValue(ui->toggle_speed_limit->checkState() ==
@@ -116,13 +106,6 @@ void ConfigureGeneral::ApplyConfiguration() {
Qt::Checked);
Settings::values.speed_limit.SetValue(ui->speed_limit->value());
}
-
- if (ui->fps_cap_combobox->currentIndex() == ConfigurationShared::USE_GLOBAL_INDEX) {
- Settings::values.fps_cap.SetGlobal(true);
- } else {
- Settings::values.fps_cap.SetGlobal(false);
- Settings::values.fps_cap.SetValue(ui->fps_cap->value());
- }
}
}
@@ -160,14 +143,12 @@ void ConfigureGeneral::SetupPerGameUI() {
Settings::values.use_speed_limit, use_speed_limit);
ConfigurationShared::SetColoredTristate(ui->use_multi_core, Settings::values.use_multi_core,
use_multi_core);
+ ConfigurationShared::SetColoredTristate(ui->use_extended_memory_layout,
+ Settings::values.use_extended_memory_layout,
+ use_extended_memory_layout);
connect(ui->toggle_speed_limit, &QCheckBox::clicked, ui->speed_limit, [this]() {
ui->speed_limit->setEnabled(ui->toggle_speed_limit->isChecked() &&
(use_speed_limit != ConfigurationShared::CheckState::Global));
});
-
- connect(ui->fps_cap_combobox, qOverload<int>(&QComboBox::activated), this, [this](int index) {
- ui->fps_cap->setEnabled(index == 1);
- ConfigurationShared::SetHighlight(ui->fps_cap_layout, index == 1);
- });
}
diff --git a/src/yuzu/configuration/configure_general.h b/src/yuzu/configuration/configure_general.h
index 85c1dd4a8..a090c1a3f 100644
--- a/src/yuzu/configuration/configure_general.h
+++ b/src/yuzu/configuration/configure_general.h
@@ -1,6 +1,5 @@
-// Copyright 2016 Citra Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: 2016 Citra Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
@@ -48,6 +47,7 @@ private:
ConfigurationShared::CheckState use_speed_limit;
ConfigurationShared::CheckState use_multi_core;
+ ConfigurationShared::CheckState use_extended_memory_layout;
const Core::System& system;
};
diff --git a/src/yuzu/configuration/configure_general.ui b/src/yuzu/configuration/configure_general.ui
index bfc771135..5b90b1109 100644
--- a/src/yuzu/configuration/configure_general.ui
+++ b/src/yuzu/configuration/configure_general.ui
@@ -28,87 +28,6 @@
<item>
<layout class="QVBoxLayout" name="GeneralVerticalLayout">
<item>
- <widget class="QWidget" name="fps_cap_layout" native="true">
- <layout class="QHBoxLayout" name="horizontalLayout" stretch="1,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>
- <layout class="QHBoxLayout" name="horizontalLayout_4">
- <item>
- <widget class="QComboBox" name="fps_cap_combobox">
- <property name="currentText">
- <string>Use global framerate cap</string>
- </property>
- <property name="currentIndex">
- <number>0</number>
- </property>
- <item>
- <property name="text">
- <string>Use global framerate cap</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Set framerate cap:</string>
- </property>
- </item>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="fps_cap_label">
- <property name="toolTip">
- <string>Requires the use of the FPS Limiter Toggle hotkey to take effect.</string>
- </property>
- <property name="text">
- <string>Framerate Cap</string>
- </property>
- </widget>
- </item>
- <item>
- <spacer name="horizontalSpacer">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </item>
- <item>
- <widget class="QSpinBox" name="fps_cap">
- <property name="suffix">
- <string>x</string>
- </property>
- <property name="minimum">
- <number>1</number>
- </property>
- <property name="maximum">
- <number>1000</number>
- </property>
- <property name="value">
- <number>500</number>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- <item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QCheckBox" name="toggle_speed_limit">
@@ -143,6 +62,13 @@
</widget>
</item>
<item>
+ <widget class="QCheckBox" name="use_extended_memory_layout">
+ <property name="text">
+ <string>Extended memory layout (6GB DRAM)</string>
+ </property>
+ </widget>
+ </item>
+ <item>
<widget class="QCheckBox" name="toggle_check_exit">
<property name="text">
<string>Confirm exit while emulation is running</string>
diff --git a/src/yuzu/configuration/configure_graphics.cpp b/src/yuzu/configuration/configure_graphics.cpp
index 59f975a6e..87e5d0f48 100644
--- a/src/yuzu/configuration/configure_graphics.cpp
+++ b/src/yuzu/configuration/configure_graphics.cpp
@@ -1,12 +1,10 @@
-// Copyright 2016 Citra Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: 2016 Citra Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
// Include this early to include Vulkan headers how we want to
#include "video_core/vulkan_common/vulkan_wrapper.h"
#include <QColorDialog>
-#include <QComboBox>
#include <QVulkanInstance>
#include "common/common_types.h"
@@ -18,6 +16,7 @@
#include "video_core/vulkan_common/vulkan_library.h"
#include "yuzu/configuration/configuration_shared.h"
#include "yuzu/configuration/configure_graphics.h"
+#include "yuzu/uisettings.h"
ConfigureGraphics::ConfigureGraphics(const Core::System& system_, QWidget* parent)
: QWidget(parent), ui{std::make_unique<Ui::ConfigureGraphics>()}, system{system_} {
@@ -58,6 +57,9 @@ ConfigureGraphics::ConfigureGraphics(const Core::System& system_, QWidget* paren
UpdateBackgroundColorButton(new_bg_color);
});
+ ui->api->setEnabled(!UISettings::values.has_broken_vulkan);
+ ui->api_widget->setEnabled(!UISettings::values.has_broken_vulkan ||
+ Settings::IsConfiguringGlobal());
ui->bg_label->setVisible(Settings::IsConfiguringGlobal());
ui->bg_combobox->setVisible(!Settings::IsConfiguringGlobal());
}
@@ -320,6 +322,10 @@ void ConfigureGraphics::UpdateAPILayout() {
}
void ConfigureGraphics::RetrieveVulkanDevices() try {
+ if (UISettings::values.has_broken_vulkan) {
+ return;
+ }
+
using namespace Vulkan;
vk::InstanceDispatch dld;
@@ -333,7 +339,6 @@ void ConfigureGraphics::RetrieveVulkanDevices() try {
const std::string name = vk::PhysicalDevice(device, dld).GetProperties().deviceName;
vulkan_devices.push_back(QString::fromStdString(name));
}
-
} catch (const Vulkan::vk::Exception& exception) {
LOG_ERROR(Frontend, "Failed to enumerate devices with error: {}", exception.what());
}
diff --git a/src/yuzu/configuration/configure_graphics.h b/src/yuzu/configuration/configure_graphics.h
index 1b101c940..70034eb1b 100644
--- a/src/yuzu/configuration/configure_graphics.h
+++ b/src/yuzu/configuration/configure_graphics.h
@@ -1,6 +1,5 @@
-// Copyright 2016 Citra Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: 2016 Citra Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
diff --git a/src/yuzu/configuration/configure_graphics.ui b/src/yuzu/configuration/configure_graphics.ui
index 74f0e0b79..1e4f74704 100644
--- a/src/yuzu/configuration/configure_graphics.ui
+++ b/src/yuzu/configuration/configure_graphics.ui
@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>437</width>
- <height>482</height>
+ <width>541</width>
+ <height>759</height>
</rect>
</property>
<property name="windowTitle">
@@ -171,11 +171,11 @@
</widget>
</item>
<item>
- <widget class="QCheckBox" name="accelerate_astc">
- <property name="text">
- <string>Accelerate ASTC texture decoding</string>
- </property>
- </widget>
+ <widget class="QCheckBox" name="accelerate_astc">
+ <property name="text">
+ <string>Accelerate ASTC texture decoding</string>
+ </property>
+ </widget>
</item>
<item>
<widget class="QWidget" name="nvdec_emulation_widget" native="true">
@@ -438,43 +438,43 @@
</widget>
</item>
<item>
- <widget class="QWidget" name="anti_aliasing_layout" native="true">
- <layout class="QHBoxLayout" name="horizontalLayout_7">
- <property name="leftMargin">
- <number>0</number>
- </property>
- <property name="topMargin">
- <number>0</number>
- </property>
- <property name="rightMargin">
- <number>0</number>
+ <widget class="QWidget" name="anti_aliasing_layout" native="true">
+ <layout class="QHBoxLayout" name="horizontalLayout_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="anti_aliasing_label">
+ <property name="text">
+ <string>Anti-Aliasing Method:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QComboBox" name="anti_aliasing_combobox">
+ <item>
+ <property name="text">
+ <string>None</string>
</property>
- <property name="bottomMargin">
- <number>0</number>
+ </item>
+ <item>
+ <property name="text">
+ <string>FXAA</string>
</property>
- <item>
- <widget class="QLabel" name="anti_aliasing_label">
- <property name="text">
- <string>Anti-Aliasing Method:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QComboBox" name="anti_aliasing_combobox">
- <item>
- <property name="text">
- <string>None</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>FXAA</string>
- </property>
- </item>
- </widget>
- </item>
- </layout>
- </widget>
+ </item>
+ </widget>
+ </item>
+ </layout>
+ </widget>
</item>
<item>
<widget class="QWidget" name="bg_layout" native="true">
diff --git a/src/yuzu/configuration/configure_graphics_advanced.cpp b/src/yuzu/configuration/configure_graphics_advanced.cpp
index 30c5a3595..01f074699 100644
--- a/src/yuzu/configuration/configure_graphics_advanced.cpp
+++ b/src/yuzu/configuration/configure_graphics_advanced.cpp
@@ -1,6 +1,5 @@
-// Copyright 2020 yuzu Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#include "common/settings.h"
#include "core/core.h"
@@ -29,6 +28,7 @@ void ConfigureGraphicsAdvanced::SetConfiguration() {
ui->use_vsync->setChecked(Settings::values.use_vsync.GetValue());
ui->use_asynchronous_shaders->setChecked(Settings::values.use_asynchronous_shaders.GetValue());
ui->use_fast_gpu_time->setChecked(Settings::values.use_fast_gpu_time.GetValue());
+ ui->use_pessimistic_flushes->setChecked(Settings::values.use_pessimistic_flushes.GetValue());
if (Settings::IsConfiguringGlobal()) {
ui->gpu_accuracy->setCurrentIndex(
@@ -56,6 +56,8 @@ void ConfigureGraphicsAdvanced::ApplyConfiguration() {
use_asynchronous_shaders);
ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_fast_gpu_time,
ui->use_fast_gpu_time, use_fast_gpu_time);
+ ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_pessimistic_flushes,
+ ui->use_pessimistic_flushes, use_pessimistic_flushes);
}
void ConfigureGraphicsAdvanced::changeEvent(QEvent* event) {
@@ -78,6 +80,8 @@ void ConfigureGraphicsAdvanced::SetupPerGameUI() {
ui->use_asynchronous_shaders->setEnabled(
Settings::values.use_asynchronous_shaders.UsingGlobal());
ui->use_fast_gpu_time->setEnabled(Settings::values.use_fast_gpu_time.UsingGlobal());
+ ui->use_pessimistic_flushes->setEnabled(
+ Settings::values.use_pessimistic_flushes.UsingGlobal());
ui->anisotropic_filtering_combobox->setEnabled(
Settings::values.max_anisotropy.UsingGlobal());
@@ -90,6 +94,9 @@ void ConfigureGraphicsAdvanced::SetupPerGameUI() {
use_asynchronous_shaders);
ConfigurationShared::SetColoredTristate(ui->use_fast_gpu_time,
Settings::values.use_fast_gpu_time, use_fast_gpu_time);
+ ConfigurationShared::SetColoredTristate(ui->use_pessimistic_flushes,
+ Settings::values.use_pessimistic_flushes,
+ use_pessimistic_flushes);
ConfigurationShared::SetColoredComboBox(
ui->gpu_accuracy, ui->label_gpu_accuracy,
static_cast<int>(Settings::values.gpu_accuracy.GetValue(true)));
diff --git a/src/yuzu/configuration/configure_graphics_advanced.h b/src/yuzu/configuration/configure_graphics_advanced.h
index 0a1724ce4..12e816905 100644
--- a/src/yuzu/configuration/configure_graphics_advanced.h
+++ b/src/yuzu/configuration/configure_graphics_advanced.h
@@ -1,6 +1,5 @@
-// Copyright 2020 yuzu Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
@@ -40,6 +39,7 @@ private:
ConfigurationShared::CheckState use_vsync;
ConfigurationShared::CheckState use_asynchronous_shaders;
ConfigurationShared::CheckState use_fast_gpu_time;
+ ConfigurationShared::CheckState use_pessimistic_flushes;
const Core::System& system;
};
diff --git a/src/yuzu/configuration/configure_graphics_advanced.ui b/src/yuzu/configuration/configure_graphics_advanced.ui
index 96de0b3d1..87a121471 100644
--- a/src/yuzu/configuration/configure_graphics_advanced.ui
+++ b/src/yuzu/configuration/configure_graphics_advanced.ui
@@ -75,7 +75,7 @@
<string>VSync prevents the screen from tearing, but some graphics cards have lower performance with VSync enabled. Keep it enabled if you don't notice a performance difference.</string>
</property>
<property name="text">
- <string>Use VSync (OpenGL only)</string>
+ <string>Use VSync</string>
</property>
</widget>
</item>
@@ -100,6 +100,16 @@
</widget>
</item>
<item>
+ <widget class="QCheckBox" name="use_pessimistic_flushes">
+ <property name="toolTip">
+ <string>Enables pessimistic buffer flushes. This option will force unmodified buffers to be flushed, which can cost performance.</string>
+ </property>
+ <property name="text">
+ <string>Use pessimistic buffer flushes (Hack)</string>
+ </property>
+ </widget>
+ </item>
+ <item>
<widget class="QWidget" name="af_layout" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_1">
<property name="leftMargin">
diff --git a/src/yuzu/configuration/configure_hotkeys.cpp b/src/yuzu/configuration/configure_hotkeys.cpp
index 53e629a5e..daa77a8f8 100644
--- a/src/yuzu/configuration/configure_hotkeys.cpp
+++ b/src/yuzu/configuration/configure_hotkeys.cpp
@@ -1,6 +1,5 @@
-// Copyright 2017 Citra Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: 2017 Citra Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#include <QMenu>
#include <QMessageBox>
@@ -35,8 +34,9 @@ ConfigureHotkeys::ConfigureHotkeys(Core::HID::HIDCore& hid_core, QWidget* parent
ui->hotkey_list->setContextMenuPolicy(Qt::CustomContextMenu);
ui->hotkey_list->setModel(model);
- ui->hotkey_list->setColumnWidth(name_column, 200);
- ui->hotkey_list->resizeColumnToContents(hotkey_column);
+ ui->hotkey_list->header()->setStretchLastSection(false);
+ ui->hotkey_list->header()->setSectionResizeMode(name_column, QHeaderView::ResizeMode::Stretch);
+ ui->hotkey_list->header()->setMinimumSectionSize(150);
connect(ui->button_restore_defaults, &QPushButton::clicked, this,
&ConfigureHotkeys::RestoreDefaults);
@@ -60,14 +60,18 @@ ConfigureHotkeys::~ConfigureHotkeys() = default;
void ConfigureHotkeys::Populate(const HotkeyRegistry& registry) {
for (const auto& group : registry.hotkey_groups) {
- auto* parent_item = new QStandardItem(group.first);
+ auto* parent_item =
+ new QStandardItem(QCoreApplication::translate("Hotkeys", qPrintable(group.first)));
parent_item->setEditable(false);
+ parent_item->setData(group.first);
for (const auto& hotkey : group.second) {
- auto* action = new QStandardItem(hotkey.first);
+ auto* action =
+ new QStandardItem(QCoreApplication::translate("Hotkeys", qPrintable(hotkey.first)));
auto* keyseq =
new QStandardItem(hotkey.second.keyseq.toString(QKeySequence::NativeText));
auto* controller_keyseq = new QStandardItem(hotkey.second.controller_keyseq);
action->setEditable(false);
+ action->setData(hotkey.first);
keyseq->setEditable(false);
controller_keyseq->setEditable(false);
parent_item->appendRow({action, keyseq, controller_keyseq});
@@ -76,8 +80,8 @@ void ConfigureHotkeys::Populate(const HotkeyRegistry& registry) {
}
ui->hotkey_list->expandAll();
- ui->hotkey_list->resizeColumnToContents(name_column);
ui->hotkey_list->resizeColumnToContents(hotkey_column);
+ ui->hotkey_list->resizeColumnToContents(controller_column);
}
void ConfigureHotkeys::changeEvent(QEvent* event) {
@@ -92,6 +96,16 @@ void ConfigureHotkeys::RetranslateUI() {
ui->retranslateUi(this);
model->setHorizontalHeaderLabels({tr("Action"), tr("Hotkey"), tr("Controller Hotkey")});
+ for (int key_id = 0; key_id < model->rowCount(); key_id++) {
+ QStandardItem* parent = model->item(key_id, 0);
+ parent->setText(
+ QCoreApplication::translate("Hotkeys", qPrintable(parent->data().toString())));
+ for (int key_column_id = 0; key_column_id < parent->rowCount(); key_column_id++) {
+ QStandardItem* action = parent->child(key_column_id, name_column);
+ action->setText(
+ QCoreApplication::translate("Hotkeys", qPrintable(action->data().toString())));
+ }
+ }
}
void ConfigureHotkeys::Configure(QModelIndex index) {
@@ -272,10 +286,10 @@ void ConfigureHotkeys::ApplyConfiguration(HotkeyRegistry& registry) {
const QStandardItem* controller_keyseq =
parent->child(key_column_id, controller_column);
for (auto& [group, sub_actions] : registry.hotkey_groups) {
- if (group != parent->text())
+ if (group != parent->data())
continue;
for (auto& [action_name, hotkey] : sub_actions) {
- if (action_name != action->text())
+ if (action_name != action->data())
continue;
hotkey.keyseq = QKeySequence(keyseq->text());
hotkey.controller_keyseq = controller_keyseq->text();
diff --git a/src/yuzu/configuration/configure_hotkeys.h b/src/yuzu/configuration/configure_hotkeys.h
index f943ec538..b45ecb185 100644
--- a/src/yuzu/configuration/configure_hotkeys.h
+++ b/src/yuzu/configuration/configure_hotkeys.h
@@ -1,6 +1,5 @@
-// Copyright 2017 Citra Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: 2017 Citra Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
diff --git a/src/yuzu/configuration/configure_input.cpp b/src/yuzu/configuration/configure_input.cpp
index 7c5776189..1db374d4a 100644
--- a/src/yuzu/configuration/configure_input.cpp
+++ b/src/yuzu/configuration/configure_input.cpp
@@ -1,14 +1,9 @@
-// Copyright 2016 Citra Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: 2016 Citra Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
-#include <algorithm>
#include <memory>
#include <thread>
-#include <QSignalBlocker>
-#include <QTimer>
-
#include "core/core.h"
#include "core/hid/emulated_controller.h"
#include "core/hid/hid_core.h"
@@ -19,11 +14,13 @@
#include "ui_configure_input.h"
#include "ui_configure_input_advanced.h"
#include "ui_configure_input_player.h"
+#include "yuzu/configuration/configure_camera.h"
#include "yuzu/configuration/configure_debug_controller.h"
#include "yuzu/configuration/configure_input.h"
#include "yuzu/configuration/configure_input_advanced.h"
#include "yuzu/configuration/configure_input_player.h"
#include "yuzu/configuration/configure_motion_touch.h"
+#include "yuzu/configuration/configure_ringcon.h"
#include "yuzu/configuration/configure_touchscreen_advanced.h"
#include "yuzu/configuration/configure_vibration.h"
#include "yuzu/configuration/input_profiles.h"
@@ -68,7 +65,7 @@ void OnDockedModeChanged(bool last_state, bool new_state, Core::System& system)
ConfigureInput::ConfigureInput(Core::System& system_, QWidget* parent)
: QWidget(parent), ui(std::make_unique<Ui::ConfigureInput>()),
- profiles(std::make_unique<InputProfiles>(system_)), system{system_} {
+ profiles(std::make_unique<InputProfiles>()), system{system_} {
ui->setupUi(this);
}
@@ -162,6 +159,13 @@ void ConfigureInput::Initialize(InputCommon::InputSubsystem* input_subsystem,
[this, input_subsystem] {
CallConfigureDialog<ConfigureMotionTouch>(*this, input_subsystem);
});
+ connect(advanced, &ConfigureInputAdvanced::CallRingControllerDialog,
+ [this, input_subsystem, &hid_core] {
+ CallConfigureDialog<ConfigureRingController>(*this, input_subsystem, hid_core);
+ });
+ connect(advanced, &ConfigureInputAdvanced::CallCameraDialog, [this, input_subsystem] {
+ CallConfigureDialog<ConfigureCamera>(*this, input_subsystem);
+ });
connect(ui->vibrationButton, &QPushButton::clicked,
[this, &hid_core] { CallConfigureDialog<ConfigureVibration>(*this, hid_core); });
diff --git a/src/yuzu/configuration/configure_input.h b/src/yuzu/configuration/configure_input.h
index 4cafa3dab..c89189c36 100644
--- a/src/yuzu/configuration/configure_input.h
+++ b/src/yuzu/configuration/configure_input.h
@@ -1,6 +1,5 @@
-// Copyright 2016 Citra Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: 2016 Citra Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
diff --git a/src/yuzu/configuration/configure_input.ui b/src/yuzu/configuration/configure_input.ui
index 2707025e7..d51774028 100644
--- a/src/yuzu/configuration/configure_input.ui
+++ b/src/yuzu/configuration/configure_input.ui
@@ -166,7 +166,7 @@
<item>
<widget class="QRadioButton" name="radioUndocked">
<property name="text">
- <string>Undocked</string>
+ <string>Handheld</string>
</property>
</widget>
</item>
diff --git a/src/yuzu/configuration/configure_input_advanced.cpp b/src/yuzu/configuration/configure_input_advanced.cpp
index 20fc2599d..10f841b98 100644
--- a/src/yuzu/configuration/configure_input_advanced.cpp
+++ b/src/yuzu/configuration/configure_input_advanced.cpp
@@ -1,6 +1,5 @@
-// Copyright 2020 yuzu Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#include <QColorDialog>
#include "common/settings.h"
@@ -79,13 +78,18 @@ ConfigureInputAdvanced::ConfigureInputAdvanced(QWidget* parent)
&ConfigureInputAdvanced::UpdateUIEnabled);
connect(ui->touchscreen_enabled, &QCheckBox::stateChanged, this,
&ConfigureInputAdvanced::UpdateUIEnabled);
+ connect(ui->enable_ring_controller, &QCheckBox::stateChanged, this,
+ &ConfigureInputAdvanced::UpdateUIEnabled);
connect(ui->debug_configure, &QPushButton::clicked, this,
[this] { CallDebugControllerDialog(); });
connect(ui->touchscreen_advanced, &QPushButton::clicked, this,
[this] { CallTouchscreenConfigDialog(); });
connect(ui->buttonMotionTouch, &QPushButton::clicked, this,
- &ConfigureInputAdvanced::CallMotionTouchConfigDialog);
+ [this] { CallMotionTouchConfigDialog(); });
+ connect(ui->ring_controller_configure, &QPushButton::clicked, this,
+ [this] { CallRingControllerDialog(); });
+ connect(ui->camera_configure, &QPushButton::clicked, this, [this] { CallCameraDialog(); });
#ifndef _WIN32
ui->enable_raw_input->setVisible(false);
@@ -132,6 +136,8 @@ void ConfigureInputAdvanced::ApplyConfiguration() {
Settings::values.enable_raw_input = ui->enable_raw_input->isChecked();
Settings::values.enable_udp_controller = ui->enable_udp_controller->isChecked();
Settings::values.controller_navigation = ui->controller_navigation->isChecked();
+ Settings::values.enable_ring_controller = ui->enable_ring_controller->isChecked();
+ Settings::values.enable_ir_sensor = ui->enable_ir_sensor->isChecked();
}
void ConfigureInputAdvanced::LoadConfiguration() {
@@ -164,6 +170,8 @@ void ConfigureInputAdvanced::LoadConfiguration() {
ui->enable_raw_input->setChecked(Settings::values.enable_raw_input.GetValue());
ui->enable_udp_controller->setChecked(Settings::values.enable_udp_controller.GetValue());
ui->controller_navigation->setChecked(Settings::values.controller_navigation.GetValue());
+ ui->enable_ring_controller->setChecked(Settings::values.enable_ring_controller.GetValue());
+ ui->enable_ir_sensor->setChecked(Settings::values.enable_ir_sensor.GetValue());
UpdateUIEnabled();
}
@@ -185,4 +193,5 @@ void ConfigureInputAdvanced::UpdateUIEnabled() {
ui->touchscreen_advanced->setEnabled(ui->touchscreen_enabled->isChecked());
ui->mouse_panning->setEnabled(!ui->mouse_enabled->isChecked());
ui->mouse_panning_sensitivity->setEnabled(!ui->mouse_enabled->isChecked());
+ ui->ring_controller_configure->setEnabled(ui->enable_ring_controller->isChecked());
}
diff --git a/src/yuzu/configuration/configure_input_advanced.h b/src/yuzu/configuration/configure_input_advanced.h
index 3083d55c1..fc1230284 100644
--- a/src/yuzu/configuration/configure_input_advanced.h
+++ b/src/yuzu/configuration/configure_input_advanced.h
@@ -1,6 +1,5 @@
-// Copyright 2020 yuzu Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
@@ -29,6 +28,8 @@ signals:
void CallMouseConfigDialog();
void CallTouchscreenConfigDialog();
void CallMotionTouchConfigDialog();
+ void CallRingControllerDialog();
+ void CallCameraDialog();
private:
void changeEvent(QEvent* event) override;
diff --git a/src/yuzu/configuration/configure_input_advanced.ui b/src/yuzu/configuration/configure_input_advanced.ui
index 66f2075f2..fac8cf827 100644
--- a/src/yuzu/configuration/configure_input_advanced.ui
+++ b/src/yuzu/configuration/configure_input_advanced.ui
@@ -2603,6 +2603,34 @@
</property>
</widget>
</item>
+ <item row="4" column="0">
+ <widget class="QCheckBox" name="enable_ring_controller">
+ <property name="text">
+ <string>Ring Controller</string>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="2">
+ <widget class="QPushButton" name="ring_controller_configure">
+ <property name="text">
+ <string>Configure</string>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="0">
+ <widget class="QCheckBox" name="enable_ir_sensor">
+ <property name="text">
+ <string>Infrared Camera</string>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="2">
+ <widget class="QPushButton" name="camera_configure">
+ <property name="text">
+ <string>Configure</string>
+ </property>
+ </widget>
+ </item>
</layout>
</widget>
</item>
diff --git a/src/yuzu/configuration/configure_input_player.cpp b/src/yuzu/configuration/configure_input_player.cpp
index 9db564663..9e5a40fe7 100644
--- a/src/yuzu/configuration/configure_input_player.cpp
+++ b/src/yuzu/configuration/configure_input_player.cpp
@@ -1,16 +1,15 @@
-// Copyright 2016 Citra Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: 2016 Citra Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#include <algorithm>
#include <memory>
#include <utility>
#include <QGridLayout>
#include <QInputDialog>
-#include <QKeyEvent>
#include <QMenu>
#include <QMessageBox>
#include <QTimer>
+#include "common/assert.h"
#include "common/param_package.h"
#include "core/hid/emulated_controller.h"
#include "core/hid/hid_core.h"
@@ -23,7 +22,6 @@
#include "yuzu/configuration/config.h"
#include "yuzu/configuration/configure_input_player.h"
#include "yuzu/configuration/configure_input_player_widget.h"
-#include "yuzu/configuration/configure_vibration.h"
#include "yuzu/configuration/input_profiles.h"
#include "yuzu/util/limitable_input_dialog.h"
@@ -121,6 +119,23 @@ QString GetButtonName(Common::Input::ButtonNames button_name) {
}
}
+QString GetDirectionName(const std::string& direction) {
+ if (direction == "left") {
+ return QObject::tr("Left");
+ }
+ if (direction == "right") {
+ return QObject::tr("Right");
+ }
+ if (direction == "up") {
+ return QObject::tr("Up");
+ }
+ if (direction == "down") {
+ return QObject::tr("Down");
+ }
+ UNIMPLEMENTED_MSG("Unimplemented direction name={}", direction);
+ return QString::fromStdString(direction);
+}
+
void SetAnalogParam(const Common::ParamPackage& input_param, Common::ParamPackage& analog_param,
const std::string& button_name) {
// The poller returned a complete axis, so set all the buttons
@@ -146,6 +161,7 @@ QString ConfigureInputPlayer::ButtonToText(const Common::ParamPackage& param) {
const QString toggle = QString::fromStdString(param.Get("toggle", false) ? "~" : "");
const QString inverted = QString::fromStdString(param.Get("inverted", false) ? "!" : "");
+ const QString invert = QString::fromStdString(param.Get("invert", "+") == "-" ? "-" : "");
const auto common_button_name = input_subsystem->GetButtonName(param);
// Retrieve the names from Qt
@@ -164,12 +180,12 @@ QString ConfigureInputPlayer::ButtonToText(const Common::ParamPackage& param) {
if (common_button_name == Common::Input::ButtonNames::Value) {
if (param.Has("hat")) {
- const QString hat = QString::fromStdString(param.Get("direction", ""));
+ const QString hat = GetDirectionName(param.Get("direction", ""));
return QObject::tr("%1%2Hat %3").arg(toggle, inverted, hat);
}
if (param.Has("axis")) {
const QString axis = QString::fromStdString(param.Get("axis", ""));
- return QObject::tr("%1%2Axis %3").arg(toggle, inverted, axis);
+ return QObject::tr("%1%2Axis %3").arg(toggle, invert, axis);
}
if (param.Has("axis_x") && param.Has("axis_y") && param.Has("axis_z")) {
const QString axis_x = QString::fromStdString(param.Get("axis_x", ""));
@@ -248,15 +264,16 @@ QString ConfigureInputPlayer::AnalogToText(const Common::ParamPackage& param,
return QObject::tr("[unknown]");
}
-ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_index,
- QWidget* bottom_row,
+ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_index_,
+ QWidget* bottom_row_,
InputCommon::InputSubsystem* input_subsystem_,
InputProfiles* profiles_, Core::HID::HIDCore& hid_core_,
- bool is_powered_on_, bool debug)
- : QWidget(parent), ui(std::make_unique<Ui::ConfigureInputPlayer>()), player_index(player_index),
- debug(debug), is_powered_on{is_powered_on_}, input_subsystem{input_subsystem_},
- profiles(profiles_), timeout_timer(std::make_unique<QTimer>()),
- poll_timer(std::make_unique<QTimer>()), bottom_row(bottom_row), hid_core{hid_core_} {
+ bool is_powered_on_, bool debug_)
+ : QWidget(parent),
+ ui(std::make_unique<Ui::ConfigureInputPlayer>()), player_index{player_index_}, debug{debug_},
+ is_powered_on{is_powered_on_}, input_subsystem{input_subsystem_}, profiles(profiles_),
+ timeout_timer(std::make_unique<QTimer>()),
+ poll_timer(std::make_unique<QTimer>()), bottom_row{bottom_row_}, hid_core{hid_core_} {
if (player_index == 0) {
auto* emulated_controller_p1 =
hid_core.GetEmulatedController(Core::HID::NpadIdType::Player1);
@@ -346,18 +363,18 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i
button_map[button_id]->setText(tr("[not set]"));
});
if (param.Has("code") || param.Has("button") || param.Has("hat")) {
- context_menu.addAction(tr("Toggle button"), [&] {
- const bool toggle_value = !param.Get("toggle", false);
- param.Set("toggle", toggle_value);
- button_map[button_id]->setText(ButtonToText(param));
- emulated_controller->SetButtonParam(button_id, param);
- });
context_menu.addAction(tr("Invert button"), [&] {
const bool invert_value = !param.Get("inverted", false);
param.Set("inverted", invert_value);
button_map[button_id]->setText(ButtonToText(param));
emulated_controller->SetButtonParam(button_id, param);
});
+ context_menu.addAction(tr("Toggle button"), [&] {
+ const bool toggle_value = !param.Get("toggle", false);
+ param.Set("toggle", toggle_value);
+ button_map[button_id]->setText(ButtonToText(param));
+ emulated_controller->SetButtonParam(button_id, param);
+ });
}
if (param.Has("axis")) {
context_menu.addAction(tr("Invert axis"), [&] {
@@ -382,6 +399,12 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i
}
emulated_controller->SetButtonParam(button_id, param);
});
+ context_menu.addAction(tr("Toggle axis"), [&] {
+ const bool toggle_value = !param.Get("toggle", false);
+ param.Set("toggle", toggle_value);
+ button_map[button_id]->setText(ButtonToText(param));
+ emulated_controller->SetButtonParam(button_id, param);
+ });
}
context_menu.exec(button_map[button_id]->mapToGlobal(menu_location));
});
@@ -473,6 +496,25 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i
[=, this](const Common::ParamPackage& params) {
Common::ParamPackage param = emulated_controller->GetStickParam(analog_id);
SetAnalogParam(params, param, analog_sub_buttons[sub_button_id]);
+ // Correct axis direction for inverted sticks
+ if (input_subsystem->IsStickInverted(param)) {
+ switch (analog_id) {
+ case Settings::NativeAnalog::LStick: {
+ const bool invert_value = param.Get("invert_x", "+") == "-";
+ const std::string invert_str = invert_value ? "+" : "-";
+ param.Set("invert_x", invert_str);
+ break;
+ }
+ case Settings::NativeAnalog::RStick: {
+ const bool invert_value = param.Get("invert_y", "+") == "-";
+ const std::string invert_str = invert_value ? "+" : "-";
+ param.Set("invert_y", invert_str);
+ break;
+ }
+ default:
+ break;
+ }
+ }
emulated_controller->SetStickParam(analog_id, param);
},
InputCommon::Polling::InputType::Stick);
@@ -485,7 +527,28 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i
QMenu context_menu;
Common::ParamPackage param = emulated_controller->GetStickParam(analog_id);
context_menu.addAction(tr("Clear"), [&] {
- emulated_controller->SetStickParam(analog_id, {});
+ if (param.Get("engine", "") != "analog_from_button") {
+ emulated_controller->SetStickParam(analog_id, {});
+ for (auto button : analog_map_buttons[analog_id]) {
+ button->setText(tr("[not set]"));
+ }
+ return;
+ }
+ switch (sub_button_id) {
+ case 0:
+ param.Erase("up");
+ break;
+ case 1:
+ param.Erase("down");
+ break;
+ case 2:
+ param.Erase("left");
+ break;
+ case 3:
+ param.Erase("right");
+ break;
+ }
+ emulated_controller->SetStickParam(analog_id, param);
analog_map_buttons[analog_id][sub_button_id]->setText(tr("[not set]"));
});
context_menu.addAction(tr("Center axis"), [&] {
@@ -640,39 +703,38 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i
UpdateControllerEnabledButtons();
UpdateControllerButtonNames();
UpdateMotionButtons();
- connect(ui->comboControllerType, qOverload<int>(&QComboBox::currentIndexChanged),
- [this, player_index](int) {
- UpdateControllerAvailableButtons();
- UpdateControllerEnabledButtons();
- UpdateControllerButtonNames();
- UpdateMotionButtons();
- const Core::HID::NpadStyleIndex type =
- GetControllerTypeFromIndex(ui->comboControllerType->currentIndex());
-
- if (player_index == 0) {
- auto* emulated_controller_p1 =
- hid_core.GetEmulatedController(Core::HID::NpadIdType::Player1);
- auto* emulated_controller_handheld =
- hid_core.GetEmulatedController(Core::HID::NpadIdType::Handheld);
- bool is_connected = emulated_controller->IsConnected(true);
-
- emulated_controller_p1->SetNpadStyleIndex(type);
- emulated_controller_handheld->SetNpadStyleIndex(type);
- if (is_connected) {
- if (type == Core::HID::NpadStyleIndex::Handheld) {
- emulated_controller_p1->Disconnect();
- emulated_controller_handheld->Connect(true);
- emulated_controller = emulated_controller_handheld;
- } else {
- emulated_controller_handheld->Disconnect();
- emulated_controller_p1->Connect(true);
- emulated_controller = emulated_controller_p1;
- }
- }
- ui->controllerFrame->SetController(emulated_controller);
+ connect(ui->comboControllerType, qOverload<int>(&QComboBox::currentIndexChanged), [this](int) {
+ UpdateControllerAvailableButtons();
+ UpdateControllerEnabledButtons();
+ UpdateControllerButtonNames();
+ UpdateMotionButtons();
+ const Core::HID::NpadStyleIndex type =
+ GetControllerTypeFromIndex(ui->comboControllerType->currentIndex());
+
+ if (player_index == 0) {
+ auto* emulated_controller_p1 =
+ hid_core.GetEmulatedController(Core::HID::NpadIdType::Player1);
+ auto* emulated_controller_handheld =
+ hid_core.GetEmulatedController(Core::HID::NpadIdType::Handheld);
+ bool is_connected = emulated_controller->IsConnected(true);
+
+ emulated_controller_p1->SetNpadStyleIndex(type);
+ emulated_controller_handheld->SetNpadStyleIndex(type);
+ if (is_connected) {
+ if (type == Core::HID::NpadStyleIndex::Handheld) {
+ emulated_controller_p1->Disconnect();
+ emulated_controller_handheld->Connect(true);
+ emulated_controller = emulated_controller_handheld;
+ } else {
+ emulated_controller_handheld->Disconnect();
+ emulated_controller_p1->Connect(true);
+ emulated_controller = emulated_controller_p1;
}
- emulated_controller->SetNpadStyleIndex(type);
- });
+ }
+ ui->controllerFrame->SetController(emulated_controller);
+ }
+ emulated_controller->SetNpadStyleIndex(type);
+ });
connect(ui->comboDevices, qOverload<int>(&QComboBox::activated), this,
&ConfigureInputPlayer::UpdateMappingWithDefaults);
@@ -953,7 +1015,7 @@ void ConfigureInputPlayer::UpdateUI() {
slider_value = static_cast<int>(param.Get("deadzone", 0.15f) * 100);
deadzone_label->setText(tr("Deadzone: %1%").arg(slider_value));
deadzone_slider->setValue(slider_value);
- range_spinbox->setValue(static_cast<int>(param.Get("range", 1.0f) * 100));
+ range_spinbox->setValue(static_cast<int>(param.Get("range", 0.95f) * 100));
} else {
slider_value = static_cast<int>(param.Get("modifier_scale", 0.5f) * 100);
modifier_label->setText(tr("Modifier Range: %1%").arg(slider_value));
@@ -1332,6 +1394,9 @@ void ConfigureInputPlayer::HandleClick(
QPushButton* button, std::size_t button_id,
std::function<void(const Common::ParamPackage&)> new_input_setter,
InputCommon::Polling::InputType type) {
+ if (timeout_timer->isActive()) {
+ return;
+ }
if (button == ui->buttonMotionLeft || button == ui->buttonMotionRight) {
button->setText(tr("Shake!"));
} else {
@@ -1352,7 +1417,7 @@ void ConfigureInputPlayer::HandleClick(
ui->controllerFrame->BeginMappingAnalog(button_id);
}
- timeout_timer->start(2500); // Cancel after 2.5 seconds
+ timeout_timer->start(4000); // Cancel after 4 seconds
poll_timer->start(25); // Check for new inputs every 25ms
}
@@ -1406,10 +1471,10 @@ void ConfigureInputPlayer::mousePressEvent(QMouseEvent* event) {
}
void ConfigureInputPlayer::keyPressEvent(QKeyEvent* event) {
- event->ignore();
if (!input_setter || !event) {
return;
}
+ event->ignore();
if (event->key() != Qt::Key_Escape) {
input_subsystem->GetKeyboard()->PressKey(event->key());
}
@@ -1417,7 +1482,7 @@ void ConfigureInputPlayer::keyPressEvent(QKeyEvent* event) {
void ConfigureInputPlayer::CreateProfile() {
const auto profile_name =
- LimitableInputDialog::GetText(this, tr("New Profile"), tr("Enter a profile name:"), 1, 20,
+ LimitableInputDialog::GetText(this, tr("New Profile"), tr("Enter a profile name:"), 1, 30,
LimitableInputDialog::InputLimiter::Filesystem);
if (profile_name.isEmpty()) {
diff --git a/src/yuzu/configuration/configure_input_player.h b/src/yuzu/configuration/configure_input_player.h
index 47df6b3d3..79434fdd8 100644
--- a/src/yuzu/configuration/configure_input_player.h
+++ b/src/yuzu/configuration/configure_input_player.h
@@ -1,6 +1,5 @@
-// Copyright 2016 Citra Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: 2016 Citra Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
diff --git a/src/yuzu/configuration/configure_input_player.ui b/src/yuzu/configuration/configure_input_player.ui
index 756a414b5..a62b57501 100644
--- a/src/yuzu/configuration/configure_input_player.ui
+++ b/src/yuzu/configuration/configure_input_player.ui
@@ -754,13 +754,13 @@
<string>%</string>
</property>
<property name="minimum">
- <number>50</number>
+ <number>25</number>
</property>
<property name="maximum">
<number>150</number>
</property>
<property name="value">
- <number>100</number>
+ <number>95</number>
</property>
</widget>
</item>
@@ -2985,13 +2985,13 @@
<string>%</string>
</property>
<property name="minimum">
- <number>50</number>
+ <number>25</number>
</property>
<property name="maximum">
<number>150</number>
</property>
<property name="value">
- <number>100</number>
+ <number>95</number>
</property>
</widget>
</item>
diff --git a/src/yuzu/configuration/configure_input_player_widget.cpp b/src/yuzu/configuration/configure_input_player_widget.cpp
index fb168b2ca..11390fec0 100644
--- a/src/yuzu/configuration/configure_input_player_widget.cpp
+++ b/src/yuzu/configuration/configure_input_player_widget.cpp
@@ -1,6 +1,5 @@
-// Copyright 2020 yuzu Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#include <algorithm>
#include <QMenu>
diff --git a/src/yuzu/configuration/configure_input_player_widget.h b/src/yuzu/configuration/configure_input_player_widget.h
index 3582ef77a..b258c6d77 100644
--- a/src/yuzu/configuration/configure_input_player_widget.h
+++ b/src/yuzu/configuration/configure_input_player_widget.h
@@ -1,6 +1,5 @@
-// Copyright 2020 yuzu Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
diff --git a/src/yuzu/configuration/configure_input_profile_dialog.cpp b/src/yuzu/configuration/configure_input_profile_dialog.cpp
index 17bbe6b61..58dffda51 100644
--- a/src/yuzu/configuration/configure_input_profile_dialog.cpp
+++ b/src/yuzu/configuration/configure_input_profile_dialog.cpp
@@ -1,6 +1,5 @@
-// Copyright 2020 yuzu Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#include "core/core.h"
#include "ui_configure_input_profile_dialog.h"
diff --git a/src/yuzu/configuration/configure_input_profile_dialog.h b/src/yuzu/configuration/configure_input_profile_dialog.h
index 84b1f6d1a..956cdf954 100644
--- a/src/yuzu/configuration/configure_input_profile_dialog.h
+++ b/src/yuzu/configuration/configure_input_profile_dialog.h
@@ -1,6 +1,5 @@
-// Copyright 2020 yuzu Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
diff --git a/src/yuzu/configuration/configure_motion_touch.cpp b/src/yuzu/configuration/configure_motion_touch.cpp
index 4340de304..d1b870c72 100644
--- a/src/yuzu/configuration/configure_motion_touch.cpp
+++ b/src/yuzu/configuration/configure_motion_touch.cpp
@@ -1,17 +1,11 @@
-// Copyright 2018 Citra Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: 2018 Citra Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
-#include <array>
#include <sstream>
#include <QCloseEvent>
-#include <QLabel>
#include <QMessageBox>
-#include <QPushButton>
-#include <QRegularExpression>
#include <QStringListModel>
-#include <QVBoxLayout>
#include "common/logging/log.h"
#include "common/settings.h"
@@ -156,6 +150,8 @@ void ConfigureMotionTouch::ConnectEvents() {
&ConfigureMotionTouch::OnConfigureTouchCalibration);
connect(ui->touch_from_button_config_btn, &QPushButton::clicked, this,
&ConfigureMotionTouch::OnConfigureTouchFromButton);
+ connect(ui->buttonBox, &QDialogButtonBox::accepted, this,
+ &ConfigureMotionTouch::ApplyConfiguration);
connect(ui->buttonBox, &QDialogButtonBox::rejected, this, [this] {
if (CanCloseDialog()) {
reject();
diff --git a/src/yuzu/configuration/configure_motion_touch.h b/src/yuzu/configuration/configure_motion_touch.h
index 8b707d2ff..7dcc9318e 100644
--- a/src/yuzu/configuration/configure_motion_touch.h
+++ b/src/yuzu/configuration/configure_motion_touch.h
@@ -1,12 +1,10 @@
-// Copyright 2018 Citra Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: 2018 Citra Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include <memory>
#include <QDialog>
-#include "common/param_package.h"
class QLabel;
class QPushButton;
diff --git a/src/yuzu/configuration/configure_motion_touch.ui b/src/yuzu/configuration/configure_motion_touch.ui
index c75a84ae4..0237fae54 100644
--- a/src/yuzu/configuration/configure_motion_touch.ui
+++ b/src/yuzu/configuration/configure_motion_touch.ui
@@ -293,22 +293,5 @@
</layout>
</widget>
<resources/>
- <connections>
- <connection>
- <sender>buttonBox</sender>
- <signal>accepted()</signal>
- <receiver>ConfigureMotionTouch</receiver>
- <slot>ApplyConfiguration()</slot>
- <hints>
- <hint type="sourcelabel">
- <x>20</x>
- <y>20</y>
- </hint>
- <hint type="destinationlabel">
- <x>20</x>
- <y>20</y>
- </hint>
- </hints>
- </connection>
- </connections>
+ <connections/>
</ui>
diff --git a/src/yuzu/configuration/configure_network.cpp b/src/yuzu/configuration/configure_network.cpp
index 7020d2964..ba1986eb1 100644
--- a/src/yuzu/configuration/configure_network.cpp
+++ b/src/yuzu/configuration/configure_network.cpp
@@ -1,12 +1,10 @@
-// Copyright 2019 yuzu Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
-#include <QGraphicsItem>
#include <QtConcurrent/QtConcurrent>
#include "common/settings.h"
#include "core/core.h"
-#include "core/network/network_interface.h"
+#include "core/internal_network/network_interface.h"
#include "ui_configure_network.h"
#include "yuzu/configuration/configure_network.h"
@@ -28,7 +26,15 @@ void ConfigureNetwork::ApplyConfiguration() {
Settings::values.network_interface = ui->network_interface->currentText().toStdString();
}
-void ConfigureNetwork::RetranslateUi() {
+void ConfigureNetwork::changeEvent(QEvent* event) {
+ if (event->type() == QEvent::LanguageChange) {
+ RetranslateUI();
+ }
+
+ QWidget::changeEvent(event);
+}
+
+void ConfigureNetwork::RetranslateUI() {
ui->retranslateUi(this);
}
diff --git a/src/yuzu/configuration/configure_network.h b/src/yuzu/configuration/configure_network.h
index 8507c62eb..f666edbd1 100644
--- a/src/yuzu/configuration/configure_network.h
+++ b/src/yuzu/configuration/configure_network.h
@@ -1,11 +1,9 @@
-// Copyright 2019 yuzu Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include <memory>
-#include <QFutureWatcher>
#include <QWidget>
namespace Ui {
@@ -20,9 +18,10 @@ public:
~ConfigureNetwork() override;
void ApplyConfiguration();
- void RetranslateUi();
private:
+ void changeEvent(QEvent*) override;
+ void RetranslateUI();
void SetConfiguration();
std::unique_ptr<Ui::ConfigureNetwork> ui;
diff --git a/src/yuzu/configuration/configure_per_game.cpp b/src/yuzu/configuration/configure_per_game.cpp
index f4cf25f05..c3cb8f61d 100644
--- a/src/yuzu/configuration/configure_per_game.cpp
+++ b/src/yuzu/configuration/configure_per_game.cpp
@@ -1,6 +1,5 @@
-// Copyright 2020 yuzu Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#include <algorithm>
#include <filesystem>
@@ -12,17 +11,11 @@
#include <QAbstractButton>
#include <QCheckBox>
-#include <QDialogButtonBox>
-#include <QHeaderView>
-#include <QMenu>
#include <QPushButton>
-#include <QStandardItemModel>
#include <QString>
#include <QTimer>
-#include <QTreeView>
#include "common/fs/fs_util.h"
-#include "common/fs/path_util.h"
#include "core/core.h"
#include "core/file_sys/control_metadata.h"
#include "core/file_sys/patch_manager.h"
@@ -42,15 +35,14 @@
#include "yuzu/uisettings.h"
#include "yuzu/util/util.h"
-ConfigurePerGame::ConfigurePerGame(QWidget* parent, u64 title_id, const std::string& file_name,
+ConfigurePerGame::ConfigurePerGame(QWidget* parent, u64 title_id_, const std::string& file_name,
Core::System& system_)
- : QDialog(parent), ui(std::make_unique<Ui::ConfigurePerGame>()),
- title_id(title_id), system{system_} {
+ : QDialog(parent),
+ ui(std::make_unique<Ui::ConfigurePerGame>()), title_id{title_id_}, system{system_} {
const auto file_path = std::filesystem::path(Common::FS::ToU8String(file_name));
const auto config_file_name = title_id == 0 ? Common::FS::PathToUTF8String(file_path.filename())
: fmt::format("{:016X}", title_id);
- game_config =
- std::make_unique<Config>(system, config_file_name, Config::ConfigType::PerGameConfig);
+ game_config = std::make_unique<Config>(config_file_name, Config::ConfigType::PerGameConfig);
addons_tab = std::make_unique<ConfigurePerGameAddons>(system_, this);
audio_tab = std::make_unique<ConfigureAudio>(system_, this);
@@ -123,8 +115,8 @@ void ConfigurePerGame::HandleApplyButtonClicked() {
ApplyConfiguration();
}
-void ConfigurePerGame::LoadFromFile(FileSys::VirtualFile file) {
- this->file = std::move(file);
+void ConfigurePerGame::LoadFromFile(FileSys::VirtualFile file_) {
+ file = std::move(file_);
LoadConfiguration();
}
diff --git a/src/yuzu/configuration/configure_per_game.h b/src/yuzu/configuration/configure_per_game.h
index c1a57d87b..17a98a0f3 100644
--- a/src/yuzu/configuration/configure_per_game.h
+++ b/src/yuzu/configuration/configure_per_game.h
@@ -1,12 +1,10 @@
-// Copyright 2020 yuzu Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include <memory>
#include <string>
-#include <vector>
#include <QDialog>
#include <QList>
@@ -41,14 +39,14 @@ class ConfigurePerGame : public QDialog {
public:
// Cannot use std::filesystem::path due to https://bugreports.qt.io/browse/QTBUG-73263
- explicit ConfigurePerGame(QWidget* parent, u64 title_id, const std::string& file_name,
+ explicit ConfigurePerGame(QWidget* parent, u64 title_id_, const std::string& file_name,
Core::System& system_);
~ConfigurePerGame() override;
/// Save all button configurations to settings file
void ApplyConfiguration();
- void LoadFromFile(FileSys::VirtualFile file);
+ void LoadFromFile(FileSys::VirtualFile file_);
private:
void changeEvent(QEvent* event) override;
diff --git a/src/yuzu/configuration/configure_per_game_addons.cpp b/src/yuzu/configuration/configure_per_game_addons.cpp
index 65e615963..674a75a62 100644
--- a/src/yuzu/configuration/configure_per_game_addons.cpp
+++ b/src/yuzu/configuration/configure_per_game_addons.cpp
@@ -1,6 +1,5 @@
-// Copyright 2016 Citra Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: 2016 Citra Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#include <algorithm>
#include <memory>
@@ -24,7 +23,6 @@
#include "yuzu/configuration/configure_input.h"
#include "yuzu/configuration/configure_per_game_addons.h"
#include "yuzu/uisettings.h"
-#include "yuzu/util/util.h"
ConfigurePerGameAddons::ConfigurePerGameAddons(Core::System& system_, QWidget* parent)
: QWidget(parent), ui{std::make_unique<Ui::ConfigurePerGameAddons>()}, system{system_} {
@@ -48,6 +46,10 @@ ConfigurePerGameAddons::ConfigurePerGameAddons(Core::System& system_, QWidget* p
item_model->setHeaderData(0, Qt::Horizontal, tr("Patch Name"));
item_model->setHeaderData(1, Qt::Horizontal, tr("Version"));
+ tree_view->header()->setStretchLastSection(false);
+ tree_view->header()->setSectionResizeMode(0, QHeaderView::ResizeMode::Stretch);
+ tree_view->header()->setMinimumSectionSize(150);
+
// We must register all custom types with the Qt Automoc system so that we are able to use it
// with signals/slots. In this case, QList falls under the umbrella of custom types.
qRegisterMetaType<QList<QStandardItem*>>("QList<QStandardItem*>");
@@ -86,8 +88,8 @@ void ConfigurePerGameAddons::ApplyConfiguration() {
Settings::values.disabled_addons[title_id] = disabled_addons;
}
-void ConfigurePerGameAddons::LoadFromFile(FileSys::VirtualFile file) {
- this->file = std::move(file);
+void ConfigurePerGameAddons::LoadFromFile(FileSys::VirtualFile file_) {
+ file = std::move(file_);
LoadConfiguration();
}
@@ -139,5 +141,5 @@ void ConfigurePerGameAddons::LoadConfiguration() {
item_model->appendRow(list_items.back());
}
- tree_view->setColumnWidth(0, 5 * tree_view->width() / 16);
+ tree_view->resizeColumnToContents(1);
}
diff --git a/src/yuzu/configuration/configure_per_game_addons.h b/src/yuzu/configuration/configure_per_game_addons.h
index 24b017494..53db405c1 100644
--- a/src/yuzu/configuration/configure_per_game_addons.h
+++ b/src/yuzu/configuration/configure_per_game_addons.h
@@ -1,6 +1,5 @@
-// Copyright 2016 Citra Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: 2016 Citra Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
@@ -35,7 +34,7 @@ public:
/// Save all button configurations to settings file
void ApplyConfiguration();
- void LoadFromFile(FileSys::VirtualFile file);
+ void LoadFromFile(FileSys::VirtualFile file_);
void SetTitleId(u64 id);
diff --git a/src/yuzu/configuration/configure_profile_manager.cpp b/src/yuzu/configuration/configure_profile_manager.cpp
index d9f6dee4e..5c0217ba8 100644
--- a/src/yuzu/configuration/configure_profile_manager.cpp
+++ b/src/yuzu/configuration/configure_profile_manager.cpp
@@ -1,16 +1,13 @@
-// Copyright 2016 Citra Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: 2016 Citra Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#include <algorithm>
#include <QFileDialog>
#include <QGraphicsItem>
-#include <QGraphicsScene>
#include <QHeaderView>
#include <QMessageBox>
#include <QStandardItemModel>
#include <QTreeView>
-#include <QVBoxLayout>
#include "common/assert.h"
#include "common/fs/path_util.h"
#include "common/settings.h"
diff --git a/src/yuzu/configuration/configure_profile_manager.h b/src/yuzu/configuration/configure_profile_manager.h
index 575cb89d5..fe9033779 100644
--- a/src/yuzu/configuration/configure_profile_manager.h
+++ b/src/yuzu/configuration/configure_profile_manager.h
@@ -1,6 +1,5 @@
-// Copyright 2016 Citra Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: 2016 Citra Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
diff --git a/src/yuzu/configuration/configure_ringcon.cpp b/src/yuzu/configuration/configure_ringcon.cpp
new file mode 100644
index 000000000..688c2dd38
--- /dev/null
+++ b/src/yuzu/configuration/configure_ringcon.cpp
@@ -0,0 +1,423 @@
+// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include <memory>
+#include <QKeyEvent>
+#include <QMenu>
+#include <QTimer>
+
+#include "core/hid/emulated_devices.h"
+#include "core/hid/hid_core.h"
+#include "input_common/drivers/keyboard.h"
+#include "input_common/drivers/mouse.h"
+#include "input_common/main.h"
+#include "ui_configure_ringcon.h"
+#include "yuzu/bootmanager.h"
+#include "yuzu/configuration/config.h"
+#include "yuzu/configuration/configure_ringcon.h"
+
+const std::array<std::string, ConfigureRingController::ANALOG_SUB_BUTTONS_NUM>
+ ConfigureRingController::analog_sub_buttons{{
+ "left",
+ "right",
+ }};
+
+namespace {
+
+QString GetKeyName(int key_code) {
+ switch (key_code) {
+ case Qt::Key_Shift:
+ return QObject::tr("Shift");
+ case Qt::Key_Control:
+ return QObject::tr("Ctrl");
+ case Qt::Key_Alt:
+ return QObject::tr("Alt");
+ case Qt::Key_Meta:
+ return {};
+ default:
+ return QKeySequence(key_code).toString();
+ }
+}
+
+QString GetButtonName(Common::Input::ButtonNames button_name) {
+ switch (button_name) {
+ case Common::Input::ButtonNames::ButtonLeft:
+ return QObject::tr("Left");
+ case Common::Input::ButtonNames::ButtonRight:
+ return QObject::tr("Right");
+ case Common::Input::ButtonNames::ButtonDown:
+ return QObject::tr("Down");
+ case Common::Input::ButtonNames::ButtonUp:
+ return QObject::tr("Up");
+ case Common::Input::ButtonNames::TriggerZ:
+ return QObject::tr("Z");
+ case Common::Input::ButtonNames::TriggerR:
+ return QObject::tr("R");
+ case Common::Input::ButtonNames::TriggerL:
+ return QObject::tr("L");
+ case Common::Input::ButtonNames::ButtonA:
+ return QObject::tr("A");
+ case Common::Input::ButtonNames::ButtonB:
+ return QObject::tr("B");
+ case Common::Input::ButtonNames::ButtonX:
+ return QObject::tr("X");
+ case Common::Input::ButtonNames::ButtonY:
+ return QObject::tr("Y");
+ case Common::Input::ButtonNames::ButtonStart:
+ return QObject::tr("Start");
+ case Common::Input::ButtonNames::L1:
+ return QObject::tr("L1");
+ case Common::Input::ButtonNames::L2:
+ return QObject::tr("L2");
+ case Common::Input::ButtonNames::L3:
+ return QObject::tr("L3");
+ case Common::Input::ButtonNames::R1:
+ return QObject::tr("R1");
+ case Common::Input::ButtonNames::R2:
+ return QObject::tr("R2");
+ case Common::Input::ButtonNames::R3:
+ return QObject::tr("R3");
+ case Common::Input::ButtonNames::Circle:
+ return QObject::tr("Circle");
+ case Common::Input::ButtonNames::Cross:
+ return QObject::tr("Cross");
+ case Common::Input::ButtonNames::Square:
+ return QObject::tr("Square");
+ case Common::Input::ButtonNames::Triangle:
+ return QObject::tr("Triangle");
+ case Common::Input::ButtonNames::Share:
+ return QObject::tr("Share");
+ case Common::Input::ButtonNames::Options:
+ return QObject::tr("Options");
+ default:
+ return QObject::tr("[undefined]");
+ }
+}
+
+void SetAnalogParam(const Common::ParamPackage& input_param, Common::ParamPackage& analog_param,
+ const std::string& button_name) {
+ // The poller returned a complete axis, so set all the buttons
+ if (input_param.Has("axis_x") && input_param.Has("axis_y")) {
+ analog_param = input_param;
+ return;
+ }
+ // Check if the current configuration has either no engine or an axis binding.
+ // Clears out the old binding and adds one with analog_from_button.
+ if (!analog_param.Has("engine") || analog_param.Has("axis_x") || analog_param.Has("axis_y")) {
+ analog_param = {
+ {"engine", "analog_from_button"},
+ };
+ }
+ analog_param.Set(button_name, input_param.Serialize());
+}
+} // namespace
+
+ConfigureRingController::ConfigureRingController(QWidget* parent,
+ InputCommon::InputSubsystem* input_subsystem_,
+ Core::HID::HIDCore& hid_core_)
+ : QDialog(parent), timeout_timer(std::make_unique<QTimer>()),
+ poll_timer(std::make_unique<QTimer>()), input_subsystem{input_subsystem_},
+
+ ui(std::make_unique<Ui::ConfigureRingController>()) {
+ ui->setupUi(this);
+
+ analog_map_buttons = {
+ ui->buttonRingAnalogPull,
+ ui->buttonRingAnalogPush,
+ };
+
+ emulated_device = hid_core_.GetEmulatedDevices();
+ emulated_device->SaveCurrentConfig();
+ emulated_device->EnableConfiguration();
+
+ LoadConfiguration();
+
+ for (int sub_button_id = 0; sub_button_id < ANALOG_SUB_BUTTONS_NUM; ++sub_button_id) {
+ auto* const analog_button = analog_map_buttons[sub_button_id];
+
+ if (analog_button == nullptr) {
+ continue;
+ }
+
+ connect(analog_button, &QPushButton::clicked, [=, this] {
+ HandleClick(
+ analog_map_buttons[sub_button_id],
+ [=, this](const Common::ParamPackage& params) {
+ Common::ParamPackage param = emulated_device->GetRingParam();
+ SetAnalogParam(params, param, analog_sub_buttons[sub_button_id]);
+ emulated_device->SetRingParam(param);
+ },
+ InputCommon::Polling::InputType::Stick);
+ });
+
+ analog_button->setContextMenuPolicy(Qt::CustomContextMenu);
+
+ connect(analog_button, &QPushButton::customContextMenuRequested,
+ [=, this](const QPoint& menu_location) {
+ QMenu context_menu;
+ Common::ParamPackage param = emulated_device->GetRingParam();
+ context_menu.addAction(tr("Clear"), [&] {
+ emulated_device->SetRingParam({});
+ analog_map_buttons[sub_button_id]->setText(tr("[not set]"));
+ });
+ context_menu.addAction(tr("Invert axis"), [&] {
+ const bool invert_value = param.Get("invert_x", "+") == "-";
+ const std::string invert_str = invert_value ? "+" : "-";
+ param.Set("invert_x", invert_str);
+ emulated_device->SetRingParam(param);
+ for (int sub_button_id2 = 0; sub_button_id2 < ANALOG_SUB_BUTTONS_NUM;
+ ++sub_button_id2) {
+ analog_map_buttons[sub_button_id2]->setText(
+ AnalogToText(param, analog_sub_buttons[sub_button_id2]));
+ }
+ });
+ context_menu.exec(
+ analog_map_buttons[sub_button_id]->mapToGlobal(menu_location));
+ });
+ }
+
+ connect(ui->sliderRingAnalogDeadzone, &QSlider::valueChanged, [=, this] {
+ Common::ParamPackage param = emulated_device->GetRingParam();
+ const auto slider_value = ui->sliderRingAnalogDeadzone->value();
+ ui->labelRingAnalogDeadzone->setText(tr("Deadzone: %1%").arg(slider_value));
+ param.Set("deadzone", slider_value / 100.0f);
+ emulated_device->SetRingParam(param);
+ });
+
+ connect(ui->restore_defaults_button, &QPushButton::clicked, this,
+ &ConfigureRingController::RestoreDefaults);
+
+ timeout_timer->setSingleShot(true);
+ connect(timeout_timer.get(), &QTimer::timeout, [this] { SetPollingResult({}, true); });
+
+ connect(poll_timer.get(), &QTimer::timeout, [this] {
+ const auto& params = input_subsystem->GetNextInput();
+ if (params.Has("engine") && IsInputAcceptable(params)) {
+ SetPollingResult(params, false);
+ return;
+ }
+ });
+
+ resize(0, 0);
+}
+
+ConfigureRingController::~ConfigureRingController() {
+ emulated_device->DisableConfiguration();
+};
+
+void ConfigureRingController::changeEvent(QEvent* event) {
+ if (event->type() == QEvent::LanguageChange) {
+ RetranslateUI();
+ }
+
+ QDialog::changeEvent(event);
+}
+
+void ConfigureRingController::RetranslateUI() {
+ ui->retranslateUi(this);
+}
+
+void ConfigureRingController::UpdateUI() {
+ RetranslateUI();
+ const Common::ParamPackage param = emulated_device->GetRingParam();
+
+ for (int sub_button_id = 0; sub_button_id < ANALOG_SUB_BUTTONS_NUM; ++sub_button_id) {
+ auto* const analog_button = analog_map_buttons[sub_button_id];
+
+ if (analog_button == nullptr) {
+ continue;
+ }
+
+ analog_button->setText(AnalogToText(param, analog_sub_buttons[sub_button_id]));
+ }
+
+ const auto deadzone_label = ui->labelRingAnalogDeadzone;
+ const auto deadzone_slider = ui->sliderRingAnalogDeadzone;
+
+ int slider_value = static_cast<int>(param.Get("deadzone", 0.15f) * 100);
+ deadzone_label->setText(tr("Deadzone: %1%").arg(slider_value));
+ deadzone_slider->setValue(slider_value);
+}
+
+void ConfigureRingController::ApplyConfiguration() {
+ emulated_device->DisableConfiguration();
+ emulated_device->SaveCurrentConfig();
+ emulated_device->EnableConfiguration();
+}
+
+void ConfigureRingController::LoadConfiguration() {
+ UpdateUI();
+}
+
+void ConfigureRingController::RestoreDefaults() {
+ const std::string default_ring_string = InputCommon::GenerateAnalogParamFromKeys(
+ 0, 0, Config::default_ringcon_analogs[0], Config::default_ringcon_analogs[1], 0, 0.05f);
+ emulated_device->SetRingParam(Common::ParamPackage(default_ring_string));
+ UpdateUI();
+}
+
+void ConfigureRingController::HandleClick(
+ QPushButton* button, std::function<void(const Common::ParamPackage&)> new_input_setter,
+ InputCommon::Polling::InputType type) {
+ button->setText(tr("[waiting]"));
+ button->setFocus();
+
+ input_setter = new_input_setter;
+
+ input_subsystem->BeginMapping(type);
+
+ QWidget::grabMouse();
+ QWidget::grabKeyboard();
+
+ timeout_timer->start(2500); // Cancel after 2.5 seconds
+ poll_timer->start(25); // Check for new inputs every 25ms
+}
+
+void ConfigureRingController::SetPollingResult(const Common::ParamPackage& params, bool abort) {
+ timeout_timer->stop();
+ poll_timer->stop();
+ input_subsystem->StopMapping();
+
+ QWidget::releaseMouse();
+ QWidget::releaseKeyboard();
+
+ if (!abort) {
+ (*input_setter)(params);
+ }
+
+ UpdateUI();
+
+ input_setter = std::nullopt;
+}
+
+bool ConfigureRingController::IsInputAcceptable(const Common::ParamPackage& params) const {
+ return true;
+}
+
+void ConfigureRingController::mousePressEvent(QMouseEvent* event) {
+ if (!input_setter || !event) {
+ return;
+ }
+
+ const auto button = GRenderWindow::QtButtonToMouseButton(event->button());
+ input_subsystem->GetMouse()->PressButton(0, 0, 0, 0, button);
+}
+
+void ConfigureRingController::keyPressEvent(QKeyEvent* event) {
+ if (!input_setter || !event) {
+ return;
+ }
+ event->ignore();
+ if (event->key() != Qt::Key_Escape) {
+ input_subsystem->GetKeyboard()->PressKey(event->key());
+ }
+}
+
+QString ConfigureRingController::ButtonToText(const Common::ParamPackage& param) {
+ if (!param.Has("engine")) {
+ return QObject::tr("[not set]");
+ }
+
+ const QString toggle = QString::fromStdString(param.Get("toggle", false) ? "~" : "");
+ const QString inverted = QString::fromStdString(param.Get("inverted", false) ? "!" : "");
+ const auto common_button_name = input_subsystem->GetButtonName(param);
+
+ // Retrieve the names from Qt
+ if (param.Get("engine", "") == "keyboard") {
+ const QString button_str = GetKeyName(param.Get("code", 0));
+ return QObject::tr("%1%2").arg(toggle, button_str);
+ }
+
+ if (common_button_name == Common::Input::ButtonNames::Invalid) {
+ return QObject::tr("[invalid]");
+ }
+
+ if (common_button_name == Common::Input::ButtonNames::Engine) {
+ return QString::fromStdString(param.Get("engine", ""));
+ }
+
+ if (common_button_name == Common::Input::ButtonNames::Value) {
+ if (param.Has("hat")) {
+ const QString hat = QString::fromStdString(param.Get("direction", ""));
+ return QObject::tr("%1%2Hat %3").arg(toggle, inverted, hat);
+ }
+ if (param.Has("axis")) {
+ const QString axis = QString::fromStdString(param.Get("axis", ""));
+ return QObject::tr("%1%2Axis %3").arg(toggle, inverted, axis);
+ }
+ if (param.Has("axis_x") && param.Has("axis_y") && param.Has("axis_z")) {
+ const QString axis_x = QString::fromStdString(param.Get("axis_x", ""));
+ const QString axis_y = QString::fromStdString(param.Get("axis_y", ""));
+ const QString axis_z = QString::fromStdString(param.Get("axis_z", ""));
+ return QObject::tr("%1%2Axis %3,%4,%5").arg(toggle, inverted, axis_x, axis_y, axis_z);
+ }
+ if (param.Has("motion")) {
+ const QString motion = QString::fromStdString(param.Get("motion", ""));
+ return QObject::tr("%1%2Motion %3").arg(toggle, inverted, motion);
+ }
+ if (param.Has("button")) {
+ const QString button = QString::fromStdString(param.Get("button", ""));
+ return QObject::tr("%1%2Button %3").arg(toggle, inverted, button);
+ }
+ }
+
+ QString button_name = GetButtonName(common_button_name);
+ if (param.Has("hat")) {
+ return QObject::tr("%1%2Hat %3").arg(toggle, inverted, button_name);
+ }
+ if (param.Has("axis")) {
+ return QObject::tr("%1%2Axis %3").arg(toggle, inverted, button_name);
+ }
+ if (param.Has("motion")) {
+ return QObject::tr("%1%2Axis %3").arg(toggle, inverted, button_name);
+ }
+ if (param.Has("button")) {
+ return QObject::tr("%1%2Button %3").arg(toggle, inverted, button_name);
+ }
+
+ return QObject::tr("[unknown]");
+}
+
+QString ConfigureRingController::AnalogToText(const Common::ParamPackage& param,
+ const std::string& dir) {
+ if (!param.Has("engine")) {
+ return QObject::tr("[not set]");
+ }
+
+ if (param.Get("engine", "") == "analog_from_button") {
+ return ButtonToText(Common::ParamPackage{param.Get(dir, "")});
+ }
+
+ if (!param.Has("axis_x") || !param.Has("axis_y")) {
+ return QObject::tr("[unknown]");
+ }
+
+ const auto engine_str = param.Get("engine", "");
+ const QString axis_x_str = QString::fromStdString(param.Get("axis_x", ""));
+ const QString axis_y_str = QString::fromStdString(param.Get("axis_y", ""));
+ const bool invert_x = param.Get("invert_x", "+") == "-";
+ const bool invert_y = param.Get("invert_y", "+") == "-";
+
+ if (dir == "modifier") {
+ return QObject::tr("[unused]");
+ }
+
+ if (dir == "left") {
+ const QString invert_x_str = QString::fromStdString(invert_x ? "+" : "-");
+ return QObject::tr("Axis %1%2").arg(axis_x_str, invert_x_str);
+ }
+ if (dir == "right") {
+ const QString invert_x_str = QString::fromStdString(invert_x ? "-" : "+");
+ return QObject::tr("Axis %1%2").arg(axis_x_str, invert_x_str);
+ }
+ if (dir == "up") {
+ const QString invert_y_str = QString::fromStdString(invert_y ? "-" : "+");
+ return QObject::tr("Axis %1%2").arg(axis_y_str, invert_y_str);
+ }
+ if (dir == "down") {
+ const QString invert_y_str = QString::fromStdString(invert_y ? "+" : "-");
+ return QObject::tr("Axis %1%2").arg(axis_y_str, invert_y_str);
+ }
+
+ return QObject::tr("[unknown]");
+} \ No newline at end of file
diff --git a/src/yuzu/configuration/configure_ringcon.h b/src/yuzu/configuration/configure_ringcon.h
new file mode 100644
index 000000000..38a9cb716
--- /dev/null
+++ b/src/yuzu/configuration/configure_ringcon.h
@@ -0,0 +1,84 @@
+// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+#include <functional>
+#include <memory>
+#include <QDialog>
+
+namespace InputCommon {
+class InputSubsystem;
+} // namespace InputCommon
+
+namespace Core::HID {
+class HIDCore;
+class EmulatedDevices;
+} // namespace Core::HID
+
+namespace Ui {
+class ConfigureRingController;
+} // namespace Ui
+
+class ConfigureRingController : public QDialog {
+ Q_OBJECT
+
+public:
+ explicit ConfigureRingController(QWidget* parent, InputCommon::InputSubsystem* input_subsystem_,
+ Core::HID::HIDCore& hid_core_);
+ ~ConfigureRingController() override;
+
+ void ApplyConfiguration();
+
+private:
+ void changeEvent(QEvent* event) override;
+ void RetranslateUI();
+
+ void UpdateUI();
+
+ /// Load configuration settings.
+ void LoadConfiguration();
+
+ /// Restore all buttons to their default values.
+ void RestoreDefaults();
+
+ /// Called when the button was pressed.
+ void HandleClick(QPushButton* button,
+ std::function<void(const Common::ParamPackage&)> new_input_setter,
+ InputCommon::Polling::InputType type);
+
+ /// Finish polling and configure input using the input_setter.
+ void SetPollingResult(const Common::ParamPackage& params, bool abort);
+
+ /// Checks whether a given input can be accepted.
+ bool IsInputAcceptable(const Common::ParamPackage& params) const;
+
+ /// Handle mouse button press events.
+ void mousePressEvent(QMouseEvent* event) override;
+
+ /// Handle key press events.
+ void keyPressEvent(QKeyEvent* event) override;
+
+ QString ButtonToText(const Common::ParamPackage& param);
+
+ QString AnalogToText(const Common::ParamPackage& param, const std::string& dir);
+
+ static constexpr int ANALOG_SUB_BUTTONS_NUM = 2;
+
+ // A group of four QPushButtons represent one analog input. The buttons each represent left,
+ // right, respectively.
+ std::array<QPushButton*, ANALOG_SUB_BUTTONS_NUM> analog_map_buttons;
+
+ static const std::array<std::string, ANALOG_SUB_BUTTONS_NUM> analog_sub_buttons;
+
+ std::unique_ptr<QTimer> timeout_timer;
+ std::unique_ptr<QTimer> poll_timer;
+
+ /// This will be the the setting function when an input is awaiting configuration.
+ std::optional<std::function<void(const Common::ParamPackage&)>> input_setter;
+
+ InputCommon::InputSubsystem* input_subsystem;
+ Core::HID::EmulatedDevices* emulated_device;
+
+ std::unique_ptr<Ui::ConfigureRingController> ui;
+};
diff --git a/src/yuzu/configuration/configure_ringcon.ui b/src/yuzu/configuration/configure_ringcon.ui
new file mode 100644
index 000000000..9ec634dd4
--- /dev/null
+++ b/src/yuzu/configuration/configure_ringcon.ui
@@ -0,0 +1,278 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>ConfigureRingController</class>
+ <widget class="QDialog" name="ConfigureRingController">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>298</width>
+ <height>339</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Configure Ring Controller</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QLabel" name="label_2">
+ <property name="minimumSize">
+ <size>
+ <width>280</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>If you want to use this controller configure player 1 as right controller and player 2 as dual joycon before starting the game to allow this controller to be detected properly.</string>
+ </property>
+ <property name="wordWrap">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="verticalSpacer_2">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Fixed</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>10</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="RingAnalog">
+ <property name="title">
+ <string>Ring Sensor Parameters</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_3">
+ <property name="spacing">
+ <number>0</number>
+ </property>
+ <property name="sizeConstraint">
+ <enum>QLayout::SetDefaultConstraint</enum>
+ </property>
+ <property name="leftMargin">
+ <number>3</number>
+ </property>
+ <property name="topMargin">
+ <number>6</number>
+ </property>
+ <property name="rightMargin">
+ <number>3</number>
+ </property>
+ <property name="bottomMargin">
+ <number>0</number>
+ </property>
+ <item>
+ <layout class="QHBoxLayout" name="buttonRingAnalogPullHorizontaLayout">
+ <property name="spacing">
+ <number>3</number>
+ </property>
+ <item alignment="Qt::AlignHCenter">
+ <widget class="QGroupBox" name="buttonRingAnalogPullGroup">
+ <property name="title">
+ <string>Pull</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ <layout class="QVBoxLayout" name="buttonRingAnalogPullVerticalLayout">
+ <property name="spacing">
+ <number>3</number>
+ </property>
+ <property name="leftMargin">
+ <number>3</number>
+ </property>
+ <property name="topMargin">
+ <number>3</number>
+ </property>
+ <property name="rightMargin">
+ <number>3</number>
+ </property>
+ <property name="bottomMargin">
+ <number>3</number>
+ </property>
+ <item>
+ <widget class="QPushButton" name="buttonRingAnalogPull">
+ <property name="minimumSize">
+ <size>
+ <width>68</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>68</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="styleSheet">
+ <string notr="true">min-width: 68px;</string>
+ </property>
+ <property name="text">
+ <string>Pull</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item alignment="Qt::AlignHCenter">
+ <widget class="QGroupBox" name="buttonRingAnalogPushGroup">
+ <property name="title">
+ <string>Push</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ <layout class="QVBoxLayout" name="buttonRingAnalogPushVerticalLayout">
+ <property name="spacing">
+ <number>3</number>
+ </property>
+ <property name="leftMargin">
+ <number>3</number>
+ </property>
+ <property name="topMargin">
+ <number>3</number>
+ </property>
+ <property name="rightMargin">
+ <number>3</number>
+ </property>
+ <property name="bottomMargin">
+ <number>3</number>
+ </property>
+ <item>
+ <widget class="QPushButton" name="buttonRingAnalogPush">
+ <property name="minimumSize">
+ <size>
+ <width>68</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>68</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="styleSheet">
+ <string notr="true">min-width: 68px;</string>
+ </property>
+ <property name="text">
+ <string>Push</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QVBoxLayout" name="sliderRingAnalogDeadzoneVerticalLayout">
+ <property name="spacing">
+ <number>3</number>
+ </property>
+ <property name="sizeConstraint">
+ <enum>QLayout::SetDefaultConstraint</enum>
+ </property>
+ <property name="leftMargin">
+ <number>0</number>
+ </property>
+ <property name="topMargin">
+ <number>10</number>
+ </property>
+ <property name="rightMargin">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
+ <number>3</number>
+ </property>
+ <item>
+ <layout class="QHBoxLayout" name="sliderRingAnalogDeadzoneHorizontalLayout">
+ <item>
+ <widget class="QLabel" name="labelRingAnalogDeadzone">
+ <property name="text">
+ <string>Deadzone: 0%</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignHCenter</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QSlider" name="sliderRingAnalogDeadzone">
+ <property name="maximum">
+ <number>100</number>
+ </property>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ </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>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QPushButton" name="restore_defaults_button">
+ <property name="text">
+ <string>Restore Defaults</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QDialogButtonBox" name="buttonBox">
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>accepted()</signal>
+ <receiver>ConfigureRingController</receiver>
+ <slot>accept()</slot>
+ </connection>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>rejected()</signal>
+ <receiver>ConfigureRingController</receiver>
+ <slot>reject()</slot>
+ </connection>
+ </connections>
+</ui>
diff --git a/src/yuzu/configuration/configure_system.cpp b/src/yuzu/configuration/configure_system.cpp
index 56c762d64..bc9d9d77a 100644
--- a/src/yuzu/configuration/configure_system.cpp
+++ b/src/yuzu/configuration/configure_system.cpp
@@ -1,15 +1,12 @@
-// Copyright 2016 Citra Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: 2016 Citra Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
-#include <array>
#include <chrono>
#include <optional>
#include <QFileDialog>
#include <QGraphicsItem>
#include <QMessageBox>
-#include "common/assert.h"
#include "common/settings.h"
#include "core/core.h"
#include "core/hle/service/time/time_manager.h"
@@ -132,8 +129,7 @@ void ConfigureSystem::ApplyConfiguration() {
// Guard if during game and set to game-specific value
if (Settings::values.rng_seed.UsingGlobal()) {
if (ui->rng_seed_checkbox->isChecked()) {
- Settings::values.rng_seed.SetValue(
- ui->rng_seed_edit->text().toULongLong(nullptr, 16));
+ Settings::values.rng_seed.SetValue(ui->rng_seed_edit->text().toUInt(nullptr, 16));
} else {
Settings::values.rng_seed.SetValue(std::nullopt);
}
@@ -144,8 +140,7 @@ void ConfigureSystem::ApplyConfiguration() {
case ConfigurationShared::CheckState::Off:
Settings::values.rng_seed.SetGlobal(false);
if (ui->rng_seed_checkbox->isChecked()) {
- Settings::values.rng_seed.SetValue(
- ui->rng_seed_edit->text().toULongLong(nullptr, 16));
+ Settings::values.rng_seed.SetValue(ui->rng_seed_edit->text().toUInt(nullptr, 16));
} else {
Settings::values.rng_seed.SetValue(std::nullopt);
}
diff --git a/src/yuzu/configuration/configure_system.h b/src/yuzu/configuration/configure_system.h
index bb24c9ae7..8f02880a7 100644
--- a/src/yuzu/configuration/configure_system.h
+++ b/src/yuzu/configuration/configure_system.h
@@ -1,12 +1,10 @@
-// Copyright 2016 Citra Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: 2016 Citra Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include <memory>
-#include <QList>
#include <QWidget>
namespace Core {
diff --git a/src/yuzu/configuration/configure_system.ui b/src/yuzu/configuration/configure_system.ui
index 5b68dcb29..b234ea87b 100644
--- a/src/yuzu/configuration/configure_system.ui
+++ b/src/yuzu/configuration/configure_system.ui
@@ -474,9 +474,6 @@
<day>1</day>
</date>
</property>
- <property name="displayFormat">
- <string>d MMM yyyy h:mm:ss AP</string>
- </property>
</widget>
</item>
<item row="6" column="1">
diff --git a/src/yuzu/configuration/configure_tas.cpp b/src/yuzu/configuration/configure_tas.cpp
index 979a8db61..1edc5f1f3 100644
--- a/src/yuzu/configuration/configure_tas.cpp
+++ b/src/yuzu/configuration/configure_tas.cpp
@@ -1,6 +1,5 @@
-// Copyright 2021 yuzu Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#include <QFileDialog>
#include <QMessageBox>
diff --git a/src/yuzu/configuration/configure_tas.h b/src/yuzu/configuration/configure_tas.h
index 1546bf16f..4a6b0ba4e 100644
--- a/src/yuzu/configuration/configure_tas.h
+++ b/src/yuzu/configuration/configure_tas.h
@@ -1,11 +1,12 @@
-// Copyright 2021 yuzu Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include <QDialog>
+class QLineEdit;
+
namespace Ui {
class ConfigureTas;
}
diff --git a/src/yuzu/configuration/configure_tas.ui b/src/yuzu/configuration/configure_tas.ui
index cf88a5bf0..625af0c89 100644
--- a/src/yuzu/configuration/configure_tas.ui
+++ b/src/yuzu/configuration/configure_tas.ui
@@ -16,6 +16,9 @@
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Reads controller input from scripts in the same format as TAS-nx scripts.&lt;br/&gt;For a more detailed explanation, please consult the &lt;a href=&quot;https://yuzu-emu.org/help/feature/tas/&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#039be5;&quot;&gt;help page&lt;/span&gt;&lt;/a&gt; on the yuzu website.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
+ <property name="openExternalLinks">
+ <bool>true</bool>
+ </property>
</widget>
</item>
<item row="1" column="0" colspan="4">
diff --git a/src/yuzu/configuration/configure_touch_from_button.cpp b/src/yuzu/configuration/configure_touch_from_button.cpp
index bde0a08c4..18e2eba69 100644
--- a/src/yuzu/configuration/configure_touch_from_button.cpp
+++ b/src/yuzu/configuration/configure_touch_from_button.cpp
@@ -1,12 +1,10 @@
-// Copyright 2020 Citra Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: 2020 Citra Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#include <QInputDialog>
#include <QKeyEvent>
#include <QMessageBox>
#include <QMouseEvent>
-#include <QResizeEvent>
#include <QStandardItemModel>
#include <QTimer>
#include "common/param_package.h"
@@ -69,10 +67,10 @@ static QString ButtonToText(const Common::ParamPackage& param) {
}
ConfigureTouchFromButton::ConfigureTouchFromButton(
- QWidget* parent, const std::vector<Settings::TouchFromButtonMap>& touch_maps,
+ QWidget* parent, const std::vector<Settings::TouchFromButtonMap>& touch_maps_,
InputCommon::InputSubsystem* input_subsystem_, const int default_index)
: QDialog(parent), ui(std::make_unique<Ui::ConfigureTouchFromButton>()),
- touch_maps(touch_maps), input_subsystem{input_subsystem_}, selected_index(default_index),
+ touch_maps{touch_maps_}, input_subsystem{input_subsystem_}, selected_index{default_index},
timeout_timer(std::make_unique<QTimer>()), poll_timer(std::make_unique<QTimer>()) {
ui->setupUi(this);
binding_list_model = new QStandardItemModel(0, 3, this);
@@ -227,6 +225,9 @@ void ConfigureTouchFromButton::RenameMapping() {
}
void ConfigureTouchFromButton::GetButtonInput(const int row_index, const bool is_new) {
+ if (timeout_timer->isActive()) {
+ return;
+ }
binding_list_model->item(row_index, 0)->setText(tr("[press key]"));
input_setter = [this, row_index, is_new](const Common::ParamPackage& params,
diff --git a/src/yuzu/configuration/configure_touch_from_button.h b/src/yuzu/configuration/configure_touch_from_button.h
index e1400481a..5a1416d00 100644
--- a/src/yuzu/configuration/configure_touch_from_button.h
+++ b/src/yuzu/configuration/configure_touch_from_button.h
@@ -1,6 +1,5 @@
-// Copyright 2020 Citra Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: 2020 Citra Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
@@ -37,7 +36,7 @@ class ConfigureTouchFromButton : public QDialog {
public:
explicit ConfigureTouchFromButton(QWidget* parent,
- const std::vector<Settings::TouchFromButtonMap>& touch_maps,
+ const std::vector<Settings::TouchFromButtonMap>& touch_maps_,
InputCommon::InputSubsystem* input_subsystem_,
int default_index = 0);
~ConfigureTouchFromButton() override;
diff --git a/src/yuzu/configuration/configure_touch_widget.h b/src/yuzu/configuration/configure_touch_widget.h
index 347b46583..49f533afe 100644
--- a/src/yuzu/configuration/configure_touch_widget.h
+++ b/src/yuzu/configuration/configure_touch_widget.h
@@ -1,6 +1,5 @@
-// Copyright 2020 Citra Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: 2020 Citra Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
diff --git a/src/yuzu/configuration/configure_touchscreen_advanced.cpp b/src/yuzu/configuration/configure_touchscreen_advanced.cpp
index 29c86c7bc..5a03e48df 100644
--- a/src/yuzu/configuration/configure_touchscreen_advanced.cpp
+++ b/src/yuzu/configuration/configure_touchscreen_advanced.cpp
@@ -1,6 +1,5 @@
-// Copyright 2016 Citra Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: 2016 Citra Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#include <memory>
#include "ui_configure_touchscreen_advanced.h"
diff --git a/src/yuzu/configuration/configure_touchscreen_advanced.h b/src/yuzu/configuration/configure_touchscreen_advanced.h
index 72061492c..034dc0d46 100644
--- a/src/yuzu/configuration/configure_touchscreen_advanced.h
+++ b/src/yuzu/configuration/configure_touchscreen_advanced.h
@@ -1,6 +1,5 @@
-// Copyright 2016 Citra Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: 2016 Citra Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
diff --git a/src/yuzu/configuration/configure_ui.cpp b/src/yuzu/configuration/configure_ui.cpp
index 46e5409db..48f71b53c 100644
--- a/src/yuzu/configuration/configure_ui.cpp
+++ b/src/yuzu/configuration/configure_ui.cpp
@@ -1,6 +1,5 @@
-// Copyright 2016 Citra Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: 2016 Citra Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#include <array>
#include <utility>
@@ -9,6 +8,7 @@
#include <QDirIterator>
#include "common/common_types.h"
#include "common/fs/path_util.h"
+#include "common/logging/log.h"
#include "common/settings.h"
#include "core/core.h"
#include "ui_configure_ui.h"
@@ -170,14 +170,75 @@ void ConfigureUi::RetranslateUI() {
}
void ConfigureUi::InitializeLanguageComboBox() {
+ // This is a list of lexicographically sorted languages, only the available translations are
+ // shown to the user.
+ static const struct {
+ const QString name;
+ const char* id;
+ } languages[] = {
+ // clang-format off
+ {QStringLiteral(u"Bahasa Indonesia"), "id"}, // Indonesian
+ {QStringLiteral(u"Bahasa Melayu"), "ms"}, // Malay
+ {QStringLiteral(u"Catal\u00E0"), "ca"}, // Catalan
+ {QStringLiteral(u"\u010Ce\u0161tina"), "cs"}, // Czech
+ {QStringLiteral(u"Dansk"), "da"}, // Danish
+ {QStringLiteral(u"Deutsch"), "de"}, // German
+ {QStringLiteral(u"English"), "en"}, // English
+ {QStringLiteral(u"Espa\u00F1ol"), "es"}, // Spanish
+ {QStringLiteral(u"Fran\u00E7ais"), "fr"}, // French
+ {QStringLiteral(u"Hrvatski"), "hr"}, // Croatian
+ {QStringLiteral(u"Italiano"), "it"}, // Italian
+ {QStringLiteral(u"Magyar"), "hu"}, // Hungarian
+ {QStringLiteral(u"Nederlands"), "nl"}, // Dutch
+ {QStringLiteral(u"Norsk bokm\u00E5l"), "nb"}, // Norwegian
+ {QStringLiteral(u"Polski"), "pl"}, // Polish
+ {QStringLiteral(u"Portugu\u00EAs"), "pt_PT"}, // Portuguese
+ {QStringLiteral(u"Portugu\u00EAs (Brasil)"), "pt_BR"}, // Portuguese (Brazil)
+ {QStringLiteral(u"Rom\u00E2n\u0103"), "ro"}, // Romanian
+ {QStringLiteral(u"Srpski"), "sr"}, // Serbian
+ {QStringLiteral(u"Suomi"), "fi"}, // Finnish
+ {QStringLiteral(u"Svenska"), "sv"}, // Swedish
+ {QStringLiteral(u"Ti\u1EBFng Vi\u1EC7t"), "vi"}, // Vietnamese
+ {QStringLiteral(u"Ti\u1EBFng Vi\u1EC7t (Vi\u1EC7t Nam)"), "vi_VN"}, // Vietnamese
+ {QStringLiteral(u"T\u00FCrk\u00E7e"), "tr_TR"}, // Turkish
+ {QStringLiteral(u"\u0395\u03BB\u03BB\u03B7\u03BD\u03B9\u03BA\u03AC"), "el"}, // Greek
+ {QStringLiteral(u"\u0420\u0443\u0441\u0441\u043A\u0438\u0439"), "ru_RU"}, // Russian
+ {QStringLiteral(u"\u0423\u043A\u0440\u0430\u0457\u043D\u0441\u044C\u043A\u0430"),
+ "uk"}, // Ukrainian
+ {QStringLiteral(u"\u0627\u0644\u0639\u0631\u0628\u064A\u0629"), "ar"}, // Arabic
+ {QStringLiteral(u"\u0641\u0627\u0631\u0633\u06CC"), "fa"}, // Farsi
+ {QStringLiteral(u"\uD55C\uAD6D\uC5B4"), "ko_KR"}, // Korean
+ {QStringLiteral(u"\u65E5\u672C\u8A9E"), "ja_JP"}, // Japanese
+ {QStringLiteral(u"\u7B80\u4F53\u4E2D\u6587"), "zh_CN"}, // Simplified Chinese
+ {QStringLiteral(u"\u7E41\u9AD4\u4E2D\u6587"), "zh_TW"}, // Traditional Chinese
+ // clang-format on
+ };
ui->language_combobox->addItem(tr("<System>"), QString{});
- ui->language_combobox->addItem(tr("English"), QStringLiteral("en"));
- QDirIterator it(QStringLiteral(":/languages"), QDirIterator::NoIteratorFlags);
- while (it.hasNext()) {
- QString locale = it.next();
+ QDir languages_dir{QStringLiteral(":/languages")};
+ QStringList language_files = languages_dir.entryList();
+ for (const auto& lang : languages) {
+ if (QString::fromLatin1(lang.id) == QStringLiteral("en")) {
+ ui->language_combobox->addItem(lang.name, QStringLiteral("en"));
+ language_files.removeOne(QStringLiteral("en.qm"));
+ continue;
+ }
+ for (int i = 0; i < language_files.size(); ++i) {
+ QString locale = language_files[i];
+ locale.truncate(locale.lastIndexOf(QLatin1Char{'.'}));
+ if (QString::fromLatin1(lang.id) == locale) {
+ ui->language_combobox->addItem(lang.name, locale);
+ language_files.removeAt(i);
+ break;
+ }
+ }
+ }
+ // Anything remaining will be at the bottom
+ for (const QString& file : language_files) {
+ LOG_CRITICAL(Frontend, "Unexpected Language File: {}", file.toStdString());
+ QString locale = file;
locale.truncate(locale.lastIndexOf(QLatin1Char{'.'}));
- locale.remove(0, locale.lastIndexOf(QLatin1Char{'/'}) + 1);
- const QString lang = QLocale::languageToString(QLocale(locale).language());
+ const QString language_name = QLocale::languageToString(QLocale(locale).language());
+ const QString lang = QStringLiteral("%1 [%2]").arg(language_name, locale);
ui->language_combobox->addItem(lang, locale);
}
diff --git a/src/yuzu/configuration/configure_ui.h b/src/yuzu/configuration/configure_ui.h
index 48b6e6d82..95af8370e 100644
--- a/src/yuzu/configuration/configure_ui.h
+++ b/src/yuzu/configuration/configure_ui.h
@@ -1,6 +1,5 @@
-// Copyright 2016 Citra Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: 2016 Citra Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
diff --git a/src/yuzu/configuration/configure_vibration.cpp b/src/yuzu/configuration/configure_vibration.cpp
index 779b6401c..d765e808a 100644
--- a/src/yuzu/configuration/configure_vibration.cpp
+++ b/src/yuzu/configuration/configure_vibration.cpp
@@ -1,13 +1,6 @@
-// Copyright 2020 yuzu Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
-#include <algorithm>
-#include <unordered_map>
-
-#include <fmt/format.h>
-
-#include "common/param_package.h"
#include "common/settings.h"
#include "core/hid/emulated_controller.h"
#include "core/hid/hid_core.h"
diff --git a/src/yuzu/configuration/configure_vibration.h b/src/yuzu/configuration/configure_vibration.h
index 50b8195fa..e9d05df51 100644
--- a/src/yuzu/configuration/configure_vibration.h
+++ b/src/yuzu/configuration/configure_vibration.h
@@ -1,6 +1,5 @@
-// Copyright 2020 yuzu Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
diff --git a/src/yuzu/configuration/configure_web.cpp b/src/yuzu/configuration/configure_web.cpp
index d779251b4..ab526e4ca 100644
--- a/src/yuzu/configuration/configure_web.cpp
+++ b/src/yuzu/configuration/configure_web.cpp
@@ -1,6 +1,5 @@
-// Copyright 2017 Citra Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: 2017 Citra Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#include <QIcon>
#include <QMessageBox>
@@ -129,20 +128,25 @@ void ConfigureWeb::RefreshTelemetryID() {
void ConfigureWeb::OnLoginChanged() {
if (ui->edit_token->text().isEmpty()) {
user_verified = true;
-
- const QPixmap pixmap = QIcon::fromTheme(QStringLiteral("checked")).pixmap(16);
- ui->label_token_verified->setPixmap(pixmap);
+ // Empty = no icon
+ ui->label_token_verified->setPixmap(QPixmap());
+ ui->label_token_verified->setToolTip(QString());
} else {
user_verified = false;
- const QPixmap pixmap = QIcon::fromTheme(QStringLiteral("failed")).pixmap(16);
+ // Show an info icon if it's been changed, clearer than showing failure
+ const QPixmap pixmap = QIcon::fromTheme(QStringLiteral("info")).pixmap(16);
ui->label_token_verified->setPixmap(pixmap);
+ ui->label_token_verified->setToolTip(
+ tr("Unverified, please click Verify before saving configuration", "Tooltip"));
}
}
void ConfigureWeb::VerifyLogin() {
ui->button_verify_login->setDisabled(true);
ui->button_verify_login->setText(tr("Verifying..."));
+ ui->label_token_verified->setPixmap(QIcon::fromTheme(QStringLiteral("sync")).pixmap(16));
+ ui->label_token_verified->setToolTip(tr("Verifying..."));
verify_watcher.setFuture(QtConcurrent::run(
[username = UsernameFromDisplayToken(ui->edit_token->text().toStdString()),
token = TokenFromDisplayToken(ui->edit_token->text().toStdString())] {
@@ -156,16 +160,21 @@ void ConfigureWeb::OnLoginVerified() {
if (verify_watcher.result()) {
user_verified = true;
- const QPixmap pixmap = QIcon::fromTheme(QStringLiteral("checked")).pixmap(16);
- ui->label_token_verified->setPixmap(pixmap);
+ ui->label_token_verified->setPixmap(QIcon::fromTheme(QStringLiteral("checked")).pixmap(16));
+ ui->label_token_verified->setToolTip(tr("Verified", "Tooltip"));
ui->username->setText(
QString::fromStdString(UsernameFromDisplayToken(ui->edit_token->text().toStdString())));
} else {
- const QPixmap pixmap = QIcon::fromTheme(QStringLiteral("failed")).pixmap(16);
- ui->label_token_verified->setPixmap(pixmap);
+ ui->label_token_verified->setPixmap(QIcon::fromTheme(QStringLiteral("failed")).pixmap(16));
+ ui->label_token_verified->setToolTip(tr("Verification failed", "Tooltip"));
ui->username->setText(tr("Unspecified"));
QMessageBox::critical(this, tr("Verification failed"),
tr("Verification failed. Check that you have entered your token "
"correctly, and that your internet connection is working."));
}
}
+
+void ConfigureWeb::SetWebServiceConfigEnabled(bool enabled) {
+ ui->label_disable_info->setVisible(!enabled);
+ ui->groupBoxWebConfig->setEnabled(enabled);
+}
diff --git a/src/yuzu/configuration/configure_web.h b/src/yuzu/configuration/configure_web.h
index 9054711ea..03feb55f8 100644
--- a/src/yuzu/configuration/configure_web.h
+++ b/src/yuzu/configuration/configure_web.h
@@ -1,6 +1,5 @@
-// Copyright 2017 Citra Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: 2017 Citra Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
@@ -20,6 +19,7 @@ public:
~ConfigureWeb() override;
void ApplyConfiguration();
+ void SetWebServiceConfigEnabled(bool enabled);
private:
void changeEvent(QEvent* event) override;
diff --git a/src/yuzu/configuration/configure_web.ui b/src/yuzu/configuration/configure_web.ui
index 35b4274b0..3ac3864be 100644
--- a/src/yuzu/configuration/configure_web.ui
+++ b/src/yuzu/configuration/configure_web.ui
@@ -113,6 +113,16 @@
</widget>
</item>
<item>
+ <widget class="QLabel" name="label_disable_info">
+ <property name="text">
+ <string>Web Service configuration can only be changed when a public room isn't being hosted.</string>
+ </property>
+ <property name="wordWrap">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Telemetry</string>
diff --git a/src/yuzu/configuration/input_profiles.cpp b/src/yuzu/configuration/input_profiles.cpp
index 38ea6c772..9bb69cab1 100644
--- a/src/yuzu/configuration/input_profiles.cpp
+++ b/src/yuzu/configuration/input_profiles.cpp
@@ -1,6 +1,5 @@
-// Copyright 2020 yuzu Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#include <fmt/format.h>
@@ -28,7 +27,7 @@ std::filesystem::path GetNameWithoutExtension(std::filesystem::path filename) {
} // namespace
-InputProfiles::InputProfiles(Core::System& system_) : system{system_} {
+InputProfiles::InputProfiles() {
const auto input_profile_loc = FS::GetYuzuPath(FS::YuzuPath::ConfigDir) / "input";
if (!FS::IsDir(input_profile_loc)) {
@@ -44,8 +43,8 @@ InputProfiles::InputProfiles(Core::System& system_) : system{system_} {
if (IsINI(filename) && IsProfileNameValid(name_without_ext)) {
map_profiles.insert_or_assign(
- name_without_ext, std::make_unique<Config>(system, name_without_ext,
- Config::ConfigType::InputProfile));
+ name_without_ext,
+ std::make_unique<Config>(name_without_ext, Config::ConfigType::InputProfile));
}
return true;
@@ -68,6 +67,8 @@ std::vector<std::string> InputProfiles::GetInputProfileNames() {
profile_names.push_back(profile_name);
}
+ std::stable_sort(profile_names.begin(), profile_names.end());
+
return profile_names;
}
@@ -81,8 +82,7 @@ bool InputProfiles::CreateProfile(const std::string& profile_name, std::size_t p
}
map_profiles.insert_or_assign(
- profile_name,
- std::make_unique<Config>(system, profile_name, Config::ConfigType::InputProfile));
+ profile_name, std::make_unique<Config>(profile_name, Config::ConfigType::InputProfile));
return SaveProfile(profile_name, player_index);
}
diff --git a/src/yuzu/configuration/input_profiles.h b/src/yuzu/configuration/input_profiles.h
index a567bd5a9..2bf3e4250 100644
--- a/src/yuzu/configuration/input_profiles.h
+++ b/src/yuzu/configuration/input_profiles.h
@@ -1,11 +1,9 @@
-// Copyright 2020 yuzu Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include <string>
-#include <string_view>
#include <unordered_map>
namespace Core {
@@ -17,7 +15,7 @@ class Config;
class InputProfiles {
public:
- explicit InputProfiles(Core::System& system_);
+ explicit InputProfiles();
virtual ~InputProfiles();
std::vector<std::string> GetInputProfileNames();
@@ -33,6 +31,4 @@ private:
bool ProfileExistsInMap(const std::string& profile_name) const;
std::unordered_map<std::string, std::unique_ptr<Config>> map_profiles;
-
- Core::System& system;
};
diff --git a/src/yuzu/debugger/console.cpp b/src/yuzu/debugger/console.cpp
index f89ea8ea7..1c1342ff1 100644
--- a/src/yuzu/debugger/console.cpp
+++ b/src/yuzu/debugger/console.cpp
@@ -1,6 +1,5 @@
-// Copyright 2018 yuzu Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#ifdef _WIN32
#include <windows.h>
@@ -30,6 +29,7 @@ void ToggleConsole() {
freopen_s(&temp, "CONIN$", "r", stdin);
freopen_s(&temp, "CONOUT$", "w", stdout);
freopen_s(&temp, "CONOUT$", "w", stderr);
+ SetConsoleOutputCP(65001);
SetColorConsoleBackendEnabled(true);
}
} else {
diff --git a/src/yuzu/debugger/console.h b/src/yuzu/debugger/console.h
index d1990c496..fdb7d174c 100644
--- a/src/yuzu/debugger/console.h
+++ b/src/yuzu/debugger/console.h
@@ -1,6 +1,5 @@
-// Copyright 2018 yuzu Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
diff --git a/src/yuzu/debugger/controller.cpp b/src/yuzu/debugger/controller.cpp
index 6b834c42e..e4bf16a04 100644
--- a/src/yuzu/debugger/controller.cpp
+++ b/src/yuzu/debugger/controller.cpp
@@ -1,6 +1,5 @@
-// Copyright 2015 Citra Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: 2015 Citra Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#include <QAction>
#include <QLayout>
diff --git a/src/yuzu/debugger/controller.h b/src/yuzu/debugger/controller.h
index 52cea3326..9651dfaa9 100644
--- a/src/yuzu/debugger/controller.h
+++ b/src/yuzu/debugger/controller.h
@@ -1,6 +1,5 @@
-// Copyright 2015 Citra Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: 2015 Citra Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
diff --git a/src/yuzu/debugger/profiler.cpp b/src/yuzu/debugger/profiler.cpp
index 33110685a..d3e2d3c12 100644
--- a/src/yuzu/debugger/profiler.cpp
+++ b/src/yuzu/debugger/profiler.cpp
@@ -1,6 +1,5 @@
-// Copyright 2015 Citra Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: 2015 Citra Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#include <QAction>
#include <QLayout>
diff --git a/src/yuzu/debugger/profiler.h b/src/yuzu/debugger/profiler.h
index 8e69fdb06..4c8ccd3c2 100644
--- a/src/yuzu/debugger/profiler.h
+++ b/src/yuzu/debugger/profiler.h
@@ -1,6 +1,5 @@
-// Copyright 2015 Citra Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: 2015 Citra Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
diff --git a/src/yuzu/debugger/wait_tree.cpp b/src/yuzu/debugger/wait_tree.cpp
index 2d1a2d9cb..7f7c5fc42 100644
--- a/src/yuzu/debugger/wait_tree.cpp
+++ b/src/yuzu/debugger/wait_tree.cpp
@@ -1,15 +1,12 @@
-// Copyright 2016 Citra Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: 2016 Citra Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#include <array>
#include <fmt/format.h>
#include "yuzu/debugger/wait_tree.h"
#include "yuzu/uisettings.h"
-#include "yuzu/util/util.h"
-#include "common/assert.h"
#include "core/arm/arm_interface.h"
#include "core/core.h"
#include "core/hle/kernel/k_class_token.h"
@@ -115,9 +112,9 @@ QString WaitTreeText::GetText() const {
return text;
}
-WaitTreeMutexInfo::WaitTreeMutexInfo(VAddr mutex_address, const Kernel::KHandleTable& handle_table,
+WaitTreeMutexInfo::WaitTreeMutexInfo(VAddr mutex_address_, const Kernel::KHandleTable& handle_table,
Core::System& system_)
- : mutex_address(mutex_address), system{system_} {
+ : mutex_address{mutex_address_}, system{system_} {
mutex_value = system.Memory().Read32(mutex_address);
owner_handle = static_cast<Kernel::Handle>(mutex_value & Kernel::Svc::HandleWaitMask);
owner = handle_table.GetObject<Kernel::KThread>(owner_handle).GetPointerUnsafe();
@@ -142,8 +139,8 @@ std::vector<std::unique_ptr<WaitTreeItem>> WaitTreeMutexInfo::GetChildren() cons
return list;
}
-WaitTreeCallstack::WaitTreeCallstack(const Kernel::KThread& thread, Core::System& system_)
- : thread(thread), system{system_} {}
+WaitTreeCallstack::WaitTreeCallstack(const Kernel::KThread& thread_, Core::System& system_)
+ : thread{thread_}, system{system_} {}
WaitTreeCallstack::~WaitTreeCallstack() = default;
QString WaitTreeCallstack::GetText() const {
@@ -173,8 +170,8 @@ std::vector<std::unique_ptr<WaitTreeItem>> WaitTreeCallstack::GetChildren() cons
}
WaitTreeSynchronizationObject::WaitTreeSynchronizationObject(
- const Kernel::KSynchronizationObject& o, Core::System& system_)
- : object(o), system{system_} {}
+ const Kernel::KSynchronizationObject& object_, Core::System& system_)
+ : object{object_}, system{system_} {}
WaitTreeSynchronizationObject::~WaitTreeSynchronizationObject() = default;
WaitTreeExpandableItem::WaitTreeExpandableItem() = default;
@@ -382,8 +379,8 @@ std::vector<std::unique_ptr<WaitTreeItem>> WaitTreeThread::GetChildren() const {
return list;
}
-WaitTreeEvent::WaitTreeEvent(const Kernel::KReadableEvent& object, Core::System& system_)
- : WaitTreeSynchronizationObject(object, system_) {}
+WaitTreeEvent::WaitTreeEvent(const Kernel::KReadableEvent& object_, Core::System& system_)
+ : WaitTreeSynchronizationObject(object_, system_) {}
WaitTreeEvent::~WaitTreeEvent() = default;
WaitTreeThreadList::WaitTreeThreadList(std::vector<Kernel::KThread*>&& list, Core::System& system_)
diff --git a/src/yuzu/debugger/wait_tree.h b/src/yuzu/debugger/wait_tree.h
index ea4d2e299..7e528b592 100644
--- a/src/yuzu/debugger/wait_tree.h
+++ b/src/yuzu/debugger/wait_tree.h
@@ -1,6 +1,5 @@
-// Copyright 2016 Citra Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: 2016 Citra Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
@@ -8,7 +7,6 @@
#include <memory>
#include <vector>
-#include <QAbstractItemModel>
#include <QDockWidget>
#include <QTreeView>
@@ -79,7 +77,7 @@ public:
class WaitTreeMutexInfo : public WaitTreeExpandableItem {
Q_OBJECT
public:
- explicit WaitTreeMutexInfo(VAddr mutex_address, const Kernel::KHandleTable& handle_table,
+ explicit WaitTreeMutexInfo(VAddr mutex_address_, const Kernel::KHandleTable& handle_table,
Core::System& system_);
~WaitTreeMutexInfo() override;
@@ -98,7 +96,7 @@ private:
class WaitTreeCallstack : public WaitTreeExpandableItem {
Q_OBJECT
public:
- explicit WaitTreeCallstack(const Kernel::KThread& thread, Core::System& system_);
+ explicit WaitTreeCallstack(const Kernel::KThread& thread_, Core::System& system_);
~WaitTreeCallstack() override;
QString GetText() const override;
@@ -113,7 +111,7 @@ private:
class WaitTreeSynchronizationObject : public WaitTreeExpandableItem {
Q_OBJECT
public:
- explicit WaitTreeSynchronizationObject(const Kernel::KSynchronizationObject& object,
+ explicit WaitTreeSynchronizationObject(const Kernel::KSynchronizationObject& object_,
Core::System& system_);
~WaitTreeSynchronizationObject() override;
@@ -163,7 +161,7 @@ private:
class WaitTreeEvent : public WaitTreeSynchronizationObject {
Q_OBJECT
public:
- explicit WaitTreeEvent(const Kernel::KReadableEvent& object, Core::System& system_);
+ explicit WaitTreeEvent(const Kernel::KReadableEvent& object_, Core::System& system_);
~WaitTreeEvent() override;
};
diff --git a/src/yuzu/discord.h b/src/yuzu/discord.h
index a867cc4d6..e08784498 100644
--- a/src/yuzu/discord.h
+++ b/src/yuzu/discord.h
@@ -1,6 +1,5 @@
-// Copyright 2018 Citra Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: 2018 Citra Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
diff --git a/src/yuzu/discord_impl.cpp b/src/yuzu/discord_impl.cpp
index 66f928af6..c351e9b83 100644
--- a/src/yuzu/discord_impl.cpp
+++ b/src/yuzu/discord_impl.cpp
@@ -1,6 +1,5 @@
-// Copyright 2018 Citra Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: 2018 Citra Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#include <chrono>
#include <string>
diff --git a/src/yuzu/discord_impl.h b/src/yuzu/discord_impl.h
index 03ad42681..84710b9c6 100644
--- a/src/yuzu/discord_impl.h
+++ b/src/yuzu/discord_impl.h
@@ -1,6 +1,5 @@
-// Copyright 2018 Citra Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: 2018 Citra Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
diff --git a/src/yuzu/game_list.cpp b/src/yuzu/game_list.cpp
index e3661b390..b127badc2 100644
--- a/src/yuzu/game_list.cpp
+++ b/src/yuzu/game_list.cpp
@@ -1,6 +1,5 @@
-// Copyright 2015 Citra Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: 2015 Citra Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#include <regex>
#include <QApplication>
@@ -10,10 +9,10 @@
#include <QJsonArray>
#include <QJsonDocument>
#include <QJsonObject>
-#include <QKeyEvent>
#include <QList>
#include <QMenu>
#include <QThreadPool>
+#include <QToolButton>
#include <fmt/format.h>
#include "common/common_types.h"
#include "common/logging/log.h"
@@ -28,8 +27,8 @@
#include "yuzu/uisettings.h"
#include "yuzu/util/controller_navigation.h"
-GameListSearchField::KeyReleaseEater::KeyReleaseEater(GameList* gamelist, QObject* parent)
- : QObject(parent), gamelist{gamelist} {}
+GameListSearchField::KeyReleaseEater::KeyReleaseEater(GameList* gamelist_, QObject* parent)
+ : QObject(parent), gamelist{gamelist_} {}
// EventFilter in order to process systemkeys while editing the searchfield
bool GameListSearchField::KeyReleaseEater::eventFilter(QObject* obj, QEvent* event) {
@@ -80,9 +79,9 @@ bool GameListSearchField::KeyReleaseEater::eventFilter(QObject* obj, QEvent* eve
return QObject::eventFilter(obj, event);
}
-void GameListSearchField::setFilterResult(int visible, int total) {
- this->visible = visible;
- this->total = total;
+void GameListSearchField::setFilterResult(int visible_, int total_) {
+ visible = visible_;
+ total = total_;
label_filter_result->setText(tr("%1 of %n result(s)", "", total).arg(visible));
}
@@ -127,10 +126,8 @@ GameListSearchField::GameListSearchField(GameList* parent) : QWidget{parent} {
layout_filter = new QHBoxLayout;
layout_filter->setContentsMargins(8, 8, 8, 8);
label_filter = new QLabel;
- label_filter->setText(tr("Filter:"));
edit_filter = new QLineEdit;
edit_filter->clear();
- edit_filter->setPlaceholderText(tr("Enter pattern to filter"));
edit_filter->installEventFilter(key_release_eater);
edit_filter->setClearButtonEnabled(true);
connect(edit_filter, &QLineEdit::textChanged, parent, &GameList::OnTextChanged);
@@ -150,6 +147,7 @@ GameListSearchField::GameListSearchField(GameList* parent) : QWidget{parent} {
layout_filter->addWidget(label_filter_result);
layout_filter->addWidget(button_filter_close);
setLayout(layout_filter);
+ RetranslateUI();
}
/**
@@ -287,7 +285,7 @@ void GameList::OnUpdateThemedIcons() {
}
case GameListItemType::AddDir:
child->setData(
- QIcon::fromTheme(QStringLiteral("plus"))
+ QIcon::fromTheme(QStringLiteral("list-add"))
.pixmap(icon_size)
.scaled(icon_size, icon_size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation),
Qt::DecorationRole);
@@ -309,9 +307,9 @@ void GameList::OnFilterCloseClicked() {
main_window->filterBarSetChecked(false);
}
-GameList::GameList(FileSys::VirtualFilesystem vfs, FileSys::ManualContentProvider* provider,
+GameList::GameList(FileSys::VirtualFilesystem vfs_, FileSys::ManualContentProvider* provider_,
Core::System& system_, GMainWindow* parent)
- : QWidget{parent}, vfs(std::move(vfs)), provider(provider), system{system_} {
+ : QWidget{parent}, vfs{std::move(vfs_)}, provider{provider_}, system{system_} {
watcher = new QFileSystemWatcher(this);
connect(watcher, &QFileSystemWatcher::directoryChanged, this, &GameList::RefreshGameDirectory);
@@ -334,13 +332,9 @@ GameList::GameList(FileSys::VirtualFilesystem vfs, FileSys::ManualContentProvide
tree_view->setStyleSheet(QStringLiteral("QTreeView{ border: none; }"));
item_model->insertColumns(0, COLUMN_COUNT);
- item_model->setHeaderData(COLUMN_NAME, Qt::Horizontal, tr("Name"));
- item_model->setHeaderData(COLUMN_COMPATIBILITY, Qt::Horizontal, tr("Compatibility"));
+ RetranslateUI();
- item_model->setHeaderData(COLUMN_ADD_ONS, Qt::Horizontal, tr("Add-ons"));
tree_view->setColumnHidden(COLUMN_ADD_ONS, !UISettings::values.show_add_ons);
- item_model->setHeaderData(COLUMN_FILE_TYPE, Qt::Horizontal, tr("File type"));
- item_model->setHeaderData(COLUMN_SIZE, Qt::Horizontal, tr("Size"));
item_model->setSortRole(GameListItemPath::SortRole);
connect(main_window, &GMainWindow::UpdateThemedIcons, this, &GameList::OnUpdateThemedIcons);
@@ -483,7 +477,7 @@ void GameList::DonePopulating(const QStringList& watch_list) {
// Also artificially caps the watcher to a certain number of directories
constexpr int LIMIT_WATCH_DIRECTORIES = 5000;
constexpr int SLICE_SIZE = 25;
- int len = std::min(watch_list.length(), LIMIT_WATCH_DIRECTORIES);
+ int len = std::min(static_cast<int>(watch_list.size()), LIMIT_WATCH_DIRECTORIES);
for (int i = 0; i < len; i += SLICE_SIZE) {
watcher->addPaths(watch_list.mid(i, i + SLICE_SIZE));
QCoreApplication::processEvents();
@@ -499,6 +493,8 @@ void GameList::DonePopulating(const QStringList& watch_list) {
}
item_model->sort(tree_view->header()->sortIndicatorSection(),
tree_view->header()->sortIndicatorOrder());
+
+ emit PopulatingCompleted();
}
void GameList::PopupContextMenu(const QPoint& menu_location) {
@@ -752,6 +748,39 @@ void GameList::LoadCompatibilityList() {
}
}
+void GameList::changeEvent(QEvent* event) {
+ if (event->type() == QEvent::LanguageChange) {
+ RetranslateUI();
+ }
+
+ QWidget::changeEvent(event);
+}
+
+void GameList::RetranslateUI() {
+ item_model->setHeaderData(COLUMN_NAME, Qt::Horizontal, tr("Name"));
+ item_model->setHeaderData(COLUMN_COMPATIBILITY, Qt::Horizontal, tr("Compatibility"));
+ item_model->setHeaderData(COLUMN_ADD_ONS, Qt::Horizontal, tr("Add-ons"));
+ item_model->setHeaderData(COLUMN_FILE_TYPE, Qt::Horizontal, tr("File type"));
+ item_model->setHeaderData(COLUMN_SIZE, Qt::Horizontal, tr("Size"));
+}
+
+void GameListSearchField::changeEvent(QEvent* event) {
+ if (event->type() == QEvent::LanguageChange) {
+ RetranslateUI();
+ }
+
+ QWidget::changeEvent(event);
+}
+
+void GameListSearchField::RetranslateUI() {
+ label_filter->setText(tr("Filter:"));
+ edit_filter->setPlaceholderText(tr("Enter pattern to filter"));
+}
+
+QStandardItemModel* GameList::GetModel() const {
+ return item_model;
+}
+
void GameList::PopulateAsync(QVector<UISettings::GameDir>& game_dirs) {
tree_view->setEnabled(false);
@@ -870,7 +899,7 @@ GameListPlaceholder::GameListPlaceholder(GMainWindow* parent) : QWidget{parent}
layout->setAlignment(Qt::AlignCenter);
image->setPixmap(QIcon::fromTheme(QStringLiteral("plus_folder")).pixmap(200));
- text->setText(tr("Double-click to add a new folder to the game list"));
+ RetranslateUI();
QFont font = text->font();
font.setPointSize(20);
text->setFont(font);
@@ -891,3 +920,15 @@ void GameListPlaceholder::onUpdateThemedIcons() {
void GameListPlaceholder::mouseDoubleClickEvent(QMouseEvent* event) {
emit GameListPlaceholder::AddDirectory();
}
+
+void GameListPlaceholder::changeEvent(QEvent* event) {
+ if (event->type() == QEvent::LanguageChange) {
+ RetranslateUI();
+ }
+
+ QWidget::changeEvent(event);
+}
+
+void GameListPlaceholder::RetranslateUI() {
+ text->setText(tr("Double-click to add a new folder to the game list"));
+}
diff --git a/src/yuzu/game_list.h b/src/yuzu/game_list.h
index a94ea1477..cdf085019 100644
--- a/src/yuzu/game_list.h
+++ b/src/yuzu/game_list.h
@@ -1,29 +1,28 @@
-// Copyright 2015 Citra Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: 2015 Citra Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include <QFileSystemWatcher>
-#include <QHBoxLayout>
#include <QLabel>
#include <QLineEdit>
#include <QList>
-#include <QModelIndex>
-#include <QSettings>
-#include <QStandardItem>
#include <QStandardItemModel>
#include <QString>
-#include <QToolButton>
#include <QTreeView>
#include <QVBoxLayout>
#include <QVector>
#include <QWidget>
#include "common/common_types.h"
+#include "core/core.h"
#include "uisettings.h"
#include "yuzu/compatibility_list.h"
+namespace Core {
+class System;
+}
+
class ControllerNavigation;
class GameListWorker;
class GameListSearchField;
@@ -72,8 +71,8 @@ public:
COLUMN_COUNT, // Number of columns
};
- explicit GameList(std::shared_ptr<FileSys::VfsFilesystem> vfs,
- FileSys::ManualContentProvider* provider, Core::System& system_,
+ explicit GameList(std::shared_ptr<FileSys::VfsFilesystem> vfs_,
+ FileSys::ManualContentProvider* provider_, Core::System& system_,
GMainWindow* parent = nullptr);
~GameList() override;
@@ -89,6 +88,8 @@ public:
void SaveInterfaceLayout();
void LoadInterfaceLayout();
+ QStandardItemModel* GetModel() const;
+
/// Disables events from the emulated controller
void UnloadController();
@@ -113,6 +114,7 @@ signals:
void OpenDirectory(const QString& directory);
void AddDirectory();
void ShowList(bool show);
+ void PopulatingCompleted();
private slots:
void OnItemExpanded(const QModelIndex& item);
@@ -138,6 +140,9 @@ private:
void AddPermDirPopup(QMenu& context_menu, QModelIndex selected);
void AddFavoritesPopup(QMenu& context_menu);
+ void changeEvent(QEvent*) override;
+ void RetranslateUI();
+
std::shared_ptr<FileSys::VfsFilesystem> vfs;
FileSys::ManualContentProvider* provider;
GameListSearchField* search_field;
@@ -171,6 +176,9 @@ protected:
void mouseDoubleClickEvent(QMouseEvent* event) override;
private:
+ void changeEvent(QEvent* event) override;
+ void RetranslateUI();
+
QVBoxLayout* layout = nullptr;
QLabel* image = nullptr;
QLabel* text = nullptr;
diff --git a/src/yuzu/game_list_p.h b/src/yuzu/game_list_p.h
index 9dc3cc7c3..6198d1e4e 100644
--- a/src/yuzu/game_list_p.h
+++ b/src/yuzu/game_list_p.h
@@ -1,6 +1,5 @@
-// Copyright 2015 Citra Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: 2015 Citra Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
@@ -11,7 +10,6 @@
#include <QCoreApplication>
#include <QFileInfo>
-#include <QImage>
#include <QObject>
#include <QStandardItem>
#include <QString>
@@ -165,8 +163,8 @@ public:
}
const CompatStatus& status = iterator->second;
setData(compatibility, CompatNumberRole);
- setText(QObject::tr(status.text));
- setToolTip(QObject::tr(status.tooltip));
+ setText(tr(status.text));
+ setToolTip(tr(status.tooltip));
setData(CreateCirclePixmapFromColor(status.color), Qt::DecorationRole);
}
@@ -226,8 +224,8 @@ public:
static constexpr int GameDirRole = Qt::UserRole + 2;
explicit GameListDir(UISettings::GameDir& directory,
- GameListItemType dir_type = GameListItemType::CustomDir)
- : dir_type{dir_type} {
+ GameListItemType dir_type_ = GameListItemType::CustomDir)
+ : dir_type{dir_type_} {
setData(type(), TypeRole);
UISettings::GameDir* game_dir = &directory;
@@ -296,7 +294,7 @@ public:
const int icon_size = UISettings::values.folder_icon_size.GetValue();
- setData(QIcon::fromTheme(QStringLiteral("plus"))
+ setData(QIcon::fromTheme(QStringLiteral("list-add"))
.pixmap(icon_size)
.scaled(icon_size, icon_size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation),
Qt::DecorationRole);
@@ -349,15 +347,18 @@ public:
explicit GameListSearchField(GameList* parent = nullptr);
QString filterText() const;
- void setFilterResult(int visible, int total);
+ void setFilterResult(int visible_, int total_);
void clear();
void setFocus();
private:
+ void changeEvent(QEvent*) override;
+ void RetranslateUI();
+
class KeyReleaseEater : public QObject {
public:
- explicit KeyReleaseEater(GameList* gamelist, QObject* parent = nullptr);
+ explicit KeyReleaseEater(GameList* gamelist_, QObject* parent = nullptr);
private:
GameList* gamelist = nullptr;
diff --git a/src/yuzu/game_list_worker.cpp b/src/yuzu/game_list_worker.cpp
index fd92b36df..63326968b 100644
--- a/src/yuzu/game_list_worker.cpp
+++ b/src/yuzu/game_list_worker.cpp
@@ -1,6 +1,5 @@
-// Copyright 2018 yuzu emulator team
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#include <memory>
#include <string>
@@ -23,7 +22,6 @@
#include "core/file_sys/patch_manager.h"
#include "core/file_sys/registered_cache.h"
#include "core/file_sys/submission_package.h"
-#include "core/hle/service/filesystem/filesystem.h"
#include "core/loader/loader.h"
#include "yuzu/compatibility_list.h"
#include "yuzu/game_list.h"
@@ -225,12 +223,12 @@ QList<QStandardItem*> MakeGameListEntry(const std::string& path, const std::stri
}
} // Anonymous namespace
-GameListWorker::GameListWorker(FileSys::VirtualFilesystem vfs,
- FileSys::ManualContentProvider* provider,
- QVector<UISettings::GameDir>& game_dirs,
- const CompatibilityList& compatibility_list, Core::System& system_)
- : vfs(std::move(vfs)), provider(provider), game_dirs(game_dirs),
- compatibility_list(compatibility_list), system{system_} {}
+GameListWorker::GameListWorker(FileSys::VirtualFilesystem vfs_,
+ FileSys::ManualContentProvider* provider_,
+ QVector<UISettings::GameDir>& game_dirs_,
+ const CompatibilityList& compatibility_list_, Core::System& system_)
+ : vfs{std::move(vfs_)}, provider{provider_}, game_dirs{game_dirs_},
+ compatibility_list{compatibility_list_}, system{system_} {}
GameListWorker::~GameListWorker() = default;
diff --git a/src/yuzu/game_list_worker.h b/src/yuzu/game_list_worker.h
index 1383e9fbc..24a4e92c3 100644
--- a/src/yuzu/game_list_worker.h
+++ b/src/yuzu/game_list_worker.h
@@ -1,22 +1,17 @@
-// Copyright 2018 yuzu emulator team
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include <atomic>
-#include <map>
#include <memory>
#include <string>
-#include <unordered_map>
#include <QList>
#include <QObject>
#include <QRunnable>
#include <QString>
-#include <QVector>
-#include "common/common_types.h"
#include "yuzu/compatibility_list.h"
namespace Core {
@@ -38,10 +33,10 @@ class GameListWorker : public QObject, public QRunnable {
Q_OBJECT
public:
- explicit GameListWorker(std::shared_ptr<FileSys::VfsFilesystem> vfs,
- FileSys::ManualContentProvider* provider,
- QVector<UISettings::GameDir>& game_dirs,
- const CompatibilityList& compatibility_list, Core::System& system_);
+ explicit GameListWorker(std::shared_ptr<FileSys::VfsFilesystem> vfs_,
+ FileSys::ManualContentProvider* provider_,
+ QVector<UISettings::GameDir>& game_dirs_,
+ const CompatibilityList& compatibility_list_, Core::System& system_);
~GameListWorker() override;
/// Starts the processing of directory tree information.
diff --git a/src/yuzu/hotkeys.cpp b/src/yuzu/hotkeys.cpp
index 6ed9611c7..13723f6e5 100644
--- a/src/yuzu/hotkeys.cpp
+++ b/src/yuzu/hotkeys.cpp
@@ -1,9 +1,7 @@
-// Copyright 2014 Citra Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: 2014 Citra Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#include <sstream>
-#include <QKeySequence>
#include <QShortcut>
#include <QTreeWidgetItem>
#include <QtGlobal>
diff --git a/src/yuzu/hotkeys.h b/src/yuzu/hotkeys.h
index 57a7c7da5..dc5b7f628 100644
--- a/src/yuzu/hotkeys.h
+++ b/src/yuzu/hotkeys.h
@@ -1,6 +1,5 @@
-// Copyright 2014 Citra Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: 2014 Citra Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
diff --git a/src/yuzu/install_dialog.cpp b/src/yuzu/install_dialog.cpp
index 06b0b1874..84ec4fe13 100644
--- a/src/yuzu/install_dialog.cpp
+++ b/src/yuzu/install_dialog.cpp
@@ -1,11 +1,9 @@
-// Copyright 2020 yuzu Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#include <QCheckBox>
#include <QDialogButtonBox>
#include <QFileInfo>
-#include <QHBoxLayout>
#include <QLabel>
#include <QListWidget>
#include <QVBoxLayout>
diff --git a/src/yuzu/install_dialog.h b/src/yuzu/install_dialog.h
index 68e03fe4e..4c7c3c158 100644
--- a/src/yuzu/install_dialog.h
+++ b/src/yuzu/install_dialog.h
@@ -1,6 +1,5 @@
-// Copyright 2020 yuzu Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
diff --git a/src/yuzu/loading_screen.cpp b/src/yuzu/loading_screen.cpp
index b001b8c23..e263a07a7 100644
--- a/src/yuzu/loading_screen.cpp
+++ b/src/yuzu/loading_screen.cpp
@@ -1,24 +1,16 @@
-// Copyright 2019 yuzu Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#include <unordered_map>
#include <QBuffer>
#include <QByteArray>
#include <QGraphicsOpacityEffect>
-#include <QHBoxLayout>
#include <QIODevice>
#include <QImage>
-#include <QLabel>
#include <QPainter>
-#include <QPalette>
#include <QPixmap>
-#include <QProgressBar>
#include <QPropertyAnimation>
#include <QStyleOption>
-#include <QTime>
-#include <QtConcurrent/QtConcurrentRun>
-#include "common/logging/log.h"
#include "core/frontend/framebuffer_layout.h"
#include "core/loader/loader.h"
#include "ui_loading_screen.h"
@@ -155,6 +147,10 @@ void LoadingScreen::OnLoadProgress(VideoCore::LoadCallbackStage stage, std::size
ui->progress_bar->setMaximum(static_cast<int>(total));
previous_total = total;
}
+ // Reset the progress bar ranges if compilation is done
+ if (stage == VideoCore::LoadCallbackStage::Complete) {
+ ui->progress_bar->setRange(0, 0);
+ }
QString estimate;
// If theres a drastic slowdown in the rate, then display an estimate
@@ -191,7 +187,7 @@ void LoadingScreen::OnLoadProgress(VideoCore::LoadCallbackStage stage, std::size
void LoadingScreen::paintEvent(QPaintEvent* event) {
QStyleOption opt;
- opt.init(this);
+ opt.initFrom(this);
QPainter p(this);
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
QWidget::paintEvent(event);
diff --git a/src/yuzu/loading_screen.h b/src/yuzu/loading_screen.h
index 29155a77c..17045595d 100644
--- a/src/yuzu/loading_screen.h
+++ b/src/yuzu/loading_screen.h
@@ -1,6 +1,5 @@
-// Copyright 2019 yuzu Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
@@ -8,6 +7,7 @@
#include <memory>
#include <QString>
#include <QWidget>
+#include <QtGlobal>
#if !QT_CONFIG(movie)
#define YUZU_QT_MOVIE_MISSING 1
@@ -89,4 +89,6 @@ private:
std::size_t slow_shader_first_value = 0;
};
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
Q_DECLARE_METATYPE(VideoCore::LoadCallbackStage);
+#endif
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp
index 3c2d7d080..4146ebc2c 100644
--- a/src/yuzu/main.cpp
+++ b/src/yuzu/main.cpp
@@ -1,14 +1,18 @@
-// Copyright 2014 Citra Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: 2014 Citra Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#include <cinttypes>
#include <clocale>
+#include <cmath>
#include <memory>
#include <thread>
#ifdef __APPLE__
#include <unistd.h> // for chdir
#endif
+#ifdef __linux__
+#include <csignal>
+#include <sys/socket.h>
+#endif
// VFS includes must be before glad as they will conflict with Windows file api, which uses defines.
#include "applets/qt_controller.h"
@@ -20,11 +24,11 @@
#include "configuration/configure_input.h"
#include "configuration/configure_per_game.h"
#include "configuration/configure_tas.h"
-#include "configuration/configure_vibration.h"
#include "core/file_sys/vfs.h"
#include "core/file_sys/vfs_real.h"
#include "core/frontend/applets/controller.h"
#include "core/frontend/applets/general_frontend.h"
+#include "core/frontend/applets/mii_edit.h"
#include "core/frontend/applets/software_keyboard.h"
#include "core/hid/emulated_controller.h"
#include "core/hid/hid_core.h"
@@ -32,6 +36,7 @@
#include "core/hle/service/am/applet_ae.h"
#include "core/hle/service/am/applet_oe.h"
#include "core/hle/service/am/applets/applets.h"
+#include "yuzu/multiplayer/state.h"
#include "yuzu/util/controller_navigation.h"
// These are wrappers to avoid the calls to CreateDirectory and CreateFile because of the Windows
@@ -52,9 +57,6 @@ static FileSys::VirtualFile VfsDirectoryCreateFileWrapper(const FileSys::Virtual
#define QT_NO_OPENGL
#include <QClipboard>
#include <QDesktopServices>
-#include <QDesktopWidget>
-#include <QDialogButtonBox>
-#include <QDir>
#include <QFile>
#include <QFileDialog>
#include <QInputDialog>
@@ -62,6 +64,7 @@ static FileSys::VirtualFile VfsDirectoryCreateFileWrapper(const FileSys::Virtual
#include <QProgressBar>
#include <QProgressDialog>
#include <QPushButton>
+#include <QScreen>
#include <QShortcut>
#include <QStatusBar>
#include <QString>
@@ -76,11 +79,9 @@ static FileSys::VirtualFile VfsDirectoryCreateFileWrapper(const FileSys::Virtual
#include <fmt/format.h>
#include "common/detached_tasks.h"
#include "common/fs/fs.h"
-#include "common/fs/fs_paths.h"
#include "common/fs/path_util.h"
#include "common/literals.h"
#include "common/logging/backend.h"
-#include "common/logging/filter.h"
#include "common/logging/log.h"
#include "common/memory_detect.h"
#include "common/microprofile.h"
@@ -105,12 +106,12 @@ static FileSys::VirtualFile VfsDirectoryCreateFileWrapper(const FileSys::Virtual
#include "core/hle/kernel/k_process.h"
#include "core/hle/service/am/am.h"
#include "core/hle/service/filesystem/filesystem.h"
-#include "core/hle/service/nfp/nfp.h"
#include "core/hle/service/sm/sm.h"
#include "core/loader/loader.h"
#include "core/perf_stats.h"
#include "core/telemetry_session.h"
#include "input_common/drivers/tas_input.h"
+#include "input_common/drivers/virtual_amiibo.h"
#include "input_common/main.h"
#include "ui_main.h"
#include "util/overlay_dialog.h"
@@ -134,7 +135,13 @@ static FileSys::VirtualFile VfsDirectoryCreateFileWrapper(const FileSys::Virtual
#include "yuzu/install_dialog.h"
#include "yuzu/loading_screen.h"
#include "yuzu/main.h"
+#include "yuzu/startup_checks.h"
#include "yuzu/uisettings.h"
+#include "yuzu/util/clickable_label.h"
+
+#ifdef YUZU_DBGHELP
+#include "yuzu/mini_dump.h"
+#endif
using namespace Common::Literals;
@@ -156,7 +163,8 @@ __declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;
}
#endif
-constexpr int default_mouse_timeout = 2500;
+constexpr int default_mouse_hide_timeout = 2500;
+constexpr int default_mouse_center_timeout = 10;
/**
* "Callouts" are one-time instructional messages shown to the user. In the config settings, there
@@ -201,12 +209,80 @@ static void RemoveCachedContents() {
Common::FS::RemoveDirRecursively(offline_system_data);
}
-GMainWindow::GMainWindow()
+static void LogRuntimes() {
+#ifdef _MSC_VER
+ // It is possible that the name of the dll will change.
+ // vcruntime140.dll is for 2015 and onwards
+ constexpr char runtime_dll_name[] = "vcruntime140.dll";
+ UINT sz = GetFileVersionInfoSizeA(runtime_dll_name, nullptr);
+ bool runtime_version_inspection_worked = false;
+ if (sz > 0) {
+ std::vector<u8> buf(sz);
+ if (GetFileVersionInfoA(runtime_dll_name, 0, sz, buf.data())) {
+ VS_FIXEDFILEINFO* pvi;
+ sz = sizeof(VS_FIXEDFILEINFO);
+ if (VerQueryValueA(buf.data(), "\\", reinterpret_cast<LPVOID*>(&pvi), &sz)) {
+ if (pvi->dwSignature == VS_FFI_SIGNATURE) {
+ runtime_version_inspection_worked = true;
+ LOG_INFO(Frontend, "MSVC Compiler: {} Runtime: {}.{}.{}.{}", _MSC_VER,
+ pvi->dwProductVersionMS >> 16, pvi->dwProductVersionMS & 0xFFFF,
+ pvi->dwProductVersionLS >> 16, pvi->dwProductVersionLS & 0xFFFF);
+ }
+ }
+ }
+ }
+ if (!runtime_version_inspection_worked) {
+ LOG_INFO(Frontend, "Unable to inspect {}", runtime_dll_name);
+ }
+#endif
+}
+
+static QString PrettyProductName() {
+#ifdef _WIN32
+ // After Windows 10 Version 2004, Microsoft decided to switch to a different notation: 20H2
+ // With that notation change they changed the registry key used to denote the current version
+ QSettings windows_registry(
+ QStringLiteral("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"),
+ QSettings::NativeFormat);
+ const QString release_id = windows_registry.value(QStringLiteral("ReleaseId")).toString();
+ if (release_id == QStringLiteral("2009")) {
+ const u32 current_build = windows_registry.value(QStringLiteral("CurrentBuild")).toUInt();
+ const QString display_version =
+ windows_registry.value(QStringLiteral("DisplayVersion")).toString();
+ const u32 ubr = windows_registry.value(QStringLiteral("UBR")).toUInt();
+ u32 version = 10;
+ if (current_build >= 22000) {
+ version = 11;
+ }
+ return QStringLiteral("Windows %1 Version %2 (Build %3.%4)")
+ .arg(QString::number(version), display_version, QString::number(current_build),
+ QString::number(ubr));
+ }
+#endif
+ return QSysInfo::prettyProductName();
+}
+
+bool GMainWindow::CheckDarkMode() {
+#ifdef __linux__
+ const QPalette test_palette(qApp->palette());
+ const QColor text_color = test_palette.color(QPalette::Active, QPalette::Text);
+ const QColor window_color = test_palette.color(QPalette::Active, QPalette::Window);
+ return (text_color.value() > window_color.value());
+#else
+ // TODO: Windows
+ return false;
+#endif // __linux__
+}
+
+GMainWindow::GMainWindow(std::unique_ptr<Config> config_, bool has_broken_vulkan)
: ui{std::make_unique<Ui::MainWindow>()}, system{std::make_unique<Core::System>()},
- input_subsystem{std::make_shared<InputCommon::InputSubsystem>()},
- config{std::make_unique<Config>(*system)},
+ input_subsystem{std::make_shared<InputCommon::InputSubsystem>()}, config{std::move(config_)},
vfs{std::make_shared<FileSys::RealVfsFilesystem>()},
provider{std::make_unique<FileSys::ManualContentProvider>()} {
+#ifdef __linux__
+ SetupSigInterrupts();
+#endif
+
Common::Log::Initialize();
LoadTranslation();
@@ -214,12 +290,21 @@ GMainWindow::GMainWindow()
ui->setupUi(this);
statusBar()->hide();
+ // Check dark mode before a theme is loaded
+ os_dark_mode = CheckDarkMode();
+ startup_icon_theme = QIcon::themeName();
+ // fallback can only be set once, colorful theme icons are okay on both light/dark
+ QIcon::setFallbackThemeName(QStringLiteral("colorful"));
+ QIcon::setFallbackSearchPaths(QStringList(QStringLiteral(":/icons")));
+
default_theme_paths = QIcon::themeSearchPaths();
UpdateUITheme();
SetDiscordEnabled(UISettings::values.enable_discord_presence.GetValue());
discord_rpc->Update();
+ system->GetRoomNetwork().Init();
+
RegisterMetaTypes();
InitializeWidgets();
@@ -246,12 +331,13 @@ GMainWindow::GMainWindow()
const auto yuzu_build_version = override_build.empty() ? yuzu_build : override_build;
LOG_INFO(Frontend, "yuzu Version: {}", yuzu_build_version);
+ LogRuntimes();
#ifdef ARCHITECTURE_x86_64
const auto& caps = Common::GetCPUCaps();
std::string cpu_string = caps.cpu_string;
- if (caps.avx || caps.avx2 || caps.avx512) {
+ if (caps.avx || caps.avx2 || caps.avx512f) {
cpu_string += " | AVX";
- if (caps.avx512) {
+ if (caps.avx512f) {
cpu_string += "512";
} else if (caps.avx2) {
cpu_string += '2';
@@ -262,7 +348,7 @@ GMainWindow::GMainWindow()
}
LOG_INFO(Frontend, "Host CPU: {}", cpu_string);
#endif
- LOG_INFO(Frontend, "Host OS: {}", QSysInfo::prettyProductName().toStdString());
+ LOG_INFO(Frontend, "Host OS: {}", PrettyProductName().toStdString());
LOG_INFO(Frontend, "Host RAM: {:.2f} GiB",
Common::GetMemInfo().TotalPhysicalMemory / f64{1_GiB});
LOG_INFO(Frontend, "Host Swap: {:.2f} GiB", Common::GetMemInfo().TotalSwapMemory / f64{1_GiB});
@@ -291,13 +377,29 @@ GMainWindow::GMainWindow()
ui->menubar->setCursor(QCursor());
statusBar()->setCursor(QCursor());
- mouse_hide_timer.setInterval(default_mouse_timeout);
+ mouse_hide_timer.setInterval(default_mouse_hide_timeout);
connect(&mouse_hide_timer, &QTimer::timeout, this, &GMainWindow::HideMouseCursor);
connect(ui->menubar, &QMenuBar::hovered, this, &GMainWindow::ShowMouseCursor);
+ mouse_center_timer.setInterval(default_mouse_center_timeout);
+ connect(&mouse_center_timer, &QTimer::timeout, this, &GMainWindow::CenterMouseCursor);
+
MigrateConfigFiles();
- ui->action_Fullscreen->setChecked(false);
+ if (has_broken_vulkan) {
+ UISettings::values.has_broken_vulkan = true;
+
+ QMessageBox::warning(this, tr("Broken Vulkan Installation Detected"),
+ tr("Vulkan initialization failed during boot.<br><br>Click <a "
+ "href='https://yuzu-emu.org/wiki/faq/"
+ "#yuzu-starts-with-the-error-broken-vulkan-installation-detected'>"
+ "here for instructions to fix the issue</a>."));
+
+ Settings::values.renderer_backend = Settings::RendererBackend::OpenGL;
+
+ renderer_status_button->setDisabled(true);
+ renderer_status_button->setChecked(false);
+ }
#if defined(HAVE_SDL2) && !defined(_WIN32)
SDL_InitSubSystem(SDL_INIT_VIDEO);
@@ -307,6 +409,8 @@ GMainWindow::GMainWindow()
SDL_EnableScreenSaver();
#endif
+ SetupPrepareForSleep();
+
Common::Log::Start();
QStringList args = QApplication::arguments();
@@ -316,17 +420,20 @@ GMainWindow::GMainWindow()
}
QString game_path;
+ bool has_gamepath = false;
+ bool is_fullscreen = false;
for (int i = 1; i < args.size(); ++i) {
// Preserves drag/drop functionality
if (args.size() == 2 && !args[1].startsWith(QChar::fromLatin1('-'))) {
game_path = args[1];
+ has_gamepath = true;
break;
}
// Launch game in fullscreen mode
if (args[i] == QStringLiteral("-f")) {
- ui->action_Fullscreen->setChecked(true);
+ is_fullscreen = true;
continue;
}
@@ -369,9 +476,15 @@ GMainWindow::GMainWindow()
}
game_path = args[++i];
+ has_gamepath = true;
}
}
+ // Override fullscreen setting if gamepath or argument is provided
+ if (has_gamepath || is_fullscreen) {
+ ui->action_Fullscreen->setChecked(is_fullscreen);
+ }
+
if (!game_path.isEmpty()) {
BootGame(game_path);
}
@@ -382,6 +495,11 @@ GMainWindow::~GMainWindow() {
if (render_window->parent() == nullptr) {
delete render_window;
}
+
+#ifdef __linux__
+ ::close(sig_interrupt_fds[0]);
+ ::close(sig_interrupt_fds[1]);
+#endif
}
void GMainWindow::RegisterMetaTypes() {
@@ -586,7 +704,7 @@ void GMainWindow::WebBrowserOpenWebPage(const std::string& main_url,
#ifdef YUZU_USE_QT_WEB_ENGINE
// Raw input breaks with the web applet, Disable web applets if enabled
- if (disable_web_applet || Settings::values.enable_raw_input) {
+ if (UISettings::values.disable_web_applet || Settings::values.enable_raw_input) {
emit WebBrowserClosed(Service::AM::Applets::WebExitReason::WindowClosed,
"http://localhost/");
return;
@@ -651,12 +769,12 @@ void GMainWindow::WebBrowserOpenWebPage(const std::string& main_url,
connect(exit_action, &QAction::triggered, this, [this, &web_browser_view] {
const auto result = QMessageBox::warning(
this, tr("Disable Web Applet"),
- tr("Disabling the web applet will cause it to not be shown again for the rest of the "
- "emulated session. This can lead to undefined behavior and should only be used with "
- "Super Mario 3D All-Stars. Are you sure you want to disable the web applet?"),
+ tr("Disabling the web applet can lead to undefined behavior and should only be used "
+ "with Super Mario 3D All-Stars. Are you sure you want to disable the web "
+ "applet?\n(This can be re-enabled in the Debug settings.)"),
QMessageBox::Yes | QMessageBox::No);
if (result == QMessageBox::Yes) {
- disable_web_applet = true;
+ UISettings::values.disable_web_applet = true;
web_browser_view.SetFinished(true);
}
});
@@ -745,6 +863,10 @@ void GMainWindow::InitializeWidgets() {
}
});
+ multiplayer_state = new MultiplayerState(this, game_list->GetModel(), ui->action_Leave_Room,
+ ui->action_Show_Room, *system);
+ multiplayer_state->setVisible(false);
+
// Create status bar
message_label = new QLabel();
// Configured separately for left alignment
@@ -777,6 +899,10 @@ void GMainWindow::InitializeWidgets() {
statusBar()->addPermanentWidget(label);
}
+ // TODO (flTobi): Add the widget when multiplayer is fully implemented
+ statusBar()->addPermanentWidget(multiplayer_state->GetStatusText(), 0);
+ statusBar()->addPermanentWidget(multiplayer_state->GetStatusIcon(), 0);
+
tas_label = new QLabel();
tas_label->setObjectName(QStringLiteral("TASlabel"));
tas_label->setFocusPolicy(Qt::NoFocus);
@@ -820,12 +946,11 @@ void GMainWindow::InitializeWidgets() {
// Setup Dock button
dock_status_button = new QPushButton();
- dock_status_button->setObjectName(QStringLiteral("TogglableStatusBarButton"));
+ dock_status_button->setObjectName(QStringLiteral("DockingStatusBarButton"));
dock_status_button->setFocusPolicy(Qt::NoFocus);
connect(dock_status_button, &QPushButton::clicked, this, &GMainWindow::OnToggleDockedMode);
- dock_status_button->setText(tr("DOCK"));
dock_status_button->setCheckable(true);
- dock_status_button->setChecked(Settings::values.use_docked_mode.GetValue());
+ UpdateDockedButton();
statusBar()->insertPermanentWidget(0, dock_status_button);
gpu_accuracy_button = new QPushButton();
@@ -856,8 +981,7 @@ void GMainWindow::InitializeWidgets() {
Settings::values.renderer_backend.SetValue(Settings::RendererBackend::Vulkan);
} else {
Settings::values.renderer_backend.SetValue(Settings::RendererBackend::OpenGL);
- const auto filter = Settings::values.scaling_filter.GetValue();
- if (filter == Settings::ScalingFilter::Fsr) {
+ if (Settings::values.scaling_filter.GetValue() == Settings::ScalingFilter::Fsr) {
Settings::values.scaling_filter.SetValue(Settings::ScalingFilter::NearestNeighbor);
UpdateFilterText();
}
@@ -926,15 +1050,16 @@ void GMainWindow::LinkActionShortcut(QAction* action, const QString& action_name
auto* controller = system->HIDCore().GetEmulatedController(Core::HID::NpadIdType::Player1);
const auto* controller_hotkey =
hotkey_registry.GetControllerHotkey(main_window, action_name, controller);
- connect(controller_hotkey, &ControllerShortcut::Activated, this,
- [action] { action->trigger(); });
+ connect(
+ controller_hotkey, &ControllerShortcut::Activated, this, [action] { action->trigger(); },
+ Qt::QueuedConnection);
}
void GMainWindow::InitializeHotkeys() {
hotkey_registry.LoadHotkeys();
LinkActionShortcut(ui->action_Load_File, QStringLiteral("Load File"));
- LinkActionShortcut(ui->action_Load_Amiibo, QStringLiteral("Load Amiibo"));
+ LinkActionShortcut(ui->action_Load_Amiibo, QStringLiteral("Load/Remove Amiibo"));
LinkActionShortcut(ui->action_Exit, QStringLiteral("Exit yuzu"));
LinkActionShortcut(ui->action_Restart, QStringLiteral("Restart Emulation"));
LinkActionShortcut(ui->action_Pause, QStringLiteral("Continue/Pause Emulation"));
@@ -954,7 +1079,8 @@ void GMainWindow::InitializeHotkeys() {
const auto* controller_hotkey =
hotkey_registry.GetControllerHotkey(main_window, action_name, controller);
connect(hotkey, &QShortcut::activated, this, function);
- connect(controller_hotkey, &ControllerShortcut::Activated, this, function);
+ connect(controller_hotkey, &ControllerShortcut::Activated, this, function,
+ Qt::QueuedConnection);
};
connect_shortcut(QStringLiteral("Exit Fullscreen"), [&] {
@@ -970,17 +1096,29 @@ void GMainWindow::InitializeHotkeys() {
connect_shortcut(QStringLiteral("Audio Mute/Unmute"),
[] { Settings::values.audio_muted = !Settings::values.audio_muted; });
connect_shortcut(QStringLiteral("Audio Volume Down"), [] {
- const auto current_volume = static_cast<int>(Settings::values.volume.GetValue());
- const auto new_volume = std::max(current_volume - 5, 0);
- Settings::values.volume.SetValue(static_cast<u8>(new_volume));
+ const auto current_volume = static_cast<s32>(Settings::values.volume.GetValue());
+ int step = 5;
+ if (current_volume <= 30) {
+ step = 2;
+ }
+ if (current_volume <= 6) {
+ step = 1;
+ }
+ Settings::values.volume.SetValue(std::max(current_volume - step, 0));
});
connect_shortcut(QStringLiteral("Audio Volume Up"), [] {
- const auto current_volume = static_cast<int>(Settings::values.volume.GetValue());
- const auto new_volume = std::min(current_volume + 5, 100);
- Settings::values.volume.SetValue(static_cast<u8>(new_volume));
+ const auto current_volume = static_cast<s32>(Settings::values.volume.GetValue());
+ int step = 5;
+ if (current_volume < 30) {
+ step = 2;
+ }
+ if (current_volume < 6) {
+ step = 1;
+ }
+ Settings::values.volume.SetValue(current_volume + step);
});
connect_shortcut(QStringLiteral("Toggle Framerate Limit"), [] {
- Settings::values.disable_fps_limit.SetValue(!Settings::values.disable_fps_limit.GetValue());
+ Settings::values.use_speed_limit.SetValue(!Settings::values.use_speed_limit.GetValue());
});
connect_shortcut(QStringLiteral("Toggle Mouse Panning"), [&] {
Settings::values.mouse_panning = !Settings::values.mouse_panning;
@@ -993,7 +1131,7 @@ void GMainWindow::InitializeHotkeys() {
void GMainWindow::SetDefaultUIGeometry() {
// geometry: 53% of the window contents are in the upper screen half, 47% in the lower half
- const QRect screenRect = QApplication::desktop()->screenGeometry(this);
+ const QRect screenRect = QGuiApplication::primaryScreen()->geometry();
const int w = screenRect.width() * 2 / 3;
const int h = screenRect.height() * 2 / 3;
@@ -1006,6 +1144,10 @@ void GMainWindow::SetDefaultUIGeometry() {
void GMainWindow::RestoreUIState() {
setWindowFlags(windowFlags() & ~Qt::FramelessWindowHint);
restoreGeometry(UISettings::values.geometry);
+ // Work-around because the games list isn't supposed to be full screen
+ if (isFullScreen()) {
+ showNormal();
+ }
restoreState(UISettings::values.state);
render_window->setWindowFlags(render_window->windowFlags() & ~Qt::FramelessWindowHint);
render_window->restoreGeometry(UISettings::values.renderwindow_geometry);
@@ -1048,6 +1190,7 @@ void GMainWindow::OnAppFocusStateChanged(Qt::ApplicationState state) {
OnPauseGame();
} else if (!emu_thread->IsRunning() && auto_paused && state == Qt::ApplicationActive) {
auto_paused = false;
+ RequestGameResume();
OnStartGame();
}
}
@@ -1081,6 +1224,8 @@ void GMainWindow::ConnectWidgetEvents() {
connect(game_list_placeholder, &GameListPlaceholder::AddDirectory, this,
&GMainWindow::OnGameListAddDirectory);
connect(game_list, &GameList::ShowList, this, &GMainWindow::OnGameListShowList);
+ connect(game_list, &GameList::PopulatingCompleted,
+ [this] { multiplayer_state->UpdateGameList(game_list->GetModel()); });
connect(game_list, &GameList::OpenPerGameGeneralRequested, this,
&GMainWindow::OnGameListOpenPerGameProperties);
@@ -1098,6 +1243,9 @@ void GMainWindow::ConnectWidgetEvents() {
connect(this, &GMainWindow::EmulationStopping, this, &GMainWindow::SoftwareKeyboardExit);
connect(&status_bar_update_timer, &QTimer::timeout, this, &GMainWindow::UpdateStatusBar);
+
+ connect(this, &GMainWindow::UpdateThemedIcons, multiplayer_state,
+ &MultiplayerState::UpdateThemedIcons);
}
void GMainWindow::ConnectMenuEvents() {
@@ -1141,6 +1289,19 @@ void GMainWindow::ConnectMenuEvents() {
ui->action_Reset_Window_Size_900,
ui->action_Reset_Window_Size_1080});
+ // Multiplayer
+ connect(ui->action_View_Lobby, &QAction::triggered, multiplayer_state,
+ &MultiplayerState::OnViewLobby);
+ connect(ui->action_Start_Room, &QAction::triggered, multiplayer_state,
+ &MultiplayerState::OnCreateRoom);
+ connect(ui->action_Leave_Room, &QAction::triggered, multiplayer_state,
+ &MultiplayerState::OnCloseRoom);
+ connect(ui->action_Connect_To_Room, &QAction::triggered, multiplayer_state,
+ &MultiplayerState::OnDirectConnectToRoom);
+ connect(ui->action_Show_Room, &QAction::triggered, multiplayer_state,
+ &MultiplayerState::OnOpenNetworkRoom);
+ connect(multiplayer_state, &MultiplayerState::SaveConfig, this, &GMainWindow::OnSaveConfig);
+
// Tools
connect_menu(ui->action_Rederive, std::bind(&GMainWindow::OnReinitializeKeys, this,
ReinitializeKeyBehavior::Warning));
@@ -1180,6 +1341,8 @@ void GMainWindow::UpdateMenuState() {
} else {
ui->action_Pause->setText(tr("&Pause"));
}
+
+ multiplayer_state->UpdateNotificationStatus();
}
void GMainWindow::OnDisplayTitleBars(bool show) {
@@ -1202,6 +1365,43 @@ void GMainWindow::OnDisplayTitleBars(bool show) {
}
}
+void GMainWindow::SetupPrepareForSleep() {
+#ifdef __linux__
+ auto bus = QDBusConnection::systemBus();
+ if (bus.isConnected()) {
+ const bool success = bus.connect(
+ QStringLiteral("org.freedesktop.login1"), QStringLiteral("/org/freedesktop/login1"),
+ QStringLiteral("org.freedesktop.login1.Manager"), QStringLiteral("PrepareForSleep"),
+ QStringLiteral("b"), this, SLOT(OnPrepareForSleep(bool)));
+
+ if (!success) {
+ LOG_WARNING(Frontend, "Couldn't register PrepareForSleep signal");
+ }
+ } else {
+ LOG_WARNING(Frontend, "QDBusConnection system bus is not connected");
+ }
+#endif // __linux__
+}
+
+void GMainWindow::OnPrepareForSleep(bool prepare_sleep) {
+ if (emu_thread == nullptr) {
+ return;
+ }
+
+ if (prepare_sleep) {
+ if (emu_thread->IsRunning()) {
+ auto_paused = true;
+ OnPauseGame();
+ }
+ } else {
+ if (!emu_thread->IsRunning() && auto_paused) {
+ auto_paused = false;
+ RequestGameResume();
+ OnStartGame();
+ }
+ }
+}
+
#ifdef __linux__
static std::optional<QDBusObjectPath> HoldWakeLockLinux(u32 window_id = 0) {
if (!QDBusConnection::sessionBus().isConnected()) {
@@ -1241,6 +1441,52 @@ static void ReleaseWakeLockLinux(QDBusObjectPath lock) {
QString::fromLatin1("org.freedesktop.portal.Request"));
unlocker.call(QString::fromLatin1("Close"));
}
+
+std::array<int, 3> GMainWindow::sig_interrupt_fds{0, 0, 0};
+
+void GMainWindow::SetupSigInterrupts() {
+ if (sig_interrupt_fds[2] == 1) {
+ return;
+ }
+ socketpair(AF_UNIX, SOCK_STREAM, 0, sig_interrupt_fds.data());
+ sig_interrupt_fds[2] = 1;
+
+ struct sigaction sa;
+ sa.sa_handler = &GMainWindow::HandleSigInterrupt;
+ sigemptyset(&sa.sa_mask);
+ sa.sa_flags = SA_RESETHAND;
+ sigaction(SIGINT, &sa, nullptr);
+ sigaction(SIGTERM, &sa, nullptr);
+
+ sig_interrupt_notifier = new QSocketNotifier(sig_interrupt_fds[1], QSocketNotifier::Read, this);
+ connect(sig_interrupt_notifier, &QSocketNotifier::activated, this,
+ &GMainWindow::OnSigInterruptNotifierActivated);
+ connect(this, &GMainWindow::SigInterrupt, this, &GMainWindow::close);
+}
+
+void GMainWindow::HandleSigInterrupt(int sig) {
+ if (sig == SIGINT) {
+ exit(1);
+ }
+
+ // Calling into Qt directly from a signal handler is not safe,
+ // so wake up a QSocketNotifier with this hacky write call instead.
+ char a = 1;
+ int ret = write(sig_interrupt_fds[0], &a, sizeof(a));
+ (void)ret;
+}
+
+void GMainWindow::OnSigInterruptNotifierActivated() {
+ sig_interrupt_notifier->setEnabled(false);
+
+ char a;
+ int ret = read(sig_interrupt_fds[1], &a, sizeof(a));
+ (void)ret;
+
+ sig_interrupt_notifier->setEnabled(true);
+
+ emit SigInterrupt();
+}
#endif // __linux__
void GMainWindow::PreventOSSleep() {
@@ -1284,6 +1530,7 @@ bool GMainWindow::LoadROM(const QString& filename, u64 program_id, std::size_t p
system->SetAppletFrontendSet({
std::make_unique<QtControllerSelector>(*this), // Controller Selector
std::make_unique<QtErrorDisplay>(*this), // Error Display
+ nullptr, // Mii Editor
nullptr, // Parental Controls
nullptr, // Photo Viewer
std::make_unique<QtProfileSelector>(*this), // Profile Selector
@@ -1357,23 +1604,24 @@ bool GMainWindow::LoadROM(const QString& filename, u64 program_id, std::size_t p
}
return false;
}
- game_path = filename;
+ current_game_path = filename;
system->TelemetrySession().AddField(Common::Telemetry::FieldType::App, "Frontend", "Qt");
return true;
}
-void GMainWindow::SelectAndSetCurrentUser() {
+bool GMainWindow::SelectAndSetCurrentUser() {
QtProfileSelectionDialog dialog(system->HIDCore(), this);
dialog.setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint |
Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint);
dialog.setWindowModality(Qt::WindowModal);
if (dialog.exec() == QDialog::Rejected) {
- return;
+ return false;
}
Settings::values.current_user = dialog.GetIndex();
+ return true;
}
void GMainWindow::BootGame(const QString& filename, u64 program_id, std::size_t program_index,
@@ -1391,16 +1639,15 @@ void GMainWindow::BootGame(const QString& filename, u64 program_id, std::size_t
if (loader != nullptr && loader->ReadProgramId(title_id) == Loader::ResultStatus::Success &&
type == StartGameType::Normal) {
// Load per game settings
- const auto file_path = std::filesystem::path{filename.toStdU16String()};
+ const auto file_path =
+ std::filesystem::path{Common::U16StringFromBuffer(filename.utf16(), filename.size())};
const auto config_file_name = title_id == 0
? Common::FS::PathToUTF8String(file_path.filename())
: fmt::format("{:016X}", title_id);
- Config per_game_config(*system, config_file_name, Config::ConfigType::PerGameConfig);
+ Config per_game_config(config_file_name, Config::ConfigType::PerGameConfig);
+ system->ApplySettings();
}
- // Disable fps limit toggle when booting a new title
- Settings::values.disable_fps_limit.SetValue(false);
-
// Save configurations
UpdateUISettings();
game_list->SaveInterfaceLayout();
@@ -1409,11 +1656,16 @@ void GMainWindow::BootGame(const QString& filename, u64 program_id, std::size_t
Settings::LogSettings();
if (UISettings::values.select_user_on_boot) {
- SelectAndSetCurrentUser();
+ if (SelectAndSetCurrentUser() == false) {
+ return;
+ }
}
- if (!LoadROM(filename, program_id, program_index))
+ if (!LoadROM(filename, program_id, program_index)) {
return;
+ }
+
+ system->SetShuttingDown(false);
// Create and start the emulation thread
emu_thread = std::make_unique<EmuThread>(*system);
@@ -1422,7 +1674,7 @@ void GMainWindow::BootGame(const QString& filename, u64 program_id, std::size_t
// Register an ExecuteProgram callback such that Core can execute a sub-program
system->RegisterExecuteProgramCallback(
- [this](std::size_t program_index) { render_window->ExecuteProgram(program_index); });
+ [this](std::size_t program_index_) { render_window->ExecuteProgram(program_index_); });
// Register an Exit callback such that Core can exit the currently running application.
system->RegisterExitCallback([this]() { render_window->Exit(); });
@@ -1457,6 +1709,8 @@ void GMainWindow::BootGame(const QString& filename, u64 program_id, std::size_t
mouse_hide_timer.start();
}
+ render_window->InitializeCamera();
+
std::string title_name;
std::string title_version;
const auto res = system->GetGameName(title_name);
@@ -1472,7 +1726,8 @@ void GMainWindow::BootGame(const QString& filename, u64 program_id, std::size_t
}
if (res != Loader::ResultStatus::Success || title_name.empty()) {
title_name = Common::FS::PathToUTF8String(
- std::filesystem::path{filename.toStdU16String()}.filename());
+ std::filesystem::path{Common::U16StringFromBuffer(filename.utf16(), filename.size())}
+ .filename());
}
const bool is_64bit = system->Kernel().CurrentProcess()->Is64BitProcess();
const auto instruction_set_suffix = is_64bit ? tr("(64-bit)") : tr("(32-bit)");
@@ -1504,6 +1759,8 @@ void GMainWindow::ShutdownGame() {
AllowOSSleep();
+ system->SetShuttingDown(true);
+ system->DetachDebugger();
discord_rpc->Pause();
emu_thread->RequestStop();
@@ -1535,6 +1792,7 @@ void GMainWindow::ShutdownGame() {
tas_label->clear();
input_subsystem->GetTas()->Stop();
OnTasStateChanged();
+ render_window->FinalizeCamera();
// Enable all controllers
system->HIDCore().SetSupportedStyleTag({Core::HID::NpadStyleSet::All});
@@ -1551,9 +1809,9 @@ void GMainWindow::ShutdownGame() {
emu_speed_label->setVisible(false);
game_fps_label->setVisible(false);
emu_frametime_label->setVisible(false);
- renderer_status_button->setEnabled(true);
+ renderer_status_button->setEnabled(!UISettings::values.has_broken_vulkan);
- game_path.clear();
+ current_game_path.clear();
// When closing the game, destroy the GLWindow to clear the context after the game is closed
render_window->ReleaseRenderTarget();
@@ -1571,7 +1829,7 @@ void GMainWindow::StoreRecentFile(const QString& filename) {
void GMainWindow::UpdateRecentFiles() {
const int num_recent_files =
- std::min(UISettings::values.recent_files.size(), max_recent_files_item);
+ std::min(static_cast<int>(UISettings::values.recent_files.size()), max_recent_files_item);
for (int i = 0; i < num_recent_files; i++) {
const QString text = QStringLiteral("&%1. %2").arg(i + 1).arg(
@@ -1746,7 +2004,7 @@ static bool RomFSRawCopy(QProgressDialog& dialog, const FileSys::VirtualDir& src
}
void GMainWindow::OnGameListRemoveInstalledEntry(u64 program_id, InstalledEntryType type) {
- const QString entry_type = [this, type] {
+ const QString entry_type = [type] {
switch (type) {
case InstalledEntryType::Game:
return tr("Contents");
@@ -1843,7 +2101,7 @@ void GMainWindow::RemoveAddOnContent(u64 program_id, const QString& entry_type)
void GMainWindow::OnGameListRemoveFile(u64 program_id, GameListRemoveTarget target,
const std::string& game_path) {
- const QString question = [this, target] {
+ const QString question = [target] {
switch (target) {
case GameListRemoveTarget::GlShaderCache:
return tr("Delete OpenGL Transferable Shader Cache?");
@@ -2472,7 +2730,7 @@ void GMainWindow::OnRestartGame() {
return;
}
// Make a copy since BootGame edits game_path
- BootGame(QString(game_path));
+ BootGame(QString(current_game_path));
}
void GMainWindow::OnPauseGame() {
@@ -2486,6 +2744,7 @@ void GMainWindow::OnPauseContinueGame() {
if (emu_thread->IsRunning()) {
OnPauseGame();
} else {
+ RequestGameResume();
OnStartGame();
}
}
@@ -2515,6 +2774,11 @@ void GMainWindow::OnExit() {
OnStopGame();
}
+void GMainWindow::OnSaveConfig() {
+ system->ApplySettings();
+ config->Save();
+}
+
void GMainWindow::ErrorDisplayDisplayError(QString error_code, QString error_text) {
OverlayDialog dialog(render_window, *system, error_code, error_text, QString{}, tr("OK"),
Qt::AlignLeft | Qt::AlignVCenter);
@@ -2569,6 +2833,18 @@ void GMainWindow::ToggleFullscreen() {
}
}
+// We're going to return the screen that the given window has the most pixels on
+static QScreen* GuessCurrentScreen(QWidget* window) {
+ const QList<QScreen*> screens = QGuiApplication::screens();
+ return *std::max_element(
+ screens.cbegin(), screens.cend(), [window](const QScreen* left, const QScreen* right) {
+ const QSize left_size = left->geometry().intersected(window->geometry()).size();
+ const QSize right_size = right->geometry().intersected(window->geometry()).size();
+ return (left_size.height() * left_size.width()) <
+ (right_size.height() * right_size.width());
+ });
+}
+
void GMainWindow::ShowFullscreen() {
const auto show_fullscreen = [](QWidget* window) {
if (Settings::values.fullscreen_mode.GetValue() == Settings::FullscreenMode::Exclusive) {
@@ -2577,7 +2853,7 @@ void GMainWindow::ShowFullscreen() {
}
window->hide();
window->setWindowFlags(window->windowFlags() | Qt::FramelessWindowHint);
- const auto screen_geometry = QApplication::desktop()->screenGeometry(window);
+ const auto screen_geometry = GuessCurrentScreen(window)->geometry();
window->setGeometry(screen_geometry.x(), screen_geometry.y(), screen_geometry.width(),
screen_geometry.height() + 1);
window->raise();
@@ -2681,7 +2957,8 @@ void GMainWindow::OnConfigure() {
const bool old_discord_presence = UISettings::values.enable_discord_presence.GetValue();
Settings::SetConfiguringGlobal(true);
- ConfigureDialog configure_dialog(this, hotkey_registry, input_subsystem.get(), *system);
+ ConfigureDialog configure_dialog(this, hotkey_registry, input_subsystem.get(), *system,
+ !multiplayer_state->IsHostingPublicRoom());
connect(&configure_dialog, &ConfigureDialog::LanguageChanged, this,
&GMainWindow::OnLanguageChanged);
@@ -2717,7 +2994,7 @@ void GMainWindow::OnConfigure() {
Settings::values.disabled_addons.clear();
- config = std::make_unique<Config>(*system);
+ config = std::make_unique<Config>();
UISettings::values.reset_to_defaults = false;
UISettings::values.game_dirs = std::move(old_game_dirs);
@@ -2738,6 +3015,11 @@ void GMainWindow::OnConfigure() {
if (UISettings::values.enable_discord_presence.GetValue() != old_discord_presence) {
SetDiscordEnabled(UISettings::values.enable_discord_presence.GetValue());
}
+
+ if (!multiplayer_state->IsHostingPublicRoom()) {
+ multiplayer_state->UpdateCredentials();
+ }
+
emit UpdateThemedIcons();
const auto reload = UISettings::values.is_game_list_reload_pending.exchange(false);
@@ -2761,8 +3043,19 @@ void GMainWindow::OnConfigure() {
mouse_hide_timer.start();
}
+ // Restart camera config
+ if (emulation_running) {
+ render_window->FinalizeCamera();
+ render_window->InitializeCamera();
+ }
+
+ if (!UISettings::values.has_broken_vulkan) {
+ renderer_status_button->setEnabled(!emulation_running);
+ }
+
UpdateStatusButtons();
controller_dialog->refreshConfiguration();
+ system->ApplySettings();
}
void GMainWindow::OnConfigureTas() {
@@ -2846,7 +3139,7 @@ void GMainWindow::OnToggleDockedMode() {
}
Settings::values.use_docked_mode.SetValue(!is_docked);
- dock_status_button->setChecked(!is_docked);
+ UpdateDockedButton();
OnDockedModeChanged(is_docked, !is_docked, *system);
}
@@ -2885,7 +3178,7 @@ void GMainWindow::OnToggleAdaptingFilter() {
void GMainWindow::OnConfigurePerGame() {
const u64 title_id = system->GetCurrentProcessProgramID();
- OpenPerGameConfiguration(title_id, game_path.toStdString());
+ OpenPerGameConfiguration(title_id, current_game_path.toStdString());
}
void GMainWindow::OpenPerGameConfiguration(u64 title_id, const std::string& file_name) {
@@ -2927,6 +3220,20 @@ void GMainWindow::OnLoadAmiibo() {
return;
}
+ auto* virtual_amiibo = input_subsystem->GetVirtualAmiibo();
+
+ // Remove amiibo if one is connected
+ if (virtual_amiibo->GetCurrentState() == InputCommon::VirtualAmiibo::State::AmiiboIsOpen) {
+ virtual_amiibo->CloseAmiibo();
+ QMessageBox::warning(this, tr("Amiibo"), tr("The current amiibo has been removed"));
+ return;
+ }
+
+ if (virtual_amiibo->GetCurrentState() != InputCommon::VirtualAmiibo::State::WaitingForAmiibo) {
+ QMessageBox::warning(this, tr("Error"), tr("The current game is not looking for amiibos"));
+ return;
+ }
+
is_amiibo_file_select_active = true;
const QString extensions{QStringLiteral("*.bin")};
const QString file_filter = tr("Amiibo File (%1);; All Files (*.*)").arg(extensions);
@@ -2941,34 +3248,30 @@ void GMainWindow::OnLoadAmiibo() {
}
void GMainWindow::LoadAmiibo(const QString& filename) {
- Service::SM::ServiceManager& sm = system->ServiceManager();
- auto nfc = sm.GetService<Service::NFP::Module::Interface>("nfp:user");
- if (nfc == nullptr) {
+ auto* virtual_amiibo = input_subsystem->GetVirtualAmiibo();
+ const QString title = tr("Error loading Amiibo data");
+ // Remove amiibo if one is connected
+ if (virtual_amiibo->GetCurrentState() == InputCommon::VirtualAmiibo::State::AmiiboIsOpen) {
+ virtual_amiibo->CloseAmiibo();
+ QMessageBox::warning(this, tr("Amiibo"), tr("The current amiibo has been removed"));
return;
}
- QFile nfc_file{filename};
- if (!nfc_file.open(QIODevice::ReadOnly)) {
- QMessageBox::warning(this, tr("Error opening Amiibo data file"),
- tr("Unable to open Amiibo file \"%1\" for reading.").arg(filename));
- return;
- }
-
- const u64 nfc_file_size = nfc_file.size();
- std::vector<u8> buffer(nfc_file_size);
- const u64 read_size = nfc_file.read(reinterpret_cast<char*>(buffer.data()), nfc_file_size);
- if (nfc_file_size != read_size) {
- QMessageBox::warning(this, tr("Error reading Amiibo data file"),
- tr("Unable to fully read Amiibo data. Expected to read %1 bytes, but "
- "was only able to read %2 bytes.")
- .arg(nfc_file_size)
- .arg(read_size));
- return;
- }
-
- if (!nfc->LoadAmiibo(buffer)) {
- QMessageBox::warning(this, tr("Error loading Amiibo data"),
- tr("Unable to load Amiibo data."));
+ switch (virtual_amiibo->LoadAmiibo(filename.toStdString())) {
+ case InputCommon::VirtualAmiibo::Info::NotAnAmiibo:
+ QMessageBox::warning(this, title, tr("The selected file is not a valid amiibo"));
+ break;
+ case InputCommon::VirtualAmiibo::Info::UnableToLoad:
+ QMessageBox::warning(this, title, tr("The selected file is already on use"));
+ break;
+ case InputCommon::VirtualAmiibo::Info::WrongDeviceState:
+ QMessageBox::warning(this, title, tr("The current game is not looking for amiibos"));
+ break;
+ case InputCommon::VirtualAmiibo::Info::Unknown:
+ QMessageBox::warning(this, title, tr("An unkown error occured"));
+ break;
+ default:
+ break;
}
}
@@ -3046,7 +3349,8 @@ void GMainWindow::MigrateConfigFiles() {
}
const auto origin = config_dir_fs_path / filename;
const auto destination = config_dir_fs_path / "custom" / filename;
- LOG_INFO(Frontend, "Migrating config file from {} to {}", origin, destination);
+ LOG_INFO(Frontend, "Migrating config file from {} to {}", origin.string(),
+ destination.string());
if (!Common::FS::RenameFile(origin, destination)) {
// Delete the old config file if one already exists in the new location.
Common::FS::RemoveFile(origin);
@@ -3112,7 +3416,7 @@ void GMainWindow::OnTasStateChanged() {
}
void GMainWindow::UpdateStatusBar() {
- if (emu_thread == nullptr) {
+ if (emu_thread == nullptr || !system->IsPoweredOn()) {
status_bar_update_timer.stop();
return;
}
@@ -3146,11 +3450,12 @@ void GMainWindow::UpdateStatusBar() {
} else {
emu_speed_label->setText(tr("Speed: %1%").arg(results.emulation_speed * 100.0, 0, 'f', 0));
}
- if (Settings::values.disable_fps_limit) {
+ if (!Settings::values.use_speed_limit) {
game_fps_label->setText(
- tr("Game: %1 FPS (Unlocked)").arg(results.average_game_fps, 0, 'f', 0));
+ tr("Game: %1 FPS (Unlocked)").arg(std::round(results.average_game_fps), 0, 'f', 0));
} else {
- game_fps_label->setText(tr("Game: %1 FPS").arg(results.average_game_fps, 0, 'f', 0));
+ game_fps_label->setText(
+ tr("Game: %1 FPS").arg(std::round(results.average_game_fps), 0, 'f', 0));
}
emu_frametime_label->setText(tr("Frame: %1 ms").arg(results.frametime * 1000.0, 0, 'f', 2));
@@ -3184,6 +3489,12 @@ void GMainWindow::UpdateGPUAccuracyButton() {
}
}
+void GMainWindow::UpdateDockedButton() {
+ const bool is_docked = Settings::values.use_docked_mode.GetValue();
+ dock_status_button->setChecked(is_docked);
+ dock_status_button->setText(is_docked ? tr("DOCKED") : tr("HANDHELD"));
+}
+
void GMainWindow::UpdateFilterText() {
const auto filter = Settings::values.scaling_filter.GetValue();
switch (filter) {
@@ -3227,10 +3538,10 @@ void GMainWindow::UpdateAAText() {
}
void GMainWindow::UpdateStatusButtons() {
- dock_status_button->setChecked(Settings::values.use_docked_mode.GetValue());
renderer_status_button->setChecked(Settings::values.renderer_backend.GetValue() ==
Settings::RendererBackend::Vulkan);
UpdateGPUAccuracyButton();
+ UpdateDockedButton();
UpdateFilterText();
UpdateAAText();
}
@@ -3269,10 +3580,26 @@ void GMainWindow::ShowMouseCursor() {
}
}
+void GMainWindow::CenterMouseCursor() {
+ if (emu_thread == nullptr || !Settings::values.mouse_panning) {
+ mouse_center_timer.stop();
+ return;
+ }
+ if (!this->isActiveWindow()) {
+ mouse_center_timer.stop();
+ return;
+ }
+ const int center_x = render_window->width() / 2;
+ const int center_y = render_window->height() / 2;
+
+ QCursor::setPos(mapToGlobal(QPoint{center_x, center_y}));
+}
+
void GMainWindow::OnMouseActivity() {
if (!Settings::values.mouse_panning) {
ShowMouseCursor();
}
+ mouse_center_timer.stop();
}
void GMainWindow::OnCoreError(Core::SystemResultStatus result, std::string details) {
@@ -3498,6 +3825,8 @@ void GMainWindow::closeEvent(QCloseEvent* event) {
}
render_window->close();
+ multiplayer_state->Close();
+ system->GetRoomNetwork().Shutdown();
QWidget::closeEvent(event);
}
@@ -3545,6 +3874,22 @@ void GMainWindow::dragMoveEvent(QDragMoveEvent* event) {
AcceptDropEvent(event);
}
+void GMainWindow::leaveEvent(QEvent* event) {
+ if (Settings::values.mouse_panning) {
+ const QRect& rect = geometry();
+ QPoint position = QCursor::pos();
+
+ qint32 x = qBound(rect.left(), position.x(), rect.right());
+ qint32 y = qBound(rect.top(), position.y(), rect.bottom());
+ // Only start the timer if the mouse has left the window bound.
+ // The leave event is also triggered when the window looses focus.
+ if (x != position.x() || y != position.y()) {
+ mouse_center_timer.start();
+ }
+ event->accept();
+ }
+}
+
bool GMainWindow::ConfirmChangeGame() {
if (emu_thread == nullptr)
return true;
@@ -3583,13 +3928,41 @@ void GMainWindow::RequestGameExit() {
}
}
+void GMainWindow::RequestGameResume() {
+ auto& sm{system->ServiceManager()};
+ auto applet_oe = sm.GetService<Service::AM::AppletOE>("appletOE");
+ auto applet_ae = sm.GetService<Service::AM::AppletAE>("appletAE");
+
+ if (applet_oe != nullptr) {
+ applet_oe->GetMessageQueue()->RequestResume();
+ return;
+ }
+
+ if (applet_ae != nullptr) {
+ applet_ae->GetMessageQueue()->RequestResume();
+ }
+}
+
void GMainWindow::filterBarSetChecked(bool state) {
ui->action_Show_Filter_Bar->setChecked(state);
emit(OnToggleFilterBar());
}
+static void AdjustLinkColor() {
+ QPalette new_pal(qApp->palette());
+ if (UISettings::IsDarkTheme()) {
+ new_pal.setColor(QPalette::Link, QColor(0, 190, 255, 255));
+ } else {
+ new_pal.setColor(QPalette::Link, QColor(0, 140, 200, 255));
+ }
+ if (qApp->palette().color(QPalette::Link) != new_pal.color(QPalette::Link)) {
+ qApp->setPalette(new_pal);
+ }
+}
+
void GMainWindow::UpdateUITheme() {
- const QString default_theme = QStringLiteral("default");
+ 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);
@@ -3597,6 +3970,23 @@ void GMainWindow::UpdateUITheme() {
current_theme = default_theme;
}
+#ifdef _WIN32
+ QIcon::setThemeName(current_theme);
+ AdjustLinkColor();
+#else
+ if (current_theme == QStringLiteral("default") || current_theme == QStringLiteral("colorful")) {
+ QIcon::setThemeName(current_theme == QStringLiteral("colorful") ? current_theme
+ : startup_icon_theme);
+ QIcon::setThemeSearchPaths(theme_paths);
+ if (CheckDarkMode()) {
+ current_theme = QStringLiteral("default_dark");
+ }
+ } else {
+ QIcon::setThemeName(current_theme);
+ QIcon::setThemeSearchPaths(QStringList(QStringLiteral(":/icons")));
+ AdjustLinkColor();
+ }
+#endif
if (current_theme != default_theme) {
QString theme_uri{QStringLiteral(":%1/style.qss").arg(current_theme)};
QFile f(theme_uri);
@@ -3619,17 +4009,9 @@ void GMainWindow::UpdateUITheme() {
qApp->setStyleSheet({});
setStyleSheet({});
}
-
- QIcon::setThemeName(current_theme);
- QIcon::setThemeSearchPaths(theme_paths);
}
void GMainWindow::LoadTranslation() {
- // If the selected language is English, no need to install any translation
- if (UISettings::values.language == QStringLiteral("en")) {
- return;
- }
-
bool loaded;
if (UISettings::values.language.isEmpty()) {
@@ -3655,6 +4037,7 @@ void GMainWindow::OnLanguageChanged(const QString& locale) {
UISettings::values.language = locale;
LoadTranslation();
ui->retranslateUi(this);
+ multiplayer_state->retranslateUi();
UpdateWindowTitle();
}
@@ -3671,11 +4054,54 @@ void GMainWindow::SetDiscordEnabled([[maybe_unused]] bool state) {
discord_rpc->Update();
}
+void GMainWindow::changeEvent(QEvent* event) {
+#ifdef __linux__
+ // PaletteChange event appears to only reach so far into the GUI, explicitly asking to
+ // UpdateUITheme is a decent work around
+ if (event->type() == QEvent::PaletteChange) {
+ const QPalette test_palette(qApp->palette());
+ const QString current_theme = UISettings::values.theme;
+ // Keeping eye on QPalette::Window to avoid looping. QPalette::Text might be useful too
+ static QColor last_window_color;
+ const QColor window_color = test_palette.color(QPalette::Active, QPalette::Window);
+ if (last_window_color != window_color && (current_theme == QStringLiteral("default") ||
+ current_theme == QStringLiteral("colorful"))) {
+ UpdateUITheme();
+ }
+ last_window_color = window_color;
+ }
+#endif // __linux__
+ QWidget::changeEvent(event);
+}
+
#ifdef main
#undef main
#endif
int main(int argc, char* argv[]) {
+ std::unique_ptr<Config> config = std::make_unique<Config>();
+ bool has_broken_vulkan = false;
+ bool is_child = false;
+ if (CheckEnvVars(&is_child)) {
+ return 0;
+ }
+
+#ifdef YUZU_DBGHELP
+ PROCESS_INFORMATION pi;
+ if (!is_child && Settings::values.create_crash_dumps.GetValue() &&
+ MiniDump::SpawnDebuggee(argv[0], pi)) {
+ // Delete the config object so that it doesn't save when the program exits
+ config.reset(nullptr);
+ MiniDump::DebugDebuggee(pi);
+ return 0;
+ }
+#endif
+
+ if (StartupChecks(argv[0], &has_broken_vulkan,
+ Settings::values.perform_vulkan_check.GetValue())) {
+ return 0;
+ }
+
Common::DetachedTasks detached_tasks;
MicroProfileOnThreadCreate("Frontend");
SCOPE_EXIT({ MicroProfileShutdown(); });
@@ -3711,11 +4137,20 @@ int main(int argc, char* argv[]) {
QCoreApplication::setAttribute(Qt::AA_DontCheckOpenGLContextThreadAffinity);
QApplication app(argc, argv);
+ // Workaround for QTBUG-85409, for Suzhou numerals the number 1 is actually \u3021
+ // 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
+ const QLocale locale = QLocale::system();
+ if (QStringLiteral("\u3008") == locale.toString(1)) {
+ QLocale::setDefault(QLocale::system().name());
+ }
+
// Qt changes the locale and causes issues in float conversion using std::to_string() when
// generating shaders
setlocale(LC_ALL, "C");
- GMainWindow main_window{};
+ GMainWindow main_window{std::move(config), has_broken_vulkan};
// After settings have been loaded by GMainWindow, apply the filter
main_window.show();
diff --git a/src/yuzu/main.h b/src/yuzu/main.h
index 6a35b9e3d..f7aa8e417 100644
--- a/src/yuzu/main.h
+++ b/src/yuzu/main.h
@@ -1,19 +1,17 @@
-// Copyright 2014 Citra Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: 2014 Citra Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include <memory>
#include <optional>
-#include <unordered_map>
#include <QMainWindow>
#include <QTimer>
#include <QTranslator>
+#include "common/announce_multiplayer_room.h"
#include "common/common_types.h"
-#include "core/hle/service/acc/profile_manager.h"
#include "yuzu/compatibility_list.h"
#include "yuzu/hotkeys.h"
@@ -24,6 +22,7 @@
#endif
class Config;
+class ClickableLabel;
class EmuThread;
class GameList;
class GImageInfo;
@@ -33,6 +32,7 @@ class MicroProfileDialog;
class ProfilerWidget;
class ControllerDialog;
class QLabel;
+class MultiplayerState;
class QPushButton;
class QProgressDialog;
class WaitTreeWidget;
@@ -120,7 +120,7 @@ class GMainWindow : public QMainWindow {
public:
void filterBarSetChecked(bool state);
void UpdateUITheme();
- explicit GMainWindow();
+ explicit GMainWindow(std::unique_ptr<Config> config_, bool has_broken_vulkan);
~GMainWindow() override;
bool DropAction(QDropEvent* event);
@@ -163,10 +163,13 @@ signals:
void WebBrowserExtractOfflineRomFS();
void WebBrowserClosed(Service::AM::Applets::WebExitReason exit_reason, std::string last_url);
+ void SigInterrupt();
+
public slots:
void OnLoadComplete();
void OnExecuteProgram(std::size_t program_index);
void OnExit();
+ void OnSaveConfig();
void ControllerSelectorReconfigureControllers(
const Core::Frontend::ControllerParameters& parameters);
void SoftwareKeyboardInitialize(
@@ -202,6 +205,8 @@ private:
void ConnectMenuEvents();
void UpdateMenuState();
+ void SetupPrepareForSleep();
+
void PreventOSSleep();
void AllowOSSleep();
@@ -214,7 +219,7 @@ private:
void SetDiscordEnabled(bool state);
void LoadAmiibo(const QString& filename);
- void SelectAndSetCurrentUser();
+ bool SelectAndSetCurrentUser();
/**
* Stores the filename in the recently loaded files list.
@@ -246,14 +251,23 @@ private:
bool ConfirmChangeGame();
bool ConfirmForceLockedExit();
void RequestGameExit();
+ void RequestGameResume();
+ void changeEvent(QEvent* event) override;
void closeEvent(QCloseEvent* event) override;
+#ifdef __linux__
+ void SetupSigInterrupts();
+ static void HandleSigInterrupt(int);
+ void OnSigInterruptNotifierActivated();
+#endif
+
private slots:
void OnStartGame();
void OnRestartGame();
void OnPauseGame();
void OnPauseContinueGame();
void OnStopGame();
+ void OnPrepareForSleep(bool prepare_sleep);
void OnMenuReportCompatibility();
void OnOpenModsPage();
void OnOpenQuickstartGuide();
@@ -322,6 +336,7 @@ private:
void MigrateConfigFiles();
void UpdateWindowTitle(std::string_view title_name = {}, std::string_view title_version = {},
std::string_view gpu_vendor = {});
+ void UpdateDockedButton();
void UpdateFilterText();
void UpdateAAText();
void UpdateStatusBar();
@@ -330,9 +345,11 @@ private:
void UpdateUISettings();
void HideMouseCursor();
void ShowMouseCursor();
+ void CenterMouseCursor();
void OpenURL(const QUrl& url);
void LoadTranslation();
void OpenPerGameConfiguration(u64 title_id, const std::string& file_name);
+ bool CheckDarkMode();
QString GetTasStateDescription() const;
@@ -342,6 +359,8 @@ private:
std::unique_ptr<DiscordRPC::DiscordInterface> discord_rpc;
std::shared_ptr<InputCommon::InputSubsystem> input_subsystem;
+ MultiplayerState* multiplayer_state = nullptr;
+
GRenderWindow* render_window;
GameList* game_list;
LoadingScreen* loading_screen;
@@ -369,11 +388,15 @@ private:
bool emulation_running = false;
std::unique_ptr<EmuThread> emu_thread;
// The path to the game currently running
- QString game_path;
+ QString current_game_path;
bool auto_paused = false;
bool auto_muted = false;
QTimer mouse_hide_timer;
+ QTimer mouse_center_timer;
+
+ QString startup_icon_theme;
+ bool os_dark_mode = false;
// FS
std::shared_ptr<FileSys::VfsFilesystem> vfs;
@@ -400,9 +423,6 @@ private:
// Last game booted, used for multi-process apps
QString last_filename_booted;
- // Disables the web applet for the rest of the emulated session
- bool disable_web_applet{};
-
// Applets
QtSoftwareKeyboardDialog* software_keyboard = nullptr;
@@ -416,6 +436,9 @@ private:
bool is_tas_recording_dialog_active{};
#ifdef __linux__
+ QSocketNotifier* sig_interrupt_notifier;
+ static std::array<int, 3> sig_interrupt_fds;
+
QDBusObjectPath wake_lock{};
#endif
@@ -423,4 +446,5 @@ protected:
void dropEvent(QDropEvent* event) override;
void dragEnterEvent(QDragEnterEvent* event) override;
void dragMoveEvent(QDragMoveEvent* event) override;
+ void leaveEvent(QEvent* event) override;
};
diff --git a/src/yuzu/main.ui b/src/yuzu/main.ui
index 5719b2ee4..74d49dbd4 100644
--- a/src/yuzu/main.ui
+++ b/src/yuzu/main.ui
@@ -120,6 +120,20 @@
<addaction name="menu_Reset_Window_Size"/>
<addaction name="menu_View_Debugging"/>
</widget>
+ <widget class="QMenu" name="menu_Multiplayer">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="title">
+ <string>&amp;Multiplayer</string>
+ </property>
+ <addaction name="action_View_Lobby"/>
+ <addaction name="action_Start_Room"/>
+ <addaction name="action_Connect_To_Room"/>
+ <addaction name="separator"/>
+ <addaction name="action_Show_Room"/>
+ <addaction name="action_Leave_Room"/>
+ </widget>
<widget class="QMenu" name="menu_Tools">
<property name="title">
<string>&amp;Tools</string>
@@ -154,6 +168,7 @@
<addaction name="menu_Emulation"/>
<addaction name="menu_View"/>
<addaction name="menu_Tools"/>
+ <addaction name="menu_Multiplayer"/>
<addaction name="menu_Help"/>
</widget>
<action name="action_Install_File_NAND">
@@ -245,6 +260,43 @@
<string>Show Status Bar</string>
</property>
</action>
+ <action name="action_View_Lobby">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string>&amp;Browse Public Game Lobby</string>
+ </property>
+ </action>
+ <action name="action_Start_Room">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string>&amp;Create Room</string>
+ </property>
+ </action>
+ <action name="action_Leave_Room">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>&amp;Leave Room</string>
+ </property>
+ </action>
+ <action name="action_Connect_To_Room">
+ <property name="text">
+ <string>&amp;Direct Connect to Room</string>
+ </property>
+ </action>
+ <action name="action_Show_Room">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>&amp;Show Current Room</string>
+ </property>
+ </action>
<action name="action_Fullscreen">
<property name="checkable">
<bool>true</bool>
@@ -266,7 +318,7 @@
<bool>false</bool>
</property>
<property name="text">
- <string>Load &amp;Amiibo...</string>
+ <string>Load/Remove &amp;Amiibo...</string>
</property>
</action>
<action name="action_Report_Compatibility">
diff --git a/src/yuzu/mini_dump.cpp b/src/yuzu/mini_dump.cpp
new file mode 100644
index 000000000..a34dc6a9c
--- /dev/null
+++ b/src/yuzu/mini_dump.cpp
@@ -0,0 +1,202 @@
+// SPDX-FileCopyrightText: 2022 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include <cstdio>
+#include <cstring>
+#include <ctime>
+#include <filesystem>
+#include <fmt/format.h>
+#include <windows.h>
+#include "yuzu/mini_dump.h"
+#include "yuzu/startup_checks.h"
+
+// dbghelp.h must be included after windows.h
+#include <dbghelp.h>
+
+namespace MiniDump {
+
+void CreateMiniDump(HANDLE process_handle, DWORD process_id, MINIDUMP_EXCEPTION_INFORMATION* info,
+ EXCEPTION_POINTERS* pep) {
+ char file_name[255];
+ const std::time_t the_time = std::time(nullptr);
+ std::strftime(file_name, 255, "yuzu-crash-%Y%m%d%H%M%S.dmp", std::localtime(&the_time));
+
+ // Open the file
+ HANDLE file_handle = CreateFileA(file_name, GENERIC_READ | GENERIC_WRITE, 0, nullptr,
+ CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr);
+
+ if (file_handle == nullptr || file_handle == INVALID_HANDLE_VALUE) {
+ fmt::print(stderr, "CreateFileA failed. Error: {}", GetLastError());
+ return;
+ }
+
+ // Create the minidump
+ const MINIDUMP_TYPE dump_type = MiniDumpNormal;
+
+ const bool write_dump_status = MiniDumpWriteDump(process_handle, process_id, file_handle,
+ dump_type, (pep != 0) ? info : 0, 0, 0);
+
+ if (write_dump_status) {
+ fmt::print(stderr, "MiniDump created: {}", file_name);
+ } else {
+ fmt::print(stderr, "MiniDumpWriteDump failed. Error: {}", GetLastError());
+ }
+
+ // Close the file
+ CloseHandle(file_handle);
+}
+
+void DumpFromDebugEvent(DEBUG_EVENT& deb_ev, PROCESS_INFORMATION& pi) {
+ EXCEPTION_RECORD& record = deb_ev.u.Exception.ExceptionRecord;
+
+ HANDLE thread_handle = OpenThread(THREAD_GET_CONTEXT, false, deb_ev.dwThreadId);
+ if (thread_handle == nullptr) {
+ fmt::print(stderr, "OpenThread failed ({})", GetLastError());
+ return;
+ }
+
+ // Get child process context
+ CONTEXT context = {};
+ context.ContextFlags = CONTEXT_ALL;
+ if (!GetThreadContext(thread_handle, &context)) {
+ fmt::print(stderr, "GetThreadContext failed ({})", GetLastError());
+ return;
+ }
+
+ // Create exception pointers for minidump
+ EXCEPTION_POINTERS ep;
+ ep.ExceptionRecord = &record;
+ ep.ContextRecord = &context;
+
+ MINIDUMP_EXCEPTION_INFORMATION info;
+ info.ThreadId = deb_ev.dwThreadId;
+ info.ExceptionPointers = &ep;
+ info.ClientPointers = false;
+
+ CreateMiniDump(pi.hProcess, pi.dwProcessId, &info, &ep);
+
+ if (CloseHandle(thread_handle) == 0) {
+ fmt::print(stderr, "error: CloseHandle(thread_handle) failed ({})", GetLastError());
+ }
+}
+
+bool SpawnDebuggee(const char* arg0, PROCESS_INFORMATION& pi) {
+ std::memset(&pi, 0, sizeof(pi));
+
+ // Don't debug if we are already being debugged
+ if (IsDebuggerPresent()) {
+ return false;
+ }
+
+ if (!SpawnChild(arg0, &pi, 0)) {
+ fmt::print(stderr, "warning: continuing without crash dumps");
+ return false;
+ }
+
+ const bool can_debug = DebugActiveProcess(pi.dwProcessId);
+ if (!can_debug) {
+ fmt::print(stderr,
+ "warning: DebugActiveProcess failed ({}), continuing without crash dumps",
+ GetLastError());
+ return false;
+ }
+
+ return true;
+}
+
+static const char* ExceptionName(DWORD exception) {
+ switch (exception) {
+ case EXCEPTION_ACCESS_VIOLATION:
+ return "EXCEPTION_ACCESS_VIOLATION";
+ case EXCEPTION_DATATYPE_MISALIGNMENT:
+ return "EXCEPTION_DATATYPE_MISALIGNMENT";
+ case EXCEPTION_BREAKPOINT:
+ return "EXCEPTION_BREAKPOINT";
+ case EXCEPTION_SINGLE_STEP:
+ return "EXCEPTION_SINGLE_STEP";
+ case EXCEPTION_ARRAY_BOUNDS_EXCEEDED:
+ return "EXCEPTION_ARRAY_BOUNDS_EXCEEDED";
+ case EXCEPTION_FLT_DENORMAL_OPERAND:
+ return "EXCEPTION_FLT_DENORMAL_OPERAND";
+ case EXCEPTION_FLT_DIVIDE_BY_ZERO:
+ return "EXCEPTION_FLT_DIVIDE_BY_ZERO";
+ case EXCEPTION_FLT_INEXACT_RESULT:
+ return "EXCEPTION_FLT_INEXACT_RESULT";
+ case EXCEPTION_FLT_INVALID_OPERATION:
+ return "EXCEPTION_FLT_INVALID_OPERATION";
+ case EXCEPTION_FLT_OVERFLOW:
+ return "EXCEPTION_FLT_OVERFLOW";
+ case EXCEPTION_FLT_STACK_CHECK:
+ return "EXCEPTION_FLT_STACK_CHECK";
+ case EXCEPTION_FLT_UNDERFLOW:
+ return "EXCEPTION_FLT_UNDERFLOW";
+ case EXCEPTION_INT_DIVIDE_BY_ZERO:
+ return "EXCEPTION_INT_DIVIDE_BY_ZERO";
+ case EXCEPTION_INT_OVERFLOW:
+ return "EXCEPTION_INT_OVERFLOW";
+ case EXCEPTION_PRIV_INSTRUCTION:
+ return "EXCEPTION_PRIV_INSTRUCTION";
+ case EXCEPTION_IN_PAGE_ERROR:
+ return "EXCEPTION_IN_PAGE_ERROR";
+ case EXCEPTION_ILLEGAL_INSTRUCTION:
+ return "EXCEPTION_ILLEGAL_INSTRUCTION";
+ case EXCEPTION_NONCONTINUABLE_EXCEPTION:
+ return "EXCEPTION_NONCONTINUABLE_EXCEPTION";
+ case EXCEPTION_STACK_OVERFLOW:
+ return "EXCEPTION_STACK_OVERFLOW";
+ case EXCEPTION_INVALID_DISPOSITION:
+ return "EXCEPTION_INVALID_DISPOSITION";
+ case EXCEPTION_GUARD_PAGE:
+ return "EXCEPTION_GUARD_PAGE";
+ case EXCEPTION_INVALID_HANDLE:
+ return "EXCEPTION_INVALID_HANDLE";
+ default:
+ return "unknown exception type";
+ }
+}
+
+void DebugDebuggee(PROCESS_INFORMATION& pi) {
+ DEBUG_EVENT deb_ev = {};
+
+ while (deb_ev.dwDebugEventCode != EXIT_PROCESS_DEBUG_EVENT) {
+ const bool wait_success = WaitForDebugEvent(&deb_ev, INFINITE);
+ if (!wait_success) {
+ fmt::print(stderr, "error: WaitForDebugEvent failed ({})", GetLastError());
+ return;
+ }
+
+ switch (deb_ev.dwDebugEventCode) {
+ case OUTPUT_DEBUG_STRING_EVENT:
+ case CREATE_PROCESS_DEBUG_EVENT:
+ case CREATE_THREAD_DEBUG_EVENT:
+ case EXIT_PROCESS_DEBUG_EVENT:
+ case EXIT_THREAD_DEBUG_EVENT:
+ case LOAD_DLL_DEBUG_EVENT:
+ case RIP_EVENT:
+ case UNLOAD_DLL_DEBUG_EVENT:
+ // Continue on all other debug events
+ ContinueDebugEvent(deb_ev.dwProcessId, deb_ev.dwThreadId, DBG_CONTINUE);
+ break;
+ case EXCEPTION_DEBUG_EVENT:
+ EXCEPTION_RECORD& record = deb_ev.u.Exception.ExceptionRecord;
+
+ // We want to generate a crash dump if we are seeing the same exception again.
+ if (!deb_ev.u.Exception.dwFirstChance) {
+ fmt::print(stderr, "Creating MiniDump on ExceptionCode: 0x{:08x} {}\n",
+ record.ExceptionCode, ExceptionName(record.ExceptionCode));
+ DumpFromDebugEvent(deb_ev, pi);
+ }
+
+ // Continue without handling the exception.
+ // Lets the debuggee use its own exception handler.
+ // - If one does not exist, we will see the exception once more where we make a minidump
+ // for. Then when it reaches here again, yuzu will probably crash.
+ // - DBG_CONTINUE on an exception that the debuggee does not handle can set us up for an
+ // infinite loop of exceptions.
+ ContinueDebugEvent(deb_ev.dwProcessId, deb_ev.dwThreadId, DBG_EXCEPTION_NOT_HANDLED);
+ break;
+ }
+ }
+}
+
+} // namespace MiniDump
diff --git a/src/yuzu/mini_dump.h b/src/yuzu/mini_dump.h
new file mode 100644
index 000000000..d6b6cca84
--- /dev/null
+++ b/src/yuzu/mini_dump.h
@@ -0,0 +1,19 @@
+// SPDX-FileCopyrightText: 2022 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+#include <windows.h>
+
+#include <dbghelp.h>
+
+namespace MiniDump {
+
+void CreateMiniDump(HANDLE process_handle, DWORD process_id, MINIDUMP_EXCEPTION_INFORMATION* info,
+ EXCEPTION_POINTERS* pep);
+
+void DumpFromDebugEvent(DEBUG_EVENT& deb_ev, PROCESS_INFORMATION& pi);
+bool SpawnDebuggee(const char* arg0, PROCESS_INFORMATION& pi);
+void DebugDebuggee(PROCESS_INFORMATION& pi);
+
+} // namespace MiniDump
diff --git a/src/yuzu/multiplayer/chat_room.cpp b/src/yuzu/multiplayer/chat_room.cpp
new file mode 100644
index 000000000..dec9696c1
--- /dev/null
+++ b/src/yuzu/multiplayer/chat_room.cpp
@@ -0,0 +1,508 @@
+// SPDX-FileCopyrightText: Copyright 2017 Citra Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include <array>
+#include <future>
+#include <QColor>
+#include <QDesktopServices>
+#include <QFutureWatcher>
+#include <QImage>
+#include <QList>
+#include <QLocale>
+#include <QMenu>
+#include <QMessageBox>
+#include <QMetaType>
+#include <QTime>
+#include <QUrl>
+#include <QtConcurrent/QtConcurrentRun>
+#include "common/logging/log.h"
+#include "network/announce_multiplayer_session.h"
+#include "ui_chat_room.h"
+#include "yuzu/game_list_p.h"
+#include "yuzu/multiplayer/chat_room.h"
+#include "yuzu/multiplayer/message.h"
+#ifdef ENABLE_WEB_SERVICE
+#include "web_service/web_backend.h"
+#endif
+
+class ChatMessage {
+public:
+ explicit ChatMessage(const Network::ChatEntry& chat, Network::RoomNetwork& room_network,
+ QTime ts = {}) {
+ /// Convert the time to their default locale defined format
+ QLocale locale;
+ timestamp = locale.toString(ts.isValid() ? ts : QTime::currentTime(), QLocale::ShortFormat);
+ nickname = QString::fromStdString(chat.nickname);
+ username = QString::fromStdString(chat.username);
+ message = QString::fromStdString(chat.message);
+
+ // Check for user pings
+ QString cur_nickname, cur_username;
+ if (auto room = room_network.GetRoomMember().lock()) {
+ cur_nickname = QString::fromStdString(room->GetNickname());
+ cur_username = QString::fromStdString(room->GetUsername());
+ }
+
+ // Handle pings at the beginning and end of message
+ QString fixed_message = QStringLiteral(" %1 ").arg(message);
+ if (fixed_message.contains(QStringLiteral(" @%1 ").arg(cur_nickname)) ||
+ (!cur_username.isEmpty() &&
+ fixed_message.contains(QStringLiteral(" @%1 ").arg(cur_username)))) {
+
+ contains_ping = true;
+ } else {
+ contains_ping = false;
+ }
+ }
+
+ bool ContainsPing() const {
+ return contains_ping;
+ }
+
+ /// Format the message using the players color
+ QString GetPlayerChatMessage(u16 player) const {
+ const bool is_dark_theme = QIcon::themeName().contains(QStringLiteral("dark")) ||
+ QIcon::themeName().contains(QStringLiteral("midnight"));
+ auto color =
+ is_dark_theme ? player_color_dark[player % 16] : player_color_default[player % 16];
+ QString name;
+ if (username.isEmpty() || username == nickname) {
+ name = nickname;
+ } else {
+ name = QStringLiteral("%1 (%2)").arg(nickname, username);
+ }
+
+ QString style, text_color;
+ if (ContainsPing()) {
+ // Add a background color to these messages
+ style = QStringLiteral("background-color: %1").arg(QString::fromStdString(ping_color));
+ // Add a font color
+ text_color = QStringLiteral("color='#000000'");
+ }
+
+ return QStringLiteral("[%1] <font color='%2'>&lt;%3&gt;</font> <font style='%4' "
+ "%5>%6</font>")
+ .arg(timestamp, QString::fromStdString(color), name.toHtmlEscaped(), style, text_color,
+ message.toHtmlEscaped());
+ }
+
+private:
+ static constexpr std::array<const char*, 16> player_color_default = {
+ {"#0000FF", "#FF0000", "#8A2BE2", "#FF69B4", "#1E90FF", "#008000", "#00FF7F", "#B22222",
+ "#DAA520", "#FF4500", "#2E8B57", "#5F9EA0", "#D2691E", "#9ACD32", "#FF7F50", "#FFFF00"}};
+ static constexpr std::array<const char*, 16> player_color_dark = {
+ {"#559AD1", "#4EC9A8", "#D69D85", "#C6C923", "#B975B5", "#D81F1F", "#7EAE39", "#4F8733",
+ "#F7CD8A", "#6FCACF", "#CE4897", "#8A2BE2", "#D2691E", "#9ACD32", "#FF7F50", "#152ccd"}};
+ static constexpr char ping_color[] = "#FFFF00";
+
+ QString timestamp;
+ QString nickname;
+ QString username;
+ QString message;
+ bool contains_ping;
+};
+
+class StatusMessage {
+public:
+ explicit StatusMessage(const QString& msg, QTime ts = {}) {
+ /// Convert the time to their default locale defined format
+ QLocale locale;
+ timestamp = locale.toString(ts.isValid() ? ts : QTime::currentTime(), QLocale::ShortFormat);
+ message = msg;
+ }
+
+ QString GetSystemChatMessage() const {
+ return QStringLiteral("[%1] <font color='%2'>* %3</font>")
+ .arg(timestamp, QString::fromStdString(system_color), message);
+ }
+
+private:
+ static constexpr const char system_color[] = "#FF8C00";
+ QString timestamp;
+ QString message;
+};
+
+class PlayerListItem : public QStandardItem {
+public:
+ static const int NicknameRole = Qt::UserRole + 1;
+ static const int UsernameRole = Qt::UserRole + 2;
+ static const int AvatarUrlRole = Qt::UserRole + 3;
+ static const int GameNameRole = Qt::UserRole + 4;
+ static const int GameVersionRole = Qt::UserRole + 5;
+
+ PlayerListItem() = default;
+ explicit PlayerListItem(const std::string& nickname, const std::string& username,
+ const std::string& avatar_url,
+ const AnnounceMultiplayerRoom::GameInfo& game_info) {
+ setEditable(false);
+ setData(QString::fromStdString(nickname), NicknameRole);
+ setData(QString::fromStdString(username), UsernameRole);
+ setData(QString::fromStdString(avatar_url), AvatarUrlRole);
+ if (game_info.name.empty()) {
+ setData(QObject::tr("Not playing a game"), GameNameRole);
+ } else {
+ setData(QString::fromStdString(game_info.name), GameNameRole);
+ }
+ setData(QString::fromStdString(game_info.version), GameVersionRole);
+ }
+
+ QVariant data(int role) const override {
+ if (role != Qt::DisplayRole) {
+ return QStandardItem::data(role);
+ }
+ QString name;
+ const QString nickname = data(NicknameRole).toString();
+ const QString username = data(UsernameRole).toString();
+ if (username.isEmpty() || username == nickname) {
+ name = nickname;
+ } else {
+ name = QStringLiteral("%1 (%2)").arg(nickname, username);
+ }
+ const QString version = data(GameVersionRole).toString();
+ QString version_string;
+ if (!version.isEmpty()) {
+ version_string = QStringLiteral("(%1)").arg(version);
+ }
+ return QStringLiteral("%1\n %2 %3")
+ .arg(name, data(GameNameRole).toString(), version_string);
+ }
+};
+
+ChatRoom::ChatRoom(QWidget* parent) : QWidget(parent), ui(std::make_unique<Ui::ChatRoom>()) {
+ ui->setupUi(this);
+
+ // set the item_model for player_view
+
+ player_list = new QStandardItemModel(ui->player_view);
+ ui->player_view->setModel(player_list);
+ ui->player_view->setContextMenuPolicy(Qt::CustomContextMenu);
+ // set a header to make it look better though there is only one column
+ player_list->insertColumns(0, 1);
+ player_list->setHeaderData(0, Qt::Horizontal, tr("Members"));
+
+ ui->chat_history->document()->setMaximumBlockCount(max_chat_lines);
+
+ auto font = ui->chat_history->font();
+ font.setPointSizeF(10);
+ ui->chat_history->setFont(font);
+
+ // register the network structs to use in slots and signals
+ qRegisterMetaType<Network::ChatEntry>();
+ qRegisterMetaType<Network::StatusMessageEntry>();
+ qRegisterMetaType<Network::RoomInformation>();
+ qRegisterMetaType<Network::RoomMember::State>();
+
+ // Connect all the widgets to the appropriate events
+ connect(ui->player_view, &QTreeView::customContextMenuRequested, this,
+ &ChatRoom::PopupContextMenu);
+ connect(ui->chat_message, &QLineEdit::returnPressed, this, &ChatRoom::OnSendChat);
+ connect(ui->chat_message, &QLineEdit::textChanged, this, &ChatRoom::OnChatTextChanged);
+ connect(ui->send_message, &QPushButton::clicked, this, &ChatRoom::OnSendChat);
+}
+
+ChatRoom::~ChatRoom() = default;
+
+void ChatRoom::Initialize(Network::RoomNetwork* room_network_) {
+ room_network = room_network_;
+ // setup the callbacks for network updates
+ if (auto member = room_network->GetRoomMember().lock()) {
+ member->BindOnChatMessageRecieved(
+ [this](const Network::ChatEntry& chat) { emit ChatReceived(chat); });
+ member->BindOnStatusMessageReceived(
+ [this](const Network::StatusMessageEntry& status_message) {
+ emit StatusMessageReceived(status_message);
+ });
+ connect(this, &ChatRoom::ChatReceived, this, &ChatRoom::OnChatReceive);
+ connect(this, &ChatRoom::StatusMessageReceived, this, &ChatRoom::OnStatusMessageReceive);
+ }
+}
+
+void ChatRoom::SetModPerms(bool is_mod) {
+ has_mod_perms = is_mod;
+}
+
+void ChatRoom::RetranslateUi() {
+ ui->retranslateUi(this);
+}
+
+void ChatRoom::Clear() {
+ ui->chat_history->clear();
+ block_list.clear();
+}
+
+void ChatRoom::AppendStatusMessage(const QString& msg) {
+ ui->chat_history->append(StatusMessage(msg).GetSystemChatMessage());
+}
+
+void ChatRoom::AppendChatMessage(const QString& msg) {
+ ui->chat_history->append(msg);
+}
+
+void ChatRoom::SendModerationRequest(Network::RoomMessageTypes type, const std::string& nickname) {
+ if (auto room = room_network->GetRoomMember().lock()) {
+ auto members = room->GetMemberInformation();
+ auto it = std::find_if(members.begin(), members.end(),
+ [&nickname](const Network::RoomMember::MemberInformation& member) {
+ return member.nickname == nickname;
+ });
+ if (it == members.end()) {
+ NetworkMessage::ErrorManager::ShowError(NetworkMessage::ErrorManager::NO_SUCH_USER);
+ return;
+ }
+ room->SendModerationRequest(type, nickname);
+ }
+}
+
+bool ChatRoom::ValidateMessage(const std::string& msg) {
+ return !msg.empty();
+}
+
+void ChatRoom::OnRoomUpdate(const Network::RoomInformation& info) {
+ // TODO(B3N30): change title
+ if (auto room_member = room_network->GetRoomMember().lock()) {
+ SetPlayerList(room_member->GetMemberInformation());
+ }
+}
+
+void ChatRoom::Disable() {
+ ui->send_message->setDisabled(true);
+ ui->chat_message->setDisabled(true);
+}
+
+void ChatRoom::Enable() {
+ ui->send_message->setEnabled(true);
+ ui->chat_message->setEnabled(true);
+}
+
+void ChatRoom::OnChatReceive(const Network::ChatEntry& chat) {
+ if (!ValidateMessage(chat.message)) {
+ return;
+ }
+ if (auto room = room_network->GetRoomMember().lock()) {
+ // get the id of the player
+ auto members = room->GetMemberInformation();
+ auto it = std::find_if(members.begin(), members.end(),
+ [&chat](const Network::RoomMember::MemberInformation& member) {
+ return member.nickname == chat.nickname &&
+ member.username == chat.username;
+ });
+ if (it == members.end()) {
+ LOG_INFO(Network, "Chat message received from unknown player. Ignoring it.");
+ return;
+ }
+ if (block_list.count(chat.nickname)) {
+ LOG_INFO(Network, "Chat message received from blocked player {}. Ignoring it.",
+ chat.nickname);
+ return;
+ }
+ auto player = std::distance(members.begin(), it);
+ ChatMessage m(chat, *room_network);
+ if (m.ContainsPing()) {
+ emit UserPinged();
+ }
+ AppendChatMessage(m.GetPlayerChatMessage(player));
+ }
+}
+
+void ChatRoom::OnStatusMessageReceive(const Network::StatusMessageEntry& status_message) {
+ QString name;
+ if (status_message.username.empty() || status_message.username == status_message.nickname) {
+ name = QString::fromStdString(status_message.nickname);
+ } else {
+ name = QStringLiteral("%1 (%2)").arg(QString::fromStdString(status_message.nickname),
+ QString::fromStdString(status_message.username));
+ }
+ QString message;
+ switch (status_message.type) {
+ case Network::IdMemberJoin:
+ message = tr("%1 has joined").arg(name);
+ break;
+ case Network::IdMemberLeave:
+ message = tr("%1 has left").arg(name);
+ break;
+ case Network::IdMemberKicked:
+ message = tr("%1 has been kicked").arg(name);
+ break;
+ case Network::IdMemberBanned:
+ message = tr("%1 has been banned").arg(name);
+ break;
+ case Network::IdAddressUnbanned:
+ message = tr("%1 has been unbanned").arg(name);
+ break;
+ }
+ if (!message.isEmpty())
+ AppendStatusMessage(message);
+}
+
+void ChatRoom::OnSendChat() {
+ if (auto room_member = room_network->GetRoomMember().lock()) {
+ if (!room_member->IsConnected()) {
+ return;
+ }
+ auto message = ui->chat_message->text().toStdString();
+ if (!ValidateMessage(message)) {
+ return;
+ }
+ auto nick = room_member->GetNickname();
+ auto username = room_member->GetUsername();
+ Network::ChatEntry chat{nick, username, message};
+
+ auto members = room_member->GetMemberInformation();
+ auto it = std::find_if(members.begin(), members.end(),
+ [&chat](const Network::RoomMember::MemberInformation& member) {
+ return member.nickname == chat.nickname &&
+ member.username == chat.username;
+ });
+ if (it == members.end()) {
+ LOG_INFO(Network, "Cannot find self in the player list when sending a message.");
+ }
+ auto player = std::distance(members.begin(), it);
+ ChatMessage m(chat, *room_network);
+ room_member->SendChatMessage(message);
+ AppendChatMessage(m.GetPlayerChatMessage(player));
+ ui->chat_message->clear();
+ }
+}
+
+void ChatRoom::UpdateIconDisplay() {
+ for (int row = 0; row < player_list->invisibleRootItem()->rowCount(); ++row) {
+ QStandardItem* item = player_list->invisibleRootItem()->child(row);
+ const std::string avatar_url =
+ item->data(PlayerListItem::AvatarUrlRole).toString().toStdString();
+ if (icon_cache.count(avatar_url)) {
+ item->setData(icon_cache.at(avatar_url), Qt::DecorationRole);
+ } else {
+ item->setData(QIcon::fromTheme(QStringLiteral("no_avatar")).pixmap(48),
+ Qt::DecorationRole);
+ }
+ }
+}
+
+void ChatRoom::SetPlayerList(const Network::RoomMember::MemberList& member_list) {
+ // TODO(B3N30): Remember which row is selected
+ player_list->removeRows(0, player_list->rowCount());
+ for (const auto& member : member_list) {
+ if (member.nickname.empty())
+ continue;
+ QStandardItem* name_item = new PlayerListItem(member.nickname, member.username,
+ member.avatar_url, member.game_info);
+
+#ifdef ENABLE_WEB_SERVICE
+ if (!icon_cache.count(member.avatar_url) && !member.avatar_url.empty()) {
+ // Start a request to get the member's avatar
+ const QUrl url(QString::fromStdString(member.avatar_url));
+ QFuture<std::string> future = QtConcurrent::run([url] {
+ WebService::Client client(
+ QStringLiteral("%1://%2").arg(url.scheme(), url.host()).toStdString(), "", "");
+ auto result = client.GetImage(url.path().toStdString(), true);
+ if (result.returned_data.empty()) {
+ LOG_ERROR(WebService, "Failed to get avatar");
+ }
+ return result.returned_data;
+ });
+ auto* future_watcher = new QFutureWatcher<std::string>(this);
+ connect(future_watcher, &QFutureWatcher<std::string>::finished, this,
+ [this, future_watcher, avatar_url = member.avatar_url] {
+ const std::string result = future_watcher->result();
+ if (result.empty())
+ return;
+ QPixmap pixmap;
+ if (!pixmap.loadFromData(reinterpret_cast<const u8*>(result.data()),
+ static_cast<uint>(result.size())))
+ return;
+ icon_cache[avatar_url] =
+ pixmap.scaled(48, 48, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
+ // Update all the displayed icons with the new icon_cache
+ UpdateIconDisplay();
+ });
+ future_watcher->setFuture(future);
+ }
+#endif
+
+ player_list->invisibleRootItem()->appendRow(name_item);
+ }
+ UpdateIconDisplay();
+ // TODO(B3N30): Restore row selection
+}
+
+void ChatRoom::OnChatTextChanged() {
+ if (ui->chat_message->text().length() > static_cast<int>(Network::MaxMessageSize))
+ ui->chat_message->setText(
+ ui->chat_message->text().left(static_cast<int>(Network::MaxMessageSize)));
+}
+
+void ChatRoom::PopupContextMenu(const QPoint& menu_location) {
+ QModelIndex item = ui->player_view->indexAt(menu_location);
+ if (!item.isValid())
+ return;
+
+ std::string nickname =
+ player_list->item(item.row())->data(PlayerListItem::NicknameRole).toString().toStdString();
+
+ QMenu context_menu;
+
+ QString username = player_list->item(item.row())->data(PlayerListItem::UsernameRole).toString();
+ if (!username.isEmpty()) {
+ QAction* view_profile_action = context_menu.addAction(tr("View Profile"));
+ connect(view_profile_action, &QAction::triggered, [username] {
+ QDesktopServices::openUrl(
+ QUrl(QStringLiteral("https://community.citra-emu.org/u/%1").arg(username)));
+ });
+ }
+
+ std::string cur_nickname;
+ if (auto room = room_network->GetRoomMember().lock()) {
+ cur_nickname = room->GetNickname();
+ }
+
+ if (nickname != cur_nickname) { // You can't block yourself
+ QAction* block_action = context_menu.addAction(tr("Block Player"));
+
+ block_action->setCheckable(true);
+ block_action->setChecked(block_list.count(nickname) > 0);
+
+ connect(block_action, &QAction::triggered, [this, nickname] {
+ if (block_list.count(nickname)) {
+ block_list.erase(nickname);
+ } else {
+ QMessageBox::StandardButton result = QMessageBox::question(
+ this, tr("Block Player"),
+ tr("When you block a player, you will no longer receive chat messages from "
+ "them.<br><br>Are you sure you would like to block %1?")
+ .arg(QString::fromStdString(nickname)),
+ QMessageBox::Yes | QMessageBox::No);
+ if (result == QMessageBox::Yes)
+ block_list.emplace(nickname);
+ }
+ });
+ }
+
+ if (has_mod_perms && nickname != cur_nickname) { // You can't kick or ban yourself
+ context_menu.addSeparator();
+
+ QAction* kick_action = context_menu.addAction(tr("Kick"));
+ QAction* ban_action = context_menu.addAction(tr("Ban"));
+
+ connect(kick_action, &QAction::triggered, [this, nickname] {
+ QMessageBox::StandardButton result =
+ QMessageBox::question(this, tr("Kick Player"),
+ tr("Are you sure you would like to <b>kick</b> %1?")
+ .arg(QString::fromStdString(nickname)),
+ QMessageBox::Yes | QMessageBox::No);
+ if (result == QMessageBox::Yes)
+ SendModerationRequest(Network::IdModKick, nickname);
+ });
+ connect(ban_action, &QAction::triggered, [this, nickname] {
+ QMessageBox::StandardButton result = QMessageBox::question(
+ this, tr("Ban Player"),
+ tr("Are you sure you would like to <b>kick and ban</b> %1?\n\nThis would "
+ "ban both their forum username and their IP address.")
+ .arg(QString::fromStdString(nickname)),
+ QMessageBox::Yes | QMessageBox::No);
+ if (result == QMessageBox::Yes)
+ SendModerationRequest(Network::IdModBan, nickname);
+ });
+ }
+
+ context_menu.exec(ui->player_view->viewport()->mapToGlobal(menu_location));
+}
diff --git a/src/yuzu/multiplayer/chat_room.h b/src/yuzu/multiplayer/chat_room.h
new file mode 100644
index 000000000..01c70fad0
--- /dev/null
+++ b/src/yuzu/multiplayer/chat_room.h
@@ -0,0 +1,75 @@
+// SPDX-FileCopyrightText: Copyright 2017 Citra Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+#include <memory>
+#include <unordered_set>
+#include <QDialog>
+#include <QSortFilterProxyModel>
+#include <QStandardItemModel>
+#include <QVariant>
+#include "network/network.h"
+
+namespace Ui {
+class ChatRoom;
+}
+
+namespace Core {
+class AnnounceMultiplayerSession;
+}
+
+class ConnectionError;
+class ComboBoxProxyModel;
+
+class ChatMessage;
+
+class ChatRoom : public QWidget {
+ Q_OBJECT
+
+public:
+ explicit ChatRoom(QWidget* parent);
+ void Initialize(Network::RoomNetwork* room_network);
+ void RetranslateUi();
+ void SetPlayerList(const Network::RoomMember::MemberList& member_list);
+ void Clear();
+ void AppendStatusMessage(const QString& msg);
+ ~ChatRoom();
+
+ void SetModPerms(bool is_mod);
+ void UpdateIconDisplay();
+
+public slots:
+ void OnRoomUpdate(const Network::RoomInformation& info);
+ void OnChatReceive(const Network::ChatEntry&);
+ void OnStatusMessageReceive(const Network::StatusMessageEntry&);
+ void OnSendChat();
+ void OnChatTextChanged();
+ void PopupContextMenu(const QPoint& menu_location);
+ void Disable();
+ void Enable();
+
+signals:
+ void ChatReceived(const Network::ChatEntry&);
+ void StatusMessageReceived(const Network::StatusMessageEntry&);
+ void UserPinged();
+
+private:
+ static constexpr u32 max_chat_lines = 1000;
+ void AppendChatMessage(const QString&);
+ bool ValidateMessage(const std::string&);
+ void SendModerationRequest(Network::RoomMessageTypes type, const std::string& nickname);
+
+ bool has_mod_perms = false;
+ QStandardItemModel* player_list;
+ std::unique_ptr<Ui::ChatRoom> ui;
+ std::unordered_set<std::string> block_list;
+ std::unordered_map<std::string, QPixmap> icon_cache;
+ Network::RoomNetwork* room_network;
+};
+
+Q_DECLARE_METATYPE(Network::ChatEntry);
+Q_DECLARE_METATYPE(Network::StatusMessageEntry);
+Q_DECLARE_METATYPE(Network::RoomInformation);
+Q_DECLARE_METATYPE(Network::RoomMember::State);
+Q_DECLARE_METATYPE(Network::RoomMember::Error);
diff --git a/src/yuzu/multiplayer/chat_room.ui b/src/yuzu/multiplayer/chat_room.ui
new file mode 100644
index 000000000..f2b31b5da
--- /dev/null
+++ b/src/yuzu/multiplayer/chat_room.ui
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>ChatRoom</class>
+ <widget class="QWidget" name="ChatRoom">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>807</width>
+ <height>432</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Room Window</string>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QTreeView" name="player_view"/>
+ </item>
+ <item>
+ <layout class="QVBoxLayout" name="verticalLayout_4">
+ <item>
+ <widget class="QTextEdit" name="chat_history">
+ <property name="undoRedoEnabled">
+ <bool>false</bool>
+ </property>
+ <property name="readOnly">
+ <bool>true</bool>
+ </property>
+ <property name="textInteractionFlags">
+ <set>Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_3">
+ <item>
+ <widget class="QLineEdit" name="chat_message">
+ <property name="placeholderText">
+ <string>Send Chat Message</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="send_message">
+ <property name="text">
+ <string>Send Message</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/src/yuzu/multiplayer/client_room.cpp b/src/yuzu/multiplayer/client_room.cpp
new file mode 100644
index 000000000..caf34a414
--- /dev/null
+++ b/src/yuzu/multiplayer/client_room.cpp
@@ -0,0 +1,115 @@
+// SPDX-FileCopyrightText: Copyright 2017 Citra Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include <future>
+#include <QColor>
+#include <QImage>
+#include <QList>
+#include <QLocale>
+#include <QMetaType>
+#include <QTime>
+#include <QtConcurrent/QtConcurrentRun>
+#include "common/logging/log.h"
+#include "network/announce_multiplayer_session.h"
+#include "ui_client_room.h"
+#include "yuzu/game_list_p.h"
+#include "yuzu/multiplayer/client_room.h"
+#include "yuzu/multiplayer/message.h"
+#include "yuzu/multiplayer/moderation_dialog.h"
+#include "yuzu/multiplayer/state.h"
+
+ClientRoomWindow::ClientRoomWindow(QWidget* parent, Network::RoomNetwork& room_network_)
+ : QDialog(parent, Qt::WindowTitleHint | Qt::WindowCloseButtonHint | Qt::WindowSystemMenuHint),
+ ui(std::make_unique<Ui::ClientRoom>()), room_network{room_network_} {
+ ui->setupUi(this);
+ ui->chat->Initialize(&room_network);
+
+ // setup the callbacks for network updates
+ if (auto member = room_network.GetRoomMember().lock()) {
+ member->BindOnRoomInformationChanged(
+ [this](const Network::RoomInformation& info) { emit RoomInformationChanged(info); });
+ member->BindOnStateChanged(
+ [this](const Network::RoomMember::State& state) { emit StateChanged(state); });
+
+ connect(this, &ClientRoomWindow::RoomInformationChanged, this,
+ &ClientRoomWindow::OnRoomUpdate);
+ connect(this, &ClientRoomWindow::StateChanged, this, &::ClientRoomWindow::OnStateChange);
+ // Update the state
+ OnStateChange(member->GetState());
+ } else {
+ // TODO (jroweboy) network was not initialized?
+ }
+
+ connect(ui->disconnect, &QPushButton::clicked, this, &ClientRoomWindow::Disconnect);
+ ui->disconnect->setDefault(false);
+ ui->disconnect->setAutoDefault(false);
+ connect(ui->moderation, &QPushButton::clicked, [this] {
+ ModerationDialog dialog(room_network, this);
+ dialog.exec();
+ });
+ ui->moderation->setDefault(false);
+ ui->moderation->setAutoDefault(false);
+ connect(ui->chat, &ChatRoom::UserPinged, this, &ClientRoomWindow::ShowNotification);
+ UpdateView();
+}
+
+ClientRoomWindow::~ClientRoomWindow() = default;
+
+void ClientRoomWindow::SetModPerms(bool is_mod) {
+ ui->chat->SetModPerms(is_mod);
+ ui->moderation->setVisible(is_mod);
+ ui->moderation->setDefault(false);
+ ui->moderation->setAutoDefault(false);
+}
+
+void ClientRoomWindow::RetranslateUi() {
+ ui->retranslateUi(this);
+ ui->chat->RetranslateUi();
+}
+
+void ClientRoomWindow::OnRoomUpdate(const Network::RoomInformation& info) {
+ UpdateView();
+}
+
+void ClientRoomWindow::OnStateChange(const Network::RoomMember::State& state) {
+ if (state == Network::RoomMember::State::Joined ||
+ state == Network::RoomMember::State::Moderator) {
+ ui->chat->Clear();
+ ui->chat->AppendStatusMessage(tr("Connected"));
+ SetModPerms(state == Network::RoomMember::State::Moderator);
+ }
+ UpdateView();
+}
+
+void ClientRoomWindow::Disconnect() {
+ auto parent = static_cast<MultiplayerState*>(parentWidget());
+ if (parent->OnCloseRoom()) {
+ ui->chat->AppendStatusMessage(tr("Disconnected"));
+ close();
+ }
+}
+
+void ClientRoomWindow::UpdateView() {
+ if (auto member = room_network.GetRoomMember().lock()) {
+ if (member->IsConnected()) {
+ ui->chat->Enable();
+ ui->disconnect->setEnabled(true);
+ auto memberlist = member->GetMemberInformation();
+ ui->chat->SetPlayerList(memberlist);
+ const auto information = member->GetRoomInformation();
+ setWindowTitle(QString(tr("%1 - %2 (%3/%4 members) - connected"))
+ .arg(QString::fromStdString(information.name))
+ .arg(QString::fromStdString(information.preferred_game.name))
+ .arg(memberlist.size())
+ .arg(information.member_slots));
+ ui->description->setText(QString::fromStdString(information.description));
+ return;
+ }
+ }
+ // TODO(B3N30): can't get RoomMember*, show error and close window
+ close();
+}
+
+void ClientRoomWindow::UpdateIconDisplay() {
+ ui->chat->UpdateIconDisplay();
+}
diff --git a/src/yuzu/multiplayer/client_room.h b/src/yuzu/multiplayer/client_room.h
new file mode 100644
index 000000000..f338e3c59
--- /dev/null
+++ b/src/yuzu/multiplayer/client_room.h
@@ -0,0 +1,39 @@
+// SPDX-FileCopyrightText: Copyright 2017 Citra Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+#include "yuzu/multiplayer/chat_room.h"
+
+namespace Ui {
+class ClientRoom;
+}
+
+class ClientRoomWindow : public QDialog {
+ Q_OBJECT
+
+public:
+ explicit ClientRoomWindow(QWidget* parent, Network::RoomNetwork& room_network_);
+ ~ClientRoomWindow();
+
+ void RetranslateUi();
+ void UpdateIconDisplay();
+
+public slots:
+ void OnRoomUpdate(const Network::RoomInformation&);
+ void OnStateChange(const Network::RoomMember::State&);
+
+signals:
+ void RoomInformationChanged(const Network::RoomInformation&);
+ void StateChanged(const Network::RoomMember::State&);
+ void ShowNotification();
+
+private:
+ void Disconnect();
+ void UpdateView();
+ void SetModPerms(bool is_mod);
+
+ QStandardItemModel* player_list;
+ std::unique_ptr<Ui::ClientRoom> ui;
+ Network::RoomNetwork& room_network;
+};
diff --git a/src/yuzu/multiplayer/client_room.ui b/src/yuzu/multiplayer/client_room.ui
new file mode 100644
index 000000000..97e88b502
--- /dev/null
+++ b/src/yuzu/multiplayer/client_room.ui
@@ -0,0 +1,80 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>ClientRoom</class>
+ <widget class="QWidget" name="ClientRoom">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>807</width>
+ <height>432</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Room Window</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <layout class="QVBoxLayout" name="verticalLayout_3">
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <property name="rightMargin">
+ <number>0</number>
+ </property>
+ <item>
+ <widget class="QLabel" name="description">
+ <property name="text">
+ <string>Room Description</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="moderation">
+ <property name="text">
+ <string>Moderation...</string>
+ </property>
+ <property name="visible">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="disconnect">
+ <property name="text">
+ <string>Leave Room</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="ChatRoom" name="chat" native="true"/>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <customwidgets>
+ <customwidget>
+ <class>ChatRoom</class>
+ <extends>QWidget</extends>
+ <header>multiplayer/chat_room.h</header>
+ <container>1</container>
+ </customwidget>
+ </customwidgets>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/src/yuzu/multiplayer/direct_connect.cpp b/src/yuzu/multiplayer/direct_connect.cpp
new file mode 100644
index 000000000..10bf0a4fb
--- /dev/null
+++ b/src/yuzu/multiplayer/direct_connect.cpp
@@ -0,0 +1,143 @@
+// SPDX-FileCopyrightText: Copyright 2017 Citra Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include <QComboBox>
+#include <QFuture>
+#include <QIntValidator>
+#include <QRegExpValidator>
+#include <QString>
+#include <QtConcurrent/QtConcurrentRun>
+#include "common/settings.h"
+#include "core/core.h"
+#include "core/internal_network/network_interface.h"
+#include "network/network.h"
+#include "ui_direct_connect.h"
+#include "yuzu/main.h"
+#include "yuzu/multiplayer/client_room.h"
+#include "yuzu/multiplayer/direct_connect.h"
+#include "yuzu/multiplayer/message.h"
+#include "yuzu/multiplayer/state.h"
+#include "yuzu/multiplayer/validation.h"
+#include "yuzu/uisettings.h"
+
+enum class ConnectionType : u8 { TraversalServer, IP };
+
+DirectConnectWindow::DirectConnectWindow(Core::System& system_, QWidget* parent)
+ : QDialog(parent, Qt::WindowTitleHint | Qt::WindowCloseButtonHint | Qt::WindowSystemMenuHint),
+ ui(std::make_unique<Ui::DirectConnect>()), system{system_}, room_network{
+ system.GetRoomNetwork()} {
+
+ ui->setupUi(this);
+
+ // setup the watcher for background connections
+ watcher = new QFutureWatcher<void>;
+ connect(watcher, &QFutureWatcher<void>::finished, this, &DirectConnectWindow::OnConnection);
+
+ ui->nickname->setValidator(validation.GetNickname());
+ ui->nickname->setText(UISettings::values.multiplayer_nickname.GetValue());
+ if (ui->nickname->text().isEmpty() && !Settings::values.yuzu_username.GetValue().empty()) {
+ // Use yuzu Web Service user name as nickname by default
+ ui->nickname->setText(QString::fromStdString(Settings::values.yuzu_username.GetValue()));
+ }
+ ui->ip->setValidator(validation.GetIP());
+ ui->ip->setText(UISettings::values.multiplayer_ip.GetValue());
+ ui->port->setValidator(validation.GetPort());
+ ui->port->setText(QString::number(UISettings::values.multiplayer_port.GetValue()));
+
+ // TODO(jroweboy): Show or hide the connection options based on the current value of the combo
+ // box. Add this back in when the traversal server support is added.
+ connect(ui->connect, &QPushButton::clicked, this, &DirectConnectWindow::Connect);
+}
+
+DirectConnectWindow::~DirectConnectWindow() = default;
+
+void DirectConnectWindow::RetranslateUi() {
+ ui->retranslateUi(this);
+}
+
+void DirectConnectWindow::Connect() {
+ if (!Network::GetSelectedNetworkInterface()) {
+ NetworkMessage::ErrorManager::ShowError(
+ NetworkMessage::ErrorManager::NO_INTERFACE_SELECTED);
+ return;
+ }
+ if (!ui->nickname->hasAcceptableInput()) {
+ NetworkMessage::ErrorManager::ShowError(NetworkMessage::ErrorManager::USERNAME_NOT_VALID);
+ return;
+ }
+ if (system.IsPoweredOn()) {
+ if (!NetworkMessage::WarnGameRunning()) {
+ return;
+ }
+ }
+ if (const auto member = room_network.GetRoomMember().lock()) {
+ // Prevent the user from trying to join a room while they are already joining.
+ if (member->GetState() == Network::RoomMember::State::Joining) {
+ return;
+ } else if (member->IsConnected()) {
+ // And ask if they want to leave the room if they are already in one.
+ if (!NetworkMessage::WarnDisconnect()) {
+ return;
+ }
+ }
+ }
+ switch (static_cast<ConnectionType>(ui->connection_type->currentIndex())) {
+ case ConnectionType::TraversalServer:
+ break;
+ case ConnectionType::IP:
+ if (!ui->ip->hasAcceptableInput()) {
+ NetworkMessage::ErrorManager::ShowError(
+ NetworkMessage::ErrorManager::IP_ADDRESS_NOT_VALID);
+ return;
+ }
+ if (!ui->port->hasAcceptableInput()) {
+ NetworkMessage::ErrorManager::ShowError(NetworkMessage::ErrorManager::PORT_NOT_VALID);
+ return;
+ }
+ break;
+ }
+
+ // Store settings
+ UISettings::values.multiplayer_nickname = ui->nickname->text();
+ UISettings::values.multiplayer_ip = ui->ip->text();
+ if (ui->port->isModified() && !ui->port->text().isEmpty()) {
+ UISettings::values.multiplayer_port = ui->port->text().toInt();
+ } else {
+ UISettings::values.multiplayer_port = UISettings::values.multiplayer_port.GetDefault();
+ }
+
+ emit SaveConfig();
+
+ // attempt to connect in a different thread
+ QFuture<void> f = QtConcurrent::run([&] {
+ if (auto room_member = room_network.GetRoomMember().lock()) {
+ auto port = UISettings::values.multiplayer_port.GetValue();
+ room_member->Join(ui->nickname->text().toStdString(),
+ ui->ip->text().toStdString().c_str(), port, 0, Network::NoPreferredIP,
+ ui->password->text().toStdString().c_str());
+ }
+ });
+ watcher->setFuture(f);
+ // and disable widgets and display a connecting while we wait
+ BeginConnecting();
+}
+
+void DirectConnectWindow::BeginConnecting() {
+ ui->connect->setEnabled(false);
+ ui->connect->setText(tr("Connecting"));
+}
+
+void DirectConnectWindow::EndConnecting() {
+ ui->connect->setEnabled(true);
+ ui->connect->setText(tr("Connect"));
+}
+
+void DirectConnectWindow::OnConnection() {
+ EndConnecting();
+
+ if (auto room_member = room_network.GetRoomMember().lock()) {
+ if (room_member->IsConnected()) {
+ close();
+ }
+ }
+}
diff --git a/src/yuzu/multiplayer/direct_connect.h b/src/yuzu/multiplayer/direct_connect.h
new file mode 100644
index 000000000..b8f66cfb2
--- /dev/null
+++ b/src/yuzu/multiplayer/direct_connect.h
@@ -0,0 +1,49 @@
+// SPDX-FileCopyrightText: Copyright 2017 Citra Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+#include <memory>
+#include <QDialog>
+#include <QFutureWatcher>
+#include "yuzu/multiplayer/validation.h"
+
+namespace Ui {
+class DirectConnect;
+}
+
+namespace Core {
+class System;
+}
+
+class DirectConnectWindow : public QDialog {
+ Q_OBJECT
+
+public:
+ explicit DirectConnectWindow(Core::System& system_, QWidget* parent = nullptr);
+ ~DirectConnectWindow();
+
+ void RetranslateUi();
+
+signals:
+ /**
+ * Signalled by this widget when it is closing itself and destroying any state such as
+ * connections that it might have.
+ */
+ void Closed();
+ void SaveConfig();
+
+private slots:
+ void OnConnection();
+
+private:
+ void Connect();
+ void BeginConnecting();
+ void EndConnecting();
+
+ QFutureWatcher<void>* watcher;
+ std::unique_ptr<Ui::DirectConnect> ui;
+ Validation validation;
+ Core::System& system;
+ Network::RoomNetwork& room_network;
+};
diff --git a/src/yuzu/multiplayer/direct_connect.ui b/src/yuzu/multiplayer/direct_connect.ui
new file mode 100644
index 000000000..57d6ec25a
--- /dev/null
+++ b/src/yuzu/multiplayer/direct_connect.ui
@@ -0,0 +1,168 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>DirectConnect</class>
+ <widget class="QWidget" name="DirectConnect">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>455</width>
+ <height>161</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Direct Connect</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <layout class="QVBoxLayout" name="verticalLayout_3">
+ <item>
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <property name="spacing">
+ <number>0</number>
+ </property>
+ <property name="leftMargin">
+ <number>0</number>
+ </property>
+ <item>
+ <widget class="QComboBox" name="connection_type">
+ <item>
+ <property name="text">
+ <string>IP Address</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ <item>
+ <widget class="QWidget" name="ip_container" native="true">
+ <layout class="QHBoxLayout" name="ip_layout">
+ <property name="leftMargin">
+ <number>5</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_2">
+ <property name="text">
+ <string>IP</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="ip">
+ <property name="toolTip">
+ <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;IPv4 address of the host&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+ </property>
+ <property name="maxLength">
+ <number>16</number>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="label_3">
+ <property name="text">
+ <string>Port</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="port">
+ <property name="toolTip">
+ <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Port number the host is listening on&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+ </property>
+ <property name="maxLength">
+ <number>5</number>
+ </property>
+ <property name="placeholderText">
+ <string notr="true" extracomment="placeholder string that tells user default port">24872</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <item>
+ <widget class="QLabel" name="label_5">
+ <property name="text">
+ <string>Nickname</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="nickname">
+ <property name="maxLength">
+ <number>20</number>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Password</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="password"/>
+ </item>
+ </layout>
+ </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>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_3">
+ <item>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="connect">
+ <property name="text">
+ <string>Connect</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/src/yuzu/multiplayer/host_room.cpp b/src/yuzu/multiplayer/host_room.cpp
new file mode 100644
index 000000000..a8faa5b24
--- /dev/null
+++ b/src/yuzu/multiplayer/host_room.cpp
@@ -0,0 +1,260 @@
+// SPDX-FileCopyrightText: Copyright 2017 Citra Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include <future>
+#include <QColor>
+#include <QImage>
+#include <QList>
+#include <QLocale>
+#include <QMessageBox>
+#include <QMetaType>
+#include <QTime>
+#include <QtConcurrent/QtConcurrentRun>
+#include "common/logging/log.h"
+#include "common/settings.h"
+#include "core/core.h"
+#include "core/internal_network/network_interface.h"
+#include "network/announce_multiplayer_session.h"
+#include "ui_host_room.h"
+#include "yuzu/game_list_p.h"
+#include "yuzu/main.h"
+#include "yuzu/multiplayer/host_room.h"
+#include "yuzu/multiplayer/message.h"
+#include "yuzu/multiplayer/state.h"
+#include "yuzu/multiplayer/validation.h"
+#include "yuzu/uisettings.h"
+#ifdef ENABLE_WEB_SERVICE
+#include "web_service/verify_user_jwt.h"
+#endif
+
+HostRoomWindow::HostRoomWindow(QWidget* parent, QStandardItemModel* list,
+ std::shared_ptr<Core::AnnounceMultiplayerSession> session,
+ Core::System& system_)
+ : QDialog(parent, Qt::WindowTitleHint | Qt::WindowCloseButtonHint | Qt::WindowSystemMenuHint),
+ ui(std::make_unique<Ui::HostRoom>()),
+ announce_multiplayer_session(session), system{system_}, room_network{
+ system.GetRoomNetwork()} {
+ ui->setupUi(this);
+
+ // set up validation for all of the fields
+ ui->room_name->setValidator(validation.GetRoomName());
+ ui->username->setValidator(validation.GetNickname());
+ ui->port->setValidator(validation.GetPort());
+ ui->port->setPlaceholderText(QString::number(Network::DefaultRoomPort));
+
+ // Create a proxy to the game list to display the list of preferred games
+ game_list = new QStandardItemModel;
+ UpdateGameList(list);
+
+ proxy = new ComboBoxProxyModel;
+ proxy->setSourceModel(game_list);
+ proxy->sort(0, Qt::AscendingOrder);
+ ui->game_list->setModel(proxy);
+
+ // Connect all the widgets to the appropriate events
+ connect(ui->host, &QPushButton::clicked, this, &HostRoomWindow::Host);
+
+ // Restore the settings:
+ ui->username->setText(UISettings::values.multiplayer_room_nickname.GetValue());
+ if (ui->username->text().isEmpty() && !Settings::values.yuzu_username.GetValue().empty()) {
+ // Use yuzu Web Service user name as nickname by default
+ ui->username->setText(QString::fromStdString(Settings::values.yuzu_username.GetValue()));
+ }
+ ui->room_name->setText(UISettings::values.multiplayer_room_name.GetValue());
+ ui->port->setText(QString::number(UISettings::values.multiplayer_room_port.GetValue()));
+ ui->max_player->setValue(UISettings::values.multiplayer_max_player.GetValue());
+ int index = UISettings::values.multiplayer_host_type.GetValue();
+ if (index < ui->host_type->count()) {
+ ui->host_type->setCurrentIndex(index);
+ }
+ index = ui->game_list->findData(UISettings::values.multiplayer_game_id.GetValue(),
+ GameListItemPath::ProgramIdRole);
+ if (index != -1) {
+ ui->game_list->setCurrentIndex(index);
+ }
+ ui->room_description->setText(UISettings::values.multiplayer_room_description.GetValue());
+}
+
+HostRoomWindow::~HostRoomWindow() = default;
+
+void HostRoomWindow::UpdateGameList(QStandardItemModel* list) {
+ game_list->clear();
+ for (int i = 0; i < list->rowCount(); i++) {
+ auto parent = list->item(i, 0);
+ for (int j = 0; j < parent->rowCount(); j++) {
+ game_list->appendRow(parent->child(j)->clone());
+ }
+ }
+}
+
+void HostRoomWindow::RetranslateUi() {
+ ui->retranslateUi(this);
+}
+
+std::unique_ptr<Network::VerifyUser::Backend> HostRoomWindow::CreateVerifyBackend(
+ bool use_validation) const {
+ std::unique_ptr<Network::VerifyUser::Backend> verify_backend;
+ if (use_validation) {
+#ifdef ENABLE_WEB_SERVICE
+ verify_backend =
+ std::make_unique<WebService::VerifyUserJWT>(Settings::values.web_api_url.GetValue());
+#else
+ verify_backend = std::make_unique<Network::VerifyUser::NullBackend>();
+#endif
+ } else {
+ verify_backend = std::make_unique<Network::VerifyUser::NullBackend>();
+ }
+ return verify_backend;
+}
+
+void HostRoomWindow::Host() {
+ if (!Network::GetSelectedNetworkInterface()) {
+ NetworkMessage::ErrorManager::ShowError(
+ NetworkMessage::ErrorManager::NO_INTERFACE_SELECTED);
+ return;
+ }
+ if (!ui->username->hasAcceptableInput()) {
+ NetworkMessage::ErrorManager::ShowError(NetworkMessage::ErrorManager::USERNAME_NOT_VALID);
+ return;
+ }
+ if (!ui->room_name->hasAcceptableInput()) {
+ NetworkMessage::ErrorManager::ShowError(NetworkMessage::ErrorManager::ROOMNAME_NOT_VALID);
+ return;
+ }
+ if (!ui->port->hasAcceptableInput()) {
+ NetworkMessage::ErrorManager::ShowError(NetworkMessage::ErrorManager::PORT_NOT_VALID);
+ return;
+ }
+ if (ui->game_list->currentIndex() == -1) {
+ NetworkMessage::ErrorManager::ShowError(NetworkMessage::ErrorManager::GAME_NOT_SELECTED);
+ return;
+ }
+ if (system.IsPoweredOn()) {
+ if (!NetworkMessage::WarnGameRunning()) {
+ return;
+ }
+ }
+ if (auto member = room_network.GetRoomMember().lock()) {
+ if (member->GetState() == Network::RoomMember::State::Joining) {
+ return;
+ } else if (member->IsConnected()) {
+ auto parent = static_cast<MultiplayerState*>(parentWidget());
+ if (!parent->OnCloseRoom()) {
+ close();
+ return;
+ }
+ }
+ ui->host->setDisabled(true);
+
+ const AnnounceMultiplayerRoom::GameInfo game{
+ .name = ui->game_list->currentData(Qt::DisplayRole).toString().toStdString(),
+ .id = ui->game_list->currentData(GameListItemPath::ProgramIdRole).toULongLong(),
+ };
+ const auto port =
+ ui->port->isModified() ? ui->port->text().toInt() : Network::DefaultRoomPort;
+ const auto password = ui->password->text().toStdString();
+ const bool is_public = ui->host_type->currentIndex() == 0;
+ Network::Room::BanList ban_list{};
+ if (ui->load_ban_list->isChecked()) {
+ ban_list = UISettings::values.multiplayer_ban_list;
+ }
+ if (auto room = room_network.GetRoom().lock()) {
+ const bool created =
+ room->Create(ui->room_name->text().toStdString(),
+ ui->room_description->toPlainText().toStdString(), "", port, password,
+ ui->max_player->value(), Settings::values.yuzu_username.GetValue(),
+ game, CreateVerifyBackend(is_public), ban_list);
+ if (!created) {
+ NetworkMessage::ErrorManager::ShowError(
+ NetworkMessage::ErrorManager::COULD_NOT_CREATE_ROOM);
+ LOG_ERROR(Network, "Could not create room!");
+ ui->host->setEnabled(true);
+ return;
+ }
+ }
+ // Start the announce session if they chose Public
+ if (is_public) {
+ if (auto session = announce_multiplayer_session.lock()) {
+ // Register the room first to ensure verify_uid is present when we connect
+ WebService::WebResult result = session->Register();
+ if (result.result_code != WebService::WebResult::Code::Success) {
+ QMessageBox::warning(
+ this, tr("Error"),
+ tr("Failed to announce the room to the public lobby. In order to host a "
+ "room publicly, you must have a valid yuzu account configured in "
+ "Emulation -> Configure -> Web. If you do not want to publish a room in "
+ "the public lobby, then select Unlisted instead.\nDebug Message: ") +
+ QString::fromStdString(result.result_string),
+ QMessageBox::Ok);
+ ui->host->setEnabled(true);
+ if (auto room = room_network.GetRoom().lock()) {
+ room->Destroy();
+ }
+ return;
+ }
+ session->Start();
+ } else {
+ LOG_ERROR(Network, "Starting announce session failed");
+ }
+ }
+ std::string token;
+#ifdef ENABLE_WEB_SERVICE
+ if (is_public) {
+ WebService::Client client(Settings::values.web_api_url.GetValue(),
+ Settings::values.yuzu_username.GetValue(),
+ Settings::values.yuzu_token.GetValue());
+ if (auto room = room_network.GetRoom().lock()) {
+ token = client.GetExternalJWT(room->GetVerifyUID()).returned_data;
+ }
+ if (token.empty()) {
+ LOG_ERROR(WebService, "Could not get external JWT, verification may fail");
+ } else {
+ LOG_INFO(WebService, "Successfully requested external JWT: size={}", token.size());
+ }
+ }
+#endif
+ // TODO: Check what to do with this
+ member->Join(ui->username->text().toStdString(), "127.0.0.1", port, 0,
+ Network::NoPreferredIP, password, token);
+
+ // Store settings
+ UISettings::values.multiplayer_room_nickname = ui->username->text();
+ UISettings::values.multiplayer_room_name = ui->room_name->text();
+ UISettings::values.multiplayer_game_id =
+ ui->game_list->currentData(GameListItemPath::ProgramIdRole).toLongLong();
+ UISettings::values.multiplayer_max_player = ui->max_player->value();
+
+ UISettings::values.multiplayer_host_type = ui->host_type->currentIndex();
+ if (ui->port->isModified() && !ui->port->text().isEmpty()) {
+ UISettings::values.multiplayer_room_port = ui->port->text().toInt();
+ } else {
+ UISettings::values.multiplayer_room_port = Network::DefaultRoomPort;
+ }
+ UISettings::values.multiplayer_room_description = ui->room_description->toPlainText();
+ ui->host->setEnabled(true);
+ emit SaveConfig();
+ close();
+ }
+}
+
+QVariant ComboBoxProxyModel::data(const QModelIndex& idx, int role) const {
+ if (role != Qt::DisplayRole) {
+ auto val = QSortFilterProxyModel::data(idx, role);
+ // If its the icon, shrink it to 16x16
+ if (role == Qt::DecorationRole)
+ val = val.value<QImage>().scaled(16, 16, Qt::KeepAspectRatio);
+ return val;
+ }
+ std::string filename;
+ Common::SplitPath(
+ QSortFilterProxyModel::data(idx, GameListItemPath::FullPathRole).toString().toStdString(),
+ nullptr, &filename, nullptr);
+ QString title = QSortFilterProxyModel::data(idx, GameListItemPath::TitleRole).toString();
+ return title.isEmpty() ? QString::fromStdString(filename) : title;
+}
+
+bool ComboBoxProxyModel::lessThan(const QModelIndex& left, const QModelIndex& right) const {
+ auto leftData = left.data(GameListItemPath::TitleRole).toString();
+ auto rightData = right.data(GameListItemPath::TitleRole).toString();
+ return leftData.compare(rightData) < 0;
+}
diff --git a/src/yuzu/multiplayer/host_room.h b/src/yuzu/multiplayer/host_room.h
new file mode 100644
index 000000000..ae816e2e0
--- /dev/null
+++ b/src/yuzu/multiplayer/host_room.h
@@ -0,0 +1,80 @@
+// SPDX-FileCopyrightText: Copyright 2017 Citra Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+#include <memory>
+#include <QDialog>
+#include <QSortFilterProxyModel>
+#include <QStandardItemModel>
+#include <QVariant>
+#include "network/network.h"
+#include "yuzu/multiplayer/chat_room.h"
+#include "yuzu/multiplayer/validation.h"
+
+namespace Ui {
+class HostRoom;
+}
+
+namespace Core {
+class System;
+class AnnounceMultiplayerSession;
+} // namespace Core
+
+class ConnectionError;
+class ComboBoxProxyModel;
+
+class ChatMessage;
+
+namespace Network::VerifyUser {
+class Backend;
+};
+
+class HostRoomWindow : public QDialog {
+ Q_OBJECT
+
+public:
+ explicit HostRoomWindow(QWidget* parent, QStandardItemModel* list,
+ std::shared_ptr<Core::AnnounceMultiplayerSession> session,
+ Core::System& system_);
+ ~HostRoomWindow();
+
+ /**
+ * Updates the dialog with a new game list model.
+ * This model should be the original model of the game list.
+ */
+ void UpdateGameList(QStandardItemModel* list);
+ void RetranslateUi();
+
+signals:
+ void SaveConfig();
+
+private:
+ void Host();
+ std::unique_ptr<Network::VerifyUser::Backend> CreateVerifyBackend(bool use_validation) const;
+
+ std::unique_ptr<Ui::HostRoom> ui;
+ std::weak_ptr<Core::AnnounceMultiplayerSession> announce_multiplayer_session;
+ QStandardItemModel* game_list;
+ ComboBoxProxyModel* proxy;
+ Validation validation;
+ Core::System& system;
+ Network::RoomNetwork& room_network;
+};
+
+/**
+ * Proxy Model for the game list combo box so we can reuse the game list model while still
+ * displaying the fields slightly differently
+ */
+class ComboBoxProxyModel : public QSortFilterProxyModel {
+ Q_OBJECT
+
+public:
+ int columnCount(const QModelIndex& idx) const override {
+ return 1;
+ }
+
+ QVariant data(const QModelIndex& idx, int role) const override;
+
+ bool lessThan(const QModelIndex& left, const QModelIndex& right) const override;
+};
diff --git a/src/yuzu/multiplayer/host_room.ui b/src/yuzu/multiplayer/host_room.ui
new file mode 100644
index 000000000..d54cf49c6
--- /dev/null
+++ b/src/yuzu/multiplayer/host_room.ui
@@ -0,0 +1,207 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>HostRoom</class>
+ <widget class="QWidget" name="HostRoom">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>607</width>
+ <height>211</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Create Room</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_3">
+ <item>
+ <widget class="QWidget" name="settings" native="true">
+ <layout class="QHBoxLayout">
+ <property name="leftMargin">
+ <number>0</number>
+ </property>
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>0</number>
+ </property>
+ <item>
+ <layout class="QFormLayout" name="formLayout_2">
+ <property name="labelAlignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ <item row="0" column="0">
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Room Name</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QLineEdit" name="room_name">
+ <property name="maxLength">
+ <number>50</number>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="label_3">
+ <property name="text">
+ <string>Preferred Game</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QComboBox" name="game_list"/>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="label_2">
+ <property name="text">
+ <string>Max Players</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QSpinBox" name="max_player">
+ <property name="minimum">
+ <number>2</number>
+ </property>
+ <property name="maximum">
+ <number>16</number>
+ </property>
+ <property name="value">
+ <number>8</number>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QFormLayout" name="formLayout">
+ <property name="labelAlignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ <item row="0" column="1">
+ <widget class="QLineEdit" name="username"/>
+ </item>
+ <item row="0" column="0">
+ <widget class="QLabel" name="label_6">
+ <property name="text">
+ <string>Username</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QLineEdit" name="password">
+ <property name="echoMode">
+ <enum>QLineEdit::PasswordEchoOnEdit</enum>
+ </property>
+ <property name="placeholderText">
+ <string>(Leave blank for open game)</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QLineEdit" name="port">
+ <property name="inputMethodHints">
+ <set>Qt::ImhDigitsOnly</set>
+ </property>
+ <property name="maxLength">
+ <number>5</number>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="label_5">
+ <property name="text">
+ <string>Password</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="label_4">
+ <property name="text">
+ <string>Port</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_3">
+ <item>
+ <widget class="QLabel" name="label_7">
+ <property name="text">
+ <string>Room Description</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QTextEdit" name="room_description"/>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout">
+ <item>
+ <widget class="QCheckBox" name="load_ban_list">
+ <property name="text">
+ <string>Load Previous Ban List</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <property name="rightMargin">
+ <number>0</number>
+ </property>
+ <item>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QComboBox" name="host_type">
+ <item>
+ <property name="text">
+ <string>Public</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Unlisted</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="host">
+ <property name="text">
+ <string>Host Room</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/src/yuzu/multiplayer/lobby.cpp b/src/yuzu/multiplayer/lobby.cpp
new file mode 100644
index 000000000..08c275696
--- /dev/null
+++ b/src/yuzu/multiplayer/lobby.cpp
@@ -0,0 +1,410 @@
+// SPDX-FileCopyrightText: Copyright 2017 Citra Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include <QInputDialog>
+#include <QList>
+#include <QtConcurrent/QtConcurrentRun>
+#include "common/logging/log.h"
+#include "common/settings.h"
+#include "core/core.h"
+#include "core/hle/service/acc/profile_manager.h"
+#include "core/internal_network/network_interface.h"
+#include "network/network.h"
+#include "ui_lobby.h"
+#include "yuzu/game_list_p.h"
+#include "yuzu/main.h"
+#include "yuzu/multiplayer/client_room.h"
+#include "yuzu/multiplayer/lobby.h"
+#include "yuzu/multiplayer/lobby_p.h"
+#include "yuzu/multiplayer/message.h"
+#include "yuzu/multiplayer/state.h"
+#include "yuzu/multiplayer/validation.h"
+#include "yuzu/uisettings.h"
+#ifdef ENABLE_WEB_SERVICE
+#include "web_service/web_backend.h"
+#endif
+
+Lobby::Lobby(QWidget* parent, QStandardItemModel* list,
+ std::shared_ptr<Core::AnnounceMultiplayerSession> session, Core::System& system_)
+ : QDialog(parent, Qt::WindowTitleHint | Qt::WindowCloseButtonHint | Qt::WindowSystemMenuHint),
+ ui(std::make_unique<Ui::Lobby>()), announce_multiplayer_session(session),
+ profile_manager(std::make_unique<Service::Account::ProfileManager>()), system{system_},
+ room_network{system.GetRoomNetwork()} {
+ ui->setupUi(this);
+
+ // setup the watcher for background connections
+ watcher = new QFutureWatcher<void>;
+
+ model = new QStandardItemModel(ui->room_list);
+
+ // Create a proxy to the game list to get the list of games owned
+ game_list = new QStandardItemModel;
+ UpdateGameList(list);
+
+ proxy = new LobbyFilterProxyModel(this, game_list);
+ proxy->setSourceModel(model);
+ proxy->setDynamicSortFilter(true);
+ proxy->setFilterCaseSensitivity(Qt::CaseInsensitive);
+ proxy->setSortLocaleAware(true);
+ ui->room_list->setModel(proxy);
+ ui->room_list->header()->setSectionResizeMode(QHeaderView::Interactive);
+ ui->room_list->header()->stretchLastSection();
+ ui->room_list->setAlternatingRowColors(true);
+ ui->room_list->setSelectionMode(QHeaderView::SingleSelection);
+ ui->room_list->setSelectionBehavior(QHeaderView::SelectRows);
+ ui->room_list->setVerticalScrollMode(QHeaderView::ScrollPerPixel);
+ ui->room_list->setHorizontalScrollMode(QHeaderView::ScrollPerPixel);
+ ui->room_list->setSortingEnabled(true);
+ ui->room_list->setEditTriggers(QHeaderView::NoEditTriggers);
+ ui->room_list->setExpandsOnDoubleClick(false);
+ ui->room_list->setContextMenuPolicy(Qt::CustomContextMenu);
+
+ ui->nickname->setValidator(validation.GetNickname());
+ ui->nickname->setText(UISettings::values.multiplayer_nickname.GetValue());
+
+ // Try find the best nickname by default
+ if (ui->nickname->text().isEmpty() || ui->nickname->text() == QStringLiteral("yuzu")) {
+ if (!Settings::values.yuzu_username.GetValue().empty()) {
+ ui->nickname->setText(
+ QString::fromStdString(Settings::values.yuzu_username.GetValue()));
+ } else if (!GetProfileUsername().empty()) {
+ ui->nickname->setText(QString::fromStdString(GetProfileUsername()));
+ } else {
+ ui->nickname->setText(QStringLiteral("yuzu"));
+ }
+ }
+
+ // UI Buttons
+ connect(ui->refresh_list, &QPushButton::clicked, this, &Lobby::RefreshLobby);
+ connect(ui->games_owned, &QCheckBox::toggled, proxy, &LobbyFilterProxyModel::SetFilterOwned);
+ connect(ui->hide_full, &QCheckBox::toggled, proxy, &LobbyFilterProxyModel::SetFilterFull);
+ connect(ui->search, &QLineEdit::textChanged, proxy, &LobbyFilterProxyModel::SetFilterSearch);
+ connect(ui->room_list, &QTreeView::doubleClicked, this, &Lobby::OnJoinRoom);
+ connect(ui->room_list, &QTreeView::clicked, this, &Lobby::OnExpandRoom);
+
+ // Actions
+ connect(&room_list_watcher, &QFutureWatcher<AnnounceMultiplayerRoom::RoomList>::finished, this,
+ &Lobby::OnRefreshLobby);
+}
+
+Lobby::~Lobby() = default;
+
+void Lobby::UpdateGameList(QStandardItemModel* list) {
+ game_list->clear();
+ for (int i = 0; i < list->rowCount(); i++) {
+ auto parent = list->item(i, 0);
+ for (int j = 0; j < parent->rowCount(); j++) {
+ game_list->appendRow(parent->child(j)->clone());
+ }
+ }
+ if (proxy)
+ proxy->UpdateGameList(game_list);
+ ui->room_list->sortByColumn(Column::GAME_NAME, Qt::AscendingOrder);
+}
+
+void Lobby::RetranslateUi() {
+ ui->retranslateUi(this);
+}
+
+QString Lobby::PasswordPrompt() {
+ bool ok;
+ const QString text =
+ QInputDialog::getText(this, tr("Password Required to Join"), tr("Password:"),
+ QLineEdit::Password, QString(), &ok);
+ return ok ? text : QString();
+}
+
+void Lobby::OnExpandRoom(const QModelIndex& index) {
+ QModelIndex member_index = proxy->index(index.row(), Column::MEMBER);
+ auto member_list = proxy->data(member_index, LobbyItemMemberList::MemberListRole).toList();
+}
+
+void Lobby::OnJoinRoom(const QModelIndex& source) {
+ if (!Network::GetSelectedNetworkInterface()) {
+ LOG_INFO(WebService, "Automatically selected network interface for room network.");
+ Network::SelectFirstNetworkInterface();
+ }
+
+ if (!Network::GetSelectedNetworkInterface()) {
+ NetworkMessage::ErrorManager::ShowError(
+ NetworkMessage::ErrorManager::NO_INTERFACE_SELECTED);
+ return;
+ }
+
+ if (system.IsPoweredOn()) {
+ if (!NetworkMessage::WarnGameRunning()) {
+ return;
+ }
+ }
+
+ if (const auto member = room_network.GetRoomMember().lock()) {
+ // Prevent the user from trying to join a room while they are already joining.
+ if (member->GetState() == Network::RoomMember::State::Joining) {
+ return;
+ } else if (member->IsConnected()) {
+ // And ask if they want to leave the room if they are already in one.
+ if (!NetworkMessage::WarnDisconnect()) {
+ return;
+ }
+ }
+ }
+ QModelIndex index = source;
+ // If the user double clicks on a child row (aka the player list) then use the parent instead
+ if (source.parent() != QModelIndex()) {
+ index = source.parent();
+ }
+ if (!ui->nickname->hasAcceptableInput()) {
+ NetworkMessage::ErrorManager::ShowError(NetworkMessage::ErrorManager::USERNAME_NOT_VALID);
+ return;
+ }
+
+ // Get a password to pass if the room is password protected
+ QModelIndex password_index = proxy->index(index.row(), Column::ROOM_NAME);
+ bool has_password = proxy->data(password_index, LobbyItemName::PasswordRole).toBool();
+ const std::string password = has_password ? PasswordPrompt().toStdString() : "";
+ if (has_password && password.empty()) {
+ return;
+ }
+
+ QModelIndex connection_index = proxy->index(index.row(), Column::HOST);
+ const std::string nickname = ui->nickname->text().toStdString();
+ const std::string ip =
+ proxy->data(connection_index, LobbyItemHost::HostIPRole).toString().toStdString();
+ int port = proxy->data(connection_index, LobbyItemHost::HostPortRole).toInt();
+ const std::string verify_uid =
+ proxy->data(connection_index, LobbyItemHost::HostVerifyUIDRole).toString().toStdString();
+
+ // attempt to connect in a different thread
+ QFuture<void> f = QtConcurrent::run([nickname, ip, port, password, verify_uid, this] {
+ std::string token;
+#ifdef ENABLE_WEB_SERVICE
+ if (!Settings::values.yuzu_username.GetValue().empty() &&
+ !Settings::values.yuzu_token.GetValue().empty()) {
+ WebService::Client client(Settings::values.web_api_url.GetValue(),
+ Settings::values.yuzu_username.GetValue(),
+ Settings::values.yuzu_token.GetValue());
+ token = client.GetExternalJWT(verify_uid).returned_data;
+ if (token.empty()) {
+ LOG_ERROR(WebService, "Could not get external JWT, verification may fail");
+ } else {
+ LOG_INFO(WebService, "Successfully requested external JWT: size={}", token.size());
+ }
+ }
+#endif
+ if (auto room_member = room_network.GetRoomMember().lock()) {
+ room_member->Join(nickname, ip.c_str(), port, 0, Network::NoPreferredIP, password,
+ token);
+ }
+ });
+ watcher->setFuture(f);
+
+ // TODO(jroweboy): disable widgets and display a connecting while we wait
+
+ // Save settings
+ UISettings::values.multiplayer_nickname = ui->nickname->text();
+ UISettings::values.multiplayer_ip =
+ proxy->data(connection_index, LobbyItemHost::HostIPRole).toString();
+ UISettings::values.multiplayer_port =
+ proxy->data(connection_index, LobbyItemHost::HostPortRole).toInt();
+ emit SaveConfig();
+}
+
+void Lobby::ResetModel() {
+ model->clear();
+ model->insertColumns(0, Column::TOTAL);
+ model->setHeaderData(Column::MEMBER, Qt::Horizontal, tr("Players"), Qt::DisplayRole);
+ model->setHeaderData(Column::ROOM_NAME, Qt::Horizontal, tr("Room Name"), Qt::DisplayRole);
+ model->setHeaderData(Column::GAME_NAME, Qt::Horizontal, tr("Preferred Game"), Qt::DisplayRole);
+ model->setHeaderData(Column::HOST, Qt::Horizontal, tr("Host"), Qt::DisplayRole);
+}
+
+void Lobby::RefreshLobby() {
+ if (auto session = announce_multiplayer_session.lock()) {
+ ResetModel();
+ ui->refresh_list->setEnabled(false);
+ ui->refresh_list->setText(tr("Refreshing"));
+ room_list_watcher.setFuture(
+ QtConcurrent::run([session]() { return session->GetRoomList(); }));
+ } else {
+ // TODO(jroweboy): Display an error box about announce couldn't be started
+ }
+}
+
+void Lobby::OnRefreshLobby() {
+ AnnounceMultiplayerRoom::RoomList new_room_list = room_list_watcher.result();
+ for (auto room : new_room_list) {
+ // find the icon for the game if this person owns that game.
+ QPixmap smdh_icon;
+ for (int r = 0; r < game_list->rowCount(); ++r) {
+ auto index = game_list->index(r, 0);
+ auto game_id = game_list->data(index, GameListItemPath::ProgramIdRole).toULongLong();
+
+ if (game_id != 0 && room.information.preferred_game.id == game_id) {
+ smdh_icon = game_list->data(index, Qt::DecorationRole).value<QPixmap>();
+ }
+ }
+
+ QList<QVariant> members;
+ for (auto member : room.members) {
+ QVariant var;
+ var.setValue(LobbyMember{QString::fromStdString(member.username),
+ QString::fromStdString(member.nickname), member.game.id,
+ QString::fromStdString(member.game.name)});
+ members.append(var);
+ }
+
+ auto first_item = new LobbyItemGame(
+ room.information.preferred_game.id,
+ QString::fromStdString(room.information.preferred_game.name), smdh_icon);
+ auto row = QList<QStandardItem*>({
+ first_item,
+ new LobbyItemName(room.has_password, QString::fromStdString(room.information.name)),
+ new LobbyItemMemberList(members, room.information.member_slots),
+ new LobbyItemHost(QString::fromStdString(room.information.host_username),
+ QString::fromStdString(room.ip), room.information.port,
+ QString::fromStdString(room.verify_uid)),
+ });
+ model->appendRow(row);
+ // To make the rows expandable, add the member data as a child of the first column of the
+ // rows with people in them and have qt set them to colspan after the model is finished
+ // resetting
+ if (!room.information.description.empty()) {
+ first_item->appendRow(
+ new LobbyItemDescription(QString::fromStdString(room.information.description)));
+ }
+ if (!room.members.empty()) {
+ first_item->appendRow(new LobbyItemExpandedMemberList(members));
+ }
+ }
+
+ // Reenable the refresh button and resize the columns
+ ui->refresh_list->setEnabled(true);
+ ui->refresh_list->setText(tr("Refresh List"));
+ ui->room_list->header()->stretchLastSection();
+ for (int i = 0; i < Column::TOTAL - 1; ++i) {
+ ui->room_list->resizeColumnToContents(i);
+ }
+
+ // Set the member list child items to span all columns
+ for (int i = 0; i < proxy->rowCount(); i++) {
+ auto parent = model->item(i, 0);
+ for (int j = 0; j < parent->rowCount(); j++) {
+ ui->room_list->setFirstColumnSpanned(j, proxy->index(i, 0), true);
+ }
+ }
+
+ ui->room_list->sortByColumn(Column::GAME_NAME, Qt::AscendingOrder);
+}
+
+std::string Lobby::GetProfileUsername() {
+ const auto& current_user = profile_manager->GetUser(Settings::values.current_user.GetValue());
+ Service::Account::ProfileBase profile{};
+
+ if (!current_user.has_value()) {
+ return "";
+ }
+
+ if (!profile_manager->GetProfileBase(*current_user, profile)) {
+ return "";
+ }
+
+ const auto text = Common::StringFromFixedZeroTerminatedBuffer(
+ reinterpret_cast<const char*>(profile.username.data()), profile.username.size());
+
+ return text;
+}
+
+LobbyFilterProxyModel::LobbyFilterProxyModel(QWidget* parent, QStandardItemModel* list)
+ : QSortFilterProxyModel(parent), game_list(list) {}
+
+void LobbyFilterProxyModel::UpdateGameList(QStandardItemModel* list) {
+ game_list = list;
+}
+
+bool LobbyFilterProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex& sourceParent) const {
+ // Prioritize filters by fastest to compute
+
+ // pass over any child rows (aka row that shows the players in the room)
+ if (sourceParent != QModelIndex()) {
+ return true;
+ }
+
+ // filter by filled rooms
+ if (filter_full) {
+ QModelIndex member_list = sourceModel()->index(sourceRow, Column::MEMBER, sourceParent);
+ int player_count =
+ sourceModel()->data(member_list, LobbyItemMemberList::MemberListRole).toList().size();
+ int max_players =
+ sourceModel()->data(member_list, LobbyItemMemberList::MaxPlayerRole).toInt();
+ if (player_count >= max_players) {
+ return false;
+ }
+ }
+
+ // filter by search parameters
+ if (!filter_search.isEmpty()) {
+ QModelIndex game_name = sourceModel()->index(sourceRow, Column::GAME_NAME, sourceParent);
+ QModelIndex room_name = sourceModel()->index(sourceRow, Column::ROOM_NAME, sourceParent);
+ QModelIndex host_name = sourceModel()->index(sourceRow, Column::HOST, sourceParent);
+ bool preferred_game_match = sourceModel()
+ ->data(game_name, LobbyItemGame::GameNameRole)
+ .toString()
+ .contains(filter_search, filterCaseSensitivity());
+ bool room_name_match = sourceModel()
+ ->data(room_name, LobbyItemName::NameRole)
+ .toString()
+ .contains(filter_search, filterCaseSensitivity());
+ bool username_match = sourceModel()
+ ->data(host_name, LobbyItemHost::HostUsernameRole)
+ .toString()
+ .contains(filter_search, filterCaseSensitivity());
+ if (!preferred_game_match && !room_name_match && !username_match) {
+ return false;
+ }
+ }
+
+ // filter by game owned
+ if (filter_owned) {
+ QModelIndex game_name = sourceModel()->index(sourceRow, Column::GAME_NAME, sourceParent);
+ QList<QModelIndex> owned_games;
+ for (int r = 0; r < game_list->rowCount(); ++r) {
+ owned_games.append(QModelIndex(game_list->index(r, 0)));
+ }
+ auto current_id = sourceModel()->data(game_name, LobbyItemGame::TitleIDRole).toLongLong();
+ if (current_id == 0) {
+ // TODO(jroweboy): homebrew often doesn't have a game id and this hides them
+ return false;
+ }
+ bool owned = false;
+ for (const auto& game : owned_games) {
+ auto game_id = game_list->data(game, GameListItemPath::ProgramIdRole).toLongLong();
+ if (current_id == game_id) {
+ owned = true;
+ }
+ }
+ if (!owned) {
+ return false;
+ }
+ }
+
+ return true;
+}
+
+void LobbyFilterProxyModel::sort(int column, Qt::SortOrder order) {
+ sourceModel()->sort(column, order);
+}
+
+void LobbyFilterProxyModel::SetFilterOwned(bool filter) {
+ filter_owned = filter;
+ invalidate();
+}
+
+void LobbyFilterProxyModel::SetFilterFull(bool filter) {
+ filter_full = filter;
+ invalidate();
+}
+
+void LobbyFilterProxyModel::SetFilterSearch(const QString& filter) {
+ filter_search = filter;
+ invalidate();
+}
diff --git a/src/yuzu/multiplayer/lobby.h b/src/yuzu/multiplayer/lobby.h
new file mode 100644
index 000000000..300dad13e
--- /dev/null
+++ b/src/yuzu/multiplayer/lobby.h
@@ -0,0 +1,141 @@
+// SPDX-FileCopyrightText: Copyright 2017 Citra Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+#include <memory>
+#include <QDialog>
+#include <QFutureWatcher>
+#include <QSortFilterProxyModel>
+#include <QStandardItemModel>
+#include "common/announce_multiplayer_room.h"
+#include "network/announce_multiplayer_session.h"
+#include "network/network.h"
+#include "yuzu/multiplayer/validation.h"
+
+namespace Ui {
+class Lobby;
+}
+
+class LobbyModel;
+class LobbyFilterProxyModel;
+
+namespace Core {
+class System;
+}
+
+namespace Service::Account {
+class ProfileManager;
+}
+
+/**
+ * Listing of all public games pulled from services. The lobby should be simple enough for users to
+ * find the game they want to play, and join it.
+ */
+class Lobby : public QDialog {
+ Q_OBJECT
+
+public:
+ explicit Lobby(QWidget* parent, QStandardItemModel* list,
+ std::shared_ptr<Core::AnnounceMultiplayerSession> session,
+ Core::System& system_);
+ ~Lobby() override;
+
+ /**
+ * Updates the lobby with a new game list model.
+ * This model should be the original model of the game list.
+ */
+ void UpdateGameList(QStandardItemModel* list);
+ void RetranslateUi();
+
+public slots:
+ /**
+ * Begin the process to pull the latest room list from web services. After the listing is
+ * returned from web services, `LobbyRefreshed` will be signalled
+ */
+ void RefreshLobby();
+
+private slots:
+ /**
+ * Pulls the list of rooms from network and fills out the lobby model with the results
+ */
+ void OnRefreshLobby();
+
+ /**
+ * Handler for single clicking on a room in the list. Expands the treeitem to show player
+ * information for the people in the room
+ *
+ * index - The row of the proxy model that the user wants to join.
+ */
+ void OnExpandRoom(const QModelIndex&);
+
+ /**
+ * Handler for double clicking on a room in the list. Gathers the host ip and port and attempts
+ * to connect. Will also prompt for a password in case one is required.
+ *
+ * index - The row of the proxy model that the user wants to join.
+ */
+ void OnJoinRoom(const QModelIndex&);
+
+signals:
+ void StateChanged(const Network::RoomMember::State&);
+ void SaveConfig();
+
+private:
+ std::string GetProfileUsername();
+
+ /**
+ * Removes all entries in the Lobby before refreshing.
+ */
+ void ResetModel();
+
+ /**
+ * Prompts for a password. Returns an empty QString if the user either did not provide a
+ * password or if the user closed the window.
+ */
+ QString PasswordPrompt();
+
+ std::unique_ptr<Ui::Lobby> ui;
+
+ QStandardItemModel* model{};
+ QStandardItemModel* game_list{};
+ LobbyFilterProxyModel* proxy{};
+
+ QFutureWatcher<AnnounceMultiplayerRoom::RoomList> room_list_watcher;
+ std::weak_ptr<Core::AnnounceMultiplayerSession> announce_multiplayer_session;
+ std::unique_ptr<Service::Account::ProfileManager> profile_manager;
+ QFutureWatcher<void>* watcher;
+ Validation validation;
+ Core::System& system;
+ Network::RoomNetwork& room_network;
+};
+
+/**
+ * Proxy Model for filtering the lobby
+ */
+class LobbyFilterProxyModel : public QSortFilterProxyModel {
+ Q_OBJECT;
+
+public:
+ explicit LobbyFilterProxyModel(QWidget* parent, QStandardItemModel* list);
+
+ /**
+ * Updates the filter with a new game list model.
+ * This model should be the processed one created by the Lobby.
+ */
+ void UpdateGameList(QStandardItemModel* list);
+
+ bool filterAcceptsRow(int sourceRow, const QModelIndex& sourceParent) const override;
+ void sort(int column, Qt::SortOrder order) override;
+
+public slots:
+ void SetFilterOwned(bool);
+ void SetFilterFull(bool);
+ void SetFilterSearch(const QString&);
+
+private:
+ QStandardItemModel* game_list;
+ bool filter_owned = false;
+ bool filter_full = false;
+ QString filter_search;
+};
diff --git a/src/yuzu/multiplayer/lobby.ui b/src/yuzu/multiplayer/lobby.ui
new file mode 100644
index 000000000..4c9901c9a
--- /dev/null
+++ b/src/yuzu/multiplayer/lobby.ui
@@ -0,0 +1,123 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Lobby</class>
+ <widget class="QWidget" name="Lobby">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>903</width>
+ <height>487</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Public Room Browser</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <property name="spacing">
+ <number>3</number>
+ </property>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_3">
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_5">
+ <item>
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Nickname</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="nickname">
+ <property name="placeholderText">
+ <string>Nickname</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_2">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QLabel" name="label_2">
+ <property name="text">
+ <string>Filters</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="search">
+ <property name="placeholderText">
+ <string>Search</string>
+ </property>
+ <property name="clearButtonEnabled">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="games_owned">
+ <property name="text">
+ <string>Games I Own</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="hide_full">
+ <property name="text">
+ <string>Hide Full Rooms</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="refresh_list">
+ <property name="text">
+ <string>Refresh Lobby</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QTreeView" name="room_list"/>
+ </item>
+ <item>
+ <widget class="QWidget" name="widget" native="true"/>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/src/yuzu/multiplayer/lobby_p.h b/src/yuzu/multiplayer/lobby_p.h
new file mode 100644
index 000000000..068c95aca
--- /dev/null
+++ b/src/yuzu/multiplayer/lobby_p.h
@@ -0,0 +1,244 @@
+// SPDX-FileCopyrightText: Copyright 2017 Citra Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+#include <utility>
+#include <QPixmap>
+#include <QStandardItem>
+#include <QStandardItemModel>
+#include "common/common_types.h"
+
+namespace Column {
+enum List {
+ GAME_NAME,
+ ROOM_NAME,
+ MEMBER,
+ HOST,
+ TOTAL,
+};
+}
+
+class LobbyItem : public QStandardItem {
+public:
+ LobbyItem() = default;
+ explicit LobbyItem(const QString& string) : QStandardItem(string) {}
+ virtual ~LobbyItem() override = default;
+};
+
+class LobbyItemName : public LobbyItem {
+public:
+ static const int NameRole = Qt::UserRole + 1;
+ static const int PasswordRole = Qt::UserRole + 2;
+
+ LobbyItemName() = default;
+ explicit LobbyItemName(bool has_password, QString name) : LobbyItem() {
+ setData(name, NameRole);
+ setData(has_password, PasswordRole);
+ }
+
+ QVariant data(int role) const override {
+ if (role == Qt::DecorationRole) {
+ bool has_password = data(PasswordRole).toBool();
+ return has_password ? QIcon::fromTheme(QStringLiteral("lock")).pixmap(16) : QIcon();
+ }
+ if (role != Qt::DisplayRole) {
+ return LobbyItem::data(role);
+ }
+ return data(NameRole).toString();
+ }
+
+ bool operator<(const QStandardItem& other) const override {
+ return data(NameRole).toString().localeAwareCompare(other.data(NameRole).toString()) < 0;
+ }
+};
+
+class LobbyItemDescription : public LobbyItem {
+public:
+ static const int DescriptionRole = Qt::UserRole + 1;
+
+ LobbyItemDescription() = default;
+ explicit LobbyItemDescription(QString description) {
+ setData(description, DescriptionRole);
+ }
+
+ QVariant data(int role) const override {
+ if (role != Qt::DisplayRole) {
+ return LobbyItem::data(role);
+ }
+ auto description = data(DescriptionRole).toString();
+ description.prepend(QStringLiteral("Description: "));
+ return description;
+ }
+
+ bool operator<(const QStandardItem& other) const override {
+ return data(DescriptionRole)
+ .toString()
+ .localeAwareCompare(other.data(DescriptionRole).toString()) < 0;
+ }
+};
+
+class LobbyItemGame : public LobbyItem {
+public:
+ static const int TitleIDRole = Qt::UserRole + 1;
+ static const int GameNameRole = Qt::UserRole + 2;
+ static const int GameIconRole = Qt::UserRole + 3;
+
+ LobbyItemGame() = default;
+ explicit LobbyItemGame(u64 title_id, QString game_name, QPixmap smdh_icon) {
+ setData(static_cast<unsigned long long>(title_id), TitleIDRole);
+ setData(game_name, GameNameRole);
+ if (!smdh_icon.isNull()) {
+ setData(smdh_icon, GameIconRole);
+ } else {
+ setData(QIcon::fromTheme(QStringLiteral("chip")).pixmap(32), GameIconRole);
+ }
+ }
+
+ QVariant data(int role) const override {
+ if (role == Qt::DecorationRole) {
+ auto val = data(GameIconRole);
+ if (val.isValid()) {
+ val = val.value<QPixmap>().scaled(32, 32, Qt::KeepAspectRatio,
+ Qt::TransformationMode::SmoothTransformation);
+ } else {
+ auto blank_image = QPixmap(32, 32);
+ blank_image.fill(Qt::black);
+ val = blank_image;
+ }
+ return val;
+ } else if (role != Qt::DisplayRole) {
+ return LobbyItem::data(role);
+ }
+ return data(GameNameRole).toString();
+ }
+
+ bool operator<(const QStandardItem& other) const override {
+ return data(GameNameRole)
+ .toString()
+ .localeAwareCompare(other.data(GameNameRole).toString()) < 0;
+ }
+};
+
+class LobbyItemHost : public LobbyItem {
+public:
+ static const int HostUsernameRole = Qt::UserRole + 1;
+ static const int HostIPRole = Qt::UserRole + 2;
+ static const int HostPortRole = Qt::UserRole + 3;
+ static const int HostVerifyUIDRole = Qt::UserRole + 4;
+
+ LobbyItemHost() = default;
+ explicit LobbyItemHost(QString username, QString ip, u16 port, QString verify_uid) {
+ setData(username, HostUsernameRole);
+ setData(ip, HostIPRole);
+ setData(port, HostPortRole);
+ setData(verify_uid, HostVerifyUIDRole);
+ }
+
+ QVariant data(int role) const override {
+ if (role != Qt::DisplayRole) {
+ return LobbyItem::data(role);
+ }
+ return data(HostUsernameRole).toString();
+ }
+
+ bool operator<(const QStandardItem& other) const override {
+ return data(HostUsernameRole)
+ .toString()
+ .localeAwareCompare(other.data(HostUsernameRole).toString()) < 0;
+ }
+};
+
+class LobbyMember {
+public:
+ LobbyMember() = default;
+ LobbyMember(const LobbyMember& other) = default;
+ explicit LobbyMember(QString username_, QString nickname_, u64 title_id_, QString game_name_)
+ : username(std::move(username_)), nickname(std::move(nickname_)), title_id(title_id_),
+ game_name(std::move(game_name_)) {}
+ ~LobbyMember() = default;
+
+ QString GetName() const {
+ if (username.isEmpty() || username == nickname) {
+ return nickname;
+ } else {
+ return QStringLiteral("%1 (%2)").arg(nickname, username);
+ }
+ }
+ u64 GetTitleId() const {
+ return title_id;
+ }
+ QString GetGameName() const {
+ return game_name;
+ }
+
+private:
+ QString username;
+ QString nickname;
+ u64 title_id;
+ QString game_name;
+};
+
+Q_DECLARE_METATYPE(LobbyMember);
+
+class LobbyItemMemberList : public LobbyItem {
+public:
+ static const int MemberListRole = Qt::UserRole + 1;
+ static const int MaxPlayerRole = Qt::UserRole + 2;
+
+ LobbyItemMemberList() = default;
+ explicit LobbyItemMemberList(QList<QVariant> members, u32 max_players) {
+ setData(members, MemberListRole);
+ setData(max_players, MaxPlayerRole);
+ }
+
+ QVariant data(int role) const override {
+ if (role != Qt::DisplayRole) {
+ return LobbyItem::data(role);
+ }
+ auto members = data(MemberListRole).toList();
+ return QStringLiteral("%1 / %2 ")
+ .arg(QString::number(members.size()), data(MaxPlayerRole).toString());
+ }
+
+ bool operator<(const QStandardItem& other) const override {
+ // sort by rooms that have the most players
+ int left_members = data(MemberListRole).toList().size();
+ int right_members = other.data(MemberListRole).toList().size();
+ return left_members < right_members;
+ }
+};
+
+/**
+ * Member information for when a lobby is expanded in the UI
+ */
+class LobbyItemExpandedMemberList : public LobbyItem {
+public:
+ static const int MemberListRole = Qt::UserRole + 1;
+
+ LobbyItemExpandedMemberList() = default;
+ explicit LobbyItemExpandedMemberList(QList<QVariant> members) {
+ setData(members, MemberListRole);
+ }
+
+ QVariant data(int role) const override {
+ if (role != Qt::DisplayRole) {
+ return LobbyItem::data(role);
+ }
+ auto members = data(MemberListRole).toList();
+ QString out;
+ bool first = true;
+ for (const auto& member : members) {
+ if (!first)
+ out.append(QStringLiteral("\n"));
+ const auto& m = member.value<LobbyMember>();
+ if (m.GetGameName().isEmpty()) {
+ out += QString(QObject::tr("%1 is not playing a game")).arg(m.GetName());
+ } else {
+ out += QString(QObject::tr("%1 is playing %2")).arg(m.GetName(), m.GetGameName());
+ }
+ first = false;
+ }
+ return out;
+ }
+};
diff --git a/src/yuzu/multiplayer/message.cpp b/src/yuzu/multiplayer/message.cpp
new file mode 100644
index 000000000..6d8f18274
--- /dev/null
+++ b/src/yuzu/multiplayer/message.cpp
@@ -0,0 +1,85 @@
+// SPDX-FileCopyrightText: Copyright 2017 Citra Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include <QMessageBox>
+#include <QString>
+
+#include "yuzu/multiplayer/message.h"
+
+namespace NetworkMessage {
+const ConnectionError ErrorManager::USERNAME_NOT_VALID(
+ QT_TR_NOOP("Username is not valid. Must be 4 to 20 alphanumeric characters."));
+const ConnectionError ErrorManager::ROOMNAME_NOT_VALID(
+ QT_TR_NOOP("Room name is not valid. Must be 4 to 20 alphanumeric characters."));
+const ConnectionError ErrorManager::USERNAME_NOT_VALID_SERVER(
+ QT_TR_NOOP("Username is already in use or not valid. Please choose another."));
+const ConnectionError ErrorManager::IP_ADDRESS_NOT_VALID(
+ QT_TR_NOOP("IP is not a valid IPv4 address."));
+const ConnectionError ErrorManager::PORT_NOT_VALID(
+ QT_TR_NOOP("Port must be a number between 0 to 65535."));
+const ConnectionError ErrorManager::GAME_NOT_SELECTED(QT_TR_NOOP(
+ "You must choose a Preferred Game to host a room. If you do not have any games in your game "
+ "list yet, add a game folder by clicking on the plus icon in the game list."));
+const ConnectionError ErrorManager::NO_INTERNET(
+ QT_TR_NOOP("Unable to find an internet connection. Check your internet settings."));
+const ConnectionError ErrorManager::UNABLE_TO_CONNECT(
+ QT_TR_NOOP("Unable to connect to the host. Verify that the connection settings are correct. If "
+ "you still cannot connect, contact the room host and verify that the host is "
+ "properly configured with the external port forwarded."));
+const ConnectionError ErrorManager::ROOM_IS_FULL(
+ QT_TR_NOOP("Unable to connect to the room because it is already full."));
+const ConnectionError ErrorManager::COULD_NOT_CREATE_ROOM(
+ QT_TR_NOOP("Creating a room failed. Please retry. Restarting yuzu might be necessary."));
+const ConnectionError ErrorManager::HOST_BANNED(
+ QT_TR_NOOP("The host of the room has banned you. Speak with the host to unban you "
+ "or try a different room."));
+const ConnectionError ErrorManager::WRONG_VERSION(
+ QT_TR_NOOP("Version mismatch! Please update to the latest version of yuzu. If the problem "
+ "persists, contact the room host and ask them to update the server."));
+const ConnectionError ErrorManager::WRONG_PASSWORD(QT_TR_NOOP("Incorrect password."));
+const ConnectionError ErrorManager::GENERIC_ERROR(QT_TR_NOOP(
+ "An unknown error occurred. If this error continues to occur, please open an issue"));
+const ConnectionError ErrorManager::LOST_CONNECTION(
+ QT_TR_NOOP("Connection to room lost. Try to reconnect."));
+const ConnectionError ErrorManager::HOST_KICKED(
+ QT_TR_NOOP("You have been kicked by the room host."));
+const ConnectionError ErrorManager::IP_COLLISION(
+ QT_TR_NOOP("IP address is already in use. Please choose another."));
+const ConnectionError ErrorManager::PERMISSION_DENIED(
+ QT_TR_NOOP("You do not have enough permission to perform this action."));
+const ConnectionError ErrorManager::NO_SUCH_USER(QT_TR_NOOP(
+ "The user you are trying to kick/ban could not be found.\nThey may have left the room."));
+const ConnectionError ErrorManager::NO_INTERFACE_SELECTED(QT_TR_NOOP(
+ "No valid network interface is selected.\nPlease go to Configure -> System -> Network and "
+ "make a selection."));
+
+static bool WarnMessage(const std::string& title, const std::string& text) {
+ return QMessageBox::Ok == QMessageBox::warning(nullptr, QObject::tr(title.c_str()),
+ QObject::tr(text.c_str()),
+ QMessageBox::Ok | QMessageBox::Cancel);
+}
+
+void ErrorManager::ShowError(const ConnectionError& e) {
+ QMessageBox::critical(nullptr, tr("Error"), tr(e.GetString().c_str()));
+}
+
+bool WarnGameRunning() {
+ return WarnMessage(
+ QT_TR_NOOP("Game already running"),
+ QT_TR_NOOP("Joining a room when the game is already running is discouraged "
+ "and can cause the room feature not to work correctly.\nProceed anyway?"));
+}
+
+bool WarnCloseRoom() {
+ return WarnMessage(
+ QT_TR_NOOP("Leave Room"),
+ QT_TR_NOOP("You are about to close the room. Any network connections will be closed."));
+}
+
+bool WarnDisconnect() {
+ return WarnMessage(
+ QT_TR_NOOP("Disconnect"),
+ QT_TR_NOOP("You are about to leave the room. Any network connections will be closed."));
+}
+
+} // namespace NetworkMessage
diff --git a/src/yuzu/multiplayer/message.h b/src/yuzu/multiplayer/message.h
new file mode 100644
index 000000000..f038b9a1f
--- /dev/null
+++ b/src/yuzu/multiplayer/message.h
@@ -0,0 +1,72 @@
+// SPDX-FileCopyrightText: Copyright 2017 Citra Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+#include <utility>
+
+namespace NetworkMessage {
+
+class ConnectionError {
+
+public:
+ explicit ConnectionError(std::string str) : err(std::move(str)) {}
+ const std::string& GetString() const {
+ return err;
+ }
+
+private:
+ std::string err;
+};
+
+class ErrorManager : QObject {
+ Q_OBJECT
+public:
+ /// When the nickname is considered invalid by the client
+ static const ConnectionError USERNAME_NOT_VALID;
+ static const ConnectionError ROOMNAME_NOT_VALID;
+ /// When the nickname is considered invalid by the room server
+ static const ConnectionError USERNAME_NOT_VALID_SERVER;
+ static const ConnectionError IP_ADDRESS_NOT_VALID;
+ static const ConnectionError PORT_NOT_VALID;
+ static const ConnectionError GAME_NOT_SELECTED;
+ static const ConnectionError NO_INTERNET;
+ static const ConnectionError UNABLE_TO_CONNECT;
+ static const ConnectionError ROOM_IS_FULL;
+ static const ConnectionError COULD_NOT_CREATE_ROOM;
+ static const ConnectionError HOST_BANNED;
+ static const ConnectionError WRONG_VERSION;
+ static const ConnectionError WRONG_PASSWORD;
+ static const ConnectionError GENERIC_ERROR;
+ static const ConnectionError LOST_CONNECTION;
+ static const ConnectionError HOST_KICKED;
+ static const ConnectionError IP_COLLISION;
+ static const ConnectionError PERMISSION_DENIED;
+ static const ConnectionError NO_SUCH_USER;
+ static const ConnectionError NO_INTERFACE_SELECTED;
+ /**
+ * Shows a standard QMessageBox with a error message
+ */
+ static void ShowError(const ConnectionError& e);
+};
+
+/**
+ * Show a standard QMessageBox with a warning message about joining a room when
+ * the game is already running
+ * return true if the user wants to close the network connection
+ */
+bool WarnGameRunning();
+
+/**
+ * Show a standard QMessageBox with a warning message about leaving the room
+ * return true if the user wants to close the network connection
+ */
+bool WarnCloseRoom();
+
+/**
+ * Show a standard QMessageBox with a warning message about disconnecting from the room
+ * return true if the user wants to disconnect
+ */
+bool WarnDisconnect();
+
+} // namespace NetworkMessage
diff --git a/src/yuzu/multiplayer/moderation_dialog.cpp b/src/yuzu/multiplayer/moderation_dialog.cpp
new file mode 100644
index 000000000..c9b8ed397
--- /dev/null
+++ b/src/yuzu/multiplayer/moderation_dialog.cpp
@@ -0,0 +1,112 @@
+// SPDX-FileCopyrightText: Copyright 2018 Citra Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include <QStandardItem>
+#include <QStandardItemModel>
+#include "network/network.h"
+#include "network/room_member.h"
+#include "ui_moderation_dialog.h"
+#include "yuzu/multiplayer/moderation_dialog.h"
+
+namespace Column {
+enum {
+ SUBJECT,
+ TYPE,
+ COUNT,
+};
+}
+
+ModerationDialog::ModerationDialog(Network::RoomNetwork& room_network_, QWidget* parent)
+ : QDialog(parent), ui(std::make_unique<Ui::ModerationDialog>()), room_network{room_network_} {
+ ui->setupUi(this);
+
+ qRegisterMetaType<Network::Room::BanList>();
+
+ if (auto member = room_network.GetRoomMember().lock()) {
+ callback_handle_status_message = member->BindOnStatusMessageReceived(
+ [this](const Network::StatusMessageEntry& status_message) {
+ emit StatusMessageReceived(status_message);
+ });
+ connect(this, &ModerationDialog::StatusMessageReceived, this,
+ &ModerationDialog::OnStatusMessageReceived);
+ callback_handle_ban_list = member->BindOnBanListReceived(
+ [this](const Network::Room::BanList& ban_list) { emit BanListReceived(ban_list); });
+ connect(this, &ModerationDialog::BanListReceived, this, &ModerationDialog::PopulateBanList);
+ }
+
+ // Initialize the UI
+ model = new QStandardItemModel(ui->ban_list_view);
+ model->insertColumns(0, Column::COUNT);
+ model->setHeaderData(Column::SUBJECT, Qt::Horizontal, tr("Subject"));
+ model->setHeaderData(Column::TYPE, Qt::Horizontal, tr("Type"));
+
+ ui->ban_list_view->setModel(model);
+
+ // Load the ban list in background
+ LoadBanList();
+
+ connect(ui->refresh, &QPushButton::clicked, this, [this] { LoadBanList(); });
+ connect(ui->unban, &QPushButton::clicked, this, [this] {
+ auto index = ui->ban_list_view->currentIndex();
+ SendUnbanRequest(model->item(index.row(), 0)->text());
+ });
+ connect(ui->ban_list_view, &QTreeView::clicked, [this] { ui->unban->setEnabled(true); });
+}
+
+ModerationDialog::~ModerationDialog() {
+ if (callback_handle_status_message) {
+ if (auto room = room_network.GetRoomMember().lock()) {
+ room->Unbind(callback_handle_status_message);
+ }
+ }
+
+ if (callback_handle_ban_list) {
+ if (auto room = room_network.GetRoomMember().lock()) {
+ room->Unbind(callback_handle_ban_list);
+ }
+ }
+}
+
+void ModerationDialog::LoadBanList() {
+ if (auto room = room_network.GetRoomMember().lock()) {
+ ui->refresh->setEnabled(false);
+ ui->refresh->setText(tr("Refreshing"));
+ ui->unban->setEnabled(false);
+ room->RequestBanList();
+ }
+}
+
+void ModerationDialog::PopulateBanList(const Network::Room::BanList& ban_list) {
+ model->removeRows(0, model->rowCount());
+ for (const auto& username : ban_list.first) {
+ QStandardItem* subject_item = new QStandardItem(QString::fromStdString(username));
+ QStandardItem* type_item = new QStandardItem(tr("Forum Username"));
+ model->invisibleRootItem()->appendRow({subject_item, type_item});
+ }
+ for (const auto& ip : ban_list.second) {
+ QStandardItem* subject_item = new QStandardItem(QString::fromStdString(ip));
+ QStandardItem* type_item = new QStandardItem(tr("IP Address"));
+ model->invisibleRootItem()->appendRow({subject_item, type_item});
+ }
+ for (int i = 0; i < Column::COUNT - 1; ++i) {
+ ui->ban_list_view->resizeColumnToContents(i);
+ }
+ ui->refresh->setEnabled(true);
+ ui->refresh->setText(tr("Refresh"));
+ ui->unban->setEnabled(false);
+}
+
+void ModerationDialog::SendUnbanRequest(const QString& subject) {
+ if (auto room = room_network.GetRoomMember().lock()) {
+ room->SendModerationRequest(Network::IdModUnban, subject.toStdString());
+ }
+}
+
+void ModerationDialog::OnStatusMessageReceived(const Network::StatusMessageEntry& status_message) {
+ if (status_message.type != Network::IdMemberBanned &&
+ status_message.type != Network::IdAddressUnbanned)
+ return;
+
+ // Update the ban list for ban/unban
+ LoadBanList();
+}
diff --git a/src/yuzu/multiplayer/moderation_dialog.h b/src/yuzu/multiplayer/moderation_dialog.h
new file mode 100644
index 000000000..e9e5daff7
--- /dev/null
+++ b/src/yuzu/multiplayer/moderation_dialog.h
@@ -0,0 +1,43 @@
+// SPDX-FileCopyrightText: Copyright 2018 Citra Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+#include <memory>
+#include <optional>
+#include <QDialog>
+#include "network/room.h"
+#include "network/room_member.h"
+
+namespace Ui {
+class ModerationDialog;
+}
+
+class QStandardItemModel;
+
+class ModerationDialog : public QDialog {
+ Q_OBJECT
+
+public:
+ explicit ModerationDialog(Network::RoomNetwork& room_network_, QWidget* parent = nullptr);
+ ~ModerationDialog();
+
+signals:
+ void StatusMessageReceived(const Network::StatusMessageEntry&);
+ void BanListReceived(const Network::Room::BanList&);
+
+private:
+ void LoadBanList();
+ void PopulateBanList(const Network::Room::BanList& ban_list);
+ void SendUnbanRequest(const QString& subject);
+ void OnStatusMessageReceived(const Network::StatusMessageEntry& status_message);
+
+ std::unique_ptr<Ui::ModerationDialog> ui;
+ QStandardItemModel* model;
+ Network::RoomMember::CallbackHandle<Network::StatusMessageEntry> callback_handle_status_message;
+ Network::RoomMember::CallbackHandle<Network::Room::BanList> callback_handle_ban_list;
+
+ Network::RoomNetwork& room_network;
+};
+
+Q_DECLARE_METATYPE(Network::Room::BanList);
diff --git a/src/yuzu/multiplayer/moderation_dialog.ui b/src/yuzu/multiplayer/moderation_dialog.ui
new file mode 100644
index 000000000..808d99414
--- /dev/null
+++ b/src/yuzu/multiplayer/moderation_dialog.ui
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>ModerationDialog</class>
+ <widget class="QDialog" name="ModerationDialog">
+ <property name="windowTitle">
+ <string>Moderation</string>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>500</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <layout class="QVBoxLayout">
+ <item>
+ <widget class="QGroupBox" name="ban_list_group_box">
+ <property name="title">
+ <string>Ban List</string>
+ </property>
+ <layout class="QVBoxLayout">
+ <item>
+ <layout class="QHBoxLayout">
+ <item>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="refresh">
+ <property name="text">
+ <string>Refreshing</string>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="unban">
+ <property name="text">
+ <string>Unban</string>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QTreeView" name="ban_list_view"/>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QDialogButtonBox" name="buttonBox">
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Ok</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <connections>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>accepted()</signal>
+ <receiver>ModerationDialog</receiver>
+ <slot>accept()</slot>
+ </connection>
+ </connections>
+ <resources/>
+</ui>
diff --git a/src/yuzu/multiplayer/state.cpp b/src/yuzu/multiplayer/state.cpp
new file mode 100644
index 000000000..ae2738ad4
--- /dev/null
+++ b/src/yuzu/multiplayer/state.cpp
@@ -0,0 +1,336 @@
+// SPDX-FileCopyrightText: Copyright 2018 Citra Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include <QAction>
+#include <QApplication>
+#include <QIcon>
+#include <QMessageBox>
+#include <QStandardItemModel>
+#include "common/announce_multiplayer_room.h"
+#include "common/logging/log.h"
+#include "core/core.h"
+#include "yuzu/game_list.h"
+#include "yuzu/multiplayer/client_room.h"
+#include "yuzu/multiplayer/direct_connect.h"
+#include "yuzu/multiplayer/host_room.h"
+#include "yuzu/multiplayer/lobby.h"
+#include "yuzu/multiplayer/message.h"
+#include "yuzu/multiplayer/state.h"
+#include "yuzu/uisettings.h"
+#include "yuzu/util/clickable_label.h"
+
+MultiplayerState::MultiplayerState(QWidget* parent, QStandardItemModel* game_list_model_,
+ QAction* leave_room_, QAction* show_room_, Core::System& system_)
+ : QWidget(parent), game_list_model(game_list_model_), leave_room(leave_room_),
+ show_room(show_room_), system{system_}, room_network{system.GetRoomNetwork()} {
+ if (auto member = room_network.GetRoomMember().lock()) {
+ // register the network structs to use in slots and signals
+ state_callback_handle = member->BindOnStateChanged(
+ [this](const Network::RoomMember::State& state) { emit NetworkStateChanged(state); });
+ connect(this, &MultiplayerState::NetworkStateChanged, this,
+ &MultiplayerState::OnNetworkStateChanged);
+ error_callback_handle = member->BindOnError(
+ [this](const Network::RoomMember::Error& error) { emit NetworkError(error); });
+ connect(this, &MultiplayerState::NetworkError, this, &MultiplayerState::OnNetworkError);
+ }
+
+ qRegisterMetaType<Network::RoomMember::State>();
+ qRegisterMetaType<Network::RoomMember::Error>();
+ qRegisterMetaType<WebService::WebResult>();
+ announce_multiplayer_session = std::make_shared<Core::AnnounceMultiplayerSession>(room_network);
+ announce_multiplayer_session->BindErrorCallback(
+ [this](const WebService::WebResult& result) { emit AnnounceFailed(result); });
+ connect(this, &MultiplayerState::AnnounceFailed, this, &MultiplayerState::OnAnnounceFailed);
+
+ status_text = new ClickableLabel(this);
+ status_icon = new ClickableLabel(this);
+
+ connect(status_text, &ClickableLabel::clicked, this, &MultiplayerState::OnOpenNetworkRoom);
+ connect(status_icon, &ClickableLabel::clicked, this, &MultiplayerState::OnOpenNetworkRoom);
+
+ connect(static_cast<QApplication*>(QApplication::instance()), &QApplication::focusChanged, this,
+ [this](QWidget* /*old*/, QWidget* now) {
+ if (client_room && client_room->isAncestorOf(now)) {
+ HideNotification();
+ }
+ });
+
+ retranslateUi();
+}
+
+MultiplayerState::~MultiplayerState() = default;
+
+void MultiplayerState::Close() {
+ if (state_callback_handle) {
+ if (auto member = room_network.GetRoomMember().lock()) {
+ member->Unbind(state_callback_handle);
+ }
+ }
+
+ if (error_callback_handle) {
+ if (auto member = room_network.GetRoomMember().lock()) {
+ member->Unbind(error_callback_handle);
+ }
+ }
+ if (host_room) {
+ host_room->close();
+ }
+ if (direct_connect) {
+ direct_connect->close();
+ }
+ if (client_room) {
+ client_room->close();
+ }
+ if (lobby) {
+ lobby->close();
+ }
+}
+
+void MultiplayerState::retranslateUi() {
+ status_text->setToolTip(tr("Current connection status"));
+
+ UpdateNotificationStatus();
+
+ if (lobby) {
+ lobby->RetranslateUi();
+ }
+ if (host_room) {
+ host_room->RetranslateUi();
+ }
+ if (client_room) {
+ client_room->RetranslateUi();
+ }
+ if (direct_connect) {
+ direct_connect->RetranslateUi();
+ }
+}
+
+void MultiplayerState::SetNotificationStatus(NotificationStatus status) {
+ notification_status = status;
+ UpdateNotificationStatus();
+}
+
+void MultiplayerState::UpdateNotificationStatus() {
+ switch (notification_status) {
+ case NotificationStatus::Unitialized:
+ status_icon->setPixmap(QIcon::fromTheme(QStringLiteral("disconnected")).pixmap(16));
+ status_text->setText(tr("Not Connected. Click here to find a room!"));
+ leave_room->setEnabled(false);
+ show_room->setEnabled(false);
+ break;
+ case NotificationStatus::Disconnected:
+ status_icon->setPixmap(QIcon::fromTheme(QStringLiteral("disconnected")).pixmap(16));
+ status_text->setText(tr("Not Connected"));
+ leave_room->setEnabled(false);
+ show_room->setEnabled(false);
+ break;
+ case NotificationStatus::Connected:
+ status_icon->setPixmap(QIcon::fromTheme(QStringLiteral("connected")).pixmap(16));
+ status_text->setText(tr("Connected"));
+ leave_room->setEnabled(true);
+ show_room->setEnabled(true);
+ break;
+ case NotificationStatus::Notification:
+ status_icon->setPixmap(
+ QIcon::fromTheme(QStringLiteral("connected_notification")).pixmap(16));
+ status_text->setText(tr("New Messages Received"));
+ leave_room->setEnabled(true);
+ show_room->setEnabled(true);
+ break;
+ }
+
+ // Clean up status bar if game is running
+ if (system.IsPoweredOn()) {
+ status_text->clear();
+ }
+}
+
+void MultiplayerState::OnNetworkStateChanged(const Network::RoomMember::State& state) {
+ LOG_DEBUG(Frontend, "Network State: {}", Network::GetStateStr(state));
+ if (state == Network::RoomMember::State::Joined ||
+ state == Network::RoomMember::State::Moderator) {
+
+ OnOpenNetworkRoom();
+ SetNotificationStatus(NotificationStatus::Connected);
+ } else {
+ SetNotificationStatus(NotificationStatus::Disconnected);
+ }
+
+ current_state = state;
+}
+
+void MultiplayerState::OnNetworkError(const Network::RoomMember::Error& error) {
+ LOG_DEBUG(Frontend, "Network Error: {}", Network::GetErrorStr(error));
+ switch (error) {
+ case Network::RoomMember::Error::LostConnection:
+ NetworkMessage::ErrorManager::ShowError(NetworkMessage::ErrorManager::LOST_CONNECTION);
+ break;
+ case Network::RoomMember::Error::HostKicked:
+ NetworkMessage::ErrorManager::ShowError(NetworkMessage::ErrorManager::HOST_KICKED);
+ break;
+ case Network::RoomMember::Error::CouldNotConnect:
+ NetworkMessage::ErrorManager::ShowError(NetworkMessage::ErrorManager::UNABLE_TO_CONNECT);
+ break;
+ case Network::RoomMember::Error::NameCollision:
+ NetworkMessage::ErrorManager::ShowError(
+ NetworkMessage::ErrorManager::USERNAME_NOT_VALID_SERVER);
+ break;
+ case Network::RoomMember::Error::IpCollision:
+ NetworkMessage::ErrorManager::ShowError(NetworkMessage::ErrorManager::IP_COLLISION);
+ break;
+ case Network::RoomMember::Error::RoomIsFull:
+ NetworkMessage::ErrorManager::ShowError(NetworkMessage::ErrorManager::ROOM_IS_FULL);
+ break;
+ case Network::RoomMember::Error::WrongPassword:
+ NetworkMessage::ErrorManager::ShowError(NetworkMessage::ErrorManager::WRONG_PASSWORD);
+ break;
+ case Network::RoomMember::Error::WrongVersion:
+ NetworkMessage::ErrorManager::ShowError(NetworkMessage::ErrorManager::WRONG_VERSION);
+ break;
+ case Network::RoomMember::Error::HostBanned:
+ NetworkMessage::ErrorManager::ShowError(NetworkMessage::ErrorManager::HOST_BANNED);
+ break;
+ case Network::RoomMember::Error::UnknownError:
+ NetworkMessage::ErrorManager::ShowError(NetworkMessage::ErrorManager::UNABLE_TO_CONNECT);
+ break;
+ case Network::RoomMember::Error::PermissionDenied:
+ NetworkMessage::ErrorManager::ShowError(NetworkMessage::ErrorManager::PERMISSION_DENIED);
+ break;
+ case Network::RoomMember::Error::NoSuchUser:
+ NetworkMessage::ErrorManager::ShowError(NetworkMessage::ErrorManager::NO_SUCH_USER);
+ break;
+ }
+}
+
+void MultiplayerState::OnAnnounceFailed(const WebService::WebResult& result) {
+ announce_multiplayer_session->Stop();
+ QMessageBox::warning(this, tr("Error"),
+ tr("Failed to update the room information. Please check your Internet "
+ "connection and try hosting the room again.\nDebug Message: ") +
+ QString::fromStdString(result.result_string),
+ QMessageBox::Ok);
+}
+
+void MultiplayerState::OnSaveConfig() {
+ emit SaveConfig();
+}
+
+void MultiplayerState::UpdateThemedIcons() {
+ if (show_notification) {
+ status_icon->setPixmap(
+ QIcon::fromTheme(QStringLiteral("connected_notification")).pixmap(16));
+ } else if (current_state == Network::RoomMember::State::Joined ||
+ current_state == Network::RoomMember::State::Moderator) {
+
+ status_icon->setPixmap(QIcon::fromTheme(QStringLiteral("connected")).pixmap(16));
+ } else {
+ status_icon->setPixmap(QIcon::fromTheme(QStringLiteral("disconnected")).pixmap(16));
+ }
+ if (client_room)
+ client_room->UpdateIconDisplay();
+}
+
+static void BringWidgetToFront(QWidget* widget) {
+ widget->show();
+ widget->activateWindow();
+ widget->raise();
+}
+
+void MultiplayerState::OnViewLobby() {
+ if (lobby == nullptr) {
+ lobby = new Lobby(this, game_list_model, announce_multiplayer_session, system);
+ connect(lobby, &Lobby::SaveConfig, this, &MultiplayerState::OnSaveConfig);
+ }
+ lobby->RefreshLobby();
+ BringWidgetToFront(lobby);
+}
+
+void MultiplayerState::OnCreateRoom() {
+ if (host_room == nullptr) {
+ host_room = new HostRoomWindow(this, game_list_model, announce_multiplayer_session, system);
+ connect(host_room, &HostRoomWindow::SaveConfig, this, &MultiplayerState::OnSaveConfig);
+ }
+ BringWidgetToFront(host_room);
+}
+
+bool MultiplayerState::OnCloseRoom() {
+ if (!NetworkMessage::WarnCloseRoom())
+ return false;
+ if (auto room = room_network.GetRoom().lock()) {
+ // if you are in a room, leave it
+ if (auto member = room_network.GetRoomMember().lock()) {
+ member->Leave();
+ LOG_DEBUG(Frontend, "Left the room (as a client)");
+ }
+
+ // if you are hosting a room, also stop hosting
+ if (room->GetState() != Network::Room::State::Open) {
+ return true;
+ }
+ // Save ban list
+ UISettings::values.multiplayer_ban_list = std::move(room->GetBanList());
+
+ room->Destroy();
+ announce_multiplayer_session->Stop();
+ LOG_DEBUG(Frontend, "Closed the room (as a server)");
+ }
+ return true;
+}
+
+void MultiplayerState::ShowNotification() {
+ if (client_room && client_room->isAncestorOf(QApplication::focusWidget()))
+ return; // Do not show notification if the chat window currently has focus
+ show_notification = true;
+ QApplication::alert(nullptr);
+ QApplication::beep();
+ SetNotificationStatus(NotificationStatus::Notification);
+}
+
+void MultiplayerState::HideNotification() {
+ show_notification = false;
+ SetNotificationStatus(NotificationStatus::Connected);
+}
+
+void MultiplayerState::OnOpenNetworkRoom() {
+ if (auto member = room_network.GetRoomMember().lock()) {
+ if (member->IsConnected()) {
+ if (client_room == nullptr) {
+ client_room = new ClientRoomWindow(this, room_network);
+ connect(client_room, &ClientRoomWindow::ShowNotification, this,
+ &MultiplayerState::ShowNotification);
+ }
+ BringWidgetToFront(client_room);
+ return;
+ }
+ }
+ // If the user is not a member of a room, show the lobby instead.
+ // This is currently only used on the clickable label in the status bar
+ OnViewLobby();
+}
+
+void MultiplayerState::OnDirectConnectToRoom() {
+ if (direct_connect == nullptr) {
+ direct_connect = new DirectConnectWindow(system, this);
+ connect(direct_connect, &DirectConnectWindow::SaveConfig, this,
+ &MultiplayerState::OnSaveConfig);
+ }
+ BringWidgetToFront(direct_connect);
+}
+
+bool MultiplayerState::IsHostingPublicRoom() const {
+ return announce_multiplayer_session->IsRunning();
+}
+
+void MultiplayerState::UpdateCredentials() {
+ announce_multiplayer_session->UpdateCredentials();
+}
+
+void MultiplayerState::UpdateGameList(QStandardItemModel* game_list) {
+ game_list_model = game_list;
+ if (lobby) {
+ lobby->UpdateGameList(game_list);
+ }
+ if (host_room) {
+ host_room->UpdateGameList(game_list);
+ }
+}
diff --git a/src/yuzu/multiplayer/state.h b/src/yuzu/multiplayer/state.h
new file mode 100644
index 000000000..5d681c5c6
--- /dev/null
+++ b/src/yuzu/multiplayer/state.h
@@ -0,0 +1,111 @@
+// SPDX-FileCopyrightText: Copyright 2018 Citra Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+#include <QWidget>
+#include "network/announce_multiplayer_session.h"
+#include "network/network.h"
+
+class QStandardItemModel;
+class Lobby;
+class HostRoomWindow;
+class ClientRoomWindow;
+class DirectConnectWindow;
+class ClickableLabel;
+
+namespace Core {
+class System;
+}
+
+class MultiplayerState : public QWidget {
+ Q_OBJECT;
+
+public:
+ enum class NotificationStatus {
+ Unitialized,
+ Disconnected,
+ Connected,
+ Notification,
+ };
+
+ explicit MultiplayerState(QWidget* parent, QStandardItemModel* game_list, QAction* leave_room,
+ QAction* show_room, Core::System& system_);
+ ~MultiplayerState();
+
+ /**
+ * Close all open multiplayer related dialogs
+ */
+ void Close();
+
+ void SetNotificationStatus(NotificationStatus state);
+
+ void UpdateNotificationStatus();
+
+ ClickableLabel* GetStatusText() const {
+ return status_text;
+ }
+
+ ClickableLabel* GetStatusIcon() const {
+ return status_icon;
+ }
+
+ void retranslateUi();
+
+ /**
+ * Whether a public room is being hosted or not.
+ * When this is true, Web Services configuration should be disabled.
+ */
+ bool IsHostingPublicRoom() const;
+
+ void UpdateCredentials();
+
+ /**
+ * Updates the multiplayer dialogs with a new game list model.
+ * This model should be the original model of the game list.
+ */
+ void UpdateGameList(QStandardItemModel* game_list);
+
+public slots:
+ void OnNetworkStateChanged(const Network::RoomMember::State& state);
+ void OnNetworkError(const Network::RoomMember::Error& error);
+ void OnViewLobby();
+ void OnCreateRoom();
+ bool OnCloseRoom();
+ void OnOpenNetworkRoom();
+ void OnDirectConnectToRoom();
+ void OnAnnounceFailed(const WebService::WebResult&);
+ void OnSaveConfig();
+ void UpdateThemedIcons();
+ void ShowNotification();
+ void HideNotification();
+
+signals:
+ void NetworkStateChanged(const Network::RoomMember::State&);
+ void NetworkError(const Network::RoomMember::Error&);
+ void AnnounceFailed(const WebService::WebResult&);
+ void SaveConfig();
+
+private:
+ Lobby* lobby = nullptr;
+ HostRoomWindow* host_room = nullptr;
+ ClientRoomWindow* client_room = nullptr;
+ DirectConnectWindow* direct_connect = nullptr;
+ ClickableLabel* status_icon = nullptr;
+ ClickableLabel* status_text = nullptr;
+ QStandardItemModel* game_list_model = nullptr;
+ QAction* leave_room;
+ QAction* show_room;
+ std::shared_ptr<Core::AnnounceMultiplayerSession> announce_multiplayer_session;
+ Network::RoomMember::State current_state = Network::RoomMember::State::Uninitialized;
+ NotificationStatus notification_status = NotificationStatus::Unitialized;
+ bool has_mod_perms = false;
+ Network::RoomMember::CallbackHandle<Network::RoomMember::State> state_callback_handle;
+ Network::RoomMember::CallbackHandle<Network::RoomMember::Error> error_callback_handle;
+
+ bool show_notification = false;
+ Core::System& system;
+ Network::RoomNetwork& room_network;
+};
+
+Q_DECLARE_METATYPE(WebService::WebResult);
diff --git a/src/yuzu/multiplayer/validation.h b/src/yuzu/multiplayer/validation.h
new file mode 100644
index 000000000..dabf860be
--- /dev/null
+++ b/src/yuzu/multiplayer/validation.h
@@ -0,0 +1,48 @@
+// SPDX-FileCopyrightText: Copyright 2017 Citra Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+#include <QRegExp>
+#include <QString>
+#include <QValidator>
+
+class Validation {
+public:
+ Validation()
+ : room_name(room_name_regex), nickname(nickname_regex), ip(ip_regex), port(0, UINT16_MAX) {}
+
+ ~Validation() = default;
+
+ const QValidator* GetRoomName() const {
+ return &room_name;
+ }
+ const QValidator* GetNickname() const {
+ return &nickname;
+ }
+ const QValidator* GetIP() const {
+ return &ip;
+ }
+ const QValidator* GetPort() const {
+ return &port;
+ }
+
+private:
+ /// room name can be alphanumeric and " " "_" "." and "-" and must have a size of 4-20
+ QRegExp room_name_regex = QRegExp(QStringLiteral("^[a-zA-Z0-9._- ]{4,20}$"));
+ QRegExpValidator room_name;
+
+ /// nickname can be alphanumeric and " " "_" "." and "-" and must have a size of 4-20
+ QRegExp nickname_regex = QRegExp(QStringLiteral("^[a-zA-Z0-9._- ]{4,20}$"));
+ QRegExpValidator nickname;
+
+ /// ipv4 address only
+ // TODO remove this when we support hostnames in direct connect
+ QRegExp ip_regex = QRegExp(QStringLiteral(
+ "(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|"
+ "2[0-4][0-9]|25[0-5])"));
+ QRegExpValidator ip;
+
+ /// port must be between 0 and 65535
+ QIntValidator port;
+};
diff --git a/src/yuzu/startup_checks.cpp b/src/yuzu/startup_checks.cpp
new file mode 100644
index 000000000..fc2693f9d
--- /dev/null
+++ b/src/yuzu/startup_checks.cpp
@@ -0,0 +1,158 @@
+// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include "video_core/vulkan_common/vulkan_wrapper.h"
+
+#ifdef _WIN32
+#include <cstring> // for memset, strncpy
+#include <processthreadsapi.h>
+#include <windows.h>
+#elif defined(YUZU_UNIX)
+#include <errno.h>
+#include <sys/wait.h>
+#include <unistd.h>
+#endif
+
+#include <cstdio>
+#include "video_core/vulkan_common/vulkan_instance.h"
+#include "video_core/vulkan_common/vulkan_library.h"
+#include "yuzu/startup_checks.h"
+
+void CheckVulkan() {
+ // Just start the Vulkan loader, this will crash if something is wrong
+ try {
+ Vulkan::vk::InstanceDispatch dld;
+ const Common::DynamicLibrary library = Vulkan::OpenLibrary();
+ const Vulkan::vk::Instance instance =
+ Vulkan::CreateInstance(library, dld, VK_API_VERSION_1_0);
+
+ } catch (const Vulkan::vk::Exception& exception) {
+ std::fprintf(stderr, "Failed to initialize Vulkan: %s\n", exception.what());
+ }
+}
+
+bool CheckEnvVars(bool* is_child) {
+#ifdef _WIN32
+ // Check environment variable to see if we are the child
+ char variable_contents[8];
+ const DWORD startup_check_var =
+ GetEnvironmentVariableA(STARTUP_CHECK_ENV_VAR, variable_contents, 8);
+ if (startup_check_var > 0 && std::strncmp(variable_contents, ENV_VAR_ENABLED_TEXT, 8) == 0) {
+ CheckVulkan();
+ return true;
+ }
+
+ // Don't perform startup checks if we are a child process
+ char is_child_s[8];
+ const DWORD is_child_len = GetEnvironmentVariableA(IS_CHILD_ENV_VAR, is_child_s, 8);
+ if (is_child_len > 0 && std::strncmp(is_child_s, ENV_VAR_ENABLED_TEXT, 8) == 0) {
+ *is_child = true;
+ return false;
+ } else if (!SetEnvironmentVariableA(IS_CHILD_ENV_VAR, ENV_VAR_ENABLED_TEXT)) {
+ std::fprintf(stderr, "SetEnvironmentVariableA failed to set %s with error %d\n",
+ IS_CHILD_ENV_VAR, GetLastError());
+ return true;
+ }
+#endif
+ return false;
+}
+
+bool StartupChecks(const char* arg0, bool* has_broken_vulkan, bool perform_vulkan_check) {
+#ifdef _WIN32
+ // Set the startup variable for child processes
+ const bool env_var_set = SetEnvironmentVariableA(STARTUP_CHECK_ENV_VAR, ENV_VAR_ENABLED_TEXT);
+ if (!env_var_set) {
+ std::fprintf(stderr, "SetEnvironmentVariableA failed to set %s with error %d\n",
+ STARTUP_CHECK_ENV_VAR, GetLastError());
+ return false;
+ }
+
+ if (perform_vulkan_check) {
+ // Spawn child process that performs Vulkan check
+ PROCESS_INFORMATION process_info;
+ std::memset(&process_info, '\0', sizeof(process_info));
+
+ if (!SpawnChild(arg0, &process_info, 0)) {
+ return false;
+ }
+
+ // Wait until the processs exits and get exit code from it
+ WaitForSingleObject(process_info.hProcess, INFINITE);
+ DWORD exit_code = STILL_ACTIVE;
+ const int err = GetExitCodeProcess(process_info.hProcess, &exit_code);
+ if (err == 0) {
+ std::fprintf(stderr, "GetExitCodeProcess failed with error %d\n", GetLastError());
+ }
+
+ // Vulkan is broken if the child crashed (return value is not zero)
+ *has_broken_vulkan = (exit_code != 0);
+
+ if (CloseHandle(process_info.hProcess) == 0) {
+ std::fprintf(stderr, "CloseHandle failed with error %d\n", GetLastError());
+ }
+ if (CloseHandle(process_info.hThread) == 0) {
+ std::fprintf(stderr, "CloseHandle failed with error %d\n", GetLastError());
+ }
+ }
+
+ if (!SetEnvironmentVariableA(STARTUP_CHECK_ENV_VAR, nullptr)) {
+ std::fprintf(stderr, "SetEnvironmentVariableA failed to clear %s with error %d\n",
+ STARTUP_CHECK_ENV_VAR, GetLastError());
+ }
+
+#elif defined(YUZU_UNIX)
+ if (perform_vulkan_check) {
+ const pid_t pid = fork();
+ if (pid == 0) {
+ CheckVulkan();
+ return true;
+ } else if (pid == -1) {
+ const int err = errno;
+ std::fprintf(stderr, "fork failed with error %d\n", err);
+ return false;
+ }
+
+ // Get exit code from child process
+ int status;
+ const int r_val = wait(&status);
+ if (r_val == -1) {
+ const int err = errno;
+ std::fprintf(stderr, "wait failed with error %d\n", err);
+ return false;
+ }
+ // Vulkan is broken if the child crashed (return value is not zero)
+ *has_broken_vulkan = (status != 0);
+ }
+#endif
+ return false;
+}
+
+#ifdef _WIN32
+bool SpawnChild(const char* arg0, PROCESS_INFORMATION* pi, int flags) {
+ STARTUPINFOA startup_info;
+
+ std::memset(&startup_info, '\0', sizeof(startup_info));
+ startup_info.cb = sizeof(startup_info);
+
+ char p_name[255];
+ std::strncpy(p_name, arg0, 255);
+
+ const bool process_created = CreateProcessA(nullptr, // lpApplicationName
+ p_name, // lpCommandLine
+ nullptr, // lpProcessAttributes
+ nullptr, // lpThreadAttributes
+ false, // bInheritHandles
+ flags, // dwCreationFlags
+ nullptr, // lpEnvironment
+ nullptr, // lpCurrentDirectory
+ &startup_info, // lpStartupInfo
+ pi // lpProcessInformation
+ );
+ if (!process_created) {
+ std::fprintf(stderr, "CreateProcessA failed with error %d\n", GetLastError());
+ return false;
+ }
+
+ return true;
+}
+#endif
diff --git a/src/yuzu/startup_checks.h b/src/yuzu/startup_checks.h
new file mode 100644
index 000000000..d8e563be6
--- /dev/null
+++ b/src/yuzu/startup_checks.h
@@ -0,0 +1,20 @@
+// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+#ifdef _WIN32
+#include <windows.h>
+#endif
+
+constexpr char IS_CHILD_ENV_VAR[] = "YUZU_IS_CHILD";
+constexpr char STARTUP_CHECK_ENV_VAR[] = "YUZU_DO_STARTUP_CHECKS";
+constexpr char ENV_VAR_ENABLED_TEXT[] = "ON";
+
+void CheckVulkan();
+bool CheckEnvVars(bool* is_child);
+bool StartupChecks(const char* arg0, bool* has_broken_vulkan, bool perform_vulkan_check);
+
+#ifdef _WIN32
+bool SpawnChild(const char* arg0, PROCESS_INFORMATION* pi, int flags);
+#endif
diff --git a/src/yuzu/uisettings.cpp b/src/yuzu/uisettings.cpp
index 21683576c..2c1b547fb 100644
--- a/src/yuzu/uisettings.cpp
+++ b/src/yuzu/uisettings.cpp
@@ -1,6 +1,5 @@
-// Copyright 2016 Citra Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: 2016 Citra Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#include "yuzu/uisettings.h"
@@ -15,6 +14,14 @@ const Themes themes{{
{"Midnight Blue Colorful", "colorful_midnight_blue"},
}};
+bool IsDarkTheme() {
+ const auto& theme = UISettings::values.theme;
+ return theme == QStringLiteral("qdarkstyle") ||
+ theme == QStringLiteral("qdarkstyle_midnight_blue") ||
+ theme == QStringLiteral("colorful_dark") ||
+ theme == QStringLiteral("colorful_midnight_blue");
+}
+
Values values = {};
} // namespace UISettings
diff --git a/src/yuzu/uisettings.h b/src/yuzu/uisettings.h
index 06e8b46da..753797efc 100644
--- a/src/yuzu/uisettings.h
+++ b/src/yuzu/uisettings.h
@@ -1,6 +1,5 @@
-// Copyright 2016 Citra Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: 2016 Citra Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
@@ -17,6 +16,8 @@
namespace UISettings {
+bool IsDarkTheme();
+
struct ContextualShortcut {
QString keyseq;
QString controller_keyseq;
@@ -62,26 +63,28 @@ struct Values {
QByteArray gamelist_header_state;
QByteArray microprofile_geometry;
- Settings::BasicSetting<bool> microprofile_visible{false, "microProfileDialogVisible"};
+ Settings::Setting<bool> microprofile_visible{false, "microProfileDialogVisible"};
- Settings::BasicSetting<bool> single_window_mode{true, "singleWindowMode"};
- Settings::BasicSetting<bool> fullscreen{false, "fullscreen"};
- Settings::BasicSetting<bool> display_titlebar{true, "displayTitleBars"};
- Settings::BasicSetting<bool> show_filter_bar{true, "showFilterBar"};
- Settings::BasicSetting<bool> show_status_bar{true, "showStatusBar"};
+ Settings::Setting<bool> single_window_mode{true, "singleWindowMode"};
+ Settings::Setting<bool> fullscreen{false, "fullscreen"};
+ Settings::Setting<bool> display_titlebar{true, "displayTitleBars"};
+ Settings::Setting<bool> show_filter_bar{true, "showFilterBar"};
+ Settings::Setting<bool> show_status_bar{true, "showStatusBar"};
- Settings::BasicSetting<bool> confirm_before_closing{true, "confirmClose"};
- Settings::BasicSetting<bool> first_start{true, "firstStart"};
- Settings::BasicSetting<bool> pause_when_in_background{false, "pauseWhenInBackground"};
- Settings::BasicSetting<bool> mute_when_in_background{false, "muteWhenInBackground"};
- Settings::BasicSetting<bool> hide_mouse{true, "hideInactiveMouse"};
+ Settings::Setting<bool> confirm_before_closing{true, "confirmClose"};
+ Settings::Setting<bool> first_start{true, "firstStart"};
+ Settings::Setting<bool> pause_when_in_background{false, "pauseWhenInBackground"};
+ Settings::Setting<bool> mute_when_in_background{false, "muteWhenInBackground"};
+ Settings::Setting<bool> hide_mouse{true, "hideInactiveMouse"};
+ // Set when Vulkan is known to crash the application
+ bool has_broken_vulkan = false;
- Settings::BasicSetting<bool> select_user_on_boot{false, "select_user_on_boot"};
+ Settings::Setting<bool> select_user_on_boot{false, "select_user_on_boot"};
// Discord RPC
- Settings::BasicSetting<bool> enable_discord_presence{true, "enable_discord_presence"};
+ Settings::Setting<bool> enable_discord_presence{true, "enable_discord_presence"};
- Settings::BasicSetting<bool> enable_screenshot_save_as{true, "enable_screenshot_save_as"};
+ Settings::Setting<bool> enable_screenshot_save_as{true, "enable_screenshot_save_as"};
QString roms_path;
QString symbols_path;
@@ -96,24 +99,39 @@ struct Values {
// Shortcut name <Shortcut, context>
std::vector<Shortcut> shortcuts;
- Settings::BasicSetting<uint32_t> callout_flags{0, "calloutFlags"};
+ Settings::Setting<uint32_t> callout_flags{0, "calloutFlags"};
+
+ // multiplayer settings
+ Settings::Setting<QString> multiplayer_nickname{{}, "nickname"};
+ Settings::Setting<QString> multiplayer_ip{{}, "ip"};
+ Settings::SwitchableSetting<uint, true> multiplayer_port{24872, 0, UINT16_MAX, "port"};
+ Settings::Setting<QString> multiplayer_room_nickname{{}, "room_nickname"};
+ Settings::Setting<QString> multiplayer_room_name{{}, "room_name"};
+ Settings::SwitchableSetting<uint, true> multiplayer_max_player{8, 0, 8, "max_player"};
+ Settings::SwitchableSetting<uint, true> multiplayer_room_port{24872, 0, UINT16_MAX,
+ "room_port"};
+ Settings::SwitchableSetting<uint, true> multiplayer_host_type{0, 0, 1, "host_type"};
+ Settings::Setting<qulonglong> multiplayer_game_id{{}, "game_id"};
+ Settings::Setting<QString> multiplayer_room_description{{}, "room_description"};
+ std::pair<std::vector<std::string>, std::vector<std::string>> multiplayer_ban_list;
// logging
- Settings::BasicSetting<bool> show_console{false, "showConsole"};
+ Settings::Setting<bool> show_console{false, "showConsole"};
// Game List
- Settings::BasicSetting<bool> show_add_ons{true, "show_add_ons"};
- Settings::BasicSetting<uint32_t> game_icon_size{64, "game_icon_size"};
- Settings::BasicSetting<uint32_t> folder_icon_size{48, "folder_icon_size"};
- Settings::BasicSetting<uint8_t> row_1_text_id{3, "row_1_text_id"};
- Settings::BasicSetting<uint8_t> row_2_text_id{2, "row_2_text_id"};
+ Settings::Setting<bool> show_add_ons{true, "show_add_ons"};
+ Settings::Setting<uint32_t> game_icon_size{64, "game_icon_size"};
+ Settings::Setting<uint32_t> folder_icon_size{48, "folder_icon_size"};
+ Settings::Setting<uint8_t> row_1_text_id{3, "row_1_text_id"};
+ Settings::Setting<uint8_t> row_2_text_id{2, "row_2_text_id"};
std::atomic_bool is_game_list_reload_pending{false};
- Settings::BasicSetting<bool> cache_game_list{true, "cache_game_list"};
- Settings::BasicSetting<bool> favorites_expanded{true, "favorites_expanded"};
+ Settings::Setting<bool> cache_game_list{true, "cache_game_list"};
+ Settings::Setting<bool> favorites_expanded{true, "favorites_expanded"};
QVector<u64> favorited_ids;
bool configuration_applied;
bool reset_to_defaults;
+ Settings::Setting<bool> disable_web_applet{true, "disable_web_applet"};
};
extern Values values;
diff --git a/src/yuzu/util/clickable_label.cpp b/src/yuzu/util/clickable_label.cpp
new file mode 100644
index 000000000..89d14190a
--- /dev/null
+++ b/src/yuzu/util/clickable_label.cpp
@@ -0,0 +1,11 @@
+// SPDX-FileCopyrightText: Copyright 2017 Citra Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include "yuzu/util/clickable_label.h"
+
+ClickableLabel::ClickableLabel(QWidget* parent, [[maybe_unused]] Qt::WindowFlags f)
+ : QLabel(parent) {}
+
+void ClickableLabel::mouseReleaseEvent([[maybe_unused]] QMouseEvent* event) {
+ emit clicked();
+}
diff --git a/src/yuzu/util/clickable_label.h b/src/yuzu/util/clickable_label.h
new file mode 100644
index 000000000..4fe744150
--- /dev/null
+++ b/src/yuzu/util/clickable_label.h
@@ -0,0 +1,21 @@
+// SPDX-FileCopyrightText: Copyright 2017 Citra Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+#include <QLabel>
+#include <QWidget>
+
+class ClickableLabel : public QLabel {
+ Q_OBJECT
+
+public:
+ explicit ClickableLabel(QWidget* parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
+ ~ClickableLabel() = default;
+
+signals:
+ void clicked();
+
+protected:
+ void mouseReleaseEvent(QMouseEvent* event);
+};
diff --git a/src/yuzu/util/controller_navigation.cpp b/src/yuzu/util/controller_navigation.cpp
index c2b13123d..d49ae67cd 100644
--- a/src/yuzu/util/controller_navigation.cpp
+++ b/src/yuzu/util/controller_navigation.cpp
@@ -1,6 +1,5 @@
-// Copyright 2021 yuzu Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included
+// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#include "common/settings_input.h"
#include "core/hid/emulated_controller.h"
@@ -39,7 +38,7 @@ void ControllerNavigation::TriggerButton(Settings::NativeButton::Values native_b
}
void ControllerNavigation::ControllerUpdateEvent(Core::HID::ControllerTriggerType type) {
- std::lock_guard lock{mutex};
+ std::scoped_lock lock{mutex};
if (!Settings::values.controller_navigation) {
return;
}
diff --git a/src/yuzu/util/controller_navigation.h b/src/yuzu/util/controller_navigation.h
index 7c616a088..86e210368 100644
--- a/src/yuzu/util/controller_navigation.h
+++ b/src/yuzu/util/controller_navigation.h
@@ -1,6 +1,5 @@
-// Copyright 2021 yuzu Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included
+// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
diff --git a/src/yuzu/util/limitable_input_dialog.cpp b/src/yuzu/util/limitable_input_dialog.cpp
index 6fea41f95..bbb370595 100644
--- a/src/yuzu/util/limitable_input_dialog.cpp
+++ b/src/yuzu/util/limitable_input_dialog.cpp
@@ -1,6 +1,5 @@
-// Copyright 2018 yuzu Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#include <QDialogButtonBox>
#include <QLabel>
diff --git a/src/yuzu/util/limitable_input_dialog.h b/src/yuzu/util/limitable_input_dialog.h
index a8e31098b..f261f1a0f 100644
--- a/src/yuzu/util/limitable_input_dialog.h
+++ b/src/yuzu/util/limitable_input_dialog.h
@@ -1,6 +1,5 @@
-// Copyright 2018 yuzu Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
diff --git a/src/yuzu/util/overlay_dialog.cpp b/src/yuzu/util/overlay_dialog.cpp
index c66dfbdff..b27954512 100644
--- a/src/yuzu/util/overlay_dialog.cpp
+++ b/src/yuzu/util/overlay_dialog.cpp
@@ -1,6 +1,5 @@
-// Copyright 2021 yuzu Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#include <QKeyEvent>
#include <QScreen>
diff --git a/src/yuzu/util/overlay_dialog.h b/src/yuzu/util/overlay_dialog.h
index d8a140ff3..39c44393c 100644
--- a/src/yuzu/util/overlay_dialog.h
+++ b/src/yuzu/util/overlay_dialog.h
@@ -1,10 +1,8 @@
-// Copyright 2021 yuzu Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
-#include <array>
#include <atomic>
#include <memory>
#include <thread>
diff --git a/src/yuzu/util/sequence_dialog/sequence_dialog.cpp b/src/yuzu/util/sequence_dialog/sequence_dialog.cpp
index bb5f74ec4..4b10fa517 100644
--- a/src/yuzu/util/sequence_dialog/sequence_dialog.cpp
+++ b/src/yuzu/util/sequence_dialog/sequence_dialog.cpp
@@ -1,6 +1,5 @@
-// Copyright 2018 Citra Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: 2018 Citra Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#include <QDialogButtonBox>
#include <QKeySequenceEdit>
diff --git a/src/yuzu/util/sequence_dialog/sequence_dialog.h b/src/yuzu/util/sequence_dialog/sequence_dialog.h
index 969c77740..85e146d40 100644
--- a/src/yuzu/util/sequence_dialog/sequence_dialog.h
+++ b/src/yuzu/util/sequence_dialog/sequence_dialog.h
@@ -1,6 +1,5 @@
-// Copyright 2018 Citra Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: 2018 Citra Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
diff --git a/src/yuzu/util/url_request_interceptor.cpp b/src/yuzu/util/url_request_interceptor.cpp
index b637e771e..996097e35 100644
--- a/src/yuzu/util/url_request_interceptor.cpp
+++ b/src/yuzu/util/url_request_interceptor.cpp
@@ -1,6 +1,5 @@
-// Copyright 2020 yuzu Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#ifdef YUZU_USE_QT_WEB_ENGINE
diff --git a/src/yuzu/util/url_request_interceptor.h b/src/yuzu/util/url_request_interceptor.h
index 8a7f7499f..9831e1523 100644
--- a/src/yuzu/util/url_request_interceptor.h
+++ b/src/yuzu/util/url_request_interceptor.h
@@ -1,6 +1,5 @@
-// Copyright 2020 yuzu Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
diff --git a/src/yuzu/util/util.cpp b/src/yuzu/util/util.cpp
index ef31bc2d2..5c3e4589e 100644
--- a/src/yuzu/util/util.cpp
+++ b/src/yuzu/util/util.cpp
@@ -1,6 +1,5 @@
-// Copyright 2015 Citra Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: 2015 Citra Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#include <array>
#include <cmath>
diff --git a/src/yuzu/util/util.h b/src/yuzu/util/util.h
index e6790f260..39dd2d895 100644
--- a/src/yuzu/util/util.h
+++ b/src/yuzu/util/util.h
@@ -1,6 +1,5 @@
-// Copyright 2015 Citra Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: 2015 Citra Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
diff --git a/src/yuzu/yuzu.qrc b/src/yuzu/yuzu.qrc
index 5733cac98..855df05fd 100644
--- a/src/yuzu/yuzu.qrc
+++ b/src/yuzu/yuzu.qrc
@@ -1,3 +1,8 @@
+<!--
+SPDX-FileCopyrightText: 2021 yuzu Emulator Project
+SPDX-License-Identifier: GPL-2.0-or-later
+-->
+
<RCC>
<qresource prefix="/img">
<file alias="yuzu.ico">../../dist/yuzu.ico</file>
diff --git a/src/yuzu/yuzu.rc b/src/yuzu/yuzu.rc
index 4a3645a71..1fc74d065 100644
--- a/src/yuzu/yuzu.rc
+++ b/src/yuzu/yuzu.rc
@@ -1,3 +1,6 @@
+// SPDX-FileCopyrightText: 2018 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
+
#include "winresrc.h"
/////////////////////////////////////////////////////////////////////////////
//