diff options
Diffstat (limited to 'src/yuzu')
223 files changed, 0 insertions, 59787 deletions
diff --git a/src/yuzu/CMakeLists.txt b/src/yuzu/CMakeLists.txt deleted file mode 100644 index 0259a8c29..000000000 --- a/src/yuzu/CMakeLists.txt +++ /dev/null @@ -1,480 +0,0 @@ -# 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) -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -# Set the RPATH for Qt Libraries -# This must be done before the `yuzu` target is created -if (YUZU_USE_BUNDLED_QT AND (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")) - set(CMAKE_BUILD_RPATH "${CMAKE_BINARY_DIR}/bin/lib/") -endif() - -add_executable(yuzu - Info.plist - about_dialog.cpp - about_dialog.h - aboutdialog.ui - applets/qt_amiibo_settings.cpp - applets/qt_amiibo_settings.h - applets/qt_amiibo_settings.ui - applets/qt_controller.cpp - applets/qt_controller.h - applets/qt_controller.ui - applets/qt_error.cpp - applets/qt_error.h - applets/qt_profile_select.cpp - applets/qt_profile_select.h - applets/qt_software_keyboard.cpp - applets/qt_software_keyboard.h - applets/qt_software_keyboard.ui - applets/qt_web_browser.cpp - applets/qt_web_browser.h - applets/qt_web_browser_scripts.h - bootmanager.cpp - bootmanager.h - compatdb.ui - compatibility_list.cpp - compatibility_list.h - configuration/configuration_shared.cpp - configuration/configuration_shared.h - configuration/configure.ui - configuration/configure_applets.cpp - configuration/configure_applets.h - configuration/configure_applets.ui - 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 - configuration/configure_cpu_debug.cpp - configuration/configure_cpu_debug.h - configuration/configure_cpu_debug.ui - configuration/configure_debug.cpp - configuration/configure_debug.h - configuration/configure_debug.ui - configuration/configure_debug_controller.cpp - configuration/configure_debug_controller.h - configuration/configure_debug_controller.ui - configuration/configure_debug_tab.cpp - configuration/configure_debug_tab.h - configuration/configure_debug_tab.ui - configuration/configure_dialog.cpp - configuration/configure_dialog.h - configuration/configure_filesystem.cpp - configuration/configure_filesystem.h - configuration/configure_filesystem.ui - configuration/configure_general.cpp - configuration/configure_general.h - configuration/configure_general.ui - configuration/configure_graphics.cpp - configuration/configure_graphics.h - configuration/configure_graphics.ui - configuration/configure_graphics_advanced.cpp - configuration/configure_graphics_advanced.h - configuration/configure_graphics_advanced.ui - configuration/configure_hotkeys.cpp - configuration/configure_hotkeys.h - configuration/configure_hotkeys.ui - configuration/configure_input.cpp - configuration/configure_input.h - configuration/configure_input.ui - configuration/configure_input_advanced.cpp - configuration/configure_input_advanced.h - configuration/configure_input_advanced.ui - configuration/configure_input_per_game.cpp - configuration/configure_input_per_game.h - configuration/configure_input_per_game.ui - configuration/configure_input_player.cpp - configuration/configure_input_player.h - configuration/configure_input_player.ui - configuration/configure_input_player_widget.cpp - configuration/configure_input_player_widget.h - configuration/configure_input_profile_dialog.cpp - configuration/configure_input_profile_dialog.h - configuration/configure_input_profile_dialog.ui - configuration/configure_linux_tab.cpp - configuration/configure_linux_tab.h - configuration/configure_linux_tab.ui - configuration/configure_mouse_panning.cpp - configuration/configure_mouse_panning.h - configuration/configure_mouse_panning.ui - configuration/configure_motion_touch.cpp - configuration/configure_motion_touch.h - configuration/configure_motion_touch.ui - configuration/configure_per_game.cpp - configuration/configure_per_game.h - configuration/configure_per_game.ui - configuration/configure_per_game_addons.cpp - configuration/configure_per_game_addons.h - configuration/configure_per_game_addons.ui - 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 - configuration/configure_system.cpp - configuration/configure_system.h - configuration/configure_system.ui - configuration/configure_tas.cpp - configuration/configure_tas.h - configuration/configure_tas.ui - configuration/configure_touch_from_button.cpp - configuration/configure_touch_from_button.h - configuration/configure_touch_from_button.ui - configuration/configure_touchscreen_advanced.cpp - configuration/configure_touchscreen_advanced.h - configuration/configure_touchscreen_advanced.ui - configuration/configure_touch_widget.h - configuration/configure_ui.cpp - configuration/configure_ui.h - configuration/configure_ui.ui - configuration/configure_vibration.cpp - configuration/configure_vibration.h - configuration/configure_vibration.ui - configuration/configure_web.cpp - configuration/configure_web.h - configuration/configure_web.ui - configuration/input_profiles.cpp - configuration/input_profiles.h - configuration/shared_translation.cpp - configuration/shared_translation.h - configuration/shared_widget.cpp - configuration/shared_widget.h - configuration/qt_config.cpp - configuration/qt_config.h - debugger/console.cpp - debugger/console.h - debugger/controller.cpp - debugger/controller.h - debugger/profiler.cpp - debugger/profiler.h - debugger/wait_tree.cpp - debugger/wait_tree.h - discord.h - game_list.cpp - game_list.h - game_list_p.h - game_list_worker.cpp - game_list_worker.h - hotkeys.cpp - hotkeys.h - install_dialog.cpp - install_dialog.h - loading_screen.cpp - loading_screen.h - loading_screen.ui - 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 - play_time_manager.cpp - play_time_manager.h - precompiled_headers.h - qt_common.cpp - qt_common.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 - util/limitable_input_dialog.h - util/overlay_dialog.cpp - util/overlay_dialog.h - util/overlay_dialog.ui - util/sequence_dialog/sequence_dialog.cpp - util/sequence_dialog/sequence_dialog.h - util/url_request_interceptor.cpp - util/url_request_interceptor.h - util/util.cpp - util/util.h - vk_device_info.cpp - vk_device_info.h - compatdb.cpp - compatdb.h - yuzu.qrc - yuzu.rc -) - -if (YUZU_CRASH_DUMPS) - target_sources(yuzu PRIVATE - breakpad.cpp - breakpad.h - ) - - target_link_libraries(yuzu PRIVATE libbreakpad_client) - target_compile_definitions(yuzu PRIVATE YUZU_CRASH_DUMPS) -endif() - -if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - target_compile_definitions(yuzu PRIVATE - $<$<VERSION_LESS:$<CXX_COMPILER_VERSION>,15>:CANNOT_EXPLICITLY_INSTANTIATE> - ) -endif() - -file(GLOB COMPAT_LIST - ${PROJECT_BINARY_DIR}/dist/compatibility_list/compatibility_list.qrc - ${PROJECT_BINARY_DIR}/dist/compatibility_list/compatibility_list.json) -file(GLOB_RECURSE ICONS ${PROJECT_SOURCE_DIR}/dist/icons/*) -file(GLOB_RECURSE THEMES ${PROJECT_SOURCE_DIR}/dist/qt_themes/*) - -if (ENABLE_QT_TRANSLATION) - set(YUZU_QT_LANGUAGES "${PROJECT_SOURCE_DIR}/dist/languages" CACHE PATH "Path to the translation bundle for the Qt frontend") - option(GENERATE_QT_TRANSLATION "Generate en.ts as the translation source file" OFF) - option(WORKAROUND_BROKEN_LUPDATE "Run lupdate directly through CMake if Qt's convenience wrappers don't work" OFF) - - # Update source TS file if enabled - if (GENERATE_QT_TRANSLATION) - get_target_property(SRCS yuzu SOURCES) - # 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") - if (WORKAROUND_BROKEN_LUPDATE) - add_custom_command(OUTPUT ${YUZU_QT_LANGUAGES}/en.ts - COMMAND lupdate - -source-language en_US - -target-language en_US - ${SRCS} - ${UIS} - -ts ${YUZU_QT_LANGUAGES}/en.ts - DEPENDS - ${SRCS} - ${UIS} - WORKING_DIRECTORY - ${CMAKE_CURRENT_SOURCE_DIR} - ) - else() - qt_create_translation(QM_FILES - ${SRCS} - ${UIS} - ${YUZU_QT_LANGUAGES}/en.ts - OPTIONS - -source-language en_US - -target-language en_US - ) - endif() - - # 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") - if (WORKAROUND_BROKEN_LUPDATE) - add_custom_command(OUTPUT ${GENERATED_PLURALS_FILE} - COMMAND lupdate - -source-language en_US - -target-language en_US - ${SRCS} - ${UIS} - -ts ${GENERATED_PLURALS_FILE} - DEPENDS - ${SRCS} - ${UIS} - WORKING_DIRECTORY - ${CMAKE_CURRENT_SOURCE_DIR} - ) - else() - qt_create_translation(QM_FILES ${SRCS} ${UIS} ${GENERATED_PLURALS_FILE} OPTIONS -pluralonly -source-language en_US -target-language en_US) - endif() - - add_custom_target(translation ALL DEPENDS ${YUZU_QT_LANGUAGES}/en.ts ${GENERATED_PLURALS_FILE}) - endif() - - # Find all TS files except en.ts - file(GLOB_RECURSE LANGUAGES_TS ${YUZU_QT_LANGUAGES}/*.ts) - list(REMOVE_ITEM LANGUAGES_TS ${YUZU_QT_LANGUAGES}/en.ts) - - # Compile TS files to QM files - 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) - file(WRITE ${LANGUAGES_QRC} "<RCC><qresource prefix=\"languages\">\n") - foreach (QM ${LANGUAGES_QM}) - get_filename_component(QM_FILE ${QM} NAME) - file(APPEND ${LANGUAGES_QRC} "<file>${QM_FILE}</file>\n") - endforeach (QM) - file(APPEND ${LANGUAGES_QRC} "</qresource></RCC>") - - # Add the QRC file to package in all QM files - qt_add_resources(LANGUAGES ${LANGUAGES_QRC}) -else() - set(LANGUAGES) -endif() - -target_sources(yuzu - PRIVATE - ${COMPAT_LIST} - ${ICONS} - ${LANGUAGES} - ${THEMES} -) - -if (APPLE) - set(MACOSX_ICON "../../dist/yuzu.icns") - set_source_files_properties(${MACOSX_ICON} PROPERTIES MACOSX_PACKAGE_LOCATION Resources) - target_sources(yuzu PRIVATE ${MACOSX_ICON}) - set_target_properties(yuzu PROPERTIES MACOSX_BUNDLE TRUE) - set_target_properties(yuzu PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist) - - if (NOT USE_SYSTEM_MOLTENVK) - set(MOLTENVK_PLATFORM "macOS") - set(MOLTENVK_VERSION "v1.2.7") - download_moltenvk_external(${MOLTENVK_PLATFORM} ${MOLTENVK_VERSION}) - endif() - find_library(MOLTENVK_LIBRARY MoltenVK REQUIRED) - message(STATUS "Using MoltenVK at ${MOLTENVK_LIBRARY}.") - set_source_files_properties(${MOLTENVK_LIBRARY} PROPERTIES MACOSX_PACKAGE_LOCATION Frameworks - XCODE_FILE_ATTRIBUTES "CodeSignOnCopy") - target_sources(yuzu PRIVATE ${MOLTENVK_LIBRARY}) - -elseif(WIN32) - # compile as a win32 gui application instead of a console application - if (QT_VERSION VERSION_GREATER_EQUAL 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 "-Wl,--subsystem,windows") - endif() -endif() - -target_link_libraries(yuzu PRIVATE common core input_common frontend_common network video_core) -target_link_libraries(yuzu PRIVATE Boost::headers glad Qt${QT_MAJOR_VERSION}::Widgets) -target_link_libraries(yuzu PRIVATE ${PLATFORM_LIBRARIES} Threads::Threads) - -target_link_libraries(yuzu PRIVATE Vulkan::Headers) -if (NOT WIN32) - target_include_directories(yuzu PRIVATE ${Qt${QT_MAJOR_VERSION}Gui_PRIVATE_INCLUDE_DIRS}) -endif() -if (UNIX AND NOT APPLE) - target_link_libraries(yuzu PRIVATE Qt${QT_MAJOR_VERSION}::DBus) -endif() - -target_compile_definitions(yuzu PRIVATE - # Use QStringBuilder for string concatenation to reduce - # the overall number of temporary strings created. - -DQT_USE_QSTRINGBUILDER - - # Disable implicit conversions from/to C strings - -DQT_NO_CAST_FROM_ASCII - -DQT_NO_CAST_TO_ASCII - - # Disable implicit type narrowing in signal/slot connect() calls. - -DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT - - # Disable unsafe overloads of QProcess' start() function. - -DQT_NO_PROCESS_COMBINED_ARGUMENT_START - - # Disable implicit QString->QUrl conversions to enforce use of proper resolving functions. - -DQT_NO_URL_CAST_FROM_STRING -) - -if (YUZU_ENABLE_COMPATIBILITY_REPORTING) - target_compile_definitions(yuzu PRIVATE -DYUZU_ENABLE_COMPATIBILITY_REPORTING) -endif() - -if (USE_DISCORD_PRESENCE) - target_sources(yuzu PUBLIC - discord_impl.cpp - discord_impl.h - ) - target_link_libraries(yuzu PRIVATE DiscordRPC::discord-rpc httplib::httplib Qt${QT_MAJOR_VERSION}::Network) - 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_MULTIMEDIA) - target_link_libraries(yuzu PRIVATE Qt${QT_MAJOR_VERSION}::Multimedia) - target_compile_definitions(yuzu PRIVATE -DYUZU_USE_QT_MULTIMEDIA) -endif () - -if (YUZU_USE_QT_WEB_ENGINE) - target_link_libraries(yuzu PRIVATE Qt${QT_MAJOR_VERSION}::WebEngineCore Qt${QT_MAJOR_VERSION}::WebEngineWidgets) - target_compile_definitions(yuzu PRIVATE -DYUZU_USE_QT_WEB_ENGINE) -endif () - -if(UNIX AND NOT APPLE) - install(TARGETS yuzu) -endif() - -if (WIN32 AND QT_VERSION VERSION_GREATER_EQUAL 6) - set(YUZU_EXE_DIR "$<TARGET_FILE_DIR:yuzu>") - add_custom_command(TARGET yuzu POST_BUILD COMMAND ${WINDEPLOYQT_EXECUTABLE} "${YUZU_EXE_DIR}/yuzu.exe" --dir "${YUZU_EXE_DIR}" --libdir "${YUZU_EXE_DIR}" --plugindir "${YUZU_EXE_DIR}/plugins" --no-compiler-runtime --no-opengl-sw --no-system-d3d-compiler --no-translations --verbose 0) -endif() - -if (YUZU_USE_BUNDLED_QT AND QT_VERSION VERSION_LESS 6) - include(CopyYuzuQt5Deps) - copy_yuzu_Qt5_deps(yuzu) -endif() - -if (ENABLE_SDL2) - target_link_libraries(yuzu PRIVATE SDL2::SDL2) - target_compile_definitions(yuzu PRIVATE HAVE_SDL2) -endif() - -if (MSVC) - include(CopyYuzuSDLDeps) - include(CopyYuzuFFmpegDeps) - copy_yuzu_SDL_deps(yuzu) - copy_yuzu_FFmpeg_deps(yuzu) -endif() - -if (NOT APPLE AND ENABLE_OPENGL) - target_compile_definitions(yuzu PRIVATE HAS_OPENGL) -endif() - -if (ARCHITECTURE_x86_64 OR ARCHITECTURE_arm64) - target_link_libraries(yuzu PRIVATE dynarmic::dynarmic) -endif() - -if (YUZU_USE_PRECOMPILED_HEADERS) - target_precompile_headers(yuzu PRIVATE precompiled_headers.h) -endif() - -create_target_directory_groups(yuzu) diff --git a/src/yuzu/Info.plist b/src/yuzu/Info.plist deleted file mode 100644 index f05f3186c..000000000 --- a/src/yuzu/Info.plist +++ /dev/null @@ -1,48 +0,0 @@ -<?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> - <key>CFBundleDevelopmentRegion</key> - <string>English</string> - <key>CFBundleExecutable</key> - <string>${EXECUTABLE_NAME}</string> - <key>CFBundleGetInfoString</key> - <string></string> - <key>CFBundleIconFile</key> - <string>yuzu.icns</string> - <key>CFBundleIdentifier</key> - <string>com.yuzu-emu.yuzu</string> - <key>CFBundleInfoDictionaryVersion</key> - <string>6.0</string> - <key>CFBundleLongVersionString</key> - <string></string> - <key>CFBundleName</key> - <string>yuzu</string> - <key>CFBundlePackageType</key> - <string>APPL</string> - <key>CFBundleShortVersionString</key> - <string></string> - <key>CFBundleSignature</key> - <string>????</string> - <key>CFBundleVersion</key> - <string></string> - <key>CSResourcesFileMapped</key> - <true/> - <key>LSApplicationCategoryType</key> - <string>public.app-category.games</string> - <key>LSRequiresCarbon</key> - <true/> - <key>NSHumanReadableCopyright</key> - <string></string> - <key>NSPrincipalClass</key> - <string>NSApplication</string> - <key>NSHighResolutionCapable</key> - <string>True</string> -</dict> -</plist> diff --git a/src/yuzu/about_dialog.cpp b/src/yuzu/about_dialog.cpp deleted file mode 100644 index eeff54359..000000000 --- a/src/yuzu/about_dialog.cpp +++ /dev/null @@ -1,32 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include <QIcon> -#include <fmt/format.h> -#include "common/scm_rev.h" -#include "ui_aboutdialog.h" -#include "yuzu/about_dialog.h" - -AboutDialog::AboutDialog(QWidget* parent) - : QDialog(parent), ui{std::make_unique<Ui::AboutDialog>()} { - const auto branch_name = std::string(Common::g_scm_branch); - const auto description = std::string(Common::g_scm_desc); - const auto build_id = std::string(Common::g_build_id); - - const auto yuzu_build = fmt::format("yuzu Development Build | {}-{}", branch_name, description); - const auto override_build = - fmt::format(fmt::runtime(std::string(Common::g_title_bar_format_idle)), build_id); - const auto yuzu_build_version = override_build.empty() ? yuzu_build : override_build; - - ui->setupUi(this); - // 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))); -} - -AboutDialog::~AboutDialog() = default; diff --git a/src/yuzu/about_dialog.h b/src/yuzu/about_dialog.h deleted file mode 100644 index 3c4e71ee6..000000000 --- a/src/yuzu/about_dialog.h +++ /dev/null @@ -1,22 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include <memory> -#include <QDialog> - -namespace Ui { -class AboutDialog; -} - -class AboutDialog : public QDialog { - Q_OBJECT - -public: - explicit AboutDialog(QWidget* parent); - ~AboutDialog() override; - -private: - std::unique_ptr<Ui::AboutDialog> ui; -}; diff --git a/src/yuzu/aboutdialog.ui b/src/yuzu/aboutdialog.ui deleted file mode 100644 index aea82809d..000000000 --- a/src/yuzu/aboutdialog.ui +++ /dev/null @@ -1,184 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>AboutDialog</class> - <widget class="QDialog" name="AboutDialog"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>616</width> - <height>294</height> - </rect> - </property> - <property name="windowTitle"> - <string>About yuzu</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout_3"> - <item> - <layout class="QHBoxLayout" name="horizontalLayout" stretch="0,1"> - <item> - <layout class="QVBoxLayout" name="verticalLayout_2"> - <item> - <widget class="QLabel" name="labelLogo"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="maximumSize"> - <size> - <width>200</width> - <height>200</height> - </size> - </property> - <property name="text"> - <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> - <item> - <spacer name="verticalSpacer"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>40</height> - </size> - </property> - </spacer> - </item> - </layout> - </item> - <item> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <widget class="QLabel" name="labelYuzu"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string><html><head/><body><p><span style=" font-size:28pt;">yuzu</span></p></body></html></string> - </property> - </widget> - </item> - <item> - <widget class="QLabel" name="labelBuildInfo"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string><html><head/><body><p>%1 (%2)</p></body></html></string> - </property> - </widget> - </item> - <item> - <widget class="QLabel" name="labelAbout"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'MS Shell Dlg 2'; font-size:12pt;">yuzu is an experimental open-source emulator for the Nintendo Switch licensed under GPLv3.0+.</span></p> -<p style="-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;"><br /></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'MS Shell Dlg 2'; font-size:12pt;">This software should not be used to play games you have not legally obtained.</span></p></body></html></string> - </property> - <property name="alignment"> - <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set> - </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="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>40</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QLabel" name="labelLinks"> - <property name="text"> - <string><html><head/><body><p><a href="https://yuzu-emu.org/"><span style=" text-decoration: underline; color:#039be5;">Website</span></a> | <a href="https://github.com/yuzu-emu"><span style=" text-decoration: underline; color:#039be5;">Source Code</span></a> | <a href="https://github.com/yuzu-emu/yuzu/graphs/contributors"><span style=" text-decoration: underline; color:#039be5;">Contributors</span></a> | <a href="https://github.com/yuzu-emu/yuzu/blob/master/LICENSE.txt"><span style=" text-decoration: underline; color:#039be5;">License</span></a></p></body></html></string> - </property> - <property name="openExternalLinks"> - <bool>true</bool> - </property> - </widget> - </item> - <item> - <widget class="QLabel" name="labelLiability"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string><html><head/><body><p><span style=" font-size:7pt;">&quot;Nintendo Switch&quot; is a trademark of Nintendo. yuzu is not affiliated with Nintendo in any way.</span></p></body></html></string> - </property> - </widget> - </item> - </layout> - </item> - </layout> - </item> - <item> - <widget class="QDialogButtonBox" name="buttonBox"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="standardButtons"> - <set>QDialogButtonBox::Ok</set> - </property> - </widget> - </item> - </layout> - </widget> - <resources> - <include location="../../dist/qt_themes_default/default/default.qrc"/> - <include location="../../dist/qt_themes/default/default.qrc"/> - </resources> - <connections> - <connection> - <sender>buttonBox</sender> - <signal>accepted()</signal> - <receiver>AboutDialog</receiver> - <slot>accept()</slot> - </connection> - <connection> - <sender>buttonBox</sender> - <signal>rejected()</signal> - <receiver>AboutDialog</receiver> - <slot>reject()</slot> - </connection> - </connections> -</ui> diff --git a/src/yuzu/applets/qt_amiibo_settings.cpp b/src/yuzu/applets/qt_amiibo_settings.cpp deleted file mode 100644 index b91796dde..000000000 --- a/src/yuzu/applets/qt_amiibo_settings.cpp +++ /dev/null @@ -1,274 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include <algorithm> -#include <thread> -#include <fmt/format.h> -#include <nlohmann/json.hpp> - -#include "common/assert.h" -#include "common/string_util.h" -#include "core/hle/service/nfc/common/device.h" -#include "core/hle/service/nfp/nfp_result.h" -#include "input_common/drivers/virtual_amiibo.h" -#include "input_common/main.h" -#include "ui_qt_amiibo_settings.h" -#ifdef ENABLE_WEB_SERVICE -#include "web_service/web_backend.h" -#endif -#include "yuzu/applets/qt_amiibo_settings.h" -#include "yuzu/main.h" - -QtAmiiboSettingsDialog::QtAmiiboSettingsDialog(QWidget* parent, - Core::Frontend::CabinetParameters parameters_, - InputCommon::InputSubsystem* input_subsystem_, - std::shared_ptr<Service::NFC::NfcDevice> nfp_device_) - : QDialog(parent), ui(std::make_unique<Ui::QtAmiiboSettingsDialog>()), - input_subsystem{input_subsystem_}, nfp_device{std::move(nfp_device_)}, - parameters(std::move(parameters_)) { - ui->setupUi(this); - - LoadInfo(); - - resize(0, 0); -} - -QtAmiiboSettingsDialog::~QtAmiiboSettingsDialog() = default; - -int QtAmiiboSettingsDialog::exec() { - if (!is_initialized) { - return QDialog::Rejected; - } - return QDialog::exec(); -} - -std::string QtAmiiboSettingsDialog::GetName() const { - return ui->amiiboCustomNameValue->text().toStdString(); -} - -void QtAmiiboSettingsDialog::LoadInfo() { - if (input_subsystem->GetVirtualAmiibo()->ReloadAmiibo() != - InputCommon::VirtualAmiibo::Info::Success) { - return; - } - - if (nfp_device->GetCurrentState() != Service::NFC::DeviceState::TagFound && - nfp_device->GetCurrentState() != Service::NFC::DeviceState::TagMounted) { - return; - } - nfp_device->Mount(Service::NFP::ModelType::Amiibo, Service::NFP::MountTarget::All); - - LoadAmiiboInfo(); - LoadAmiiboData(); - LoadAmiiboGameInfo(); - - ui->amiiboDirectoryValue->setText( - QString::fromStdString(input_subsystem->GetVirtualAmiibo()->GetLastFilePath())); - - SetSettingsDescription(); - is_initialized = true; -} - -void QtAmiiboSettingsDialog::LoadAmiiboInfo() { - Service::NFP::ModelInfo model_info{}; - const auto model_result = nfp_device->GetModelInfo(model_info); - - if (model_result.IsFailure()) { - ui->amiiboImageLabel->setVisible(false); - ui->amiiboInfoGroup->setVisible(false); - return; - } - - const auto amiibo_id = - fmt::format("{:04x}{:02x}{:02x}{:04x}{:02x}02", Common::swap16(model_info.character_id), - model_info.character_variant, model_info.amiibo_type, model_info.model_number, - model_info.series); - - LOG_DEBUG(Frontend, "Loading amiibo id {}", amiibo_id); - // Note: This function is not being used until we host the images on our server - // LoadAmiiboApiInfo(amiibo_id); - ui->amiiboImageLabel->setVisible(false); - ui->amiiboInfoGroup->setVisible(false); -} - -void QtAmiiboSettingsDialog::LoadAmiiboApiInfo(std::string_view amiibo_id) { -#ifdef ENABLE_WEB_SERVICE - // TODO: Host this data on our website - WebService::Client client{"https://amiiboapi.com", {}, {}}; - WebService::Client image_client{"https://raw.githubusercontent.com", {}, {}}; - const auto url_path = fmt::format("/api/amiibo/?id={}", amiibo_id); - - const auto amiibo_json = client.GetJson(url_path, true).returned_data; - if (amiibo_json.empty()) { - ui->amiiboImageLabel->setVisible(false); - ui->amiiboInfoGroup->setVisible(false); - return; - } - - std::string amiibo_series{}; - std::string amiibo_name{}; - std::string amiibo_image_url{}; - std::string amiibo_type{}; - - const auto parsed_amiibo_json_json = nlohmann::json::parse(amiibo_json).at("amiibo"); - parsed_amiibo_json_json.at("amiiboSeries").get_to(amiibo_series); - parsed_amiibo_json_json.at("name").get_to(amiibo_name); - parsed_amiibo_json_json.at("image").get_to(amiibo_image_url); - parsed_amiibo_json_json.at("type").get_to(amiibo_type); - - ui->amiiboSeriesValue->setText(QString::fromStdString(amiibo_series)); - ui->amiiboNameValue->setText(QString::fromStdString(amiibo_name)); - ui->amiiboTypeValue->setText(QString::fromStdString(amiibo_type)); - - if (amiibo_image_url.size() < 34) { - ui->amiiboImageLabel->setVisible(false); - } - - const auto image_url_path = amiibo_image_url.substr(34, amiibo_image_url.size() - 34); - const auto image_data = image_client.GetImage(image_url_path, true).returned_data; - - if (image_data.empty()) { - ui->amiiboImageLabel->setVisible(false); - } - - QPixmap pixmap; - pixmap.loadFromData(reinterpret_cast<const u8*>(image_data.data()), - static_cast<uint>(image_data.size())); - pixmap = pixmap.scaled(250, 350, Qt::AspectRatioMode::KeepAspectRatio, - Qt::TransformationMode::SmoothTransformation); - ui->amiiboImageLabel->setPixmap(pixmap); -#endif -} - -void QtAmiiboSettingsDialog::LoadAmiiboData() { - Service::NFP::RegisterInfo register_info{}; - Service::NFP::CommonInfo common_info{}; - const auto register_result = nfp_device->GetRegisterInfo(register_info); - const auto common_result = nfp_device->GetCommonInfo(common_info); - - if (register_result.IsFailure()) { - ui->creationDateValue->setDisabled(true); - ui->modificationDateValue->setDisabled(true); - ui->amiiboCustomNameValue->setReadOnly(false); - ui->amiiboOwnerValue->setReadOnly(false); - return; - } - - if (parameters.mode == Service::NFP::CabinetMode::StartNicknameAndOwnerSettings) { - ui->creationDateValue->setDisabled(true); - ui->modificationDateValue->setDisabled(true); - } - - const auto amiibo_name = std::string(register_info.amiibo_name.data()); - const auto owner_name = - Common::UTF16ToUTF8(register_info.mii_char_info.GetNickname().data.data()); - const auto creation_date = - QDate(register_info.creation_date.year, register_info.creation_date.month, - register_info.creation_date.day); - - ui->amiiboCustomNameValue->setText(QString::fromStdString(amiibo_name)); - ui->amiiboOwnerValue->setText(QString::fromStdString(owner_name)); - ui->amiiboCustomNameValue->setReadOnly(true); - ui->amiiboOwnerValue->setReadOnly(true); - ui->creationDateValue->setDate(creation_date); - - if (common_result.IsFailure()) { - ui->modificationDateValue->setDisabled(true); - return; - } - - const auto modification_date = - QDate(common_info.last_write_date.year, common_info.last_write_date.month, - common_info.last_write_date.day); - ui->modificationDateValue->setDate(modification_date); -} - -void QtAmiiboSettingsDialog::LoadAmiiboGameInfo() { - u32 application_area_id{}; - const auto application_result = nfp_device->GetApplicationAreaId(application_area_id); - - if (application_result.IsFailure()) { - ui->gameIdValue->setVisible(false); - ui->gameIdLabel->setText(tr("No game data present")); - return; - } - - SetGameDataName(application_area_id); -} - -void QtAmiiboSettingsDialog::SetGameDataName(u32 application_area_id) { - static constexpr std::array<std::pair<u32, const char*>, 12> game_name_list = { - // 3ds, wii u - std::pair<u32, const char*>{0x10110E00, "Super Smash Bros (3DS/WiiU)"}, - {0x00132600, "Mario & Luigi: Paper Jam"}, - {0x0014F000, "Animal Crossing: Happy Home Designer"}, - {0x00152600, "Chibi-Robo!: Zip Lash"}, - {0x10161f00, "Mario Party 10"}, - {0x1019C800, "The Legend of Zelda: Twilight Princess HD"}, - // switch - {0x10162B00, "Splatoon 2"}, - {0x1016e100, "Shovel Knight: Treasure Trove"}, - {0x1019C800, "The Legend of Zelda: Breath of the Wild"}, - {0x34F80200, "Super Smash Bros. Ultimate"}, - {0x38600500, "Splatoon 3"}, - {0x3B440400, "The Legend of Zelda: Link's Awakening"}, - }; - - for (const auto& [game_id, game_name] : game_name_list) { - if (application_area_id == game_id) { - ui->gameIdValue->setText(QString::fromStdString(game_name)); - return; - } - } - - const auto application_area_string = fmt::format("{:016x}", application_area_id); - ui->gameIdValue->setText(QString::fromStdString(application_area_string)); -} - -void QtAmiiboSettingsDialog::SetSettingsDescription() { - switch (parameters.mode) { - case Service::NFP::CabinetMode::StartFormatter: - ui->cabinetActionDescriptionLabel->setText( - tr("The following amiibo data will be formatted:")); - break; - case Service::NFP::CabinetMode::StartGameDataEraser: - ui->cabinetActionDescriptionLabel->setText(tr("The following game data will removed:")); - break; - case Service::NFP::CabinetMode::StartNicknameAndOwnerSettings: - ui->cabinetActionDescriptionLabel->setText(tr("Set nickname and owner:")); - break; - case Service::NFP::CabinetMode::StartRestorer: - ui->cabinetActionDescriptionLabel->setText(tr("Do you wish to restore this amiibo?")); - break; - } -} - -QtAmiiboSettings::QtAmiiboSettings(GMainWindow& parent) { - connect(this, &QtAmiiboSettings::MainWindowShowAmiiboSettings, &parent, - &GMainWindow::AmiiboSettingsShowDialog, Qt::QueuedConnection); - connect(this, &QtAmiiboSettings::MainWindowRequestExit, &parent, - &GMainWindow::AmiiboSettingsRequestExit, Qt::QueuedConnection); - connect(&parent, &GMainWindow::AmiiboSettingsFinished, this, - &QtAmiiboSettings::MainWindowFinished, Qt::QueuedConnection); -} - -QtAmiiboSettings::~QtAmiiboSettings() = default; - -void QtAmiiboSettings::Close() const { - callback = {}; - emit MainWindowRequestExit(); -} - -void QtAmiiboSettings::ShowCabinetApplet( - const Core::Frontend::CabinetCallback& callback_, - const Core::Frontend::CabinetParameters& parameters, - std::shared_ptr<Service::NFC::NfcDevice> nfp_device) const { - callback = std::move(callback_); - emit MainWindowShowAmiiboSettings(parameters, nfp_device); -} - -void QtAmiiboSettings::MainWindowFinished(bool is_success, const std::string& name) { - if (callback) { - callback(is_success, name); - } -} diff --git a/src/yuzu/applets/qt_amiibo_settings.h b/src/yuzu/applets/qt_amiibo_settings.h deleted file mode 100644 index 3833cf6f2..000000000 --- a/src/yuzu/applets/qt_amiibo_settings.h +++ /dev/null @@ -1,85 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include <array> -#include <memory> -#include <QDialog> -#include "core/frontend/applets/cabinet.h" - -class GMainWindow; -class QCheckBox; -class QComboBox; -class QDialogButtonBox; -class QGroupBox; -class QLabel; - -namespace InputCommon { -class InputSubsystem; -} - -namespace Ui { -class QtAmiiboSettingsDialog; -} - -namespace Service::NFC { -class NfcDevice; -} // namespace Service::NFC - -class QtAmiiboSettingsDialog final : public QDialog { - Q_OBJECT - -public: - explicit QtAmiiboSettingsDialog(QWidget* parent, Core::Frontend::CabinetParameters parameters_, - InputCommon::InputSubsystem* input_subsystem_, - std::shared_ptr<Service::NFC::NfcDevice> nfp_device_); - ~QtAmiiboSettingsDialog() override; - - int exec() override; - - std::string GetName() const; - -private: - void LoadInfo(); - void LoadAmiiboInfo(); - void LoadAmiiboApiInfo(std::string_view amiibo_id); - void LoadAmiiboData(); - void LoadAmiiboGameInfo(); - void SetGameDataName(u32 application_area_id); - void SetSettingsDescription(); - - std::unique_ptr<Ui::QtAmiiboSettingsDialog> ui; - - InputCommon::InputSubsystem* input_subsystem; - std::shared_ptr<Service::NFC::NfcDevice> nfp_device; - - // Parameters sent in from the backend HLE applet. - Core::Frontend::CabinetParameters parameters; - - // If false amiibo settings failed to load - bool is_initialized{}; -}; - -class QtAmiiboSettings final : public QObject, public Core::Frontend::CabinetApplet { - Q_OBJECT - -public: - explicit QtAmiiboSettings(GMainWindow& parent); - ~QtAmiiboSettings() override; - - void Close() const override; - void ShowCabinetApplet(const Core::Frontend::CabinetCallback& callback_, - const Core::Frontend::CabinetParameters& parameters, - std::shared_ptr<Service::NFC::NfcDevice> nfp_device) const override; - -signals: - void MainWindowShowAmiiboSettings(const Core::Frontend::CabinetParameters& parameters, - std::shared_ptr<Service::NFC::NfcDevice> nfp_device) const; - void MainWindowRequestExit() const; - -private: - void MainWindowFinished(bool is_success, const std::string& name); - - mutable Core::Frontend::CabinetCallback callback; -}; diff --git a/src/yuzu/applets/qt_amiibo_settings.ui b/src/yuzu/applets/qt_amiibo_settings.ui deleted file mode 100644 index f377a6e61..000000000 --- a/src/yuzu/applets/qt_amiibo_settings.ui +++ /dev/null @@ -1,494 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>QtAmiiboSettingsDialog</class> - <widget class="QDialog" name="QtAmiiboSettingsDialog"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>839</width> - <height>500</height> - </rect> - </property> - <property name="windowTitle"> - <string>Amiibo Settings</string> - </property> - <property name="styleSheet"> - <string notr="true"/> - </property> - <layout class="QVBoxLayout" name="verticalLayout" stretch="0"> - <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="QWidget" name="mainControllerApplet" native="true"> - <layout class="QVBoxLayout" name="verticalLayout_1" stretch="0,3,0"> - <property name="spacing"> - <number>0</number> - </property> - <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="QWidget" name="topControllerApplet" native="true"> - <layout class="QHBoxLayout" name="horizontalLayout"> - <property name="spacing"> - <number>10</number> - </property> - <property name="leftMargin"> - <number>20</number> - </property> - <property name="topMargin"> - <number>15</number> - </property> - <property name="rightMargin"> - <number>0</number> - </property> - <property name="bottomMargin"> - <number>15</number> - </property> - <item> - <widget class="QLabel" name="cabinetActionDescriptionLabel"> - <property name="font"> - <font> - <pointsize>12</pointsize> - <weight>75</weight> - <bold>true</bold> - </font> - </property> - <property name="text"> - <string/> - </property> - <property name="alignment"> - <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set> - </property> - <property name="wordWrap"> - <bool>false</bool> - </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> - </layout> - </widget> - </item> - <item> - <widget class="QWidget" name="middleControllerApplet" native="true"> - <layout class="QVBoxLayout" name="verticalLayout_3"> - <property name="spacing"> - <number>0</number> - </property> - <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_2"> - <property name="spacing"> - <number>20</number> - </property> - <property name="leftMargin"> - <number>15</number> - </property> - <property name="rightMargin"> - <number>15</number> - </property> - <item> - <widget class="QLabel" name="amiiboImageLabel"> - <property name="minimumSize"> - <size> - <width>250</width> - <height>350</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>236</width> - <height>350</height> - </size> - </property> - <property name="text"> - <string/> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - </widget> - </item> - <item> - <layout class="QVBoxLayout" name="verticalLayout_4"> - <property name="leftMargin"> - <number>0</number> - </property> - <property name="topMargin"> - <number>8</number> - </property> - <property name="bottomMargin"> - <number>15</number> - </property> - <item> - <widget class="QGroupBox" name="amiiboInfoGroup"> - <property name="title"> - <string>Amiibo Info</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout_5"> - <item> - <layout class="QGridLayout" name="gridLayout_1"> - <item row="0" column="0"> - <widget class="QLabel" name="amiiboSeriesLabel"> - <property name="text"> - <string>Series</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QLineEdit" name="amiiboSeriesValue"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="readOnly"> - <bool>true</bool> - </property> - </widget> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="amiiboTypeLabel"> - <property name="text"> - <string>Type</string> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QLineEdit" name="amiiboTypeValue"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="readOnly"> - <bool>true</bool> - </property> - </widget> - </item> - <item row="2" column="0"> - <widget class="QLabel" name="amiiboNameLabel"> - <property name="text"> - <string>Name</string> - </property> - </widget> - </item> - <item row="2" column="1"> - <widget class="QLineEdit" name="amiiboNameValue"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="readOnly"> - <bool>true</bool> - </property> - </widget> - </item> - </layout> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QGroupBox" name="amiiboDataGroup"> - <property name="title"> - <string>Amiibo Data</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout_6"> - <item> - <layout class="QGridLayout" name="gridLayout_2"> - <item row="0" column="0"> - <widget class="QLabel" name="amiiboCustomNameLabel"> - <property name="text"> - <string>Custom Name</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QLineEdit" name="amiiboCustomNameValue"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="maxLength"> - <number>10</number> - </property> - </widget> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="amiiboOwnerLabel"> - <property name="text"> - <string>Owner</string> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QLineEdit" name="amiiboOwnerValue"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="maxLength"> - <number>10</number> - </property> - </widget> - </item> - <item row="2" column="0"> - <widget class="QLabel" name="creationDateLabel"> - <property name="text"> - <string>Creation Date</string> - </property> - </widget> - </item> - <item row="2" column="1"> - <widget class="QDateTimeEdit" name="creationDateValue"> - <property name="readOnly"> - <bool>true</bool> - </property> - <property name="minimumDate"> - <date> - <year>1970</year> - <month>1</month> - <day>1</day> - </date> - </property> - <property name="displayFormat"> - <string>dd/MM/yyyy</string> - </property> - </widget> - </item> - <item row="3" column="0"> - <widget class="QLabel" name="modificationDateLabel"> - <property name="text"> - <string>Modification Date</string> - </property> - </widget> - </item> - <item row="3" column="1"> - <widget class="QDateTimeEdit" name="modificationDateValue"> - <property name="readOnly"> - <bool>true</bool> - </property> - <property name="minimumDate"> - <date> - <year>1970</year> - <month>1</month> - <day>1</day> - </date> - </property> - <property name="displayFormat"> - <string>dd/MM/yyyy </string> - </property> - </widget> - </item> - </layout> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QGroupBox" name="gameDataGroup"> - <property name="minimumSize"> - <size> - <width>500</width> - <height>0</height> - </size> - </property> - <property name="title"> - <string>Game Data</string> - </property> - <layout class="QGridLayout" name="gridLayout_3"> - <item row="0" column="0"> - <widget class="QLabel" name="gameIdLabel"> - <property name="text"> - <string>Game Id</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QLineEdit" name="gameIdValue"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="readOnly"> - <bool>true</bool> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QGroupBox" name="MountAmiiboGroup"> - <property name="minimumSize"> - <size> - <width>500</width> - <height>0</height> - </size> - </property> - <property name="title"> - <string>Mount Amiibo</string> - </property> - <layout class="QGridLayout" name="gridLayout_4"> - <item row="0" column="3"> - <widget class="QToolButton" name="amiiboDirectoryButton"> - <property name="text"> - <string>...</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <spacer name="horizontalSpacer"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeType"> - <enum>QSizePolicy::Maximum</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>60</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item row="0" column="0"> - <widget class="QLabel" name="amiiboDirectoryLabel"> - <property name="text"> - <string>File Path</string> - </property> - </widget> - </item> - <item row="0" column="2"> - <widget class="QLineEdit" name="amiiboDirectoryValue"/> - </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> - </layout> - </item> - </layout> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QWidget" name="bottomControllerApplet" native="true"> - <layout class="QHBoxLayout" name="horizontalLayout_6"> - <property name="spacing"> - <number>15</number> - </property> - <property name="leftMargin"> - <number>15</number> - </property> - <property name="topMargin"> - <number>8</number> - </property> - <property name="rightMargin"> - <number>20</number> - </property> - <property name="bottomMargin"> - <number>8</number> - </property> - <item alignment="Qt::AlignBottom"> - <widget class="QDialogButtonBox" name="buttonBox"> - <property name="enabled"> - <bool>true</bool> - </property> - <property name="standardButtons"> - <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> - </property> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - <resources/> - <connections> - <connection> - <sender>buttonBox</sender> - <signal>accepted()</signal> - <receiver>QtAmiiboSettingsDialog</receiver> - <slot>accept()</slot> - </connection> - <connection> - <sender>buttonBox</sender> - <signal>rejected()</signal> - <receiver>QtAmiiboSettingsDialog</receiver> - <slot>reject()</slot> - </connection> - </connections> -</ui> diff --git a/src/yuzu/applets/qt_controller.cpp b/src/yuzu/applets/qt_controller.cpp deleted file mode 100644 index 48ce860ad..000000000 --- a/src/yuzu/applets/qt_controller.cpp +++ /dev/null @@ -1,778 +0,0 @@ -// 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/settings.h" -#include "common/settings_enums.h" -#include "common/string_util.h" -#include "core/core.h" -#include "core/hle/service/sm/sm.h" -#include "hid_core/frontend/emulated_controller.h" -#include "hid_core/hid_core.h" -#include "hid_core/hid_types.h" -#include "hid_core/resources/npad/npad.h" -#include "ui_qt_controller.h" -#include "yuzu/applets/qt_controller.h" -#include "yuzu/configuration/configure_input.h" -#include "yuzu/configuration/configure_input_profile_dialog.h" -#include "yuzu/configuration/configure_motion_touch.h" -#include "yuzu/configuration/configure_vibration.h" -#include "yuzu/configuration/input_profiles.h" -#include "yuzu/main.h" -#include "yuzu/util/controller_navigation.h" - -namespace { - -void UpdateController(Core::HID::EmulatedController* controller, - Core::HID::NpadStyleIndex controller_type, bool connected) { - if (controller->IsConnected(true)) { - controller->Disconnect(); - } - controller->SetNpadStyleIndex(controller_type); - if (connected) { - controller->Connect(true); - } -} - -// Returns true if the given controller type is compatible with the given parameters. -bool IsControllerCompatible(Core::HID::NpadStyleIndex controller_type, - Core::Frontend::ControllerParameters parameters) { - switch (controller_type) { - case Core::HID::NpadStyleIndex::Fullkey: - return parameters.allow_pro_controller; - case Core::HID::NpadStyleIndex::JoyconDual: - return parameters.allow_dual_joycons; - case Core::HID::NpadStyleIndex::JoyconLeft: - return parameters.allow_left_joycon; - case Core::HID::NpadStyleIndex::JoyconRight: - return parameters.allow_right_joycon; - case Core::HID::NpadStyleIndex::Handheld: - return parameters.enable_single_mode && parameters.allow_handheld; - case Core::HID::NpadStyleIndex::GameCube: - return parameters.allow_gamecube_controller; - default: - return false; - } -} - -} // namespace - -QtControllerSelectorDialog::QtControllerSelectorDialog( - QWidget* parent, Core::Frontend::ControllerParameters parameters_, - 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_} { - ui->setupUi(this); - - player_widgets = { - ui->widgetPlayer1, ui->widgetPlayer2, ui->widgetPlayer3, ui->widgetPlayer4, - ui->widgetPlayer5, ui->widgetPlayer6, ui->widgetPlayer7, ui->widgetPlayer8, - }; - - player_groupboxes = { - ui->groupPlayer1Connected, ui->groupPlayer2Connected, ui->groupPlayer3Connected, - ui->groupPlayer4Connected, ui->groupPlayer5Connected, ui->groupPlayer6Connected, - ui->groupPlayer7Connected, ui->groupPlayer8Connected, - }; - - connected_controller_icons = { - ui->controllerPlayer1, ui->controllerPlayer2, ui->controllerPlayer3, ui->controllerPlayer4, - ui->controllerPlayer5, ui->controllerPlayer6, ui->controllerPlayer7, ui->controllerPlayer8, - }; - - led_patterns_boxes = {{ - {ui->checkboxPlayer1LED1, ui->checkboxPlayer1LED2, ui->checkboxPlayer1LED3, - ui->checkboxPlayer1LED4}, - {ui->checkboxPlayer2LED1, ui->checkboxPlayer2LED2, ui->checkboxPlayer2LED3, - ui->checkboxPlayer2LED4}, - {ui->checkboxPlayer3LED1, ui->checkboxPlayer3LED2, ui->checkboxPlayer3LED3, - ui->checkboxPlayer3LED4}, - {ui->checkboxPlayer4LED1, ui->checkboxPlayer4LED2, ui->checkboxPlayer4LED3, - ui->checkboxPlayer4LED4}, - {ui->checkboxPlayer5LED1, ui->checkboxPlayer5LED2, ui->checkboxPlayer5LED3, - ui->checkboxPlayer5LED4}, - {ui->checkboxPlayer6LED1, ui->checkboxPlayer6LED2, ui->checkboxPlayer6LED3, - ui->checkboxPlayer6LED4}, - {ui->checkboxPlayer7LED1, ui->checkboxPlayer7LED2, ui->checkboxPlayer7LED3, - ui->checkboxPlayer7LED4}, - {ui->checkboxPlayer8LED1, ui->checkboxPlayer8LED2, ui->checkboxPlayer8LED3, - ui->checkboxPlayer8LED4}, - }}; - - explain_text_labels = { - ui->labelPlayer1Explain, ui->labelPlayer2Explain, ui->labelPlayer3Explain, - ui->labelPlayer4Explain, ui->labelPlayer5Explain, ui->labelPlayer6Explain, - ui->labelPlayer7Explain, ui->labelPlayer8Explain, - }; - - emulated_controllers = { - ui->comboPlayer1Emulated, ui->comboPlayer2Emulated, ui->comboPlayer3Emulated, - ui->comboPlayer4Emulated, ui->comboPlayer5Emulated, ui->comboPlayer6Emulated, - ui->comboPlayer7Emulated, ui->comboPlayer8Emulated, - }; - - player_labels = { - ui->labelPlayer1, ui->labelPlayer2, ui->labelPlayer3, ui->labelPlayer4, - ui->labelPlayer5, ui->labelPlayer6, ui->labelPlayer7, ui->labelPlayer8, - }; - - connected_controller_labels = { - ui->labelConnectedPlayer1, ui->labelConnectedPlayer2, ui->labelConnectedPlayer3, - ui->labelConnectedPlayer4, ui->labelConnectedPlayer5, ui->labelConnectedPlayer6, - ui->labelConnectedPlayer7, ui->labelConnectedPlayer8, - }; - - connected_controller_checkboxes = { - ui->checkboxPlayer1Connected, ui->checkboxPlayer2Connected, ui->checkboxPlayer3Connected, - ui->checkboxPlayer4Connected, ui->checkboxPlayer5Connected, ui->checkboxPlayer6Connected, - ui->checkboxPlayer7Connected, ui->checkboxPlayer8Connected, - }; - - ui->labelError->setVisible(false); - - // Setup/load everything prior to setting up connections. - // This avoids unintentionally changing the states of elements while loading them in. - SetSupportedControllers(); - DisableUnsupportedPlayers(); - - for (std::size_t player_index = 0; player_index < NUM_PLAYERS; ++player_index) { - SetEmulatedControllers(player_index); - } - - LoadConfiguration(); - - controller_navigation = new ControllerNavigation(system.HIDCore(), this); - - for (std::size_t i = 0; i < NUM_PLAYERS; ++i) { - SetExplainText(i); - UpdateControllerIcon(i); - UpdateLEDPattern(i); - UpdateBorderColor(i); - - connect(player_groupboxes[i], &QGroupBox::toggled, [this, i](bool checked) { - // Reconnect current controller if it was the last one checked - // (player number was reduced by more than one) - const bool reconnect_first = !checked && i < player_groupboxes.size() - 1 && - player_groupboxes[i + 1]->isChecked(); - - // Ensures that connecting a controller changes the number of players - if (connected_controller_checkboxes[i]->isChecked() != checked) { - // Ensures that the players are always connected in sequential order - PropagatePlayerNumberChanged(i, checked, reconnect_first); - } - }); - connect(connected_controller_checkboxes[i], &QCheckBox::clicked, [this, i](bool checked) { - // Reconnect current controller if it was the last one checked - // (player number was reduced by more than one) - const bool reconnect_first = !checked && - i < connected_controller_checkboxes.size() - 1 && - connected_controller_checkboxes[i + 1]->isChecked(); - - // Ensures that the players are always connected in sequential order - PropagatePlayerNumberChanged(i, checked, reconnect_first); - }); - - connect(emulated_controllers[i], qOverload<int>(&QComboBox::currentIndexChanged), - [this, i](int) { - UpdateControllerIcon(i); - UpdateControllerState(i); - UpdateLEDPattern(i); - CheckIfParametersMet(); - }); - - connect(connected_controller_checkboxes[i], &QCheckBox::stateChanged, [this, i](int state) { - player_groupboxes[i]->setChecked(state == Qt::Checked); - UpdateControllerIcon(i); - UpdateControllerState(i); - UpdateLEDPattern(i); - UpdateBorderColor(i); - CheckIfParametersMet(); - }); - - if (i == 0) { - connect(emulated_controllers[i], qOverload<int>(&QComboBox::currentIndexChanged), - [this, i](int index) { - UpdateDockedState(GetControllerTypeFromIndex(index, i) == - Core::HID::NpadStyleIndex::Handheld); - }); - } - } - - connect(ui->vibrationButton, &QPushButton::clicked, this, - &QtControllerSelectorDialog::CallConfigureVibrationDialog); - - connect(ui->motionButton, &QPushButton::clicked, this, - &QtControllerSelectorDialog::CallConfigureMotionTouchDialog); - - connect(ui->inputConfigButton, &QPushButton::clicked, this, - &QtControllerSelectorDialog::CallConfigureInputProfileDialog); - - connect(ui->buttonBox, &QDialogButtonBox::accepted, this, - &QtControllerSelectorDialog::ApplyConfiguration); - - connect(controller_navigation, &ControllerNavigation::TriggerKeyboardEvent, - [this](Qt::Key key) { - QKeyEvent* event = new QKeyEvent(QEvent::KeyPress, key, Qt::NoModifier); - QCoreApplication::postEvent(this, event); - }); - - // Enhancement: Check if the parameters have already been met before disconnecting controllers. - // If all the parameters are met AND only allows a single player, - // stop the constructor here as we do not need to continue. - if (CheckIfParametersMet() && parameters.enable_single_mode) { - return; - } - - // If keep_controllers_connected is false, forcefully disconnect all controllers - if (!parameters.keep_controllers_connected) { - for (auto player : player_groupboxes) { - player->setChecked(false); - } - } - - resize(0, 0); -} - -QtControllerSelectorDialog::~QtControllerSelectorDialog() { - controller_navigation->UnloadController(); - system.HIDCore().DisableAllControllerConfiguration(); -} - -int QtControllerSelectorDialog::exec() { - if (parameters_met && parameters.enable_single_mode) { - return QDialog::Accepted; - } - return QDialog::exec(); -} - -void QtControllerSelectorDialog::ApplyConfiguration() { - const bool pre_docked_mode = Settings::IsDockedMode(); - const bool docked_mode_selected = ui->radioDocked->isChecked(); - Settings::values.use_docked_mode.SetValue( - docked_mode_selected ? Settings::ConsoleMode::Docked : Settings::ConsoleMode::Handheld); - OnDockedModeChanged(pre_docked_mode, docked_mode_selected, system); - - Settings::values.vibration_enabled.SetValue(ui->vibrationGroup->isChecked()); - Settings::values.motion_enabled.SetValue(ui->motionGroup->isChecked()); -} - -void QtControllerSelectorDialog::LoadConfiguration() { - system.HIDCore().EnableAllControllerConfiguration(); - - const auto* handheld = system.HIDCore().GetEmulatedController(Core::HID::NpadIdType::Handheld); - for (std::size_t index = 0; index < NUM_PLAYERS; ++index) { - const auto* controller = system.HIDCore().GetEmulatedControllerByIndex(index); - const auto connected = - controller->IsConnected(true) || (index == 0 && handheld->IsConnected(true)); - player_groupboxes[index]->setChecked(connected); - connected_controller_checkboxes[index]->setChecked(connected); - emulated_controllers[index]->setCurrentIndex( - GetIndexFromControllerType(controller->GetNpadStyleIndex(true), index)); - } - - UpdateDockedState(handheld->IsConnected(true)); - - ui->vibrationGroup->setChecked(Settings::values.vibration_enabled.GetValue()); - ui->motionGroup->setChecked(Settings::values.motion_enabled.GetValue()); -} - -void QtControllerSelectorDialog::CallConfigureVibrationDialog() { - ConfigureVibration dialog(this, system.HIDCore()); - - dialog.setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | - Qt::WindowSystemMenuHint); - dialog.setWindowModality(Qt::WindowModal); - - if (dialog.exec() == QDialog::Accepted) { - dialog.ApplyConfiguration(); - } -} - -void QtControllerSelectorDialog::CallConfigureMotionTouchDialog() { - ConfigureMotionTouch dialog(this, input_subsystem); - - dialog.setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | - Qt::WindowSystemMenuHint); - dialog.setWindowModality(Qt::WindowModal); - - if (dialog.exec() == QDialog::Accepted) { - dialog.ApplyConfiguration(); - } -} - -void QtControllerSelectorDialog::CallConfigureInputProfileDialog() { - ConfigureInputProfileDialog dialog(this, input_subsystem, input_profiles.get(), system); - - dialog.setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | - Qt::WindowSystemMenuHint); - dialog.setWindowModality(Qt::WindowModal); - dialog.exec(); -} - -void QtControllerSelectorDialog::keyPressEvent(QKeyEvent* evt) { - const auto num_connected_players = static_cast<int>( - std::count_if(player_groupboxes.begin(), player_groupboxes.end(), - [](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; - - if ((evt->key() == Qt::Key_Enter || evt->key() == Qt::Key_Return) && !parameters_met) { - // Display error message when trying to validate using "Enter" and "OK" button is disabled - ui->labelError->setVisible(true); - return; - } else if (evt->key() == Qt::Key_Left && num_connected_players > min_supported_players) { - // Remove a player if possible - connected_controller_checkboxes[num_connected_players - 1]->setChecked(false); - return; - } else if (evt->key() == Qt::Key_Right && num_connected_players < max_supported_players) { - // Add a player, if possible - ui->labelError->setVisible(false); - connected_controller_checkboxes[num_connected_players]->setChecked(true); - return; - } - QDialog::keyPressEvent(evt); -} - -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(), - [](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; - - // First, check against the number of connected players. - if (num_connected_players < min_supported_players || - num_connected_players > max_supported_players) { - parameters_met = false; - ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(parameters_met); - return parameters_met; - } - - // Next, check against all connected controllers. - const auto all_controllers_compatible = [this] { - for (std::size_t index = 0; index < NUM_PLAYERS; ++index) { - // Skip controllers that are not used, we only care about the currently connected ones. - if (!player_groupboxes[index]->isChecked() || !player_groupboxes[index]->isEnabled()) { - continue; - } - - const auto compatible = IsControllerCompatible( - GetControllerTypeFromIndex(emulated_controllers[index]->currentIndex(), index), - parameters); - - // If any controller is found to be incompatible, return false early. - if (!compatible) { - return false; - } - } - - // Reaching here means all currently connected controllers are compatible. - return true; - }(); - - parameters_met = all_controllers_compatible; - ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(parameters_met); - return parameters_met; -} - -void QtControllerSelectorDialog::SetSupportedControllers() { - const QString theme = [] { - if (QIcon::themeName().contains(QStringLiteral("dark"))) { - return QStringLiteral("_dark"); - } else if (QIcon::themeName().contains(QStringLiteral("midnight"))) { - return QStringLiteral("_midnight"); - } else { - return QString{}; - } - }(); - - if (parameters.enable_single_mode && parameters.allow_handheld) { - ui->controllerSupported1->setStyleSheet( - QStringLiteral("image: url(:/controller/applet_handheld%0); ").arg(theme)); - } else { - ui->controllerSupported1->setStyleSheet( - QStringLiteral("image: url(:/controller/applet_handheld%0_disabled); ").arg(theme)); - } - - if (parameters.allow_dual_joycons) { - ui->controllerSupported2->setStyleSheet( - QStringLiteral("image: url(:/controller/applet_dual_joycon%0); ").arg(theme)); - } else { - ui->controllerSupported2->setStyleSheet( - QStringLiteral("image: url(:/controller/applet_dual_joycon%0_disabled); ").arg(theme)); - } - - if (parameters.allow_left_joycon) { - ui->controllerSupported3->setStyleSheet( - QStringLiteral("image: url(:/controller/applet_joycon_left%0); ").arg(theme)); - } else { - ui->controllerSupported3->setStyleSheet( - QStringLiteral("image: url(:/controller/applet_joycon_left%0_disabled); ").arg(theme)); - } - - if (parameters.allow_right_joycon) { - ui->controllerSupported4->setStyleSheet( - QStringLiteral("image: url(:/controller/applet_joycon_right%0); ").arg(theme)); - } else { - ui->controllerSupported4->setStyleSheet( - QStringLiteral("image: url(:/controller/applet_joycon_right%0_disabled); ").arg(theme)); - } - - if (parameters.allow_pro_controller || parameters.allow_gamecube_controller) { - ui->controllerSupported5->setStyleSheet( - QStringLiteral("image: url(:/controller/applet_pro_controller%0); ").arg(theme)); - } else { - ui->controllerSupported5->setStyleSheet( - QStringLiteral("image: url(:/controller/applet_pro_controller%0_disabled); ") - .arg(theme)); - } - - // enable_single_mode overrides min_players and max_players. - if (parameters.enable_single_mode) { - ui->numberSupportedLabel->setText(QStringLiteral("1")); - return; - } - - if (parameters.min_players == parameters.max_players) { - ui->numberSupportedLabel->setText(QStringLiteral("%1").arg(parameters.max_players)); - } else { - ui->numberSupportedLabel->setText( - QStringLiteral("%1 - %2").arg(parameters.min_players).arg(parameters.max_players)); - } -} - -void QtControllerSelectorDialog::SetEmulatedControllers(std::size_t player_index) { - const auto npad_style_set = system.HIDCore().GetSupportedStyleTag(); - auto& pairs = index_controller_type_pairs[player_index]; - - pairs.clear(); - emulated_controllers[player_index]->clear(); - - const auto add_item = [&](Core::HID::NpadStyleIndex controller_type, - const QString& controller_name) { - pairs.emplace_back(emulated_controllers[player_index]->count(), controller_type); - emulated_controllers[player_index]->addItem(controller_name); - }; - - if (npad_style_set.fullkey == 1) { - add_item(Core::HID::NpadStyleIndex::Fullkey, tr("Pro Controller")); - } - - if (npad_style_set.joycon_dual == 1) { - add_item(Core::HID::NpadStyleIndex::JoyconDual, tr("Dual Joycons")); - } - - if (npad_style_set.joycon_left == 1) { - add_item(Core::HID::NpadStyleIndex::JoyconLeft, tr("Left Joycon")); - } - - if (npad_style_set.joycon_right == 1) { - add_item(Core::HID::NpadStyleIndex::JoyconRight, tr("Right Joycon")); - } - - if (player_index == 0 && npad_style_set.handheld == 1) { - add_item(Core::HID::NpadStyleIndex::Handheld, tr("Handheld")); - } - - if (npad_style_set.gamecube == 1) { - add_item(Core::HID::NpadStyleIndex::GameCube, tr("GameCube Controller")); - } - - // Disable all unsupported controllers - if (!Settings::values.enable_all_controllers) { - return; - } - - if (npad_style_set.palma == 1) { - add_item(Core::HID::NpadStyleIndex::Pokeball, tr("Poke Ball Plus")); - } - - if (npad_style_set.lark == 1) { - add_item(Core::HID::NpadStyleIndex::NES, tr("NES Controller")); - } - - if (npad_style_set.lucia == 1) { - add_item(Core::HID::NpadStyleIndex::SNES, tr("SNES Controller")); - } - - if (npad_style_set.lagoon == 1) { - add_item(Core::HID::NpadStyleIndex::N64, tr("N64 Controller")); - } - - if (npad_style_set.lager == 1) { - add_item(Core::HID::NpadStyleIndex::SegaGenesis, tr("Sega Genesis")); - } -} - -Core::HID::NpadStyleIndex QtControllerSelectorDialog::GetControllerTypeFromIndex( - int index, std::size_t player_index) const { - const auto& pairs = index_controller_type_pairs[player_index]; - - const auto it = std::find_if(pairs.begin(), pairs.end(), - [index](const auto& pair) { return pair.first == index; }); - - if (it == pairs.end()) { - return Core::HID::NpadStyleIndex::Fullkey; - } - - return it->second; -} - -int QtControllerSelectorDialog::GetIndexFromControllerType(Core::HID::NpadStyleIndex type, - std::size_t player_index) const { - const auto& pairs = index_controller_type_pairs[player_index]; - - const auto it = std::find_if(pairs.begin(), pairs.end(), - [type](const auto& pair) { return pair.second == type; }); - - if (it == pairs.end()) { - return 0; - } - - return it->first; -} - -void QtControllerSelectorDialog::UpdateControllerIcon(std::size_t player_index) { - if (!player_groupboxes[player_index]->isChecked()) { - connected_controller_icons[player_index]->setStyleSheet(QString{}); - player_labels[player_index]->show(); - return; - } - - const QString stylesheet = [this, player_index] { - switch (GetControllerTypeFromIndex(emulated_controllers[player_index]->currentIndex(), - player_index)) { - case Core::HID::NpadStyleIndex::Fullkey: - case Core::HID::NpadStyleIndex::GameCube: - return QStringLiteral("image: url(:/controller/applet_pro_controller%0); "); - case Core::HID::NpadStyleIndex::JoyconDual: - return QStringLiteral("image: url(:/controller/applet_dual_joycon%0); "); - case Core::HID::NpadStyleIndex::JoyconLeft: - return QStringLiteral("image: url(:/controller/applet_joycon_left%0); "); - case Core::HID::NpadStyleIndex::JoyconRight: - return QStringLiteral("image: url(:/controller/applet_joycon_right%0); "); - case Core::HID::NpadStyleIndex::Handheld: - return QStringLiteral("image: url(:/controller/applet_handheld%0); "); - default: - return QString{}; - } - }(); - - if (stylesheet.isEmpty()) { - connected_controller_icons[player_index]->setStyleSheet(QString{}); - player_labels[player_index]->show(); - return; - } - - const QString theme = [] { - if (QIcon::themeName().contains(QStringLiteral("dark"))) { - return QStringLiteral("_dark"); - } else if (QIcon::themeName().contains(QStringLiteral("midnight"))) { - return QStringLiteral("_midnight"); - } else { - return QString{}; - } - }(); - - connected_controller_icons[player_index]->setStyleSheet(stylesheet.arg(theme)); - player_labels[player_index]->hide(); -} - -void QtControllerSelectorDialog::UpdateControllerState(std::size_t player_index) { - auto* controller = system.HIDCore().GetEmulatedControllerByIndex(player_index); - - const auto controller_type = GetControllerTypeFromIndex( - emulated_controllers[player_index]->currentIndex(), player_index); - const auto player_connected = player_groupboxes[player_index]->isChecked() && - controller_type != Core::HID::NpadStyleIndex::Handheld; - - if (controller->GetNpadStyleIndex(true) == controller_type && - controller->IsConnected(true) == player_connected) { - return; - } - - // Disconnect the controller first. - UpdateController(controller, controller_type, false); - - // Handheld - if (player_index == 0) { - if (controller_type == Core::HID::NpadStyleIndex::Handheld) { - auto* handheld = - system.HIDCore().GetEmulatedController(Core::HID::NpadIdType::Handheld); - UpdateController(handheld, Core::HID::NpadStyleIndex::Handheld, - player_groupboxes[player_index]->isChecked()); - } - } - - UpdateController(controller, controller_type, player_connected); -} - -void QtControllerSelectorDialog::UpdateLEDPattern(std::size_t player_index) { - if (!player_groupboxes[player_index]->isChecked() || - GetControllerTypeFromIndex(emulated_controllers[player_index]->currentIndex(), - player_index) == Core::HID::NpadStyleIndex::Handheld) { - led_patterns_boxes[player_index][0]->setChecked(false); - led_patterns_boxes[player_index][1]->setChecked(false); - led_patterns_boxes[player_index][2]->setChecked(false); - led_patterns_boxes[player_index][3]->setChecked(false); - return; - } - - const auto* controller = system.HIDCore().GetEmulatedControllerByIndex(player_index); - const auto led_pattern = controller->GetLedPattern(); - led_patterns_boxes[player_index][0]->setChecked(led_pattern.position1); - led_patterns_boxes[player_index][1]->setChecked(led_pattern.position2); - led_patterns_boxes[player_index][2]->setChecked(led_pattern.position3); - led_patterns_boxes[player_index][3]->setChecked(led_pattern.position4); -} - -void QtControllerSelectorDialog::UpdateBorderColor(std::size_t player_index) { - if (!parameters.enable_border_color || - player_index >= static_cast<std::size_t>(parameters.max_players) || - player_groupboxes[player_index]->styleSheet().contains(QStringLiteral("QGroupBox"))) { - return; - } - - player_groupboxes[player_index]->setStyleSheet( - player_groupboxes[player_index]->styleSheet().append( - QStringLiteral("QGroupBox#groupPlayer%1Connected:checked " - "{ border: 1px solid rgba(%2, %3, %4, %5); }") - .arg(player_index + 1) - .arg(parameters.border_colors[player_index][0]) - .arg(parameters.border_colors[player_index][1]) - .arg(parameters.border_colors[player_index][2]) - .arg(parameters.border_colors[player_index][3]))); -} - -void QtControllerSelectorDialog::SetExplainText(std::size_t player_index) { - if (!parameters.enable_explain_text || - player_index >= static_cast<std::size_t>(parameters.max_players)) { - return; - } - - explain_text_labels[player_index]->setText(QString::fromStdString( - Common::StringFromFixedZeroTerminatedBuffer(parameters.explain_text[player_index].data(), - parameters.explain_text[player_index].size()))); -} - -void QtControllerSelectorDialog::UpdateDockedState(bool is_handheld) { - // Disallow changing the console mode if the controller type is handheld. - ui->radioDocked->setEnabled(!is_handheld); - ui->radioUndocked->setEnabled(!is_handheld); - - ui->radioDocked->setChecked(Settings::IsDockedMode()); - ui->radioUndocked->setChecked(!Settings::IsDockedMode()); - - // Also force into undocked mode if the controller type is handheld. - if (is_handheld) { - ui->radioUndocked->setChecked(true); - } -} - -void QtControllerSelectorDialog::PropagatePlayerNumberChanged(size_t player_index, bool checked, - bool reconnect_current) { - connected_controller_checkboxes[player_index]->setChecked(checked); - // Hide eventual error message about number of controllers - ui->labelError->setVisible(false); - - if (checked) { - // Check all previous buttons when checked - if (player_index > 0) { - PropagatePlayerNumberChanged(player_index - 1, checked); - } - } else { - // Unchecked all following buttons when unchecked - if (player_index < connected_controller_checkboxes.size() - 1) { - PropagatePlayerNumberChanged(player_index + 1, checked); - } - } - - if (reconnect_current) { - connected_controller_checkboxes[player_index]->setCheckState(Qt::Checked); - } -} - -void QtControllerSelectorDialog::DisableUnsupportedPlayers() { - const auto max_supported_players = parameters.enable_single_mode ? 1 : parameters.max_players; - - switch (max_supported_players) { - case 0: - default: - ASSERT(false); - return; - case 1: - ui->widgetSpacer->hide(); - ui->widgetSpacer2->hide(); - ui->widgetSpacer3->hide(); - ui->widgetSpacer4->hide(); - break; - case 2: - ui->widgetSpacer->hide(); - ui->widgetSpacer2->hide(); - ui->widgetSpacer3->hide(); - break; - case 3: - ui->widgetSpacer->hide(); - ui->widgetSpacer2->hide(); - break; - case 4: - ui->widgetSpacer->hide(); - break; - case 5: - case 6: - case 7: - case 8: - break; - } - - for (std::size_t index = max_supported_players; index < NUM_PLAYERS; ++index) { - auto* controller = system.HIDCore().GetEmulatedControllerByIndex(index); - // Disconnect any unsupported players here and disable or hide them if applicable. - UpdateController(controller, controller->GetNpadStyleIndex(true), false); - // Hide the player widgets when max_supported_controllers is less than or equal to 4. - if (max_supported_players <= 4) { - player_widgets[index]->hide(); - } - - // Disable and hide the following to prevent these from interaction. - player_widgets[index]->setDisabled(true); - connected_controller_checkboxes[index]->setDisabled(true); - connected_controller_labels[index]->hide(); - connected_controller_checkboxes[index]->hide(); - } -} - -QtControllerSelector::QtControllerSelector(GMainWindow& parent) { - connect(this, &QtControllerSelector::MainWindowReconfigureControllers, &parent, - &GMainWindow::ControllerSelectorReconfigureControllers, Qt::QueuedConnection); - connect(this, &QtControllerSelector::MainWindowRequestExit, &parent, - &GMainWindow::ControllerSelectorRequestExit, Qt::QueuedConnection); - connect(&parent, &GMainWindow::ControllerSelectorReconfigureFinished, this, - &QtControllerSelector::MainWindowReconfigureFinished, Qt::QueuedConnection); -} - -QtControllerSelector::~QtControllerSelector() = default; - -void QtControllerSelector::Close() const { - callback = {}; - emit MainWindowRequestExit(); -} - -void QtControllerSelector::ReconfigureControllers( - ReconfigureCallback callback_, const Core::Frontend::ControllerParameters& parameters) const { - callback = std::move(callback_); - emit MainWindowReconfigureControllers(parameters); -} - -void QtControllerSelector::MainWindowReconfigureFinished(bool is_success) { - if (callback) { - callback(is_success); - } -} diff --git a/src/yuzu/applets/qt_controller.h b/src/yuzu/applets/qt_controller.h deleted file mode 100644 index e5372495d..000000000 --- a/src/yuzu/applets/qt_controller.h +++ /dev/null @@ -1,183 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include <array> -#include <memory> -#include <QDialog> -#include "core/frontend/applets/controller.h" - -class GMainWindow; -class QCheckBox; -class QComboBox; -class QDialogButtonBox; -class QGroupBox; -class QLabel; - -class InputProfiles; - -namespace InputCommon { -class InputSubsystem; -} - -namespace Ui { -class QtControllerSelectorDialog; -} - -namespace Core { -class System; -} - -namespace Core::HID { -class HIDCore; -enum class NpadStyleIndex : u8; -} // namespace Core::HID - -class ControllerNavigation; - -class QtControllerSelectorDialog final : public QDialog { - Q_OBJECT - -public: - explicit QtControllerSelectorDialog(QWidget* parent, - Core::Frontend::ControllerParameters parameters_, - InputCommon::InputSubsystem* input_subsystem_, - Core::System& system_); - ~QtControllerSelectorDialog() override; - - int exec() override; - - void keyPressEvent(QKeyEvent* evt) override; - -private: - // Applies the current configuration. - void ApplyConfiguration(); - - // Loads the current input configuration into the frontend applet. - void LoadConfiguration(); - - // Initializes the "Configure Vibration" Dialog. - void CallConfigureVibrationDialog(); - - // Initializes the "Configure Motion / Touch" Dialog. - void CallConfigureMotionTouchDialog(); - - // Initializes the "Create Input Profile" Dialog. - void CallConfigureInputProfileDialog(); - - // Checks the current configuration against the given parameters. - // This sets and returns the value of parameters_met. - bool CheckIfParametersMet(); - - // Sets the controller icons for "Supported Controller Types". - void SetSupportedControllers(); - - // Sets the emulated controllers per player. - void SetEmulatedControllers(std::size_t player_index); - - // Gets the Controller Type for a given controller combobox index per player. - Core::HID::NpadStyleIndex GetControllerTypeFromIndex(int index, std::size_t player_index) const; - - // Gets the controller combobox index for a given Controller Type per player. - int GetIndexFromControllerType(Core::HID::NpadStyleIndex type, std::size_t player_index) const; - - // Updates the controller icons per player. - void UpdateControllerIcon(std::size_t player_index); - - // Updates the controller state (type and connection status) per player. - void UpdateControllerState(std::size_t player_index); - - // Updates the LED pattern per player. - void UpdateLEDPattern(std::size_t player_index); - - // Updates the border color per player. - void UpdateBorderColor(std::size_t player_index); - - // Sets the "Explain Text" per player. - void SetExplainText(std::size_t player_index); - - // Updates the console mode. - void UpdateDockedState(bool is_handheld); - - // Enable preceding controllers or disable following ones - void PropagatePlayerNumberChanged(size_t player_index, bool checked, - bool reconnect_current = false); - - // Disables and disconnects unsupported players based on the given parameters. - void DisableUnsupportedPlayers(); - - std::unique_ptr<Ui::QtControllerSelectorDialog> ui; - - // Parameters sent in from the backend HLE applet. - Core::Frontend::ControllerParameters parameters; - - InputCommon::InputSubsystem* input_subsystem; - - std::unique_ptr<InputProfiles> input_profiles; - - Core::System& system; - - ControllerNavigation* controller_navigation = nullptr; - - // This is true if and only if all parameters are met. Otherwise, this is false. - // This determines whether the "OK" button can be clicked to exit the applet. - bool parameters_met{false}; - - static constexpr std::size_t NUM_PLAYERS = 8; - - // Widgets encapsulating the groupboxes and comboboxes per player. - std::array<QWidget*, NUM_PLAYERS> player_widgets; - - // Groupboxes encapsulating the controller icons and LED patterns per player. - std::array<QGroupBox*, NUM_PLAYERS> player_groupboxes; - - // Icons for currently connected controllers/players. - std::array<QWidget*, NUM_PLAYERS> connected_controller_icons; - - // Labels that represent the player numbers in place of the controller icons. - std::array<QLabel*, NUM_PLAYERS> player_labels; - - // LED patterns for currently connected controllers/players. - std::array<std::array<QCheckBox*, 4>, NUM_PLAYERS> led_patterns_boxes; - - // Labels representing additional information known as "Explain Text" per player. - std::array<QLabel*, NUM_PLAYERS> explain_text_labels; - - // Comboboxes with a list of emulated controllers per player. - std::array<QComboBox*, NUM_PLAYERS> emulated_controllers; - - /// Pairs of emulated controller index and Controller Type enum per player. - std::array<std::vector<std::pair<int, Core::HID::NpadStyleIndex>>, NUM_PLAYERS> - index_controller_type_pairs; - - // Labels representing the number of connected controllers - // above the "Connected Controllers" checkboxes. - std::array<QLabel*, NUM_PLAYERS> connected_controller_labels; - - // Checkboxes representing the "Connected Controllers". - std::array<QCheckBox*, NUM_PLAYERS> connected_controller_checkboxes; -}; - -class QtControllerSelector final : public QObject, public Core::Frontend::ControllerApplet { - Q_OBJECT - -public: - explicit QtControllerSelector(GMainWindow& parent); - ~QtControllerSelector() override; - - void Close() const override; - void ReconfigureControllers( - ReconfigureCallback callback_, - const Core::Frontend::ControllerParameters& parameters) const override; - -signals: - void MainWindowReconfigureControllers( - const Core::Frontend::ControllerParameters& parameters) const; - void MainWindowRequestExit() const; - -private: - void MainWindowReconfigureFinished(bool is_success); - - mutable ReconfigureCallback callback; -}; diff --git a/src/yuzu/applets/qt_controller.ui b/src/yuzu/applets/qt_controller.ui deleted file mode 100644 index 6f7cb3c13..000000000 --- a/src/yuzu/applets/qt_controller.ui +++ /dev/null @@ -1,2699 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>QtControllerSelectorDialog</class> - <widget class="QDialog" name="QtControllerSelectorDialog"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>839</width> - <height>630</height> - </rect> - </property> - <property name="windowTitle"> - <string>Controller Applet</string> - </property> - <property name="styleSheet"> - <string notr="true"/> - </property> - <layout class="QVBoxLayout" name="verticalLayout" stretch="0"> - <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="QWidget" name="mainControllerApplet" native="true"> - <layout class="QVBoxLayout" name="verticalLayout_2" stretch="0,3,0"> - <property name="spacing"> - <number>0</number> - </property> - <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="QWidget" name="topControllerApplet" native="true"> - <layout class="QHBoxLayout" name="horizontalLayout"> - <property name="spacing"> - <number>10</number> - </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>10</number> - </property> - <item> - <spacer name="controllerAppletHorizontalSpacer2"> - <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="QWidget" name="controllersSupported" native="true"> - <property name="minimumSize"> - <size> - <width>70</width> - <height>70</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>70</width> - <height>70</height> - </size> - </property> - <layout class="QVBoxLayout" name="verticalLayout_21"> - <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="controllersSupportedLabel"> - <property name="minimumSize"> - <size> - <width>70</width> - <height>70</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>70</width> - <height>70</height> - </size> - </property> - <property name="font"> - <font> - <weight>75</weight> - <bold>true</bold> - </font> - </property> - <property name="text"> - <string>Supported Controller Types:</string> - </property> - <property name="alignment"> - <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> - </property> - <property name="wordWrap"> - <bool>true</bool> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QWidget" name="controllerSupported1" native="true"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimumSize"> - <size> - <width>70</width> - <height>70</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>70</width> - <height>70</height> - </size> - </property> - <property name="styleSheet"> - <string notr="true"/> - </property> - </widget> - </item> - <item> - <widget class="QWidget" name="controllerSupported2" native="true"> - <property name="minimumSize"> - <size> - <width>70</width> - <height>70</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>70</width> - <height>70</height> - </size> - </property> - <property name="styleSheet"> - <string notr="true"/> - </property> - </widget> - </item> - <item> - <widget class="QWidget" name="controllerSupported3" native="true"> - <property name="minimumSize"> - <size> - <width>70</width> - <height>70</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>70</width> - <height>70</height> - </size> - </property> - <property name="styleSheet"> - <string notr="true"/> - </property> - </widget> - </item> - <item> - <widget class="QWidget" name="controllerSupported4" native="true"> - <property name="minimumSize"> - <size> - <width>70</width> - <height>70</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>70</width> - <height>70</height> - </size> - </property> - <property name="styleSheet"> - <string notr="true"/> - </property> - </widget> - </item> - <item> - <widget class="QWidget" name="controllerSupported5" native="true"> - <property name="minimumSize"> - <size> - <width>70</width> - <height>70</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>70</width> - <height>70</height> - </size> - </property> - <property name="styleSheet"> - <string notr="true"/> - </property> - </widget> - </item> - <item> - <widget class="QWidget" name="playersSupported" native="true"> - <property name="minimumSize"> - <size> - <width>70</width> - <height>70</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>70</width> - <height>70</height> - </size> - </property> - <layout class="QVBoxLayout" name="verticalLayout_20"> - <property name="spacing"> - <number>0</number> - </property> - <property name="leftMargin"> - <number>0</number> - </property> - <property name="topMargin"> - <number>16</number> - </property> - <property name="rightMargin"> - <number>14</number> - </property> - <property name="bottomMargin"> - <number>16</number> - </property> - <item> - <widget class="QLabel" name="maxSupportedLabel"> - <property name="font"> - <font> - <weight>75</weight> - <bold>true</bold> - </font> - </property> - <property name="text"> - <string>Players:</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - <property name="wordWrap"> - <bool>false</bool> - </property> - </widget> - </item> - <item> - <widget class="QLabel" name="numberSupportedLabel"> - <property name="font"> - <font> - <pointsize>14</pointsize> - </font> - </property> - <property name="text"> - <string>1 - 8</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <spacer name="controllerAppletHorizontalSpacer3"> - <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="QWidget" name="middleControllerApplet" native="true"> - <layout class="QVBoxLayout" name="verticalLayout_3"> - <property name="spacing"> - <number>0</number> - </property> - <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="QGridLayout" name="gridLayout"> - <property name="spacing"> - <number>5</number> - </property> - <item row="1" column="7"> - <widget class="QWidget" name="widgetPlayer4" native="true"> - <layout class="QVBoxLayout" name="verticalLayout_27"> - <property name="spacing"> - <number>5</number> - </property> - <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 alignment="Qt::AlignHCenter"> - <widget class="QGroupBox" name="groupPlayer4Connected"> - <property name="minimumSize"> - <size> - <width>100</width> - <height>100</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>100</width> - <height>100</height> - </size> - </property> - <property name="title"> - <string/> - </property> - <property name="checkable"> - <bool>true</bool> - </property> - <property name="checked"> - <bool>false</bool> - </property> - <layout class="QVBoxLayout" name="verticalLayout_7" stretch="1,0"> - <property name="spacing"> - <number>7</number> - </property> - <property name="leftMargin"> - <number>14</number> - </property> - <property name="topMargin"> - <number>7</number> - </property> - <property name="rightMargin"> - <number>14</number> - </property> - <property name="bottomMargin"> - <number>4</number> - </property> - <item> - <widget class="QWidget" name="controllerPlayer4" native="true"> - <property name="styleSheet"> - <string notr="true"/> - </property> - <layout class="QVBoxLayout" name="verticalLayout_15"> - <property name="topMargin"> - <number>16</number> - </property> - <item alignment="Qt::AlignHCenter|Qt::AlignVCenter"> - <widget class="QLabel" name="labelPlayer4"> - <property name="text"> - <string>P4</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item alignment="Qt::AlignHCenter"> - <widget class="QWidget" name="Player4LEDs" native="true"> - <property name="enabled"> - <bool>false</bool> - </property> - <property name="minimumSize"> - <size> - <width>0</width> - <height>10</height> - </size> - </property> - <layout class="QHBoxLayout" name="horizontalLayout_10"> - <property name="spacing"> - <number>4</number> - </property> - <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="QCheckBox" name="checkboxPlayer4LED1"/> - </item> - <item> - <widget class="QCheckBox" name="checkboxPlayer4LED2"/> - </item> - <item> - <widget class="QCheckBox" name="checkboxPlayer4LED3"/> - </item> - <item> - <widget class="QCheckBox" name="checkboxPlayer4LED4"/> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QWidget" name="Player4Explain" native="true"> - <property name="minimumSize"> - <size> - <width>0</width> - <height>10</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>150</width> - <height>16777215</height> - </size> - </property> - <layout class="QVBoxLayout" name="verticalLayout_39"> - <property name="spacing"> - <number>0</number> - </property> - <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="labelPlayer4Explain"> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QComboBox" name="comboPlayer4Emulated"> - <item> - <property name="text"> - <string>Pro Controller</string> - </property> - </item> - <item> - <property name="text"> - <string>Dual Joycons</string> - </property> - </item> - <item> - <property name="text"> - <string>Left Joycon</string> - </property> - </item> - <item> - <property name="text"> - <string>Right Joycon</string> - </property> - </item> - </widget> - </item> - <item> - <widget class="QComboBox" name="comboPlayer4Profile"> - <item> - <property name="text"> - <string>Use Current Config</string> - </property> - </item> - </widget> - </item> - </layout> - </widget> - </item> - <item row="1" column="3"> - <widget class="QWidget" name="widgetPlayer2" native="true"> - <layout class="QVBoxLayout" name="verticalLayout_29"> - <property name="spacing"> - <number>5</number> - </property> - <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 alignment="Qt::AlignHCenter"> - <widget class="QGroupBox" name="groupPlayer2Connected"> - <property name="minimumSize"> - <size> - <width>100</width> - <height>100</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>100</width> - <height>100</height> - </size> - </property> - <property name="title"> - <string/> - </property> - <property name="checkable"> - <bool>true</bool> - </property> - <property name="checked"> - <bool>false</bool> - </property> - <layout class="QVBoxLayout" name="verticalLayout_5" stretch="1,0"> - <property name="spacing"> - <number>7</number> - </property> - <property name="leftMargin"> - <number>14</number> - </property> - <property name="topMargin"> - <number>7</number> - </property> - <property name="rightMargin"> - <number>14</number> - </property> - <property name="bottomMargin"> - <number>4</number> - </property> - <item> - <widget class="QWidget" name="controllerPlayer2" native="true"> - <property name="styleSheet"> - <string notr="true"/> - </property> - <layout class="QVBoxLayout" name="verticalLayout_13"> - <property name="topMargin"> - <number>16</number> - </property> - <item alignment="Qt::AlignHCenter|Qt::AlignVCenter"> - <widget class="QLabel" name="labelPlayer2"> - <property name="text"> - <string>P2</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item alignment="Qt::AlignHCenter"> - <widget class="QWidget" name="Player2LEDs" native="true"> - <property name="enabled"> - <bool>false</bool> - </property> - <property name="minimumSize"> - <size> - <width>0</width> - <height>10</height> - </size> - </property> - <layout class="QHBoxLayout" name="horizontalLayout_8"> - <property name="spacing"> - <number>4</number> - </property> - <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="QCheckBox" name="checkboxPlayer2LED1"/> - </item> - <item> - <widget class="QCheckBox" name="checkboxPlayer2LED2"/> - </item> - <item> - <widget class="QCheckBox" name="checkboxPlayer2LED3"/> - </item> - <item> - <widget class="QCheckBox" name="checkboxPlayer2LED4"/> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QWidget" name="Player2Explain" native="true"> - <property name="minimumSize"> - <size> - <width>0</width> - <height>10</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>150</width> - <height>16777215</height> - </size> - </property> - <layout class="QVBoxLayout" name="verticalLayout_37"> - <property name="spacing"> - <number>0</number> - </property> - <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="labelPlayer2Explain"> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QComboBox" name="comboPlayer2Emulated"> - <item> - <property name="text"> - <string>Pro Controller</string> - </property> - </item> - <item> - <property name="text"> - <string>Dual Joycons</string> - </property> - </item> - <item> - <property name="text"> - <string>Left Joycon</string> - </property> - </item> - <item> - <property name="text"> - <string>Right Joycon</string> - </property> - </item> - </widget> - </item> - <item> - <widget class="QComboBox" name="comboPlayer2Profile"> - <item> - <property name="text"> - <string>Use Current Config</string> - </property> - </item> - </widget> - </item> - </layout> - </widget> - </item> - <item row="1" column="1"> - <widget class="QWidget" name="widgetPlayer1" native="true"> - <layout class="QVBoxLayout" name="verticalLayout_30"> - <property name="spacing"> - <number>5</number> - </property> - <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 alignment="Qt::AlignHCenter"> - <widget class="QGroupBox" name="groupPlayer1Connected"> - <property name="minimumSize"> - <size> - <width>100</width> - <height>100</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>100</width> - <height>100</height> - </size> - </property> - <property name="title"> - <string/> - </property> - <property name="checkable"> - <bool>true</bool> - </property> - <property name="checked"> - <bool>false</bool> - </property> - <layout class="QVBoxLayout" name="verticalLayout_4" stretch="1,0"> - <property name="spacing"> - <number>7</number> - </property> - <property name="leftMargin"> - <number>14</number> - </property> - <property name="topMargin"> - <number>7</number> - </property> - <property name="rightMargin"> - <number>14</number> - </property> - <property name="bottomMargin"> - <number>4</number> - </property> - <item> - <widget class="QWidget" name="controllerPlayer1" native="true"> - <property name="styleSheet"> - <string notr="true"/> - </property> - <layout class="QVBoxLayout" name="verticalLayout_12"> - <property name="topMargin"> - <number>16</number> - </property> - <item alignment="Qt::AlignHCenter|Qt::AlignVCenter"> - <widget class="QLabel" name="labelPlayer1"> - <property name="text"> - <string>P1</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item alignment="Qt::AlignHCenter"> - <widget class="QWidget" name="Player1LEDs" native="true"> - <property name="enabled"> - <bool>false</bool> - </property> - <property name="minimumSize"> - <size> - <width>0</width> - <height>10</height> - </size> - </property> - <layout class="QHBoxLayout" name="horizontalLayout_2"> - <property name="spacing"> - <number>4</number> - </property> - <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="QCheckBox" name="checkboxPlayer1LED1"> - <property name="layoutDirection"> - <enum>Qt::LeftToRight</enum> - </property> - </widget> - </item> - <item> - <widget class="QCheckBox" name="checkboxPlayer1LED2"/> - </item> - <item> - <widget class="QCheckBox" name="checkboxPlayer1LED3"/> - </item> - <item> - <widget class="QCheckBox" name="checkboxPlayer1LED4"/> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QWidget" name="Player1Explain" native="true"> - <property name="minimumSize"> - <size> - <width>0</width> - <height>10</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>150</width> - <height>16777215</height> - </size> - </property> - <layout class="QVBoxLayout" name="verticalLayout_36"> - <property name="spacing"> - <number>0</number> - </property> - <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="labelPlayer1Explain"> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QComboBox" name="comboPlayer1Emulated"> - <item> - <property name="text"> - <string>Pro Controller</string> - </property> - </item> - <item> - <property name="text"> - <string>Dual Joycons</string> - </property> - </item> - <item> - <property name="text"> - <string>Left Joycon</string> - </property> - </item> - <item> - <property name="text"> - <string>Right Joycon</string> - </property> - </item> - <item> - <property name="text"> - <string>Handheld</string> - </property> - </item> - </widget> - </item> - <item> - <widget class="QComboBox" name="comboPlayer1Profile"> - <item> - <property name="text"> - <string>Use Current Config</string> - </property> - </item> - </widget> - </item> - </layout> - </widget> - </item> - <item row="1" column="8"> - <widget class="QWidget" name="widgetSpacer2" native="true"> - <property name="minimumSize"> - <size> - <width>25</width> - <height>0</height> - </size> - </property> - <layout class="QVBoxLayout" name="verticalLayout_31"> - <property name="spacing"> - <number>0</number> - </property> - <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> - <spacer name="controllerAppletHorizontalSpacer8"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>25</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - </item> - <item row="1" column="4"> - <widget class="QWidget" name="widgetSpacer4" native="true"> - <layout class="QVBoxLayout" name="verticalLayout_33"> - <property name="spacing"> - <number>0</number> - </property> - <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> - <spacer name="controllerAppletHorizontalSpacer6"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>0</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - </item> - <item row="1" column="6"> - <widget class="QWidget" name="widgetSpacer3" native="true"> - <layout class="QVBoxLayout" name="verticalLayout_32"> - <property name="spacing"> - <number>0</number> - </property> - <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> - <spacer name="controllerAppletHorizontalSpacer7"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>0</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - </item> - <item row="1" column="5"> - <widget class="QWidget" name="widgetPlayer3" native="true"> - <layout class="QVBoxLayout" name="verticalLayout_28"> - <property name="spacing"> - <number>5</number> - </property> - <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 alignment="Qt::AlignHCenter"> - <widget class="QGroupBox" name="groupPlayer3Connected"> - <property name="minimumSize"> - <size> - <width>100</width> - <height>100</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>100</width> - <height>100</height> - </size> - </property> - <property name="title"> - <string/> - </property> - <property name="checkable"> - <bool>true</bool> - </property> - <property name="checked"> - <bool>false</bool> - </property> - <layout class="QVBoxLayout" name="verticalLayout_6" stretch="1,0"> - <property name="spacing"> - <number>7</number> - </property> - <property name="leftMargin"> - <number>14</number> - </property> - <property name="topMargin"> - <number>7</number> - </property> - <property name="rightMargin"> - <number>14</number> - </property> - <property name="bottomMargin"> - <number>4</number> - </property> - <item> - <widget class="QWidget" name="controllerPlayer3" native="true"> - <property name="styleSheet"> - <string notr="true"/> - </property> - <layout class="QVBoxLayout" name="verticalLayout_14"> - <property name="topMargin"> - <number>16</number> - </property> - <item alignment="Qt::AlignHCenter|Qt::AlignVCenter"> - <widget class="QLabel" name="labelPlayer3"> - <property name="text"> - <string>P3</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item alignment="Qt::AlignHCenter"> - <widget class="QWidget" name="Player3LEDs" native="true"> - <property name="enabled"> - <bool>false</bool> - </property> - <property name="minimumSize"> - <size> - <width>0</width> - <height>10</height> - </size> - </property> - <layout class="QHBoxLayout" name="horizontalLayout_9"> - <property name="spacing"> - <number>4</number> - </property> - <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="QCheckBox" name="checkboxPlayer3LED1"/> - </item> - <item> - <widget class="QCheckBox" name="checkboxPlayer3LED2"/> - </item> - <item> - <widget class="QCheckBox" name="checkboxPlayer3LED3"/> - </item> - <item> - <widget class="QCheckBox" name="checkboxPlayer3LED4"/> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QWidget" name="Player3Explain" native="true"> - <property name="minimumSize"> - <size> - <width>0</width> - <height>10</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>150</width> - <height>16777215</height> - </size> - </property> - <layout class="QVBoxLayout" name="verticalLayout_38"> - <property name="spacing"> - <number>0</number> - </property> - <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="labelPlayer3Explain"> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QComboBox" name="comboPlayer3Emulated"> - <item> - <property name="text"> - <string>Pro Controller</string> - </property> - </item> - <item> - <property name="text"> - <string>Dual Joycons</string> - </property> - </item> - <item> - <property name="text"> - <string>Left Joycon</string> - </property> - </item> - <item> - <property name="text"> - <string>Right Joycon</string> - </property> - </item> - </widget> - </item> - <item> - <widget class="QComboBox" name="comboPlayer3Profile"> - <item> - <property name="text"> - <string>Use Current Config</string> - </property> - </item> - </widget> - </item> - </layout> - </widget> - </item> - <item row="0" column="1"> - <widget class="QWidget" name="widgetSpacer5" native="true"> - <property name="minimumSize"> - <size> - <width>0</width> - <height>25</height> - </size> - </property> - <layout class="QVBoxLayout" name="verticalLayout_34"> - <property name="spacing"> - <number>0</number> - </property> - <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> - <spacer name="controllerAppletVerticalSpacer3"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>25</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - </item> - <item row="6" column="5"> - <widget class="QWidget" name="widgetPlayer7" native="true"> - <layout class="QVBoxLayout" name="verticalLayout_25"> - <property name="spacing"> - <number>5</number> - </property> - <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 alignment="Qt::AlignHCenter"> - <widget class="QGroupBox" name="groupPlayer7Connected"> - <property name="minimumSize"> - <size> - <width>100</width> - <height>100</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>100</width> - <height>100</height> - </size> - </property> - <property name="title"> - <string/> - </property> - <property name="checkable"> - <bool>true</bool> - </property> - <property name="checked"> - <bool>false</bool> - </property> - <layout class="QVBoxLayout" name="verticalLayout_10" stretch="1,0"> - <property name="spacing"> - <number>7</number> - </property> - <property name="leftMargin"> - <number>14</number> - </property> - <property name="topMargin"> - <number>7</number> - </property> - <property name="rightMargin"> - <number>14</number> - </property> - <property name="bottomMargin"> - <number>4</number> - </property> - <item> - <widget class="QWidget" name="controllerPlayer7" native="true"> - <property name="styleSheet"> - <string notr="true"/> - </property> - <layout class="QVBoxLayout" name="verticalLayout_18"> - <property name="topMargin"> - <number>16</number> - </property> - <item alignment="Qt::AlignHCenter|Qt::AlignVCenter"> - <widget class="QLabel" name="labelPlayer7"> - <property name="text"> - <string>P7</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item alignment="Qt::AlignHCenter"> - <widget class="QWidget" name="Player7LEDs" native="true"> - <property name="enabled"> - <bool>false</bool> - </property> - <property name="minimumSize"> - <size> - <width>0</width> - <height>10</height> - </size> - </property> - <layout class="QHBoxLayout" name="horizontalLayout_13"> - <property name="spacing"> - <number>4</number> - </property> - <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="QCheckBox" name="checkboxPlayer7LED1"/> - </item> - <item> - <widget class="QCheckBox" name="checkboxPlayer7LED2"/> - </item> - <item> - <widget class="QCheckBox" name="checkboxPlayer7LED3"/> - </item> - <item> - <widget class="QCheckBox" name="checkboxPlayer7LED4"/> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QWidget" name="Player7Explain" native="true"> - <property name="minimumSize"> - <size> - <width>0</width> - <height>10</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>150</width> - <height>16777215</height> - </size> - </property> - <layout class="QVBoxLayout" name="verticalLayout_42"> - <property name="spacing"> - <number>0</number> - </property> - <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="labelPlayer7Explain"> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QComboBox" name="comboPlayer7Emulated"> - <item> - <property name="text"> - <string>Pro Controller</string> - </property> - </item> - <item> - <property name="text"> - <string>Dual Joycons</string> - </property> - </item> - <item> - <property name="text"> - <string>Left Joycon</string> - </property> - </item> - <item> - <property name="text"> - <string>Right Joycon</string> - </property> - </item> - </widget> - </item> - <item> - <widget class="QComboBox" name="comboPlayer7Profile"> - <item> - <property name="text"> - <string>Use Current Config</string> - </property> - </item> - </widget> - </item> - </layout> - </widget> - </item> - <item row="6" column="7"> - <widget class="QWidget" name="widgetPlayer8" native="true"> - <layout class="QVBoxLayout" name="verticalLayout_26"> - <property name="spacing"> - <number>5</number> - </property> - <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 alignment="Qt::AlignHCenter"> - <widget class="QGroupBox" name="groupPlayer8Connected"> - <property name="minimumSize"> - <size> - <width>100</width> - <height>100</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>100</width> - <height>100</height> - </size> - </property> - <property name="title"> - <string/> - </property> - <property name="checkable"> - <bool>true</bool> - </property> - <property name="checked"> - <bool>false</bool> - </property> - <layout class="QVBoxLayout" name="verticalLayout_11" stretch="1,0"> - <property name="spacing"> - <number>7</number> - </property> - <property name="leftMargin"> - <number>14</number> - </property> - <property name="topMargin"> - <number>7</number> - </property> - <property name="rightMargin"> - <number>14</number> - </property> - <property name="bottomMargin"> - <number>4</number> - </property> - <item> - <widget class="QWidget" name="controllerPlayer8" native="true"> - <property name="styleSheet"> - <string notr="true"/> - </property> - <layout class="QVBoxLayout" name="verticalLayout_19"> - <property name="topMargin"> - <number>16</number> - </property> - <item alignment="Qt::AlignHCenter|Qt::AlignVCenter"> - <widget class="QLabel" name="labelPlayer8"> - <property name="text"> - <string>P8</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item alignment="Qt::AlignHCenter"> - <widget class="QWidget" name="Player8LEDs" native="true"> - <property name="enabled"> - <bool>false</bool> - </property> - <property name="minimumSize"> - <size> - <width>0</width> - <height>10</height> - </size> - </property> - <layout class="QHBoxLayout" name="horizontalLayout_14"> - <property name="spacing"> - <number>4</number> - </property> - <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="QCheckBox" name="checkboxPlayer8LED1"/> - </item> - <item> - <widget class="QCheckBox" name="checkboxPlayer8LED2"/> - </item> - <item> - <widget class="QCheckBox" name="checkboxPlayer8LED3"/> - </item> - <item> - <widget class="QCheckBox" name="checkboxPlayer8LED4"/> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QWidget" name="Player8Explain" native="true"> - <property name="minimumSize"> - <size> - <width>0</width> - <height>10</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>150</width> - <height>16777215</height> - </size> - </property> - <layout class="QVBoxLayout" name="verticalLayout_35"> - <property name="spacing"> - <number>0</number> - </property> - <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="labelPlayer8Explain"> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QComboBox" name="comboPlayer8Emulated"> - <item> - <property name="text"> - <string>Pro Controller</string> - </property> - </item> - <item> - <property name="text"> - <string>Dual Joycons</string> - </property> - </item> - <item> - <property name="text"> - <string>Left Joycon</string> - </property> - </item> - <item> - <property name="text"> - <string>Right Joycon</string> - </property> - </item> - </widget> - </item> - <item> - <widget class="QComboBox" name="comboPlayer8Profile"> - <item> - <property name="text"> - <string>Use Current Config</string> - </property> - </item> - </widget> - </item> - </layout> - </widget> - </item> - <item row="6" column="1"> - <widget class="QWidget" name="widgetPlayer5" native="true"> - <layout class="QVBoxLayout" name="verticalLayout_23"> - <property name="spacing"> - <number>5</number> - </property> - <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 alignment="Qt::AlignHCenter"> - <widget class="QGroupBox" name="groupPlayer5Connected"> - <property name="minimumSize"> - <size> - <width>100</width> - <height>100</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>100</width> - <height>100</height> - </size> - </property> - <property name="title"> - <string/> - </property> - <property name="checkable"> - <bool>true</bool> - </property> - <property name="checked"> - <bool>false</bool> - </property> - <layout class="QVBoxLayout" name="verticalLayout_8" stretch="1,0"> - <property name="spacing"> - <number>7</number> - </property> - <property name="leftMargin"> - <number>14</number> - </property> - <property name="topMargin"> - <number>7</number> - </property> - <property name="rightMargin"> - <number>14</number> - </property> - <property name="bottomMargin"> - <number>4</number> - </property> - <item> - <widget class="QWidget" name="controllerPlayer5" native="true"> - <property name="styleSheet"> - <string notr="true"/> - </property> - <layout class="QVBoxLayout" name="verticalLayout_16"> - <property name="topMargin"> - <number>16</number> - </property> - <item alignment="Qt::AlignHCenter|Qt::AlignVCenter"> - <widget class="QLabel" name="labelPlayer5"> - <property name="text"> - <string>P5</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item alignment="Qt::AlignHCenter"> - <widget class="QWidget" name="Player5LEDs" native="true"> - <property name="enabled"> - <bool>false</bool> - </property> - <property name="minimumSize"> - <size> - <width>0</width> - <height>10</height> - </size> - </property> - <layout class="QHBoxLayout" name="horizontalLayout_11"> - <property name="spacing"> - <number>4</number> - </property> - <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="QCheckBox" name="checkboxPlayer5LED1"> - <property name="layoutDirection"> - <enum>Qt::LeftToRight</enum> - </property> - </widget> - </item> - <item> - <widget class="QCheckBox" name="checkboxPlayer5LED2"/> - </item> - <item> - <widget class="QCheckBox" name="checkboxPlayer5LED3"/> - </item> - <item> - <widget class="QCheckBox" name="checkboxPlayer5LED4"/> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QWidget" name="Player5Explain" native="true"> - <property name="minimumSize"> - <size> - <width>0</width> - <height>10</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>150</width> - <height>16777215</height> - </size> - </property> - <layout class="QVBoxLayout" name="verticalLayout_40"> - <property name="spacing"> - <number>0</number> - </property> - <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="labelPlayer5Explain"> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QComboBox" name="comboPlayer5Emulated"> - <item> - <property name="text"> - <string>Pro Controller</string> - </property> - </item> - <item> - <property name="text"> - <string>Dual Joycons</string> - </property> - </item> - <item> - <property name="text"> - <string>Left Joycon</string> - </property> - </item> - <item> - <property name="text"> - <string>Right Joycon</string> - </property> - </item> - </widget> - </item> - <item> - <widget class="QComboBox" name="comboPlayer5Profile"> - <item> - <property name="text"> - <string>Use Current Config</string> - </property> - </item> - </widget> - </item> - </layout> - </widget> - </item> - <item row="6" column="3"> - <widget class="QWidget" name="widgetPlayer6" native="true"> - <layout class="QVBoxLayout" name="verticalLayout_24"> - <property name="spacing"> - <number>5</number> - </property> - <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 alignment="Qt::AlignHCenter"> - <widget class="QGroupBox" name="groupPlayer6Connected"> - <property name="minimumSize"> - <size> - <width>100</width> - <height>100</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>100</width> - <height>100</height> - </size> - </property> - <property name="title"> - <string/> - </property> - <property name="checkable"> - <bool>true</bool> - </property> - <property name="checked"> - <bool>false</bool> - </property> - <layout class="QVBoxLayout" name="verticalLayout_9" stretch="1,0"> - <property name="spacing"> - <number>7</number> - </property> - <property name="leftMargin"> - <number>14</number> - </property> - <property name="topMargin"> - <number>7</number> - </property> - <property name="rightMargin"> - <number>14</number> - </property> - <property name="bottomMargin"> - <number>4</number> - </property> - <item> - <widget class="QWidget" name="controllerPlayer6" native="true"> - <property name="styleSheet"> - <string notr="true"/> - </property> - <layout class="QVBoxLayout" name="verticalLayout_17"> - <property name="topMargin"> - <number>16</number> - </property> - <item alignment="Qt::AlignHCenter|Qt::AlignVCenter"> - <widget class="QLabel" name="labelPlayer6"> - <property name="text"> - <string>P6</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item alignment="Qt::AlignHCenter"> - <widget class="QWidget" name="Player6LEDs" native="true"> - <property name="enabled"> - <bool>false</bool> - </property> - <property name="minimumSize"> - <size> - <width>0</width> - <height>10</height> - </size> - </property> - <layout class="QHBoxLayout" name="horizontalLayout_12"> - <property name="spacing"> - <number>4</number> - </property> - <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="QCheckBox" name="checkboxPlayer6LED1"/> - </item> - <item> - <widget class="QCheckBox" name="checkboxPlayer6LED2"/> - </item> - <item> - <widget class="QCheckBox" name="checkboxPlayer6LED3"/> - </item> - <item> - <widget class="QCheckBox" name="checkboxPlayer6LED4"/> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QWidget" name="Player6Explain" native="true"> - <property name="minimumSize"> - <size> - <width>0</width> - <height>10</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>150</width> - <height>16777215</height> - </size> - </property> - <layout class="QVBoxLayout" name="verticalLayout_41"> - <property name="spacing"> - <number>0</number> - </property> - <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="labelPlayer6Explain"> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QComboBox" name="comboPlayer6Emulated"> - <item> - <property name="text"> - <string>Pro Controller</string> - </property> - </item> - <item> - <property name="text"> - <string>Dual Joycons</string> - </property> - </item> - <item> - <property name="text"> - <string>Left Joycon</string> - </property> - </item> - <item> - <property name="text"> - <string>Right Joycon</string> - </property> - </item> - </widget> - </item> - <item> - <widget class="QComboBox" name="comboPlayer6Profile"> - <item> - <property name="text"> - <string>Use Current Config</string> - </property> - </item> - </widget> - </item> - </layout> - </widget> - </item> - <item row="10" column="1"> - <widget class="QWidget" name="widgetSpacer" native="true"> - <property name="minimumSize"> - <size> - <width>0</width> - <height>25</height> - </size> - </property> - <layout class="QVBoxLayout" name="verticalLayout_22"> - <property name="spacing"> - <number>0</number> - </property> - <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> - <spacer name="controllerAppletVerticalSpacer"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>25</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - </item> - <item row="1" column="2"> - <widget class="QWidget" name="widgetSpacer6" native="true"> - <layout class="QHBoxLayout" name="horizontalLayout_15"> - <property name="spacing"> - <number>0</number> - </property> - <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> - <spacer name="controllerAppletHorizontalSpacer5"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>0</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - </item> - <item row="1" column="0"> - <widget class="QWidget" name="widgetSpacer7" native="true"> - <property name="minimumSize"> - <size> - <width>25</width> - <height>0</height> - </size> - </property> - <layout class="QHBoxLayout" name="horizontalLayout_16"> - <property name="spacing"> - <number>0</number> - </property> - <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> - <spacer name="controllerAppletHorizontalSpacer4"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>25</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - </item> - <item row="2" column="1"> - <widget class="QWidget" name="widgetSpacer9" native="true"> - <property name="minimumSize"> - <size> - <width>0</width> - <height>25</height> - </size> - </property> - <layout class="QHBoxLayout" name="horizontalLayout_17"> - <property name="spacing"> - <number>0</number> - </property> - <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> - <spacer name="controllerAppletVerticalSpacer2"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>25</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - </item> - </layout> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QWidget" name="bottomControllerApplet" native="true"> - <layout class="QHBoxLayout" name="horizontalLayout_6"> - <property name="spacing"> - <number>15</number> - </property> - <property name="leftMargin"> - <number>15</number> - </property> - <property name="topMargin"> - <number>8</number> - </property> - <property name="rightMargin"> - <number>15</number> - </property> - <property name="bottomMargin"> - <number>15</number> - </property> - <item> - <widget class="QGroupBox" name="handheldGroup"> - <property name="maximumSize"> - <size> - <width>16777215</width> - <height>16777215</height> - </size> - </property> - <property name="title"> - <string>Console Mode</string> - </property> - <layout class="QHBoxLayout" name="horizontalLayout_3"> - <property name="spacing"> - <number>6</number> - </property> - <property name="leftMargin"> - <number>8</number> - </property> - <property name="topMargin"> - <number>6</number> - </property> - <property name="rightMargin"> - <number>3</number> - </property> - <property name="bottomMargin"> - <number>6</number> - </property> - <item> - <widget class="QRadioButton" name="radioDocked"> - <property name="text"> - <string>Docked</string> - </property> - <property name="checked"> - <bool>true</bool> - </property> - </widget> - </item> - <item> - <widget class="QRadioButton" name="radioUndocked"> - <property name="text"> - <string>Handheld</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QGroupBox" name="vibrationGroup"> - <property name="title"> - <string>Vibration</string> - </property> - <property name="checkable"> - <bool>true</bool> - </property> - <layout class="QHBoxLayout" name="horizontalLayout_5"> - <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="vibrationButton"> - <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>Configure</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QGroupBox" name="motionGroup"> - <property name="title"> - <string>Motion</string> - </property> - <property name="checkable"> - <bool>true</bool> - </property> - <layout class="QHBoxLayout" name="horizontalLayout_4"> - <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="motionButton"> - <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>Configure</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QGroupBox" name="inputConfigGroup"> - <property name="title"> - <string>Profiles</string> - </property> - <layout class="QHBoxLayout" name="horizontalLayout_7"> - <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="inputConfigButton"> - <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>Create</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QWidget" name="connectedControllers" native="true"> - <layout class="QGridLayout" name="gridLayout_2"> - <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> - <property name="spacing"> - <number>3</number> - </property> - <item row="1" column="4"> - <widget class="QCheckBox" name="checkboxPlayer4Connected"> - <property name="text"> - <string/> - </property> - </widget> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="labelControllers"> - <property name="text"> - <string>Controllers</string> - </property> - </widget> - </item> - <item row="1" column="2"> - <widget class="QCheckBox" name="checkboxPlayer2Connected"> - <property name="text"> - <string/> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QLabel" name="labelConnectedPlayer1"> - <property name="text"> - <string>1</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - </widget> - </item> - <item row="1" column="3"> - <widget class="QCheckBox" name="checkboxPlayer3Connected"> - <property name="text"> - <string/> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QCheckBox" name="checkboxPlayer1Connected"> - <property name="layoutDirection"> - <enum>Qt::LeftToRight</enum> - </property> - <property name="checked"> - <bool>false</bool> - </property> - </widget> - </item> - <item row="0" column="2"> - <widget class="QLabel" name="labelConnectedPlayer2"> - <property name="text"> - <string>2</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - </widget> - </item> - <item row="0" column="4"> - <widget class="QLabel" name="labelConnectedPlayer4"> - <property name="text"> - <string>4</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - </widget> - </item> - <item row="0" column="3"> - <widget class="QLabel" name="labelConnectedPlayer3"> - <property name="text"> - <string>3</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - </widget> - </item> - <item row="0" column="0"> - <widget class="QLabel" name="labelConnected"> - <property name="text"> - <string>Connected</string> - </property> - </widget> - </item> - <item row="1" column="7"> - <widget class="QCheckBox" name="checkboxPlayer7Connected"> - <property name="text"> - <string/> - </property> - </widget> - </item> - <item row="0" column="5"> - <widget class="QLabel" name="labelConnectedPlayer5"> - <property name="text"> - <string>5</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - </widget> - </item> - <item row="1" column="6"> - <widget class="QCheckBox" name="checkboxPlayer6Connected"> - <property name="text"> - <string/> - </property> - </widget> - </item> - <item row="0" column="7"> - <widget class="QLabel" name="labelConnectedPlayer7"> - <property name="text"> - <string>7</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - </widget> - </item> - <item row="1" column="5"> - <widget class="QCheckBox" name="checkboxPlayer5Connected"> - <property name="text"> - <string/> - </property> - </widget> - </item> - <item row="0" column="6"> - <widget class="QLabel" name="labelConnectedPlayer6"> - <property name="text"> - <string>6</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - </widget> - </item> - <item row="0" column="8"> - <widget class="QLabel" name="labelConnectedPlayer8"> - <property name="text"> - <string>8</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - </widget> - </item> - <item row="1" column="8"> - <widget class="QCheckBox" name="checkboxPlayer8Connected"> - <property name="text"> - <string/> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <spacer name="controllerAppletHorizontalSpacer"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>0</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item alignment="Qt::AlignBottom"> - <widget class="QWidget" name="closeButtons" native="true"> - <layout class="QVBoxLayout" name="verticalLayout_46"> - <property name="spacing"> - <number>7</number> - </property> - <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="labelError"> - <property name="enabled"> - <bool>true</bool> - </property> - <property name="styleSheet"> - <string notr="true">QLabel { color : red; }</string> - </property> - <property name="text"> - <string>Not enough controllers</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - <property name="margin"> - <number>0</number> - </property> - </widget> - </item> - <item> - <widget class="QDialogButtonBox" name="buttonBox"> - <property name="enabled"> - <bool>true</bool> - </property> - <property name="standardButtons"> - <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> - </property> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - <resources/> - <connections> - <connection> - <sender>buttonBox</sender> - <signal>accepted()</signal> - <receiver>QtControllerSelectorDialog</receiver> - <slot>accept()</slot> - </connection> - <connection> - <sender>buttonBox</sender> - <signal>rejected()</signal> - <receiver>QtControllerSelectorDialog</receiver> - <slot>reject()</slot> - </connection> - </connections> -</ui> diff --git a/src/yuzu/applets/qt_error.cpp b/src/yuzu/applets/qt_error.cpp deleted file mode 100644 index ad35f4126..000000000 --- a/src/yuzu/applets/qt_error.cpp +++ /dev/null @@ -1,68 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include <QDateTime> -#include "yuzu/applets/qt_error.h" -#include "yuzu/main.h" - -QtErrorDisplay::QtErrorDisplay(GMainWindow& parent) { - connect(this, &QtErrorDisplay::MainWindowDisplayError, &parent, - &GMainWindow::ErrorDisplayDisplayError, Qt::QueuedConnection); - connect(this, &QtErrorDisplay::MainWindowRequestExit, &parent, - &GMainWindow::ErrorDisplayRequestExit, Qt::QueuedConnection); - connect(&parent, &GMainWindow::ErrorDisplayFinished, this, - &QtErrorDisplay::MainWindowFinishedError, Qt::DirectConnection); -} - -QtErrorDisplay::~QtErrorDisplay() = default; - -void QtErrorDisplay::Close() const { - callback = {}; - emit MainWindowRequestExit(); -} - -void QtErrorDisplay::ShowError(Result error, FinishedCallback finished) const { - callback = std::move(finished); - emit MainWindowDisplayError( - tr("Error Code: %1-%2 (0x%3)") - .arg(static_cast<u32>(error.GetModule()) + 2000, 4, 10, QChar::fromLatin1('0')) - .arg(error.GetDescription(), 4, 10, QChar::fromLatin1('0')) - .arg(error.raw, 8, 16, QChar::fromLatin1('0')), - tr("An error has occurred.\nPlease try again or contact the developer of the software.")); -} - -void QtErrorDisplay::ShowErrorWithTimestamp(Result error, std::chrono::seconds time, - FinishedCallback finished) const { - callback = std::move(finished); - - const QDateTime date_time = QDateTime::fromSecsSinceEpoch(time.count()); - emit MainWindowDisplayError( - tr("Error Code: %1-%2 (0x%3)") - .arg(static_cast<u32>(error.GetModule()) + 2000, 4, 10, QChar::fromLatin1('0')) - .arg(error.GetDescription(), 4, 10, QChar::fromLatin1('0')) - .arg(error.raw, 8, 16, QChar::fromLatin1('0')), - tr("An error occurred on %1 at %2.\nPlease try again or contact the developer of the " - "software.") - .arg(date_time.toString(QStringLiteral("dddd, MMMM d, yyyy"))) - .arg(date_time.toString(QStringLiteral("h:mm:ss A")))); -} - -void QtErrorDisplay::ShowCustomErrorText(Result error, std::string dialog_text, - std::string fullscreen_text, - FinishedCallback finished) const { - callback = std::move(finished); - emit MainWindowDisplayError( - tr("Error Code: %1-%2 (0x%3)") - .arg(static_cast<u32>(error.GetModule()) + 2000, 4, 10, QChar::fromLatin1('0')) - .arg(error.GetDescription(), 4, 10, QChar::fromLatin1('0')) - .arg(error.raw, 8, 16, QChar::fromLatin1('0')), - tr("An error has occurred.\n\n%1\n\n%2") - .arg(QString::fromStdString(dialog_text)) - .arg(QString::fromStdString(fullscreen_text))); -} - -void QtErrorDisplay::MainWindowFinishedError() { - if (callback) { - callback(); - } -} diff --git a/src/yuzu/applets/qt_error.h b/src/yuzu/applets/qt_error.h deleted file mode 100644 index 957f170ad..000000000 --- a/src/yuzu/applets/qt_error.h +++ /dev/null @@ -1,34 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include <QObject> - -#include "core/frontend/applets/error.h" - -class GMainWindow; - -class QtErrorDisplay final : public QObject, public Core::Frontend::ErrorApplet { - Q_OBJECT - -public: - explicit QtErrorDisplay(GMainWindow& parent); - ~QtErrorDisplay() override; - - void Close() const override; - void ShowError(Result error, FinishedCallback finished) const override; - void ShowErrorWithTimestamp(Result error, std::chrono::seconds time, - FinishedCallback finished) const override; - void ShowCustomErrorText(Result error, std::string dialog_text, std::string fullscreen_text, - FinishedCallback finished) const override; - -signals: - void MainWindowDisplayError(QString error_code, QString error_text) const; - void MainWindowRequestExit() const; - -private: - void MainWindowFinishedError(); - - mutable FinishedCallback callback; -}; diff --git a/src/yuzu/applets/qt_profile_select.cpp b/src/yuzu/applets/qt_profile_select.cpp deleted file mode 100644 index 66edd6acd..000000000 --- a/src/yuzu/applets/qt_profile_select.cpp +++ /dev/null @@ -1,260 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include <mutex> -#include <QApplication> -#include <QDialogButtonBox> -#include <QHeaderView> -#include <QLabel> -#include <QLineEdit> -#include <QScrollArea> -#include <QStandardItemModel> -#include <QTreeView> -#include <QVBoxLayout> -#include "common/fs/path_util.h" -#include "common/string_util.h" -#include "core/constants.h" -#include "core/core.h" -#include "core/hle/service/acc/profile_manager.h" -#include "yuzu/applets/qt_profile_select.h" -#include "yuzu/main.h" -#include "yuzu/util/controller_navigation.h" - -namespace { -QString FormatUserEntryText(const QString& username, Common::UUID uuid) { - return QtProfileSelectionDialog::tr( - "%1\n%2", "%1 is the profile username, %2 is the formatted UUID (e.g. " - "00112233-4455-6677-8899-AABBCCDDEEFF))") - .arg(username, QString::fromStdString(uuid.FormattedString())); -} - -QString GetImagePath(Common::UUID uuid) { - const auto path = - Common::FS::GetYuzuPath(Common::FS::YuzuPath::NANDDir) / - fmt::format("system/save/8000000000000010/su/avators/{}.jpg", uuid.FormattedString()); - return QString::fromStdString(Common::FS::PathToUTF8String(path)); -} - -QPixmap GetIcon(Common::UUID uuid) { - QPixmap icon{GetImagePath(uuid)}; - - if (!icon) { - icon.fill(Qt::black); - icon.loadFromData(Core::Constants::ACCOUNT_BACKUP_JPEG.data(), - static_cast<u32>(Core::Constants::ACCOUNT_BACKUP_JPEG.size())); - } - - return icon.scaled(64, 64, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); -} -} // Anonymous namespace - -QtProfileSelectionDialog::QtProfileSelectionDialog( - Core::System& system, QWidget* parent, - const Core::Frontend::ProfileSelectParameters& parameters) - : QDialog(parent), profile_manager{system.GetProfileManager()} { - outer_layout = new QVBoxLayout; - - instruction_label = new QLabel(); - - scroll_area = new QScrollArea; - - buttons = new QDialogButtonBox(QDialogButtonBox::Cancel | QDialogButtonBox::Ok); - connect(buttons, &QDialogButtonBox::accepted, this, &QtProfileSelectionDialog::accept); - connect(buttons, &QDialogButtonBox::rejected, this, &QtProfileSelectionDialog::reject); - - outer_layout->addWidget(instruction_label); - outer_layout->addWidget(scroll_area); - outer_layout->addWidget(buttons); - - layout = new QVBoxLayout; - tree_view = new QTreeView; - item_model = new QStandardItemModel(tree_view); - tree_view->setModel(item_model); - controller_navigation = new ControllerNavigation(system.HIDCore(), this); - - tree_view->setAlternatingRowColors(true); - tree_view->setSelectionMode(QHeaderView::SingleSelection); - tree_view->setSelectionBehavior(QHeaderView::SelectRows); - tree_view->setVerticalScrollMode(QHeaderView::ScrollPerPixel); - tree_view->setHorizontalScrollMode(QHeaderView::ScrollPerPixel); - tree_view->setSortingEnabled(true); - tree_view->setEditTriggers(QHeaderView::NoEditTriggers); - tree_view->setUniformRowHeights(true); - tree_view->setIconSize({64, 64}); - tree_view->setContextMenuPolicy(Qt::NoContextMenu); - - item_model->insertColumns(0, 1); - item_model->setHeaderData(0, Qt::Horizontal, tr("Users")); - - // 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*>"); - - layout->setContentsMargins(0, 0, 0, 0); - layout->setSpacing(0); - layout->addWidget(tree_view); - - scroll_area->setLayout(layout); - - connect(tree_view, &QTreeView::clicked, this, &QtProfileSelectionDialog::SelectUser); - connect(tree_view, &QTreeView::doubleClicked, this, &QtProfileSelectionDialog::accept); - connect(controller_navigation, &ControllerNavigation::TriggerKeyboardEvent, - [this](Qt::Key key) { - if (!this->isActiveWindow()) { - return; - } - QKeyEvent* event = new QKeyEvent(QEvent::KeyPress, key, Qt::NoModifier); - QCoreApplication::postEvent(tree_view, event); - SelectUser(tree_view->currentIndex()); - }); - - const auto& profiles = profile_manager.GetAllUsers(); - for (const auto& user : profiles) { - Service::Account::ProfileBase profile{}; - if (!profile_manager.GetProfileBase(user, profile)) - continue; - - const auto username = Common::StringFromFixedZeroTerminatedBuffer( - reinterpret_cast<const char*>(profile.username.data()), profile.username.size()); - - list_items.push_back(QList<QStandardItem*>{new QStandardItem{ - GetIcon(user), FormatUserEntryText(QString::fromStdString(username), user)}}); - } - - for (const auto& item : list_items) - item_model->appendRow(item); - - setLayout(outer_layout); - SetWindowTitle(parameters); - SetDialogPurpose(parameters); - resize(550, 400); -} - -QtProfileSelectionDialog::~QtProfileSelectionDialog() { - controller_navigation->UnloadController(); -}; - -int QtProfileSelectionDialog::exec() { - // Skip profile selection when there's only one. - if (profile_manager.GetUserCount() == 1) { - user_index = 0; - return QDialog::Accepted; - } - return QDialog::exec(); -} - -void QtProfileSelectionDialog::accept() { - QDialog::accept(); -} - -void QtProfileSelectionDialog::reject() { - user_index = 0; - QDialog::reject(); -} - -int QtProfileSelectionDialog::GetIndex() const { - return user_index; -} - -void QtProfileSelectionDialog::SelectUser(const QModelIndex& index) { - user_index = index.row(); -} - -void QtProfileSelectionDialog::SetWindowTitle( - const Core::Frontend::ProfileSelectParameters& parameters) { - using Service::AM::Frontend::UiMode; - switch (parameters.mode) { - case UiMode::UserCreator: - case UiMode::UserCreatorForStarter: - setWindowTitle(tr("Profile Creator")); - return; - case UiMode::EnsureNetworkServiceAccountAvailable: - setWindowTitle(tr("Profile Selector")); - return; - case UiMode::UserIconEditor: - setWindowTitle(tr("Profile Icon Editor")); - return; - case UiMode::UserNicknameEditor: - setWindowTitle(tr("Profile Nickname Editor")); - return; - case UiMode::NintendoAccountAuthorizationRequestContext: - case UiMode::IntroduceExternalNetworkServiceAccount: - case UiMode::IntroduceExternalNetworkServiceAccountForRegistration: - case UiMode::NintendoAccountNnidLinker: - case UiMode::LicenseRequirementsForNetworkService: - case UiMode::LicenseRequirementsForNetworkServiceWithUserContextImpl: - case UiMode::UserCreatorForImmediateNaLoginTest: - case UiMode::UserQualificationPromoter: - case UiMode::UserSelector: - default: - setWindowTitle(tr("Profile Selector")); - } -} - -void QtProfileSelectionDialog::SetDialogPurpose( - const Core::Frontend::ProfileSelectParameters& parameters) { - using Service::AM::Frontend::UserSelectionPurpose; - - switch (parameters.purpose) { - case UserSelectionPurpose::GameCardRegistration: - instruction_label->setText(tr("Who will receive the points?")); - return; - case UserSelectionPurpose::EShopLaunch: - instruction_label->setText(tr("Who is using Nintendo eShop?")); - return; - case UserSelectionPurpose::EShopItemShow: - instruction_label->setText(tr("Who is making this purchase?")); - return; - case UserSelectionPurpose::PicturePost: - instruction_label->setText(tr("Who is posting?")); - return; - case UserSelectionPurpose::NintendoAccountLinkage: - instruction_label->setText(tr("Select a user to link to a Nintendo Account.")); - return; - case UserSelectionPurpose::SettingsUpdate: - instruction_label->setText(tr("Change settings for which user?")); - return; - case UserSelectionPurpose::SaveDataDeletion: - instruction_label->setText(tr("Format data for which user?")); - return; - case UserSelectionPurpose::UserMigration: - instruction_label->setText(tr("Which user will be transferred to another console?")); - return; - case UserSelectionPurpose::SaveDataTransfer: - instruction_label->setText(tr("Send save data for which user?")); - return; - case UserSelectionPurpose::General: - default: - instruction_label->setText(tr("Select a user:")); - return; - } -} - -QtProfileSelector::QtProfileSelector(GMainWindow& parent) { - connect(this, &QtProfileSelector::MainWindowSelectProfile, &parent, - &GMainWindow::ProfileSelectorSelectProfile, Qt::QueuedConnection); - connect(this, &QtProfileSelector::MainWindowRequestExit, &parent, - &GMainWindow::ProfileSelectorRequestExit, Qt::QueuedConnection); - connect(&parent, &GMainWindow::ProfileSelectorFinishedSelection, this, - &QtProfileSelector::MainWindowFinishedSelection, Qt::DirectConnection); -} - -QtProfileSelector::~QtProfileSelector() = default; - -void QtProfileSelector::Close() const { - callback = {}; - emit MainWindowRequestExit(); -} - -void QtProfileSelector::SelectProfile( - SelectProfileCallback callback_, - const Core::Frontend::ProfileSelectParameters& parameters) const { - callback = std::move(callback_); - emit MainWindowSelectProfile(parameters); -} - -void QtProfileSelector::MainWindowFinishedSelection(std::optional<Common::UUID> uuid) { - if (callback) { - callback(uuid); - } -} diff --git a/src/yuzu/applets/qt_profile_select.h b/src/yuzu/applets/qt_profile_select.h deleted file mode 100644 index 607f1777c..000000000 --- a/src/yuzu/applets/qt_profile_select.h +++ /dev/null @@ -1,87 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include <vector> -#include <QDialog> -#include <QList> -#include "core/frontend/applets/profile_select.h" - -class ControllerNavigation; -class GMainWindow; -class QDialogButtonBox; -class QGraphicsScene; -class QLabel; -class QScrollArea; -class QStandardItem; -class QStandardItemModel; -class QTreeView; -class QVBoxLayout; - -namespace Core { -class System; -} - -namespace Service::Account { -class ProfileManager; -} - -class QtProfileSelectionDialog final : public QDialog { - Q_OBJECT - -public: - explicit QtProfileSelectionDialog(Core::System& system, QWidget* parent, - const Core::Frontend::ProfileSelectParameters& parameters); - ~QtProfileSelectionDialog() override; - - int exec() override; - void accept() override; - void reject() override; - - int GetIndex() const; - -private: - void SelectUser(const QModelIndex& index); - - void SetWindowTitle(const Core::Frontend::ProfileSelectParameters& parameters); - void SetDialogPurpose(const Core::Frontend::ProfileSelectParameters& parameters); - - int user_index = 0; - - QVBoxLayout* layout; - QTreeView* tree_view; - QStandardItemModel* item_model; - QGraphicsScene* scene; - - std::vector<QList<QStandardItem*>> list_items; - - QVBoxLayout* outer_layout; - QLabel* instruction_label; - QScrollArea* scroll_area; - QDialogButtonBox* buttons; - - Service::Account::ProfileManager& profile_manager; - ControllerNavigation* controller_navigation = nullptr; -}; - -class QtProfileSelector final : public QObject, public Core::Frontend::ProfileSelectApplet { - Q_OBJECT - -public: - explicit QtProfileSelector(GMainWindow& parent); - ~QtProfileSelector() override; - - void Close() const override; - void SelectProfile(SelectProfileCallback callback_, - const Core::Frontend::ProfileSelectParameters& parameters) const override; - -signals: - void MainWindowSelectProfile(const Core::Frontend::ProfileSelectParameters& parameters) const; - void MainWindowRequestExit() const; - -private: - void MainWindowFinishedSelection(std::optional<Common::UUID> uuid); - - mutable SelectProfileCallback callback; -}; diff --git a/src/yuzu/applets/qt_software_keyboard.cpp b/src/yuzu/applets/qt_software_keyboard.cpp deleted file mode 100644 index 2749e6ed3..000000000 --- a/src/yuzu/applets/qt_software_keyboard.cpp +++ /dev/null @@ -1,1674 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include <QCursor> -#include <QKeyEvent> -#include <QScreen> - -#include "common/logging/log.h" -#include "common/settings.h" -#include "common/string_util.h" -#include "core/core.h" -#include "hid_core/frontend/emulated_controller.h" -#include "hid_core/frontend/input_interpreter.h" -#include "hid_core/hid_core.h" -#include "hid_core/hid_types.h" -#include "ui_qt_software_keyboard.h" -#include "yuzu/applets/qt_software_keyboard.h" -#include "yuzu/main.h" -#include "yuzu/util/overlay_dialog.h" - -namespace { - -using namespace Service::AM::Frontend; - -constexpr float BASE_HEADER_FONT_SIZE = 23.0f; -constexpr float BASE_SUB_FONT_SIZE = 17.0f; -constexpr float BASE_EDITOR_FONT_SIZE = 26.0f; -constexpr float BASE_CHAR_BUTTON_FONT_SIZE = 28.0f; -constexpr float BASE_LABEL_BUTTON_FONT_SIZE = 18.0f; -constexpr float BASE_ICON_BUTTON_SIZE = 36.0f; -[[maybe_unused]] constexpr float BASE_WIDTH = 1280.0f; -constexpr float BASE_HEIGHT = 720.0f; - -} // Anonymous namespace - -QtSoftwareKeyboardDialog::QtSoftwareKeyboardDialog( - QWidget* parent, Core::System& system_, bool is_inline_, - Core::Frontend::KeyboardInitializeParameters initialize_parameters_) - : QDialog(parent), ui{std::make_unique<Ui::QtSoftwareKeyboardDialog>()}, system{system_}, - is_inline{is_inline_}, initialize_parameters{std::move(initialize_parameters_)} { - ui->setupUi(this); - - setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint | Qt::WindowTitleHint | - Qt::WindowSystemMenuHint | Qt::CustomizeWindowHint); - setWindowModality(Qt::WindowModal); - setAttribute(Qt::WA_DeleteOnClose); - setAttribute(Qt::WA_TranslucentBackground); - - keyboard_buttons = {{ - {{ - { - ui->button_1, - ui->button_2, - ui->button_3, - ui->button_4, - ui->button_5, - ui->button_6, - ui->button_7, - ui->button_8, - ui->button_9, - ui->button_0, - ui->button_minus, - ui->button_backspace, - }, - { - ui->button_q, - ui->button_w, - ui->button_e, - ui->button_r, - ui->button_t, - ui->button_y, - ui->button_u, - ui->button_i, - ui->button_o, - ui->button_p, - ui->button_slash, - ui->button_return, - }, - { - ui->button_a, - ui->button_s, - ui->button_d, - ui->button_f, - ui->button_g, - ui->button_h, - ui->button_j, - ui->button_k, - ui->button_l, - ui->button_colon, - ui->button_apostrophe, - ui->button_return, - }, - { - ui->button_z, - ui->button_x, - ui->button_c, - ui->button_v, - ui->button_b, - ui->button_n, - ui->button_m, - ui->button_comma, - ui->button_dot, - ui->button_question, - ui->button_exclamation, - ui->button_ok, - }, - { - ui->button_shift, - ui->button_shift, - ui->button_space, - ui->button_space, - ui->button_space, - ui->button_space, - ui->button_space, - ui->button_space, - ui->button_space, - ui->button_space, - ui->button_space, - ui->button_ok, - }, - }}, - {{ - { - ui->button_hash, - ui->button_left_bracket, - ui->button_right_bracket, - ui->button_dollar, - ui->button_percent, - ui->button_circumflex, - ui->button_ampersand, - ui->button_asterisk, - ui->button_left_parenthesis, - ui->button_right_parenthesis, - ui->button_underscore, - ui->button_backspace_shift, - }, - { - ui->button_q_shift, - ui->button_w_shift, - ui->button_e_shift, - ui->button_r_shift, - ui->button_t_shift, - ui->button_y_shift, - ui->button_u_shift, - ui->button_i_shift, - ui->button_o_shift, - ui->button_p_shift, - ui->button_at, - ui->button_return_shift, - }, - { - ui->button_a_shift, - ui->button_s_shift, - ui->button_d_shift, - ui->button_f_shift, - ui->button_g_shift, - ui->button_h_shift, - ui->button_j_shift, - ui->button_k_shift, - ui->button_l_shift, - ui->button_semicolon, - ui->button_quotation, - ui->button_return_shift, - }, - { - ui->button_z_shift, - ui->button_x_shift, - ui->button_c_shift, - ui->button_v_shift, - ui->button_b_shift, - ui->button_n_shift, - ui->button_m_shift, - ui->button_less_than, - ui->button_greater_than, - ui->button_plus, - ui->button_equal, - ui->button_ok_shift, - }, - { - ui->button_shift_shift, - ui->button_shift_shift, - ui->button_space_shift, - ui->button_space_shift, - ui->button_space_shift, - ui->button_space_shift, - ui->button_space_shift, - ui->button_space_shift, - ui->button_space_shift, - ui->button_space_shift, - ui->button_space_shift, - ui->button_ok_shift, - }, - }}, - }}; - - numberpad_buttons = {{ - { - ui->button_1_num, - ui->button_2_num, - ui->button_3_num, - ui->button_backspace_num, - }, - { - ui->button_4_num, - ui->button_5_num, - ui->button_6_num, - ui->button_ok_num, - }, - { - ui->button_7_num, - ui->button_8_num, - ui->button_9_num, - ui->button_ok_num, - }, - { - ui->button_left_optional_num, - ui->button_0_num, - ui->button_right_optional_num, - ui->button_ok_num, - }, - }}; - - all_buttons = { - ui->button_1, - ui->button_2, - ui->button_3, - ui->button_4, - ui->button_5, - ui->button_6, - ui->button_7, - ui->button_8, - ui->button_9, - ui->button_0, - ui->button_minus, - ui->button_backspace, - ui->button_q, - ui->button_w, - ui->button_e, - ui->button_r, - ui->button_t, - ui->button_y, - ui->button_u, - ui->button_i, - ui->button_o, - ui->button_p, - ui->button_slash, - ui->button_return, - ui->button_a, - ui->button_s, - ui->button_d, - ui->button_f, - ui->button_g, - ui->button_h, - ui->button_j, - ui->button_k, - ui->button_l, - ui->button_colon, - ui->button_apostrophe, - ui->button_z, - ui->button_x, - ui->button_c, - ui->button_v, - ui->button_b, - ui->button_n, - ui->button_m, - ui->button_comma, - ui->button_dot, - ui->button_question, - ui->button_exclamation, - ui->button_ok, - ui->button_shift, - ui->button_space, - ui->button_hash, - ui->button_left_bracket, - ui->button_right_bracket, - ui->button_dollar, - ui->button_percent, - ui->button_circumflex, - ui->button_ampersand, - ui->button_asterisk, - ui->button_left_parenthesis, - ui->button_right_parenthesis, - ui->button_underscore, - ui->button_backspace_shift, - ui->button_q_shift, - ui->button_w_shift, - ui->button_e_shift, - ui->button_r_shift, - ui->button_t_shift, - ui->button_y_shift, - ui->button_u_shift, - ui->button_i_shift, - ui->button_o_shift, - ui->button_p_shift, - ui->button_at, - ui->button_return_shift, - ui->button_a_shift, - ui->button_s_shift, - ui->button_d_shift, - ui->button_f_shift, - ui->button_g_shift, - ui->button_h_shift, - ui->button_j_shift, - ui->button_k_shift, - ui->button_l_shift, - ui->button_semicolon, - ui->button_quotation, - ui->button_z_shift, - ui->button_x_shift, - ui->button_c_shift, - ui->button_v_shift, - ui->button_b_shift, - ui->button_n_shift, - ui->button_m_shift, - ui->button_less_than, - ui->button_greater_than, - ui->button_plus, - ui->button_equal, - ui->button_ok_shift, - ui->button_shift_shift, - ui->button_space_shift, - ui->button_1_num, - ui->button_2_num, - ui->button_3_num, - ui->button_backspace_num, - ui->button_4_num, - ui->button_5_num, - ui->button_6_num, - ui->button_ok_num, - 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(); - - if (!initialize_parameters.ok_text.empty()) { - ui->button_ok->setText(QString::fromStdU16String(initialize_parameters.ok_text)); - } - - 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; - - SetTextDrawType(); - - for (auto* button : all_buttons) { - connect(button, &QPushButton::clicked, this, [this, button](bool) { - if (is_inline) { - InlineKeyboardButtonClicked(button); - } else { - NormalKeyboardButtonClicked(button); - } - }); - } - - // TODO (Morph): Remove this when InputInterpreter no longer relies on the HID backend - if (system.IsPoweredOn()) { - input_interpreter = std::make_unique<InputInterpreter>(system); - } -} - -QtSoftwareKeyboardDialog::~QtSoftwareKeyboardDialog() { - StopInputThread(); -} - -void QtSoftwareKeyboardDialog::ShowNormalKeyboard(QPoint pos, QSize size) { - if (isVisible()) { - return; - } - - MoveAndResizeWindow(pos, size); - - SetKeyboardType(); - SetPasswordMode(); - SetControllerImage(); - DisableKeyboardButtons(); - SetBackspaceOkEnabled(); - - open(); -} - -void QtSoftwareKeyboardDialog::ShowTextCheckDialog( - Service::AM::Frontend::SwkbdTextCheckResult text_check_result, - std::u16string text_check_message) { - switch (text_check_result) { - case SwkbdTextCheckResult::Success: - case SwkbdTextCheckResult::Silent: - default: - break; - case SwkbdTextCheckResult::Failure: { - StopInputThread(); - - OverlayDialog dialog(this, system, QString{}, QString::fromStdU16String(text_check_message), - QString{}, tr("OK"), Qt::AlignCenter); - dialog.exec(); - - StartInputThread(); - break; - } - case SwkbdTextCheckResult::Confirm: { - StopInputThread(); - - OverlayDialog dialog(this, system, QString{}, QString::fromStdU16String(text_check_message), - tr("Cancel"), tr("OK"), Qt::AlignCenter); - if (dialog.exec() != QDialog::Accepted) { - StartInputThread(); - break; - } - - 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_str), true); - break; - } - } -} - -void QtSoftwareKeyboardDialog::ShowInlineKeyboard( - Core::Frontend::InlineAppearParameters appear_parameters, QPoint pos, QSize size) { - MoveAndResizeWindow(pos, size); - - ui->topOSK->setStyleSheet(QStringLiteral("background: rgba(0, 0, 0, 0);")); - - ui->headerOSK->hide(); - ui->subOSK->hide(); - ui->inputOSK->hide(); - ui->charactersOSK->hide(); - ui->inputBoxOSK->hide(); - ui->charactersBoxOSK->hide(); - - initialize_parameters.max_text_length = appear_parameters.max_text_length; - initialize_parameters.min_text_length = appear_parameters.min_text_length; - initialize_parameters.type = appear_parameters.type; - initialize_parameters.key_disable_flags = appear_parameters.key_disable_flags; - initialize_parameters.enable_backspace_button = appear_parameters.enable_backspace_button; - initialize_parameters.enable_return_button = appear_parameters.enable_return_button; - initialize_parameters.disable_cancel_button = appear_parameters.disable_cancel_button; - - SetKeyboardType(); - SetControllerImage(); - DisableKeyboardButtons(); - SetBackspaceOkEnabled(); - - open(); -} - -void QtSoftwareKeyboardDialog::HideInlineKeyboard() { - StopInputThread(); - QDialog::hide(); -} - -void QtSoftwareKeyboardDialog::InlineTextChanged( - Core::Frontend::InlineTextParameters text_parameters) { - current_text = text_parameters.input_text; - cursor_position = text_parameters.cursor_position; - - SetBackspaceOkEnabled(); -} - -void QtSoftwareKeyboardDialog::ExitKeyboard() { - StopInputThread(); - QDialog::done(QDialog::Accepted); -} - -void QtSoftwareKeyboardDialog::open() { - QDialog::open(); - - row = 0; - column = 0; - - switch (bottom_osk_index) { - case BottomOSKIndex::LowerCase: - case BottomOSKIndex::UpperCase: { - const auto* const curr_button = - keyboard_buttons[static_cast<std::size_t>(bottom_osk_index)][row][column]; - - // This is a workaround for setFocus() randomly not showing focus in the UI - QCursor::setPos(curr_button->mapToGlobal(curr_button->rect().center())); - break; - } - case BottomOSKIndex::NumberPad: { - const auto* const curr_button = numberpad_buttons[row][column]; - - // This is a workaround for setFocus() randomly not showing focus in the UI - QCursor::setPos(curr_button->mapToGlobal(curr_button->rect().center())); - break; - } - default: - break; - } - - StartInputThread(); -} - -void QtSoftwareKeyboardDialog::reject() { - // Pressing the ESC key in a dialog calls QDialog::reject(). - // We will override this behavior to the "Cancel" action on the software keyboard. - TranslateButtonPress(Core::HID::NpadButton::X); -} - -void QtSoftwareKeyboardDialog::keyPressEvent(QKeyEvent* event) { - if (!is_inline) { - QDialog::keyPressEvent(event); - return; - } - - const auto entered_key = event->key(); - - switch (entered_key) { - case Qt::Key_Escape: - QDialog::keyPressEvent(event); - return; - case Qt::Key_Backspace: - switch (bottom_osk_index) { - case BottomOSKIndex::LowerCase: - ui->button_backspace->click(); - break; - case BottomOSKIndex::UpperCase: - ui->button_backspace_shift->click(); - break; - case BottomOSKIndex::NumberPad: - ui->button_backspace_num->click(); - break; - default: - break; - } - return; - case Qt::Key_Return: - switch (bottom_osk_index) { - case BottomOSKIndex::LowerCase: - ui->button_ok->click(); - break; - case BottomOSKIndex::UpperCase: - ui->button_ok_shift->click(); - break; - case BottomOSKIndex::NumberPad: - ui->button_ok_num->click(); - break; - default: - break; - } - return; - case Qt::Key_Left: - MoveTextCursorDirection(Direction::Left); - return; - case Qt::Key_Right: - MoveTextCursorDirection(Direction::Right); - return; - default: - break; - } - - const auto entered_text = event->text(); - - if (entered_text.isEmpty()) { - return; - } - - InlineTextInsertString(Common::U16StringFromBuffer(entered_text.utf16(), entered_text.size())); -} - -void QtSoftwareKeyboardDialog::MoveAndResizeWindow(QPoint pos, QSize size) { - QDialog::move(pos); - QDialog::resize(size); - - // High DPI - const float dpi_scale = screen()->logicalDotsPerInch() / 96.0f; - - RescaleKeyboardElements(size.width(), size.height(), dpi_scale); -} - -void QtSoftwareKeyboardDialog::RescaleKeyboardElements(float width, float height, float dpi_scale) { - const auto header_font_size = BASE_HEADER_FONT_SIZE * (height / BASE_HEIGHT) / dpi_scale; - const auto sub_font_size = BASE_SUB_FONT_SIZE * (height / BASE_HEIGHT) / dpi_scale; - const auto editor_font_size = BASE_EDITOR_FONT_SIZE * (height / BASE_HEIGHT) / dpi_scale; - const auto char_button_font_size = - BASE_CHAR_BUTTON_FONT_SIZE * (height / BASE_HEIGHT) / dpi_scale; - const auto label_button_font_size = - BASE_LABEL_BUTTON_FONT_SIZE * (height / BASE_HEIGHT) / dpi_scale; - - QFont header_font(QStringLiteral("MS Shell Dlg 2"), header_font_size, QFont::Normal); - QFont sub_font(QStringLiteral("MS Shell Dlg 2"), sub_font_size, QFont::Normal); - QFont editor_font(QStringLiteral("MS Shell Dlg 2"), editor_font_size, QFont::Normal); - QFont char_button_font(QStringLiteral("MS Shell Dlg 2"), char_button_font_size, QFont::Normal); - QFont label_button_font(QStringLiteral("MS Shell Dlg 2"), label_button_font_size, - QFont::Normal); - - ui->label_header->setFont(header_font); - ui->label_sub->setFont(sub_font); - ui->line_edit_osk->setFont(editor_font); - ui->text_edit_osk->setFont(editor_font); - ui->label_characters->setFont(sub_font); - ui->label_characters_box->setFont(sub_font); - - ui->label_shift->setFont(label_button_font); - ui->label_shift_shift->setFont(label_button_font); - ui->label_cancel->setFont(label_button_font); - ui->label_cancel_shift->setFont(label_button_font); - ui->label_cancel_num->setFont(label_button_font); - ui->label_enter->setFont(label_button_font); - ui->label_enter_shift->setFont(label_button_font); - ui->label_enter_num->setFont(label_button_font); - - for (auto* button : all_buttons) { - if (button == ui->button_return || button == ui->button_return_shift) { - button->setFont(label_button_font); - continue; - } - - if (button == ui->button_space || button == ui->button_space_shift) { - button->setFont(label_button_font); - continue; - } - - if (button == ui->button_shift || button == ui->button_shift_shift) { - button->setFont(label_button_font); - button->setIconSize(QSize(BASE_ICON_BUTTON_SIZE, BASE_ICON_BUTTON_SIZE) * - (height / BASE_HEIGHT)); - continue; - } - - if (button == ui->button_backspace || button == ui->button_backspace_shift || - button == ui->button_backspace_num) { - button->setFont(label_button_font); - button->setIconSize(QSize(BASE_ICON_BUTTON_SIZE, BASE_ICON_BUTTON_SIZE) * - (height / BASE_HEIGHT)); - continue; - } - - if (button == ui->button_ok || button == ui->button_ok_shift || - button == ui->button_ok_num) { - button->setFont(label_button_font); - continue; - } - - button->setFont(char_button_font); - } -} - -void QtSoftwareKeyboardDialog::SetKeyboardType() { - switch (initialize_parameters.type) { - case SwkbdType::Normal: - case SwkbdType::Qwerty: - case SwkbdType::Unknown3: - case SwkbdType::Latin: - case SwkbdType::SimplifiedChinese: - case SwkbdType::TraditionalChinese: - case SwkbdType::Korean: - default: { - bottom_osk_index = BottomOSKIndex::LowerCase; - ui->bottomOSK->setCurrentIndex(static_cast<int>(bottom_osk_index)); - - ui->verticalLayout_2->setStretch(0, 320); - ui->verticalLayout_2->setStretch(1, 400); - - ui->gridLineOSK->setRowStretch(5, 94); - ui->gridBoxOSK->setRowStretch(2, 81); - break; - } - case SwkbdType::NumberPad: { - bottom_osk_index = BottomOSKIndex::NumberPad; - ui->bottomOSK->setCurrentIndex(static_cast<int>(bottom_osk_index)); - - ui->verticalLayout_2->setStretch(0, 370); - ui->verticalLayout_2->setStretch(1, 350); - - ui->gridLineOSK->setRowStretch(5, 144); - ui->gridBoxOSK->setRowStretch(2, 131); - break; - } - } -} - -void QtSoftwareKeyboardDialog::SetPasswordMode() { - switch (initialize_parameters.password_mode) { - case SwkbdPasswordMode::Disabled: - default: - ui->line_edit_osk->setEchoMode(QLineEdit::Normal); - break; - case SwkbdPasswordMode::Enabled: - ui->line_edit_osk->setEchoMode(QLineEdit::Password); - break; - } -} - -void QtSoftwareKeyboardDialog::SetTextDrawType() { - switch (initialize_parameters.text_draw_type) { - case SwkbdTextDrawType::Line: - case SwkbdTextDrawType::DownloadCode: { - ui->topOSK->setCurrentIndex(0); - - if (initialize_parameters.max_text_length <= 10) { - ui->gridLineOSK->setColumnStretch(0, 390); - ui->gridLineOSK->setColumnStretch(1, 500); - ui->gridLineOSK->setColumnStretch(2, 390); - } else { - ui->gridLineOSK->setColumnStretch(0, 130); - ui->gridLineOSK->setColumnStretch(1, 1020); - ui->gridLineOSK->setColumnStretch(2, 130); - } - - if (is_inline) { - return; - } - - connect(ui->line_edit_osk, &QLineEdit::textChanged, [this](const QString& changed_string) { - const auto is_valid = ValidateInputText(changed_string); - - const auto text_length = static_cast<u32>(changed_string.length()); - - ui->label_characters->setText(QStringLiteral("%1/%2") - .arg(text_length) - .arg(initialize_parameters.max_text_length)); - - ui->button_ok->setEnabled(is_valid); - ui->button_ok_shift->setEnabled(is_valid); - ui->button_ok_num->setEnabled(is_valid); - - ui->line_edit_osk->setFocus(); - }); - - connect(ui->line_edit_osk, &QLineEdit::cursorPositionChanged, - [this](int old_cursor_position, int new_cursor_position) { - ui->button_backspace->setEnabled( - initialize_parameters.enable_backspace_button && new_cursor_position > 0); - ui->button_backspace_shift->setEnabled( - initialize_parameters.enable_backspace_button && new_cursor_position > 0); - ui->button_backspace_num->setEnabled( - initialize_parameters.enable_backspace_button && new_cursor_position > 0); - - ui->line_edit_osk->setFocus(); - }); - - connect( - ui->line_edit_osk, &QLineEdit::returnPressed, this, - [this] { TranslateButtonPress(Core::HID::NpadButton::Plus); }, Qt::QueuedConnection); - - ui->line_edit_osk->setPlaceholderText( - QString::fromStdU16String(initialize_parameters.guide_text)); - ui->line_edit_osk->setText(QString::fromStdU16String(initialize_parameters.initial_text)); - ui->line_edit_osk->setMaxLength(initialize_parameters.max_text_length); - ui->line_edit_osk->setCursorPosition(initialize_parameters.initial_cursor_position); - - ui->label_characters->setText(QStringLiteral("%1/%2") - .arg(initialize_parameters.initial_text.size()) - .arg(initialize_parameters.max_text_length)); - break; - } - case SwkbdTextDrawType::Box: - default: { - ui->topOSK->setCurrentIndex(1); - - if (is_inline) { - return; - } - - connect(ui->text_edit_osk, &QTextEdit::textChanged, [this] { - if (static_cast<u32>(ui->text_edit_osk->toPlainText().length()) > - initialize_parameters.max_text_length) { - auto text_cursor = ui->text_edit_osk->textCursor(); - ui->text_edit_osk->setTextCursor(text_cursor); - text_cursor.deletePreviousChar(); - } - - const auto is_valid = ValidateInputText(ui->text_edit_osk->toPlainText()); - - const auto text_length = static_cast<u32>(ui->text_edit_osk->toPlainText().length()); - - ui->label_characters_box->setText(QStringLiteral("%1/%2") - .arg(text_length) - .arg(initialize_parameters.max_text_length)); - - ui->button_ok->setEnabled(is_valid); - ui->button_ok_shift->setEnabled(is_valid); - ui->button_ok_num->setEnabled(is_valid); - - ui->text_edit_osk->setFocus(); - }); - - connect(ui->text_edit_osk, &QTextEdit::cursorPositionChanged, [this] { - const auto new_cursor_position = ui->text_edit_osk->textCursor().position(); - - ui->button_backspace->setEnabled(initialize_parameters.enable_backspace_button && - new_cursor_position > 0); - ui->button_backspace_shift->setEnabled(initialize_parameters.enable_backspace_button && - new_cursor_position > 0); - ui->button_backspace_num->setEnabled(initialize_parameters.enable_backspace_button && - new_cursor_position > 0); - - ui->text_edit_osk->setFocus(); - }); - - ui->text_edit_osk->setPlaceholderText( - QString::fromStdU16String(initialize_parameters.guide_text)); - ui->text_edit_osk->setText(QString::fromStdU16String(initialize_parameters.initial_text)); - ui->text_edit_osk->moveCursor(initialize_parameters.initial_cursor_position == 0 - ? QTextCursor::Start - : QTextCursor::End); - - ui->label_characters_box->setText(QStringLiteral("%1/%2") - .arg(initialize_parameters.initial_text.size()) - .arg(initialize_parameters.max_text_length)); - break; - } - } -} - -void QtSoftwareKeyboardDialog::SetControllerImage() { - const auto* handheld = system.HIDCore().GetEmulatedController(Core::HID::NpadIdType::Handheld); - const auto* player_1 = system.HIDCore().GetEmulatedController(Core::HID::NpadIdType::Player1); - const auto controller_type = - handheld->IsConnected() ? handheld->GetNpadStyleIndex() : player_1->GetNpadStyleIndex(); - - const QString theme = [] { - if (QIcon::themeName().contains(QStringLiteral("dark")) || - QIcon::themeName().contains(QStringLiteral("midnight"))) { - return QStringLiteral("_dark"); - } else { - return QString{}; - } - }(); - - switch (controller_type) { - case Core::HID::NpadStyleIndex::Fullkey: - case Core::HID::NpadStyleIndex::GameCube: - ui->icon_controller->setStyleSheet( - QStringLiteral("image: url(:/overlay/controller_pro%1.png);").arg(theme)); - ui->icon_controller_shift->setStyleSheet( - QStringLiteral("image: url(:/overlay/controller_pro%1.png);").arg(theme)); - ui->icon_controller_num->setStyleSheet( - QStringLiteral("image: url(:/overlay/controller_pro%1.png);").arg(theme)); - break; - case Core::HID::NpadStyleIndex::JoyconDual: - ui->icon_controller->setStyleSheet( - QStringLiteral("image: url(:/overlay/controller_dual_joycon%1.png);").arg(theme)); - ui->icon_controller_shift->setStyleSheet( - QStringLiteral("image: url(:/overlay/controller_dual_joycon%1.png);").arg(theme)); - ui->icon_controller_num->setStyleSheet( - QStringLiteral("image: url(:/overlay/controller_dual_joycon%1.png);").arg(theme)); - break; - case Core::HID::NpadStyleIndex::JoyconLeft: - ui->icon_controller->setStyleSheet( - QStringLiteral("image: url(:/overlay/controller_single_joycon_left%1.png);") - .arg(theme)); - ui->icon_controller_shift->setStyleSheet( - QStringLiteral("image: url(:/overlay/controller_single_joycon_left%1.png);") - .arg(theme)); - ui->icon_controller_num->setStyleSheet( - QStringLiteral("image: url(:/overlay/controller_single_joycon_left%1.png);") - .arg(theme)); - break; - case Core::HID::NpadStyleIndex::JoyconRight: - ui->icon_controller->setStyleSheet( - QStringLiteral("image: url(:/overlay/controller_single_joycon_right%1.png);") - .arg(theme)); - ui->icon_controller_shift->setStyleSheet( - QStringLiteral("image: url(:/overlay/controller_single_joycon_right%1.png);") - .arg(theme)); - ui->icon_controller_num->setStyleSheet( - QStringLiteral("image: url(:/overlay/controller_single_joycon_right%1.png);") - .arg(theme)); - break; - case Core::HID::NpadStyleIndex::Handheld: - ui->icon_controller->setStyleSheet( - QStringLiteral("image: url(:/overlay/controller_handheld%1.png);").arg(theme)); - ui->icon_controller_shift->setStyleSheet( - QStringLiteral("image: url(:/overlay/controller_handheld%1.png);").arg(theme)); - ui->icon_controller_num->setStyleSheet( - QStringLiteral("image: url(:/overlay/controller_handheld%1.png);").arg(theme)); - break; - default: - break; - } -} - -void QtSoftwareKeyboardDialog::DisableKeyboardButtons() { - switch (bottom_osk_index) { - case BottomOSKIndex::LowerCase: - case BottomOSKIndex::UpperCase: - default: { - for (const auto& keys : keyboard_buttons) { - for (const auto& rows : keys) { - for (auto* button : rows) { - if (!button) { - continue; - } - - button->setEnabled(true); - } - } - } - - const auto& key_disable_flags = initialize_parameters.key_disable_flags; - - ui->button_space->setDisabled(key_disable_flags.space); - ui->button_space_shift->setDisabled(key_disable_flags.space); - - ui->button_at->setDisabled(key_disable_flags.at || key_disable_flags.username); - - ui->button_percent->setDisabled(key_disable_flags.percent || key_disable_flags.username); - - ui->button_slash->setDisabled(key_disable_flags.slash); - - ui->button_1->setDisabled(key_disable_flags.numbers); - ui->button_2->setDisabled(key_disable_flags.numbers); - ui->button_3->setDisabled(key_disable_flags.numbers); - ui->button_4->setDisabled(key_disable_flags.numbers); - ui->button_5->setDisabled(key_disable_flags.numbers); - ui->button_6->setDisabled(key_disable_flags.numbers); - ui->button_7->setDisabled(key_disable_flags.numbers); - ui->button_8->setDisabled(key_disable_flags.numbers); - ui->button_9->setDisabled(key_disable_flags.numbers); - ui->button_0->setDisabled(key_disable_flags.numbers); - - ui->button_return->setEnabled(initialize_parameters.enable_return_button); - ui->button_return_shift->setEnabled(initialize_parameters.enable_return_button); - break; - } - case BottomOSKIndex::NumberPad: { - for (const auto& rows : numberpad_buttons) { - for (auto* button : rows) { - if (!button) { - continue; - } - - 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; - } - } -} - -void QtSoftwareKeyboardDialog::SetBackspaceOkEnabled() { - if (is_inline) { - ui->button_ok->setEnabled(current_text.size() >= initialize_parameters.min_text_length); - ui->button_ok_shift->setEnabled(current_text.size() >= - initialize_parameters.min_text_length); - ui->button_ok_num->setEnabled(current_text.size() >= initialize_parameters.min_text_length); - - ui->button_backspace->setEnabled(initialize_parameters.enable_backspace_button && - cursor_position > 0); - ui->button_backspace_shift->setEnabled(initialize_parameters.enable_backspace_button && - cursor_position > 0); - ui->button_backspace_num->setEnabled(initialize_parameters.enable_backspace_button && - cursor_position > 0); - } else { - const auto text_length = [this] { - if (ui->topOSK->currentIndex() == 1) { - return static_cast<u32>(ui->text_edit_osk->toPlainText().length()); - } else { - return static_cast<u32>(ui->line_edit_osk->text().length()); - } - }(); - - const auto normal_cursor_position = [this] { - if (ui->topOSK->currentIndex() == 1) { - return ui->text_edit_osk->textCursor().position(); - } else { - return ui->line_edit_osk->cursorPosition(); - } - }(); - - ui->button_ok->setEnabled(text_length >= initialize_parameters.min_text_length); - ui->button_ok_shift->setEnabled(text_length >= initialize_parameters.min_text_length); - ui->button_ok_num->setEnabled(text_length >= initialize_parameters.min_text_length); - - ui->button_backspace->setEnabled(initialize_parameters.enable_backspace_button && - normal_cursor_position > 0); - ui->button_backspace_shift->setEnabled(initialize_parameters.enable_backspace_button && - normal_cursor_position > 0); - ui->button_backspace_num->setEnabled(initialize_parameters.enable_backspace_button && - normal_cursor_position > 0); - } -} - -bool QtSoftwareKeyboardDialog::ValidateInputText(const QString& input_text) { - const auto& key_disable_flags = initialize_parameters.key_disable_flags; - - const auto input_text_length = static_cast<u32>(input_text.length()); - - if (input_text_length < initialize_parameters.min_text_length || - input_text_length > initialize_parameters.max_text_length) { - return false; - } - - if (key_disable_flags.space && input_text.contains(QLatin1Char{' '})) { - return false; - } - - if ((key_disable_flags.at || key_disable_flags.username) && - input_text.contains(QLatin1Char{'@'})) { - return false; - } - - if ((key_disable_flags.percent || key_disable_flags.username) && - input_text.contains(QLatin1Char{'%'})) { - return false; - } - - if (key_disable_flags.slash && input_text.contains(QLatin1Char{'/'})) { - return false; - } - - if ((key_disable_flags.backslash || key_disable_flags.username) && - input_text.contains(QLatin1Char('\\'))) { - return false; - } - - if (key_disable_flags.numbers && - std::any_of(input_text.begin(), input_text.end(), [](QChar c) { return c.isDigit(); })) { - return false; - } - - if (bottom_osk_index == BottomOSKIndex::NumberPad && - 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; - } - - return true; -} - -void QtSoftwareKeyboardDialog::ChangeBottomOSKIndex() { - switch (bottom_osk_index) { - case BottomOSKIndex::LowerCase: - bottom_osk_index = BottomOSKIndex::UpperCase; - ui->bottomOSK->setCurrentIndex(static_cast<int>(bottom_osk_index)); - - ui->button_shift_shift->setStyleSheet( - QStringLiteral("image: url(:/overlay/osk_button_shift_lock_off.png);" - "\nimage-position: left;")); - - ui->button_shift_shift->setIconSize(ui->button_shift->iconSize()); - ui->button_backspace_shift->setIconSize(ui->button_backspace->iconSize()); - break; - case BottomOSKIndex::UpperCase: - if (caps_lock_enabled) { - caps_lock_enabled = false; - - ui->button_shift_shift->setStyleSheet( - QStringLiteral("image: url(:/overlay/osk_button_shift_lock_off.png);" - "\nimage-position: left;")); - - ui->button_shift_shift->setIconSize(ui->button_shift->iconSize()); - ui->button_backspace_shift->setIconSize(ui->button_backspace->iconSize()); - - ui->label_shift_shift->setText(QStringLiteral("Caps Lock")); - - bottom_osk_index = BottomOSKIndex::LowerCase; - ui->bottomOSK->setCurrentIndex(static_cast<int>(bottom_osk_index)); - } else { - caps_lock_enabled = true; - - ui->button_shift_shift->setStyleSheet( - QStringLiteral("image: url(:/overlay/osk_button_shift_lock_on.png);" - "\nimage-position: left;")); - - ui->button_shift_shift->setIconSize(ui->button_shift->iconSize()); - ui->button_backspace_shift->setIconSize(ui->button_backspace->iconSize()); - - ui->label_shift_shift->setText(QStringLiteral("Caps Lock Off")); - } - break; - case BottomOSKIndex::NumberPad: - default: - break; - } -} - -void QtSoftwareKeyboardDialog::NormalKeyboardButtonClicked(QPushButton* button) { - if (button == ui->button_ampersand) { - if (ui->topOSK->currentIndex() == 1) { - ui->text_edit_osk->insertPlainText(QStringLiteral("&")); - } else { - ui->line_edit_osk->insert(QStringLiteral("&")); - } - return; - } - - if (button == ui->button_return || button == ui->button_return_shift) { - if (ui->topOSK->currentIndex() == 1) { - ui->text_edit_osk->insertPlainText(QStringLiteral("\n")); - } else { - ui->line_edit_osk->insert(QStringLiteral("\n")); - } - return; - } - - if (button == ui->button_space || button == ui->button_space_shift) { - if (ui->topOSK->currentIndex() == 1) { - ui->text_edit_osk->insertPlainText(QStringLiteral(" ")); - } else { - ui->line_edit_osk->insert(QStringLiteral(" ")); - } - return; - } - - if (button == ui->button_shift || button == ui->button_shift_shift) { - ChangeBottomOSKIndex(); - return; - } - - if (button == ui->button_backspace || button == ui->button_backspace_shift || - button == ui->button_backspace_num) { - if (ui->topOSK->currentIndex() == 1) { - auto text_cursor = ui->text_edit_osk->textCursor(); - ui->text_edit_osk->setTextCursor(text_cursor); - text_cursor.deletePreviousChar(); - } else { - ui->line_edit_osk->backspace(); - } - return; - } - - if (button == ui->button_ok || button == ui->button_ok_shift || button == ui->button_ok_num) { - 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_str)); - return; - } - - if (ui->topOSK->currentIndex() == 1) { - ui->text_edit_osk->insertPlainText(button->text()); - } else { - ui->line_edit_osk->insert(button->text()); - } - - // Revert the keyboard to lowercase if the shift key is active. - if (bottom_osk_index == BottomOSKIndex::UpperCase && !caps_lock_enabled) { - // This is set to true since ChangeBottomOSKIndex will change bottom_osk_index to LowerCase - // if bottom_osk_index is UpperCase and caps_lock_enabled is true. - caps_lock_enabled = true; - ChangeBottomOSKIndex(); - } -} - -void QtSoftwareKeyboardDialog::InlineKeyboardButtonClicked(QPushButton* button) { - if (!button->isEnabled()) { - return; - } - - if (button == ui->button_ampersand) { - InlineTextInsertString(u"&"); - return; - } - - if (button == ui->button_return || button == ui->button_return_shift) { - InlineTextInsertString(u"\n"); - return; - } - - if (button == ui->button_space || button == ui->button_space_shift) { - InlineTextInsertString(u" "); - return; - } - - if (button == ui->button_shift || button == ui->button_shift_shift) { - ChangeBottomOSKIndex(); - return; - } - - if (button == ui->button_backspace || button == ui->button_backspace_shift || - button == ui->button_backspace_num) { - if (cursor_position <= 0 || current_text.empty()) { - cursor_position = 0; - return; - } - - --cursor_position; - - current_text.erase(cursor_position, 1); - - SetBackspaceOkEnabled(); - - emit SubmitInlineText(SwkbdReplyType::ChangedString, current_text, cursor_position); - return; - } - - if (button == ui->button_ok || button == ui->button_ok_shift || button == ui->button_ok_num) { - emit SubmitInlineText(SwkbdReplyType::DecidedEnter, current_text, cursor_position); - return; - } - - 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) { - // This is set to true since ChangeBottomOSKIndex will change bottom_osk_index to LowerCase - // if bottom_osk_index is UpperCase and caps_lock_enabled is true. - caps_lock_enabled = true; - ChangeBottomOSKIndex(); - } -} - -void QtSoftwareKeyboardDialog::InlineTextInsertString(std::u16string_view string) { - if ((current_text.size() + string.size()) > initialize_parameters.max_text_length) { - return; - } - - current_text.insert(cursor_position, string); - - cursor_position += static_cast<s32>(string.size()); - - SetBackspaceOkEnabled(); - - emit SubmitInlineText(SwkbdReplyType::ChangedString, current_text, cursor_position); -} - -void QtSoftwareKeyboardDialog::SetupMouseHover() { - // setFocus() has a bug where continuously changing focus will cause the focus UI to - // mysteriously disappear. A workaround we have found is using the mouse to hover over - // the buttons to act in place of the button focus. As a result, we will have to set - // a blank cursor when hovering over all the buttons and set a no focus policy so the - // buttons do not stay in focus in addition to the mouse hover. - for (auto* button : all_buttons) { - button->setCursor(QCursor(Qt::BlankCursor)); - button->setFocusPolicy(Qt::NoFocus); - } -} - -template <Core::HID::NpadButton... T> -void QtSoftwareKeyboardDialog::HandleButtonPressedOnce() { - const auto f = [this](Core::HID::NpadButton button) { - if (input_interpreter->IsButtonPressedOnce(button)) { - TranslateButtonPress(button); - } - }; - - (f(T), ...); -} - -template <Core::HID::NpadButton... T> -void QtSoftwareKeyboardDialog::HandleButtonHold() { - const auto f = [this](Core::HID::NpadButton button) { - if (input_interpreter->IsButtonHeld(button)) { - TranslateButtonPress(button); - } - }; - - (f(T), ...); -} - -void QtSoftwareKeyboardDialog::TranslateButtonPress(Core::HID::NpadButton button) { - switch (button) { - case Core::HID::NpadButton::A: - switch (bottom_osk_index) { - case BottomOSKIndex::LowerCase: - case BottomOSKIndex::UpperCase: - keyboard_buttons[static_cast<std::size_t>(bottom_osk_index)][row][column]->click(); - break; - case BottomOSKIndex::NumberPad: - numberpad_buttons[row][column]->click(); - break; - default: - break; - } - break; - case Core::HID::NpadButton::B: - switch (bottom_osk_index) { - case BottomOSKIndex::LowerCase: - ui->button_backspace->click(); - break; - case BottomOSKIndex::UpperCase: - ui->button_backspace_shift->click(); - break; - case BottomOSKIndex::NumberPad: - ui->button_backspace_num->click(); - break; - default: - break; - } - break; - case Core::HID::NpadButton::X: - if (is_inline) { - emit SubmitInlineText(SwkbdReplyType::DecidedCancel, current_text, cursor_position); - } else { - 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_str)); - } - break; - case Core::HID::NpadButton::Y: - switch (bottom_osk_index) { - case BottomOSKIndex::LowerCase: - ui->button_space->click(); - break; - case BottomOSKIndex::UpperCase: - ui->button_space_shift->click(); - break; - case BottomOSKIndex::NumberPad: - default: - break; - } - break; - case Core::HID::NpadButton::StickL: - case Core::HID::NpadButton::StickR: - switch (bottom_osk_index) { - case BottomOSKIndex::LowerCase: - ui->button_shift->click(); - break; - case BottomOSKIndex::UpperCase: - ui->button_shift_shift->click(); - break; - case BottomOSKIndex::NumberPad: - default: - break; - } - break; - case Core::HID::NpadButton::L: - MoveTextCursorDirection(Direction::Left); - break; - case Core::HID::NpadButton::R: - MoveTextCursorDirection(Direction::Right); - break; - case Core::HID::NpadButton::Plus: - switch (bottom_osk_index) { - case BottomOSKIndex::LowerCase: - ui->button_ok->click(); - break; - case BottomOSKIndex::UpperCase: - ui->button_ok_shift->click(); - break; - case BottomOSKIndex::NumberPad: - ui->button_ok_num->click(); - break; - default: - break; - } - break; - case Core::HID::NpadButton::Left: - case Core::HID::NpadButton::StickLLeft: - case Core::HID::NpadButton::StickRLeft: - MoveButtonDirection(Direction::Left); - break; - case Core::HID::NpadButton::Up: - case Core::HID::NpadButton::StickLUp: - case Core::HID::NpadButton::StickRUp: - MoveButtonDirection(Direction::Up); - break; - case Core::HID::NpadButton::Right: - case Core::HID::NpadButton::StickLRight: - case Core::HID::NpadButton::StickRRight: - MoveButtonDirection(Direction::Right); - break; - case Core::HID::NpadButton::Down: - case Core::HID::NpadButton::StickLDown: - case Core::HID::NpadButton::StickRDown: - MoveButtonDirection(Direction::Down); - break; - default: - break; - } -} - -void QtSoftwareKeyboardDialog::MoveButtonDirection(Direction direction) { - // Changes the row or column index depending on the direction. - auto move_direction = [this, direction](std::size_t max_rows, std::size_t max_columns) { - switch (direction) { - case Direction::Left: - column = (column + max_columns - 1) % max_columns; - break; - case Direction::Up: - row = (row + max_rows - 1) % max_rows; - break; - case Direction::Right: - column = (column + 1) % max_columns; - break; - case Direction::Down: - row = (row + 1) % max_rows; - break; - default: - break; - } - }; - - // 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: { - const auto index = static_cast<std::size_t>(bottom_osk_index); - - const auto* const prev_button = keyboard_buttons[index][row][column]; - move_direction(NUM_ROWS_NORMAL, NUM_COLUMNS_NORMAL); - 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]; - } - - // This is a workaround for setFocus() randomly not showing focus in the UI - QCursor::setPos(curr_button->mapToGlobal(curr_button->rect().center())); - break; - } - case BottomOSKIndex::NumberPad: { - const auto* const prev_button = numberpad_buttons[row][column]; - move_direction(NUM_ROWS_NUMPAD, NUM_COLUMNS_NUMPAD); - 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]; - } - - // This is a workaround for setFocus() randomly not showing focus in the UI - QCursor::setPos(curr_button->mapToGlobal(curr_button->rect().center())); - break; - } - default: - break; - } -} - -void QtSoftwareKeyboardDialog::MoveTextCursorDirection(Direction direction) { - switch (direction) { - case Direction::Left: - if (is_inline) { - if (cursor_position <= 0) { - cursor_position = 0; - } else { - --cursor_position; - emit SubmitInlineText(SwkbdReplyType::MovedCursor, current_text, cursor_position); - } - } else { - if (ui->topOSK->currentIndex() == 1) { - ui->text_edit_osk->moveCursor(QTextCursor::Left); - } else { - ui->line_edit_osk->setCursorPosition(ui->line_edit_osk->cursorPosition() - 1); - } - } - break; - case Direction::Right: - if (is_inline) { - if (cursor_position >= static_cast<s32>(current_text.size())) { - cursor_position = static_cast<s32>(current_text.size()); - } else { - ++cursor_position; - emit SubmitInlineText(SwkbdReplyType::MovedCursor, current_text, cursor_position); - } - } else { - if (ui->topOSK->currentIndex() == 1) { - ui->text_edit_osk->moveCursor(QTextCursor::Right); - } else { - ui->line_edit_osk->setCursorPosition(ui->line_edit_osk->cursorPosition() + 1); - } - } - break; - default: - break; - } -} - -void QtSoftwareKeyboardDialog::StartInputThread() { - if (input_thread_running) { - return; - } - - input_thread_running = true; - - input_thread = std::thread(&QtSoftwareKeyboardDialog::InputThread, this); -} - -void QtSoftwareKeyboardDialog::StopInputThread() { - input_thread_running = false; - - if (input_thread.joinable()) { - input_thread.join(); - } - - if (input_interpreter) { - input_interpreter->ResetButtonStates(); - } -} - -void QtSoftwareKeyboardDialog::InputThread() { - while (input_thread_running) { - input_interpreter->PollInput(); - - HandleButtonPressedOnce< - Core::HID::NpadButton::A, Core::HID::NpadButton::B, Core::HID::NpadButton::X, - Core::HID::NpadButton::Y, Core::HID::NpadButton::StickL, Core::HID::NpadButton::StickR, - Core::HID::NpadButton::L, Core::HID::NpadButton::R, Core::HID::NpadButton::Plus, - Core::HID::NpadButton::Left, Core::HID::NpadButton::Up, Core::HID::NpadButton::Right, - Core::HID::NpadButton::Down, Core::HID::NpadButton::StickLLeft, - Core::HID::NpadButton::StickLUp, Core::HID::NpadButton::StickLRight, - Core::HID::NpadButton::StickLDown, Core::HID::NpadButton::StickRLeft, - Core::HID::NpadButton::StickRUp, Core::HID::NpadButton::StickRRight, - Core::HID::NpadButton::StickRDown>(); - - HandleButtonHold<Core::HID::NpadButton::B, Core::HID::NpadButton::L, - Core::HID::NpadButton::R, Core::HID::NpadButton::Left, - Core::HID::NpadButton::Up, Core::HID::NpadButton::Right, - Core::HID::NpadButton::Down, Core::HID::NpadButton::StickLLeft, - Core::HID::NpadButton::StickLUp, Core::HID::NpadButton::StickLRight, - Core::HID::NpadButton::StickLDown, Core::HID::NpadButton::StickRLeft, - Core::HID::NpadButton::StickRUp, Core::HID::NpadButton::StickRRight, - Core::HID::NpadButton::StickRDown>(); - - std::this_thread::sleep_for(std::chrono::milliseconds(50)); - } -} - -QtSoftwareKeyboard::QtSoftwareKeyboard(GMainWindow& main_window) { - connect(this, &QtSoftwareKeyboard::MainWindowInitializeKeyboard, &main_window, - &GMainWindow::SoftwareKeyboardInitialize, Qt::QueuedConnection); - connect(this, &QtSoftwareKeyboard::MainWindowShowNormalKeyboard, &main_window, - &GMainWindow::SoftwareKeyboardShowNormal, Qt::QueuedConnection); - connect(this, &QtSoftwareKeyboard::MainWindowShowTextCheckDialog, &main_window, - &GMainWindow::SoftwareKeyboardShowTextCheck, Qt::QueuedConnection); - connect(this, &QtSoftwareKeyboard::MainWindowShowInlineKeyboard, &main_window, - &GMainWindow::SoftwareKeyboardShowInline, Qt::QueuedConnection); - connect(this, &QtSoftwareKeyboard::MainWindowHideInlineKeyboard, &main_window, - &GMainWindow::SoftwareKeyboardHideInline, Qt::QueuedConnection); - connect(this, &QtSoftwareKeyboard::MainWindowInlineTextChanged, &main_window, - &GMainWindow::SoftwareKeyboardInlineTextChanged, Qt::QueuedConnection); - connect(this, &QtSoftwareKeyboard::MainWindowExitKeyboard, &main_window, - &GMainWindow::SoftwareKeyboardExit, Qt::QueuedConnection); - connect(&main_window, &GMainWindow::SoftwareKeyboardSubmitNormalText, this, - &QtSoftwareKeyboard::SubmitNormalText, Qt::QueuedConnection); - connect(&main_window, &GMainWindow::SoftwareKeyboardSubmitInlineText, this, - &QtSoftwareKeyboard::SubmitInlineText, Qt::QueuedConnection); -} - -QtSoftwareKeyboard::~QtSoftwareKeyboard() = default; - -void QtSoftwareKeyboard::InitializeKeyboard( - bool is_inline, Core::Frontend::KeyboardInitializeParameters initialize_parameters, - SubmitNormalCallback submit_normal_callback_, SubmitInlineCallback submit_inline_callback_) { - if (is_inline) { - submit_inline_callback = std::move(submit_inline_callback_); - } else { - submit_normal_callback = std::move(submit_normal_callback_); - } - - LOG_INFO(Service_AM, - "\nKeyboardInitializeParameters:" - "\nok_text={}" - "\nheader_text={}" - "\nsub_text={}" - "\nguide_text={}" - "\ninitial_text={}" - "\nmax_text_length={}" - "\nmin_text_length={}" - "\ninitial_cursor_position={}" - "\ntype={}" - "\npassword_mode={}" - "\ntext_draw_type={}" - "\nkey_disable_flags={}" - "\nuse_blur_background={}" - "\nenable_backspace_button={}" - "\nenable_return_button={}" - "\ndisable_cancel_button={}", - Common::UTF16ToUTF8(initialize_parameters.ok_text), - Common::UTF16ToUTF8(initialize_parameters.header_text), - Common::UTF16ToUTF8(initialize_parameters.sub_text), - Common::UTF16ToUTF8(initialize_parameters.guide_text), - Common::UTF16ToUTF8(initialize_parameters.initial_text), - initialize_parameters.max_text_length, initialize_parameters.min_text_length, - initialize_parameters.initial_cursor_position, initialize_parameters.type, - initialize_parameters.password_mode, initialize_parameters.text_draw_type, - initialize_parameters.key_disable_flags.raw, initialize_parameters.use_blur_background, - initialize_parameters.enable_backspace_button, - initialize_parameters.enable_return_button, - initialize_parameters.disable_cancel_button); - - emit MainWindowInitializeKeyboard(is_inline, std::move(initialize_parameters)); -} - -void QtSoftwareKeyboard::ShowNormalKeyboard() const { - emit MainWindowShowNormalKeyboard(); -} - -void QtSoftwareKeyboard::ShowTextCheckDialog( - Service::AM::Frontend::SwkbdTextCheckResult text_check_result, - std::u16string text_check_message) const { - emit MainWindowShowTextCheckDialog(text_check_result, std::move(text_check_message)); -} - -void QtSoftwareKeyboard::ShowInlineKeyboard( - Core::Frontend::InlineAppearParameters appear_parameters) const { - LOG_INFO(Service_AM, - "\nInlineAppearParameters:" - "\nmax_text_length={}" - "\nmin_text_length={}" - "\nkey_top_scale_x={}" - "\nkey_top_scale_y={}" - "\nkey_top_translate_x={}" - "\nkey_top_translate_y={}" - "\ntype={}" - "\nkey_disable_flags={}" - "\nkey_top_as_floating={}" - "\nenable_backspace_button={}" - "\nenable_return_button={}" - "\ndisable_cancel_button={}", - appear_parameters.max_text_length, appear_parameters.min_text_length, - appear_parameters.key_top_scale_x, appear_parameters.key_top_scale_y, - appear_parameters.key_top_translate_x, appear_parameters.key_top_translate_y, - appear_parameters.type, appear_parameters.key_disable_flags.raw, - appear_parameters.key_top_as_floating, appear_parameters.enable_backspace_button, - appear_parameters.enable_return_button, appear_parameters.disable_cancel_button); - - emit MainWindowShowInlineKeyboard(std::move(appear_parameters)); -} - -void QtSoftwareKeyboard::HideInlineKeyboard() const { - emit MainWindowHideInlineKeyboard(); -} - -void QtSoftwareKeyboard::InlineTextChanged( - Core::Frontend::InlineTextParameters text_parameters) const { - LOG_INFO(Service_AM, - "\nInlineTextParameters:" - "\ninput_text={}" - "\ncursor_position={}", - Common::UTF16ToUTF8(text_parameters.input_text), text_parameters.cursor_position); - - emit MainWindowInlineTextChanged(std::move(text_parameters)); -} - -void QtSoftwareKeyboard::ExitKeyboard() const { - emit MainWindowExitKeyboard(); -} - -void QtSoftwareKeyboard::SubmitNormalText(Service::AM::Frontend::SwkbdResult result, - std::u16string submitted_text, bool confirmed) const { - submit_normal_callback(result, submitted_text, confirmed); -} - -void QtSoftwareKeyboard::SubmitInlineText(Service::AM::Frontend::SwkbdReplyType reply_type, - std::u16string submitted_text, - s32 cursor_position) const { - submit_inline_callback(reply_type, submitted_text, cursor_position); -} diff --git a/src/yuzu/applets/qt_software_keyboard.h b/src/yuzu/applets/qt_software_keyboard.h deleted file mode 100644 index 7e2fdf09e..000000000 --- a/src/yuzu/applets/qt_software_keyboard.h +++ /dev/null @@ -1,287 +0,0 @@ -// 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> - -#include <QDialog> -#include <QValidator> - -#include "core/frontend/applets/software_keyboard.h" - -class InputInterpreter; - -namespace Core { -class System; -} - -namespace Core::HID { -enum class NpadButton : u64; -} - -namespace Ui { -class QtSoftwareKeyboardDialog; -} - -class GMainWindow; - -class QtSoftwareKeyboardDialog final : public QDialog { - Q_OBJECT - -public: - QtSoftwareKeyboardDialog(QWidget* parent, Core::System& system_, bool is_inline_, - Core::Frontend::KeyboardInitializeParameters initialize_parameters_); - ~QtSoftwareKeyboardDialog() override; - - void ShowNormalKeyboard(QPoint pos, QSize size); - - void ShowTextCheckDialog(Service::AM::Frontend::SwkbdTextCheckResult text_check_result, - std::u16string text_check_message); - - void ShowInlineKeyboard(Core::Frontend::InlineAppearParameters appear_parameters, QPoint pos, - QSize size); - - void HideInlineKeyboard(); - - void InlineTextChanged(Core::Frontend::InlineTextParameters text_parameters); - - void ExitKeyboard(); - -signals: - void SubmitNormalText(Service::AM::Frontend::SwkbdResult result, std::u16string submitted_text, - bool confirmed = false) const; - - void SubmitInlineText(Service::AM::Frontend::SwkbdReplyType reply_type, - std::u16string submitted_text, s32 cursor_position) const; - -public slots: - void open() override; - void reject() override; - -protected: - /// We override the keyPressEvent for inputting text into the inline software keyboard. - void keyPressEvent(QKeyEvent* event) override; - -private: - enum class Direction { - Left, - Up, - Right, - Down, - }; - - enum class BottomOSKIndex { - LowerCase, - UpperCase, - NumberPad, - }; - - /** - * Moves and resizes the window to a specified position and size. - * - * @param pos Top-left window position - * @param size Window size - */ - void MoveAndResizeWindow(QPoint pos, QSize size); - - /** - * Rescales all keyboard elements to account for High DPI displays. - * - * @param width Window width - * @param height Window height - * @param dpi_scale Display scaling factor - */ - void RescaleKeyboardElements(float width, float height, float dpi_scale); - - /// Sets the keyboard type based on initialize_parameters. - void SetKeyboardType(); - - /// Sets the password mode based on initialize_parameters. - void SetPasswordMode(); - - /// Sets the text draw type based on initialize_parameters. - void SetTextDrawType(); - - /// Sets the controller image at the bottom left of the software keyboard. - void SetControllerImage(); - - /// Disables buttons based on initialize_parameters. - void DisableKeyboardButtons(); - - /// Changes whether the backspace or/and ok buttons should be enabled or disabled. - void SetBackspaceOkEnabled(); - - /** - * Validates the input text sent in based on the parameters in initialize_parameters. - * - * @param input_text Input text - * - * @returns True if the input text is valid, false otherwise. - */ - bool ValidateInputText(const QString& input_text); - - /// Switches between LowerCase and UpperCase (Shift and Caps Lock) - void ChangeBottomOSKIndex(); - - /// Processes a keyboard button click from the UI as normal keyboard input. - void NormalKeyboardButtonClicked(QPushButton* button); - - /// Processes a keyboard button click from the UI as inline keyboard input. - void InlineKeyboardButtonClicked(QPushButton* button); - - /** - * Inserts a string of arbitrary length into the current_text at the current cursor position. - * This is only used for the inline software keyboard. - */ - void InlineTextInsertString(std::u16string_view string); - - /// Setup the mouse hover workaround for "focusing" buttons. This should only be called once. - void SetupMouseHover(); - - /** - * Handles button presses and converts them into keyboard input. - * - * @tparam HIDButton The list of buttons that can be converted into keyboard input. - */ - template <Core::HID::NpadButton... T> - void HandleButtonPressedOnce(); - - /** - * Handles button holds and converts them into keyboard input. - * - * @tparam HIDButton The list of buttons that can be converted into keyboard input. - */ - template <Core::HID::NpadButton... T> - void HandleButtonHold(); - - /** - * Translates a button press to focus or click a keyboard button. - * - * @param button The button press to process. - */ - void TranslateButtonPress(Core::HID::NpadButton button); - - /** - * Moves the focus of a button in a certain direction. - * - * @param direction The direction to move. - */ - void MoveButtonDirection(Direction direction); - - /** - * Moves the text cursor in a certain direction. - * - * @param direction The direction to move. - */ - void MoveTextCursorDirection(Direction direction); - - void StartInputThread(); - void StopInputThread(); - - /// The thread where input is being polled and processed. - void InputThread(); - - std::unique_ptr<Ui::QtSoftwareKeyboardDialog> ui; - - Core::System& system; - - // True if it is the inline software keyboard. - bool is_inline; - - // Common software keyboard initialize parameters. - Core::Frontend::KeyboardInitializeParameters initialize_parameters; - - // Used only by the inline software keyboard since the QLineEdit or QTextEdit is hidden. - std::u16string current_text; - s32 cursor_position{0}; - - static constexpr std::size_t NUM_ROWS_NORMAL = 5; - static constexpr std::size_t NUM_COLUMNS_NORMAL = 12; - static constexpr std::size_t NUM_ROWS_NUMPAD = 4; - static constexpr std::size_t NUM_COLUMNS_NUMPAD = 4; - - // Stores the normal keyboard layout. - std::array<std::array<std::array<QPushButton*, NUM_COLUMNS_NORMAL>, NUM_ROWS_NORMAL>, 2> - keyboard_buttons; - // Stores the numberpad keyboard layout. - 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*, 112> all_buttons; - - std::size_t row{0}; - std::size_t column{0}; - - BottomOSKIndex bottom_osk_index{BottomOSKIndex::LowerCase}; - std::atomic<bool> caps_lock_enabled{false}; - - std::unique_ptr<InputInterpreter> input_interpreter; - - std::thread input_thread; - - std::atomic<bool> input_thread_running{}; -}; - -class QtSoftwareKeyboard final : public QObject, public Core::Frontend::SoftwareKeyboardApplet { - Q_OBJECT - -public: - explicit QtSoftwareKeyboard(GMainWindow& parent); - ~QtSoftwareKeyboard() override; - - void Close() const override { - ExitKeyboard(); - } - - void InitializeKeyboard(bool is_inline, - Core::Frontend::KeyboardInitializeParameters initialize_parameters, - SubmitNormalCallback submit_normal_callback_, - SubmitInlineCallback submit_inline_callback_) override; - - void ShowNormalKeyboard() const override; - - void ShowTextCheckDialog(Service::AM::Frontend::SwkbdTextCheckResult text_check_result, - std::u16string text_check_message) const override; - - void ShowInlineKeyboard( - Core::Frontend::InlineAppearParameters appear_parameters) const override; - - void HideInlineKeyboard() const override; - - void InlineTextChanged(Core::Frontend::InlineTextParameters text_parameters) const override; - - void ExitKeyboard() const override; - -signals: - void MainWindowInitializeKeyboard( - bool is_inline, Core::Frontend::KeyboardInitializeParameters initialize_parameters) const; - - void MainWindowShowNormalKeyboard() const; - - void MainWindowShowTextCheckDialog( - Service::AM::Frontend::SwkbdTextCheckResult text_check_result, - std::u16string text_check_message) const; - - void MainWindowShowInlineKeyboard( - Core::Frontend::InlineAppearParameters appear_parameters) const; - - void MainWindowHideInlineKeyboard() const; - - void MainWindowInlineTextChanged(Core::Frontend::InlineTextParameters text_parameters) const; - - void MainWindowExitKeyboard() const; - -private: - void SubmitNormalText(Service::AM::Frontend::SwkbdResult result, std::u16string submitted_text, - bool confirmed) const; - - void SubmitInlineText(Service::AM::Frontend::SwkbdReplyType reply_type, - std::u16string submitted_text, s32 cursor_position) const; - - mutable SubmitNormalCallback submit_normal_callback; - mutable SubmitInlineCallback submit_inline_callback; -}; diff --git a/src/yuzu/applets/qt_software_keyboard.ui b/src/yuzu/applets/qt_software_keyboard.ui deleted file mode 100644 index 9661cb260..000000000 --- a/src/yuzu/applets/qt_software_keyboard.ui +++ /dev/null @@ -1,3541 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>QtSoftwareKeyboardDialog</class> - <widget class="QDialog" name="QtSoftwareKeyboardDialog"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>1280</width> - <height>720</height> - </rect> - </property> - <property name="windowTitle"> - <string>Software Keyboard</string> - </property> - <property name="styleSheet"> - <string notr="true"/> - </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <property name="spacing"> - <number>0</number> - </property> - <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="QWidget" name="mainOSK" native="true"> - <layout class="QVBoxLayout" name="verticalLayout_2" stretch="320,400"> - <property name="spacing"> - <number>0</number> - </property> - <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="QStackedWidget" name="topOSK"> - <property name="currentIndex"> - <number>0</number> - </property> - <widget class="QWidget" name="lineOSK"> - <property name="minimumSize"> - <size> - <width>0</width> - <height>100</height> - </size> - </property> - <layout class="QVBoxLayout" name="lineOSKVerticalLayout"> - <property name="spacing"> - <number>0</number> - </property> - <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="QGridLayout" name="gridLineOSK" rowstretch="40,50,23,48,65,94" columnstretch="130,1020,130"> - <property name="topMargin"> - <number>0</number> - </property> - <property name="spacing"> - <number>0</number> - </property> - <item row="4" column="2"> - <spacer name="horizontalSpacer_3"> - <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="4" column="0"> - <spacer name="horizontalSpacer_4"> - <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="5" column="1"> - <widget class="QWidget" name="charactersOSK" native="true"> - <layout class="QVBoxLayout" name="verticalLayout_5"> - <property name="spacing"> - <number>0</number> - </property> - <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 alignment="Qt::AlignRight|Qt::AlignTop"> - <widget class="QLabel" name="label_characters"> - <property name="font"> - <font> - <pointsize>17</pointsize> - </font> - </property> - <property name="text"> - <string notr="true">0/32</string> - </property> - <property name="alignment"> - <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item row="3" column="1"> - <spacer name="verticalSpacer_2"> - <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 row="5" column="0"> - <spacer name="verticalSpacer_3"> - <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 row="4" column="1"> - <widget class="QWidget" name="inputOSK" native="true"> - <layout class="QVBoxLayout" name="verticalLayout_3"> - <item> - <widget class="QLineEdit" name="line_edit_osk"> - <property name="font"> - <font> - <pointsize>26</pointsize> - <weight>50</weight> - <bold>false</bold> - </font> - </property> - <property name="focusPolicy"> - <enum>Qt::StrongFocus</enum> - </property> - <property name="text"> - <string/> - </property> - <property name="maxLength"> - <number>32</number> - </property> - <property name="placeholderText"> - <string>Enter Text</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item row="0" column="1"> - <spacer name="verticalSpacer_4"> - <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 row="1" column="0" colspan="3"> - <widget class="QWidget" name="headerOSK" native="true"> - <layout class="QHBoxLayout" name="horizontalLayout_4" stretch="130,1020,130"> - <property name="spacing"> - <number>0</number> - </property> - <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> - <spacer name="horizontalSpacer_18"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>127</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QLabel" name="label_header"> - <property name="font"> - <font> - <pointsize>23</pointsize> - </font> - </property> - <property name="text"> - <string/> - </property> - </widget> - </item> - <item> - <spacer name="horizontalSpacer_19"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>127</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - </item> - <item row="2" column="0" colspan="3"> - <widget class="QWidget" name="subOSK" native="true"> - <layout class="QHBoxLayout" name="horizontalLayout_3" stretch="130,1020,130"> - <property name="spacing"> - <number>0</number> - </property> - <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> - <spacer name="horizontalSpacer_16"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>127</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QLabel" name="label_sub"> - <property name="font"> - <font> - <pointsize>17</pointsize> - </font> - </property> - <property name="text"> - <string/> - </property> - </widget> - </item> - <item> - <spacer name="horizontalSpacer_17"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>127</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - </item> - </layout> - </item> - </layout> - </widget> - <widget class="QWidget" name="boxOSK"> - <layout class="QVBoxLayout" name="boxOSKVerticalLayout"> - <property name="spacing"> - <number>0</number> - </property> - <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="QGridLayout" name="gridBoxOSK" rowstretch="61,178,81" columnstretch="120,1040,120"> - <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> - <property name="spacing"> - <number>0</number> - </property> - <item row="0" column="1"> - <spacer name="verticalSpacer_5"> - <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 row="1" column="0"> - <spacer name="horizontalSpacer_20"> - <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="1" column="2"> - <spacer name="horizontalSpacer_21"> - <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="2" column="1" alignment="Qt::AlignRight|Qt::AlignTop"> - <widget class="QWidget" name="charactersBoxOSK" native="true"> - <layout class="QVBoxLayout" name="verticalLayout_4"> - <property name="spacing"> - <number>0</number> - </property> - <property name="leftMargin"> - <number>0</number> - </property> - <property name="topMargin"> - <number>0</number> - </property> - <property name="rightMargin"> - <number>0</number> - </property> - <property name="bottomMargin"> - <number>0</number> - </property> - <item> - <widget class="QLabel" name="label_characters_box"> - <property name="enabled"> - <bool>true</bool> - </property> - <property name="font"> - <font> - <pointsize>17</pointsize> - </font> - </property> - <property name="text"> - <string notr="true">0/500</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item row="1" column="1"> - <widget class="QWidget" name="inputBoxOSK" native="true"> - <layout class="QVBoxLayout" name="verticalLayout_6"> - <property name="spacing"> - <number>0</number> - </property> - <property name="leftMargin"> - <number>14</number> - </property> - <property name="topMargin"> - <number>9</number> - </property> - <property name="rightMargin"> - <number>14</number> - </property> - <property name="bottomMargin"> - <number>9</number> - </property> - <item> - <widget class="QTextEdit" name="text_edit_osk"> - <property name="font"> - <font> - <pointsize>26</pointsize> - </font> - </property> - <property name="focusPolicy"> - <enum>Qt::StrongFocus</enum> - </property> - <property name="html"> - <string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:26pt; font-weight:400; font-style:normal;"> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p></body></html></string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </item> - </layout> - </widget> - </widget> - </item> - <item> - <widget class="QStackedWidget" name="bottomOSK"> - <property name="currentIndex"> - <number>0</number> - </property> - <widget class="QWidget" name="normalOSK"> - <layout class="QVBoxLayout" name="normalPageVerticalLayout"> - <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="QGridLayout" name="kbOSKnormal" rowstretch="15,63,63,63,63,63,70" columnstretch="54,96,96,96,96,96,96,96,96,96,96,96,116,54"> - <property name="spacing"> - <number>0</number> - </property> - <item row="6" column="1" colspan="12"> - <widget class="QWidget" name="legendOSK" native="true"> - <layout class="QHBoxLayout" name="horizontalLayout_2" stretch="70,525,25,12,22,41,25,12,22,41,25,12,47,37,29,12,69,37,29,12,56,8"> - <property name="spacing"> - <number>0</number> - </property> - <property name="leftMargin"> - <number>2</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="QWidget" name="icon_controller" native="true"> - <property name="styleSheet"> - <string notr="true"/> - </property> - </widget> - </item> - <item> - <spacer name="horizontalSpacer_5"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>0</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QWidget" name="button_L" native="true"/> - </item> - <item> - <spacer name="horizontalSpacer_14"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>0</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QWidget" name="arrow_left" native="true"/> - </item> - <item> - <spacer name="horizontalSpacer_13"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>0</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QWidget" name="button_R" native="true"/> - </item> - <item> - <spacer name="horizontalSpacer_12"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>0</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QWidget" name="arrow_right" native="true"/> - </item> - <item> - <spacer name="horizontalSpacer_11"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>0</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QWidget" name="button_press_stick" native="true"/> - </item> - <item> - <spacer name="horizontalSpacer_10"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>0</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QLabel" name="label_shift"> - <property name="font"> - <font> - <pointsize>18</pointsize> - </font> - </property> - <property name="text"> - <string notr="true">Shift</string> - </property> - </widget> - </item> - <item> - <spacer name="horizontalSpacer_15"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>0</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QWidget" name="button_X" native="true"/> - </item> - <item> - <spacer name="horizontalSpacer_9"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>0</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QLabel" name="label_cancel"> - <property name="font"> - <font> - <pointsize>18</pointsize> - </font> - </property> - <property name="text"> - <string notr="true">Cancel</string> - </property> - </widget> - </item> - <item> - <spacer name="horizontalSpacer_8"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>0</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QWidget" name="button_A" native="true"/> - </item> - <item> - <spacer name="horizontalSpacer_7"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>0</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QLabel" name="label_enter"> - <property name="font"> - <font> - <pointsize>18</pointsize> - </font> - </property> - <property name="text"> - <string notr="true">Enter</string> - </property> - </widget> - </item> - <item> - <spacer name="horizontalSpacer_6"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>0</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - </item> - <item row="1" column="11"> - <widget class="QPushButton" name="button_minus"> - <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="3" column="11"> - <widget class="QPushButton" name="button_apostrophe"> - <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="2" column="11"> - <widget class="QPushButton" name="button_slash"> - <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="11"> - <widget class="QPushButton" name="button_exclamation"> - <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="7"> - <widget class="QPushButton" name="button_7"> - <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">7</string> - </property> - </widget> - </item> - <item row="1" column="8"> - <widget class="QPushButton" name="button_8"> - <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">8</string> - </property> - </widget> - </item> - <item row="1" column="10"> - <widget class="QPushButton" name="button_0"> - <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">0</string> - </property> - </widget> - </item> - <item row="1" column="9"> - <widget class="QPushButton" name="button_9"> - <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">9</string> - </property> - </widget> - </item> - <item row="2" column="2"> - <widget class="QPushButton" name="button_w"> - <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">w</string> - </property> - </widget> - </item> - <item row="2" column="4"> - <widget class="QPushButton" name="button_r"> - <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">r</string> - </property> - </widget> - </item> - <item row="2" column="3"> - <widget class="QPushButton" name="button_e"> - <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">e</string> - </property> - </widget> - </item> - <item row="2" column="1"> - <widget class="QPushButton" name="button_q"> - <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">q</string> - </property> - </widget> - </item> - <item row="2" column="7"> - <widget class="QPushButton" name="button_u"> - <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">u</string> - </property> - </widget> - </item> - <item row="2" column="6"> - <widget class="QPushButton" name="button_y"> - <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">y</string> - </property> - </widget> - </item> - <item row="2" column="5"> - <widget class="QPushButton" name="button_t"> - <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">t</string> - </property> - </widget> - </item> - <item row="2" column="9"> - <widget class="QPushButton" name="button_o"> - <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">o</string> - </property> - </widget> - </item> - <item row="2" column="10"> - <widget class="QPushButton" name="button_p"> - <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">p</string> - </property> - </widget> - </item> - <item row="2" column="8"> - <widget class="QPushButton" name="button_i"> - <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">i</string> - </property> - </widget> - </item> - <item row="3" column="1"> - <widget class="QPushButton" name="button_a"> - <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">a</string> - </property> - </widget> - </item> - <item row="3" column="2"> - <widget class="QPushButton" name="button_s"> - <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">s</string> - </property> - </widget> - </item> - <item row="3" column="3"> - <widget class="QPushButton" name="button_d"> - <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">d</string> - </property> - </widget> - </item> - <item row="3" column="4"> - <widget class="QPushButton" name="button_f"> - <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">f</string> - </property> - </widget> - </item> - <item row="3" column="6"> - <widget class="QPushButton" name="button_h"> - <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">h</string> - </property> - </widget> - </item> - <item row="3" column="7"> - <widget class="QPushButton" name="button_j"> - <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">j</string> - </property> - </widget> - </item> - <item row="3" column="5"> - <widget class="QPushButton" name="button_g"> - <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">g</string> - </property> - </widget> - </item> - <item row="3" column="8"> - <widget class="QPushButton" name="button_k"> - <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">k</string> - </property> - </widget> - </item> - <item row="3" column="9"> - <widget class="QPushButton" name="button_l"> - <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">l</string> - </property> - </widget> - </item> - <item row="3" column="10"> - <widget class="QPushButton" name="button_colon"> - <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="2" column="12" rowspan="2"> - <widget class="QPushButton" name="button_return"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Expanding"> - <horstretch>1</horstretch> - <verstretch>1</verstretch> - </sizepolicy> - </property> - <property name="font"> - <font> - <pointsize>18</pointsize> - </font> - </property> - <property name="text"> - <string notr="true">Return</string> - </property> - </widget> - </item> - <item row="4" column="12" rowspan="2"> - <widget class="QPushButton" name="button_ok"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Expanding"> - <horstretch>1</horstretch> - <verstretch>1</verstretch> - </sizepolicy> - </property> - <property name="font"> - <font> - <pointsize>18</pointsize> - </font> - </property> - <property name="text"> - <string notr="true">OK</string> - </property> - </widget> - </item> - <item row="4" column="1"> - <widget class="QPushButton" name="button_z"> - <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">z</string> - </property> - </widget> - </item> - <item row="4" column="3"> - <widget class="QPushButton" name="button_c"> - <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">c</string> - </property> - </widget> - </item> - <item row="4" column="2"> - <widget class="QPushButton" name="button_x"> - <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">x</string> - </property> - </widget> - </item> - <item row="4" column="4"> - <widget class="QPushButton" name="button_v"> - <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">v</string> - </property> - </widget> - </item> - <item row="4" column="7"> - <widget class="QPushButton" name="button_m"> - <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">m</string> - </property> - </widget> - </item> - <item row="4" column="8"> - <widget class="QPushButton" name="button_comma"> - <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="6"> - <widget class="QPushButton" name="button_n"> - <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">n</string> - </property> - </widget> - </item> - <item row="4" column="5"> - <widget class="QPushButton" name="button_b"> - <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">b</string> - </property> - </widget> - </item> - <item row="5" column="1" colspan="2"> - <widget class="QPushButton" name="button_shift"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Expanding"> - <horstretch>1</horstretch> - <verstretch>1</verstretch> - </sizepolicy> - </property> - <property name="font"> - <font> - <pointsize>18</pointsize> - </font> - </property> - <property name="text"> - <string notr="true"/> - </property> - <property name="checkable"> - <bool>true</bool> - </property> - <property name="checked"> - <bool>false</bool> - </property> - </widget> - </item> - <item row="4" column="10"> - <widget class="QPushButton" name="button_question"> - <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="9"> - <widget class="QPushButton" name="button_dot"> - <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="1"> - <widget class="QPushButton" name="button_1"> - <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">1</string> - </property> - </widget> - </item> - <item row="1" column="3"> - <widget class="QPushButton" name="button_3"> - <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">3</string> - </property> - </widget> - </item> - <item row="1" column="4"> - <widget class="QPushButton" name="button_4"> - <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">4</string> - </property> - </widget> - </item> - <item row="1" column="2"> - <widget class="QPushButton" name="button_2"> - <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">2</string> - </property> - </widget> - </item> - <item row="1" column="6"> - <widget class="QPushButton" name="button_6"> - <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">6</string> - </property> - </widget> - </item> - <item row="1" column="5"> - <widget class="QPushButton" name="button_5"> - <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">5</string> - </property> - </widget> - </item> - <item row="5" column="3" colspan="9"> - <widget class="QPushButton" name="button_space"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Expanding"> - <horstretch>1</horstretch> - <verstretch>1</verstretch> - </sizepolicy> - </property> - <property name="font"> - <font> - <pointsize>18</pointsize> - </font> - </property> - <property name="text"> - <string notr="true">Space</string> - </property> - </widget> - </item> - <item row="1" column="12"> - <widget class="QPushButton" name="button_backspace"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Expanding"> - <horstretch>1</horstretch> - <verstretch>1</verstretch> - </sizepolicy> - </property> - <property name="font"> - <font> - <pointsize>18</pointsize> - </font> - </property> - <property name="text"> - <string notr="true"/> - </property> - </widget> - </item> - <item row="1" 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"> - <spacer name="verticalSpacer"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>0</height> - </size> - </property> - </spacer> - </item> - <item row="1" column="13"> - <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> - </item> - </layout> - </widget> - <widget class="QWidget" name="shiftOSK"> - <layout class="QVBoxLayout" name="shiftPageVerticalLayout"> - <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="QGridLayout" name="kbOSKshift" rowstretch="15,63,63,63,63,63,70" columnstretch="54,96,96,96,96,96,96,96,96,96,96,96,116,54"> - <property name="spacing"> - <number>0</number> - </property> - <item row="6" column="1" colspan="12"> - <widget class="QWidget" name="legendOSKshift" native="true"> - <layout class="QHBoxLayout" name="horizontalLayout_5" stretch="70,464,25,12,22,41,25,12,22,41,25,12,95,37,29,12,69,37,29,12,56,8"> - <property name="spacing"> - <number>0</number> - </property> - <property name="leftMargin"> - <number>2</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="QWidget" name="icon_controller_shift" native="true"> - <property name="styleSheet"> - <string notr="true"/> - </property> - </widget> - </item> - <item> - <spacer name="horizontalSpacer_22"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>0</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QWidget" name="button_L_shift" native="true"/> - </item> - <item> - <spacer name="horizontalSpacer_23"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>0</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QWidget" name="arrow_left_shift" native="true"/> - </item> - <item> - <spacer name="horizontalSpacer_24"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>0</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QWidget" name="button_R_shift" native="true"/> - </item> - <item> - <spacer name="horizontalSpacer_25"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>0</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QWidget" name="arrow_right_shift" native="true"/> - </item> - <item> - <spacer name="horizontalSpacer_26"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>0</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QWidget" name="button_press_stick_shift" native="true"/> - </item> - <item> - <spacer name="horizontalSpacer_27"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>0</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QLabel" name="label_shift_shift"> - <property name="font"> - <font> - <pointsize>18</pointsize> - </font> - </property> - <property name="text"> - <string notr="true">Caps Lock</string> - </property> - </widget> - </item> - <item> - <spacer name="horizontalSpacer_28"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>0</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QWidget" name="button_X_shift" native="true"/> - </item> - <item> - <spacer name="horizontalSpacer_29"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>0</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QLabel" name="label_cancel_shift"> - <property name="font"> - <font> - <pointsize>18</pointsize> - </font> - </property> - <property name="text"> - <string notr="true">Cancel</string> - </property> - </widget> - </item> - <item> - <spacer name="horizontalSpacer_30"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>0</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QWidget" name="button_A_shift" native="true"/> - </item> - <item> - <spacer name="horizontalSpacer_31"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>0</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QLabel" name="label_enter_shift"> - <property name="font"> - <font> - <pointsize>18</pointsize> - </font> - </property> - <property name="text"> - <string notr="true">Enter</string> - </property> - </widget> - </item> - <item> - <spacer name="horizontalSpacer_32"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>0</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - </item> - <item row="1" column="11"> - <widget class="QPushButton" name="button_underscore"> - <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="3" column="11"> - <widget class="QPushButton" name="button_quotation"> - <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="2" column="11"> - <widget class="QPushButton" name="button_at"> - <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="11"> - <widget class="QPushButton" name="button_equal"> - <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="7"> - <widget class="QPushButton" name="button_ampersand"> - <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="8"> - <widget class="QPushButton" name="button_asterisk"> - <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="10"> - <widget class="QPushButton" name="button_right_parenthesis"> - <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="9"> - <widget class="QPushButton" name="button_left_parenthesis"> - <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="2" column="2"> - <widget class="QPushButton" name="button_w_shift"> - <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">W</string> - </property> - </widget> - </item> - <item row="2" column="4"> - <widget class="QPushButton" name="button_r_shift"> - <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">R</string> - </property> - </widget> - </item> - <item row="2" column="3"> - <widget class="QPushButton" name="button_e_shift"> - <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">E</string> - </property> - </widget> - </item> - <item row="2" column="1"> - <widget class="QPushButton" name="button_q_shift"> - <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">Q</string> - </property> - </widget> - </item> - <item row="2" column="7"> - <widget class="QPushButton" name="button_u_shift"> - <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">U</string> - </property> - </widget> - </item> - <item row="2" column="6"> - <widget class="QPushButton" name="button_y_shift"> - <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">Y</string> - </property> - </widget> - </item> - <item row="2" column="5"> - <widget class="QPushButton" name="button_t_shift"> - <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">T</string> - </property> - </widget> - </item> - <item row="2" column="9"> - <widget class="QPushButton" name="button_o_shift"> - <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">O</string> - </property> - </widget> - </item> - <item row="2" column="10"> - <widget class="QPushButton" name="button_p_shift"> - <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">P</string> - </property> - </widget> - </item> - <item row="2" column="8"> - <widget class="QPushButton" name="button_i_shift"> - <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">I</string> - </property> - </widget> - </item> - <item row="3" column="1"> - <widget class="QPushButton" name="button_a_shift"> - <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">A</string> - </property> - </widget> - </item> - <item row="3" column="2"> - <widget class="QPushButton" name="button_s_shift"> - <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">S</string> - </property> - </widget> - </item> - <item row="3" column="3"> - <widget class="QPushButton" name="button_d_shift"> - <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">D</string> - </property> - </widget> - </item> - <item row="3" column="4"> - <widget class="QPushButton" name="button_f_shift"> - <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">F</string> - </property> - </widget> - </item> - <item row="3" column="6"> - <widget class="QPushButton" name="button_h_shift"> - <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">H</string> - </property> - </widget> - </item> - <item row="3" column="7"> - <widget class="QPushButton" name="button_j_shift"> - <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">J</string> - </property> - </widget> - </item> - <item row="3" column="5"> - <widget class="QPushButton" name="button_g_shift"> - <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">G</string> - </property> - </widget> - </item> - <item row="3" column="8"> - <widget class="QPushButton" name="button_k_shift"> - <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">K</string> - </property> - </widget> - </item> - <item row="3" column="9"> - <widget class="QPushButton" name="button_l_shift"> - <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">L</string> - </property> - </widget> - </item> - <item row="3" column="10"> - <widget class="QPushButton" name="button_semicolon"> - <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="2" column="12" rowspan="2"> - <widget class="QPushButton" name="button_return_shift"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Expanding"> - <horstretch>1</horstretch> - <verstretch>1</verstretch> - </sizepolicy> - </property> - <property name="font"> - <font> - <pointsize>18</pointsize> - </font> - </property> - <property name="text"> - <string notr="true">Return</string> - </property> - </widget> - </item> - <item row="4" column="12" rowspan="2"> - <widget class="QPushButton" name="button_ok_shift"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Expanding"> - <horstretch>1</horstretch> - <verstretch>1</verstretch> - </sizepolicy> - </property> - <property name="font"> - <font> - <pointsize>18</pointsize> - </font> - </property> - <property name="text"> - <string notr="true">OK</string> - </property> - </widget> - </item> - <item row="4" column="1"> - <widget class="QPushButton" name="button_z_shift"> - <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">Z</string> - </property> - </widget> - </item> - <item row="4" column="3"> - <widget class="QPushButton" name="button_c_shift"> - <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">C</string> - </property> - </widget> - </item> - <item row="4" column="2"> - <widget class="QPushButton" name="button_x_shift"> - <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">X</string> - </property> - </widget> - </item> - <item row="4" column="4"> - <widget class="QPushButton" name="button_v_shift"> - <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">V</string> - </property> - </widget> - </item> - <item row="4" column="7"> - <widget class="QPushButton" name="button_m_shift"> - <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">M</string> - </property> - </widget> - </item> - <item row="4" column="8"> - <widget class="QPushButton" name="button_less_than"> - <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="6"> - <widget class="QPushButton" name="button_n_shift"> - <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">N</string> - </property> - </widget> - </item> - <item row="4" column="5"> - <widget class="QPushButton" name="button_b_shift"> - <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">B</string> - </property> - </widget> - </item> - <item row="5" column="1" colspan="2"> - <widget class="QPushButton" name="button_shift_shift"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Expanding"> - <horstretch>1</horstretch> - <verstretch>1</verstretch> - </sizepolicy> - </property> - <property name="font"> - <font> - <pointsize>18</pointsize> - </font> - </property> - <property name="text"> - <string notr="true"/> - </property> - <property name="checkable"> - <bool>true</bool> - </property> - <property name="checked"> - <bool>false</bool> - </property> - </widget> - </item> - <item row="4" column="10"> - <widget class="QPushButton" name="button_plus"> - <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="9"> - <widget class="QPushButton" name="button_greater_than"> - <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="1"> - <widget class="QPushButton" name="button_hash"> - <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="3"> - <widget class="QPushButton" name="button_right_bracket"> - <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_dollar"> - <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="2"> - <widget class="QPushButton" name="button_left_bracket"> - <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="6"> - <widget class="QPushButton" name="button_circumflex"> - <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="5"> - <widget class="QPushButton" name="button_percent"> - <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="5" column="3" colspan="9"> - <widget class="QPushButton" name="button_space_shift"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Expanding"> - <horstretch>1</horstretch> - <verstretch>1</verstretch> - </sizepolicy> - </property> - <property name="font"> - <font> - <pointsize>18</pointsize> - </font> - </property> - <property name="text"> - <string notr="true">Space</string> - </property> - </widget> - </item> - <item row="1" column="12"> - <widget class="QPushButton" name="button_backspace_shift"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Expanding"> - <horstretch>1</horstretch> - <verstretch>1</verstretch> - </sizepolicy> - </property> - <property name="font"> - <font> - <pointsize>18</pointsize> - </font> - </property> - <property name="text"> - <string notr="true"/> - </property> - </widget> - </item> - <item row="1" column="0"> - <spacer name="horizontalSpacer_33"> - <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"> - <spacer name="verticalSpacer_6"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>0</height> - </size> - </property> - </spacer> - </item> - <item row="1" column="13"> - <spacer name="horizontalSpacer_34"> - <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> - </layout> - </widget> - <widget class="QWidget" name="numOSK"> - <layout class="QVBoxLayout" name="graphicsTabVerticalLayout"> - <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="QGridLayout" name="kbOSKnum" rowstretch="18,63,63,63,63,10,70" columnstretch="54,307,186,186,186,120,187,54"> - <property name="leftMargin"> - <number>0</number> - </property> - <property name="rightMargin"> - <number>0</number> - </property> - <property name="spacing"> - <number>0</number> - </property> - <item row="1" column="5"> - <widget class="QPushButton" name="button_backspace_num"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Expanding"> - <horstretch>1</horstretch> - <verstretch>1</verstretch> - </sizepolicy> - </property> - <property name="font"> - <font> - <pointsize>18</pointsize> - </font> - </property> - <property name="text"> - <string notr="true"/> - </property> - </widget> - </item> - <item row="1" column="6"> - <spacer name="horizontalSpacer_35"> - <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="1" column="1"> - <spacer name="horizontalSpacer_36"> - <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="2"> - <spacer name="verticalSpacer_7"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>0</height> - </size> - </property> - </spacer> - </item> - <item row="6" column="1" colspan="6"> - <widget class="QWidget" name="legendOSKnum" native="true"> - <layout class="QHBoxLayout" name="horizontalLayout_6" stretch="25,70,601,25,12,22,41,25,12,22,41,29,12,69,37,29,12,56,30"> - <property name="spacing"> - <number>0</number> - </property> - <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> - <spacer name="horizontalSpacer_48"> - <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="QWidget" name="icon_controller_num" native="true"> - <property name="styleSheet"> - <string notr="true"/> - </property> - </widget> - </item> - <item> - <spacer name="horizontalSpacer_38"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>0</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QWidget" name="button_L_num" native="true"/> - </item> - <item> - <spacer name="horizontalSpacer_39"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>0</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QWidget" name="arrow_left_num" native="true"/> - </item> - <item> - <spacer name="horizontalSpacer_40"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>0</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QWidget" name="button_R_num" native="true"/> - </item> - <item> - <spacer name="horizontalSpacer_41"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>0</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QWidget" name="arrow_right_num" native="true"/> - </item> - <item> - <spacer name="horizontalSpacer_42"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>0</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QWidget" name="button_X_num" native="true"/> - </item> - <item> - <spacer name="horizontalSpacer_43"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>0</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QLabel" name="label_cancel_num"> - <property name="font"> - <font> - <pointsize>18</pointsize> - </font> - </property> - <property name="text"> - <string notr="true">Cancel</string> - </property> - </widget> - </item> - <item> - <spacer name="horizontalSpacer_44"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>0</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QWidget" name="button_A_num" native="true"/> - </item> - <item> - <spacer name="horizontalSpacer_45"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>0</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QLabel" name="label_enter_num"> - <property name="font"> - <font> - <pointsize>18</pointsize> - </font> - </property> - <property name="text"> - <string notr="true">Enter</string> - </property> - </widget> - </item> - <item> - <spacer name="horizontalSpacer_46"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>0</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - </item> - <item row="2" column="4"> - <widget class="QPushButton" name="button_6_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">6</string> - </property> - </widget> - </item> - <item row="2" column="2"> - <widget class="QPushButton" name="button_4_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">4</string> - </property> - </widget> - </item> - <item row="3" column="4"> - <widget class="QPushButton" name="button_9_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">9</string> - </property> - </widget> - </item> - <item row="2" column="3"> - <widget class="QPushButton" name="button_5_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">5</string> - </property> - </widget> - </item> - <item row="2" column="5" rowspan="3"> - <widget class="QPushButton" name="button_ok_num"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Expanding"> - <horstretch>1</horstretch> - <verstretch>1</verstretch> - </sizepolicy> - </property> - <property name="font"> - <font> - <pointsize>18</pointsize> - </font> - </property> - <property name="text"> - <string notr="true">OK</string> - </property> - </widget> - </item> - <item row="3" column="2"> - <widget class="QPushButton" name="button_7_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">7</string> - </property> - </widget> - </item> - <item row="3" column="3"> - <widget class="QPushButton" name="button_8_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">8</string> - </property> - </widget> - </item> - <item row="1" column="3"> - <widget class="QPushButton" name="button_2_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">2</string> - </property> - </widget> - </item> - <item row="1" column="2"> - <widget class="QPushButton" name="button_1_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">1</string> - </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"> - <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">0</string> - </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"> - <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">3</string> - </property> - </widget> - </item> - <item row="1" column="0"> - <spacer name="horizontalSpacer_37"> - <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="1" column="7"> - <spacer name="horizontalSpacer_47"> - <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="5" column="3"> - <spacer name="verticalSpacer_8"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>0</height> - </size> - </property> - </spacer> - </item> - </layout> - </item> - </layout> - </widget> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - <tabstops> - <tabstop>button_1</tabstop> - <tabstop>button_2</tabstop> - <tabstop>button_3</tabstop> - <tabstop>button_4</tabstop> - <tabstop>button_5</tabstop> - <tabstop>button_6</tabstop> - <tabstop>button_7</tabstop> - <tabstop>button_8</tabstop> - <tabstop>button_9</tabstop> - <tabstop>button_0</tabstop> - <tabstop>button_minus</tabstop> - <tabstop>button_backspace</tabstop> - <tabstop>button_q</tabstop> - <tabstop>button_w</tabstop> - <tabstop>button_e</tabstop> - <tabstop>button_r</tabstop> - <tabstop>button_t</tabstop> - <tabstop>button_y</tabstop> - <tabstop>button_u</tabstop> - <tabstop>button_i</tabstop> - <tabstop>button_o</tabstop> - <tabstop>button_p</tabstop> - <tabstop>button_slash</tabstop> - <tabstop>button_return</tabstop> - <tabstop>button_a</tabstop> - <tabstop>button_s</tabstop> - <tabstop>button_d</tabstop> - <tabstop>button_f</tabstop> - <tabstop>button_g</tabstop> - <tabstop>button_h</tabstop> - <tabstop>button_j</tabstop> - <tabstop>button_k</tabstop> - <tabstop>button_l</tabstop> - <tabstop>button_colon</tabstop> - <tabstop>button_apostrophe</tabstop> - <tabstop>button_z</tabstop> - <tabstop>button_x</tabstop> - <tabstop>button_c</tabstop> - <tabstop>button_v</tabstop> - <tabstop>button_b</tabstop> - <tabstop>button_n</tabstop> - <tabstop>button_m</tabstop> - <tabstop>button_comma</tabstop> - <tabstop>button_dot</tabstop> - <tabstop>button_question</tabstop> - <tabstop>button_exclamation</tabstop> - <tabstop>button_ok</tabstop> - <tabstop>button_shift</tabstop> - <tabstop>button_space</tabstop> - <tabstop>button_hash</tabstop> - <tabstop>button_left_bracket</tabstop> - <tabstop>button_right_bracket</tabstop> - <tabstop>button_dollar</tabstop> - <tabstop>button_percent</tabstop> - <tabstop>button_circumflex</tabstop> - <tabstop>button_ampersand</tabstop> - <tabstop>button_asterisk</tabstop> - <tabstop>button_left_parenthesis</tabstop> - <tabstop>button_right_parenthesis</tabstop> - <tabstop>button_underscore</tabstop> - <tabstop>button_backspace_shift</tabstop> - <tabstop>button_q_shift</tabstop> - <tabstop>button_w_shift</tabstop> - <tabstop>button_e_shift</tabstop> - <tabstop>button_r_shift</tabstop> - <tabstop>button_t_shift</tabstop> - <tabstop>button_y_shift</tabstop> - <tabstop>button_u_shift</tabstop> - <tabstop>button_i_shift</tabstop> - <tabstop>button_o_shift</tabstop> - <tabstop>button_p_shift</tabstop> - <tabstop>button_at</tabstop> - <tabstop>button_return_shift</tabstop> - <tabstop>button_a_shift</tabstop> - <tabstop>button_s_shift</tabstop> - <tabstop>button_d_shift</tabstop> - <tabstop>button_f_shift</tabstop> - <tabstop>button_g_shift</tabstop> - <tabstop>button_h_shift</tabstop> - <tabstop>button_j_shift</tabstop> - <tabstop>button_k_shift</tabstop> - <tabstop>button_l_shift</tabstop> - <tabstop>button_semicolon</tabstop> - <tabstop>button_quotation</tabstop> - <tabstop>button_z_shift</tabstop> - <tabstop>button_x_shift</tabstop> - <tabstop>button_c_shift</tabstop> - <tabstop>button_v_shift</tabstop> - <tabstop>button_b_shift</tabstop> - <tabstop>button_n_shift</tabstop> - <tabstop>button_m_shift</tabstop> - <tabstop>button_less_than</tabstop> - <tabstop>button_greater_than</tabstop> - <tabstop>button_plus</tabstop> - <tabstop>button_equal</tabstop> - <tabstop>button_ok_shift</tabstop> - <tabstop>button_shift_shift</tabstop> - <tabstop>button_space_shift</tabstop> - <tabstop>button_1_num</tabstop> - <tabstop>button_2_num</tabstop> - <tabstop>button_3_num</tabstop> - <tabstop>button_backspace_num</tabstop> - <tabstop>button_4_num</tabstop> - <tabstop>button_5_num</tabstop> - <tabstop>button_6_num</tabstop> - <tabstop>button_ok_num</tabstop> - <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"/> - </resources> - <connections/> -</ui> diff --git a/src/yuzu/applets/qt_web_browser.cpp b/src/yuzu/applets/qt_web_browser.cpp deleted file mode 100644 index cce9b2efb..000000000 --- a/src/yuzu/applets/qt_web_browser.cpp +++ /dev/null @@ -1,449 +0,0 @@ -// 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> - -#include <QWebEngineProfile> -#include <QWebEngineScript> -#include <QWebEngineScriptCollection> -#include <QWebEngineSettings> -#include <QWebEngineUrlScheme> - -#include "hid_core/frontend/input_interpreter.h" -#include "yuzu/applets/qt_web_browser_scripts.h" -#endif - -#include "common/fs/path_util.h" -#include "core/core.h" -#include "input_common/drivers/keyboard.h" -#include "yuzu/applets/qt_web_browser.h" -#include "yuzu/main.h" -#include "yuzu/util/url_request_interceptor.h" - -#ifdef YUZU_USE_QT_WEB_ENGINE - -namespace { - -constexpr int HIDButtonToKey(Core::HID::NpadButton button) { - switch (button) { - case Core::HID::NpadButton::Left: - case Core::HID::NpadButton::StickLLeft: - return Qt::Key_Left; - case Core::HID::NpadButton::Up: - case Core::HID::NpadButton::StickLUp: - return Qt::Key_Up; - case Core::HID::NpadButton::Right: - case Core::HID::NpadButton::StickLRight: - return Qt::Key_Right; - case Core::HID::NpadButton::Down: - case Core::HID::NpadButton::StickLDown: - return Qt::Key_Down; - default: - return 0; - } -} - -} // Anonymous namespace - -QtNXWebEngineView::QtNXWebEngineView(QWidget* parent, Core::System& system, - InputCommon::InputSubsystem* input_subsystem_) - : 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{ - default_profile->settings()} { - default_profile->setPersistentStoragePath(QString::fromStdString(Common::FS::PathToUTF8String( - Common::FS::GetYuzuPath(Common::FS::YuzuPath::YuzuDir) / "qtwebengine"))); - - QWebEngineScript gamepad; - QWebEngineScript window_nx; - - gamepad.setName(QStringLiteral("gamepad_script.js")); - window_nx.setName(QStringLiteral("window_nx_script.js")); - - gamepad.setSourceCode(QString::fromStdString(GAMEPAD_SCRIPT)); - window_nx.setSourceCode(QString::fromStdString(WINDOW_NX_SCRIPT)); - - gamepad.setInjectionPoint(QWebEngineScript::DocumentCreation); - window_nx.setInjectionPoint(QWebEngineScript::DocumentCreation); - - gamepad.setWorldId(QWebEngineScript::MainWorld); - window_nx.setWorldId(QWebEngineScript::MainWorld); - - gamepad.setRunsOnSubFrames(true); - window_nx.setRunsOnSubFrames(true); - - default_profile->scripts()->insert(gamepad); - default_profile->scripts()->insert(window_nx); - - default_profile->setUrlRequestInterceptor(url_interceptor.get()); - - global_settings->setAttribute(QWebEngineSettings::LocalContentCanAccessRemoteUrls, true); - global_settings->setAttribute(QWebEngineSettings::FullScreenSupportEnabled, true); - global_settings->setAttribute(QWebEngineSettings::AllowRunningInsecureContent, true); - global_settings->setAttribute(QWebEngineSettings::FocusOnNavigationEnabled, true); - global_settings->setAttribute(QWebEngineSettings::AllowWindowActivationFromJavaScript, true); - global_settings->setAttribute(QWebEngineSettings::ShowScrollBars, false); - - global_settings->setFontFamily(QWebEngineSettings::StandardFont, QStringLiteral("Roboto")); - - connect( - page(), &QWebEnginePage::windowCloseRequested, page(), - [this] { - if (page()->url() == url_interceptor->GetRequestedURL()) { - SetFinished(true); - SetExitReason(Service::AM::Frontend::WebExitReason::WindowClosed); - } - }, - Qt::QueuedConnection); -} - -QtNXWebEngineView::~QtNXWebEngineView() { - SetFinished(true); - StopInputThread(); -} - -void QtNXWebEngineView::LoadLocalWebPage(const std::string& main_url, - const std::string& additional_args) { - is_local = true; - - LoadExtractedFonts(); - FocusFirstLinkElement(); - SetUserAgent(UserAgent::WebApplet); - SetFinished(false); - SetExitReason(Service::AM::Frontend::WebExitReason::EndButtonPressed); - SetLastURL("http://localhost/"); - StartInputThread(); - - load(QUrl(QUrl::fromLocalFile(QString::fromStdString(main_url)).toString() + - QString::fromStdString(additional_args))); -} - -void QtNXWebEngineView::LoadExternalWebPage(const std::string& main_url, - const std::string& additional_args) { - is_local = false; - - FocusFirstLinkElement(); - SetUserAgent(UserAgent::WebApplet); - SetFinished(false); - SetExitReason(Service::AM::Frontend::WebExitReason::EndButtonPressed); - SetLastURL("http://localhost/"); - StartInputThread(); - - load(QUrl(QString::fromStdString(main_url) + QString::fromStdString(additional_args))); -} - -void QtNXWebEngineView::SetUserAgent(UserAgent user_agent) { - const QString user_agent_str = [user_agent] { - switch (user_agent) { - case UserAgent::WebApplet: - default: - return QStringLiteral("WebApplet"); - case UserAgent::ShopN: - return QStringLiteral("ShopN"); - case UserAgent::LoginApplet: - return QStringLiteral("LoginApplet"); - case UserAgent::ShareApplet: - return QStringLiteral("ShareApplet"); - case UserAgent::LobbyApplet: - return QStringLiteral("LobbyApplet"); - case UserAgent::WifiWebAuthApplet: - return QStringLiteral("WifiWebAuthApplet"); - } - }(); - - QWebEngineProfile::defaultProfile()->setHttpUserAgent( - QStringLiteral("Mozilla/5.0 (Nintendo Switch; %1) AppleWebKit/606.4 " - "(KHTML, like Gecko) NF/6.0.1.15.4 NintendoBrowser/5.1.0.20389") - .arg(user_agent_str)); -} - -bool QtNXWebEngineView::IsFinished() const { - return finished; -} - -void QtNXWebEngineView::SetFinished(bool finished_) { - finished = finished_; -} - -Service::AM::Frontend::WebExitReason QtNXWebEngineView::GetExitReason() const { - return exit_reason; -} - -void QtNXWebEngineView::SetExitReason(Service::AM::Frontend::WebExitReason exit_reason_) { - exit_reason = exit_reason_; -} - -const std::string& QtNXWebEngineView::GetLastURL() const { - return last_url; -} - -void QtNXWebEngineView::SetLastURL(std::string last_url_) { - last_url = std::move(last_url_); -} - -QString QtNXWebEngineView::GetCurrentURL() const { - return url_interceptor->GetRequestedURL().toString(); -} - -void QtNXWebEngineView::hide() { - SetFinished(true); - StopInputThread(); - - QWidget::hide(); -} - -void QtNXWebEngineView::keyPressEvent(QKeyEvent* event) { - if (is_local) { - input_subsystem->GetKeyboard()->PressKey(event->key()); - } -} - -void QtNXWebEngineView::keyReleaseEvent(QKeyEvent* event) { - if (is_local) { - input_subsystem->GetKeyboard()->ReleaseKey(event->key()); - } -} - -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(button_index), - [this, button](const QVariant& variant) { - if (variant.toBool()) { - switch (button) { - case Core::HID::NpadButton::A: - SendMultipleKeyPressEvents<Qt::Key_A, Qt::Key_Space, Qt::Key_Return>(); - break; - case Core::HID::NpadButton::B: - SendKeyPressEvent(Qt::Key_B); - break; - case Core::HID::NpadButton::X: - SendKeyPressEvent(Qt::Key_X); - break; - case Core::HID::NpadButton::Y: - SendKeyPressEvent(Qt::Key_Y); - break; - default: - break; - } - } - }); - - page()->runJavaScript( - QStringLiteral("if (yuzu_key_callbacks[%1] != null) { yuzu_key_callbacks[%1](); }") - .arg(button_index)); - } - }; - - (f(T), ...); -} - -template <Core::HID::NpadButton... T> -void QtNXWebEngineView::HandleWindowKeyButtonPressedOnce() { - const auto f = [this](Core::HID::NpadButton button) { - if (input_interpreter->IsButtonPressedOnce(button)) { - SendKeyPressEvent(HIDButtonToKey(button)); - } - }; - - (f(T), ...); -} - -template <Core::HID::NpadButton... T> -void QtNXWebEngineView::HandleWindowKeyButtonHold() { - const auto f = [this](Core::HID::NpadButton button) { - if (input_interpreter->IsButtonHeld(button)) { - SendKeyPressEvent(HIDButtonToKey(button)); - } - }; - - (f(T), ...); -} - -void QtNXWebEngineView::SendKeyPressEvent(int key) { - if (key == 0) { - return; - } - - QCoreApplication::postEvent(focusProxy(), - new QKeyEvent(QKeyEvent::KeyPress, key, Qt::NoModifier)); - QCoreApplication::postEvent(focusProxy(), - new QKeyEvent(QKeyEvent::KeyRelease, key, Qt::NoModifier)); -} - -void QtNXWebEngineView::StartInputThread() { - if (input_thread_running) { - return; - } - - input_thread_running = true; - input_thread = std::thread(&QtNXWebEngineView::InputThread, this); -} - -void QtNXWebEngineView::StopInputThread() { - if (is_local) { - QWidget::releaseKeyboard(); - } - - input_thread_running = false; - if (input_thread.joinable()) { - input_thread.join(); - } -} - -void QtNXWebEngineView::InputThread() { - // Wait for 1 second before allowing any inputs to be processed. - std::this_thread::sleep_for(std::chrono::seconds(1)); - - if (is_local) { - QWidget::grabKeyboard(); - } - - while (input_thread_running) { - input_interpreter->PollInput(); - - HandleWindowFooterButtonPressedOnce<Core::HID::NpadButton::A, Core::HID::NpadButton::B, - Core::HID::NpadButton::X, Core::HID::NpadButton::Y, - Core::HID::NpadButton::L, Core::HID::NpadButton::R>(); - - HandleWindowKeyButtonPressedOnce< - Core::HID::NpadButton::Left, Core::HID::NpadButton::Up, Core::HID::NpadButton::Right, - Core::HID::NpadButton::Down, Core::HID::NpadButton::StickLLeft, - Core::HID::NpadButton::StickLUp, Core::HID::NpadButton::StickLRight, - Core::HID::NpadButton::StickLDown>(); - - HandleWindowKeyButtonHold< - Core::HID::NpadButton::Left, Core::HID::NpadButton::Up, Core::HID::NpadButton::Right, - Core::HID::NpadButton::Down, Core::HID::NpadButton::StickLLeft, - Core::HID::NpadButton::StickLUp, Core::HID::NpadButton::StickLRight, - Core::HID::NpadButton::StickLDown>(); - - std::this_thread::sleep_for(std::chrono::milliseconds(50)); - } -} - -void QtNXWebEngineView::LoadExtractedFonts() { - QWebEngineScript nx_font_css; - QWebEngineScript load_nx_font; - - auto fonts_dir_str = Common::FS::PathToUTF8String( - Common::FS::GetYuzuPath(Common::FS::YuzuPath::CacheDir) / "fonts/"); - - std::replace(fonts_dir_str.begin(), fonts_dir_str.end(), '\\', '/'); - - const auto fonts_dir = QString::fromStdString(fonts_dir_str); - - nx_font_css.setName(QStringLiteral("nx_font_css.js")); - load_nx_font.setName(QStringLiteral("load_nx_font.js")); - - nx_font_css.setSourceCode( - QString::fromStdString(NX_FONT_CSS) - .arg(fonts_dir + QStringLiteral("FontStandard.ttf")) - .arg(fonts_dir + QStringLiteral("FontChineseSimplified.ttf")) - .arg(fonts_dir + QStringLiteral("FontExtendedChineseSimplified.ttf")) - .arg(fonts_dir + QStringLiteral("FontChineseTraditional.ttf")) - .arg(fonts_dir + QStringLiteral("FontKorean.ttf")) - .arg(fonts_dir + QStringLiteral("FontNintendoExtended.ttf")) - .arg(fonts_dir + QStringLiteral("FontNintendoExtended2.ttf"))); - load_nx_font.setSourceCode(QString::fromStdString(LOAD_NX_FONT)); - - nx_font_css.setInjectionPoint(QWebEngineScript::DocumentReady); - load_nx_font.setInjectionPoint(QWebEngineScript::Deferred); - - nx_font_css.setWorldId(QWebEngineScript::MainWorld); - load_nx_font.setWorldId(QWebEngineScript::MainWorld); - - nx_font_css.setRunsOnSubFrames(true); - load_nx_font.setRunsOnSubFrames(true); - - default_profile->scripts()->insert(nx_font_css); - default_profile->scripts()->insert(load_nx_font); - - connect( - url_interceptor.get(), &UrlRequestInterceptor::FrameChanged, url_interceptor.get(), - [this] { - std::this_thread::sleep_for(std::chrono::milliseconds(50)); - page()->runJavaScript(QString::fromStdString(LOAD_NX_FONT)); - }, - Qt::QueuedConnection); -} - -void QtNXWebEngineView::FocusFirstLinkElement() { - QWebEngineScript focus_link_element; - - focus_link_element.setName(QStringLiteral("focus_link_element.js")); - focus_link_element.setSourceCode(QString::fromStdString(FOCUS_LINK_ELEMENT_SCRIPT)); - focus_link_element.setWorldId(QWebEngineScript::MainWorld); - focus_link_element.setInjectionPoint(QWebEngineScript::Deferred); - focus_link_element.setRunsOnSubFrames(true); - default_profile->scripts()->insert(focus_link_element); -} - -#endif - -QtWebBrowser::QtWebBrowser(GMainWindow& main_window) { - connect(this, &QtWebBrowser::MainWindowOpenWebPage, &main_window, - &GMainWindow::WebBrowserOpenWebPage, Qt::QueuedConnection); - connect(this, &QtWebBrowser::MainWindowRequestExit, &main_window, - &GMainWindow::WebBrowserRequestExit, Qt::QueuedConnection); - connect(&main_window, &GMainWindow::WebBrowserExtractOfflineRomFS, this, - &QtWebBrowser::MainWindowExtractOfflineRomFS, Qt::QueuedConnection); - connect(&main_window, &GMainWindow::WebBrowserClosed, this, - &QtWebBrowser::MainWindowWebBrowserClosed, Qt::QueuedConnection); -} - -QtWebBrowser::~QtWebBrowser() = default; - -void QtWebBrowser::Close() const { - callback = {}; - emit MainWindowRequestExit(); -} - -void QtWebBrowser::OpenLocalWebPage(const std::string& local_url, - ExtractROMFSCallback extract_romfs_callback_, - OpenWebPageCallback callback_) const { - extract_romfs_callback = std::move(extract_romfs_callback_); - callback = std::move(callback_); - - const auto index = local_url.find('?'); - - if (index == std::string::npos) { - emit MainWindowOpenWebPage(local_url, "", true); - } else { - emit MainWindowOpenWebPage(local_url.substr(0, index), local_url.substr(index), true); - } -} - -void QtWebBrowser::OpenExternalWebPage(const std::string& external_url, - OpenWebPageCallback callback_) const { - callback = std::move(callback_); - - const auto index = external_url.find('?'); - - if (index == std::string::npos) { - emit MainWindowOpenWebPage(external_url, "", false); - } else { - emit MainWindowOpenWebPage(external_url.substr(0, index), external_url.substr(index), - false); - } -} - -void QtWebBrowser::MainWindowExtractOfflineRomFS() { - extract_romfs_callback(); -} - -void QtWebBrowser::MainWindowWebBrowserClosed(Service::AM::Frontend::WebExitReason exit_reason, - std::string last_url) { - if (callback) { - callback(exit_reason, last_url); - } -} diff --git a/src/yuzu/applets/qt_web_browser.h b/src/yuzu/applets/qt_web_browser.h deleted file mode 100644 index e8a0b6931..000000000 --- a/src/yuzu/applets/qt_web_browser.h +++ /dev/null @@ -1,220 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include <atomic> -#include <thread> - -#include <QObject> - -#ifdef YUZU_USE_QT_WEB_ENGINE -#include <QWebEngineView> -#endif - -#include "core/frontend/applets/web_browser.h" - -class GMainWindow; -class InputInterpreter; -class UrlRequestInterceptor; - -namespace Core { -class System; -} - -namespace Core::HID { -enum class NpadButton : u64; -} - -namespace InputCommon { -class InputSubsystem; -} - -#ifdef YUZU_USE_QT_WEB_ENGINE - -enum class UserAgent { - WebApplet, - ShopN, - LoginApplet, - ShareApplet, - LobbyApplet, - WifiWebAuthApplet, -}; - -class QWebEngineProfile; -class QWebEngineSettings; - -class QtNXWebEngineView : public QWebEngineView { - Q_OBJECT - -public: - explicit QtNXWebEngineView(QWidget* parent, Core::System& system, - InputCommon::InputSubsystem* input_subsystem_); - ~QtNXWebEngineView() override; - - /** - * Loads a HTML document that exists locally. Cannot be used to load external websites. - * - * @param main_url The url to the file. - * @param additional_args Additional arguments appended to the main url. - */ - void LoadLocalWebPage(const std::string& main_url, const std::string& additional_args); - - /** - * Loads an external website. Cannot be used to load local urls. - * - * @param main_url The url to the website. - * @param additional_args Additional arguments appended to the main url. - */ - void LoadExternalWebPage(const std::string& main_url, const std::string& additional_args); - - /** - * Sets the background color of the web page. - * - * @param color The color to set. - */ - void SetBackgroundColor(QColor color); - - /** - * Sets the user agent of the web browser. - * - * @param user_agent The user agent enum. - */ - void SetUserAgent(UserAgent user_agent); - - [[nodiscard]] bool IsFinished() const; - void SetFinished(bool finished_); - - [[nodiscard]] Service::AM::Frontend::WebExitReason GetExitReason() const; - void SetExitReason(Service::AM::Frontend::WebExitReason exit_reason_); - - [[nodiscard]] const std::string& GetLastURL() const; - void SetLastURL(std::string last_url_); - - /** - * This gets the current URL that has been requested by the webpage. - * This only applies to the main frame. Sub frames and other resources are ignored. - * - * @return Currently requested URL - */ - [[nodiscard]] QString GetCurrentURL() const; - -public slots: - void hide(); - -protected: - void keyPressEvent(QKeyEvent* event) override; - void keyReleaseEvent(QKeyEvent* event) override; - -private: - /** - * Handles button presses to execute functions assigned in yuzu_key_callbacks. - * yuzu_key_callbacks contains specialized functions for the buttons in the window footer - * that can be overridden by games to achieve desired functionality. - * - * @tparam HIDButton The list of buttons contained in yuzu_key_callbacks - */ - template <Core::HID::NpadButton... T> - void HandleWindowFooterButtonPressedOnce(); - - /** - * Handles button presses and converts them into keyboard input. - * This should only be used to convert D-Pad or Analog Stick input into arrow keys. - * - * @tparam HIDButton The list of buttons that can be converted into keyboard input. - */ - template <Core::HID::NpadButton... T> - void HandleWindowKeyButtonPressedOnce(); - - /** - * Handles button holds and converts them into keyboard input. - * This should only be used to convert D-Pad or Analog Stick input into arrow keys. - * - * @tparam HIDButton The list of buttons that can be converted into keyboard input. - */ - template <Core::HID::NpadButton... T> - void HandleWindowKeyButtonHold(); - - /** - * Sends a key press event to QWebEngineView. - * - * @param key Qt key code. - */ - void SendKeyPressEvent(int key); - - /** - * Sends multiple key press events to QWebEngineView. - * - * @tparam int Qt key code. - */ - template <int... T> - void SendMultipleKeyPressEvents() { - (SendKeyPressEvent(T), ...); - } - - void StartInputThread(); - void StopInputThread(); - - /// The thread where input is being polled and processed. - void InputThread(); - - /// Loads the extracted fonts using JavaScript. - void LoadExtractedFonts(); - - /// Brings focus to the first available link element. - void FocusFirstLinkElement(); - - InputCommon::InputSubsystem* input_subsystem; - - std::unique_ptr<UrlRequestInterceptor> url_interceptor; - - std::unique_ptr<InputInterpreter> input_interpreter; - - std::thread input_thread; - - std::atomic<bool> input_thread_running{}; - - std::atomic<bool> finished{}; - - Service::AM::Frontend::WebExitReason exit_reason{ - Service::AM::Frontend::WebExitReason::EndButtonPressed}; - - std::string last_url{"http://localhost/"}; - - bool is_local{}; - - QWebEngineProfile* default_profile; - QWebEngineSettings* global_settings; -}; - -#endif - -class QtWebBrowser final : public QObject, public Core::Frontend::WebBrowserApplet { - Q_OBJECT - -public: - explicit QtWebBrowser(GMainWindow& parent); - ~QtWebBrowser() override; - - void Close() const override; - void OpenLocalWebPage(const std::string& local_url, - ExtractROMFSCallback extract_romfs_callback_, - OpenWebPageCallback callback_) const override; - - void OpenExternalWebPage(const std::string& external_url, - OpenWebPageCallback callback_) const override; - -signals: - void MainWindowOpenWebPage(const std::string& main_url, const std::string& additional_args, - bool is_local) const; - void MainWindowRequestExit() const; - -private: - void MainWindowExtractOfflineRomFS(); - - void MainWindowWebBrowserClosed(Service::AM::Frontend::WebExitReason exit_reason, - std::string last_url); - - mutable ExtractROMFSCallback extract_romfs_callback; - mutable OpenWebPageCallback callback; -}; diff --git a/src/yuzu/applets/qt_web_browser_scripts.h b/src/yuzu/applets/qt_web_browser_scripts.h deleted file mode 100644 index f5530c38f..000000000 --- a/src/yuzu/applets/qt_web_browser_scripts.h +++ /dev/null @@ -1,198 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -constexpr char NX_FONT_CSS[] = R"( -(function() { - css = document.createElement('style'); - css.type = 'text/css'; - css.id = 'nx_font'; - css.innerText = ` -/* FontStandard */ -@font-face { - font-family: 'FontStandard'; - src: url('%1') format('truetype'); -} - -/* FontChineseSimplified */ -@font-face { - font-family: 'FontChineseSimplified'; - src: url('%2') format('truetype'); -} - -/* FontExtendedChineseSimplified */ -@font-face { - font-family: 'FontExtendedChineseSimplified'; - src: url('%3') format('truetype'); -} - -/* FontChineseTraditional */ -@font-face { - font-family: 'FontChineseTraditional'; - src: url('%4') format('truetype'); -} - -/* FontKorean */ -@font-face { - font-family: 'FontKorean'; - src: url('%5') format('truetype'); -} - -/* FontNintendoExtended */ -@font-face { - font-family: 'NintendoExt003'; - src: url('%6') format('truetype'); -} - -/* FontNintendoExtended2 */ -@font-face { - font-family: 'NintendoExt003'; - src: url('%7') format('truetype'); -} -`; - - document.head.appendChild(css); -})(); -)"; - -constexpr char LOAD_NX_FONT[] = R"( -(function() { - var elements = document.querySelectorAll("*"); - - for (var i = 0; i < elements.length; i++) { - var style = window.getComputedStyle(elements[i], null); - if (style.fontFamily.includes("Arial") || style.fontFamily.includes("Calibri") || - style.fontFamily.includes("Century") || style.fontFamily.includes("Times New Roman")) { - elements[i].style.fontFamily = "FontStandard, FontChineseSimplified, FontExtendedChineseSimplified, FontChineseTraditional, FontKorean, NintendoExt003"; - } else { - elements[i].style.fontFamily = style.fontFamily + ", FontStandard, FontChineseSimplified, FontExtendedChineseSimplified, FontChineseTraditional, FontKorean, NintendoExt003"; - } - } -})(); -)"; - -constexpr char FOCUS_LINK_ELEMENT_SCRIPT[] = R"( -if (document.getElementsByTagName("a").length > 0) { - document.getElementsByTagName("a")[0].focus(); -} -)"; - -constexpr char GAMEPAD_SCRIPT[] = R"( -window.addEventListener("gamepadconnected", function(e) { - console.log("Gamepad connected at index %d: %s. %d buttons, %d axes.", - e.gamepad.index, e.gamepad.id, e.gamepad.buttons.length, e.gamepad.axes.length); -}); - -window.addEventListener("gamepaddisconnected", function(e) { - console.log("Gamepad disconnected from index %d: %s", e.gamepad.index, e.gamepad.id); -}); -)"; - -constexpr char WINDOW_NX_SCRIPT[] = R"( -var end_applet = false; -var yuzu_key_callbacks = []; - -(function() { - class WindowNX { - constructor() { - yuzu_key_callbacks[1] = function() { window.history.back(); }; - yuzu_key_callbacks[2] = function() { window.nx.endApplet(); }; - } - - addEventListener(type, listener, options) { - console.log("nx.addEventListener called, type=%s", type); - - window.addEventListener(type, listener, options); - } - - endApplet() { - console.log("nx.endApplet called"); - - end_applet = true; - } - - playSystemSe(system_se) { - console.log("nx.playSystemSe is not implemented, system_se=%s", system_se); - } - - sendMessage(message) { - console.log("nx.sendMessage is not implemented, message=%s", message); - } - - setCursorScrollSpeed(scroll_speed) { - console.log("nx.setCursorScrollSpeed is not implemented, scroll_speed=%d", scroll_speed); - } - } - - class WindowNXFooter { - setAssign(key, label, func, option) { - console.log("nx.footer.setAssign called, key=%s", key); - - switch (key) { - case "A": - yuzu_key_callbacks[0] = func; - break; - case "B": - yuzu_key_callbacks[1] = func; - break; - case "X": - yuzu_key_callbacks[2] = func; - break; - case "Y": - yuzu_key_callbacks[3] = func; - break; - case "L": - yuzu_key_callbacks[6] = func; - break; - case "R": - yuzu_key_callbacks[7] = func; - break; - } - } - - setFixed(kind) { - console.log("nx.footer.setFixed is not implemented, kind=%s", kind); - } - - unsetAssign(key) { - console.log("nx.footer.unsetAssign called, key=%s", key); - - switch (key) { - case "A": - yuzu_key_callbacks[0] = function() {}; - break; - case "B": - yuzu_key_callbacks[1] = function() {}; - break; - case "X": - yuzu_key_callbacks[2] = function() {}; - break; - case "Y": - yuzu_key_callbacks[3] = function() {}; - break; - case "L": - yuzu_key_callbacks[6] = function() {}; - break; - case "R": - yuzu_key_callbacks[7] = function() {}; - break; - } - } - } - - class WindowNXPlayReport { - incrementCounter(counter_id) { - console.log("nx.playReport.incrementCounter is not implemented, counter_id=%d", counter_id); - } - - setCounterSetIdentifier(counter_id) { - console.log("nx.playReport.setCounterSetIdentifier is not implemented, counter_id=%d", counter_id); - } - } - - window.nx = new WindowNX(); - window.nx.footer = new WindowNXFooter(); - window.nx.playReport = new WindowNXPlayReport(); -})(); -)"; diff --git a/src/yuzu/bootmanager.cpp b/src/yuzu/bootmanager.cpp deleted file mode 100644 index ed5750155..000000000 --- a/src/yuzu/bootmanager.cpp +++ /dev/null @@ -1,1140 +0,0 @@ -// SPDX-FileCopyrightText: 2014 Citra Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include <algorithm> -#include <array> -#include <cmath> -#include <cstring> -#include <string> -#include <tuple> -#include <type_traits> -#include <glad/glad.h> - -#include <QtCore/qglobal.h> -#include "common/settings_enums.h" -#include "uisettings.h" -#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) && YUZU_USE_QT_MULTIMEDIA -#include <QCamera> -#include <QCameraImageCapture> -#include <QCameraInfo> -#endif -#include <QCursor> -#include <QEvent> -#include <QGuiApplication> -#include <QHBoxLayout> -#include <QKeyEvent> -#include <QLayout> -#include <QList> -#include <QMessageBox> -#include <QScreen> -#include <QSize> -#include <QStringLiteral> -#include <QSurfaceFormat> -#include <QWindow> -#include <QtCore/qobjectdefs.h> - -#ifdef HAS_OPENGL -#include <QOffscreenSurface> -#include <QOpenGLContext> -#endif - -#include "common/microprofile.h" -#include "common/polyfill_thread.h" -#include "common/scm_rev.h" -#include "common/settings.h" -#include "common/settings_input.h" -#include "common/thread.h" -#include "core/core.h" -#include "core/cpu_manager.h" -#include "core/frontend/framebuffer_layout.h" -#include "core/frontend/graphics_context.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/gpu.h" -#include "video_core/rasterizer_interface.h" -#include "video_core/renderer_base.h" -#include "yuzu/bootmanager.h" -#include "yuzu/main.h" -#include "yuzu/qt_common.h" - -class QObject; -class QPaintEngine; -class QSurface; - -constexpr int default_mouse_constrain_timeout = 10; - -EmuThread::EmuThread(Core::System& system) : m_system{system} {} - -EmuThread::~EmuThread() = default; - -void EmuThread::run() { - const char* name = "EmuControlThread"; - MicroProfileOnThreadCreate(name); - Common::SetCurrentThreadName(name); - - auto& gpu = m_system.GPU(); - auto stop_token = m_stop_source.get_token(); - - m_system.RegisterHostThread(); - - // Main process has been loaded. Make the context current to this thread and begin GPU and CPU - // execution. - gpu.ObtainContext(); - - emit LoadProgress(VideoCore::LoadCallbackStage::Prepare, 0, 0); - if (Settings::values.use_disk_shader_cache.GetValue()) { - m_system.Renderer().ReadRasterizer()->LoadDiskResources( - m_system.GetApplicationProcessProgramID(), stop_token, - [this](VideoCore::LoadCallbackStage stage, std::size_t value, std::size_t total) { - emit LoadProgress(stage, value, total); - }); - } - emit LoadProgress(VideoCore::LoadCallbackStage::Complete, 0, 0); - - gpu.ReleaseContext(); - gpu.Start(); - - m_system.GetCpuManager().OnGpuReady(); - - if (m_system.DebuggerEnabled()) { - m_system.InitializeDebugger(); - } - - while (!stop_token.stop_requested()) { - std::unique_lock lk{m_should_run_mutex}; - if (m_should_run) { - m_system.Run(); - m_stopped.Reset(); - - Common::CondvarWait(m_should_run_cv, lk, stop_token, [&] { return !m_should_run; }); - } else { - m_system.Pause(); - m_stopped.Set(); - - EmulationPaused(lk); - Common::CondvarWait(m_should_run_cv, lk, stop_token, [&] { return m_should_run; }); - EmulationResumed(lk); - } - } - - // Shutdown the main emulated process - m_system.DetachDebugger(); - m_system.ShutdownMainProcess(); - -#if MICROPROFILE_ENABLED - MicroProfileOnThreadExit(); -#endif -} - -// Unlock while emitting signals so that the main thread can -// continue pumping events. - -void EmuThread::EmulationPaused(std::unique_lock<std::mutex>& lk) { - lk.unlock(); - emit DebugModeEntered(); - lk.lock(); -} - -void EmuThread::EmulationResumed(std::unique_lock<std::mutex>& lk) { - lk.unlock(); - emit DebugModeLeft(); - lk.lock(); -} - -#ifdef HAS_OPENGL -class OpenGLSharedContext : public Core::Frontend::GraphicsContext { -public: - /// Create the original context that should be shared from - explicit OpenGLSharedContext(QSurface* surface_) : surface{surface_} { - QSurfaceFormat format; - format.setVersion(4, 6); - format.setProfile(QSurfaceFormat::CompatibilityProfile); - format.setOption(QSurfaceFormat::FormatOption::DeprecatedFunctions); - if (Settings::values.renderer_debug) { - format.setOption(QSurfaceFormat::FormatOption::DebugContext); - } - // TODO: expose a setting for buffer value (ie default/single/double/triple) - format.setSwapBehavior(QSurfaceFormat::DefaultSwapBehavior); - format.setSwapInterval(0); - - context = std::make_unique<QOpenGLContext>(); - context->setFormat(format); - if (!context->create()) { - LOG_ERROR(Frontend, "Unable to create main openGL context"); - } - } - - /// Create the shared contexts for rendering and presentation - explicit OpenGLSharedContext(QOpenGLContext* share_context, QSurface* main_surface = nullptr) { - - // disable vsync for any shared contexts - auto format = share_context->format(); - const int swap_interval = - Settings::values.vsync_mode.GetValue() == Settings::VSyncMode::Immediate ? 0 : 1; - - format.setSwapInterval(main_surface ? swap_interval : 0); - - context = std::make_unique<QOpenGLContext>(); - context->setShareContext(share_context); - context->setFormat(format); - if (!context->create()) { - LOG_ERROR(Frontend, "Unable to create shared openGL context"); - } - - if (!main_surface) { - offscreen_surface = std::make_unique<QOffscreenSurface>(nullptr); - offscreen_surface->setFormat(format); - offscreen_surface->create(); - surface = offscreen_surface.get(); - } else { - surface = main_surface; - } - } - - ~OpenGLSharedContext() { - DoneCurrent(); - } - - void SwapBuffers() override { - context->swapBuffers(surface); - } - - void MakeCurrent() override { - // We can't track the current state of the underlying context in this wrapper class because - // Qt may make the underlying context not current for one reason or another. In particular, - // the WebBrowser uses GL, so it seems to conflict if we aren't careful. - // Instead of always just making the context current (which does not have any caching to - // check if the underlying context is already current) we can check for the current context - // in the thread local data by calling `currentContext()` and checking if its ours. - if (QOpenGLContext::currentContext() != context.get()) { - context->makeCurrent(surface); - } - } - - void DoneCurrent() override { - context->doneCurrent(); - } - - QOpenGLContext* GetShareContext() { - return context.get(); - } - - const QOpenGLContext* GetShareContext() const { - return context.get(); - } - -private: - // Avoid using Qt parent system here since we might move the QObjects to new threads - // As a note, this means we should avoid using slots/signals with the objects too - std::unique_ptr<QOpenGLContext> context; - std::unique_ptr<QOffscreenSurface> offscreen_surface{}; - QSurface* surface; -}; -#endif - -class DummyContext : public Core::Frontend::GraphicsContext {}; - -class RenderWidget : public QWidget { -public: - explicit RenderWidget(GRenderWindow* parent) : QWidget(parent), render_window(parent) { - setAttribute(Qt::WA_NativeWindow); - setAttribute(Qt::WA_PaintOnScreen); - if (QtCommon::GetWindowSystemType() == Core::Frontend::WindowSystemType::Wayland) { - setAttribute(Qt::WA_DontCreateNativeAncestors); - } - } - - virtual ~RenderWidget() = default; - - QPaintEngine* paintEngine() const override { - return nullptr; - } - -private: - GRenderWindow* render_window; -}; - -struct OpenGLRenderWidget : public RenderWidget { - explicit OpenGLRenderWidget(GRenderWindow* parent) : RenderWidget(parent) { - windowHandle()->setSurfaceType(QWindow::OpenGLSurface); - } - - void SetContext(std::unique_ptr<Core::Frontend::GraphicsContext>&& context_) { - context = std::move(context_); - } - -private: - std::unique_ptr<Core::Frontend::GraphicsContext> context; -}; - -struct VulkanRenderWidget : public RenderWidget { - explicit VulkanRenderWidget(GRenderWindow* parent) : RenderWidget(parent) { - windowHandle()->setSurfaceType(QWindow::VulkanSurface); - } -}; - -struct NullRenderWidget : public RenderWidget { - explicit NullRenderWidget(GRenderWindow* parent) : RenderWidget(parent) {} -}; - -GRenderWindow::GRenderWindow(GMainWindow* parent, EmuThread* emu_thread_, - std::shared_ptr<InputCommon::InputSubsystem> input_subsystem_, - Core::System& system_) - : QWidget(parent), - emu_thread(emu_thread_), input_subsystem{std::move(input_subsystem_)}, system{system_} { - setWindowTitle(QStringLiteral("yuzu %1 | %2-%3") - .arg(QString::fromUtf8(Common::g_build_name), - QString::fromUtf8(Common::g_scm_branch), - QString::fromUtf8(Common::g_scm_desc))); - setAttribute(Qt::WA_AcceptTouchEvents); - auto* layout = new QHBoxLayout(this); - layout->setContentsMargins(0, 0, 0, 0); - setLayout(layout); - input_subsystem->Initialize(); - this->setMouseTracking(true); - - strict_context_required = QGuiApplication::platformName() == QStringLiteral("wayland") || - QGuiApplication::platformName() == QStringLiteral("wayland-egl"); - - connect(this, &GRenderWindow::FirstFrameDisplayed, parent, &GMainWindow::OnLoadComplete); - connect(this, &GRenderWindow::ExecuteProgramSignal, parent, &GMainWindow::OnExecuteProgram, - Qt::QueuedConnection); - connect(this, &GRenderWindow::ExitSignal, parent, &GMainWindow::OnExit, Qt::QueuedConnection); - connect(this, &GRenderWindow::TasPlaybackStateChanged, parent, &GMainWindow::OnTasStateChanged); - - mouse_constrain_timer.setInterval(default_mouse_constrain_timeout); - connect(&mouse_constrain_timer, &QTimer::timeout, this, &GRenderWindow::ConstrainMouse); -} - -void GRenderWindow::ExecuteProgram(std::size_t program_index) { - emit ExecuteProgramSignal(program_index); -} - -void GRenderWindow::Exit() { - emit ExitSignal(); -} - -GRenderWindow::~GRenderWindow() { - input_subsystem->Shutdown(); -} - -void GRenderWindow::OnFrameDisplayed() { - input_subsystem->GetTas()->UpdateThread(); - const InputCommon::TasInput::TasState new_tas_state = - std::get<0>(input_subsystem->GetTas()->GetStatus()); - - if (!first_frame) { - last_tas_state = new_tas_state; - first_frame = true; - emit FirstFrameDisplayed(); - } - - if (new_tas_state != last_tas_state) { - last_tas_state = new_tas_state; - emit TasPlaybackStateChanged(); - } -} - -bool GRenderWindow::IsShown() const { - return !isMinimized(); -} - -// On Qt 5.0+, this correctly gets the size of the framebuffer (pixels). -// -// Older versions get the window size (density independent pixels), -// and hence, do not support DPI scaling ("retina" displays). -// The result will be a viewport that is smaller than the extent of the window. -void GRenderWindow::OnFramebufferSizeChanged() { - // Screen changes potentially incur a change in screen DPI, hence we should update the - // framebuffer size - const qreal pixel_ratio = windowPixelRatio(); - const u32 width = this->width() * pixel_ratio; - const u32 height = this->height() * pixel_ratio; - UpdateCurrentFramebufferLayout(width, height); -} - -void GRenderWindow::BackupGeometry() { - geometry = QWidget::saveGeometry(); -} - -void GRenderWindow::RestoreGeometry() { - // We don't want to back up the geometry here (obviously) - QWidget::restoreGeometry(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_); - BackupGeometry(); -} - -QByteArray GRenderWindow::saveGeometry() { - // If we are a top-level widget, store the current geometry - // otherwise, store the last backup - if (parent() == nullptr) { - return QWidget::saveGeometry(); - } - - return geometry; -} - -qreal GRenderWindow::windowPixelRatio() const { - return devicePixelRatioF(); -} - -std::pair<u32, u32> GRenderWindow::ScaleTouch(const QPointF& pos) const { - const qreal pixel_ratio = windowPixelRatio(); - return {static_cast<u32>(std::max(std::round(pos.x() * pixel_ratio), qreal{0.0})), - static_cast<u32>(std::max(std::round(pos.y() * pixel_ratio), qreal{0.0}))}; -} - -void GRenderWindow::closeEvent(QCloseEvent* event) { - emit Closed(); - QWidget::closeEvent(event); -} - -void GRenderWindow::leaveEvent(QEvent* event) { - if (Settings::values.mouse_panning) { - const QRect& rect = QWidget::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_constrain_timer.start(); - } - event->accept(); - } -} - -int GRenderWindow::QtKeyToSwitchKey(Qt::Key qt_key) { - static constexpr std::array<std::pair<Qt::Key, Settings::NativeKeyboard::Keys>, 106> key_map = { - std::pair<Qt::Key, Settings::NativeKeyboard::Keys>{Qt::Key_A, Settings::NativeKeyboard::A}, - {Qt::Key_A, Settings::NativeKeyboard::A}, - {Qt::Key_B, Settings::NativeKeyboard::B}, - {Qt::Key_C, Settings::NativeKeyboard::C}, - {Qt::Key_D, Settings::NativeKeyboard::D}, - {Qt::Key_E, Settings::NativeKeyboard::E}, - {Qt::Key_F, Settings::NativeKeyboard::F}, - {Qt::Key_G, Settings::NativeKeyboard::G}, - {Qt::Key_H, Settings::NativeKeyboard::H}, - {Qt::Key_I, Settings::NativeKeyboard::I}, - {Qt::Key_J, Settings::NativeKeyboard::J}, - {Qt::Key_K, Settings::NativeKeyboard::K}, - {Qt::Key_L, Settings::NativeKeyboard::L}, - {Qt::Key_M, Settings::NativeKeyboard::M}, - {Qt::Key_N, Settings::NativeKeyboard::N}, - {Qt::Key_O, Settings::NativeKeyboard::O}, - {Qt::Key_P, Settings::NativeKeyboard::P}, - {Qt::Key_Q, Settings::NativeKeyboard::Q}, - {Qt::Key_R, Settings::NativeKeyboard::R}, - {Qt::Key_S, Settings::NativeKeyboard::S}, - {Qt::Key_T, Settings::NativeKeyboard::T}, - {Qt::Key_U, Settings::NativeKeyboard::U}, - {Qt::Key_V, Settings::NativeKeyboard::V}, - {Qt::Key_W, Settings::NativeKeyboard::W}, - {Qt::Key_X, Settings::NativeKeyboard::X}, - {Qt::Key_Y, Settings::NativeKeyboard::Y}, - {Qt::Key_Z, Settings::NativeKeyboard::Z}, - {Qt::Key_1, Settings::NativeKeyboard::N1}, - {Qt::Key_2, Settings::NativeKeyboard::N2}, - {Qt::Key_3, Settings::NativeKeyboard::N3}, - {Qt::Key_4, Settings::NativeKeyboard::N4}, - {Qt::Key_5, Settings::NativeKeyboard::N5}, - {Qt::Key_6, Settings::NativeKeyboard::N6}, - {Qt::Key_7, Settings::NativeKeyboard::N7}, - {Qt::Key_8, Settings::NativeKeyboard::N8}, - {Qt::Key_9, Settings::NativeKeyboard::N9}, - {Qt::Key_0, Settings::NativeKeyboard::N0}, - {Qt::Key_Return, Settings::NativeKeyboard::Return}, - {Qt::Key_Escape, Settings::NativeKeyboard::Escape}, - {Qt::Key_Backspace, Settings::NativeKeyboard::Backspace}, - {Qt::Key_Tab, Settings::NativeKeyboard::Tab}, - {Qt::Key_Space, Settings::NativeKeyboard::Space}, - {Qt::Key_Minus, Settings::NativeKeyboard::Minus}, - {Qt::Key_Plus, Settings::NativeKeyboard::Plus}, - {Qt::Key_questiondown, Settings::NativeKeyboard::Plus}, - {Qt::Key_BracketLeft, Settings::NativeKeyboard::OpenBracket}, - {Qt::Key_BraceLeft, Settings::NativeKeyboard::OpenBracket}, - {Qt::Key_BracketRight, Settings::NativeKeyboard::CloseBracket}, - {Qt::Key_BraceRight, Settings::NativeKeyboard::CloseBracket}, - {Qt::Key_Bar, Settings::NativeKeyboard::Pipe}, - {Qt::Key_Dead_Tilde, Settings::NativeKeyboard::Tilde}, - {Qt::Key_Ntilde, Settings::NativeKeyboard::Semicolon}, - {Qt::Key_Semicolon, Settings::NativeKeyboard::Semicolon}, - {Qt::Key_Apostrophe, Settings::NativeKeyboard::Quote}, - {Qt::Key_Dead_Grave, Settings::NativeKeyboard::Backquote}, - {Qt::Key_Comma, Settings::NativeKeyboard::Comma}, - {Qt::Key_Period, Settings::NativeKeyboard::Period}, - {Qt::Key_Slash, Settings::NativeKeyboard::Slash}, - {Qt::Key_CapsLock, Settings::NativeKeyboard::CapsLockKey}, - {Qt::Key_F1, Settings::NativeKeyboard::F1}, - {Qt::Key_F2, Settings::NativeKeyboard::F2}, - {Qt::Key_F3, Settings::NativeKeyboard::F3}, - {Qt::Key_F4, Settings::NativeKeyboard::F4}, - {Qt::Key_F5, Settings::NativeKeyboard::F5}, - {Qt::Key_F6, Settings::NativeKeyboard::F6}, - {Qt::Key_F7, Settings::NativeKeyboard::F7}, - {Qt::Key_F8, Settings::NativeKeyboard::F8}, - {Qt::Key_F9, Settings::NativeKeyboard::F9}, - {Qt::Key_F10, Settings::NativeKeyboard::F10}, - {Qt::Key_F11, Settings::NativeKeyboard::F11}, - {Qt::Key_F12, Settings::NativeKeyboard::F12}, - {Qt::Key_Print, Settings::NativeKeyboard::PrintScreen}, - {Qt::Key_ScrollLock, Settings::NativeKeyboard::ScrollLockKey}, - {Qt::Key_Pause, Settings::NativeKeyboard::Pause}, - {Qt::Key_Insert, Settings::NativeKeyboard::Insert}, - {Qt::Key_Home, Settings::NativeKeyboard::Home}, - {Qt::Key_PageUp, Settings::NativeKeyboard::PageUp}, - {Qt::Key_Delete, Settings::NativeKeyboard::Delete}, - {Qt::Key_End, Settings::NativeKeyboard::End}, - {Qt::Key_PageDown, Settings::NativeKeyboard::PageDown}, - {Qt::Key_Right, Settings::NativeKeyboard::Right}, - {Qt::Key_Left, Settings::NativeKeyboard::Left}, - {Qt::Key_Down, Settings::NativeKeyboard::Down}, - {Qt::Key_Up, Settings::NativeKeyboard::Up}, - {Qt::Key_NumLock, Settings::NativeKeyboard::NumLockKey}, - // Numpad keys are missing here - {Qt::Key_F13, Settings::NativeKeyboard::F13}, - {Qt::Key_F14, Settings::NativeKeyboard::F14}, - {Qt::Key_F15, Settings::NativeKeyboard::F15}, - {Qt::Key_F16, Settings::NativeKeyboard::F16}, - {Qt::Key_F17, Settings::NativeKeyboard::F17}, - {Qt::Key_F18, Settings::NativeKeyboard::F18}, - {Qt::Key_F19, Settings::NativeKeyboard::F19}, - {Qt::Key_F20, Settings::NativeKeyboard::F20}, - {Qt::Key_F21, Settings::NativeKeyboard::F21}, - {Qt::Key_F22, Settings::NativeKeyboard::F22}, - {Qt::Key_F23, Settings::NativeKeyboard::F23}, - {Qt::Key_F24, Settings::NativeKeyboard::F24}, - // {Qt::..., Settings::NativeKeyboard::KPComma}, - // {Qt::..., Settings::NativeKeyboard::Ro}, - {Qt::Key_Hiragana_Katakana, Settings::NativeKeyboard::KatakanaHiragana}, - {Qt::Key_yen, Settings::NativeKeyboard::Yen}, - {Qt::Key_Henkan, Settings::NativeKeyboard::Henkan}, - {Qt::Key_Muhenkan, Settings::NativeKeyboard::Muhenkan}, - // {Qt::..., Settings::NativeKeyboard::NumPadCommaPc98}, - {Qt::Key_Hangul, Settings::NativeKeyboard::HangulEnglish}, - {Qt::Key_Hangul_Hanja, Settings::NativeKeyboard::Hanja}, - {Qt::Key_Katakana, Settings::NativeKeyboard::KatakanaKey}, - {Qt::Key_Hiragana, Settings::NativeKeyboard::HiraganaKey}, - {Qt::Key_Zenkaku_Hankaku, Settings::NativeKeyboard::ZenkakuHankaku}, - // Modifier keys are handled by the modifier property - }; - - for (const auto& [qkey, nkey] : key_map) { - if (qt_key == qkey) { - return nkey; - } - } - - return Settings::NativeKeyboard::None; -} - -int GRenderWindow::QtModifierToSwitchModifier(Qt::KeyboardModifiers qt_modifiers) { - int modifier = 0; - - if ((qt_modifiers & Qt::KeyboardModifier::ShiftModifier) != 0) { - modifier |= 1 << Settings::NativeKeyboard::LeftShift; - } - if ((qt_modifiers & Qt::KeyboardModifier::ControlModifier) != 0) { - modifier |= 1 << Settings::NativeKeyboard::LeftControl; - } - if ((qt_modifiers & Qt::KeyboardModifier::AltModifier) != 0) { - modifier |= 1 << Settings::NativeKeyboard::LeftAlt; - } - if ((qt_modifiers & Qt::KeyboardModifier::MetaModifier) != 0) { - modifier |= 1 << Settings::NativeKeyboard::LeftMeta; - } - - // TODO: These keys can't be obtained with Qt::KeyboardModifier - - // if ((qt_modifiers & 0x10) != 0) { - // modifier |= 1 << Settings::NativeKeyboard::RightShift; - // } - // if ((qt_modifiers & 0x20) != 0) { - // modifier |= 1 << Settings::NativeKeyboard::RightControl; - // } - // if ((qt_modifiers & 0x40) != 0) { - // modifier |= 1 << Settings::NativeKeyboard::RightAlt; - // } - // if ((qt_modifiers & 0x80) != 0) { - // modifier |= 1 << Settings::NativeKeyboard::RightMeta; - // } - // if ((qt_modifiers & 0x100) != 0) { - // modifier |= 1 << Settings::NativeKeyboard::CapsLock; - // } - // if ((qt_modifiers & 0x200) != 0) { - // modifier |= 1 << Settings::NativeKeyboard::NumLock; - // } - // if ((qt_modifiers & ???) != 0) { - // modifier |= 1 << Settings::NativeKeyboard::ScrollLock; - // } - // if ((qt_modifiers & ???) != 0) { - // modifier |= 1 << Settings::NativeKeyboard::Katakana; - // } - // if ((qt_modifiers & ???) != 0) { - // modifier |= 1 << Settings::NativeKeyboard::Hiragana; - // } - return modifier; -} - -void GRenderWindow::keyPressEvent(QKeyEvent* event) { - /** - * This feature can be enhanced with the following functions, but they do not provide - * cross-platform behavior. - * - * event->nativeVirtualKey() can distinguish between keys on the numpad. - * event->nativeModifiers() can distinguish between left and right keys and numlock, - * capslock, scroll lock. - */ - if (!event->isAutoRepeat()) { - const auto modifier = QtModifierToSwitchModifier(event->modifiers()); - const auto key = QtKeyToSwitchKey(Qt::Key(event->key())); - input_subsystem->GetKeyboard()->SetKeyboardModifiers(modifier); - input_subsystem->GetKeyboard()->PressKeyboardKey(key); - // This is used for gamepads that can have any key mapped - input_subsystem->GetKeyboard()->PressKey(event->key()); - } -} - -void GRenderWindow::keyReleaseEvent(QKeyEvent* event) { - /** - * This feature can be enhanced with the following functions, but they do not provide - * cross-platform behavior. - * - * event->nativeVirtualKey() can distinguish between keys on the numpad. - * event->nativeModifiers() can distinguish between left and right buttons and numlock, - * capslock, scroll lock. - */ - if (!event->isAutoRepeat()) { - const auto modifier = QtModifierToSwitchModifier(event->modifiers()); - const auto key = QtKeyToSwitchKey(Qt::Key(event->key())); - input_subsystem->GetKeyboard()->SetKeyboardModifiers(modifier); - input_subsystem->GetKeyboard()->ReleaseKeyboardKey(key); - // This is used for gamepads that can have any key mapped - input_subsystem->GetKeyboard()->ReleaseKey(event->key()); - } -} - -InputCommon::MouseButton GRenderWindow::QtButtonToMouseButton(Qt::MouseButton button) { - switch (button) { - case Qt::LeftButton: - return InputCommon::MouseButton::Left; - case Qt::RightButton: - return InputCommon::MouseButton::Right; - case Qt::MiddleButton: - return InputCommon::MouseButton::Wheel; - case Qt::BackButton: - return InputCommon::MouseButton::Backward; - case Qt::ForwardButton: - return InputCommon::MouseButton::Forward; - case Qt::TaskButton: - return InputCommon::MouseButton::Task; - default: - return InputCommon::MouseButton::Extra; - } -} - -void GRenderWindow::mousePressEvent(QMouseEvent* event) { - // Touch input is handled in TouchBeginEvent - if (event->source() == Qt::MouseEventSynthesizedBySystem) { - return; - } - // Qt sometimes returns the parent coordinates. To avoid this we read the global mouse - // coordinates and map them to the current render area - const auto pos = mapFromGlobal(QCursor::pos()); - const auto [x, y] = ScaleTouch(pos); - const auto [touch_x, touch_y] = MapToTouchScreen(x, y); - const auto button = QtButtonToMouseButton(event->button()); - - input_subsystem->GetMouse()->PressMouseButton(button); - input_subsystem->GetMouse()->PressButton(pos.x(), pos.y(), button); - input_subsystem->GetMouse()->PressTouchButton(touch_x, touch_y, button); - - emit MouseActivity(); -} - -void GRenderWindow::mouseMoveEvent(QMouseEvent* event) { - // Touch input is handled in TouchUpdateEvent - if (event->source() == Qt::MouseEventSynthesizedBySystem) { - return; - } - // Qt sometimes returns the parent coordinates. To avoid this we read the global mouse - // coordinates and map them to the current render area - const auto pos = mapFromGlobal(QCursor::pos()); - const auto [x, y] = ScaleTouch(pos); - const auto [touch_x, touch_y] = MapToTouchScreen(x, y); - const int center_x = width() / 2; - const int center_y = height() / 2; - - input_subsystem->GetMouse()->MouseMove(touch_x, touch_y); - input_subsystem->GetMouse()->TouchMove(touch_x, touch_y); - input_subsystem->GetMouse()->Move(pos.x(), pos.y(), center_x, center_y); - - // Center mouse for mouse panning - if (Settings::values.mouse_panning && !Settings::values.mouse_enabled) { - QCursor::setPos(mapToGlobal(QPoint{center_x, center_y})); - } - - // Constrain mouse for mouse emulation with mouse panning - if (Settings::values.mouse_panning && Settings::values.mouse_enabled) { - const auto [clamped_mouse_x, clamped_mouse_y] = ClipToTouchScreen(x, y); - QCursor::setPos(mapToGlobal( - QPoint{static_cast<int>(clamped_mouse_x), static_cast<int>(clamped_mouse_y)})); - } - - mouse_constrain_timer.stop(); - emit MouseActivity(); -} - -void GRenderWindow::mouseReleaseEvent(QMouseEvent* event) { - // Touch input is handled in TouchEndEvent - if (event->source() == Qt::MouseEventSynthesizedBySystem) { - return; - } - - const auto button = QtButtonToMouseButton(event->button()); - input_subsystem->GetMouse()->ReleaseButton(button); -} - -void GRenderWindow::ConstrainMouse() { - if (emu_thread == nullptr || !Settings::values.mouse_panning) { - mouse_constrain_timer.stop(); - return; - } - if (!this->isActiveWindow()) { - mouse_constrain_timer.stop(); - return; - } - - if (Settings::values.mouse_enabled) { - const auto pos = mapFromGlobal(QCursor::pos()); - const int new_pos_x = std::clamp(pos.x(), 0, width()); - const int new_pos_y = std::clamp(pos.y(), 0, height()); - - QCursor::setPos(mapToGlobal(QPoint{new_pos_x, new_pos_y})); - return; - } - - const int center_x = width() / 2; - const int center_y = height() / 2; - - QCursor::setPos(mapToGlobal(QPoint{center_x, center_y})); -} - -void GRenderWindow::wheelEvent(QWheelEvent* event) { - const int x = event->angleDelta().x(); - const int y = event->angleDelta().y(); - input_subsystem->GetMouse()->MouseWheelChange(x, y); -} - -void GRenderWindow::TouchBeginEvent(const QTouchEvent* event) { - QList<QTouchEvent::TouchPoint> touch_points = event->touchPoints(); - for (const auto& touch_point : touch_points) { - 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) { - 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() { - input_subsystem->GetTouchScreen()->ReleaseAllTouch(); -} - -void GRenderWindow::InitializeCamera() { -#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) && YUZU_USE_QT_MULTIMEDIA - 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; - } - - const auto camera_width = input_subsystem->GetCamera()->getImageWidth(); - const auto camera_height = input_subsystem->GetCamera()->getImageHeight(); - camera_data.resize(camera_width * camera_height); - 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); -#endif -} - -void GRenderWindow::FinalizeCamera() { -#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) && YUZU_USE_QT_MULTIMEDIA - if (camera_timer) { - camera_timer->stop(); - } - if (camera) { - camera->unload(); - } -#endif -} - -void GRenderWindow::RequestCameraCapture() { -#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) && YUZU_USE_QT_MULTIMEDIA - if (!Settings::values.enable_ir_sensor) { - return; - } - - // 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(); -#endif -} - -void GRenderWindow::OnCameraCapture(int requestId, const QImage& img) { -#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) && YUZU_USE_QT_MULTIMEDIA - // TODO: Capture directly in the format and resolution needed - const auto camera_width = input_subsystem->GetCamera()->getImageWidth(); - const auto camera_height = input_subsystem->GetCamera()->getImageHeight(); - const auto converted = - img.scaled(static_cast<int>(camera_width), static_cast<int>(camera_height), - Qt::AspectRatioMode::IgnoreAspectRatio, - Qt::TransformationMode::SmoothTransformation) - .mirrored(false, true); - if (camera_data.size() != camera_width * camera_height) { - 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; -#endif -} - -bool GRenderWindow::event(QEvent* event) { - if (event->type() == QEvent::TouchBegin) { - TouchBeginEvent(static_cast<QTouchEvent*>(event)); - return true; - } else if (event->type() == QEvent::TouchUpdate) { - TouchUpdateEvent(static_cast<QTouchEvent*>(event)); - return true; - } else if (event->type() == QEvent::TouchEnd || event->type() == QEvent::TouchCancel) { - TouchEndEvent(); - return true; - } - - return QWidget::event(event); -} - -void GRenderWindow::focusOutEvent(QFocusEvent* event) { - QWidget::focusOutEvent(event); - input_subsystem->GetKeyboard()->ReleaseAllKeys(); - input_subsystem->GetMouse()->ReleaseAllButtons(); - input_subsystem->GetTouchScreen()->ReleaseAllTouch(); -} - -void GRenderWindow::resizeEvent(QResizeEvent* event) { - QWidget::resizeEvent(event); - OnFramebufferSizeChanged(); -} - -std::unique_ptr<Core::Frontend::GraphicsContext> GRenderWindow::CreateSharedContext() const { -#ifdef HAS_OPENGL - if (Settings::values.renderer_backend.GetValue() == Settings::RendererBackend::OpenGL) { - auto c = static_cast<OpenGLSharedContext*>(main_context.get()); - // Bind the shared contexts to the main surface in case the backend wants to take over - // presentation - return std::make_unique<OpenGLSharedContext>(c->GetShareContext(), - child_widget->windowHandle()); - } -#endif - return std::make_unique<DummyContext>(); -} - -bool GRenderWindow::InitRenderTarget() { - ReleaseRenderTarget(); - - { - // Create a dummy render widget so that Qt - // places the render window at the correct position. - const RenderWidget dummy_widget{this}; - } - - first_frame = false; - - switch (Settings::values.renderer_backend.GetValue()) { - case Settings::RendererBackend::OpenGL: - if (!InitializeOpenGL()) { - return false; - } - break; - case Settings::RendererBackend::Vulkan: - if (!InitializeVulkan()) { - return false; - } - break; - case Settings::RendererBackend::Null: - InitializeNull(); - break; - } - - // Update the Window System information with the new render target - window_info = QtCommon::GetWindowSystemInfo(child_widget->windowHandle()); - - child_widget->resize(Layout::ScreenUndocked::Width, Layout::ScreenUndocked::Height); - layout()->addWidget(child_widget); - // Reset minimum required size to avoid resizing issues on the main window after restarting. - setMinimumSize(1, 1); - - resize(Layout::ScreenUndocked::Width, Layout::ScreenUndocked::Height); - - OnMinimalClientAreaChangeRequest(GetActiveConfig().min_client_area_size); - OnFramebufferSizeChanged(); - BackupGeometry(); - - if (Settings::values.renderer_backend.GetValue() == Settings::RendererBackend::OpenGL) { - if (!LoadOpenGL()) { - return false; - } - } - - return true; -} - -void GRenderWindow::ReleaseRenderTarget() { - if (child_widget) { - layout()->removeWidget(child_widget); - child_widget->deleteLater(); - child_widget = nullptr; - } - main_context.reset(); -} - -void GRenderWindow::CaptureScreenshot(const QString& screenshot_path) { - auto& renderer = system.Renderer(); - - if (renderer.IsScreenshotPending()) { - LOG_WARNING(Render, - "A screenshot is already requested or in progress, ignoring the request"); - return; - } - - const Layout::FramebufferLayout layout{[]() { - u32 height = UISettings::values.screenshot_height.GetValue(); - if (height == 0) { - height = Settings::IsDockedMode() ? Layout::ScreenDocked::Height - : Layout::ScreenUndocked::Height; - height *= Settings::values.resolution_info.up_factor; - } - const u32 width = - UISettings::CalculateWidth(height, Settings::values.aspect_ratio.GetValue()); - return Layout::DefaultFrameLayout(width, height); - }()}; - - screenshot_image = QImage(QSize(layout.width, layout.height), QImage::Format_RGB32); - renderer.RequestScreenshot( - screenshot_image.bits(), - [=, this](bool invert_y) { - const std::string std_screenshot_path = screenshot_path.toStdString(); - if (screenshot_image.mirrored(false, invert_y).save(screenshot_path)) { - LOG_INFO(Frontend, "Screenshot saved to \"{}\"", std_screenshot_path); - } else { - LOG_ERROR(Frontend, "Failed to save screenshot to \"{}\"", std_screenshot_path); - } - }, - layout); -} - -bool GRenderWindow::IsLoadingComplete() const { - return first_frame; -} - -void GRenderWindow::OnMinimalClientAreaChangeRequest(std::pair<u32, u32> minimal_size) { - setMinimumSize(minimal_size.first, minimal_size.second); -} - -bool GRenderWindow::InitializeOpenGL() { -#ifdef HAS_OPENGL - if (!QOpenGLContext::supportsThreadedOpenGL()) { - QMessageBox::warning(this, tr("OpenGL not available!"), - tr("OpenGL shared contexts are not supported.")); - return false; - } - - // TODO: One of these flags might be interesting: WA_OpaquePaintEvent, WA_NoBackground, - // WA_DontShowOnScreen, WA_DeleteOnClose - auto child = new OpenGLRenderWidget(this); - child_widget = child; - child_widget->windowHandle()->create(); - auto context = std::make_shared<OpenGLSharedContext>(child->windowHandle()); - main_context = context; - child->SetContext( - std::make_unique<OpenGLSharedContext>(context->GetShareContext(), child->windowHandle())); - - return true; -#else - QMessageBox::warning(this, tr("OpenGL not available!"), - tr("yuzu has not been compiled with OpenGL support.")); - return false; -#endif -} - -bool GRenderWindow::InitializeVulkan() { - auto child = new VulkanRenderWidget(this); - child_widget = child; - child_widget->windowHandle()->create(); - main_context = std::make_unique<DummyContext>(); - - return true; -} - -void GRenderWindow::InitializeNull() { - child_widget = new NullRenderWidget(this); - main_context = std::make_unique<DummyContext>(); -} - -bool GRenderWindow::LoadOpenGL() { - auto context = CreateSharedContext(); - auto scope = context->Acquire(); - if (!gladLoadGL()) { - QMessageBox::warning( - this, tr("Error while initializing OpenGL!"), - tr("Your GPU may not support OpenGL, or you do not have the latest graphics driver.")); - return false; - } - - const QString renderer = - QString::fromUtf8(reinterpret_cast<const char*>(glGetString(GL_RENDERER))); - - if (!GLAD_GL_VERSION_4_6) { - LOG_ERROR(Frontend, "GPU does not support OpenGL 4.6: {}", renderer.toStdString()); - QMessageBox::warning(this, tr("Error while initializing OpenGL 4.6!"), - tr("Your GPU may not support OpenGL 4.6, or you do not have the " - "latest graphics driver.<br><br>GL Renderer:<br>%1") - .arg(renderer)); - return false; - } - - QStringList unsupported_gl_extensions = GetUnsupportedGLExtensions(); - if (!unsupported_gl_extensions.empty()) { - QMessageBox::warning( - this, tr("Error while initializing OpenGL!"), - tr("Your GPU may not support one or more required OpenGL extensions. Please ensure you " - "have the latest graphics driver.<br><br>GL Renderer:<br>%1<br><br>Unsupported " - "extensions:<br>%2") - .arg(renderer) - .arg(unsupported_gl_extensions.join(QStringLiteral("<br>")))); - return false; - } - return true; -} - -QStringList GRenderWindow::GetUnsupportedGLExtensions() const { - QStringList unsupported_ext; - - // Extensions required to support some texture formats. - if (!GLAD_GL_EXT_texture_compression_s3tc) { - unsupported_ext.append(QStringLiteral("EXT_texture_compression_s3tc")); - } - if (!GLAD_GL_ARB_texture_compression_rgtc) { - unsupported_ext.append(QStringLiteral("ARB_texture_compression_rgtc")); - } - - if (!unsupported_ext.empty()) { - 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()); - } - - return unsupported_ext; -} - -void GRenderWindow::OnEmulationStarting(EmuThread* emu_thread_) { - emu_thread = emu_thread_; -} - -void GRenderWindow::OnEmulationStopping() { - emu_thread = nullptr; -} - -void GRenderWindow::showEvent(QShowEvent* event) { - QWidget::showEvent(event); - - // windowHandle() is not initialized until the Window is shown, so we connect it here. - connect(windowHandle(), &QWindow::screenChanged, this, &GRenderWindow::OnFramebufferSizeChanged, - Qt::UniqueConnection); -} - -bool GRenderWindow::eventFilter(QObject* object, QEvent* event) { - if (event->type() == QEvent::HoverMove) { - if (Settings::values.mouse_panning || Settings::values.mouse_enabled) { - auto* hover_event = static_cast<QMouseEvent*>(event); - mouseMoveEvent(hover_event); - return false; - } - emit MouseActivity(); - } - return false; -} diff --git a/src/yuzu/bootmanager.h b/src/yuzu/bootmanager.h deleted file mode 100644 index ae12b3481..000000000 --- a/src/yuzu/bootmanager.h +++ /dev/null @@ -1,280 +0,0 @@ -// SPDX-FileCopyrightText: 2014 Citra Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include <condition_variable> -#include <cstddef> -#include <memory> -#include <mutex> -#include <utility> -#include <vector> - -#include <QByteArray> -#include <QImage> -#include <QObject> -#include <QPoint> -#include <QString> -#include <QStringList> -#include <QThread> -#include <QTimer> -#include <QWidget> -#include <qglobal.h> -#include <qnamespace.h> -#include <qobjectdefs.h> - -#include "common/common_types.h" -#include "common/logging/log.h" -#include "common/polyfill_thread.h" -#include "common/thread.h" -#include "core/frontend/emu_window.h" - -class GMainWindow; -class QCamera; -class QCameraImageCapture; -class QCloseEvent; -class QFocusEvent; -class QKeyEvent; -class QMouseEvent; -class QObject; -class QResizeEvent; -class QShowEvent; -class QTouchEvent; -class QWheelEvent; - -namespace Core { -class System; -} // namespace Core - -namespace InputCommon { -class InputSubsystem; -enum class MouseButton; -} // namespace InputCommon - -namespace InputCommon::TasInput { -enum class TasState; -} // namespace InputCommon::TasInput - -namespace VideoCore { -enum class LoadCallbackStage; -} // namespace VideoCore - -class EmuThread final : public QThread { - Q_OBJECT - -public: - explicit EmuThread(Core::System& system); - ~EmuThread() override; - - /** - * Start emulation (on new thread) - * @warning Only call when not running! - */ - void run() override; - - /** - * Sets whether the emulation thread should run or not - * @param should_run Boolean value, set the emulation thread to running if true - */ - void SetRunning(bool should_run) { - // TODO: Prevent other threads from modifying the state until we finish. - { - // Notify the running thread to change state. - std::unique_lock run_lk{m_should_run_mutex}; - m_should_run = should_run; - m_should_run_cv.notify_one(); - } - - // Wait until paused, if pausing. - if (!should_run) { - m_stopped.Wait(); - } - } - - /** - * Check if the emulation thread is running or not - * @return True if the emulation thread is running, otherwise false - */ - bool IsRunning() const { - return m_should_run; - } - - /** - * Requests for the emulation thread to immediately stop running - */ - void ForceStop() { - LOG_WARNING(Frontend, "Force stopping EmuThread"); - m_stop_source.request_stop(); - } - -private: - void EmulationPaused(std::unique_lock<std::mutex>& lk); - void EmulationResumed(std::unique_lock<std::mutex>& lk); - -private: - Core::System& m_system; - - std::stop_source m_stop_source; - std::mutex m_should_run_mutex; - std::condition_variable_any m_should_run_cv; - Common::Event m_stopped; - bool m_should_run{true}; - -signals: - /** - * Emitted when the CPU has halted execution - * - * @warning When connecting to this signal from other threads, make sure to specify either - * Qt::QueuedConnection (invoke slot within the destination object's message thread) or even - * Qt::BlockingQueuedConnection (additionally block source thread until slot returns) - */ - void DebugModeEntered(); - - /** - * Emitted right before the CPU continues execution - * - * @warning When connecting to this signal from other threads, make sure to specify either - * Qt::QueuedConnection (invoke slot within the destination object's message thread) or even - * Qt::BlockingQueuedConnection (additionally block source thread until slot returns) - */ - void DebugModeLeft(); - - void LoadProgress(VideoCore::LoadCallbackStage stage, std::size_t value, std::size_t total); -}; - -class GRenderWindow : public QWidget, public Core::Frontend::EmuWindow { - Q_OBJECT - -public: - explicit GRenderWindow(GMainWindow* parent, EmuThread* emu_thread_, - std::shared_ptr<InputCommon::InputSubsystem> input_subsystem_, - Core::System& system_); - ~GRenderWindow() override; - - // EmuWindow implementation. - void OnFrameDisplayed() override; - bool IsShown() const override; - std::unique_ptr<Core::Frontend::GraphicsContext> CreateSharedContext() const override; - - void BackupGeometry(); - void RestoreGeometry(); - void restoreGeometry(const QByteArray& geometry_); // overridden - QByteArray saveGeometry(); // overridden - - qreal windowPixelRatio() const; - - std::pair<u32, u32> ScaleTouch(const QPointF& pos) const; - - void closeEvent(QCloseEvent* event) override; - void leaveEvent(QEvent* event) override; - - void resizeEvent(QResizeEvent* event) override; - - /// Converts a Qt keyboard key into NativeKeyboard key - static int QtKeyToSwitchKey(Qt::Key qt_keys); - - /// Converts a Qt modifier keys into NativeKeyboard modifier keys - static int QtModifierToSwitchModifier(Qt::KeyboardModifiers qt_modifiers); - - void keyPressEvent(QKeyEvent* event) override; - void keyReleaseEvent(QKeyEvent* event) override; - - /// Converts a Qt mouse button into MouseInput mouse button - static InputCommon::MouseButton QtButtonToMouseButton(Qt::MouseButton button); - - void mousePressEvent(QMouseEvent* event) override; - void mouseMoveEvent(QMouseEvent* event) override; - void mouseReleaseEvent(QMouseEvent* event) override; - void wheelEvent(QWheelEvent* event) override; - - void InitializeCamera(); - void FinalizeCamera(); - - bool event(QEvent* event) override; - - void focusOutEvent(QFocusEvent* event) override; - - bool InitRenderTarget(); - - /// Destroy the previous run's child_widget which should also destroy the child_window - void ReleaseRenderTarget(); - - bool IsLoadingComplete() const; - - void CaptureScreenshot(const QString& screenshot_path); - - /** - * Instructs the window to re-launch the application using the specified program_index. - * @param program_index Specifies the index within the application of the program to launch. - */ - void ExecuteProgram(std::size_t program_index); - - /// Instructs the window to exit the application. - void Exit(); - -public slots: - void OnEmulationStarting(EmuThread* emu_thread_); - void OnEmulationStopping(); - void OnFramebufferSizeChanged(); - -signals: - /// Emitted when the window is closed - void Closed(); - void FirstFrameDisplayed(); - void ExecuteProgramSignal(std::size_t program_index); - void ExitSignal(); - void MouseActivity(); - void TasPlaybackStateChanged(); - -private: - void TouchBeginEvent(const QTouchEvent* event); - void TouchUpdateEvent(const QTouchEvent* event); - void TouchEndEvent(); - void ConstrainMouse(); - - void RequestCameraCapture(); - void OnCameraCapture(int requestId, const QImage& img); - - void OnMinimalClientAreaChangeRequest(std::pair<u32, u32> minimal_size) override; - - bool InitializeOpenGL(); - bool InitializeVulkan(); - void InitializeNull(); - bool LoadOpenGL(); - QStringList GetUnsupportedGLExtensions() const; - - EmuThread* emu_thread; - std::shared_ptr<InputCommon::InputSubsystem> input_subsystem; - - // Main context that will be shared with all other contexts that are requested. - // If this is used in a shared context setting, then this should not be used directly, but - // should instead be shared from - std::shared_ptr<Core::Frontend::GraphicsContext> main_context; - - /// Temporary storage of the screenshot taken - QImage screenshot_image; - - QByteArray geometry; - - QWidget* child_widget = nullptr; - - bool first_frame = false; - InputCommon::TasInput::TasState last_tas_state; - -#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) && YUZU_USE_QT_MULTIMEDIA - bool is_virtual_camera; - int pending_camera_snapshots; - std::vector<u32> camera_data; - std::unique_ptr<QCamera> camera; - std::unique_ptr<QCameraImageCapture> camera_capture; - std::unique_ptr<QTimer> camera_timer; -#endif - - QTimer mouse_constrain_timer; - - Core::System& system; - -protected: - void showEvent(QShowEvent* event) override; - bool eventFilter(QObject* object, QEvent* event) override; -}; diff --git a/src/yuzu/breakpad.cpp b/src/yuzu/breakpad.cpp deleted file mode 100644 index 0f6a71ab0..000000000 --- a/src/yuzu/breakpad.cpp +++ /dev/null @@ -1,77 +0,0 @@ -// SPDX-FileCopyrightText: 2023 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include <algorithm> -#include <ranges> - -#if defined(_WIN32) -#include <client/windows/handler/exception_handler.h> -#elif defined(__linux__) -#include <client/linux/handler/exception_handler.h> -#else -#error Minidump creation not supported on this platform -#endif - -#include "common/fs/fs_paths.h" -#include "common/fs/path_util.h" -#include "yuzu/breakpad.h" - -namespace Breakpad { - -static void PruneDumpDirectory(const std::filesystem::path& dump_path) { - // Code in this function should be exception-safe. - struct Entry { - std::filesystem::path path; - std::filesystem::file_time_type last_write_time; - }; - std::vector<Entry> existing_dumps; - - // Get existing entries. - std::error_code ec; - std::filesystem::directory_iterator dir(dump_path, ec); - for (auto& entry : dir) { - if (entry.is_regular_file()) { - existing_dumps.push_back(Entry{ - .path = entry.path(), - .last_write_time = entry.last_write_time(ec), - }); - } - } - - // Sort descending by creation date. - std::ranges::stable_sort(existing_dumps, [](const auto& a, const auto& b) { - return a.last_write_time > b.last_write_time; - }); - - // Delete older dumps. - for (size_t i = 5; i < existing_dumps.size(); i++) { - std::filesystem::remove(existing_dumps[i].path, ec); - } -} - -#if defined(__linux__) -[[noreturn]] bool DumpCallback(const google_breakpad::MinidumpDescriptor& descriptor, void* context, - bool succeeded) { - // Prevent time- and space-consuming core dumps from being generated, as we have - // already generated a minidump and a core file will not be useful anyway. - _exit(1); -} -#endif - -void InstallCrashHandler() { - // Write crash dumps to profile directory. - const auto dump_path = GetYuzuPath(Common::FS::YuzuPath::CrashDumpsDir); - PruneDumpDirectory(dump_path); - -#if defined(_WIN32) - // TODO: If we switch to MinGW builds for Windows, this needs to be wrapped in a C API. - static google_breakpad::ExceptionHandler eh{dump_path, nullptr, nullptr, nullptr, - google_breakpad::ExceptionHandler::HANDLER_ALL}; -#elif defined(__linux__) - static google_breakpad::MinidumpDescriptor descriptor{dump_path}; - static google_breakpad::ExceptionHandler eh{descriptor, nullptr, DumpCallback, - nullptr, true, -1}; -#endif -} - -} // namespace Breakpad diff --git a/src/yuzu/breakpad.h b/src/yuzu/breakpad.h deleted file mode 100644 index 0f911aa9c..000000000 --- a/src/yuzu/breakpad.h +++ /dev/null @@ -1,10 +0,0 @@ -// SPDX-FileCopyrightText: 2023 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -namespace Breakpad { - -void InstallCrashHandler(); - -} diff --git a/src/yuzu/compatdb.cpp b/src/yuzu/compatdb.cpp deleted file mode 100644 index a57a96a38..000000000 --- a/src/yuzu/compatdb.cpp +++ /dev/null @@ -1,210 +0,0 @@ -// SPDX-FileCopyrightText: 2017 Citra Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include <QButtonGroup> -#include <QMessageBox> -#include <QPushButton> -#include <QtConcurrent/qtconcurrentrun.h> -#include "common/logging/log.h" -#include "common/telemetry.h" -#include "core/telemetry_session.h" -#include "ui_compatdb.h" -#include "yuzu/compatdb.h" - -CompatDB::CompatDB(Core::TelemetrySession& telemetry_session_, QWidget* parent) - : QWizard(parent, Qt::WindowTitleHint | Qt::WindowCloseButtonHint | Qt::WindowSystemMenuHint), - ui{std::make_unique<Ui::CompatDB>()}, telemetry_session{telemetry_session_} { - ui->setupUi(this); - - connect(ui->radioButton_GameBoot_Yes, &QRadioButton::clicked, this, &CompatDB::EnableNext); - connect(ui->radioButton_GameBoot_No, &QRadioButton::clicked, this, &CompatDB::EnableNext); - connect(ui->radioButton_Gameplay_Yes, &QRadioButton::clicked, this, &CompatDB::EnableNext); - connect(ui->radioButton_Gameplay_No, &QRadioButton::clicked, this, &CompatDB::EnableNext); - connect(ui->radioButton_NoFreeze_Yes, &QRadioButton::clicked, this, &CompatDB::EnableNext); - connect(ui->radioButton_NoFreeze_No, &QRadioButton::clicked, this, &CompatDB::EnableNext); - connect(ui->radioButton_Complete_Yes, &QRadioButton::clicked, this, &CompatDB::EnableNext); - connect(ui->radioButton_Complete_No, &QRadioButton::clicked, this, &CompatDB::EnableNext); - connect(ui->radioButton_Graphical_Major, &QRadioButton::clicked, this, &CompatDB::EnableNext); - connect(ui->radioButton_Graphical_Minor, &QRadioButton::clicked, this, &CompatDB::EnableNext); - connect(ui->radioButton_Graphical_No, &QRadioButton::clicked, this, &CompatDB::EnableNext); - connect(ui->radioButton_Audio_Major, &QRadioButton::clicked, this, &CompatDB::EnableNext); - connect(ui->radioButton_Audio_Minor, &QRadioButton::clicked, this, &CompatDB::EnableNext); - connect(ui->radioButton_Audio_No, &QRadioButton::clicked, this, &CompatDB::EnableNext); - - connect(button(NextButton), &QPushButton::clicked, this, &CompatDB::Submit); - connect(&testcase_watcher, &QFutureWatcher<bool>::finished, this, - &CompatDB::OnTestcaseSubmitted); -} - -CompatDB::~CompatDB() = default; - -enum class CompatDBPage { - Intro = 0, - GameBoot = 1, - GamePlay = 2, - Freeze = 3, - Completion = 4, - Graphical = 5, - Audio = 6, - Final = 7, -}; - -void CompatDB::Submit() { - QButtonGroup* compatibility_GameBoot = new QButtonGroup(this); - compatibility_GameBoot->addButton(ui->radioButton_GameBoot_Yes, 0); - compatibility_GameBoot->addButton(ui->radioButton_GameBoot_No, 1); - - QButtonGroup* compatibility_Gameplay = new QButtonGroup(this); - compatibility_Gameplay->addButton(ui->radioButton_Gameplay_Yes, 0); - compatibility_Gameplay->addButton(ui->radioButton_Gameplay_No, 1); - - QButtonGroup* compatibility_NoFreeze = new QButtonGroup(this); - compatibility_NoFreeze->addButton(ui->radioButton_NoFreeze_Yes, 0); - compatibility_NoFreeze->addButton(ui->radioButton_NoFreeze_No, 1); - - QButtonGroup* compatibility_Complete = new QButtonGroup(this); - compatibility_Complete->addButton(ui->radioButton_Complete_Yes, 0); - compatibility_Complete->addButton(ui->radioButton_Complete_No, 1); - - QButtonGroup* compatibility_Graphical = new QButtonGroup(this); - compatibility_Graphical->addButton(ui->radioButton_Graphical_Major, 0); - compatibility_Graphical->addButton(ui->radioButton_Graphical_Minor, 1); - compatibility_Graphical->addButton(ui->radioButton_Graphical_No, 2); - - QButtonGroup* compatibility_Audio = new QButtonGroup(this); - compatibility_Audio->addButton(ui->radioButton_Audio_Major, 0); - compatibility_Graphical->addButton(ui->radioButton_Audio_Minor, 1); - compatibility_Audio->addButton(ui->radioButton_Audio_No, 2); - - const int compatibility = static_cast<int>(CalculateCompatibility()); - - switch ((static_cast<CompatDBPage>(currentId()))) { - case CompatDBPage::Intro: - break; - case CompatDBPage::GameBoot: - if (compatibility_GameBoot->checkedId() == -1) { - button(NextButton)->setEnabled(false); - } - break; - case CompatDBPage::GamePlay: - if (compatibility_Gameplay->checkedId() == -1) { - button(NextButton)->setEnabled(false); - } - break; - case CompatDBPage::Freeze: - if (compatibility_NoFreeze->checkedId() == -1) { - button(NextButton)->setEnabled(false); - } - break; - case CompatDBPage::Completion: - if (compatibility_Complete->checkedId() == -1) { - button(NextButton)->setEnabled(false); - } - break; - case CompatDBPage::Graphical: - if (compatibility_Graphical->checkedId() == -1) { - button(NextButton)->setEnabled(false); - } - break; - case CompatDBPage::Audio: - if (compatibility_Audio->checkedId() == -1) { - button(NextButton)->setEnabled(false); - } - break; - case CompatDBPage::Final: - back(); - LOG_INFO(Frontend, "Compatibility Rating: {}", compatibility); - telemetry_session.AddField(Common::Telemetry::FieldType::UserFeedback, "Compatibility", - compatibility); - - button(NextButton)->setEnabled(false); - button(NextButton)->setText(tr("Submitting")); - button(CancelButton)->setVisible(false); - - testcase_watcher.setFuture( - QtConcurrent::run([this] { return telemetry_session.SubmitTestcase(); })); - break; - default: - LOG_ERROR(Frontend, "Unexpected page: {}", currentId()); - break; - } -} - -int CompatDB::nextId() const { - switch ((static_cast<CompatDBPage>(currentId()))) { - case CompatDBPage::Intro: - return static_cast<int>(CompatDBPage::GameBoot); - case CompatDBPage::GameBoot: - if (ui->radioButton_GameBoot_No->isChecked()) { - return static_cast<int>(CompatDBPage::Final); - } - return static_cast<int>(CompatDBPage::GamePlay); - case CompatDBPage::GamePlay: - if (ui->radioButton_Gameplay_No->isChecked()) { - return static_cast<int>(CompatDBPage::Final); - } - return static_cast<int>(CompatDBPage::Freeze); - case CompatDBPage::Freeze: - if (ui->radioButton_NoFreeze_No->isChecked()) { - return static_cast<int>(CompatDBPage::Final); - } - return static_cast<int>(CompatDBPage::Completion); - case CompatDBPage::Completion: - if (ui->radioButton_Complete_No->isChecked()) { - return static_cast<int>(CompatDBPage::Final); - } - return static_cast<int>(CompatDBPage::Graphical); - case CompatDBPage::Graphical: - return static_cast<int>(CompatDBPage::Audio); - case CompatDBPage::Audio: - return static_cast<int>(CompatDBPage::Final); - case CompatDBPage::Final: - return -1; - default: - LOG_ERROR(Frontend, "Unexpected page: {}", currentId()); - return static_cast<int>(CompatDBPage::Intro); - } -} - -CompatibilityStatus CompatDB::CalculateCompatibility() const { - if (ui->radioButton_GameBoot_No->isChecked()) { - return CompatibilityStatus::WontBoot; - } - - if (ui->radioButton_Gameplay_No->isChecked()) { - return CompatibilityStatus::IntroMenu; - } - - if (ui->radioButton_NoFreeze_No->isChecked() || ui->radioButton_Complete_No->isChecked()) { - return CompatibilityStatus::Ingame; - } - - if (ui->radioButton_Graphical_Major->isChecked() || ui->radioButton_Audio_Major->isChecked()) { - return CompatibilityStatus::Ingame; - } - - if (ui->radioButton_Graphical_Minor->isChecked() || ui->radioButton_Audio_Minor->isChecked()) { - return CompatibilityStatus::Playable; - } - - return CompatibilityStatus::Perfect; -} - -void CompatDB::OnTestcaseSubmitted() { - if (!testcase_watcher.result()) { - QMessageBox::critical(this, tr("Communication error"), - tr("An error occurred while sending the Testcase")); - button(NextButton)->setEnabled(true); - button(NextButton)->setText(tr("Next")); - button(CancelButton)->setVisible(true); - } else { - next(); - // older versions of QT don't support the "NoCancelButtonOnLastPage" option, this is a - // workaround - button(CancelButton)->setVisible(false); - } -} - -void CompatDB::EnableNext() { - button(NextButton)->setEnabled(true); -} diff --git a/src/yuzu/compatdb.h b/src/yuzu/compatdb.h deleted file mode 100644 index 37e11278b..000000000 --- a/src/yuzu/compatdb.h +++ /dev/null @@ -1,43 +0,0 @@ -// SPDX-FileCopyrightText: 2017 Citra Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include <memory> -#include <QFutureWatcher> -#include <QWizard> -#include "core/telemetry_session.h" - -namespace Ui { -class CompatDB; -} - -enum class CompatibilityStatus { - Perfect = 0, - Playable = 1, - // Unused: Okay = 2, - Ingame = 3, - IntroMenu = 4, - WontBoot = 5, -}; - -class CompatDB : public QWizard { - Q_OBJECT - -public: - explicit CompatDB(Core::TelemetrySession& telemetry_session_, QWidget* parent = nullptr); - ~CompatDB(); - int nextId() const override; - -private: - QFutureWatcher<bool> testcase_watcher; - - std::unique_ptr<Ui::CompatDB> ui; - - void Submit(); - CompatibilityStatus CalculateCompatibility() const; - void OnTestcaseSubmitted(); - void EnableNext(); - - Core::TelemetrySession& telemetry_session; -}; diff --git a/src/yuzu/compatdb.ui b/src/yuzu/compatdb.ui deleted file mode 100644 index d11669df2..000000000 --- a/src/yuzu/compatdb.ui +++ /dev/null @@ -1,398 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>CompatDB</class> - <widget class="QWizard" name="CompatDB"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>600</width> - <height>482</height> - </rect> - </property> - <property name="minimumSize"> - <size> - <width>500</width> - <height>410</height> - </size> - </property> - <property name="windowTitle"> - <string>Report Compatibility</string> - </property> - <property name="options"> - <set>QWizard::DisabledBackButtonOnLastPage|QWizard::HelpButtonOnRight|QWizard::NoBackButtonOnStartPage</set> - </property> - <widget class="QWizardPage" name="wizard_Info"> - <property name="title"> - <string>Report Game Compatibility</string> - </property> - <attribute name="pageId"> - <string notr="true">0</string> - </attribute> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <widget class="QLabel" name="lbl_Spiel"> - <property name="text"> - <string><html><head/><body><p><span style=" font-size:10pt;">Should you choose to submit a test case to the </span><a href="https://yuzu-emu.org/game/"><span style=" font-size:10pt; text-decoration: underline; color:#0000ff;">yuzu Compatibility List</span></a><span style=" font-size:10pt;">, The following information will be collected and displayed on the site:</span></p><ul style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; -qt-list-indent: 1;"><li style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Hardware Information (CPU / GPU / Operating System)</li><li style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Which version of yuzu you are running</li><li style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">The connected yuzu account</li></ul></body></html></string> - </property> - <property name="wordWrap"> - <bool>true</bool> - </property> - <property name="openExternalLinks"> - <bool>true</bool> - </property> - </widget> - </item> - <item> - <spacer name="verticalSpacer_2"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>0</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - <widget class="QWizardPage" name="wizard_GameBoot"> - <property name="title"> - <string>Report Game Compatibility</string> - </property> - <attribute name="pageId"> - <string notr="true">1</string> - </attribute> - <layout class="QFormLayout" name="formLayout1"> - <item row="0" column="0" colspan="2"> - <widget class="QLabel" name="lbl_Independent1"> - <property name="font"> - <font> - <pointsize>10</pointsize> - </font> - </property> - <property name="text"> - <string><html><head/><body><p>Does the game boot?</p></body></html></string> - </property> - <property name="wordWrap"> - <bool>true</bool> - </property> - </widget> - </item> - <item row="1" column="0" colspan="2"> - <spacer name="verticalSpacer1"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>0</height> - </size> - </property> - </spacer> - </item> - <item row="2" column="0"> - <widget class="QRadioButton" name="radioButton_GameBoot_Yes"> - <property name="text"> - <string>Yes The game starts to output video or audio</string> - </property> - </widget> - </item> - <item row="4" column="0"> - <widget class="QRadioButton" name="radioButton_GameBoot_No"> - <property name="text"> - <string>No The game doesn't get past the "Launching..." screen</string> - </property> - </widget> - </item> - </layout> - </widget> - <widget class="QWizardPage" name="wizard_GamePlay"> - <property name="title"> - <string>Report Game Compatibility</string> - </property> - <attribute name="pageId"> - <string notr="true">2</string> - </attribute> - <layout class="QFormLayout" name="formLayout2"> - <item row="2" column="0"> - <widget class="QRadioButton" name="radioButton_Gameplay_Yes"> - <property name="text"> - <string>Yes The game gets past the intro/menu and into gameplay</string> - </property> - </widget> - </item> - <item row="4" column="0"> - <widget class="QRadioButton" name="radioButton_Gameplay_No"> - <property name="text"> - <string>No The game crashes or freezes while loading or using the menu</string> - </property> - </widget> - </item> - <item row="0" column="0" colspan="2"> - <widget class="QLabel" name="lbl_Independent2"> - <property name="font"> - <font> - <pointsize>10</pointsize> - </font> - </property> - <property name="text"> - <string><html><head/><body><p>Does the game reach gameplay?</p></body></html></string> - </property> - <property name="wordWrap"> - <bool>true</bool> - </property> - </widget> - </item> - <item row="1" column="0" colspan="2"> - <spacer name="verticalSpacer2"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>0</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - <widget class="QWizardPage" name="wizard_NoFreeze"> - <property name="title"> - <string>Report Game Compatibility</string> - </property> - <attribute name="pageId"> - <string notr="true">3</string> - </attribute> - <layout class="QFormLayout" name="formLayout3"> - <item row="2" column="0"> - <widget class="QRadioButton" name="radioButton_NoFreeze_Yes"> - <property name="text"> - <string>Yes The game works without crashes</string> - </property> - </widget> - </item> - <item row="4" column="0"> - <widget class="QRadioButton" name="radioButton_NoFreeze_No"> - <property name="text"> - <string>No The game crashes or freezes during gameplay</string> - </property> - </widget> - </item> - <item row="0" column="0" colspan="2"> - <widget class="QLabel" name="lbl_Independent3"> - <property name="font"> - <font> - <pointsize>10</pointsize> - </font> - </property> - <property name="text"> - <string><html><head/><body><p>Does the game work without crashing, freezing or locking up during gameplay?</p></body></html></string> - </property> - <property name="wordWrap"> - <bool>true</bool> - </property> - </widget> - </item> - <item row="1" column="0" colspan="2"> - <spacer name="verticalSpacer3"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>0</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - <widget class="QWizardPage" name="wizard_Complete"> - <property name="title"> - <string>Report Game Compatibility</string> - </property> - <attribute name="pageId"> - <string notr="true">4</string> - </attribute> - <layout class="QFormLayout" name="formLayout4"> - <item row="2" column="0"> - <widget class="QRadioButton" name="radioButton_Complete_Yes"> - <property name="text"> - <string>Yes The game can be finished without any workarounds</string> - </property> - </widget> - </item> - <item row="4" column="0"> - <widget class="QRadioButton" name="radioButton_Complete_No"> - <property name="text"> - <string>No The game can't progress past a certain area</string> - </property> - </widget> - </item> - <item row="0" column="0" colspan="2"> - <widget class="QLabel" name="lbl_Independent4"> - <property name="font"> - <font> - <pointsize>10</pointsize> - </font> - </property> - <property name="text"> - <string><html><head/><body><p>Is the game completely playable from start to finish?</p></body></html></string> - </property> - <property name="wordWrap"> - <bool>true</bool> - </property> - </widget> - </item> - <item row="1" column="0" colspan="2"> - <spacer name="verticalSpacer4"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>0</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - <widget class="QWizardPage" name="wizard_Graphical"> - <property name="title"> - <string>Report Game Compatibility</string> - </property> - <attribute name="pageId"> - <string notr="true">5</string> - </attribute> - <layout class="QFormLayout" name="formLayout5"> - <item row="2" column="0"> - <widget class="QRadioButton" name="radioButton_Graphical_Major"> - <property name="text"> - <string>Major The game has major graphical errors</string> - </property> - </widget> - </item> - <item row="4" column="0"> - <widget class="QRadioButton" name="radioButton_Graphical_Minor"> - <property name="text"> - <string>Minor The game has minor graphical errors</string> - </property> - </widget> - </item> - <item row="6" column="0"> - <widget class="QRadioButton" name="radioButton_Graphical_No"> - <property name="text"> - <string>None Everything is rendered as it looks on the Nintendo Switch</string> - </property> - </widget> - </item> - <item row="0" column="0" colspan="2"> - <widget class="QLabel" name="lbl_Independent5"> - <property name="font"> - <font> - <pointsize>10</pointsize> - </font> - </property> - <property name="text"> - <string><html><head/><body><p>Does the game have any graphical glitches?</p></body></html></string> - </property> - <property name="wordWrap"> - <bool>true</bool> - </property> - </widget> - </item> - <item row="1" column="0" colspan="2"> - <spacer name="verticalSpacer5"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>0</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - <widget class="QWizardPage" name="wizard_Audio"> - <property name="title"> - <string>Report Game Compatibility</string> - </property> - <attribute name="pageId"> - <string notr="true">6</string> - </attribute> - <layout class="QFormLayout" name="formLayout6"> - <item row="2" column="0"> - <widget class="QRadioButton" name="radioButton_Audio_Major"> - <property name="text"> - <string>Major The game has major audio errors</string> - </property> - </widget> - </item> - <item row="4" column="0"> - <widget class="QRadioButton" name="radioButton_Audio_Minor"> - <property name="text"> - <string>Minor The game has minor audio errors</string> - </property> - </widget> - </item> - <item row="6" column="0"> - <widget class="QRadioButton" name="radioButton_Audio_No"> - <property name="text"> - <string>None Audio is played perfectly</string> - </property> - </widget> - </item> - <item row="0" column="0" colspan="2"> - <widget class="QLabel" name="lbl_Independent6"> - <property name="font"> - <font> - <pointsize>10</pointsize> - </font> - </property> - <property name="text"> - <string><html><head/><body><p>Does the game have any audio glitches / missing effects?</p></body></html></string> - </property> - <property name="wordWrap"> - <bool>true</bool> - </property> - </widget> - </item> - <item row="1" column="0" colspan="2"> - <spacer name="verticalSpacer6"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>0</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - <widget class="QWizardPage" name="wizard_ThankYou"> - <property name="title"> - <string>Thank you for your submission!</string> - </property> - <attribute name="pageId"> - <string notr="true">7</string> - </attribute> - </widget> - </widget> - <resources/> - <connections/> -</ui> diff --git a/src/yuzu/compatibility_list.cpp b/src/yuzu/compatibility_list.cpp deleted file mode 100644 index dbbe76448..000000000 --- a/src/yuzu/compatibility_list.cpp +++ /dev/null @@ -1,17 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include <algorithm> - -#include <fmt/format.h> - -#include "yuzu/compatibility_list.h" - -CompatibilityList::const_iterator FindMatchingCompatibilityEntry( - const CompatibilityList& compatibility_list, u64 program_id) { - return std::find_if(compatibility_list.begin(), compatibility_list.end(), - [program_id](const auto& element) { - std::string pid = fmt::format("{:016X}", program_id); - return element.first == pid; - }); -} diff --git a/src/yuzu/compatibility_list.h b/src/yuzu/compatibility_list.h deleted file mode 100644 index c0675d793..000000000 --- a/src/yuzu/compatibility_list.h +++ /dev/null @@ -1,16 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include <string> -#include <unordered_map> - -#include <QString> - -#include "common/common_types.h" - -using CompatibilityList = std::unordered_map<std::string, std::pair<QString, QString>>; - -CompatibilityList::const_iterator FindMatchingCompatibilityEntry( - const CompatibilityList& compatibility_list, u64 program_id); diff --git a/src/yuzu/configuration/configuration_shared.cpp b/src/yuzu/configuration/configuration_shared.cpp deleted file mode 100644 index 0ed6146a0..000000000 --- a/src/yuzu/configuration/configuration_shared.cpp +++ /dev/null @@ -1,19 +0,0 @@ -// SPDX-FileCopyrightText: 2016 Citra Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include <memory> -#include <type_traits> -#include <vector> -#include "yuzu/configuration/configuration_shared.h" - -namespace ConfigurationShared { - -Tab::Tab(std::shared_ptr<std::vector<Tab*>> group, QWidget* parent) : QWidget(parent) { - if (group != nullptr) { - group->push_back(this); - } -} - -Tab::~Tab() = default; - -} // namespace ConfigurationShared diff --git a/src/yuzu/configuration/configuration_shared.h b/src/yuzu/configuration/configuration_shared.h deleted file mode 100644 index 31897a6b0..000000000 --- a/src/yuzu/configuration/configuration_shared.h +++ /dev/null @@ -1,27 +0,0 @@ -// SPDX-FileCopyrightText: 2016 Citra Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include <memory> -#include <vector> -#include <QString> -#include <QWidget> -#include <qobjectdefs.h> - -class QObject; - -namespace ConfigurationShared { - -class Tab : public QWidget { - Q_OBJECT - -public: - explicit Tab(std::shared_ptr<std::vector<Tab*>> group, QWidget* parent = nullptr); - ~Tab(); - - virtual void ApplyConfiguration() = 0; - virtual void SetConfiguration() = 0; -}; - -} // namespace ConfigurationShared diff --git a/src/yuzu/configuration/configure.ui b/src/yuzu/configuration/configure.ui deleted file mode 100644 index 573c40801..000000000 --- a/src/yuzu/configuration/configure.ui +++ /dev/null @@ -1,117 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>ConfigureDialog</class> - <widget class="QDialog" name="ConfigureDialog"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>650</width> - <height>650</height> - </rect> - </property> - <property name="minimumSize"> - <size> - <width>0</width> - <height>650</height> - </size> - </property> - <property name="windowTitle"> - <string>yuzu Configuration</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <layout class="QHBoxLayout" name="horizontalLayout"> - <item> - <widget class="QListWidget" name="selectorList"> - <property name="minimumSize"> - <size> - <width>120</width> - <height>0</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>120</width> - <height>16777215</height> - </size> - </property> - </widget> - </item> - <item> - <widget class="QTabWidget" name="tabWidget"> - <property name="currentIndex"> - <number>-1</number> - </property> - </widget> - </item> - </layout> - </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayout_2"> - <property name="leftMargin"> - <number>0</number> - </property> - <property name="topMargin"> - <number>0</number> - </property> - <property name="rightMargin"> - <number>0</number> - </property> - <property name="bottomMargin"> - <number>0</number> - </property> - <item> - <widget class="QLabel" name="label"> - <property name="text"> - <string>Some settings are only available when a game is not running.</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>ConfigureDialog</receiver> - <slot>accept()</slot> - <hints> - <hint type="sourcelabel"> - <x>20</x> - <y>20</y> - </hint> - <hint type="destinationlabel"> - <x>20</x> - <y>20</y> - </hint> - </hints> - </connection> - <connection> - <sender>buttonBox</sender> - <signal>rejected()</signal> - <receiver>ConfigureDialog</receiver> - <slot>reject()</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> -</ui> diff --git a/src/yuzu/configuration/configure_applets.cpp b/src/yuzu/configuration/configure_applets.cpp deleted file mode 100644 index 139bfa9da..000000000 --- a/src/yuzu/configuration/configure_applets.cpp +++ /dev/null @@ -1,84 +0,0 @@ -// SPDX-FileCopyrightText: 2024 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include "common/settings.h" -#include "core/core.h" -#include "ui_configure_applets.h" -#include "yuzu/configuration/configuration_shared.h" -#include "yuzu/configuration/configure_applets.h" -#include "yuzu/configuration/shared_widget.h" - -ConfigureApplets::ConfigureApplets(Core::System& system_, - std::shared_ptr<std::vector<ConfigurationShared::Tab*>> group_, - const ConfigurationShared::Builder& builder, QWidget* parent) - : Tab(group_, parent), ui{std::make_unique<Ui::ConfigureApplets>()}, system{system_} { - ui->setupUi(this); - - Setup(builder); - - SetConfiguration(); -} - -ConfigureApplets::~ConfigureApplets() = default; - -void ConfigureApplets::changeEvent(QEvent* event) { - if (event->type() == QEvent::LanguageChange) { - RetranslateUI(); - } - - QWidget::changeEvent(event); -} - -void ConfigureApplets::RetranslateUI() { - ui->retranslateUi(this); -} - -void ConfigureApplets::Setup(const ConfigurationShared::Builder& builder) { - auto& library_applets_layout = *ui->group_library_applet_modes->layout(); - std::map<u32, QWidget*> applets_hold{}; - - std::vector<Settings::BasicSetting*> settings; - auto push = [&settings](auto& list) { - for (auto setting : list) { - settings.push_back(setting); - } - }; - - push(Settings::values.linkage.by_category[Settings::Category::LibraryApplet]); - - for (auto setting : settings) { - ConfigurationShared::Widget* widget = builder.BuildWidget(setting, apply_funcs); - - if (widget == nullptr) { - continue; - } - if (!widget->Valid()) { - widget->deleteLater(); - continue; - } - - // Untested applets - if (setting->Id() == Settings::values.data_erase_applet_mode.Id() || - setting->Id() == Settings::values.net_connect_applet_mode.Id() || - setting->Id() == Settings::values.shop_applet_mode.Id() || - setting->Id() == Settings::values.login_share_applet_mode.Id() || - setting->Id() == Settings::values.wifi_web_auth_applet_mode.Id() || - setting->Id() == Settings::values.my_page_applet_mode.Id()) { - widget->setHidden(true); - } - - applets_hold.emplace(setting->Id(), widget); - } - for (const auto& [label, widget] : applets_hold) { - library_applets_layout.addWidget(widget); - } -} - -void ConfigureApplets::SetConfiguration() {} - -void ConfigureApplets::ApplyConfiguration() { - const bool powered_on = system.IsPoweredOn(); - for (const auto& func : apply_funcs) { - func(powered_on); - } -} diff --git a/src/yuzu/configuration/configure_applets.h b/src/yuzu/configuration/configure_applets.h deleted file mode 100644 index 54f494d2f..000000000 --- a/src/yuzu/configuration/configure_applets.h +++ /dev/null @@ -1,48 +0,0 @@ -// SPDX-FileCopyrightText: 2024 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include <QWidget> -#include "yuzu/configuration/configuration_shared.h" - -class QCheckBox; -class QLineEdit; -class QComboBox; -class QDateTimeEdit; -namespace Core { -class System; -} - -namespace Ui { -class ConfigureApplets; -} - -namespace ConfigurationShared { -class Builder; -} - -class ConfigureApplets : public ConfigurationShared::Tab { -public: - explicit ConfigureApplets(Core::System& system_, - std::shared_ptr<std::vector<ConfigurationShared::Tab*>> group, - const ConfigurationShared::Builder& builder, - QWidget* parent = nullptr); - ~ConfigureApplets() override; - - void ApplyConfiguration() override; - void SetConfiguration() override; - -private: - void changeEvent(QEvent* event) override; - void RetranslateUI(); - - void Setup(const ConfigurationShared::Builder& builder); - - std::vector<std::function<void(bool)>> apply_funcs{}; - - std::unique_ptr<Ui::ConfigureApplets> ui; - bool enabled = false; - - Core::System& system; -}; diff --git a/src/yuzu/configuration/configure_applets.ui b/src/yuzu/configuration/configure_applets.ui deleted file mode 100644 index 6f2ca66bd..000000000 --- a/src/yuzu/configuration/configure_applets.ui +++ /dev/null @@ -1,65 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>ConfigureApplets</class> - <widget class="QWidget" name="ConfigureApplets"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>605</width> - <height>300</height> - </rect> - </property> - <property name="windowTitle"> - <string>Form</string> - </property> - <property name="accessibleName"> - <string>Applets</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout_1"> - <item> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <widget class="QGroupBox" name="group_library_applet_modes"> - <property name="title"> - <string>Applet mode preference</string> - </property> - <layout class="QVBoxLayout"> - <item> - <widget class="QWidget" name="applets_widget" native="true"> - <layout class="QVBoxLayout" name="verticalLayout_3"> - <property name="leftMargin"> - <number>0</number> - </property> - <property name="topMargin"> - <number>0</number> - </property> - <property name="rightMargin"> - <number>0</number> - </property> - </layout> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </item> - <item> - <spacer name="verticalSpacer"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>40</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - <resources/> - <connections/> -</ui> diff --git a/src/yuzu/configuration/configure_audio.cpp b/src/yuzu/configuration/configure_audio.cpp deleted file mode 100644 index c235b0fca..000000000 --- a/src/yuzu/configuration/configure_audio.cpp +++ /dev/null @@ -1,278 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include <map> -#include <memory> -#include <vector> -#include <QComboBox> -#include <QPushButton> - -#include "audio_core/sink/sink.h" -#include "audio_core/sink/sink_details.h" -#include "common/common_types.h" -#include "common/settings.h" -#include "common/settings_common.h" -#include "core/core.h" -#include "ui_configure_audio.h" -#include "yuzu/configuration/configuration_shared.h" -#include "yuzu/configuration/configure_audio.h" -#include "yuzu/configuration/shared_translation.h" -#include "yuzu/configuration/shared_widget.h" -#include "yuzu/uisettings.h" - -ConfigureAudio::ConfigureAudio(const Core::System& system_, - std::shared_ptr<std::vector<ConfigurationShared::Tab*>> group_, - const ConfigurationShared::Builder& builder, QWidget* parent) - : Tab(group_, parent), ui(std::make_unique<Ui::ConfigureAudio>()), system{system_} { - ui->setupUi(this); - Setup(builder); - - SetConfiguration(); -} - -ConfigureAudio::~ConfigureAudio() = default; - -void ConfigureAudio::Setup(const ConfigurationShared::Builder& builder) { - auto& layout = *ui->audio_widget->layout(); - - std::vector<Settings::BasicSetting*> settings; - - std::map<u32, QWidget*> hold; - - auto push_settings = [&](Settings::Category category) { - for (auto* setting : Settings::values.linkage.by_category[category]) { - settings.push_back(setting); - } - }; - - auto push_ui_settings = [&](Settings::Category category) { - for (auto* setting : UISettings::values.linkage.by_category[category]) { - settings.push_back(setting); - } - }; - - push_settings(Settings::Category::Audio); - push_settings(Settings::Category::SystemAudio); - push_ui_settings(Settings::Category::UiAudio); - - for (auto* setting : settings) { - auto* widget = builder.BuildWidget(setting, apply_funcs); - - if (widget == nullptr) { - continue; - } - if (!widget->Valid()) { - widget->deleteLater(); - continue; - } - - hold.emplace(std::pair{setting->Id(), widget}); - - auto global_sink_match = [this] { - return static_cast<Settings::AudioEngine>(sink_combo_box->currentIndex()) == - Settings::values.sink_id.GetValue(true); - }; - if (setting->Id() == Settings::values.sink_id.Id()) { - // TODO (lat9nq): Let the system manage sink_id - sink_combo_box = widget->combobox; - InitializeAudioSinkComboBox(); - - if (Settings::IsConfiguringGlobal()) { - connect(sink_combo_box, qOverload<int>(&QComboBox::currentIndexChanged), this, - &ConfigureAudio::UpdateAudioDevices); - } else { - restore_sink_button = ConfigurationShared::Widget::CreateRestoreGlobalButton( - Settings::values.sink_id.UsingGlobal(), widget); - widget->layout()->addWidget(restore_sink_button); - connect(restore_sink_button, &QAbstractButton::clicked, [this](bool) { - Settings::values.sink_id.SetGlobal(true); - const int sink_index = static_cast<int>(Settings::values.sink_id.GetValue()); - sink_combo_box->setCurrentIndex(sink_index); - ConfigureAudio::UpdateAudioDevices(sink_index); - Settings::values.audio_output_device_id.SetGlobal(true); - Settings::values.audio_input_device_id.SetGlobal(true); - restore_sink_button->setVisible(false); - }); - connect(sink_combo_box, qOverload<int>(&QComboBox::currentIndexChanged), - [this, global_sink_match](const int slot) { - Settings::values.sink_id.SetGlobal(false); - Settings::values.audio_output_device_id.SetGlobal(false); - Settings::values.audio_input_device_id.SetGlobal(false); - - restore_sink_button->setVisible(true); - restore_sink_button->setEnabled(true); - output_device_combo_box->setCurrentIndex(0); - restore_output_device_button->setVisible(true); - restore_output_device_button->setEnabled(global_sink_match()); - input_device_combo_box->setCurrentIndex(0); - restore_input_device_button->setVisible(true); - restore_input_device_button->setEnabled(global_sink_match()); - ConfigureAudio::UpdateAudioDevices(slot); - }); - } - } else if (setting->Id() == Settings::values.audio_output_device_id.Id()) { - // Keep track of output (and input) device comboboxes to populate them with system - // devices, which are determined at run time - output_device_combo_box = widget->combobox; - - if (!Settings::IsConfiguringGlobal()) { - restore_output_device_button = - ConfigurationShared::Widget::CreateRestoreGlobalButton( - Settings::values.audio_output_device_id.UsingGlobal(), widget); - restore_output_device_button->setEnabled(global_sink_match()); - restore_output_device_button->setVisible( - !Settings::values.audio_output_device_id.UsingGlobal()); - widget->layout()->addWidget(restore_output_device_button); - connect(restore_output_device_button, &QAbstractButton::clicked, [this](bool) { - Settings::values.audio_output_device_id.SetGlobal(true); - SetOutputDevicesFromDeviceID(); - restore_output_device_button->setVisible(false); - }); - connect(output_device_combo_box, qOverload<int>(&QComboBox::currentIndexChanged), - [this, global_sink_match](int) { - if (updating_devices) { - return; - } - Settings::values.audio_output_device_id.SetGlobal(false); - restore_output_device_button->setVisible(true); - restore_output_device_button->setEnabled(global_sink_match()); - }); - } - } else if (setting->Id() == Settings::values.audio_input_device_id.Id()) { - input_device_combo_box = widget->combobox; - - if (!Settings::IsConfiguringGlobal()) { - restore_input_device_button = - ConfigurationShared::Widget::CreateRestoreGlobalButton( - Settings::values.audio_input_device_id.UsingGlobal(), widget); - widget->layout()->addWidget(restore_input_device_button); - connect(restore_input_device_button, &QAbstractButton::clicked, [this](bool) { - Settings::values.audio_input_device_id.SetGlobal(true); - SetInputDevicesFromDeviceID(); - restore_input_device_button->setVisible(false); - }); - connect(input_device_combo_box, qOverload<int>(&QComboBox::currentIndexChanged), - [this, global_sink_match](int) { - if (updating_devices) { - return; - } - Settings::values.audio_input_device_id.SetGlobal(false); - restore_input_device_button->setVisible(true); - restore_input_device_button->setEnabled(global_sink_match()); - }); - } - } - } - - for (const auto& [id, widget] : hold) { - layout.addWidget(widget); - } -} - -void ConfigureAudio::SetConfiguration() { - SetOutputSinkFromSinkID(); - - // The device list cannot be pre-populated (nor listed) until the output sink is known. - UpdateAudioDevices(sink_combo_box->currentIndex()); - - SetOutputDevicesFromDeviceID(); - SetInputDevicesFromDeviceID(); -} - -void ConfigureAudio::SetOutputSinkFromSinkID() { - [[maybe_unused]] const QSignalBlocker blocker(sink_combo_box); - - int new_sink_index = 0; - const QString sink_id = QString::fromStdString(Settings::values.sink_id.ToString()); - for (int index = 0; index < sink_combo_box->count(); index++) { - if (sink_combo_box->itemText(index) == sink_id) { - new_sink_index = index; - break; - } - } - - sink_combo_box->setCurrentIndex(new_sink_index); -} - -void ConfigureAudio::SetOutputDevicesFromDeviceID() { - int new_device_index = 0; - - const QString output_device_id = - QString::fromStdString(Settings::values.audio_output_device_id.GetValue()); - for (int index = 0; index < output_device_combo_box->count(); index++) { - if (output_device_combo_box->itemText(index) == output_device_id) { - new_device_index = index; - break; - } - } - - output_device_combo_box->setCurrentIndex(new_device_index); -} - -void ConfigureAudio::SetInputDevicesFromDeviceID() { - int new_device_index = 0; - const QString input_device_id = - QString::fromStdString(Settings::values.audio_input_device_id.GetValue()); - for (int index = 0; index < input_device_combo_box->count(); index++) { - if (input_device_combo_box->itemText(index) == input_device_id) { - new_device_index = index; - break; - } - } - - input_device_combo_box->setCurrentIndex(new_device_index); -} - -void ConfigureAudio::ApplyConfiguration() { - const bool is_powered_on = system.IsPoweredOn(); - for (const auto& apply_func : apply_funcs) { - apply_func(is_powered_on); - } - - Settings::values.sink_id.LoadString( - sink_combo_box->itemText(sink_combo_box->currentIndex()).toStdString()); - Settings::values.audio_output_device_id.SetValue( - output_device_combo_box->itemText(output_device_combo_box->currentIndex()).toStdString()); - Settings::values.audio_input_device_id.SetValue( - input_device_combo_box->itemText(input_device_combo_box->currentIndex()).toStdString()); -} - -void ConfigureAudio::changeEvent(QEvent* event) { - if (event->type() == QEvent::LanguageChange) { - RetranslateUI(); - } - - QWidget::changeEvent(event); -} - -void ConfigureAudio::UpdateAudioDevices(int sink_index) { - updating_devices = true; - output_device_combo_box->clear(); - output_device_combo_box->addItem(QString::fromUtf8(AudioCore::Sink::auto_device_name)); - - const auto sink_id = - Settings::ToEnum<Settings::AudioEngine>(sink_combo_box->itemText(sink_index).toStdString()); - for (const auto& device : AudioCore::Sink::GetDeviceListForSink(sink_id, false)) { - output_device_combo_box->addItem(QString::fromStdString(device)); - } - - input_device_combo_box->clear(); - input_device_combo_box->addItem(QString::fromUtf8(AudioCore::Sink::auto_device_name)); - for (const auto& device : AudioCore::Sink::GetDeviceListForSink(sink_id, true)) { - input_device_combo_box->addItem(QString::fromStdString(device)); - } - updating_devices = false; -} - -void ConfigureAudio::InitializeAudioSinkComboBox() { - sink_combo_box->clear(); - sink_combo_box->addItem(QString::fromUtf8(AudioCore::Sink::auto_device_name)); - - for (const auto& id : AudioCore::Sink::GetSinkIDs()) { - sink_combo_box->addItem(QString::fromStdString(Settings::CanonicalizeEnum(id))); - } -} - -void ConfigureAudio::RetranslateUI() { - ui->retranslateUi(this); -} diff --git a/src/yuzu/configuration/configure_audio.h b/src/yuzu/configuration/configure_audio.h deleted file mode 100644 index 32a2fa5f0..000000000 --- a/src/yuzu/configuration/configure_audio.h +++ /dev/null @@ -1,66 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include <functional> -#include <memory> -#include <vector> -#include <QWidget> -#include "yuzu/configuration/configuration_shared.h" - -class QComboBox; - -namespace Core { -class System; -} - -namespace Ui { -class ConfigureAudio; -} - -namespace ConfigurationShared { -class Builder; -} - -class ConfigureAudio : public ConfigurationShared::Tab { - Q_OBJECT - -public: - explicit ConfigureAudio(const Core::System& system_, - std::shared_ptr<std::vector<ConfigurationShared::Tab*>> group, - const ConfigurationShared::Builder& builder, QWidget* parent = nullptr); - ~ConfigureAudio() override; - - void ApplyConfiguration() override; - void SetConfiguration() override; - -private: - void changeEvent(QEvent* event) override; - - void InitializeAudioSinkComboBox(); - - void RetranslateUI(); - - void UpdateAudioDevices(int sink_index); - - void SetOutputSinkFromSinkID(); - void SetOutputDevicesFromDeviceID(); - void SetInputDevicesFromDeviceID(); - - void Setup(const ConfigurationShared::Builder& builder); - - std::unique_ptr<Ui::ConfigureAudio> ui; - - const Core::System& system; - - std::vector<std::function<void(bool)>> apply_funcs{}; - - bool updating_devices = false; - QComboBox* sink_combo_box; - QPushButton* restore_sink_button; - QComboBox* output_device_combo_box; - QPushButton* restore_output_device_button; - QComboBox* input_device_combo_box; - QPushButton* restore_input_device_button; -}; diff --git a/src/yuzu/configuration/configure_audio.ui b/src/yuzu/configuration/configure_audio.ui deleted file mode 100644 index 1181aeb00..000000000 --- a/src/yuzu/configuration/configure_audio.ui +++ /dev/null @@ -1,67 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>ConfigureAudio</class> - <widget class="QWidget" name="ConfigureAudio"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>367</width> - <height>368</height> - </rect> - </property> - <property name="accessibleName"> - <string>Audio</string> - </property> - <layout class="QVBoxLayout"> - <item> - <widget class="QGroupBox" name="groupBox"> - <property name="title"> - <string>Audio</string> - </property> - <layout class="QVBoxLayout"> - <item> - <widget class="QWidget" name="audio_widget" native="true"> - <property name="maximumSize"> - <size> - <width>16777215</width> - <height>16777213</height> - </size> - </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <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> - </layout> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <spacer> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>167</width> - <height>55</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - <resources/> - <connections/> -</ui> diff --git a/src/yuzu/configuration/configure_camera.cpp b/src/yuzu/configuration/configure_camera.cpp deleted file mode 100644 index 3368f53f3..000000000 --- a/src/yuzu/configuration/configure_camera.cpp +++ /dev/null @@ -1,163 +0,0 @@ -// Text : Copyright 2022 yuzu Emulator Project -// SPDX-License-Identifier: GPL-3.0-or-later - -#include <memory> -#include <QtCore> -#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) && YUZU_USE_QT_MULTIMEDIA -#include <QCameraImageCapture> -#include <QCameraInfo> -#endif -#include <QStandardItemModel> -#include <QTimer> - -#include "common/settings.h" -#include "input_common/drivers/camera.h" -#include "input_common/main.h" -#include "ui_configure_camera.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() { -#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) && YUZU_USE_QT_MULTIMEDIA - 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); -#endif -} - -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")); -#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) && YUZU_USE_QT_MULTIMEDIA - 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()); - } -#endif - - 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 deleted file mode 100644 index 3d822da7b..000000000 --- a/src/yuzu/configuration/configure_camera.h +++ /dev/null @@ -1,56 +0,0 @@ -// 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; -#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) && YUZU_USE_QT_MULTIMEDIA - std::unique_ptr<QCamera> camera; - std::unique_ptr<QCameraImageCapture> camera_capture; -#endif - 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 deleted file mode 100644 index 976a9b1ec..000000000 --- a/src/yuzu/configuration/configure_camera.ui +++ /dev/null @@ -1,170 +0,0 @@ -<?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 deleted file mode 100644 index 7e16cf17d..000000000 --- a/src/yuzu/configuration/configure_cpu.cpp +++ /dev/null @@ -1,114 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include <memory> -#include <typeinfo> -#include <vector> -#include <QComboBox> -#include "common/common_types.h" -#include "common/settings.h" -#include "common/settings_enums.h" -#include "configuration/shared_widget.h" -#include "core/core.h" -#include "ui_configure_cpu.h" -#include "yuzu/configuration/configuration_shared.h" -#include "yuzu/configuration/configure_cpu.h" - -ConfigureCpu::ConfigureCpu(const Core::System& system_, - std::shared_ptr<std::vector<ConfigurationShared::Tab*>> group_, - const ConfigurationShared::Builder& builder, QWidget* parent) - : Tab(group_, parent), ui{std::make_unique<Ui::ConfigureCpu>()}, system{system_}, - combobox_translations(builder.ComboboxTranslations()) { - ui->setupUi(this); - - Setup(builder); - - SetConfiguration(); - - connect(accuracy_combobox, qOverload<int>(&QComboBox::currentIndexChanged), this, - &ConfigureCpu::UpdateGroup); - - connect(backend_combobox, qOverload<int>(&QComboBox::currentIndexChanged), this, - &ConfigureCpu::UpdateGroup); - -#ifdef HAS_NCE - ui->backend_group->setVisible(true); -#endif -} - -ConfigureCpu::~ConfigureCpu() = default; - -void ConfigureCpu::SetConfiguration() {} -void ConfigureCpu::Setup(const ConfigurationShared::Builder& builder) { - auto* accuracy_layout = ui->widget_accuracy->layout(); - auto* backend_layout = ui->widget_backend->layout(); - auto* unsafe_layout = ui->unsafe_widget->layout(); - std::map<u32, QWidget*> unsafe_hold{}; - - std::vector<Settings::BasicSetting*> settings; - const auto push = [&](Settings::Category category) { - for (const auto setting : Settings::values.linkage.by_category[category]) { - settings.push_back(setting); - } - }; - - push(Settings::Category::Cpu); - push(Settings::Category::CpuUnsafe); - - for (const auto setting : settings) { - auto* widget = builder.BuildWidget(setting, apply_funcs); - - if (widget == nullptr) { - continue; - } - if (!widget->Valid()) { - widget->deleteLater(); - continue; - } - - if (setting->Id() == Settings::values.cpu_accuracy.Id()) { - // Keep track of cpu_accuracy combobox to display/hide the unsafe settings - accuracy_layout->addWidget(widget); - accuracy_combobox = widget->combobox; - } else if (setting->Id() == Settings::values.cpu_backend.Id()) { - backend_layout->addWidget(widget); - backend_combobox = widget->combobox; - } else { - // Presently, all other settings here are unsafe checkboxes - unsafe_hold.insert({setting->Id(), widget}); - } - } - - for (const auto& [label, widget] : unsafe_hold) { - unsafe_layout->addWidget(widget); - } - - UpdateGroup(accuracy_combobox->currentIndex()); - UpdateGroup(backend_combobox->currentIndex()); -} - -void ConfigureCpu::UpdateGroup(int index) { - const auto accuracy = static_cast<Settings::CpuAccuracy>( - combobox_translations.at(Settings::EnumMetadata<Settings::CpuAccuracy>::Index())[index] - .first); - ui->unsafe_group->setVisible(accuracy == Settings::CpuAccuracy::Unsafe); -} - -void ConfigureCpu::ApplyConfiguration() { - const bool is_powered_on = system.IsPoweredOn(); - for (const auto& apply_func : apply_funcs) { - apply_func(is_powered_on); - } -} - -void ConfigureCpu::changeEvent(QEvent* event) { - if (event->type() == QEvent::LanguageChange) { - RetranslateUI(); - } - - QWidget::changeEvent(event); -} - -void ConfigureCpu::RetranslateUI() { - ui->retranslateUi(this); -} diff --git a/src/yuzu/configuration/configure_cpu.h b/src/yuzu/configuration/configure_cpu.h deleted file mode 100644 index 7bbeac496..000000000 --- a/src/yuzu/configuration/configure_cpu.h +++ /dev/null @@ -1,55 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include <memory> -#include <vector> -#include <QWidget> -#include "yuzu/configuration/configuration_shared.h" -#include "yuzu/configuration/shared_translation.h" - -class QComboBox; - -namespace Core { -class System; -} - -namespace Ui { -class ConfigureCpu; -} - -namespace ConfigurationShared { -class Builder; -} - -class ConfigureCpu : public ConfigurationShared::Tab { - Q_OBJECT - -public: - explicit ConfigureCpu(const Core::System& system_, - std::shared_ptr<std::vector<ConfigurationShared::Tab*>> group, - const ConfigurationShared::Builder& builder, QWidget* parent = nullptr); - ~ConfigureCpu() override; - - void ApplyConfiguration() override; - void SetConfiguration() override; - -private: - void changeEvent(QEvent* event) override; - void RetranslateUI(); - - void UpdateGroup(int index); - - void Setup(const ConfigurationShared::Builder& builder); - - std::unique_ptr<Ui::ConfigureCpu> ui; - - const Core::System& system; - - const ConfigurationShared::ComboboxTranslationMap& combobox_translations; - std::vector<std::function<void(bool)>> apply_funcs{}; - - QComboBox* accuracy_combobox; - QComboBox* backend_combobox; -}; diff --git a/src/yuzu/configuration/configure_cpu.ui b/src/yuzu/configuration/configure_cpu.ui deleted file mode 100644 index 13fd43605..000000000 --- a/src/yuzu/configuration/configure_cpu.ui +++ /dev/null @@ -1,151 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>ConfigureCpu</class> - <widget class="QWidget" name="ConfigureCpu"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>448</width> - <height>439</height> - </rect> - </property> - <property name="windowTitle"> - <string>Form</string> - </property> - <property name="accessibleName"> - <string>CPU</string> - </property> - <layout class="QVBoxLayout" name="vboxlayout_2" stretch="0"> - <item> - <layout class="QVBoxLayout" name="vboxlayout"> - <property name="bottomMargin"> - <number>0</number> - </property> - <item> - <widget class="QGroupBox" name="groupBox"> - <property name="title"> - <string>General</string> - </property> - <layout class="QVBoxLayout"> - <item> - <widget class="QWidget" name="widget_accuracy" native="true"> - <layout class="QVBoxLayout" name="verticalLayout"> - <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> - </layout> - </widget> - </item> - <item> - <widget class="QLabel" name="label_recommended_accuracy"> - <property name="text"> - <string>We recommend setting accuracy to "Auto".</string> - </property> - <property name="wordWrap"> - <bool>false</bool> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QGroupBox" name="backend_group"> - <property name="title"> - <string>CPU Backend</string> - </property> - <layout class="QVBoxLayout"> - <item> - <widget class="QWidget" name="widget_backend" native="true"> - <layout class="QVBoxLayout" name="verticalLayout1"> - <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> - </layout> - </widget> - </item> - </layout> - <property name="visible"> - <bool>false</bool> - </property> - </widget> - </item> - <item> - <widget class="QGroupBox" name="unsafe_group"> - <property name="title"> - <string>Unsafe CPU Optimization Settings</string> - </property> - <layout class="QVBoxLayout"> - <item> - <widget class="QLabel" name="label_accuracy_description"> - <property name="text"> - <string>These settings reduce accuracy for speed.</string> - </property> - <property name="wordWrap"> - <bool>false</bool> - </property> - </widget> - </item> - <item> - <widget class="QWidget" name="unsafe_widget" native="true"> - <layout class="QVBoxLayout" name="unsafe_layout"> - <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> - </layout> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <spacer name="verticalSpacer"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeType"> - <enum>QSizePolicy::Expanding</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>40</height> - </size> - </property> - </spacer> - </item> - </layout> - </item> - </layout> - </widget> - <resources/> - <connections/> -</ui> diff --git a/src/yuzu/configuration/configure_cpu_debug.cpp b/src/yuzu/configuration/configure_cpu_debug.cpp deleted file mode 100644 index 8cfef0cc1..000000000 --- a/src/yuzu/configuration/configure_cpu_debug.cpp +++ /dev/null @@ -1,78 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include "common/settings.h" -#include "core/core.h" -#include "ui_configure_cpu_debug.h" -#include "yuzu/configuration/configure_cpu_debug.h" - -ConfigureCpuDebug::ConfigureCpuDebug(const Core::System& system_, QWidget* parent) - : QWidget(parent), ui{std::make_unique<Ui::ConfigureCpuDebug>()}, system{system_} { - ui->setupUi(this); - - SetConfiguration(); -} - -ConfigureCpuDebug::~ConfigureCpuDebug() = default; - -void ConfigureCpuDebug::SetConfiguration() { - const bool runtime_lock = !system.IsPoweredOn(); - - ui->cpuopt_page_tables->setEnabled(runtime_lock); - ui->cpuopt_page_tables->setChecked(Settings::values.cpuopt_page_tables.GetValue()); - ui->cpuopt_block_linking->setEnabled(runtime_lock); - ui->cpuopt_block_linking->setChecked(Settings::values.cpuopt_block_linking.GetValue()); - ui->cpuopt_return_stack_buffer->setEnabled(runtime_lock); - ui->cpuopt_return_stack_buffer->setChecked( - Settings::values.cpuopt_return_stack_buffer.GetValue()); - ui->cpuopt_fast_dispatcher->setEnabled(runtime_lock); - ui->cpuopt_fast_dispatcher->setChecked(Settings::values.cpuopt_fast_dispatcher.GetValue()); - ui->cpuopt_context_elimination->setEnabled(runtime_lock); - ui->cpuopt_context_elimination->setChecked( - Settings::values.cpuopt_context_elimination.GetValue()); - ui->cpuopt_const_prop->setEnabled(runtime_lock); - ui->cpuopt_const_prop->setChecked(Settings::values.cpuopt_const_prop.GetValue()); - ui->cpuopt_misc_ir->setEnabled(runtime_lock); - ui->cpuopt_misc_ir->setChecked(Settings::values.cpuopt_misc_ir.GetValue()); - ui->cpuopt_reduce_misalign_checks->setEnabled(runtime_lock); - ui->cpuopt_reduce_misalign_checks->setChecked( - 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()); - ui->cpuopt_ignore_memory_aborts->setEnabled(runtime_lock); - ui->cpuopt_ignore_memory_aborts->setChecked( - Settings::values.cpuopt_ignore_memory_aborts.GetValue()); -} - -void ConfigureCpuDebug::ApplyConfiguration() { - Settings::values.cpuopt_page_tables = ui->cpuopt_page_tables->isChecked(); - Settings::values.cpuopt_block_linking = ui->cpuopt_block_linking->isChecked(); - Settings::values.cpuopt_return_stack_buffer = ui->cpuopt_return_stack_buffer->isChecked(); - Settings::values.cpuopt_fast_dispatcher = ui->cpuopt_fast_dispatcher->isChecked(); - Settings::values.cpuopt_context_elimination = ui->cpuopt_context_elimination->isChecked(); - Settings::values.cpuopt_const_prop = ui->cpuopt_const_prop->isChecked(); - 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(); - Settings::values.cpuopt_ignore_memory_aborts = ui->cpuopt_ignore_memory_aborts->isChecked(); -} - -void ConfigureCpuDebug::changeEvent(QEvent* event) { - if (event->type() == QEvent::LanguageChange) { - RetranslateUI(); - } - - QWidget::changeEvent(event); -} - -void ConfigureCpuDebug::RetranslateUI() { - ui->retranslateUi(this); -} diff --git a/src/yuzu/configuration/configure_cpu_debug.h b/src/yuzu/configuration/configure_cpu_debug.h deleted file mode 100644 index 566ae7ecc..000000000 --- a/src/yuzu/configuration/configure_cpu_debug.h +++ /dev/null @@ -1,35 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include <memory> -#include <QWidget> - -namespace Core { -class System; -} - -namespace Ui { -class ConfigureCpuDebug; -} - -class ConfigureCpuDebug : public QWidget { - Q_OBJECT - -public: - explicit ConfigureCpuDebug(const Core::System& system_, QWidget* parent = nullptr); - ~ConfigureCpuDebug() override; - - void ApplyConfiguration(); - -private: - void changeEvent(QEvent* event) override; - void RetranslateUI(); - - void SetConfiguration(); - - std::unique_ptr<Ui::ConfigureCpuDebug> ui; - - const Core::System& system; -}; diff --git a/src/yuzu/configuration/configure_cpu_debug.ui b/src/yuzu/configuration/configure_cpu_debug.ui deleted file mode 100644 index 3010f7fad..000000000 --- a/src/yuzu/configuration/configure_cpu_debug.ui +++ /dev/null @@ -1,223 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>ConfigureCpuDebug</class> - <widget class="QWidget" name="ConfigureCpuDebug"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>592</width> - <height>503</height> - </rect> - </property> - <property name="windowTitle"> - <string>Form</string> - </property> - <property name="accessibleName"> - <string>CPU</string> - </property> - <layout class="QVBoxLayout"> - <item> - <layout class="QVBoxLayout"> - <item> - <widget class="QGroupBox" name="groupBox"> - <property name="title"> - <string>Toggle CPU Optimizations</string> - </property> - <layout class="QVBoxLayout"> - <item> - <widget class="QLabel" name="label"> - <property name="text"> - <string><html><head/><body><p><span style=" font-weight:600;">For debugging only.</span><br/>If you're not sure what these do, keep all of these enabled. <br/>These settings, when disabled, only take effect when CPU Debugging is enabled. </p></body></html></string> - </property> - <property name="wordWrap"> - <bool>false</bool> - </property> - </widget> - </item> - <item> - <widget class="QCheckBox" name="cpuopt_page_tables"> - <property name="toolTip"> - <string> - <div style="white-space: nowrap">This optimization speeds up memory accesses by the guest program.</div> - <div style="white-space: nowrap">Enabling it inlines accesses to PageTable::pointers into emitted code.</div> - <div style="white-space: nowrap">Disabling this forces all memory accesses to go through the Memory::Read/Memory::Write functions.</div> - </string> - </property> - <property name="text"> - <string>Enable inline page tables</string> - </property> - </widget> - </item> - <item> - <widget class="QCheckBox" name="cpuopt_block_linking"> - <property name="toolTip"> - <string> - <div>This optimization avoids dispatcher lookups by allowing emitted basic blocks to jump directly to other basic blocks if the destination PC is static.</div> - </string> - </property> - <property name="text"> - <string>Enable block linking</string> - </property> - </widget> - </item> - <item> - <widget class="QCheckBox" name="cpuopt_return_stack_buffer"> - <property name="toolTip"> - <string> - <div>This optimization avoids dispatcher lookups by keeping track potential return addresses of BL instructions. This approximates what happens with a return stack buffer on a real CPU.</div> - </string> - </property> - <property name="text"> - <string>Enable return stack buffer</string> - </property> - </widget> - </item> - <item> - <widget class="QCheckBox" name="cpuopt_fast_dispatcher"> - <property name="toolTip"> - <string> - <div>Enable a two-tiered dispatch system. A faster dispatcher written in assembly has a small MRU cache of jump destinations is used first. If that fails, dispatch falls back to the slower C++ dispatcher.</div> - </string> - </property> - <property name="text"> - <string>Enable fast dispatcher</string> - </property> - </widget> - </item> - <item> - <widget class="QCheckBox" name="cpuopt_context_elimination"> - <property name="toolTip"> - <string> - <div>Enables an IR optimization that reduces unnecessary accesses to the CPU context structure.</div> - </string> - </property> - <property name="text"> - <string>Enable context elimination</string> - </property> - </widget> - </item> - <item> - <widget class="QCheckBox" name="cpuopt_const_prop"> - <property name="toolTip"> - <string> - <div>Enables IR optimizations that involve constant propagation.</div> - </string> - </property> - <property name="text"> - <string>Enable constant propagation</string> - </property> - </widget> - </item> - <item> - <widget class="QCheckBox" name="cpuopt_misc_ir"> - <property name="toolTip"> - <string> - <div>Enables miscellaneous IR optimizations.</div> - </string> - </property> - <property name="text"> - <string>Enable miscellaneous optimizations</string> - </property> - </widget> - </item> - <item> - <widget class="QCheckBox" name="cpuopt_reduce_misalign_checks"> - <property name="toolTip"> - <string> - <div style="white-space: nowrap">When enabled, a misalignment is only triggered when an access crosses a page boundary.</div> - <div style="white-space: nowrap">When disabled, a misalignment is triggered on all misaligned accesses.</div> - </string> - </property> - <property name="text"> - <string>Enable misalignment check reduction</string> - </property> - </widget> - </item> - <item> - <widget class="QCheckBox" name="cpuopt_fastmem"> - <property name="toolTip"> - <string> - <div style="white-space: nowrap">This optimization speeds up memory accesses by the guest program.</div> - <div style="white-space: nowrap">Enabling it causes guest memory reads/writes to be done directly into memory and make use of Host's MMU.</div> - <div style="white-space: nowrap">Disabling this forces all memory accesses to use Software MMU Emulation.</div> - </string> - </property> - <property name="text"> - <string>Enable Host MMU Emulation (general memory instructions)</string> - </property> - </widget> - </item> - <item> - <widget class="QCheckBox" name="cpuopt_fastmem_exclusives"> - <property name="toolTip"> - <string> - <div style="white-space: nowrap">This optimization speeds up exclusive memory accesses by the guest program.</div> - <div style="white-space: nowrap">Enabling it causes guest exclusive memory reads/writes to be done directly into memory and make use of Host's MMU.</div> - <div style="white-space: nowrap">Disabling this forces all exclusive memory accesses to use Software MMU Emulation.</div> - </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> - <div style="white-space: nowrap">This optimization speeds up exclusive memory accesses by the guest program.</div> - <div style="white-space: nowrap">Enabling it reduces the overhead of fastmem failure of exclusive memory accesses.</div> - </string> - </property> - <property name="text"> - <string>Enable recompilation of exclusive memory instructions</string> - </property> - </widget> - </item> - <item> - <widget class="QCheckBox" name="cpuopt_ignore_memory_aborts"> - <property name="toolTip"> - <string> - <div style="white-space: nowrap">This optimization speeds up memory accesses by allowing invalid memory accesses to succeed.</div> - <div style="white-space: nowrap">Enabling it reduces the overhead of all memory accesses and has no impact on programs that don't access invalid memory.</div> - </string> - </property> - <property name="text"> - <string>Enable fallbacks for invalid memory accesses</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </item> - <item> - <spacer name="verticalSpacer"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>40</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QLabel" name="label_disable_info"> - <property name="text"> - <string>CPU settings are available only when game is not running.</string> - </property> - <property name="wordWrap"> - <bool>true</bool> - </property> - </widget> - </item> - </layout> - </widget> - <resources/> - <connections/> -</ui> diff --git a/src/yuzu/configuration/configure_debug.cpp b/src/yuzu/configuration/configure_debug.cpp deleted file mode 100644 index 1010038b7..000000000 --- a/src/yuzu/configuration/configure_debug.cpp +++ /dev/null @@ -1,130 +0,0 @@ -// 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" -#include "common/logging/filter.h" -#include "common/settings.h" -#include "core/core.h" -#include "ui_configure_debug.h" -#include "yuzu/configuration/configure_debug.h" -#include "yuzu/debugger/console.h" -#include "yuzu/uisettings.h" - -ConfigureDebug::ConfigureDebug(const Core::System& system_, QWidget* parent) - : QScrollArea(parent), ui{std::make_unique<Ui::ConfigureDebug>()}, system{system_} { - ui->setupUi(this); - SetConfiguration(); - - connect(ui->open_log_button, &QPushButton::clicked, []() { - const auto path = - 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()); }); -} - -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())); - ui->homebrew_args_edit->setText( - QString::fromStdString(Settings::values.program_args.GetValue())); - 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()); - ui->enable_all_controllers->setChecked(Settings::values.enable_all_controllers.GetValue()); - ui->enable_renderdoc_hotkey->setEnabled(runtime_lock); - ui->enable_renderdoc_hotkey->setChecked(Settings::values.enable_renderdoc_hotkey.GetValue()); - ui->disable_buffer_reorder->setEnabled(runtime_lock); - ui->disable_buffer_reorder->setChecked(Settings::values.disable_buffer_reorder.GetValue()); - ui->enable_graphics_debugging->setEnabled(runtime_lock); - ui->enable_graphics_debugging->setChecked(Settings::values.renderer_debug.GetValue()); - ui->enable_shader_feedback->setEnabled(runtime_lock); - ui->enable_shader_feedback->setChecked(Settings::values.renderer_shader_feedback.GetValue()); - ui->enable_cpu_debugging->setEnabled(runtime_lock); - ui->enable_cpu_debugging->setChecked(Settings::values.cpu_debug_mode.GetValue()); - ui->enable_nsight_aftermath->setEnabled(runtime_lock); - 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_macro_hle->setEnabled(runtime_lock); - ui->disable_macro_hle->setChecked(Settings::values.disable_macro_hle.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 -} - -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.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(); - Settings::values.enable_all_controllers = ui->enable_all_controllers->isChecked(); - Settings::values.renderer_debug = ui->enable_graphics_debugging->isChecked(); - Settings::values.enable_renderdoc_hotkey = ui->enable_renderdoc_hotkey->isChecked(); - Settings::values.disable_buffer_reorder = ui->disable_buffer_reorder->isChecked(); - Settings::values.renderer_shader_feedback = ui->enable_shader_feedback->isChecked(); - 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.disable_macro_hle = ui->disable_macro_hle->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()); - Common::Log::SetGlobalFilter(filter); -} - -void ConfigureDebug::changeEvent(QEvent* event) { - if (event->type() == QEvent::LanguageChange) { - RetranslateUI(); - } - - QWidget::changeEvent(event); -} - -void ConfigureDebug::RetranslateUI() { - ui->retranslateUi(this); -} diff --git a/src/yuzu/configuration/configure_debug.h b/src/yuzu/configuration/configure_debug.h deleted file mode 100644 index 030a0b7f7..000000000 --- a/src/yuzu/configuration/configure_debug.h +++ /dev/null @@ -1,37 +0,0 @@ -// SPDX-FileCopyrightText: 2016 Citra Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include <memory> -#include <QScrollArea> - -namespace Core { -class System; -} - -namespace Ui { -class ConfigureDebug; -} - -class ConfigureDebug : public QScrollArea { - Q_OBJECT - -public: - explicit ConfigureDebug(const Core::System& system_, QWidget* parent = nullptr); - ~ConfigureDebug() override; - - void ApplyConfiguration(); - -private: - void changeEvent(QEvent* event) override; - - void RetranslateUI(); - void SetConfiguration(); - - 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 deleted file mode 100644 index d842b0135..000000000 --- a/src/yuzu/configuration/configure_debug.ui +++ /dev/null @@ -1,576 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>ConfigureDebug</class> - <widget class="QScrollArea" name="ConfigureDebug"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>831</width> - <height>760</height> - </rect> - </property> - <property name="widgetResizable"> - <bool>true</bool> - </property> - <widget class="QWidget" name="widget"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>842</width> - <height>741</height> - </rect> - </property> - <layout class="QVBoxLayout" name="verticalLayout_1"> - <item> - <layout class="QHBoxLayout" name="horizontalLayout"> - <property name="topMargin"> - <number>0</number> - </property> - <item> - <widget class="QGroupBox" name="groupBox"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="title"> - <string>Debugger</string> - </property> - <property name="alignment"> - <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> - </property> - <property name="flat"> - <bool>false</bool> - </property> - <property name="checkable"> - <bool>false</bool> - </property> - <layout class="QVBoxLayout" name="verticalLayout_3"> - <item> - <widget class="QWidget" name="debug_widget" native="true"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Maximum"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <property name="sizeConstraint"> - <enum>QLayout::SetDefaultConstraint</enum> - </property> - <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="QCheckBox" name="toggle_gdbstub"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Maximum" vsizetype="Maximum"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string>Enable GDB Stub</string> - </property> - </widget> - </item> - <item> - <widget class="QWidget" name="horizontalWidget_3" native="true"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Maximum"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <layout class="QHBoxLayout" name="horizontalLayout_3"> - <property name="leftMargin"> - <number>0</number> - </property> - <property name="topMargin"> - <number>0</number> - </property> - <property name="rightMargin"> - <number>0</number> - </property> - <property name="bottomMargin"> - <number>0</number> - </property> - <item> - <widget class="QLabel" name="label_11"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Minimum" vsizetype="Maximum"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string>Port:</string> - </property> - </widget> - </item> - <item> - <widget class="QSpinBox" name="gdbport_spinbox"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Maximum"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimum"> - <number>1024</number> - </property> - <property name="maximum"> - <number>65535</number> - </property> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QGroupBox" name="groupBox_2"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="title"> - <string>Logging</string> - </property> - <layout class="QGridLayout" name="gridLayout_1"> - <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="0" column="0" colspan="2"> - <widget class="QWidget" name="logging_widget" native="true"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Maximum"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <layout class="QHBoxLayout" name="horizontalLayout_1"> - <property name="leftMargin"> - <number>0</number> - </property> - <property name="topMargin"> - <number>0</number> - </property> - <property name="rightMargin"> - <number>0</number> - </property> - <property name="bottomMargin"> - <number>0</number> - </property> - <item> - <widget class="QLabel" name="label_1"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string>Global Log Filter</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="log_filter_edit"/> - </item> - </layout> - </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> - <item row="1" column="0"> - <widget class="QCheckBox" name="toggle_console"> - <property name="text"> - <string>Show Log in Console</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </item> - <item> - <widget class="QGroupBox" name="groupBox_3"> - <property name="title"> - <string>Homebrew</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout_5"> - <item> - <layout class="QHBoxLayout" name="horizontalLayout_4"> - <item> - <widget class="QLabel" name="label_3"> - <property name="text"> - <string>Arguments String</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="homebrew_args_edit"/> - </item> - </layout> - </item> - </layout> - </widget> - </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayout_2"> - <item> - <widget class="QGroupBox" name="groupBox_4"> - <property name="title"> - <string>Graphics</string> - </property> - <layout class="QGridLayout" name="gridLayout_2"> - <item row="4" column="0"> - <widget class="QCheckBox" name="disable_loop_safety_checks"> - <property name="toolTip"> - <string>When checked, it executes shaders without loop logic changes</string> - </property> - <property name="text"> - <string>Disable Loop safety checks</string> - </property> - </widget> - </item> - <item row="8" column="0"> - <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="3" column="0"> - <widget class="QCheckBox" name="enable_nsight_aftermath"> - <property name="toolTip"> - <string>When checked, it enables Nsight Aftermath crash dumps</string> - </property> - <property name="text"> - <string>Enable Nsight Aftermath</string> - </property> - </widget> - </item> - <item row="6" column="0"> - <widget class="QCheckBox" name="dump_shaders"> - <property name="enabled"> - <bool>true</bool> - </property> - <property name="toolTip"> - <string>When checked, it will dump all the original assembler shaders from the disk shader cache or game as found</string> - </property> - <property name="text"> - <string>Dump Game Shaders</string> - </property> - </widget> - </item> - <item row="1" column="0"> - <widget class="QCheckBox" name="enable_renderdoc_hotkey"> - <property name="text"> - <string>Enable Renderdoc Hotkey</string> - </property> - </widget> - </item> - <item row="7" column="0"> - <widget class="QCheckBox" name="disable_macro_jit"> - <property name="enabled"> - <bool>true</bool> - </property> - <property name="toolTip"> - <string>When checked, it disables the macro Just In Time compiler. Enabling this makes games run slower</string> - </property> - <property name="text"> - <string>Disable Macro JIT</string> - </property> - </widget> - </item> - <item row="9" column="0"> - <widget class="QCheckBox" name="disable_macro_hle"> - <property name="enabled"> - <bool>true</bool> - </property> - <property name="toolTip"> - <string>When checked, it disables the macro HLE functions. Enabling this makes games run slower</string> - </property> - <property name="text"> - <string>Disable Macro HLE</string> - </property> - </widget> - </item> - <item row="0" column="0"> - <widget class="QCheckBox" name="enable_graphics_debugging"> - <property name="enabled"> - <bool>true</bool> - </property> - <property name="toolTip"> - <string>When checked, the graphics API enters a slower debugging mode</string> - </property> - <property name="text"> - <string>Enable Graphics Debugging</string> - </property> - </widget> - </item> - <item row="10" column="0"> - <spacer name="verticalSpacer_5"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeType"> - <enum>QSizePolicy::Preferred</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>0</height> - </size> - </property> - </spacer> - </item> - <item row="2" column="0"> - <widget class="QCheckBox" name="enable_shader_feedback"> - <property name="toolTip"> - <string>When checked, yuzu will log statistics about the compiled pipeline cache</string> - </property> - <property name="text"> - <string>Enable Shader Feedback</string> - </property> - </widget> - </item> - <item row="5" column="0"> - <widget class="QCheckBox" name="disable_buffer_reorder"> - <property name="toolTip"> - <string><html><head/><body><p>When checked, disables reordering of mapped memory uploads which allows to associate uploads with specific draws. May reduce performance in some cases.</p></body></html></string> - </property> - <property name="text"> - <string>Disable Buffer Reorder</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QGroupBox" name="groupBox_6"> - <property name="title"> - <string>Advanced</string> - </property> - <layout class="QGridLayout" name="gridLayout_4"> - <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> - <item row="4" column="0"> - <widget class="QCheckBox" name="disable_web_applet"> - <property name="text"> - <string>Disable Web Applet</string> - </property> - </widget> - </item> - <item row="5" column="0"> - <widget class="QCheckBox" name="enable_all_controllers"> - <property name="text"> - <string>Enable All Controller Types</string> - </property> - </widget> - </item> - <item row="6" column="0"> - <widget class="QCheckBox" name="use_auto_stub"> - <property name="text"> - <string>Enable Auto-Stub**</string> - </property> - </widget> - </item> - <item row="0" column="0"> - <widget class="QCheckBox" name="quest_flag"> - <property name="text"> - <string>Kiosk (Quest) Mode</string> - </property> - </widget> - </item> - <item row="1" column="0"> - <widget class="QCheckBox" name="enable_cpu_debugging"> - <property name="text"> - <string>Enable CPU Debugging</string> - </property> - </widget> - </item> - <item row="2" column="0"> - <widget class="QCheckBox" name="use_debug_asserts"> - <property name="text"> - <string>Enable Debug Asserts</string> - </property> - </widget> - </item> - <item row="7" column="0"> - <spacer name="verticalSpacer_4"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeType"> - <enum>QSizePolicy::Expanding</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>0</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QGroupBox" name="groupBox_5"> - <property name="title"> - <string>Debugging</string> - </property> - <layout class="QGridLayout" name="gridLayout_3"> - <item row="0" column="0"> - <widget class="QCheckBox" name="fs_access_log"> - <property name="text"> - <string>Enable FS Access Log</string> - </property> - </widget> - </item> - <item row="3" column="0"> - <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>Dump Audio Commands To Console**</string> - </property> - </widget> - </item> - <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="5" column="0"> - <spacer name="verticalSpacer_3"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeType"> - <enum>QSizePolicy::Expanding</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>0</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - </item> - </layout> - </item> - <item> - <spacer name="verticalSpacer"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>0</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QLabel" name="label_5"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="font"> - <font> - <italic>true</italic> - </font> - </property> - <property name="text"> - <string>**This will be reset automatically when yuzu closes.</string> - </property> - <property name="indent"> - <number>20</number> - </property> - </widget> - </item> - </layout> - </widget> - </widget> - <tabstops> - <tabstop>log_filter_edit</tabstop> - <tabstop>toggle_console</tabstop> - <tabstop>extended_logging</tabstop> - <tabstop>open_log_button</tabstop> - <tabstop>homebrew_args_edit</tabstop> - <tabstop>enable_graphics_debugging</tabstop> - <tabstop>enable_shader_feedback</tabstop> - <tabstop>enable_nsight_aftermath</tabstop> - <tabstop>fs_access_log</tabstop> - <tabstop>reporting_services</tabstop> - <tabstop>quest_flag</tabstop> - <tabstop>enable_cpu_debugging</tabstop> - <tabstop>use_debug_asserts</tabstop> - </tabstops> - <resources/> - <connections/> -</ui> diff --git a/src/yuzu/configuration/configure_debug_controller.cpp b/src/yuzu/configuration/configure_debug_controller.cpp deleted file mode 100644 index 74208d1cc..000000000 --- a/src/yuzu/configuration/configure_debug_controller.cpp +++ /dev/null @@ -1,44 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include "hid_core/hid_core.h" -#include "ui_configure_debug_controller.h" -#include "yuzu/configuration/configure_debug_controller.h" -#include "yuzu/configuration/configure_input_player.h" - -ConfigureDebugController::ConfigureDebugController(QWidget* parent, - InputCommon::InputSubsystem* input_subsystem, - InputProfiles* profiles, - Core::HID::HIDCore& hid_core, bool is_powered_on) - : QDialog(parent), ui(std::make_unique<Ui::ConfigureDebugController>()), - debug_controller(new ConfigureInputPlayer(this, 9, nullptr, input_subsystem, profiles, - hid_core, is_powered_on, true)) { - ui->setupUi(this); - - ui->controllerLayout->addWidget(debug_controller); - - connect(ui->clear_all_button, &QPushButton::clicked, this, - [this] { debug_controller->ClearAll(); }); - connect(ui->restore_defaults_button, &QPushButton::clicked, this, - [this] { debug_controller->RestoreDefaults(); }); - - RetranslateUI(); -} - -ConfigureDebugController::~ConfigureDebugController() = default; - -void ConfigureDebugController::ApplyConfiguration() { - debug_controller->ApplyConfiguration(); -} - -void ConfigureDebugController::changeEvent(QEvent* event) { - if (event->type() == QEvent::LanguageChange) { - RetranslateUI(); - } - - QDialog::changeEvent(event); -} - -void ConfigureDebugController::RetranslateUI() { - ui->retranslateUi(this); -} diff --git a/src/yuzu/configuration/configure_debug_controller.h b/src/yuzu/configuration/configure_debug_controller.h deleted file mode 100644 index aaed717e2..000000000 --- a/src/yuzu/configuration/configure_debug_controller.h +++ /dev/null @@ -1,45 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include <memory> -#include <QDialog> - -class QPushButton; - -class ConfigureInputPlayer; - -class InputProfiles; - -namespace Core::HID { -class HIDCore; -} - -namespace InputCommon { -class InputSubsystem; -} - -namespace Ui { -class ConfigureDebugController; -} - -class ConfigureDebugController : public QDialog { - Q_OBJECT - -public: - explicit ConfigureDebugController(QWidget* parent, InputCommon::InputSubsystem* input_subsystem, - InputProfiles* profiles, Core::HID::HIDCore& hid_core, - bool is_powered_on); - ~ConfigureDebugController() override; - - void ApplyConfiguration(); - -private: - void changeEvent(QEvent* event) override; - void RetranslateUI(); - - std::unique_ptr<Ui::ConfigureDebugController> ui; - - ConfigureInputPlayer* debug_controller; -}; diff --git a/src/yuzu/configuration/configure_debug_controller.ui b/src/yuzu/configuration/configure_debug_controller.ui deleted file mode 100644 index 7b7e6582c..000000000 --- a/src/yuzu/configuration/configure_debug_controller.ui +++ /dev/null @@ -1,77 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>ConfigureDebugController</class> - <widget class="QDialog" name="ConfigureDebugController"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>780</width> - <height>500</height> - </rect> - </property> - <property name="windowTitle"> - <string>Configure Debug Controller</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <property name="spacing"> - <number>2</number> - </property> - <property name="leftMargin"> - <number>9</number> - </property> - <property name="topMargin"> - <number>9</number> - </property> - <property name="rightMargin"> - <number>9</number> - </property> - <property name="bottomMargin"> - <number>9</number> - </property> - <item> - <layout class="QHBoxLayout" name="controllerLayout"/> - </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayout"> - <item> - <widget class="QPushButton" name="clear_all_button"> - <property name="text"> - <string>Clear</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="restore_defaults_button"> - <property name="text"> - <string>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>ConfigureDebugController</receiver> - <slot>accept()</slot> - </connection> - <connection> - <sender>buttonBox</sender> - <signal>rejected()</signal> - <receiver>ConfigureDebugController</receiver> - <slot>reject()</slot> - </connection> - </connections> -</ui> diff --git a/src/yuzu/configuration/configure_debug_tab.cpp b/src/yuzu/configuration/configure_debug_tab.cpp deleted file mode 100644 index d1ca4752a..000000000 --- a/src/yuzu/configuration/configure_debug_tab.cpp +++ /dev/null @@ -1,45 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include <memory> -#include "ui_configure_debug_tab.h" -#include "yuzu/configuration/configure_cpu_debug.h" -#include "yuzu/configuration/configure_debug.h" -#include "yuzu/configuration/configure_debug_tab.h" - -ConfigureDebugTab::ConfigureDebugTab(const Core::System& system_, QWidget* parent) - : QWidget(parent), ui{std::make_unique<Ui::ConfigureDebugTab>()}, - debug_tab{std::make_unique<ConfigureDebug>(system_, this)}, - cpu_debug_tab{std::make_unique<ConfigureCpuDebug>(system_, this)} { - ui->setupUi(this); - - ui->tabWidget->addTab(debug_tab.get(), tr("Debug")); - ui->tabWidget->addTab(cpu_debug_tab.get(), tr("CPU")); - - SetConfiguration(); -} - -ConfigureDebugTab::~ConfigureDebugTab() = default; - -void ConfigureDebugTab::ApplyConfiguration() { - debug_tab->ApplyConfiguration(); - cpu_debug_tab->ApplyConfiguration(); -} - -void ConfigureDebugTab::SetCurrentIndex(int index) { - ui->tabWidget->setCurrentIndex(index); -} - -void ConfigureDebugTab::changeEvent(QEvent* event) { - if (event->type() == QEvent::LanguageChange) { - RetranslateUI(); - } - - QWidget::changeEvent(event); -} - -void ConfigureDebugTab::RetranslateUI() { - ui->retranslateUi(this); -} - -void ConfigureDebugTab::SetConfiguration() {} diff --git a/src/yuzu/configuration/configure_debug_tab.h b/src/yuzu/configuration/configure_debug_tab.h deleted file mode 100644 index c0fd9f73f..000000000 --- a/src/yuzu/configuration/configure_debug_tab.h +++ /dev/null @@ -1,41 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include <memory> -#include <QWidget> - -class ConfigureDebug; -class ConfigureCpuDebug; - -namespace Core { -class System; -} - -namespace Ui { -class ConfigureDebugTab; -} - -class ConfigureDebugTab : public QWidget { - Q_OBJECT - -public: - explicit ConfigureDebugTab(const Core::System& system_, QWidget* parent = nullptr); - ~ConfigureDebugTab() override; - - void ApplyConfiguration(); - - void SetCurrentIndex(int index); - -private: - void changeEvent(QEvent* event) override; - void RetranslateUI(); - - void SetConfiguration(); - - std::unique_ptr<Ui::ConfigureDebugTab> ui; - - std::unique_ptr<ConfigureDebug> debug_tab; - std::unique_ptr<ConfigureCpuDebug> cpu_debug_tab; -}; diff --git a/src/yuzu/configuration/configure_debug_tab.ui b/src/yuzu/configuration/configure_debug_tab.ui deleted file mode 100644 index 15ec74727..000000000 --- a/src/yuzu/configuration/configure_debug_tab.ui +++ /dev/null @@ -1,31 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>ConfigureDebugTab</class> - <widget class="QWidget" name="ConfigureDebugTab"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>320</width> - <height>240</height> - </rect> - </property> - <property name="windowTitle"> - <string>Form</string> - </property> - <property name="accessibleName"> - <string>Debug</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <widget class="QTabWidget" name="tabWidget"> - <property name="currentIndex"> - <number>-1</number> - </property> - </widget> - </item> - </layout> - </widget> - <resources/> - <connections/> -</ui> diff --git a/src/yuzu/configuration/configure_dialog.cpp b/src/yuzu/configuration/configure_dialog.cpp deleted file mode 100644 index 37f23388e..000000000 --- a/src/yuzu/configuration/configure_dialog.cpp +++ /dev/null @@ -1,213 +0,0 @@ -// SPDX-FileCopyrightText: 2016 Citra Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include <memory> -#include "common/logging/log.h" -#include "common/settings.h" -#include "common/settings_enums.h" -#include "core/core.h" -#include "ui_configure.h" -#include "vk_device_info.h" -#include "yuzu/configuration/configure_applets.h" -#include "yuzu/configuration/configure_audio.h" -#include "yuzu/configuration/configure_cpu.h" -#include "yuzu/configuration/configure_debug_tab.h" -#include "yuzu/configuration/configure_dialog.h" -#include "yuzu/configuration/configure_filesystem.h" -#include "yuzu/configuration/configure_general.h" -#include "yuzu/configuration/configure_graphics.h" -#include "yuzu/configuration/configure_graphics_advanced.h" -#include "yuzu/configuration/configure_hotkeys.h" -#include "yuzu/configuration/configure_input.h" -#include "yuzu/configuration/configure_input_player.h" -#include "yuzu/configuration/configure_network.h" -#include "yuzu/configuration/configure_profile_manager.h" -#include "yuzu/configuration/configure_system.h" -#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_, - InputCommon::InputSubsystem* input_subsystem, - std::vector<VkDeviceInfo::Record>& vk_device_records, - Core::System& system_, bool enable_web_config) - : QDialog(parent), ui{std::make_unique<Ui::ConfigureDialog>()}, - registry(registry_), system{system_}, builder{std::make_unique<ConfigurationShared::Builder>( - this, !system_.IsPoweredOn())}, - applets_tab{std::make_unique<ConfigureApplets>(system_, nullptr, *builder, this)}, - audio_tab{std::make_unique<ConfigureAudio>(system_, nullptr, *builder, this)}, - cpu_tab{std::make_unique<ConfigureCpu>(system_, nullptr, *builder, this)}, - debug_tab_tab{std::make_unique<ConfigureDebugTab>(system_, this)}, - filesystem_tab{std::make_unique<ConfigureFilesystem>(this)}, - general_tab{std::make_unique<ConfigureGeneral>(system_, nullptr, *builder, this)}, - graphics_advanced_tab{ - std::make_unique<ConfigureGraphicsAdvanced>(system_, nullptr, *builder, this)}, - ui_tab{std::make_unique<ConfigureUi>(system_, this)}, - graphics_tab{std::make_unique<ConfigureGraphics>( - system_, vk_device_records, [&]() { graphics_advanced_tab->ExposeComputeOption(); }, - [this](Settings::AspectRatio ratio, Settings::ResolutionSetup setup) { - ui_tab->UpdateScreenshotInfo(ratio, setup); - }, - nullptr, *builder, this)}, - hotkeys_tab{std::make_unique<ConfigureHotkeys>(system_.HIDCore(), this)}, - input_tab{std::make_unique<ConfigureInput>(system_, this)}, - network_tab{std::make_unique<ConfigureNetwork>(system_, this)}, - profile_tab{std::make_unique<ConfigureProfileManager>(system_, this)}, - system_tab{std::make_unique<ConfigureSystem>(system_, nullptr, *builder, this)}, - web_tab{std::make_unique<ConfigureWeb>(this)} { - Settings::SetConfiguringGlobal(true); - - ui->setupUi(this); - - ui->tabWidget->addTab(applets_tab.get(), tr("Applets")); - ui->tabWidget->addTab(audio_tab.get(), tr("Audio")); - ui->tabWidget->addTab(cpu_tab.get(), tr("CPU")); - ui->tabWidget->addTab(debug_tab_tab.get(), tr("Debug")); - ui->tabWidget->addTab(filesystem_tab.get(), tr("Filesystem")); - ui->tabWidget->addTab(general_tab.get(), tr("General")); - ui->tabWidget->addTab(graphics_tab.get(), tr("Graphics")); - ui->tabWidget->addTab(graphics_advanced_tab.get(), tr("GraphicsAdvanced")); - ui->tabWidget->addTab(hotkeys_tab.get(), tr("Hotkeys")); - ui->tabWidget->addTab(input_tab.get(), tr("Controls")); - ui->tabWidget->addTab(profile_tab.get(), tr("Profiles")); - ui->tabWidget->addTab(network_tab.get(), tr("Network")); - ui->tabWidget->addTab(system_tab.get(), tr("System")); - 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); - - input_tab->Initialize(input_subsystem); - - general_tab->SetResetCallback([&] { this->close(); }); - - SetConfiguration(); - PopulateSelectionList(); - - connect(ui->tabWidget, &QTabWidget::currentChanged, this, [this](int index) { - if (index != -1) { - debug_tab_tab->SetCurrentIndex(0); - } - }); - connect(ui_tab.get(), &ConfigureUi::LanguageChanged, this, &ConfigureDialog::OnLanguageChanged); - connect(ui->selectorList, &QListWidget::itemSelectionChanged, this, - &ConfigureDialog::UpdateVisibleTabs); - - if (system.IsPoweredOn()) { - QPushButton* apply_button = ui->buttonBox->addButton(QDialogButtonBox::Apply); - connect(apply_button, &QAbstractButton::clicked, this, - &ConfigureDialog::HandleApplyButtonClicked); - } - - adjustSize(); - ui->selectorList->setCurrentRow(0); - - // Selects the leftmost button on the bottom bar (Cancel as of writing) - ui->buttonBox->setFocus(); -} - -ConfigureDialog::~ConfigureDialog() = default; - -void ConfigureDialog::SetConfiguration() {} - -void ConfigureDialog::ApplyConfiguration() { - general_tab->ApplyConfiguration(); - ui_tab->ApplyConfiguration(); - system_tab->ApplyConfiguration(); - profile_tab->ApplyConfiguration(); - filesystem_tab->ApplyConfiguration(); - input_tab->ApplyConfiguration(); - hotkeys_tab->ApplyConfiguration(registry); - cpu_tab->ApplyConfiguration(); - graphics_tab->ApplyConfiguration(); - graphics_advanced_tab->ApplyConfiguration(); - audio_tab->ApplyConfiguration(); - debug_tab_tab->ApplyConfiguration(); - web_tab->ApplyConfiguration(); - network_tab->ApplyConfiguration(); - applets_tab->ApplyConfiguration(); - system.ApplySettings(); - Settings::LogSettings(); -} - -void ConfigureDialog::changeEvent(QEvent* event) { - if (event->type() == QEvent::LanguageChange) { - RetranslateUI(); - } - - QDialog::changeEvent(event); -} - -void ConfigureDialog::RetranslateUI() { - const int old_row = ui->selectorList->currentRow(); - const int old_index = ui->tabWidget->currentIndex(); - - ui->retranslateUi(this); - - PopulateSelectionList(); - ui->selectorList->setCurrentRow(old_row); - - UpdateVisibleTabs(); - ui->tabWidget->setCurrentIndex(old_index); -} - -void ConfigureDialog::HandleApplyButtonClicked() { - UISettings::values.configuration_applied = true; - ApplyConfiguration(); -} - -Q_DECLARE_METATYPE(QList<QWidget*>); - -void ConfigureDialog::PopulateSelectionList() { - const std::array<std::pair<QString, QList<QWidget*>>, 6> items{ - {{tr("General"), - {general_tab.get(), hotkeys_tab.get(), ui_tab.get(), web_tab.get(), debug_tab_tab.get()}}, - {tr("System"), - {system_tab.get(), profile_tab.get(), network_tab.get(), filesystem_tab.get(), - applets_tab.get()}}, - {tr("CPU"), {cpu_tab.get()}}, - {tr("Graphics"), {graphics_tab.get(), graphics_advanced_tab.get()}}, - {tr("Audio"), {audio_tab.get()}}, - {tr("Controls"), input_tab->GetSubTabs()}}, - }; - - [[maybe_unused]] const QSignalBlocker blocker(ui->selectorList); - - ui->selectorList->clear(); - for (const auto& entry : items) { - auto* const item = new QListWidgetItem(entry.first); - item->setData(Qt::UserRole, QVariant::fromValue(entry.second)); - - ui->selectorList->addItem(item); - } -} - -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(); - SetConfiguration(); -} - -void ConfigureDialog::UpdateVisibleTabs() { - const auto items = ui->selectorList->selectedItems(); - if (items.isEmpty()) { - return; - } - - [[maybe_unused]] const QSignalBlocker blocker(ui->tabWidget); - - ui->tabWidget->clear(); - - const auto tabs = qvariant_cast<QList<QWidget*>>(items[0]->data(Qt::UserRole)); - - for (auto* const tab : tabs) { - LOG_DEBUG(Frontend, "{}", tab->accessibleName().toStdString()); - ui->tabWidget->addTab(tab, tab->accessibleName()); - } -} diff --git a/src/yuzu/configuration/configure_dialog.h b/src/yuzu/configuration/configure_dialog.h deleted file mode 100644 index d0a24a07b..000000000 --- a/src/yuzu/configuration/configure_dialog.h +++ /dev/null @@ -1,94 +0,0 @@ -// SPDX-FileCopyrightText: 2016 Citra Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include <memory> -#include <vector> -#include <QDialog> -#include "configuration/shared_widget.h" -#include "yuzu/configuration/configuration_shared.h" -#include "yuzu/configuration/shared_translation.h" -#include "yuzu/vk_device_info.h" - -namespace Core { -class System; -} - -class ConfigureApplets; -class ConfigureAudio; -class ConfigureCpu; -class ConfigureDebugTab; -class ConfigureFilesystem; -class ConfigureGeneral; -class ConfigureGraphics; -class ConfigureGraphicsAdvanced; -class ConfigureHotkeys; -class ConfigureInput; -class ConfigureProfileManager; -class ConfigureSystem; -class ConfigureNetwork; -class ConfigureUi; -class ConfigureWeb; - -class HotkeyRegistry; - -namespace InputCommon { -class InputSubsystem; -} - -namespace Ui { -class ConfigureDialog; -} - -class ConfigureDialog : public QDialog { - Q_OBJECT - -public: - explicit ConfigureDialog(QWidget* parent, HotkeyRegistry& registry_, - InputCommon::InputSubsystem* input_subsystem, - std::vector<VkDeviceInfo::Record>& vk_device_records, - Core::System& system_, bool enable_web_config = true); - ~ConfigureDialog() override; - - void ApplyConfiguration(); - -private slots: - void OnLanguageChanged(const QString& locale); - -signals: - void LanguageChanged(const QString& locale); - -private: - void changeEvent(QEvent* event) override; - void RetranslateUI(); - - void HandleApplyButtonClicked(); - - void SetConfiguration(); - void UpdateVisibleTabs(); - void PopulateSelectionList(); - - std::unique_ptr<Ui::ConfigureDialog> ui; - HotkeyRegistry& registry; - - Core::System& system; - std::unique_ptr<ConfigurationShared::Builder> builder; - std::vector<ConfigurationShared::Tab*> tab_group; - - std::unique_ptr<ConfigureApplets> applets_tab; - std::unique_ptr<ConfigureAudio> audio_tab; - std::unique_ptr<ConfigureCpu> cpu_tab; - std::unique_ptr<ConfigureDebugTab> debug_tab_tab; - std::unique_ptr<ConfigureFilesystem> filesystem_tab; - std::unique_ptr<ConfigureGeneral> general_tab; - std::unique_ptr<ConfigureGraphicsAdvanced> graphics_advanced_tab; - std::unique_ptr<ConfigureUi> ui_tab; - std::unique_ptr<ConfigureGraphics> graphics_tab; - std::unique_ptr<ConfigureHotkeys> hotkeys_tab; - std::unique_ptr<ConfigureInput> input_tab; - std::unique_ptr<ConfigureNetwork> network_tab; - std::unique_ptr<ConfigureProfileManager> profile_tab; - std::unique_ptr<ConfigureSystem> system_tab; - std::unique_ptr<ConfigureWeb> web_tab; -}; diff --git a/src/yuzu/configuration/configure_filesystem.cpp b/src/yuzu/configuration/configure_filesystem.cpp deleted file mode 100644 index ad1951754..000000000 --- a/src/yuzu/configuration/configure_filesystem.cpp +++ /dev/null @@ -1,155 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include <QFileDialog> -#include <QMessageBox> -#include "common/fs/fs.h" -#include "common/fs/path_util.h" -#include "common/settings.h" -#include "ui_configure_filesystem.h" -#include "yuzu/configuration/configure_filesystem.h" -#include "yuzu/uisettings.h" - -ConfigureFilesystem::ConfigureFilesystem(QWidget* parent) - : QWidget(parent), ui(std::make_unique<Ui::ConfigureFilesystem>()) { - ui->setupUi(this); - SetConfiguration(); - - connect(ui->nand_directory_button, &QToolButton::pressed, this, - [this] { SetDirectory(DirectoryTarget::NAND, ui->nand_directory_edit); }); - connect(ui->sdmc_directory_button, &QToolButton::pressed, this, - [this] { SetDirectory(DirectoryTarget::SD, ui->sdmc_directory_edit); }); - connect(ui->gamecard_path_button, &QToolButton::pressed, this, - [this] { SetDirectory(DirectoryTarget::Gamecard, ui->gamecard_path_edit); }); - connect(ui->dump_path_button, &QToolButton::pressed, this, - [this] { SetDirectory(DirectoryTarget::Dump, ui->dump_path_edit); }); - connect(ui->load_path_button, &QToolButton::pressed, this, - [this] { SetDirectory(DirectoryTarget::Load, ui->load_path_edit); }); - - connect(ui->reset_game_list_cache, &QPushButton::pressed, this, - &ConfigureFilesystem::ResetMetadata); - - connect(ui->gamecard_inserted, &QCheckBox::stateChanged, this, - &ConfigureFilesystem::UpdateEnabledControls); - connect(ui->gamecard_current_game, &QCheckBox::stateChanged, this, - &ConfigureFilesystem::UpdateEnabledControls); -} - -ConfigureFilesystem::~ConfigureFilesystem() = default; - -void ConfigureFilesystem::changeEvent(QEvent* event) { - if (event->type() == QEvent::LanguageChange) { - RetranslateUI(); - } - - QWidget::changeEvent(event); -} - -void ConfigureFilesystem::SetConfiguration() { - ui->nand_directory_edit->setText( - QString::fromStdString(Common::FS::GetYuzuPathString(Common::FS::YuzuPath::NANDDir))); - ui->sdmc_directory_edit->setText( - QString::fromStdString(Common::FS::GetYuzuPathString(Common::FS::YuzuPath::SDMCDir))); - ui->gamecard_path_edit->setText( - QString::fromStdString(Settings::values.gamecard_path.GetValue())); - ui->dump_path_edit->setText( - QString::fromStdString(Common::FS::GetYuzuPathString(Common::FS::YuzuPath::DumpDir))); - ui->load_path_edit->setText( - QString::fromStdString(Common::FS::GetYuzuPathString(Common::FS::YuzuPath::LoadDir))); - - ui->gamecard_inserted->setChecked(Settings::values.gamecard_inserted.GetValue()); - ui->gamecard_current_game->setChecked(Settings::values.gamecard_current_game.GetValue()); - ui->dump_exefs->setChecked(Settings::values.dump_exefs.GetValue()); - ui->dump_nso->setChecked(Settings::values.dump_nso.GetValue()); - - ui->cache_game_list->setChecked(UISettings::values.cache_game_list.GetValue()); - - UpdateEnabledControls(); -} - -void ConfigureFilesystem::ApplyConfiguration() { - Common::FS::SetYuzuPath(Common::FS::YuzuPath::NANDDir, - ui->nand_directory_edit->text().toStdString()); - Common::FS::SetYuzuPath(Common::FS::YuzuPath::SDMCDir, - ui->sdmc_directory_edit->text().toStdString()); - Common::FS::SetYuzuPath(Common::FS::YuzuPath::DumpDir, - ui->dump_path_edit->text().toStdString()); - Common::FS::SetYuzuPath(Common::FS::YuzuPath::LoadDir, - ui->load_path_edit->text().toStdString()); - - Settings::values.gamecard_inserted = ui->gamecard_inserted->isChecked(); - Settings::values.gamecard_current_game = ui->gamecard_current_game->isChecked(); - Settings::values.dump_exefs = ui->dump_exefs->isChecked(); - Settings::values.dump_nso = ui->dump_nso->isChecked(); - - UISettings::values.cache_game_list = ui->cache_game_list->isChecked(); -} - -void ConfigureFilesystem::SetDirectory(DirectoryTarget target, QLineEdit* edit) { - QString caption; - - switch (target) { - case DirectoryTarget::NAND: - caption = tr("Select Emulated NAND Directory..."); - break; - case DirectoryTarget::SD: - caption = tr("Select Emulated SD Directory..."); - break; - case DirectoryTarget::Gamecard: - caption = tr("Select Gamecard Path..."); - break; - case DirectoryTarget::Dump: - caption = tr("Select Dump Directory..."); - break; - case DirectoryTarget::Load: - caption = tr("Select Mod Load Directory..."); - break; - } - - QString str; - if (target == DirectoryTarget::Gamecard) { - str = QFileDialog::getOpenFileName(this, caption, QFileInfo(edit->text()).dir().path(), - QStringLiteral("NX Gamecard;*.xci")); - } else { - str = QFileDialog::getExistingDirectory(this, caption, edit->text()); - } - - if (str.isNull() || str.isEmpty()) { - return; - } - - if (str.back() != QChar::fromLatin1('/')) { - str.append(QChar::fromLatin1('/')); - } - - edit->setText(str); -} - -void ConfigureFilesystem::ResetMetadata() { - if (!Common::FS::Exists(Common::FS::GetYuzuPath(Common::FS::YuzuPath::CacheDir) / - "game_list/")) { - QMessageBox::information(this, tr("Reset Metadata Cache"), - tr("The metadata cache is already empty.")); - } else if (Common::FS::RemoveDirRecursively( - Common::FS::GetYuzuPath(Common::FS::YuzuPath::CacheDir) / "game_list")) { - QMessageBox::information(this, tr("Reset Metadata Cache"), - tr("The operation completed successfully.")); - UISettings::values.is_game_list_reload_pending.exchange(true); - } else { - QMessageBox::warning( - this, tr("Reset Metadata Cache"), - tr("The metadata cache couldn't be deleted. It might be in use or non-existent.")); - } -} - -void ConfigureFilesystem::UpdateEnabledControls() { - ui->gamecard_current_game->setEnabled(ui->gamecard_inserted->isChecked()); - ui->gamecard_path_edit->setEnabled(ui->gamecard_inserted->isChecked() && - !ui->gamecard_current_game->isChecked()); - ui->gamecard_path_button->setEnabled(ui->gamecard_inserted->isChecked() && - !ui->gamecard_current_game->isChecked()); -} - -void ConfigureFilesystem::RetranslateUI() { - ui->retranslateUi(this); -} diff --git a/src/yuzu/configuration/configure_filesystem.h b/src/yuzu/configuration/configure_filesystem.h deleted file mode 100644 index 31d2f1d56..000000000 --- a/src/yuzu/configuration/configure_filesystem.h +++ /dev/null @@ -1,43 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include <memory> -#include <QWidget> - -class QLineEdit; - -namespace Ui { -class ConfigureFilesystem; -} - -class ConfigureFilesystem : public QWidget { - Q_OBJECT - -public: - explicit ConfigureFilesystem(QWidget* parent = nullptr); - ~ConfigureFilesystem() override; - - void ApplyConfiguration(); - -private: - void changeEvent(QEvent* event) override; - - void RetranslateUI(); - void SetConfiguration(); - - enum class DirectoryTarget { - NAND, - SD, - Gamecard, - Dump, - Load, - }; - - void SetDirectory(DirectoryTarget target, QLineEdit* edit); - void ResetMetadata(); - void UpdateEnabledControls(); - - std::unique_ptr<Ui::ConfigureFilesystem> ui; -}; diff --git a/src/yuzu/configuration/configure_filesystem.ui b/src/yuzu/configuration/configure_filesystem.ui deleted file mode 100644 index 2f6030b5c..000000000 --- a/src/yuzu/configuration/configure_filesystem.ui +++ /dev/null @@ -1,244 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>ConfigureFilesystem</class> - <widget class="QWidget" name="ConfigureFilesystem"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>453</width> - <height>561</height> - </rect> - </property> - <property name="windowTitle"> - <string>Form</string> - </property> - <property name="accessibleName"> - <string>Filesystem</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <layout class="QVBoxLayout" name="verticalLayout_3"> - <item> - <widget class="QGroupBox" name="groupBox"> - <property name="title"> - <string>Storage Directories</string> - </property> - <layout class="QGridLayout" name="gridLayout"> - <item row="0" column="0"> - <widget class="QLabel" name="label"> - <property name="text"> - <string>NAND</string> - </property> - </widget> - </item> - <item row="0" column="3"> - <widget class="QToolButton" name="nand_directory_button"> - <property name="text"> - <string>...</string> - </property> - </widget> - </item> - <item row="0" column="2"> - <widget class="QLineEdit" name="nand_directory_edit"/> - </item> - <item row="1" column="2"> - <widget class="QLineEdit" name="sdmc_directory_edit"/> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="label_2"> - <property name="text"> - <string>SD Card</string> - </property> - </widget> - </item> - <item row="1" column="3"> - <widget class="QToolButton" name="sdmc_directory_button"> - <property name="text"> - <string>...</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <spacer name="horizontalSpacer"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeType"> - <enum>QSizePolicy::Maximum</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>60</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QGroupBox" name="groupBox_2"> - <property name="title"> - <string>Gamecard</string> - </property> - <layout class="QGridLayout" name="gridLayout_2"> - <item row="2" column="1"> - <widget class="QLabel" name="label_3"> - <property name="text"> - <string>Path</string> - </property> - </widget> - </item> - <item row="2" column="2"> - <widget class="QLineEdit" name="gamecard_path_edit"/> - </item> - <item row="0" column="1"> - <widget class="QCheckBox" name="gamecard_inserted"> - <property name="text"> - <string>Inserted</string> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QCheckBox" name="gamecard_current_game"> - <property name="text"> - <string>Current Game</string> - </property> - </widget> - </item> - <item row="2" column="3"> - <widget class="QToolButton" name="gamecard_path_button"> - <property name="text"> - <string>...</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QGroupBox" name="groupBox_4"> - <property name="title"> - <string>Patch Manager</string> - </property> - <layout class="QGridLayout" name="gridLayout_4"> - <item row="1" column="2"> - <widget class="QLineEdit" name="load_path_edit"/> - </item> - <item row="0" column="2"> - <widget class="QLineEdit" name="dump_path_edit"/> - </item> - <item row="0" column="3"> - <widget class="QToolButton" name="dump_path_button"> - <property name="text"> - <string>...</string> - </property> - </widget> - </item> - <item row="1" column="3"> - <widget class="QToolButton" name="load_path_button"> - <property name="text"> - <string>...</string> - </property> - </widget> - </item> - <item row="2" column="0" colspan="4"> - <layout class="QHBoxLayout" name="horizontalLayout"> - <item> - <widget class="QCheckBox" name="dump_nso"> - <property name="text"> - <string>Dump Decompressed NSOs</string> - </property> - </widget> - </item> - <item> - <widget class="QCheckBox" name="dump_exefs"> - <property name="text"> - <string>Dump ExeFS</string> - </property> - </widget> - </item> - </layout> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="label_9"> - <property name="text"> - <string>Mod Load Root</string> - </property> - </widget> - </item> - <item row="0" column="0"> - <widget class="QLabel" name="label_8"> - <property name="text"> - <string>Dump Root</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <spacer name="horizontalSpacer_2"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeType"> - <enum>QSizePolicy::Fixed</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="groupBox_5"> - <property name="title"> - <string>Caching</string> - </property> - <layout class="QGridLayout" name="gridLayout_5"> - <item row="0" column="0" colspan="2"> - <layout class="QHBoxLayout" name="horizontalLayout_2"> - <item> - <widget class="QCheckBox" name="cache_game_list"> - <property name="text"> - <string>Cache Game List Metadata</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="reset_game_list_cache"> - <property name="text"> - <string>Reset Metadata Cache</string> - </property> - </widget> - </item> - </layout> - </item> - </layout> - </widget> - </item> - </layout> - </item> - <item> - <spacer name="verticalSpacer"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>40</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - <resources/> - <connections/> -</ui> diff --git a/src/yuzu/configuration/configure_general.cpp b/src/yuzu/configuration/configure_general.cpp deleted file mode 100644 index 701b895e7..000000000 --- a/src/yuzu/configuration/configure_general.cpp +++ /dev/null @@ -1,128 +0,0 @@ -// SPDX-FileCopyrightText: 2016 Citra Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include <functional> -#include <utility> -#include <vector> -#include <QMessageBox> -#include "common/settings.h" -#include "core/core.h" -#include "ui_configure_general.h" -#include "yuzu/configuration/configuration_shared.h" -#include "yuzu/configuration/configure_general.h" -#include "yuzu/configuration/shared_widget.h" -#include "yuzu/uisettings.h" - -ConfigureGeneral::ConfigureGeneral(const Core::System& system_, - std::shared_ptr<std::vector<ConfigurationShared::Tab*>> group_, - const ConfigurationShared::Builder& builder, QWidget* parent) - : Tab(group_, parent), ui{std::make_unique<Ui::ConfigureGeneral>()}, system{system_} { - ui->setupUi(this); - - Setup(builder); - - SetConfiguration(); - - connect(ui->button_reset_defaults, &QPushButton::clicked, this, - &ConfigureGeneral::ResetDefaults); - - if (!Settings::IsConfiguringGlobal()) { - ui->button_reset_defaults->setVisible(false); - } -} - -ConfigureGeneral::~ConfigureGeneral() = default; - -void ConfigureGeneral::SetConfiguration() {} - -void ConfigureGeneral::Setup(const ConfigurationShared::Builder& builder) { - QLayout& general_layout = *ui->general_widget->layout(); - QLayout& linux_layout = *ui->linux_widget->layout(); - - std::map<u32, QWidget*> general_hold{}; - std::map<u32, QWidget*> linux_hold{}; - - std::vector<Settings::BasicSetting*> settings; - - auto push = [&settings](auto& list) { - for (auto setting : list) { - settings.push_back(setting); - } - }; - - push(UISettings::values.linkage.by_category[Settings::Category::UiGeneral]); - push(Settings::values.linkage.by_category[Settings::Category::Linux]); - - // Only show Linux group on Unix -#ifndef __unix__ - ui->LinuxGroupBox->setVisible(false); -#endif - - for (const auto setting : settings) { - auto* widget = builder.BuildWidget(setting, apply_funcs); - - if (widget == nullptr) { - continue; - } - if (!widget->Valid()) { - widget->deleteLater(); - continue; - } - - switch (setting->GetCategory()) { - case Settings::Category::UiGeneral: - general_hold.emplace(setting->Id(), widget); - break; - case Settings::Category::Linux: - linux_hold.emplace(setting->Id(), widget); - break; - default: - widget->deleteLater(); - } - } - - for (const auto& [id, widget] : general_hold) { - general_layout.addWidget(widget); - } - for (const auto& [id, widget] : linux_hold) { - linux_layout.addWidget(widget); - } -} - -// Called to set the callback when resetting settings to defaults -void ConfigureGeneral::SetResetCallback(std::function<void()> callback) { - reset_callback = std::move(callback); -} - -void ConfigureGeneral::ResetDefaults() { - QMessageBox::StandardButton answer = QMessageBox::question( - this, tr("yuzu"), - tr("This reset all settings and remove all per-game configurations. This will not delete " - "game directories, profiles, or input profiles. Proceed?"), - QMessageBox::Yes | QMessageBox::No, QMessageBox::No); - if (answer == QMessageBox::No) { - return; - } - UISettings::values.reset_to_defaults = true; - UISettings::values.is_game_list_reload_pending.exchange(true); - reset_callback(); -} - -void ConfigureGeneral::ApplyConfiguration() { - bool powered_on = system.IsPoweredOn(); - for (const auto& func : apply_funcs) { - func(powered_on); - } -} - -void ConfigureGeneral::changeEvent(QEvent* event) { - if (event->type() == QEvent::LanguageChange) { - RetranslateUI(); - } - - QWidget::changeEvent(event); -} - -void ConfigureGeneral::RetranslateUI() { - ui->retranslateUi(this); -} diff --git a/src/yuzu/configuration/configure_general.h b/src/yuzu/configuration/configure_general.h deleted file mode 100644 index ada6526a6..000000000 --- a/src/yuzu/configuration/configure_general.h +++ /dev/null @@ -1,55 +0,0 @@ -// SPDX-FileCopyrightText: 2016 Citra Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include <functional> -#include <memory> -#include <vector> -#include <QWidget> -#include "yuzu/configuration/configuration_shared.h" - -namespace Core { -class System; -} - -class ConfigureDialog; -class HotkeyRegistry; - -namespace Ui { -class ConfigureGeneral; -} - -namespace ConfigurationShared { -class Builder; -} - -class ConfigureGeneral : public ConfigurationShared::Tab { - Q_OBJECT - -public: - explicit ConfigureGeneral(const Core::System& system_, - std::shared_ptr<std::vector<ConfigurationShared::Tab*>> group, - const ConfigurationShared::Builder& builder, - QWidget* parent = nullptr); - ~ConfigureGeneral() override; - - void SetResetCallback(std::function<void()> callback); - void ResetDefaults(); - void ApplyConfiguration() override; - void SetConfiguration() override; - -private: - void Setup(const ConfigurationShared::Builder& builder); - - void changeEvent(QEvent* event) override; - void RetranslateUI(); - - std::function<void()> reset_callback; - - std::unique_ptr<Ui::ConfigureGeneral> ui; - - std::vector<std::function<void(bool)>> apply_funcs{}; - - const Core::System& system; -}; diff --git a/src/yuzu/configuration/configure_general.ui b/src/yuzu/configuration/configure_general.ui deleted file mode 100644 index ef20891a3..000000000 --- a/src/yuzu/configuration/configure_general.ui +++ /dev/null @@ -1,134 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>ConfigureGeneral</class> - <widget class="QWidget" name="ConfigureGeneral"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>744</width> - <height>568</height> - </rect> - </property> - <property name="windowTitle"> - <string>Form</string> - </property> - <property name="accessibleName"> - <string>General</string> - </property> - <layout class="QHBoxLayout" name="HorizontalLayout"> - <item> - <layout class="QVBoxLayout" name="VerticalLayout"> - <item> - <widget class="QGroupBox" name="GeneralGroupBox"> - <property name="title"> - <string>General</string> - </property> - <layout class="QHBoxLayout" name="GeneralHorizontalLayout"> - <item> - <widget class="QWidget" name="general_widget" native="true"> - <layout class="QVBoxLayout" name="GeneralVerticalLayout"> - <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> - </layout> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QGroupBox" name="LinuxGroupBox"> - <property name="title"> - <string>Linux</string> - </property> - <layout class="QVBoxLayout" name="LinuxVerticalLayout_1"> - <item> - <widget class="QWidget" name="linux_widget" native="true"> - <layout class="QVBoxLayout" name="LinuxVerticalLayout_2"> - <property name="leftMargin"> - <number>0</number> - </property> - <property name="topMargin"> - <number>0</number> - </property> - <property name="rightMargin"> - <number>0</number> - </property> - <property name="bottomMargin"> - <number>0</number> - </property> - </layout> - </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="layout_reset"> - <property name="spacing"> - <number>6</number> - </property> - <property name="leftMargin"> - <number>5</number> - </property> - <property name="topMargin"> - <number>5</number> - </property> - <property name="rightMargin"> - <number>5</number> - </property> - <property name="bottomMargin"> - <number>5</number> - </property> - <item> - <widget class="QPushButton" name="button_reset_defaults"> - <property name="text"> - <string>Reset All Settings</string> - </property> - </widget> - </item> - <item> - <spacer name="spacer_reset"> - <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> - </layout> - </item> - </layout> - </widget> - <resources/> - <connections/> -</ui> diff --git a/src/yuzu/configuration/configure_graphics.cpp b/src/yuzu/configuration/configure_graphics.cpp deleted file mode 100644 index 54c931e56..000000000 --- a/src/yuzu/configuration/configure_graphics.cpp +++ /dev/null @@ -1,552 +0,0 @@ -// SPDX-FileCopyrightText: 2016 Citra Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include <algorithm> -#include <functional> -#include <iosfwd> -#include <iterator> -#include <string> -#include <tuple> -#include <typeinfo> -#include <utility> -#include <vector> -#include <QBoxLayout> -#include <QCheckBox> -#include <QColorDialog> -#include <QComboBox> -#include <QIcon> -#include <QLabel> -#include <QLineEdit> -#include <QPixmap> -#include <QPushButton> -#include <QSlider> -#include <QStringLiteral> -#include <QtCore/qobjectdefs.h> -#include <qabstractbutton.h> -#include <qboxlayout.h> -#include <qcombobox.h> -#include <qcoreevent.h> -#include <qglobal.h> -#include <qgridlayout.h> -#include <vulkan/vulkan_core.h> - -#include "common/common_types.h" -#include "common/dynamic_library.h" -#include "common/logging/log.h" -#include "common/settings.h" -#include "common/settings_enums.h" -#include "core/core.h" -#include "ui_configure_graphics.h" -#include "yuzu/configuration/configuration_shared.h" -#include "yuzu/configuration/configure_graphics.h" -#include "yuzu/configuration/shared_widget.h" -#include "yuzu/qt_common.h" -#include "yuzu/uisettings.h" -#include "yuzu/vk_device_info.h" - -static const std::vector<VkPresentModeKHR> default_present_modes{VK_PRESENT_MODE_IMMEDIATE_KHR, - VK_PRESENT_MODE_FIFO_KHR}; - -// Converts a setting to a present mode (or vice versa) -static constexpr VkPresentModeKHR VSyncSettingToMode(Settings::VSyncMode mode) { - switch (mode) { - case Settings::VSyncMode::Immediate: - return VK_PRESENT_MODE_IMMEDIATE_KHR; - case Settings::VSyncMode::Mailbox: - return VK_PRESENT_MODE_MAILBOX_KHR; - case Settings::VSyncMode::Fifo: - return VK_PRESENT_MODE_FIFO_KHR; - case Settings::VSyncMode::FifoRelaxed: - return VK_PRESENT_MODE_FIFO_RELAXED_KHR; - default: - return VK_PRESENT_MODE_FIFO_KHR; - } -} - -static constexpr Settings::VSyncMode PresentModeToSetting(VkPresentModeKHR mode) { - switch (mode) { - case VK_PRESENT_MODE_IMMEDIATE_KHR: - return Settings::VSyncMode::Immediate; - case VK_PRESENT_MODE_MAILBOX_KHR: - return Settings::VSyncMode::Mailbox; - case VK_PRESENT_MODE_FIFO_KHR: - return Settings::VSyncMode::Fifo; - case VK_PRESENT_MODE_FIFO_RELAXED_KHR: - return Settings::VSyncMode::FifoRelaxed; - default: - return Settings::VSyncMode::Fifo; - } -} - -ConfigureGraphics::ConfigureGraphics( - const Core::System& system_, std::vector<VkDeviceInfo::Record>& records_, - const std::function<void()>& expose_compute_option_, - const std::function<void(Settings::AspectRatio, Settings::ResolutionSetup)>& - update_aspect_ratio_, - std::shared_ptr<std::vector<ConfigurationShared::Tab*>> group_, - const ConfigurationShared::Builder& builder, QWidget* parent) - : ConfigurationShared::Tab(group_, parent), ui{std::make_unique<Ui::ConfigureGraphics>()}, - records{records_}, expose_compute_option{expose_compute_option_}, - update_aspect_ratio{update_aspect_ratio_}, system{system_}, - combobox_translations{builder.ComboboxTranslations()}, - shader_mapping{ - combobox_translations.at(Settings::EnumMetadata<Settings::ShaderBackend>::Index())} { - vulkan_device = Settings::values.vulkan_device.GetValue(); - RetrieveVulkanDevices(); - - ui->setupUi(this); - - Setup(builder); - - for (const auto& device : vulkan_devices) { - vulkan_device_combobox->addItem(device); - } - - UpdateBackgroundColorButton(QColor::fromRgb(Settings::values.bg_red.GetValue(), - Settings::values.bg_green.GetValue(), - Settings::values.bg_blue.GetValue())); - UpdateAPILayout(); - PopulateVSyncModeSelection(false); //< must happen after UpdateAPILayout - - // VSync setting needs to be determined after populating the VSync combobox - const auto vsync_mode_setting = Settings::values.vsync_mode.GetValue(); - const auto vsync_mode = VSyncSettingToMode(vsync_mode_setting); - int index{}; - for (const auto mode : vsync_mode_combobox_enum_map) { - if (mode == vsync_mode) { - break; - } - index++; - } - if (static_cast<unsigned long>(index) < vsync_mode_combobox_enum_map.size()) { - vsync_mode_combobox->setCurrentIndex(index); - } - - connect(api_combobox, qOverload<int>(&QComboBox::activated), this, [this] { - UpdateAPILayout(); - PopulateVSyncModeSelection(false); - }); - connect(vulkan_device_combobox, qOverload<int>(&QComboBox::activated), this, - [this](int device) { - UpdateDeviceSelection(device); - PopulateVSyncModeSelection(false); - }); - connect(shader_backend_combobox, qOverload<int>(&QComboBox::activated), this, - [this](int backend) { UpdateShaderBackendSelection(backend); }); - - connect(ui->bg_button, &QPushButton::clicked, this, [this] { - const QColor new_bg_color = QColorDialog::getColor(bg_color); - if (!new_bg_color.isValid()) { - return; - } - UpdateBackgroundColorButton(new_bg_color); - }); - - const auto& update_screenshot_info = [this, &builder]() { - const auto& combobox_enumerations = builder.ComboboxTranslations().at( - Settings::EnumMetadata<Settings::AspectRatio>::Index()); - const auto ratio_index = aspect_ratio_combobox->currentIndex(); - const auto ratio = - static_cast<Settings::AspectRatio>(combobox_enumerations[ratio_index].first); - - const auto& combobox_enumerations_resolution = builder.ComboboxTranslations().at( - Settings::EnumMetadata<Settings::ResolutionSetup>::Index()); - const auto res_index = resolution_combobox->currentIndex(); - const auto setup = static_cast<Settings::ResolutionSetup>( - combobox_enumerations_resolution[res_index].first); - - update_aspect_ratio(ratio, setup); - }; - - connect(aspect_ratio_combobox, QOverload<int>::of(&QComboBox::currentIndexChanged), - update_screenshot_info); - connect(resolution_combobox, QOverload<int>::of(&QComboBox::currentIndexChanged), - update_screenshot_info); - - api_combobox->setEnabled(!UISettings::values.has_broken_vulkan && api_combobox->isEnabled()); - ui->api_widget->setEnabled( - (!UISettings::values.has_broken_vulkan || Settings::IsConfiguringGlobal()) && - ui->api_widget->isEnabled()); - - if (Settings::IsConfiguringGlobal()) { - ui->bg_widget->setEnabled(Settings::values.bg_red.UsingGlobal()); - } -} - -void ConfigureGraphics::PopulateVSyncModeSelection(bool use_setting) { - const Settings::RendererBackend backend{GetCurrentGraphicsBackend()}; - if (backend == Settings::RendererBackend::Null) { - vsync_mode_combobox->setEnabled(false); - return; - } - vsync_mode_combobox->setEnabled(true); - - const int current_index = //< current selected vsync mode from combobox - vsync_mode_combobox->currentIndex(); - const auto current_mode = //< current selected vsync mode as a VkPresentModeKHR - current_index == -1 || use_setting - ? VSyncSettingToMode(Settings::values.vsync_mode.GetValue()) - : vsync_mode_combobox_enum_map[current_index]; - int index{}; - const int device{vulkan_device_combobox->currentIndex()}; //< current selected Vulkan device - - const auto& present_modes = //< relevant vector of present modes for the selected device or API - backend == Settings::RendererBackend::Vulkan && device > -1 ? device_present_modes[device] - : default_present_modes; - - vsync_mode_combobox->clear(); - vsync_mode_combobox_enum_map.clear(); - vsync_mode_combobox_enum_map.reserve(present_modes.size()); - for (const auto present_mode : present_modes) { - const auto mode_name = TranslateVSyncMode(present_mode, backend); - if (mode_name.isEmpty()) { - continue; - } - - vsync_mode_combobox->insertItem(index, mode_name); - vsync_mode_combobox_enum_map.push_back(present_mode); - if (present_mode == current_mode) { - vsync_mode_combobox->setCurrentIndex(index); - } - index++; - } - - if (!Settings::IsConfiguringGlobal()) { - vsync_restore_global_button->setVisible(!Settings::values.vsync_mode.UsingGlobal()); - - const Settings::VSyncMode global_vsync_mode = Settings::values.vsync_mode.GetValue(true); - vsync_restore_global_button->setEnabled( - (backend == Settings::RendererBackend::OpenGL && - (global_vsync_mode == Settings::VSyncMode::Immediate || - global_vsync_mode == Settings::VSyncMode::Fifo)) || - backend == Settings::RendererBackend::Vulkan); - } -} - -void ConfigureGraphics::UpdateVsyncSetting() const { - const Settings::RendererBackend backend{GetCurrentGraphicsBackend()}; - if (backend == Settings::RendererBackend::Null) { - return; - } - - const auto mode = vsync_mode_combobox_enum_map[vsync_mode_combobox->currentIndex()]; - const auto vsync_mode = PresentModeToSetting(mode); - Settings::values.vsync_mode.SetValue(vsync_mode); -} - -void ConfigureGraphics::UpdateDeviceSelection(int device) { - if (device == -1) { - return; - } - if (GetCurrentGraphicsBackend() == Settings::RendererBackend::Vulkan) { - vulkan_device = device; - } -} - -void ConfigureGraphics::UpdateShaderBackendSelection(int backend) { - if (backend == -1) { - return; - } - if (GetCurrentGraphicsBackend() == Settings::RendererBackend::OpenGL) { - shader_backend = static_cast<Settings::ShaderBackend>(backend); - } -} - -ConfigureGraphics::~ConfigureGraphics() = default; - -void ConfigureGraphics::SetConfiguration() {} - -void ConfigureGraphics::Setup(const ConfigurationShared::Builder& builder) { - QLayout* api_layout = ui->api_widget->layout(); - QWidget* api_grid_widget = new QWidget(this); - QVBoxLayout* api_grid_layout = new QVBoxLayout(api_grid_widget); - api_grid_layout->setContentsMargins(0, 0, 0, 0); - api_layout->addWidget(api_grid_widget); - - QLayout& graphics_layout = *ui->graphics_widget->layout(); - - std::map<u32, QWidget*> hold_graphics; - std::vector<QWidget*> hold_api; - - for (const auto setting : Settings::values.linkage.by_category[Settings::Category::Renderer]) { - ConfigurationShared::Widget* widget = [&]() { - if (setting->Id() == Settings::values.fsr_sharpening_slider.Id()) { - // FSR needs a reversed slider and a 0.5 multiplier - return builder.BuildWidget( - setting, apply_funcs, ConfigurationShared::RequestType::ReverseSlider, true, - 0.5f, nullptr, tr("%", "FSR sharpening percentage (e.g. 50%)")); - } else { - return builder.BuildWidget(setting, apply_funcs); - } - }(); - - if (widget == nullptr) { - continue; - } - if (!widget->Valid()) { - widget->deleteLater(); - continue; - } - - if (setting->Id() == Settings::values.renderer_backend.Id()) { - // Add the renderer combobox now so it's at the top - api_grid_layout->addWidget(widget); - api_combobox = widget->combobox; - api_restore_global_button = widget->restore_button; - - if (!Settings::IsConfiguringGlobal()) { - QObject::connect(api_restore_global_button, &QAbstractButton::clicked, - [this](bool) { UpdateAPILayout(); }); - - // Detach API's restore button and place it where we want - // Lets us put it on the side, and it will automatically scale if there's a - // second combobox (shader_backend, vulkan_device) - widget->layout()->removeWidget(api_restore_global_button); - api_layout->addWidget(api_restore_global_button); - } - } else if (setting->Id() == Settings::values.vulkan_device.Id()) { - // Keep track of vulkan_device's combobox so we can populate it - hold_api.push_back(widget); - vulkan_device_combobox = widget->combobox; - vulkan_device_widget = widget; - } else if (setting->Id() == Settings::values.shader_backend.Id()) { - // Keep track of shader_backend's combobox so we can populate it - hold_api.push_back(widget); - shader_backend_combobox = widget->combobox; - shader_backend_widget = widget; - } else if (setting->Id() == Settings::values.vsync_mode.Id()) { - // Keep track of vsync_mode's combobox so we can populate it - vsync_mode_combobox = widget->combobox; - - // Since vsync is populated at runtime, we have to manually set up the button for - // restoring the global setting. - if (!Settings::IsConfiguringGlobal()) { - QPushButton* restore_button = - ConfigurationShared::Widget::CreateRestoreGlobalButton( - Settings::values.vsync_mode.UsingGlobal(), widget); - restore_button->setEnabled(true); - widget->layout()->addWidget(restore_button); - - QObject::connect(restore_button, &QAbstractButton::clicked, - [restore_button, this](bool) { - Settings::values.vsync_mode.SetGlobal(true); - PopulateVSyncModeSelection(true); - - restore_button->setVisible(false); - }); - - std::function<void()> set_non_global = [restore_button, this]() { - Settings::values.vsync_mode.SetGlobal(false); - UpdateVsyncSetting(); - restore_button->setVisible(true); - }; - QObject::connect(widget->combobox, QOverload<int>::of(&QComboBox::activated), - [set_non_global]() { set_non_global(); }); - vsync_restore_global_button = restore_button; - } - hold_graphics.emplace(setting->Id(), widget); - } else if (setting->Id() == Settings::values.aspect_ratio.Id()) { - // Keep track of the aspect ratio combobox to update other UI tabs that need it - aspect_ratio_combobox = widget->combobox; - hold_graphics.emplace(setting->Id(), widget); - } else if (setting->Id() == Settings::values.resolution_setup.Id()) { - // Keep track of the resolution combobox to update other UI tabs that need it - resolution_combobox = widget->combobox; - hold_graphics.emplace(setting->Id(), widget); - } else { - hold_graphics.emplace(setting->Id(), widget); - } - } - - for (const auto& [id, widget] : hold_graphics) { - graphics_layout.addWidget(widget); - } - - for (auto widget : hold_api) { - api_grid_layout->addWidget(widget); - } - - // Background color is too specific to build into the new system, so we manage it here - // (3 settings, all collected into a single widget with a QColor to manage on top) - if (Settings::IsConfiguringGlobal()) { - apply_funcs.push_back([this](bool powered_on) { - Settings::values.bg_red.SetValue(static_cast<u8>(bg_color.red())); - Settings::values.bg_green.SetValue(static_cast<u8>(bg_color.green())); - Settings::values.bg_blue.SetValue(static_cast<u8>(bg_color.blue())); - }); - } else { - QPushButton* bg_restore_button = ConfigurationShared::Widget::CreateRestoreGlobalButton( - Settings::values.bg_red.UsingGlobal(), ui->bg_widget); - ui->bg_widget->layout()->addWidget(bg_restore_button); - - QObject::connect(bg_restore_button, &QAbstractButton::clicked, - [bg_restore_button, this](bool) { - const int r = Settings::values.bg_red.GetValue(true); - const int g = Settings::values.bg_green.GetValue(true); - const int b = Settings::values.bg_blue.GetValue(true); - UpdateBackgroundColorButton(QColor::fromRgb(r, g, b)); - - bg_restore_button->setVisible(false); - bg_restore_button->setEnabled(false); - }); - - QObject::connect(ui->bg_button, &QAbstractButton::clicked, [bg_restore_button](bool) { - bg_restore_button->setVisible(true); - bg_restore_button->setEnabled(true); - }); - - apply_funcs.push_back([bg_restore_button, this](bool powered_on) { - const bool using_global = !bg_restore_button->isEnabled(); - Settings::values.bg_red.SetGlobal(using_global); - Settings::values.bg_green.SetGlobal(using_global); - Settings::values.bg_blue.SetGlobal(using_global); - if (!using_global) { - Settings::values.bg_red.SetValue(static_cast<u8>(bg_color.red())); - Settings::values.bg_green.SetValue(static_cast<u8>(bg_color.green())); - Settings::values.bg_blue.SetValue(static_cast<u8>(bg_color.blue())); - } - }); - } -} - -const QString ConfigureGraphics::TranslateVSyncMode(VkPresentModeKHR mode, - Settings::RendererBackend backend) const { - switch (mode) { - case VK_PRESENT_MODE_IMMEDIATE_KHR: - return backend == Settings::RendererBackend::OpenGL - ? tr("Off") - : QStringLiteral("Immediate (%1)").arg(tr("VSync Off")); - case VK_PRESENT_MODE_MAILBOX_KHR: - return QStringLiteral("Mailbox (%1)").arg(tr("Recommended")); - case VK_PRESENT_MODE_FIFO_KHR: - return backend == Settings::RendererBackend::OpenGL - ? tr("On") - : QStringLiteral("FIFO (%1)").arg(tr("VSync On")); - case VK_PRESENT_MODE_FIFO_RELAXED_KHR: - return QStringLiteral("FIFO Relaxed"); - default: - return {}; - break; - } -} - -int ConfigureGraphics::FindIndex(u32 enumeration, int value) const { - for (u32 i = 0; i < combobox_translations.at(enumeration).size(); i++) { - if (combobox_translations.at(enumeration)[i].first == static_cast<u32>(value)) { - return i; - } - } - return -1; -} - -void ConfigureGraphics::ApplyConfiguration() { - const bool powered_on = system.IsPoweredOn(); - for (const auto& func : apply_funcs) { - func(powered_on); - } - - UpdateVsyncSetting(); - - Settings::values.vulkan_device.SetGlobal(true); - Settings::values.shader_backend.SetGlobal(true); - if (Settings::IsConfiguringGlobal() || - (!Settings::IsConfiguringGlobal() && api_restore_global_button->isEnabled())) { - auto backend = static_cast<Settings::RendererBackend>( - combobox_translations - .at(Settings::EnumMetadata< - Settings::RendererBackend>::Index())[api_combobox->currentIndex()] - .first); - switch (backend) { - case Settings::RendererBackend::OpenGL: - Settings::values.shader_backend.SetGlobal(Settings::IsConfiguringGlobal()); - Settings::values.shader_backend.SetValue(static_cast<Settings::ShaderBackend>( - shader_mapping[shader_backend_combobox->currentIndex()].first)); - break; - case Settings::RendererBackend::Vulkan: - Settings::values.vulkan_device.SetGlobal(Settings::IsConfiguringGlobal()); - Settings::values.vulkan_device.SetValue(vulkan_device_combobox->currentIndex()); - break; - case Settings::RendererBackend::Null: - break; - } - } -} - -void ConfigureGraphics::changeEvent(QEvent* event) { - if (event->type() == QEvent::LanguageChange) { - RetranslateUI(); - } - - QWidget::changeEvent(event); -} - -void ConfigureGraphics::RetranslateUI() { - ui->retranslateUi(this); -} - -void ConfigureGraphics::UpdateBackgroundColorButton(QColor color) { - bg_color = color; - - QPixmap pixmap(ui->bg_button->size()); - pixmap.fill(bg_color); - - const QIcon color_icon(pixmap); - ui->bg_button->setIcon(color_icon); -} - -void ConfigureGraphics::UpdateAPILayout() { - bool runtime_lock = !system.IsPoweredOn(); - bool need_global = !(Settings::IsConfiguringGlobal() || api_restore_global_button->isEnabled()); - vulkan_device = Settings::values.vulkan_device.GetValue(need_global); - shader_backend = Settings::values.shader_backend.GetValue(need_global); - vulkan_device_widget->setEnabled(!need_global && runtime_lock); - shader_backend_widget->setEnabled(!need_global && runtime_lock); - - const auto current_backend = GetCurrentGraphicsBackend(); - const bool is_opengl = current_backend == Settings::RendererBackend::OpenGL; - const bool is_vulkan = current_backend == Settings::RendererBackend::Vulkan; - - vulkan_device_widget->setVisible(is_vulkan); - shader_backend_widget->setVisible(is_opengl); - - if (is_opengl) { - shader_backend_combobox->setCurrentIndex( - FindIndex(Settings::EnumMetadata<Settings::ShaderBackend>::Index(), - static_cast<int>(shader_backend))); - } else if (is_vulkan && static_cast<int>(vulkan_device) < vulkan_device_combobox->count()) { - vulkan_device_combobox->setCurrentIndex(vulkan_device); - } -} - -void ConfigureGraphics::RetrieveVulkanDevices() { - vulkan_devices.clear(); - vulkan_devices.reserve(records.size()); - device_present_modes.clear(); - device_present_modes.reserve(records.size()); - for (const auto& record : records) { - vulkan_devices.push_back(QString::fromStdString(record.name)); - device_present_modes.push_back(record.vsync_support); - - if (record.has_broken_compute) { - expose_compute_option(); - } - } -} - -Settings::RendererBackend ConfigureGraphics::GetCurrentGraphicsBackend() const { - const auto selected_backend = [&]() { - if (!Settings::IsConfiguringGlobal() && !api_restore_global_button->isEnabled()) { - return Settings::values.renderer_backend.GetValue(true); - } - return static_cast<Settings::RendererBackend>( - combobox_translations.at(Settings::EnumMetadata<Settings::RendererBackend>::Index()) - .at(api_combobox->currentIndex()) - .first); - }(); - - if (selected_backend == Settings::RendererBackend::Vulkan && - UISettings::values.has_broken_vulkan) { - return Settings::RendererBackend::OpenGL; - } - return selected_backend; -} diff --git a/src/yuzu/configuration/configure_graphics.h b/src/yuzu/configuration/configure_graphics.h deleted file mode 100644 index b92b4496b..000000000 --- a/src/yuzu/configuration/configure_graphics.h +++ /dev/null @@ -1,116 +0,0 @@ -// SPDX-FileCopyrightText: 2016 Citra Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include <functional> -#include <memory> -#include <type_traits> -#include <typeindex> -#include <vector> -#include <QColor> -#include <QString> -#include <QWidget> -#include <qobjectdefs.h> -#include <vulkan/vulkan_core.h> -#include "common/common_types.h" -#include "common/settings_enums.h" -#include "configuration/shared_translation.h" -#include "vk_device_info.h" -#include "yuzu/configuration/configuration_shared.h" - -class QPushButton; -class QEvent; -class QObject; -class QComboBox; - -namespace Settings { -enum class NvdecEmulation : u32; -enum class RendererBackend : u32; -enum class ShaderBackend : u32; -} // namespace Settings - -namespace Core { -class System; -} - -namespace Ui { -class ConfigureGraphics; -} - -namespace ConfigurationShared { -class Builder; -} - -class ConfigureGraphics : public ConfigurationShared::Tab { - Q_OBJECT - -public: - explicit ConfigureGraphics( - const Core::System& system_, std::vector<VkDeviceInfo::Record>& records, - const std::function<void()>& expose_compute_option, - const std::function<void(Settings::AspectRatio, Settings::ResolutionSetup)>& - update_aspect_ratio, - std::shared_ptr<std::vector<ConfigurationShared::Tab*>> group, - const ConfigurationShared::Builder& builder, QWidget* parent = nullptr); - ~ConfigureGraphics() override; - - void ApplyConfiguration() override; - void SetConfiguration() override; - -private: - void changeEvent(QEvent* event) override; - void RetranslateUI(); - - void Setup(const ConfigurationShared::Builder& builder); - - void PopulateVSyncModeSelection(bool use_setting); - void UpdateVsyncSetting() const; - void UpdateBackgroundColorButton(QColor color); - void UpdateAPILayout(); - void UpdateDeviceSelection(int device); - void UpdateShaderBackendSelection(int backend); - - void RetrieveVulkanDevices(); - - /* Turns a Vulkan present mode into a textual string for a UI - * (and eventually for a human to read) */ - const QString TranslateVSyncMode(VkPresentModeKHR mode, - Settings::RendererBackend backend) const; - - Settings::RendererBackend GetCurrentGraphicsBackend() const; - - int FindIndex(u32 enumeration, int value) const; - - std::unique_ptr<Ui::ConfigureGraphics> ui; - QColor bg_color; - - std::vector<std::function<void(bool)>> apply_funcs{}; - - std::vector<VkDeviceInfo::Record>& records; - std::vector<QString> vulkan_devices; - std::vector<std::vector<VkPresentModeKHR>> device_present_modes; - std::vector<VkPresentModeKHR> - vsync_mode_combobox_enum_map{}; //< Keeps track of which present mode corresponds to which - // selection in the combobox - u32 vulkan_device{}; - Settings::ShaderBackend shader_backend{}; - const std::function<void()>& expose_compute_option; - const std::function<void(Settings::AspectRatio, Settings::ResolutionSetup)> update_aspect_ratio; - - const Core::System& system; - const ConfigurationShared::ComboboxTranslationMap& combobox_translations; - const std::vector<std::pair<u32, QString>>& shader_mapping; - - QPushButton* api_restore_global_button; - QComboBox* vulkan_device_combobox; - QComboBox* api_combobox; - QComboBox* shader_backend_combobox; - QComboBox* vsync_mode_combobox; - QPushButton* vsync_restore_global_button; - QWidget* vulkan_device_widget; - QWidget* api_widget; - QWidget* shader_backend_widget; - QComboBox* aspect_ratio_combobox; - QComboBox* resolution_combobox; -}; diff --git a/src/yuzu/configuration/configure_graphics.ui b/src/yuzu/configuration/configure_graphics.ui deleted file mode 100644 index d09415d70..000000000 --- a/src/yuzu/configuration/configure_graphics.ui +++ /dev/null @@ -1,151 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>ConfigureGraphics</class> - <widget class="QWidget" name="ConfigureGraphics"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>541</width> - <height>759</height> - </rect> - </property> - <property name="windowTitle"> - <string>Form</string> - </property> - <property name="accessibleName"> - <string>Graphics</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout_1"> - <item> - <layout class="QVBoxLayout" name="verticalLayout_2"> - <item> - <widget class="QGroupBox" name="groupBox_2"> - <property name="title"> - <string>API Settings</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout_3"> - <item> - <widget class="QWidget" name="api_widget" native="true"> - <layout class="QHBoxLayout" name="horizontalLayout"> - <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> - </layout> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QGroupBox" name="groupBox"> - <property name="maximumSize"> - <size> - <width>16777215</width> - <height>16777215</height> - </size> - </property> - <property name="title"> - <string>Graphics Settings</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout_4"> - <item> - <widget class="QWidget" name="graphics_widget" native="true"> - <layout class="QVBoxLayout" name="verticalLayout"> - <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> - </layout> - </widget> - </item> - <item> - <widget class="QWidget" name="bg_widget" native="true"> - <layout class="QHBoxLayout" name="bg_layout"> - <property name="leftMargin"> - <number>0</number> - </property> - <property name="topMargin"> - <number>0</number> - </property> - <property name="rightMargin"> - <number>0</number> - </property> - <property name="bottomMargin"> - <number>0</number> - </property> - <item> - <widget class="QLabel" name="label"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string>Background Color:</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="bg_button"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="maximumSize"> - <size> - <width>40</width> - <height>16777215</height> - </size> - </property> - <property name="text"> - <string/> - </property> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </item> - <item> - <spacer name="verticalSpacer"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>40</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - <resources/> - <connections/> -</ui> diff --git a/src/yuzu/configuration/configure_graphics_advanced.cpp b/src/yuzu/configuration/configure_graphics_advanced.cpp deleted file mode 100644 index 4db18673d..000000000 --- a/src/yuzu/configuration/configure_graphics_advanced.cpp +++ /dev/null @@ -1,82 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include <vector> -#include <QLabel> -#include <qnamespace.h> -#include "common/settings.h" -#include "core/core.h" -#include "ui_configure_graphics_advanced.h" -#include "yuzu/configuration/configuration_shared.h" -#include "yuzu/configuration/configure_graphics_advanced.h" -#include "yuzu/configuration/shared_translation.h" -#include "yuzu/configuration/shared_widget.h" - -ConfigureGraphicsAdvanced::ConfigureGraphicsAdvanced( - const Core::System& system_, std::shared_ptr<std::vector<ConfigurationShared::Tab*>> group_, - const ConfigurationShared::Builder& builder, QWidget* parent) - : Tab(group_, parent), ui{std::make_unique<Ui::ConfigureGraphicsAdvanced>()}, system{system_} { - - ui->setupUi(this); - - Setup(builder); - - SetConfiguration(); - - checkbox_enable_compute_pipelines->setVisible(false); -} - -ConfigureGraphicsAdvanced::~ConfigureGraphicsAdvanced() = default; - -void ConfigureGraphicsAdvanced::SetConfiguration() {} - -void ConfigureGraphicsAdvanced::Setup(const ConfigurationShared::Builder& builder) { - auto& layout = *ui->populate_target->layout(); - std::map<u32, QWidget*> hold{}; // A map will sort the data for us - - for (auto setting : - Settings::values.linkage.by_category[Settings::Category::RendererAdvanced]) { - ConfigurationShared::Widget* widget = builder.BuildWidget(setting, apply_funcs); - - if (widget == nullptr) { - continue; - } - if (!widget->Valid()) { - widget->deleteLater(); - continue; - } - - hold.emplace(setting->Id(), widget); - - // Keep track of enable_compute_pipelines so we can display it when needed - if (setting->Id() == Settings::values.enable_compute_pipelines.Id()) { - checkbox_enable_compute_pipelines = widget; - } - } - for (const auto& [id, widget] : hold) { - layout.addWidget(widget); - } -} - -void ConfigureGraphicsAdvanced::ApplyConfiguration() { - const bool is_powered_on = system.IsPoweredOn(); - for (const auto& func : apply_funcs) { - func(is_powered_on); - } -} - -void ConfigureGraphicsAdvanced::changeEvent(QEvent* event) { - if (event->type() == QEvent::LanguageChange) { - RetranslateUI(); - } - - QWidget::changeEvent(event); -} - -void ConfigureGraphicsAdvanced::RetranslateUI() { - ui->retranslateUi(this); -} - -void ConfigureGraphicsAdvanced::ExposeComputeOption() { - checkbox_enable_compute_pipelines->setVisible(true); -} diff --git a/src/yuzu/configuration/configure_graphics_advanced.h b/src/yuzu/configuration/configure_graphics_advanced.h deleted file mode 100644 index 82431987e..000000000 --- a/src/yuzu/configuration/configure_graphics_advanced.h +++ /dev/null @@ -1,49 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include <memory> -#include <vector> -#include <QWidget> -#include "yuzu/configuration/configuration_shared.h" - -namespace Core { -class System; -} - -namespace Ui { -class ConfigureGraphicsAdvanced; -} - -namespace ConfigurationShared { -class Builder; -} - -class ConfigureGraphicsAdvanced : public ConfigurationShared::Tab { - Q_OBJECT - -public: - explicit ConfigureGraphicsAdvanced( - const Core::System& system_, std::shared_ptr<std::vector<ConfigurationShared::Tab*>> group, - const ConfigurationShared::Builder& builder, QWidget* parent = nullptr); - ~ConfigureGraphicsAdvanced() override; - - void ApplyConfiguration() override; - void SetConfiguration() override; - - void ExposeComputeOption(); - -private: - void Setup(const ConfigurationShared::Builder& builder); - void changeEvent(QEvent* event) override; - void RetranslateUI(); - - std::unique_ptr<Ui::ConfigureGraphicsAdvanced> ui; - - const Core::System& system; - - std::vector<std::function<void(bool)>> apply_funcs; - - QWidget* checkbox_enable_compute_pipelines{}; -}; diff --git a/src/yuzu/configuration/configure_graphics_advanced.ui b/src/yuzu/configuration/configure_graphics_advanced.ui deleted file mode 100644 index 37a854ca3..000000000 --- a/src/yuzu/configuration/configure_graphics_advanced.ui +++ /dev/null @@ -1,68 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>ConfigureGraphicsAdvanced</class> - <widget class="QWidget" name="ConfigureGraphicsAdvanced"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>404</width> - <height>376</height> - </rect> - </property> - <property name="windowTitle"> - <string>Form</string> - </property> - <property name="accessibleName"> - <string>Advanced</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout_1"> - <item> - <layout class="QVBoxLayout" name="verticalLayout_2"> - <item> - <widget class="QGroupBox" name="groupBox_1"> - <property name="title"> - <string>Advanced Graphics Settings</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout_3"> - <item> - <widget class="QWidget" name="populate_target" native="true"> - <layout class="QVBoxLayout" name="verticalLayout"> - <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> - </layout> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </item> - <item> - <spacer name="verticalSpacer"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>40</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - <resources/> - <connections/> -</ui> diff --git a/src/yuzu/configuration/configure_hotkeys.cpp b/src/yuzu/configuration/configure_hotkeys.cpp deleted file mode 100644 index 3f68de12d..000000000 --- a/src/yuzu/configuration/configure_hotkeys.cpp +++ /dev/null @@ -1,423 +0,0 @@ -// SPDX-FileCopyrightText: 2017 Citra Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include <QMenu> -#include <QMessageBox> -#include <QStandardItemModel> -#include <QTimer> - -#include "hid_core/frontend/emulated_controller.h" -#include "hid_core/hid_core.h" - -#include "frontend_common/config.h" -#include "ui_configure_hotkeys.h" -#include "yuzu/configuration/configure_hotkeys.h" -#include "yuzu/hotkeys.h" -#include "yuzu/uisettings.h" -#include "yuzu/util/sequence_dialog/sequence_dialog.h" - -constexpr int name_column = 0; -constexpr int hotkey_column = 1; -constexpr int controller_column = 2; - -ConfigureHotkeys::ConfigureHotkeys(Core::HID::HIDCore& hid_core, QWidget* parent) - : QWidget(parent), ui(std::make_unique<Ui::ConfigureHotkeys>()), - timeout_timer(std::make_unique<QTimer>()), poll_timer(std::make_unique<QTimer>()) { - ui->setupUi(this); - setFocusPolicy(Qt::ClickFocus); - - model = new QStandardItemModel(this); - model->setColumnCount(3); - - connect(ui->hotkey_list, &QTreeView::doubleClicked, this, &ConfigureHotkeys::Configure); - connect(ui->hotkey_list, &QTreeView::customContextMenuRequested, this, - &ConfigureHotkeys::PopupContextMenu); - ui->hotkey_list->setContextMenuPolicy(Qt::CustomContextMenu); - ui->hotkey_list->setModel(model); - - 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); - connect(ui->button_clear_all, &QPushButton::clicked, this, &ConfigureHotkeys::ClearAll); - - controller = hid_core.GetEmulatedController(Core::HID::NpadIdType::Player1); - - connect(timeout_timer.get(), &QTimer::timeout, [this] { - const bool is_button_pressed = pressed_buttons != Core::HID::NpadButton::None || - pressed_home_button || pressed_capture_button; - SetPollingResult(!is_button_pressed); - }); - - connect(poll_timer.get(), &QTimer::timeout, [this] { - pressed_buttons |= controller->GetNpadButtons().raw; - pressed_home_button |= this->controller->GetHomeButtons().home != 0; - pressed_capture_button |= this->controller->GetCaptureButtons().capture != 0; - if (pressed_buttons != Core::HID::NpadButton::None || pressed_home_button || - pressed_capture_button) { - const QString button_name = - GetButtonCombinationName(pressed_buttons, pressed_home_button, - pressed_capture_button) + - QStringLiteral("..."); - model->setData(button_model_index, button_name); - } - }); - RetranslateUI(); -} - -ConfigureHotkeys::~ConfigureHotkeys() = default; - -void ConfigureHotkeys::Populate(const HotkeyRegistry& registry) { - for (const auto& group : registry.hotkey_groups) { - QString parent_item_data = QString::fromStdString(group.first); - auto* parent_item = - new QStandardItem(QCoreApplication::translate("Hotkeys", qPrintable(parent_item_data))); - parent_item->setEditable(false); - parent_item->setData(parent_item_data); - for (const auto& hotkey : group.second) { - QString hotkey_action_data = QString::fromStdString(hotkey.first); - auto* action = new QStandardItem( - QCoreApplication::translate("Hotkeys", qPrintable(hotkey_action_data))); - auto* keyseq = - new QStandardItem(hotkey.second.keyseq.toString(QKeySequence::NativeText)); - auto* controller_keyseq = - new QStandardItem(QString::fromStdString(hotkey.second.controller_keyseq)); - action->setEditable(false); - action->setData(hotkey_action_data); - keyseq->setEditable(false); - controller_keyseq->setEditable(false); - parent_item->appendRow({action, keyseq, controller_keyseq}); - } - model->appendRow(parent_item); - } - - ui->hotkey_list->expandAll(); - ui->hotkey_list->resizeColumnToContents(hotkey_column); - ui->hotkey_list->resizeColumnToContents(controller_column); -} - -void ConfigureHotkeys::changeEvent(QEvent* event) { - if (event->type() == QEvent::LanguageChange) { - RetranslateUI(); - } - - QWidget::changeEvent(event); -} - -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) { - if (!index.parent().isValid()) { - return; - } - - // Controller configuration is selected - if (index.column() == controller_column) { - ConfigureController(index); - return; - } - - // Swap to the hotkey column - index = index.sibling(index.row(), hotkey_column); - - const auto previous_key = model->data(index); - - SequenceDialog hotkey_dialog{this}; - - const int return_code = hotkey_dialog.exec(); - const auto key_sequence = hotkey_dialog.GetSequence(); - if (return_code == QDialog::Rejected || key_sequence.isEmpty()) { - return; - } - const auto [key_sequence_used, used_action] = IsUsedKey(key_sequence); - - if (key_sequence_used && key_sequence != QKeySequence(previous_key.toString())) { - QMessageBox::warning( - this, tr("Conflicting Key Sequence"), - tr("The entered key sequence is already assigned to: %1").arg(used_action)); - } else { - model->setData(index, key_sequence.toString(QKeySequence::NativeText)); - } -} -void ConfigureHotkeys::ConfigureController(QModelIndex index) { - if (timeout_timer->isActive()) { - return; - } - - const auto previous_key = model->data(index); - - input_setter = [this, index, previous_key](const bool cancel) { - if (cancel) { - model->setData(index, previous_key); - return; - } - - const QString button_string = - GetButtonCombinationName(pressed_buttons, pressed_home_button, pressed_capture_button); - - const auto [key_sequence_used, used_action] = IsUsedControllerKey(button_string); - - if (key_sequence_used) { - QMessageBox::warning( - this, tr("Conflicting Key Sequence"), - tr("The entered key sequence is already assigned to: %1").arg(used_action)); - model->setData(index, previous_key); - } else { - model->setData(index, button_string); - } - }; - - button_model_index = index; - pressed_buttons = Core::HID::NpadButton::None; - pressed_home_button = false; - pressed_capture_button = false; - - model->setData(index, tr("[waiting]")); - timeout_timer->start(2500); // Cancel after 2.5 seconds - poll_timer->start(100); // Check for new inputs every 100ms - // We need to disable configuration to be able to read npad buttons - controller->DisableConfiguration(); -} - -void ConfigureHotkeys::SetPollingResult(const bool cancel) { - timeout_timer->stop(); - poll_timer->stop(); - (*input_setter)(cancel); - // Re-Enable configuration - controller->EnableConfiguration(); - - input_setter = std::nullopt; -} - -QString ConfigureHotkeys::GetButtonCombinationName(Core::HID::NpadButton button, - const bool home = false, - const bool capture = false) const { - Core::HID::NpadButtonState state{button}; - QString button_combination; - if (home) { - button_combination.append(QStringLiteral("Home+")); - } - if (capture) { - button_combination.append(QStringLiteral("Screenshot+")); - } - if (state.a) { - button_combination.append(QStringLiteral("A+")); - } - if (state.b) { - button_combination.append(QStringLiteral("B+")); - } - if (state.x) { - button_combination.append(QStringLiteral("X+")); - } - if (state.y) { - button_combination.append(QStringLiteral("Y+")); - } - if (state.l || state.right_sl || state.left_sl) { - button_combination.append(QStringLiteral("L+")); - } - if (state.r || state.right_sr || state.left_sr) { - button_combination.append(QStringLiteral("R+")); - } - if (state.zl) { - button_combination.append(QStringLiteral("ZL+")); - } - if (state.zr) { - button_combination.append(QStringLiteral("ZR+")); - } - if (state.left) { - button_combination.append(QStringLiteral("Dpad_Left+")); - } - if (state.right) { - button_combination.append(QStringLiteral("Dpad_Right+")); - } - if (state.up) { - button_combination.append(QStringLiteral("Dpad_Up+")); - } - if (state.down) { - button_combination.append(QStringLiteral("Dpad_Down+")); - } - if (state.stick_l) { - button_combination.append(QStringLiteral("Left_Stick+")); - } - if (state.stick_r) { - button_combination.append(QStringLiteral("Right_Stick+")); - } - if (state.minus) { - button_combination.append(QStringLiteral("Minus+")); - } - if (state.plus) { - button_combination.append(QStringLiteral("Plus+")); - } - if (button_combination.isEmpty()) { - return tr("Invalid"); - } else { - button_combination.chop(1); - return button_combination; - } -} - -std::pair<bool, QString> ConfigureHotkeys::IsUsedKey(QKeySequence key_sequence) const { - for (int r = 0; r < model->rowCount(); ++r) { - const QStandardItem* const parent = model->item(r, 0); - - for (int r2 = 0; r2 < parent->rowCount(); ++r2) { - const QStandardItem* const key_seq_item = parent->child(r2, hotkey_column); - const auto key_seq_str = key_seq_item->text(); - const auto key_seq = QKeySequence::fromString(key_seq_str, QKeySequence::NativeText); - - if (key_sequence == key_seq) { - return std::make_pair(true, parent->child(r2, 0)->text()); - } - } - } - - return std::make_pair(false, QString()); -} - -std::pair<bool, QString> ConfigureHotkeys::IsUsedControllerKey(const QString& key_sequence) const { - for (int r = 0; r < model->rowCount(); ++r) { - const QStandardItem* const parent = model->item(r, 0); - - for (int r2 = 0; r2 < parent->rowCount(); ++r2) { - const QStandardItem* const key_seq_item = parent->child(r2, controller_column); - const auto key_seq_str = key_seq_item->text(); - - if (key_sequence == key_seq_str) { - return std::make_pair(true, parent->child(r2, 0)->text()); - } - } - } - - return std::make_pair(false, QString()); -} - -void ConfigureHotkeys::ApplyConfiguration(HotkeyRegistry& registry) { - for (int key_id = 0; key_id < model->rowCount(); key_id++) { - const QStandardItem* parent = model->item(key_id, 0); - for (int key_column_id = 0; key_column_id < parent->rowCount(); key_column_id++) { - const QStandardItem* action = parent->child(key_column_id, name_column); - const QStandardItem* keyseq = parent->child(key_column_id, hotkey_column); - const QStandardItem* controller_keyseq = - parent->child(key_column_id, controller_column); - for (auto& [group, sub_actions] : registry.hotkey_groups) { - if (group != parent->data().toString().toStdString()) - continue; - for (auto& [action_name, hotkey] : sub_actions) { - if (action_name != action->data().toString().toStdString()) - continue; - hotkey.keyseq = QKeySequence(keyseq->text()); - hotkey.controller_keyseq = controller_keyseq->text().toStdString(); - } - } - } - } - - registry.SaveHotkeys(); -} - -void ConfigureHotkeys::RestoreDefaults() { - for (int r = 0; r < model->rowCount(); ++r) { - const QStandardItem* parent = model->item(r, 0); - const int hotkey_size = static_cast<int>(UISettings::default_hotkeys.size()); - - if (hotkey_size != parent->rowCount()) { - QMessageBox::warning(this, tr("Invalid hotkey settings"), - tr("An error occurred. Please report this issue on github.")); - return; - } - - for (int r2 = 0; r2 < parent->rowCount(); ++r2) { - model->item(r, 0) - ->child(r2, hotkey_column) - ->setText(QString::fromStdString(UISettings::default_hotkeys[r2].shortcut.keyseq)); - model->item(r, 0) - ->child(r2, controller_column) - ->setText(QString::fromStdString( - UISettings::default_hotkeys[r2].shortcut.controller_keyseq)); - } - } -} - -void ConfigureHotkeys::ClearAll() { - for (int r = 0; r < model->rowCount(); ++r) { - const QStandardItem* parent = model->item(r, 0); - - for (int r2 = 0; r2 < parent->rowCount(); ++r2) { - model->item(r, 0)->child(r2, hotkey_column)->setText(QString{}); - model->item(r, 0)->child(r2, controller_column)->setText(QString{}); - } - } -} - -void ConfigureHotkeys::PopupContextMenu(const QPoint& menu_location) { - QModelIndex index = ui->hotkey_list->indexAt(menu_location); - if (!index.parent().isValid()) { - return; - } - - // Swap to the hotkey column if the controller hotkey column is not selected - if (index.column() != controller_column) { - index = index.sibling(index.row(), hotkey_column); - } - - QMenu context_menu; - - QAction* restore_default = context_menu.addAction(tr("Restore Default")); - QAction* clear = context_menu.addAction(tr("Clear")); - - connect(restore_default, &QAction::triggered, [this, index] { - if (index.column() == controller_column) { - RestoreControllerHotkey(index); - return; - } - RestoreHotkey(index); - }); - connect(clear, &QAction::triggered, [this, index] { model->setData(index, QString{}); }); - - context_menu.exec(ui->hotkey_list->viewport()->mapToGlobal(menu_location)); -} - -void ConfigureHotkeys::RestoreControllerHotkey(QModelIndex index) { - const QString& default_key_sequence = - QString::fromStdString(UISettings::default_hotkeys[index.row()].shortcut.controller_keyseq); - const auto [key_sequence_used, used_action] = IsUsedControllerKey(default_key_sequence); - - if (key_sequence_used && default_key_sequence != model->data(index).toString()) { - QMessageBox::warning( - this, tr("Conflicting Button Sequence"), - tr("The default button sequence is already assigned to: %1").arg(used_action)); - } else { - model->setData(index, default_key_sequence); - } -} - -void ConfigureHotkeys::RestoreHotkey(QModelIndex index) { - const QKeySequence& default_key_sequence = QKeySequence::fromString( - QString::fromStdString(UISettings::default_hotkeys[index.row()].shortcut.keyseq), - QKeySequence::NativeText); - const auto [key_sequence_used, used_action] = IsUsedKey(default_key_sequence); - - if (key_sequence_used && default_key_sequence != QKeySequence(model->data(index).toString())) { - QMessageBox::warning( - this, tr("Conflicting Key Sequence"), - tr("The default key sequence is already assigned to: %1").arg(used_action)); - } else { - model->setData(index, default_key_sequence.toString(QKeySequence::NativeText)); - } -} diff --git a/src/yuzu/configuration/configure_hotkeys.h b/src/yuzu/configuration/configure_hotkeys.h deleted file mode 100644 index 20ea3b515..000000000 --- a/src/yuzu/configuration/configure_hotkeys.h +++ /dev/null @@ -1,74 +0,0 @@ -// SPDX-FileCopyrightText: 2017 Citra Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include <memory> -#include <QStandardItemModel> -#include <QWidget> - -namespace Common { -class ParamPackage; -} - -namespace Core::HID { -class HIDCore; -class EmulatedController; -enum class NpadButton : u64; -} // namespace Core::HID - -namespace Ui { -class ConfigureHotkeys; -} - -class HotkeyRegistry; -class QStandardItemModel; - -class ConfigureHotkeys : public QWidget { - Q_OBJECT - -public: - explicit ConfigureHotkeys(Core::HID::HIDCore& hid_core_, QWidget* parent = nullptr); - ~ConfigureHotkeys() override; - - void ApplyConfiguration(HotkeyRegistry& registry); - - /** - * Populates the hotkey list widget using data from the provided registry. - * Called every time the Configure dialog is opened. - * @param registry The HotkeyRegistry whose data is used to populate the list. - */ - void Populate(const HotkeyRegistry& registry); - -private: - void changeEvent(QEvent* event) override; - void RetranslateUI(); - - void Configure(QModelIndex index); - void ConfigureController(QModelIndex index); - std::pair<bool, QString> IsUsedKey(QKeySequence key_sequence) const; - std::pair<bool, QString> IsUsedControllerKey(const QString& key_sequence) const; - - void RestoreDefaults(); - void ClearAll(); - void PopupContextMenu(const QPoint& menu_location); - void RestoreControllerHotkey(QModelIndex index); - void RestoreHotkey(QModelIndex index); - - void SetPollingResult(bool cancel); - QString GetButtonCombinationName(Core::HID::NpadButton button, bool home, bool capture) const; - - std::unique_ptr<Ui::ConfigureHotkeys> ui; - - QStandardItemModel* model; - - bool pressed_home_button; - bool pressed_capture_button; - QModelIndex button_model_index; - Core::HID::NpadButton pressed_buttons; - - Core::HID::EmulatedController* controller; - std::unique_ptr<QTimer> timeout_timer; - std::unique_ptr<QTimer> poll_timer; - std::optional<std::function<void(bool)>> input_setter; -}; diff --git a/src/yuzu/configuration/configure_hotkeys.ui b/src/yuzu/configuration/configure_hotkeys.ui deleted file mode 100644 index a6902a5d8..000000000 --- a/src/yuzu/configuration/configure_hotkeys.ui +++ /dev/null @@ -1,76 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>ConfigureHotkeys</class> - <widget class="QWidget" name="ConfigureHotkeys"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>439</width> - <height>510</height> - </rect> - </property> - <property name="windowTitle"> - <string>Hotkey Settings</string> - </property> - <property name="accessibleName"> - <string>Hotkeys</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <layout class="QHBoxLayout" name="horizontalLayout"> - <item> - <widget class="QLabel" name="label_2"> - <property name="text"> - <string>Double-click on a binding to change it.</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="button_clear_all"> - <property name="text"> - <string>Clear All</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="button_restore_defaults"> - <property name="text"> - <string>Restore Defaults</string> - </property> - </widget> - </item> - </layout> - </item> - <item> - <layout class="QVBoxLayout" name="verticalLayout_2"> - <item> - <widget class="QTreeView" name="hotkey_list"> - <property name="editTriggers"> - <set>QAbstractItemView::NoEditTriggers</set> - </property> - <property name="sortingEnabled"> - <bool>false</bool> - </property> - </widget> - </item> - </layout> - </item> - </layout> - </widget> - <resources/> - <connections/> -</ui> diff --git a/src/yuzu/configuration/configure_input.cpp b/src/yuzu/configuration/configure_input.cpp deleted file mode 100644 index 28c3baf08..000000000 --- a/src/yuzu/configuration/configure_input.cpp +++ /dev/null @@ -1,309 +0,0 @@ -// SPDX-FileCopyrightText: 2016 Citra Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include <memory> -#include <thread> - -#include "common/settings.h" -#include "common/settings_enums.h" -#include "core/core.h" -#include "core/hle/service/am/am.h" -#include "core/hle/service/am/applet_manager.h" -#include "core/hle/service/sm/sm.h" -#include "hid_core/frontend/emulated_controller.h" -#include "hid_core/hid_core.h" -#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" - -namespace { -template <typename Dialog, typename... Args> -void CallConfigureDialog(ConfigureInput& parent, Args&&... args) { - Dialog dialog(&parent, std::forward<Args>(args)...); - - const auto res = dialog.exec(); - if (res == QDialog::Accepted) { - dialog.ApplyConfiguration(); - } -} -} // Anonymous namespace - -void OnDockedModeChanged(bool last_state, bool new_state, Core::System& system) { - if (last_state == new_state) { - return; - } - - if (!system.IsPoweredOn()) { - return; - } - - system.GetAppletManager().OperationModeChanged(); -} - -ConfigureInput::ConfigureInput(Core::System& system_, QWidget* parent) - : QWidget(parent), ui(std::make_unique<Ui::ConfigureInput>()), - profiles(std::make_unique<InputProfiles>()), system{system_} { - ui->setupUi(this); -} - -ConfigureInput::~ConfigureInput() = default; - -void ConfigureInput::Initialize(InputCommon::InputSubsystem* input_subsystem, - std::size_t max_players) { - const bool is_powered_on = system.IsPoweredOn(); - auto& hid_core = system.HIDCore(); - player_controllers = { - new ConfigureInputPlayer(this, 0, ui->consoleInputSettings, input_subsystem, profiles.get(), - hid_core, is_powered_on), - new ConfigureInputPlayer(this, 1, ui->consoleInputSettings, input_subsystem, profiles.get(), - hid_core, is_powered_on), - new ConfigureInputPlayer(this, 2, ui->consoleInputSettings, input_subsystem, profiles.get(), - hid_core, is_powered_on), - new ConfigureInputPlayer(this, 3, ui->consoleInputSettings, input_subsystem, profiles.get(), - hid_core, is_powered_on), - new ConfigureInputPlayer(this, 4, ui->consoleInputSettings, input_subsystem, profiles.get(), - hid_core, is_powered_on), - new ConfigureInputPlayer(this, 5, ui->consoleInputSettings, input_subsystem, profiles.get(), - hid_core, is_powered_on), - new ConfigureInputPlayer(this, 6, ui->consoleInputSettings, input_subsystem, profiles.get(), - hid_core, is_powered_on), - new ConfigureInputPlayer(this, 7, ui->consoleInputSettings, input_subsystem, profiles.get(), - hid_core, is_powered_on), - }; - - player_tabs = { - ui->tabPlayer1, ui->tabPlayer2, ui->tabPlayer3, ui->tabPlayer4, - ui->tabPlayer5, ui->tabPlayer6, ui->tabPlayer7, ui->tabPlayer8, - }; - - connected_controller_checkboxes = { - ui->checkboxPlayer1Connected, ui->checkboxPlayer2Connected, ui->checkboxPlayer3Connected, - ui->checkboxPlayer4Connected, ui->checkboxPlayer5Connected, ui->checkboxPlayer6Connected, - ui->checkboxPlayer7Connected, ui->checkboxPlayer8Connected, - }; - - std::array<QLabel*, 8> connected_controller_labels = { - ui->label, ui->label_3, ui->label_4, ui->label_5, - ui->label_6, ui->label_7, ui->label_8, ui->label_9, - }; - - for (std::size_t i = 0; i < player_tabs.size(); ++i) { - player_tabs[i]->setLayout(new QHBoxLayout(player_tabs[i])); - player_tabs[i]->layout()->addWidget(player_controllers[i]); - connect(player_controllers[i], &ConfigureInputPlayer::Connected, [this, i](bool checked) { - // Ensures that connecting a controller changes the number of players - if (connected_controller_checkboxes[i]->isChecked() != checked) { - // Ensures that the players are always connected in sequential order - PropagatePlayerNumberChanged(i, checked); - } - }); - connect(connected_controller_checkboxes[i], &QCheckBox::clicked, [this, i](bool checked) { - // Reconnect current controller if it was the last one checked - // (player number was reduced by more than one) - const bool reconnect_first = !checked && - i < connected_controller_checkboxes.size() - 1 && - connected_controller_checkboxes[i + 1]->isChecked(); - - // Ensures that the players are always connected in sequential order - PropagatePlayerNumberChanged(i, checked, reconnect_first); - }); - connect(player_controllers[i], &ConfigureInputPlayer::RefreshInputDevices, this, - &ConfigureInput::UpdateAllInputDevices); - connect(player_controllers[i], &ConfigureInputPlayer::RefreshInputProfiles, this, - &ConfigureInput::UpdateAllInputProfiles, Qt::QueuedConnection); - connect(connected_controller_checkboxes[i], &QCheckBox::stateChanged, [this, i](int state) { - // Keep activated controllers synced with the "Connected Controllers" checkboxes - player_controllers[i]->ConnectPlayer(state == Qt::Checked); - }); - - // Remove/hide all the elements that exceed max_players, if applicable. - if (i >= max_players) { - ui->tabWidget->removeTab(static_cast<int>(max_players)); - connected_controller_checkboxes[i]->hide(); - connected_controller_labels[i]->hide(); - } - } - // Only the first player can choose handheld mode so connect the signal just to player 1 - connect(player_controllers[0], &ConfigureInputPlayer::HandheldStateChanged, - [this](bool is_handheld) { UpdateDockedState(is_handheld); }); - - advanced = new ConfigureInputAdvanced(hid_core, this); - ui->tabAdvanced->setLayout(new QHBoxLayout(ui->tabAdvanced)); - ui->tabAdvanced->layout()->addWidget(advanced); - - connect(advanced, &ConfigureInputAdvanced::CallDebugControllerDialog, - [this, input_subsystem, &hid_core, is_powered_on] { - CallConfigureDialog<ConfigureDebugController>( - *this, input_subsystem, profiles.get(), hid_core, is_powered_on); - }); - connect(advanced, &ConfigureInputAdvanced::CallTouchscreenConfigDialog, - [this] { CallConfigureDialog<ConfigureTouchscreenAdvanced>(*this); }); - connect(advanced, &ConfigureInputAdvanced::CallMotionTouchConfigDialog, - [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); }); - - connect(ui->motionButton, &QPushButton::clicked, [this, input_subsystem] { - CallConfigureDialog<ConfigureMotionTouch>(*this, input_subsystem); - }); - - connect(ui->buttonClearAll, &QPushButton::clicked, [this] { ClearAll(); }); - connect(ui->buttonRestoreDefaults, &QPushButton::clicked, [this] { RestoreDefaults(); }); - - RetranslateUI(); - LoadConfiguration(); -} - -void ConfigureInput::PropagatePlayerNumberChanged(size_t player_index, bool checked, - bool reconnect_current) { - connected_controller_checkboxes[player_index]->setChecked(checked); - - if (checked) { - // Check all previous buttons when checked - if (player_index > 0) { - PropagatePlayerNumberChanged(player_index - 1, checked); - } - } else { - // Unchecked all following buttons when unchecked - if (player_index < connected_controller_checkboxes.size() - 1) { - PropagatePlayerNumberChanged(player_index + 1, checked); - } - } - - if (reconnect_current) { - connected_controller_checkboxes[player_index]->setCheckState(Qt::Checked); - } -} - -QList<QWidget*> ConfigureInput::GetSubTabs() const { - return { - ui->tabPlayer1, ui->tabPlayer2, ui->tabPlayer3, ui->tabPlayer4, ui->tabPlayer5, - ui->tabPlayer6, ui->tabPlayer7, ui->tabPlayer8, ui->tabAdvanced, - }; -} - -void ConfigureInput::ApplyConfiguration() { - const bool was_global = Settings::values.players.UsingGlobal(); - Settings::values.players.SetGlobal(true); - for (auto* controller : player_controllers) { - controller->ApplyConfiguration(); - } - - advanced->ApplyConfiguration(); - - const bool pre_docked_mode = Settings::IsDockedMode(); - const bool docked_mode_selected = ui->radioDocked->isChecked(); - Settings::values.use_docked_mode.SetValue( - docked_mode_selected ? Settings::ConsoleMode::Docked : Settings::ConsoleMode::Handheld); - OnDockedModeChanged(pre_docked_mode, docked_mode_selected, system); - - Settings::values.vibration_enabled.SetValue(ui->vibrationGroup->isChecked()); - Settings::values.motion_enabled.SetValue(ui->motionGroup->isChecked()); - Settings::values.players.SetGlobal(was_global); -} - -void ConfigureInput::changeEvent(QEvent* event) { - if (event->type() == QEvent::LanguageChange) { - RetranslateUI(); - } - - QWidget::changeEvent(event); -} - -void ConfigureInput::RetranslateUI() { - ui->retranslateUi(this); -} - -void ConfigureInput::LoadConfiguration() { - const auto* handheld = system.HIDCore().GetEmulatedController(Core::HID::NpadIdType::Handheld); - - LoadPlayerControllerIndices(); - UpdateDockedState(handheld->IsConnected()); - - ui->vibrationGroup->setChecked(Settings::values.vibration_enabled.GetValue()); - ui->motionGroup->setChecked(Settings::values.motion_enabled.GetValue()); -} - -void ConfigureInput::LoadPlayerControllerIndices() { - for (std::size_t i = 0; i < connected_controller_checkboxes.size(); ++i) { - if (i == 0) { - auto* handheld = - system.HIDCore().GetEmulatedController(Core::HID::NpadIdType::Handheld); - if (handheld->IsConnected()) { - connected_controller_checkboxes[i]->setChecked(true); - continue; - } - } - const auto* controller = system.HIDCore().GetEmulatedControllerByIndex(i); - connected_controller_checkboxes[i]->setChecked(controller->IsConnected()); - } -} - -void ConfigureInput::ClearAll() { - // We don't have a good way to know what tab is active, but we can find out by getting the - // parent of the consoleInputSettings - auto* player_tab = static_cast<ConfigureInputPlayer*>(ui->consoleInputSettings->parent()); - player_tab->ClearAll(); -} - -void ConfigureInput::RestoreDefaults() { - // We don't have a good way to know what tab is active, but we can find out by getting the - // parent of the consoleInputSettings - auto* player_tab = static_cast<ConfigureInputPlayer*>(ui->consoleInputSettings->parent()); - player_tab->RestoreDefaults(); - - ui->radioDocked->setChecked(true); - ui->radioUndocked->setChecked(false); - ui->vibrationGroup->setChecked(true); - ui->motionGroup->setChecked(true); -} - -void ConfigureInput::UpdateDockedState(bool is_handheld) { - // Disallow changing the console mode if the controller type is handheld. - ui->radioDocked->setEnabled(!is_handheld); - ui->radioUndocked->setEnabled(!is_handheld); - - ui->radioDocked->setChecked(Settings::IsDockedMode()); - ui->radioUndocked->setChecked(!Settings::IsDockedMode()); - - // Also force into undocked mode if the controller type is handheld. - if (is_handheld) { - ui->radioUndocked->setChecked(true); - } -} - -void ConfigureInput::UpdateAllInputDevices() { - for (const auto& player : player_controllers) { - player->UpdateInputDeviceCombobox(); - } -} - -void ConfigureInput::UpdateAllInputProfiles(std::size_t player_index) { - for (std::size_t i = 0; i < player_controllers.size(); ++i) { - if (i == player_index) { - continue; - } - - player_controllers[i]->UpdateInputProfiles(); - } -} diff --git a/src/yuzu/configuration/configure_input.h b/src/yuzu/configuration/configure_input.h deleted file mode 100644 index beb503dae..000000000 --- a/src/yuzu/configuration/configure_input.h +++ /dev/null @@ -1,81 +0,0 @@ -// SPDX-FileCopyrightText: 2016 Citra Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include <array> -#include <memory> - -#include <QKeyEvent> -#include <QList> -#include <QWidget> - -namespace Core { -class System; -} - -class QCheckBox; -class QString; -class QTimer; - -class ConfigureInputAdvanced; -class ConfigureInputPlayer; - -class InputProfiles; - -namespace InputCommon { -class InputSubsystem; -} - -namespace Ui { -class ConfigureInput; -} - -void OnDockedModeChanged(bool last_state, bool new_state, Core::System& system); - -class ConfigureInput : public QWidget { - Q_OBJECT - -public: - explicit ConfigureInput(Core::System& system_, QWidget* parent = nullptr); - ~ConfigureInput() override; - - /// Initializes the input dialog with the given input subsystem. - void Initialize(InputCommon::InputSubsystem* input_subsystem_, std::size_t max_players = 8); - - /// Save all button configurations to settings file. - void ApplyConfiguration(); - - QList<QWidget*> GetSubTabs() const; - -private: - void changeEvent(QEvent* event) override; - void RetranslateUI(); - void ClearAll(); - - void UpdateDockedState(bool is_handheld); - void UpdateAllInputDevices(); - void UpdateAllInputProfiles(std::size_t player_index); - // Enable preceding controllers or disable following ones - void PropagatePlayerNumberChanged(size_t player_index, bool checked, - bool reconnect_current = false); - - /// Load configuration settings. - void LoadConfiguration(); - void LoadPlayerControllerIndices(); - - /// Restore all buttons to their default values. - void RestoreDefaults(); - - std::unique_ptr<Ui::ConfigureInput> ui; - - std::unique_ptr<InputProfiles> profiles; - - std::array<ConfigureInputPlayer*, 8> player_controllers; - std::array<QWidget*, 8> player_tabs; - // Checkboxes representing the "Connected Controllers". - std::array<QCheckBox*, 8> connected_controller_checkboxes; - ConfigureInputAdvanced* advanced; - - Core::System& system; -}; diff --git a/src/yuzu/configuration/configure_input.ui b/src/yuzu/configuration/configure_input.ui deleted file mode 100644 index d51774028..000000000 --- a/src/yuzu/configuration/configure_input.ui +++ /dev/null @@ -1,548 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>ConfigureInput</class> - <widget class="QWidget" name="ConfigureInput"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>680</width> - <height>540</height> - </rect> - </property> - <property name="windowTitle"> - <string>ConfigureInput</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout_5"> - <property name="spacing"> - <number>2</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="QTabWidget" name="tabWidget"> - <property name="currentIndex"> - <number>0</number> - </property> - <widget class="QWidget" name="tabPlayer1"> - <property name="accessibleName"> - <string>Player 1</string> - </property> - <attribute name="title"> - <string>Player 1</string> - </attribute> - </widget> - <widget class="QWidget" name="tabPlayer2"> - <property name="accessibleName"> - <string>Player 2</string> - </property> - <attribute name="title"> - <string>Player 2</string> - </attribute> - </widget> - <widget class="QWidget" name="tabPlayer3"> - <property name="accessibleName"> - <string>Player 3</string> - </property> - <attribute name="title"> - <string>Player 3</string> - </attribute> - </widget> - <widget class="QWidget" name="tabPlayer4"> - <property name="accessibleName"> - <string>Player 4</string> - </property> - <attribute name="title"> - <string>Player 4</string> - </attribute> - </widget> - <widget class="QWidget" name="tabPlayer5"> - <property name="accessibleName"> - <string>Player 5</string> - </property> - <attribute name="title"> - <string>Player 5</string> - </attribute> - </widget> - <widget class="QWidget" name="tabPlayer6"> - <property name="accessibleName"> - <string>Player 6</string> - </property> - <attribute name="title"> - <string>Player 6</string> - </attribute> - </widget> - <widget class="QWidget" name="tabPlayer7"> - <property name="accessibleName"> - <string>Player 7</string> - </property> - <attribute name="title"> - <string>Player 7</string> - </attribute> - </widget> - <widget class="QWidget" name="tabPlayer8"> - <property name="accessibleName"> - <string>Player 8</string> - </property> - <attribute name="title"> - <string>Player 8</string> - </attribute> - </widget> - <widget class="QWidget" name="tabAdvanced"> - <property name="accessibleName"> - <string>Advanced</string> - </property> - <attribute name="title"> - <string>Advanced</string> - </attribute> - </widget> - </widget> - </item> - <item alignment="Qt::AlignVCenter"> - <widget class="QWidget" name="consoleInputSettings" native="true"> - <layout class="QHBoxLayout" name="buttonsBottomRightHorizontalLayout"> - <property name="spacing"> - <number>3</number> - </property> - <property name="leftMargin"> - <number>0</number> - </property> - <property name="topMargin"> - <number>3</number> - </property> - <property name="rightMargin"> - <number>0</number> - </property> - <property name="bottomMargin"> - <number>0</number> - </property> - <item alignment="Qt::AlignVCenter"> - <widget class="QGroupBox" name="handheldGroup"> - <property name="maximumSize"> - <size> - <width>16777215</width> - <height>16777215</height> - </size> - </property> - <property name="title"> - <string>Console Mode</string> - </property> - <layout class="QHBoxLayout" name="horizontalLayout"> - <property name="spacing"> - <number>6</number> - </property> - <property name="leftMargin"> - <number>8</number> - </property> - <property name="topMargin"> - <number>6</number> - </property> - <property name="rightMargin"> - <number>3</number> - </property> - <property name="bottomMargin"> - <number>6</number> - </property> - <item> - <widget class="QRadioButton" name="radioDocked"> - <property name="text"> - <string>Docked</string> - </property> - <property name="checked"> - <bool>true</bool> - </property> - </widget> - </item> - <item> - <widget class="QRadioButton" name="radioUndocked"> - <property name="text"> - <string>Handheld</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QGroupBox" name="vibrationGroup"> - <property name="title"> - <string>Vibration</string> - </property> - <property name="checkable"> - <bool>true</bool> - </property> - <layout class="QHBoxLayout" name="horizontalLayout_2"> - <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="vibrationButton"> - <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>Configure</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QGroupBox" name="motionGroup"> - <property name="title"> - <string>Motion</string> - </property> - <property name="checkable"> - <bool>true</bool> - </property> - <layout class="QHBoxLayout" name="horizontalLayout_3"> - <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="motionButton"> - <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>Configure</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item alignment="Qt::AlignVCenter"> - <widget class="QWidget" name="connectedControllers" native="true"> - <layout class="QGridLayout" name="gridLayout_2"> - <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> - <property name="spacing"> - <number>3</number> - </property> - <item row="1" column="2"> - <widget class="QCheckBox" name="checkboxPlayer2Connected"> - <property name="text"> - <string/> - </property> - </widget> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="label_2"> - <property name="text"> - <string>Controllers</string> - </property> - </widget> - </item> - <item row="1" column="4"> - <widget class="QCheckBox" name="checkboxPlayer4Connected"> - <property name="text"> - <string/> - </property> - </widget> - </item> - <item row="1" column="3"> - <widget class="QCheckBox" name="checkboxPlayer3Connected"> - <property name="text"> - <string/> - </property> - </widget> - </item> - <item row="1" column="5"> - <widget class="QCheckBox" name="checkboxPlayer5Connected"> - <property name="text"> - <string/> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QLabel" name="label"> - <property name="text"> - <string>1</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - </widget> - </item> - <item row="1" column="7"> - <widget class="QCheckBox" name="checkboxPlayer7Connected"> - <property name="text"> - <string/> - </property> - </widget> - </item> - <item row="1" column="6"> - <widget class="QCheckBox" name="checkboxPlayer6Connected"> - <property name="text"> - <string/> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QCheckBox" name="checkboxPlayer1Connected"> - <property name="layoutDirection"> - <enum>Qt::LeftToRight</enum> - </property> - <property name="checked"> - <bool>true</bool> - </property> - </widget> - </item> - <item row="1" column="8"> - <widget class="QCheckBox" name="checkboxPlayer8Connected"> - <property name="text"> - <string/> - </property> - </widget> - </item> - <item row="0" column="2"> - <widget class="QLabel" name="label_3"> - <property name="text"> - <string>2</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - </widget> - </item> - <item row="0" column="3"> - <widget class="QLabel" name="label_4"> - <property name="text"> - <string>3</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - </widget> - </item> - <item row="0" column="4"> - <widget class="QLabel" name="label_5"> - <property name="text"> - <string>4</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - </widget> - </item> - <item row="0" column="5"> - <widget class="QLabel" name="label_6"> - <property name="text"> - <string>5</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - </widget> - </item> - <item row="0" column="6"> - <widget class="QLabel" name="label_7"> - <property name="text"> - <string>6</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - </widget> - </item> - <item row="0" column="7"> - <widget class="QLabel" name="label_8"> - <property name="text"> - <string>7</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - </widget> - </item> - <item row="0" column="8"> - <widget class="QLabel" name="label_9"> - <property name="text"> - <string>8</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - </widget> - </item> - <item row="0" column="0"> - <widget class="QLabel" name="label_10"> - <property name="text"> - <string>Connected</string> - </property> - </widget> - </item> - </layout> - </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 alignment="Qt::AlignBottom"> - <widget class="QPushButton" name="buttonRestoreDefaults"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <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="sizeIncrement"> - <size> - <width>0</width> - <height>0</height> - </size> - </property> - <property name="baseSize"> - <size> - <width>0</width> - <height>0</height> - </size> - </property> - <property name="layoutDirection"> - <enum>Qt::LeftToRight</enum> - </property> - <property name="styleSheet"> - <string notr="true">min-width: 68px;</string> - </property> - <property name="text"> - <string>Defaults</string> - </property> - </widget> - </item> - <item alignment="Qt::AlignBottom"> - <widget class="QPushButton" name="buttonClearAll"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <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="sizeIncrement"> - <size> - <width>0</width> - <height>0</height> - </size> - </property> - <property name="baseSize"> - <size> - <width>0</width> - <height>0</height> - </size> - </property> - <property name="layoutDirection"> - <enum>Qt::LeftToRight</enum> - </property> - <property name="styleSheet"> - <string notr="true">min-width: 68px;</string> - </property> - <property name="text"> - <string>Clear</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - <resources/> - <connections/> -</ui> diff --git a/src/yuzu/configuration/configure_input_advanced.cpp b/src/yuzu/configuration/configure_input_advanced.cpp deleted file mode 100644 index d6c4e09ec..000000000 --- a/src/yuzu/configuration/configure_input_advanced.cpp +++ /dev/null @@ -1,204 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include <QColorDialog> -#include "common/settings.h" -#include "core/core.h" -#include "hid_core/frontend/emulated_controller.h" -#include "hid_core/hid_core.h" -#include "ui_configure_input_advanced.h" -#include "yuzu/configuration/configure_input_advanced.h" - -ConfigureInputAdvanced::ConfigureInputAdvanced(Core::HID::HIDCore& hid_core_, QWidget* parent) - : QWidget(parent), ui(std::make_unique<Ui::ConfigureInputAdvanced>()), hid_core{hid_core_} { - ui->setupUi(this); - - controllers_color_buttons = {{ - { - ui->player1_left_body_button, - ui->player1_left_buttons_button, - ui->player1_right_body_button, - ui->player1_right_buttons_button, - }, - { - ui->player2_left_body_button, - ui->player2_left_buttons_button, - ui->player2_right_body_button, - ui->player2_right_buttons_button, - }, - { - ui->player3_left_body_button, - ui->player3_left_buttons_button, - ui->player3_right_body_button, - ui->player3_right_buttons_button, - }, - { - ui->player4_left_body_button, - ui->player4_left_buttons_button, - ui->player4_right_body_button, - ui->player4_right_buttons_button, - }, - { - ui->player5_left_body_button, - ui->player5_left_buttons_button, - ui->player5_right_body_button, - ui->player5_right_buttons_button, - }, - { - ui->player6_left_body_button, - ui->player6_left_buttons_button, - ui->player6_right_body_button, - ui->player6_right_buttons_button, - }, - { - ui->player7_left_body_button, - ui->player7_left_buttons_button, - ui->player7_right_body_button, - ui->player7_right_buttons_button, - }, - { - ui->player8_left_body_button, - ui->player8_left_buttons_button, - ui->player8_right_body_button, - ui->player8_right_buttons_button, - }, - }}; - - for (std::size_t player_idx = 0; player_idx < controllers_color_buttons.size(); ++player_idx) { - auto& color_buttons = controllers_color_buttons[player_idx]; - for (std::size_t button_idx = 0; button_idx < color_buttons.size(); ++button_idx) { - connect(color_buttons[button_idx], &QPushButton::clicked, this, - [this, player_idx, button_idx] { - OnControllerButtonClick(player_idx, button_idx); - }); - } - } - - connect(ui->mouse_enabled, &QCheckBox::stateChanged, this, - &ConfigureInputAdvanced::UpdateUIEnabled); - connect(ui->debug_enabled, &QCheckBox::stateChanged, this, - &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, - [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); -#endif - - LoadConfiguration(); -} - -ConfigureInputAdvanced::~ConfigureInputAdvanced() = default; - -void ConfigureInputAdvanced::OnControllerButtonClick(std::size_t player_idx, - std::size_t button_idx) { - const QColor new_bg_color = QColorDialog::getColor(controllers_colors[player_idx][button_idx]); - if (!new_bg_color.isValid()) { - return; - } - controllers_colors[player_idx][button_idx] = new_bg_color; - controllers_color_buttons[player_idx][button_idx]->setStyleSheet( - QStringLiteral("background-color: %1; min-width: 60px;") - .arg(controllers_colors[player_idx][button_idx].name())); -} - -void ConfigureInputAdvanced::ApplyConfiguration() { - for (std::size_t player_idx = 0; player_idx < controllers_color_buttons.size(); ++player_idx) { - auto& player = Settings::values.players.GetValue()[player_idx]; - std::array<u32, 4> colors{}; - std::transform(controllers_colors[player_idx].begin(), controllers_colors[player_idx].end(), - colors.begin(), [](QColor color) { return color.rgb(); }); - - player.body_color_left = colors[0]; - player.button_color_left = colors[1]; - player.body_color_right = colors[2]; - player.button_color_right = colors[3]; - - hid_core.GetEmulatedControllerByIndex(player_idx)->ReloadColorsFromSettings(); - } - - Settings::values.debug_pad_enabled = ui->debug_enabled->isChecked(); - Settings::values.mouse_enabled = ui->mouse_enabled->isChecked(); - Settings::values.keyboard_enabled = ui->keyboard_enabled->isChecked(); - Settings::values.emulate_analog_keyboard = ui->emulate_analog_keyboard->isChecked(); - Settings::values.touchscreen.enabled = ui->touchscreen_enabled->isChecked(); - 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(); - Settings::values.enable_joycon_driver = ui->enable_joycon_driver->isChecked(); - Settings::values.enable_procon_driver = ui->enable_procon_driver->isChecked(); - Settings::values.random_amiibo_id = ui->random_amiibo_id->isChecked(); -} - -void ConfigureInputAdvanced::LoadConfiguration() { - for (std::size_t player_idx = 0; player_idx < controllers_color_buttons.size(); ++player_idx) { - auto& player = Settings::values.players.GetValue()[player_idx]; - std::array<u32, 4> colors = { - player.body_color_left, - player.button_color_left, - player.body_color_right, - player.button_color_right, - }; - - std::transform(colors.begin(), colors.end(), controllers_colors[player_idx].begin(), - [](u32 rgb) { return QColor::fromRgb(rgb); }); - - for (std::size_t button_idx = 0; button_idx < colors.size(); ++button_idx) { - controllers_color_buttons[player_idx][button_idx]->setStyleSheet( - QStringLiteral("background-color: %1; min-width: 60px;") - .arg(controllers_colors[player_idx][button_idx].name())); - } - } - - ui->debug_enabled->setChecked(Settings::values.debug_pad_enabled.GetValue()); - ui->mouse_enabled->setChecked(Settings::values.mouse_enabled.GetValue()); - ui->keyboard_enabled->setChecked(Settings::values.keyboard_enabled.GetValue()); - ui->emulate_analog_keyboard->setChecked(Settings::values.emulate_analog_keyboard.GetValue()); - ui->touchscreen_enabled->setChecked(Settings::values.touchscreen.enabled); - 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()); - ui->enable_joycon_driver->setChecked(Settings::values.enable_joycon_driver.GetValue()); - ui->enable_procon_driver->setChecked(Settings::values.enable_procon_driver.GetValue()); - ui->random_amiibo_id->setChecked(Settings::values.random_amiibo_id.GetValue()); - - UpdateUIEnabled(); -} - -void ConfigureInputAdvanced::changeEvent(QEvent* event) { - if (event->type() == QEvent::LanguageChange) { - RetranslateUI(); - } - - QWidget::changeEvent(event); -} - -void ConfigureInputAdvanced::RetranslateUI() { - ui->retranslateUi(this); -} - -void ConfigureInputAdvanced::UpdateUIEnabled() { - ui->debug_configure->setEnabled(ui->debug_enabled->isChecked()); - ui->touchscreen_advanced->setEnabled(ui->touchscreen_enabled->isChecked()); - ui->ring_controller_configure->setEnabled(ui->enable_ring_controller->isChecked()); -#if QT_VERSION > QT_VERSION_CHECK(6, 0, 0) || !defined(YUZU_USE_QT_MULTIMEDIA) - ui->enable_ir_sensor->setEnabled(false); - ui->camera_configure->setEnabled(false); -#endif -} diff --git a/src/yuzu/configuration/configure_input_advanced.h b/src/yuzu/configuration/configure_input_advanced.h deleted file mode 100644 index 41f822c4a..000000000 --- a/src/yuzu/configuration/configure_input_advanced.h +++ /dev/null @@ -1,53 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include <array> -#include <memory> -#include <QWidget> - -class QColor; -class QPushButton; - -namespace Ui { -class ConfigureInputAdvanced; -} - -namespace Core::HID { -class HIDCore; -} // namespace Core::HID - -class ConfigureInputAdvanced : public QWidget { - Q_OBJECT - -public: - explicit ConfigureInputAdvanced(Core::HID::HIDCore& hid_core_, QWidget* parent = nullptr); - ~ConfigureInputAdvanced() override; - - void ApplyConfiguration(); - -signals: - void CallDebugControllerDialog(); - void CallMouseConfigDialog(); - void CallTouchscreenConfigDialog(); - void CallMotionTouchConfigDialog(); - void CallRingControllerDialog(); - void CallCameraDialog(); - -private: - void changeEvent(QEvent* event) override; - void RetranslateUI(); - void UpdateUIEnabled(); - - void OnControllerButtonClick(std::size_t player_idx, std::size_t button_idx); - - void LoadConfiguration(); - - std::unique_ptr<Ui::ConfigureInputAdvanced> ui; - - std::array<std::array<QColor, 4>, 8> controllers_colors; - std::array<std::array<QPushButton*, 4>, 8> controllers_color_buttons; - - Core::HID::HIDCore& hid_core; -}; diff --git a/src/yuzu/configuration/configure_input_advanced.ui b/src/yuzu/configuration/configure_input_advanced.ui deleted file mode 100644 index 2994d0ab4..000000000 --- a/src/yuzu/configuration/configure_input_advanced.ui +++ /dev/null @@ -1,2821 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>ConfigureInputAdvanced</class> - <widget class="QWidget" name="ConfigureInputAdvanced"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>710</width> - <height>580</height> - </rect> - </property> - <property name="windowTitle"> - <string>Configure Input</string> - </property> - <property name="styleSheet"> - <string notr="true"/> - </property> - <layout class="QHBoxLayout" name="horizontalLayout"> - <property name="spacing"> - <number>0</number> - </property> - <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="QWidget" name="mainInputAdvanced" native="true"> - <layout class="QHBoxLayout" name="main" stretch="1,1"> - <property name="spacing"> - <number>9</number> - </property> - <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="QWidget" name="leftInputAdvanced" native="true"> - <layout class="QVBoxLayout" name="leftLayout" stretch="0"> - <property name="spacing"> - <number>3</number> - </property> - <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="QGroupBox" name="joyconColorsGroup"> - <property name="title"> - <string>Joycon Colors</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout_3" stretch="1,1"> - <property name="leftMargin"> - <number>9</number> - </property> - <property name="topMargin"> - <number>9</number> - </property> - <property name="rightMargin"> - <number>9</number> - </property> - <property name="bottomMargin"> - <number>9</number> - </property> - <item> - <widget class="QWidget" name="topLeftInputAdvanced" native="true"> - <layout class="QVBoxLayout" name="verticalLayout_4"> - <property name="spacing"> - <number>6</number> - </property> - <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="QWidget" name="player12Widget" native="true"> - <layout class="QHBoxLayout" name="horizontalLayout_4"> - <property name="leftMargin"> - <number>0</number> - </property> - <property name="topMargin"> - <number>0</number> - </property> - <property name="rightMargin"> - <number>0</number> - </property> - <property name="bottomMargin"> - <number>0</number> - </property> - <item> - <widget class="QGroupBox" name="player1Group"> - <property name="title"> - <string>Player 1</string> - </property> - <layout class="QHBoxLayout" name="horizontalLayout_2"> - <property name="spacing"> - <number>6</number> - </property> - <property name="leftMargin"> - <number>6</number> - </property> - <property name="topMargin"> - <number>0</number> - </property> - <property name="rightMargin"> - <number>6</number> - </property> - <property name="bottomMargin"> - <number>6</number> - </property> - <item> - <widget class="QWidget" name="player1LeftJoycon" native="true"> - <layout class="QVBoxLayout" name="buttonMiscButtonsLeftJoyconVerticalLayout_14"> - <property name="spacing"> - <number>0</number> - </property> - <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 alignment="Qt::AlignHCenter"> - <widget class="QGroupBox" name="player1LeftBodyGroup"> - <property name="title"> - <string>L Body</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - <layout class="QVBoxLayout" name="verticalLayout_66"> - <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="player1_left_body_button"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <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/> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item alignment="Qt::AlignHCenter"> - <widget class="QGroupBox" name="player1LeftButtonsGroup"> - <property name="title"> - <string>L Button</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - <layout class="QVBoxLayout" name="verticalLayout_67"> - <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="player1_left_buttons_button"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <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/> - </property> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QWidget" name="player1RightJoycon" native="true"> - <layout class="QVBoxLayout" name="buttonMiscButtonsRightJoyconVerticalLayout_14"> - <property name="spacing"> - <number>0</number> - </property> - <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 alignment="Qt::AlignHCenter"> - <widget class="QGroupBox" name="player1RightBodyGroup"> - <property name="title"> - <string>R Body</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - <layout class="QVBoxLayout" name="verticalLayout_64"> - <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="player1_right_body_button"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <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/> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item alignment="Qt::AlignHCenter"> - <widget class="QGroupBox" name="player1RightButtonsGroup"> - <property name="title"> - <string>R Button</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - <layout class="QVBoxLayout" name="verticalLayout_65"> - <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="player1_right_buttons_button"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <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/> - </property> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QGroupBox" name="player2Group"> - <property name="title"> - <string>Player 2</string> - </property> - <layout class="QHBoxLayout" name="horizontalLayout_14"> - <property name="spacing"> - <number>6</number> - </property> - <property name="leftMargin"> - <number>6</number> - </property> - <property name="topMargin"> - <number>0</number> - </property> - <property name="rightMargin"> - <number>6</number> - </property> - <property name="bottomMargin"> - <number>6</number> - </property> - <item> - <widget class="QWidget" name="player2LeftJoycon" native="true"> - <layout class="QVBoxLayout" name="buttonMiscButtonsLeftJoyconVerticalLayout_15"> - <property name="spacing"> - <number>0</number> - </property> - <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 alignment="Qt::AlignHCenter"> - <widget class="QGroupBox" name="player2LeftBodyGroup"> - <property name="title"> - <string>L Body</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - <layout class="QVBoxLayout" name="verticalLayout_70"> - <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="player2_left_body_button"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <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/> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item alignment="Qt::AlignHCenter"> - <widget class="QGroupBox" name="player2LeftButtonsGroup"> - <property name="title"> - <string>L Button</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - <layout class="QVBoxLayout" name="verticalLayout_71"> - <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="player2_left_buttons_button"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <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/> - </property> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QWidget" name="player2RightJoycon" native="true"> - <layout class="QVBoxLayout" name="buttonMiscButtonsRightJoyconVerticalLayout_15"> - <property name="spacing"> - <number>0</number> - </property> - <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 alignment="Qt::AlignHCenter"> - <widget class="QGroupBox" name="player2RightBodyGroup"> - <property name="title"> - <string>R Body</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - <layout class="QVBoxLayout" name="verticalLayout_68"> - <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="player2_right_body_button"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <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/> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item alignment="Qt::AlignHCenter"> - <widget class="QGroupBox" name="player2RightButtonsGroup"> - <property name="title"> - <string>R Button</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - <layout class="QVBoxLayout" name="verticalLayout_69"> - <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="player2_right_buttons_button"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <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/> - </property> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QWidget" name="player34Widget" native="true"> - <layout class="QHBoxLayout" name="horizontalLayout_5"> - <property name="leftMargin"> - <number>0</number> - </property> - <property name="topMargin"> - <number>0</number> - </property> - <property name="rightMargin"> - <number>0</number> - </property> - <property name="bottomMargin"> - <number>0</number> - </property> - <item> - <widget class="QGroupBox" name="player3Group"> - <property name="title"> - <string>Player 3</string> - </property> - <layout class="QHBoxLayout" name="horizontalLayout_15"> - <property name="spacing"> - <number>6</number> - </property> - <property name="leftMargin"> - <number>6</number> - </property> - <property name="topMargin"> - <number>0</number> - </property> - <property name="rightMargin"> - <number>6</number> - </property> - <property name="bottomMargin"> - <number>6</number> - </property> - <item> - <widget class="QWidget" name="player3LeftJoycon" native="true"> - <layout class="QVBoxLayout" name="buttonMiscButtonsLeftJoyconVerticalLayout_16"> - <property name="spacing"> - <number>0</number> - </property> - <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 alignment="Qt::AlignHCenter"> - <widget class="QGroupBox" name="player3LeftBodyGroup"> - <property name="title"> - <string>L Body</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - <layout class="QVBoxLayout" name="verticalLayout_74"> - <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="player3_left_body_button"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <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/> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item alignment="Qt::AlignHCenter"> - <widget class="QGroupBox" name="player3LeftButtonsGroup"> - <property name="title"> - <string>L Button</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - <layout class="QVBoxLayout" name="verticalLayout_75"> - <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="player3_left_buttons_button"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <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/> - </property> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QWidget" name="player3RightJoycon" native="true"> - <layout class="QVBoxLayout" name="buttonMiscButtonsRightJoyconVerticalLayout_16"> - <property name="spacing"> - <number>0</number> - </property> - <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 alignment="Qt::AlignHCenter"> - <widget class="QGroupBox" name="player3RightBodyGroup"> - <property name="title"> - <string>R Body</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - <layout class="QVBoxLayout" name="verticalLayout_72"> - <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="player3_right_body_button"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <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/> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item alignment="Qt::AlignHCenter"> - <widget class="QGroupBox" name="player3RightButtonsGroup"> - <property name="title"> - <string>R Button</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - <layout class="QVBoxLayout" name="verticalLayout_73"> - <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="player3_right_buttons_button"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <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/> - </property> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QGroupBox" name="player4Group"> - <property name="title"> - <string>Player 4</string> - </property> - <layout class="QHBoxLayout" name="horizontalLayout_16"> - <property name="spacing"> - <number>6</number> - </property> - <property name="leftMargin"> - <number>6</number> - </property> - <property name="topMargin"> - <number>0</number> - </property> - <property name="rightMargin"> - <number>6</number> - </property> - <property name="bottomMargin"> - <number>6</number> - </property> - <item> - <widget class="QWidget" name="player4LeftJoycon" native="true"> - <layout class="QVBoxLayout" name="buttonMiscButtonsLeftJoyconVerticalLayout_17"> - <property name="spacing"> - <number>0</number> - </property> - <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 alignment="Qt::AlignHCenter"> - <widget class="QGroupBox" name="player4LeftBodyGroup"> - <property name="title"> - <string>L Body</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - <layout class="QVBoxLayout" name="verticalLayout_78"> - <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="player4_left_body_button"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <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/> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item alignment="Qt::AlignHCenter"> - <widget class="QGroupBox" name="player4LeftButtonsGroup"> - <property name="title"> - <string>L Button</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - <layout class="QVBoxLayout" name="verticalLayout_79"> - <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="player4_left_buttons_button"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <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/> - </property> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QWidget" name="player4RightJoycon" native="true"> - <layout class="QVBoxLayout" name="buttonMiscButtonsRightJoyconVerticalLayout_17"> - <property name="spacing"> - <number>0</number> - </property> - <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 alignment="Qt::AlignHCenter"> - <widget class="QGroupBox" name="player4RightBodyGroup"> - <property name="title"> - <string>R Body</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - <layout class="QVBoxLayout" name="verticalLayout_76"> - <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="player4_right_body_button"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <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/> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item alignment="Qt::AlignHCenter"> - <widget class="QGroupBox" name="player4RightButtonsGroup"> - <property name="title"> - <string>R Button</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - <layout class="QVBoxLayout" name="verticalLayout_77"> - <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="player4_right_buttons_button"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <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/> - </property> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QWidget" name="bottomLeftInputAdvanced" native="true"> - <layout class="QVBoxLayout" name="verticalLayout_5"> - <property name="spacing"> - <number>6</number> - </property> - <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="QWidget" name="player56Widget" native="true"> - <layout class="QHBoxLayout" name="horizontalLayout_6"> - <property name="leftMargin"> - <number>0</number> - </property> - <property name="topMargin"> - <number>0</number> - </property> - <property name="rightMargin"> - <number>0</number> - </property> - <property name="bottomMargin"> - <number>0</number> - </property> - <item> - <widget class="QGroupBox" name="player5Group"> - <property name="title"> - <string>Player 5</string> - </property> - <layout class="QHBoxLayout" name="horizontalLayout_10"> - <property name="spacing"> - <number>6</number> - </property> - <property name="leftMargin"> - <number>6</number> - </property> - <property name="topMargin"> - <number>0</number> - </property> - <property name="rightMargin"> - <number>6</number> - </property> - <property name="bottomMargin"> - <number>6</number> - </property> - <item> - <widget class="QWidget" name="player5LeftJoycon" native="true"> - <layout class="QVBoxLayout" name="buttonMiscButtonsLeftJoyconVerticalLayout_10"> - <property name="spacing"> - <number>0</number> - </property> - <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 alignment="Qt::AlignHCenter"> - <widget class="QGroupBox" name="player5LeftBodyGroup"> - <property name="title"> - <string>L Body</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - <layout class="QVBoxLayout" name="verticalLayout_50"> - <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="player5_left_body_button"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <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/> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item alignment="Qt::AlignHCenter"> - <widget class="QGroupBox" name="player5LeftButtonsGroup"> - <property name="title"> - <string>L Button</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - <layout class="QVBoxLayout" name="verticalLayout_51"> - <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="player5_left_buttons_button"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <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/> - </property> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QWidget" name="player5RightJoycon" native="true"> - <layout class="QVBoxLayout" name="buttonMiscButtonsRightJoyconVerticalLayout_10"> - <property name="spacing"> - <number>0</number> - </property> - <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 alignment="Qt::AlignHCenter"> - <widget class="QGroupBox" name="player5RightBodyGroup"> - <property name="title"> - <string>R Body</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - <layout class="QVBoxLayout" name="verticalLayout_48"> - <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="player5_right_body_button"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <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/> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item alignment="Qt::AlignHCenter"> - <widget class="QGroupBox" name="player5RightButtonsGroup"> - <property name="title"> - <string>R Button</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - <layout class="QVBoxLayout" name="verticalLayout_49"> - <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="player5_right_buttons_button"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <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/> - </property> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QGroupBox" name="player6Group"> - <property name="title"> - <string>Player 6</string> - </property> - <layout class="QHBoxLayout" name="horizontalLayout_11"> - <property name="spacing"> - <number>6</number> - </property> - <property name="leftMargin"> - <number>6</number> - </property> - <property name="topMargin"> - <number>0</number> - </property> - <property name="rightMargin"> - <number>6</number> - </property> - <property name="bottomMargin"> - <number>6</number> - </property> - <item> - <widget class="QWidget" name="player6LeftJoycon" native="true"> - <layout class="QVBoxLayout" name="buttonMiscButtonsLeftJoyconVerticalLayout_11"> - <property name="spacing"> - <number>0</number> - </property> - <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 alignment="Qt::AlignHCenter"> - <widget class="QGroupBox" name="player6LeftBodyGroup"> - <property name="title"> - <string>L Body</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - <layout class="QVBoxLayout" name="verticalLayout_54"> - <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="player6_left_body_button"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <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/> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item alignment="Qt::AlignHCenter"> - <widget class="QGroupBox" name="player6LeftButtonsGroup"> - <property name="title"> - <string>L Button</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - <layout class="QVBoxLayout" name="verticalLayout_55"> - <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="player6_left_buttons_button"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <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/> - </property> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QWidget" name="player6RightJoycon" native="true"> - <layout class="QVBoxLayout" name="buttonMiscButtonsRightJoyconVerticalLayout_11"> - <property name="spacing"> - <number>0</number> - </property> - <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 alignment="Qt::AlignHCenter"> - <widget class="QGroupBox" name="player6RightBodyGroup"> - <property name="title"> - <string>R Body</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - <layout class="QVBoxLayout" name="verticalLayout_52"> - <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="player6_right_body_button"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <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/> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item alignment="Qt::AlignHCenter"> - <widget class="QGroupBox" name="player6RightButtonsGroup"> - <property name="title"> - <string>R Button</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - <layout class="QVBoxLayout" name="verticalLayout_53"> - <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="player6_right_buttons_button"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <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/> - </property> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QWidget" name="player78Widget" 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="QGroupBox" name="player7Group"> - <property name="title"> - <string>Player 7</string> - </property> - <layout class="QHBoxLayout" name="horizontalLayout_12"> - <property name="spacing"> - <number>6</number> - </property> - <property name="leftMargin"> - <number>6</number> - </property> - <property name="topMargin"> - <number>0</number> - </property> - <property name="rightMargin"> - <number>6</number> - </property> - <property name="bottomMargin"> - <number>6</number> - </property> - <item> - <widget class="QWidget" name="player7LeftJoycon" native="true"> - <layout class="QVBoxLayout" name="buttonMiscButtonsLeftJoyconVerticalLayout_12"> - <property name="spacing"> - <number>0</number> - </property> - <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 alignment="Qt::AlignHCenter"> - <widget class="QGroupBox" name="player7LeftBodyGroup"> - <property name="title"> - <string>L Body</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - <layout class="QVBoxLayout" name="verticalLayout_58"> - <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="player7_left_body_button"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <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/> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item alignment="Qt::AlignHCenter"> - <widget class="QGroupBox" name="player7LeftButtonsGroup"> - <property name="title"> - <string>L Button</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - <layout class="QVBoxLayout" name="verticalLayout_59"> - <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="player7_left_buttons_button"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <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/> - </property> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QWidget" name="player7RightJoycon" native="true"> - <layout class="QVBoxLayout" name="buttonMiscButtonsRightJoyconVerticalLayout_12"> - <property name="spacing"> - <number>0</number> - </property> - <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 alignment="Qt::AlignHCenter"> - <widget class="QGroupBox" name="player7RightBodyGroup"> - <property name="title"> - <string>R Body</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - <layout class="QVBoxLayout" name="verticalLayout_56"> - <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="player7_right_body_button"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <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/> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item alignment="Qt::AlignHCenter"> - <widget class="QGroupBox" name="player7RightButtonsGroup"> - <property name="title"> - <string>R Button</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - <layout class="QVBoxLayout" name="verticalLayout_57"> - <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="player7_right_buttons_button"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <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/> - </property> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QGroupBox" name="player8Group"> - <property name="title"> - <string>Player 8</string> - </property> - <layout class="QHBoxLayout" name="horizontalLayout_13"> - <property name="spacing"> - <number>6</number> - </property> - <property name="leftMargin"> - <number>6</number> - </property> - <property name="topMargin"> - <number>0</number> - </property> - <property name="rightMargin"> - <number>6</number> - </property> - <property name="bottomMargin"> - <number>6</number> - </property> - <item> - <widget class="QWidget" name="player8LeftJoycon" native="true"> - <layout class="QVBoxLayout" name="buttonMiscButtonsLeftJoyconVerticalLayout_13"> - <property name="spacing"> - <number>0</number> - </property> - <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 alignment="Qt::AlignHCenter"> - <widget class="QGroupBox" name="player8LeftBodyGroup"> - <property name="title"> - <string>L Body</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - <layout class="QVBoxLayout" name="verticalLayout_62"> - <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="player8_left_body_button"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <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/> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item alignment="Qt::AlignHCenter"> - <widget class="QGroupBox" name="player8LeftButtonsGroup"> - <property name="title"> - <string>L Button</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - <layout class="QVBoxLayout" name="verticalLayout_63"> - <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="player8_left_buttons_button"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <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/> - </property> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QWidget" name="player8RightJoycon" native="true"> - <layout class="QVBoxLayout" name="buttonMiscButtonsRightJoyconVerticalLayout_13"> - <property name="spacing"> - <number>0</number> - </property> - <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 alignment="Qt::AlignHCenter"> - <widget class="QGroupBox" name="player8RightBodyGroup"> - <property name="title"> - <string>R Body</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - <layout class="QVBoxLayout" name="verticalLayout_60"> - <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="player8_right_body_button"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <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/> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item alignment="Qt::AlignHCenter"> - <widget class="QGroupBox" name="player8RightButtonsGroup"> - <property name="title"> - <string>R Button</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - <layout class="QVBoxLayout" name="verticalLayout_61"> - <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="player8_right_buttons_button"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <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/> - </property> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QWidget" name="rightInputAdvanced" native="true"> - <layout class="QVBoxLayout" name="rightLayout" stretch="1,1"> - <property name="spacing"> - <number>3</number> - </property> - <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="QWidget" name="topRightInputAdvanced" native="true"> - <layout class="QVBoxLayout" name="verticalLayout"> - <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="QGroupBox" name="emulatedDevicesGroupBox"> - <property name="title"> - <string>Emulated Devices</string> - </property> - <layout class="QGridLayout" name="emulatedDevicesGridLayout"> - <item row="0" column="0"> - <widget class="QCheckBox" name="keyboard_enabled"> - <property name="minimumSize"> - <size> - <width>0</width> - <height>23</height> - </size> - </property> - <property name="text"> - <string>Keyboard</string> - </property> - </widget> - </item> - <item row="1" column="0"> - <widget class="QCheckBox" name="mouse_enabled"> - <property name="minimumSize"> - <size> - <width>0</width> - <height>23</height> - </size> - </property> - <property name="text"> - <string>Mouse</string> - </property> - </widget> - </item> - <item row="2" column="0"> - <widget class="QCheckBox" name="touchscreen_enabled"> - <property name="text"> - <string>Touchscreen</string> - </property> - </widget> - </item> - <item row="2" column="1"> - <spacer name="horizontalSpacer_8"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeType"> - <enum>QSizePolicy::Fixed</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>76</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item row="2" column="2"> - <widget class="QPushButton" name="touchscreen_advanced"> - <property name="text"> - <string>Advanced</string> - </property> - </widget> - </item> - <item row="3" column="0"> - <widget class="QCheckBox" name="debug_enabled"> - <property name="text"> - <string>Debug Controller</string> - </property> - </widget> - </item> - <item row="3" column="2"> - <widget class="QPushButton" name="debug_configure"> - <property name="text"> - <string>Configure</string> - </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> - <item> - <widget class="QGroupBox" name="otherGroupBox"> - <property name="title"> - <string>Other</string> - </property> - <layout class="QGridLayout" name="OtherGridLayout"> - <item row="1" column="0"> - <widget class="QCheckBox" name="emulate_analog_keyboard"> - <property name="minimumSize"> - <size> - <width>0</width> - <height>23</height> - </size> - </property> - <property name="text"> - <string>Emulate Analog with Keyboard Input</string> - </property> - </widget> - </item> - <item row="2" column="0"> - <widget class="QCheckBox" name="enable_raw_input"> - <property name="toolTip"> - <string>Requires restarting yuzu</string> - </property> - <property name="minimumSize"> - <size> - <width>0</width> - <height>23</height> - </size> - </property> - <property name="text"> - <string>Enable XInput 8 player support (disables web applet)</string> - </property> - </widget> - </item> - <item row="3" column="0"> - <widget class="QCheckBox" name="enable_udp_controller"> - <property name="minimumSize"> - <size> - <width>0</width> - <height>23</height> - </size> - </property> - <property name="text"> - <string>Enable UDP controllers (not needed for motion)</string> - </property> - </widget> - </item> - <item row="4" column="0"> - <widget class="QCheckBox" name="controller_navigation"> - <property name="minimumSize"> - <size> - <width>0</width> - <height>23</height> - </size> - </property> - <property name="text"> - <string>Controller navigation</string> - </property> - </widget> - </item> - <item row="5" column="0"> - <widget class="QCheckBox" name="enable_joycon_driver"> - <property name="toolTip"> - <string>Requires restarting yuzu</string> - </property> - <property name="minimumSize"> - <size> - <width>0</width> - <height>23</height> - </size> - </property> - <property name="text"> - <string>Enable direct JoyCon driver</string> - </property> - </widget> - </item> - <item row="6" column="0"> - <widget class="QCheckBox" name="enable_procon_driver"> - <property name="toolTip"> - <string>Requires restarting yuzu</string> - </property> - <property name="minimumSize"> - <size> - <width>0</width> - <height>23</height> - </size> - </property> - <property name="text"> - <string>Enable direct Pro Controller driver [EXPERIMENTAL]</string> - </property> - </widget> - </item> - <item row="7" column="0"> - <widget class="QCheckBox" name="random_amiibo_id"> - <property name="toolTip"> - <string>Allows unlimited uses of the same Amiibo in games that would otherwise limit you to one use.</string> - </property> - <property name="minimumSize"> - <size> - <width>0</width> - <height>23</height> - </size> - </property> - <property name="text"> - <string>Use random Amiibo ID</string> - </property> - </widget> - </item> - <item row="8" column="0"> - <widget class="QLabel" name="motion_touch"> - <property name="text"> - <string>Motion / Touch</string> - </property> - </widget> - </item> - <item row="8" column="2"> - <widget class="QPushButton" name="buttonMotionTouch"> - <property name="text"> - <string>Configure</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> - </layout> - </widget> - </item> - <item> - <widget class="QWidget" name="bottomRightInputAdvanced" native="true"> - <layout class="QVBoxLayout" name="verticalLayout_2"> - <property name="leftMargin"> - <number>0</number> - </property> - <property name="topMargin"> - <number>0</number> - </property> - <property name="rightMargin"> - <number>0</number> - </property> - <property name="bottomMargin"> - <number>0</number> - </property> - <item> - <spacer name="mainVerticalSpacer"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>40</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - <resources> - </resources> - <connections/> -</ui> diff --git a/src/yuzu/configuration/configure_input_per_game.cpp b/src/yuzu/configuration/configure_input_per_game.cpp deleted file mode 100644 index eea7ec369..000000000 --- a/src/yuzu/configuration/configure_input_per_game.cpp +++ /dev/null @@ -1,115 +0,0 @@ -// SPDX-FileCopyrightText: 2022 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include "common/settings.h" -#include "core/core.h" -#include "frontend_common/config.h" -#include "hid_core/frontend/emulated_controller.h" -#include "hid_core/hid_core.h" -#include "ui_configure_input_per_game.h" -#include "yuzu/configuration/configure_input_per_game.h" -#include "yuzu/configuration/input_profiles.h" - -ConfigureInputPerGame::ConfigureInputPerGame(Core::System& system_, QtConfig* config_, - QWidget* parent) - : QWidget(parent), ui(std::make_unique<Ui::ConfigureInputPerGame>()), - profiles(std::make_unique<InputProfiles>()), system{system_}, config{config_} { - ui->setupUi(this); - const std::array labels = { - ui->label_player_1, ui->label_player_2, ui->label_player_3, ui->label_player_4, - ui->label_player_5, ui->label_player_6, ui->label_player_7, ui->label_player_8, - }; - profile_comboboxes = { - ui->profile_player_1, ui->profile_player_2, ui->profile_player_3, ui->profile_player_4, - ui->profile_player_5, ui->profile_player_6, ui->profile_player_7, ui->profile_player_8, - }; - - Settings::values.players.SetGlobal(false); - - const auto& profile_names = profiles->GetInputProfileNames(); - const auto populate_profiles = [this, &profile_names](size_t player_index) { - const auto previous_profile = - Settings::values.players.GetValue()[player_index].profile_name; - - auto* const player_combobox = profile_comboboxes[player_index]; - player_combobox->addItem(tr("Use global input configuration")); - - for (size_t index = 0; index < profile_names.size(); ++index) { - const auto& profile_name = profile_names[index]; - player_combobox->addItem(QString::fromStdString(profile_name)); - if (profile_name == previous_profile) { - // offset by 1 since the first element is the global config - player_combobox->setCurrentIndex(static_cast<int>(index + 1)); - } - } - }; - for (size_t index = 0; index < profile_comboboxes.size(); ++index) { - labels[index]->setText(tr("Player %1 profile").arg(index + 1)); - populate_profiles(index); - } - - LoadConfiguration(); -} - -void ConfigureInputPerGame::ApplyConfiguration() { - LoadConfiguration(); - SaveConfiguration(); -} - -void ConfigureInputPerGame::LoadConfiguration() { - static constexpr size_t HANDHELD_INDEX = 8; - - auto& hid_core = system.HIDCore(); - for (size_t player_index = 0; player_index < profile_comboboxes.size(); ++player_index) { - Settings::values.players.SetGlobal(false); - - auto* emulated_controller = hid_core.GetEmulatedControllerByIndex(player_index); - auto* const player_combobox = profile_comboboxes[player_index]; - - const auto selection_index = player_combobox->currentIndex(); - if (selection_index == 0) { - Settings::values.players.GetValue()[player_index].profile_name = ""; - if (player_index == 0) { - Settings::values.players.GetValue()[HANDHELD_INDEX] = {}; - } - Settings::values.players.SetGlobal(true); - emulated_controller->ReloadFromSettings(); - continue; - } - const auto profile_name = player_combobox->itemText(selection_index).toStdString(); - if (profile_name.empty()) { - continue; - } - auto& player = Settings::values.players.GetValue()[player_index]; - player.profile_name = profile_name; - // Read from the profile into the custom player settings - profiles->LoadProfile(profile_name, player_index); - // Make sure the controller is connected - player.connected = true; - - emulated_controller->ReloadFromSettings(); - - if (player_index > 0) { - continue; - } - // Handle Handheld cases - auto& handheld_player = Settings::values.players.GetValue()[HANDHELD_INDEX]; - auto* handheld_controller = hid_core.GetEmulatedController(Core::HID::NpadIdType::Handheld); - if (player.controller_type == Settings::ControllerType::Handheld) { - handheld_player = player; - } else { - handheld_player = {}; - } - handheld_controller->ReloadFromSettings(); - } -} - -void ConfigureInputPerGame::SaveConfiguration() { - Settings::values.players.SetGlobal(false); - - // Clear all controls from the config in case the user reverted back to globals - config->ClearControlPlayerValues(); - for (size_t index = 0; index < Settings::values.players.GetValue().size(); ++index) { - config->SaveQtControlPlayerValues(index); - } -} diff --git a/src/yuzu/configuration/configure_input_per_game.h b/src/yuzu/configuration/configure_input_per_game.h deleted file mode 100644 index 4420e856c..000000000 --- a/src/yuzu/configuration/configure_input_per_game.h +++ /dev/null @@ -1,46 +0,0 @@ -// SPDX-FileCopyrightText: 2022 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include <memory> - -#include <QWidget> - -#include "ui_configure_input_per_game.h" -#include "yuzu/configuration/input_profiles.h" -#include "yuzu/configuration/qt_config.h" - -class QComboBox; - -namespace Core { -class System; -} // namespace Core - -class Config; - -class ConfigureInputPerGame : public QWidget { - Q_OBJECT - -public: - explicit ConfigureInputPerGame(Core::System& system_, QtConfig* config_, - QWidget* parent = nullptr); - - /// Load and Save configurations to settings file. - void ApplyConfiguration(); - -private: - /// Load configuration from settings file. - void LoadConfiguration(); - - /// Save configuration to settings file. - void SaveConfiguration(); - - std::unique_ptr<Ui::ConfigureInputPerGame> ui; - std::unique_ptr<InputProfiles> profiles; - - std::array<QComboBox*, 8> profile_comboboxes; - - Core::System& system; - QtConfig* config; -}; diff --git a/src/yuzu/configuration/configure_input_per_game.ui b/src/yuzu/configuration/configure_input_per_game.ui deleted file mode 100644 index fbd8eab1c..000000000 --- a/src/yuzu/configuration/configure_input_per_game.ui +++ /dev/null @@ -1,333 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>ConfigureInputPerGame</class> - <widget class="QWidget" name="PerGameInput"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>541</width> - <height>759</height> - </rect> - </property> - <property name="windowTitle"> - <string>Form</string> - </property> - <property name="accessibleName"> - <string>Graphics</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout_1"> - <item> - <layout class="QVBoxLayout" name="verticalLayout_2"> - <property name="spacing"> - <number>0</number> - </property> - <item> - <widget class="QGroupBox" name="groupBox"> - <property name="title"> - <string>Input Profiles</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout_4"> - <item> - <widget class="QWidget" name="player_1" native="true"> - <layout class="QHBoxLayout" name="input_profile_layout_1"> - <property name="leftMargin"> - <number>0</number> - </property> - <property name="topMargin"> - <number>0</number> - </property> - <property name="rightMargin"> - <number>0</number> - </property> - <property name="bottomMargin"> - <number>0</number> - </property> - <item> - <widget class="QLabel" name="label_player_1"> - <property name="text"> - <string>Player 1 Profile</string> - </property> - </widget> - </item> - <item> - <widget class="QComboBox" name="profile_player_1"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QWidget" name="player_2" native="true"> - <layout class="QHBoxLayout" name="input_profile_layout_2"> - <property name="leftMargin"> - <number>0</number> - </property> - <property name="topMargin"> - <number>0</number> - </property> - <property name="rightMargin"> - <number>0</number> - </property> - <property name="bottomMargin"> - <number>0</number> - </property> - <item> - <widget class="QLabel" name="label_player_2"> - <property name="text"> - <string>Player 2 Profile</string> - </property> - </widget> - </item> - <item> - <widget class="QComboBox" name="profile_player_2"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QWidget" name="player_3" native="true"> - <layout class="QHBoxLayout" name="input_profile_layout_3"> - <property name="leftMargin"> - <number>0</number> - </property> - <property name="topMargin"> - <number>0</number> - </property> - <property name="rightMargin"> - <number>0</number> - </property> - <property name="bottomMargin"> - <number>0</number> - </property> - <item> - <widget class="QLabel" name="label_player_3"> - <property name="text"> - <string>Player 3 Profile</string> - </property> - </widget> - </item> - <item> - <widget class="QComboBox" name="profile_player_3"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QWidget" name="player_4" native="true"> - <layout class="QHBoxLayout" name="input_profile_layout_4"> - <property name="leftMargin"> - <number>0</number> - </property> - <property name="topMargin"> - <number>0</number> - </property> - <property name="rightMargin"> - <number>0</number> - </property> - <property name="bottomMargin"> - <number>0</number> - </property> - <item> - <widget class="QLabel" name="label_player_4"> - <property name="text"> - <string>Player 4 Profile</string> - </property> - </widget> - </item> - <item> - <widget class="QComboBox" name="profile_player_4"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QWidget" name="player_5" native="true"> - <layout class="QHBoxLayout" name="input_profile_layout_5"> - <property name="leftMargin"> - <number>0</number> - </property> - <property name="topMargin"> - <number>0</number> - </property> - <property name="rightMargin"> - <number>0</number> - </property> - <property name="bottomMargin"> - <number>0</number> - </property> - <item> - <widget class="QLabel" name="label_player_5"> - <property name="text"> - <string>Player 5 Profile</string> - </property> - </widget> - </item> - <item> - <widget class="QComboBox" name="profile_player_5"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QWidget" name="player_6" native="true"> - <layout class="QHBoxLayout" name="input_profile_layout_6"> - <property name="leftMargin"> - <number>0</number> - </property> - <property name="topMargin"> - <number>0</number> - </property> - <property name="rightMargin"> - <number>0</number> - </property> - <property name="bottomMargin"> - <number>0</number> - </property> - <item> - <widget class="QLabel" name="label_player_6"> - <property name="text"> - <string>Player 6 Profile</string> - </property> - </widget> - </item> - <item> - <widget class="QComboBox" name="profile_player_6"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QWidget" name="player_7" native="true"> - <layout class="QHBoxLayout" name="input_profile_layout_7"> - <property name="leftMargin"> - <number>0</number> - </property> - <property name="topMargin"> - <number>0</number> - </property> - <property name="rightMargin"> - <number>0</number> - </property> - <property name="bottomMargin"> - <number>0</number> - </property> - <item> - <widget class="QLabel" name="label_player_7"> - <property name="text"> - <string>Player 7 Profile</string> - </property> - </widget> - </item> - <item> - <widget class="QComboBox" name="profile_player_7"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QWidget" name="player_8" native="true"> - <layout class="QHBoxLayout" name="input_profile_layout_8"> - <property name="leftMargin"> - <number>0</number> - </property> - <property name="topMargin"> - <number>0</number> - </property> - <property name="rightMargin"> - <number>0</number> - </property> - <property name="bottomMargin"> - <number>0</number> - </property> - <item> - <widget class="QLabel" name="label_player_8"> - <property name="text"> - <string>Player 8 Profile</string> - </property> - </widget> - </item> - <item> - <widget class="QComboBox" name="profile_player_8"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </item> - <item> - <spacer name="verticalSpacer"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>40</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - <resources/> - <connections/> -</ui> diff --git a/src/yuzu/configuration/configure_input_player.cpp b/src/yuzu/configuration/configure_input_player.cpp deleted file mode 100644 index 400917f9d..000000000 --- a/src/yuzu/configuration/configure_input_player.cpp +++ /dev/null @@ -1,1670 +0,0 @@ -// 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 <QMenu> -#include <QMessageBox> -#include <QMouseEvent> -#include <QTimer> -#include "common/assert.h" -#include "common/param_package.h" -#include "configuration/qt_config.h" -#include "frontend_common/config.h" -#include "hid_core/frontend/emulated_controller.h" -#include "hid_core/hid_core.h" -#include "hid_core/hid_types.h" -#include "input_common/drivers/keyboard.h" -#include "input_common/drivers/mouse.h" -#include "input_common/main.h" -#include "ui_configure_input_player.h" -#include "yuzu/bootmanager.h" -#include "yuzu/configuration/configure_input_player.h" -#include "yuzu/configuration/configure_input_player_widget.h" -#include "yuzu/configuration/configure_mouse_panning.h" -#include "yuzu/configuration/input_profiles.h" -#include "yuzu/util/limitable_input_dialog.h" - -const std::array<std::string, ConfigureInputPlayer::ANALOG_SUB_BUTTONS_NUM> - ConfigureInputPlayer::analog_sub_buttons{{ - "up", - "down", - "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::TriggerZR: - return QObject::tr("ZR"); - case Common::Input::ButtonNames::TriggerZL: - return QObject::tr("ZL"); - case Common::Input::ButtonNames::TriggerSR: - return QObject::tr("SR"); - case Common::Input::ButtonNames::TriggerSL: - return QObject::tr("SL"); - case Common::Input::ButtonNames::ButtonStickL: - return QObject::tr("Stick L"); - case Common::Input::ButtonNames::ButtonStickR: - return QObject::tr("Stick R"); - 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::ButtonPlus: - return QObject::tr("Plus"); - case Common::Input::ButtonNames::ButtonMinus: - return QObject::tr("Minus"); - case Common::Input::ButtonNames::ButtonHome: - return QObject::tr("Home"); - case Common::Input::ButtonNames::ButtonCapture: - return QObject::tr("Capture"); - 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"); - case Common::Input::ButtonNames::Home: - return QObject::tr("Home"); - case Common::Input::ButtonNames::Touch: - return QObject::tr("Touch"); - case Common::Input::ButtonNames::ButtonMouseWheel: - return QObject::tr("Wheel", "Indicates the mouse wheel"); - case Common::Input::ButtonNames::ButtonBackward: - return QObject::tr("Backward"); - case Common::Input::ButtonNames::ButtonForward: - return QObject::tr("Forward"); - case Common::Input::ButtonNames::ButtonTask: - return QObject::tr("Task"); - case Common::Input::ButtonNames::ButtonExtra: - return QObject::tr("Extra"); - default: - return QObject::tr("[undefined]"); - } -} - -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 - 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 - -QString ConfigureInputPlayer::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 QString invert = QString::fromStdString(param.Get("invert", "+") == "-" ? "-" : ""); - const QString turbo = QString::fromStdString(param.Get("turbo", 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%3%4").arg(turbo, toggle, inverted, 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 = GetDirectionName(param.Get("direction", "")); - return QObject::tr("%1%2%3Hat %4").arg(turbo, toggle, inverted, hat); - } - if (param.Has("axis")) { - const QString axis = QString::fromStdString(param.Get("axis", "")); - return QObject::tr("%1%2%3Axis %4").arg(toggle, inverted, 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", "")); - 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%2%3Button %4").arg(turbo, toggle, inverted, button); - } - } - - QString button_name = GetButtonName(common_button_name); - if (param.Has("hat")) { - return QObject::tr("%1%2%3Hat %4").arg(turbo, toggle, inverted, button_name); - } - if (param.Has("axis")) { - return QObject::tr("%1%2%3Axis %4").arg(toggle, inverted, invert, 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%2%3Button %4").arg(turbo, toggle, inverted, button_name); - } - - return QObject::tr("[unknown]"); -} - -QString ConfigureInputPlayer::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]"); -} - -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_} { - 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); - emulated_controller_p1->SaveCurrentConfig(); - emulated_controller_p1->EnableConfiguration(); - emulated_controller_handheld->SaveCurrentConfig(); - emulated_controller_handheld->EnableConfiguration(); - if (emulated_controller_handheld->IsConnected(true)) { - emulated_controller_p1->Disconnect(); - emulated_controller = emulated_controller_handheld; - } else { - emulated_controller = emulated_controller_p1; - } - } else { - emulated_controller = hid_core.GetEmulatedControllerByIndex(player_index); - emulated_controller->SaveCurrentConfig(); - emulated_controller->EnableConfiguration(); - } - ui->setupUi(this); - - setFocusPolicy(Qt::ClickFocus); - - button_map = { - ui->buttonA, ui->buttonB, ui->buttonX, ui->buttonY, - ui->buttonLStick, ui->buttonRStick, ui->buttonL, ui->buttonR, - ui->buttonZL, ui->buttonZR, ui->buttonPlus, ui->buttonMinus, - ui->buttonDpadLeft, ui->buttonDpadUp, ui->buttonDpadRight, ui->buttonDpadDown, - ui->buttonSLLeft, ui->buttonSRLeft, ui->buttonHome, ui->buttonScreenshot, - ui->buttonSLRight, ui->buttonSRRight, - }; - - analog_map_buttons = {{ - { - ui->buttonLStickUp, - ui->buttonLStickDown, - ui->buttonLStickLeft, - ui->buttonLStickRight, - }, - { - ui->buttonRStickUp, - ui->buttonRStickDown, - ui->buttonRStickLeft, - ui->buttonRStickRight, - }, - }}; - - motion_map = { - ui->buttonMotionLeft, - ui->buttonMotionRight, - }; - - analog_map_deadzone_label = {ui->labelLStickDeadzone, ui->labelRStickDeadzone}; - analog_map_deadzone_slider = {ui->sliderLStickDeadzone, ui->sliderRStickDeadzone}; - analog_map_modifier_groupbox = {ui->buttonLStickModGroup, ui->buttonRStickModGroup}; - analog_map_modifier_button = {ui->buttonLStickMod, ui->buttonRStickMod}; - analog_map_modifier_label = {ui->labelLStickModifierRange, ui->labelRStickModifierRange}; - analog_map_modifier_slider = {ui->sliderLStickModifierRange, ui->sliderRStickModifierRange}; - analog_map_range_groupbox = {ui->buttonLStickRangeGroup, ui->buttonRStickRangeGroup}; - analog_map_range_spinbox = {ui->spinboxLStickRange, ui->spinboxRStickRange}; - - ui->controllerFrame->SetController(emulated_controller); - - for (int button_id = 0; button_id < Settings::NativeButton::NumButtons; ++button_id) { - auto* const button = button_map[button_id]; - - if (button == nullptr) { - continue; - } - - connect(button, &QPushButton::clicked, [=, this] { - HandleClick( - button, button_id, - [=, this](const Common::ParamPackage& params) { - emulated_controller->SetButtonParam(button_id, params); - }, - InputCommon::Polling::InputType::Button); - }); - - button->setContextMenuPolicy(Qt::CustomContextMenu); - connect(button, &QPushButton::customContextMenuRequested, - [=, this](const QPoint& menu_location) { - QMenu context_menu; - Common::ParamPackage param = emulated_controller->GetButtonParam(button_id); - context_menu.addAction(tr("Clear"), [&] { - emulated_controller->SetButtonParam(button_id, {}); - button_map[button_id]->setText(tr("[not set]")); - }); - if (param.Has("code") || param.Has("button") || param.Has("hat")) { - 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); - }); - context_menu.addAction(tr("Turbo button"), [&] { - const bool turbo_value = !param.Get("turbo", false); - param.Set("turbo", turbo_value); - button_map[button_id]->setText(ButtonToText(param)); - emulated_controller->SetButtonParam(button_id, param); - }); - } - if (param.Has("axis")) { - context_menu.addAction(tr("Invert axis"), [&] { - const bool toggle_value = !(param.Get("invert", "+") == "-"); - param.Set("invert", 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("Set threshold"), [&] { - const int button_threshold = - static_cast<int>(param.Get("threshold", 0.5f) * 100.0f); - const int new_threshold = QInputDialog::getInt( - this, tr("Set threshold"), tr("Choose a value between 0% and 100%"), - button_threshold, 0, 100); - param.Set("threshold", new_threshold / 100.0f); - - if (button_id == Settings::NativeButton::ZL) { - ui->sliderZLThreshold->setValue(new_threshold); - } - if (button_id == Settings::NativeButton::ZR) { - ui->sliderZRThreshold->setValue(new_threshold); - } - 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)); - }); - } - - for (int motion_id = 0; motion_id < Settings::NativeMotion::NumMotions; ++motion_id) { - auto* const button = motion_map[motion_id]; - if (button == nullptr) { - continue; - } - - connect(button, &QPushButton::clicked, [=, this] { - HandleClick( - button, motion_id, - [=, this](const Common::ParamPackage& params) { - emulated_controller->SetMotionParam(motion_id, params); - }, - InputCommon::Polling::InputType::Motion); - }); - - button->setContextMenuPolicy(Qt::CustomContextMenu); - - connect(button, &QPushButton::customContextMenuRequested, - [=, this](const QPoint& menu_location) { - QMenu context_menu; - Common::ParamPackage param = emulated_controller->GetMotionParam(motion_id); - context_menu.addAction(tr("Clear"), [&] { - emulated_controller->SetMotionParam(motion_id, {}); - motion_map[motion_id]->setText(tr("[not set]")); - }); - if (param.Has("motion")) { - context_menu.addAction(tr("Set gyro threshold"), [&] { - const int gyro_threshold = - static_cast<int>(param.Get("threshold", 0.007f) * 1000.0f); - const int new_threshold = QInputDialog::getInt( - this, tr("Set threshold"), tr("Choose a value between 0% and 100%"), - gyro_threshold, 0, 100); - param.Set("threshold", new_threshold / 1000.0f); - emulated_controller->SetMotionParam(motion_id, param); - }); - context_menu.addAction(tr("Calibrate sensor"), [&] { - emulated_controller->StartMotionCalibration(); - }); - } - context_menu.exec(motion_map[motion_id]->mapToGlobal(menu_location)); - }); - } - - connect(ui->sliderZLThreshold, &QSlider::valueChanged, [=, this] { - Common::ParamPackage param = - emulated_controller->GetButtonParam(Settings::NativeButton::ZL); - if (param.Has("threshold")) { - const auto slider_value = ui->sliderZLThreshold->value(); - param.Set("threshold", slider_value / 100.0f); - emulated_controller->SetButtonParam(Settings::NativeButton::ZL, param); - } - }); - - connect(ui->sliderZRThreshold, &QSlider::valueChanged, [=, this] { - Common::ParamPackage param = - emulated_controller->GetButtonParam(Settings::NativeButton::ZR); - if (param.Has("threshold")) { - const auto slider_value = ui->sliderZRThreshold->value(); - param.Set("threshold", slider_value / 100.0f); - emulated_controller->SetButtonParam(Settings::NativeButton::ZR, param); - } - }); - - for (int analog_id = 0; analog_id < Settings::NativeAnalog::NumAnalogs; ++analog_id) { - for (int sub_button_id = 0; sub_button_id < ANALOG_SUB_BUTTONS_NUM; ++sub_button_id) { - auto* const analog_button = analog_map_buttons[analog_id][sub_button_id]; - - if (analog_button == nullptr) { - continue; - } - - connect(analog_button, &QPushButton::clicked, [=, this] { - if (!map_analog_stick_accepted) { - map_analog_stick_accepted = - QMessageBox::information( - this, tr("Map Analog Stick"), - tr("After pressing OK, first move your joystick horizontally, and then " - "vertically.\nTo invert the axes, first move your joystick " - "vertically, and then horizontally."), - QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::Ok; - if (!map_analog_stick_accepted) { - return; - } - } - HandleClick( - analog_map_buttons[analog_id][sub_button_id], analog_id, - [=, 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); - }); - - analog_button->setContextMenuPolicy(Qt::CustomContextMenu); - - connect(analog_button, &QPushButton::customContextMenuRequested, - [=, this](const QPoint& menu_location) { - QMenu context_menu; - Common::ParamPackage param = emulated_controller->GetStickParam(analog_id); - context_menu.addAction(tr("Clear"), [&] { - 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"), [&] { - const auto stick_value = - emulated_controller->GetSticksValues()[analog_id]; - const float offset_x = stick_value.x.properties.offset; - const float offset_y = stick_value.y.properties.offset; - float raw_value_x = stick_value.x.raw_value; - float raw_value_y = stick_value.y.raw_value; - // See Core::HID::SanitizeStick() to obtain the original raw axis value - if (std::abs(offset_x) < 0.5f) { - if (raw_value_x > 0) { - raw_value_x *= 1 + offset_x; - } else { - raw_value_x *= 1 - offset_x; - } - } - if (std::abs(offset_x) < 0.5f) { - if (raw_value_y > 0) { - raw_value_y *= 1 + offset_y; - } else { - raw_value_y *= 1 - offset_y; - } - } - param.Set("offset_x", -raw_value_x + offset_x); - param.Set("offset_y", -raw_value_y + offset_y); - emulated_controller->SetStickParam(analog_id, param); - }); - context_menu.addAction(tr("Invert axis"), [&] { - if (sub_button_id == 2 || sub_button_id == 3) { - const bool invert_value = param.Get("invert_x", "+") == "-"; - const std::string invert_str = invert_value ? "+" : "-"; - param.Set("invert_x", invert_str); - emulated_controller->SetStickParam(analog_id, param); - } - if (sub_button_id == 0 || sub_button_id == 1) { - const bool invert_value = param.Get("invert_y", "+") == "-"; - const std::string invert_str = invert_value ? "+" : "-"; - param.Set("invert_y", invert_str); - emulated_controller->SetStickParam(analog_id, param); - } - for (int analog_sub_button_id = 0; - analog_sub_button_id < ANALOG_SUB_BUTTONS_NUM; - ++analog_sub_button_id) { - analog_map_buttons[analog_id][analog_sub_button_id]->setText( - AnalogToText(param, analog_sub_buttons[analog_sub_button_id])); - } - }); - context_menu.exec(analog_map_buttons[analog_id][sub_button_id]->mapToGlobal( - menu_location)); - }); - } - - // Handle clicks for the modifier buttons as well. - connect(analog_map_modifier_button[analog_id], &QPushButton::clicked, [=, this] { - HandleClick( - analog_map_modifier_button[analog_id], analog_id, - [=, this](const Common::ParamPackage& params) { - Common::ParamPackage param = emulated_controller->GetStickParam(analog_id); - param.Set("modifier", params.Serialize()); - emulated_controller->SetStickParam(analog_id, param); - }, - InputCommon::Polling::InputType::Button); - }); - - analog_map_modifier_button[analog_id]->setContextMenuPolicy(Qt::CustomContextMenu); - - connect( - analog_map_modifier_button[analog_id], &QPushButton::customContextMenuRequested, - [=, this](const QPoint& menu_location) { - QMenu context_menu; - Common::ParamPackage param = emulated_controller->GetStickParam(analog_id); - context_menu.addAction(tr("Clear"), [&] { - param.Set("modifier", ""); - analog_map_modifier_button[analog_id]->setText(tr("[not set]")); - emulated_controller->SetStickParam(analog_id, param); - }); - context_menu.addAction(tr("Toggle button"), [&] { - Common::ParamPackage modifier_param = - Common::ParamPackage{param.Get("modifier", "")}; - const bool toggle_value = !modifier_param.Get("toggle", false); - modifier_param.Set("toggle", toggle_value); - param.Set("modifier", modifier_param.Serialize()); - analog_map_modifier_button[analog_id]->setText(ButtonToText(modifier_param)); - emulated_controller->SetStickParam(analog_id, param); - }); - context_menu.addAction(tr("Invert button"), [&] { - Common::ParamPackage modifier_param = - Common::ParamPackage{param.Get("modifier", "")}; - const bool invert_value = !modifier_param.Get("inverted", false); - modifier_param.Set("inverted", invert_value); - param.Set("modifier", modifier_param.Serialize()); - analog_map_modifier_button[analog_id]->setText(ButtonToText(modifier_param)); - emulated_controller->SetStickParam(analog_id, param); - }); - context_menu.exec( - analog_map_modifier_button[analog_id]->mapToGlobal(menu_location)); - }); - - connect(analog_map_range_spinbox[analog_id], qOverload<int>(&QSpinBox::valueChanged), - [=, this] { - Common::ParamPackage param = emulated_controller->GetStickParam(analog_id); - const auto spinbox_value = analog_map_range_spinbox[analog_id]->value(); - param.Set("range", spinbox_value / 100.0f); - emulated_controller->SetStickParam(analog_id, param); - }); - - connect(analog_map_deadzone_slider[analog_id], &QSlider::valueChanged, [=, this] { - Common::ParamPackage param = emulated_controller->GetStickParam(analog_id); - const auto slider_value = analog_map_deadzone_slider[analog_id]->value(); - analog_map_deadzone_label[analog_id]->setText(tr("Deadzone: %1%").arg(slider_value)); - param.Set("deadzone", slider_value / 100.0f); - emulated_controller->SetStickParam(analog_id, param); - }); - - connect(analog_map_modifier_slider[analog_id], &QSlider::valueChanged, [=, this] { - Common::ParamPackage param = emulated_controller->GetStickParam(analog_id); - const auto slider_value = analog_map_modifier_slider[analog_id]->value(); - analog_map_modifier_label[analog_id]->setText( - tr("Modifier Range: %1%").arg(slider_value)); - param.Set("modifier_scale", slider_value / 100.0f); - emulated_controller->SetStickParam(analog_id, param); - }); - } - - if (player_index_ == 0) { - connect(ui->mousePanningButton, &QPushButton::clicked, [this, input_subsystem_] { - const auto right_stick_param = - emulated_controller->GetStickParam(Settings::NativeAnalog::RStick); - ConfigureMousePanning dialog(this, input_subsystem_, - right_stick_param.Get("deadzone", 0.0f), - right_stick_param.Get("range", 1.0f)); - if (dialog.exec() == QDialog::Accepted) { - dialog.ApplyConfiguration(); - } - }); - } else { - ui->mousePanningWidget->hide(); - } - - // Player Connected checkbox - connect(ui->groupConnectedController, &QGroupBox::toggled, - [this](bool checked) { emit Connected(checked); }); - - if (player_index == 0) { - connect(ui->comboControllerType, qOverload<int>(&QComboBox::currentIndexChanged), - [this](int index) { - emit HandheldStateChanged(GetControllerTypeFromIndex(index) == - Core::HID::NpadStyleIndex::Handheld); - }); - } - - if (debug || player_index == 9) { - ui->groupConnectedController->setCheckable(false); - } - - // The Debug Controller can only choose the Pro Controller. - if (debug) { - ui->buttonScreenshot->setEnabled(false); - ui->buttonHome->setEnabled(false); - ui->comboControllerType->addItem(tr("Pro Controller")); - } else { - SetConnectableControllers(); - } - - UpdateControllerAvailableButtons(); - UpdateControllerEnabledButtons(); - UpdateControllerButtonNames(); - UpdateMotionButtons(); - 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; - } - } - ui->controllerFrame->SetController(emulated_controller); - } - emulated_controller->SetNpadStyleIndex(type); - }); - - connect(ui->comboDevices, qOverload<int>(&QComboBox::activated), this, - &ConfigureInputPlayer::UpdateMappingWithDefaults); - ui->comboDevices->installEventFilter(this); - - ui->comboDevices->setCurrentIndex(-1); - - 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; - } - }); - - UpdateInputProfiles(); - - connect(ui->buttonProfilesNew, &QPushButton::clicked, this, - &ConfigureInputPlayer::CreateProfile); - connect(ui->buttonProfilesDelete, &QPushButton::clicked, this, - &ConfigureInputPlayer::DeleteProfile); - connect(ui->comboProfiles, qOverload<int>(&QComboBox::activated), this, - &ConfigureInputPlayer::LoadProfile); - connect(ui->buttonProfilesSave, &QPushButton::clicked, this, - &ConfigureInputPlayer::SaveProfile); - - LoadConfiguration(); -} - -ConfigureInputPlayer::~ConfigureInputPlayer() { - 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); - emulated_controller_p1->DisableConfiguration(); - emulated_controller_handheld->DisableConfiguration(); - } else { - emulated_controller->DisableConfiguration(); - } -} - -void ConfigureInputPlayer::ApplyConfiguration() { - 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); - emulated_controller_p1->DisableConfiguration(); - emulated_controller_p1->SaveCurrentConfig(); - emulated_controller_p1->EnableConfiguration(); - emulated_controller_handheld->DisableConfiguration(); - emulated_controller_handheld->SaveCurrentConfig(); - emulated_controller_handheld->EnableConfiguration(); - return; - } - emulated_controller->DisableConfiguration(); - emulated_controller->SaveCurrentConfig(); - emulated_controller->EnableConfiguration(); -} - -void ConfigureInputPlayer::showEvent(QShowEvent* event) { - if (bottom_row == nullptr) { - return; - } - QWidget::showEvent(event); - ui->main->addWidget(bottom_row); -} - -void ConfigureInputPlayer::changeEvent(QEvent* event) { - if (event->type() == QEvent::LanguageChange) { - RetranslateUI(); - } - - QWidget::changeEvent(event); -} - -void ConfigureInputPlayer::RetranslateUI() { - ui->retranslateUi(this); - UpdateUI(); -} - -void ConfigureInputPlayer::LoadConfiguration() { - emulated_controller->ReloadFromSettings(); - - UpdateUI(); - UpdateInputDeviceCombobox(); - - if (debug) { - return; - } - - const int comboBoxIndex = - GetIndexFromControllerType(emulated_controller->GetNpadStyleIndex(true)); - ui->comboControllerType->setCurrentIndex(comboBoxIndex); - ui->groupConnectedController->setChecked(emulated_controller->IsConnected(true)); -} - -void ConfigureInputPlayer::ConnectPlayer(bool connected) { - ui->groupConnectedController->setChecked(connected); - if (connected) { - emulated_controller->Connect(true); - } else { - emulated_controller->Disconnect(); - } -} - -void ConfigureInputPlayer::UpdateInputDeviceCombobox() { - // Skip input device persistence if "Input Devices" is set to "Any". - if (ui->comboDevices->currentIndex() == 0) { - UpdateInputDevices(); - return; - } - - const auto devices = emulated_controller->GetMappedDevices(); - UpdateInputDevices(); - - if (devices.empty()) { - return; - } - - if (devices.size() > 2) { - ui->comboDevices->setCurrentIndex(0); - return; - } - - const auto first_engine = devices[0].Get("engine", ""); - const auto first_guid = devices[0].Get("guid", ""); - const auto first_port = devices[0].Get("port", 0); - const auto first_pad = devices[0].Get("pad", 0); - - if (devices.size() == 1) { - const auto devices_it = std::find_if( - input_devices.begin(), input_devices.end(), - [first_engine, first_guid, first_port, first_pad](const Common::ParamPackage& param) { - return param.Get("engine", "") == first_engine && - param.Get("guid", "") == first_guid && param.Get("port", 0) == first_port && - param.Get("pad", 0) == first_pad; - }); - const int device_index = - devices_it != input_devices.end() - ? static_cast<int>(std::distance(input_devices.begin(), devices_it)) - : 0; - ui->comboDevices->setCurrentIndex(device_index); - return; - } - - const auto second_engine = devices[1].Get("engine", ""); - const auto second_guid = devices[1].Get("guid", ""); - const auto second_port = devices[1].Get("port", 0); - - const bool is_keyboard_mouse = (first_engine == "keyboard" || first_engine == "mouse") && - (second_engine == "keyboard" || second_engine == "mouse"); - - if (is_keyboard_mouse) { - ui->comboDevices->setCurrentIndex(2); - return; - } - - const bool is_engine_equal = first_engine == second_engine; - const bool is_port_equal = first_port == second_port; - - if (is_engine_equal && is_port_equal) { - const auto devices_it = std::find_if( - input_devices.begin(), input_devices.end(), - [first_engine, first_guid, second_guid, first_port](const Common::ParamPackage& param) { - const bool is_guid_valid = - (param.Get("guid", "") == first_guid && - param.Get("guid2", "") == second_guid) || - (param.Get("guid", "") == second_guid && param.Get("guid2", "") == first_guid); - return param.Get("engine", "") == first_engine && is_guid_valid && - param.Get("port", 0) == first_port; - }); - const int device_index = - devices_it != input_devices.end() - ? static_cast<int>(std::distance(input_devices.begin(), devices_it)) - : 0; - ui->comboDevices->setCurrentIndex(device_index); - } else { - ui->comboDevices->setCurrentIndex(0); - } -} - -void ConfigureInputPlayer::RestoreDefaults() { - UpdateMappingWithDefaults(); -} - -void ConfigureInputPlayer::ClearAll() { - for (int button_id = 0; button_id < Settings::NativeButton::NumButtons; ++button_id) { - const auto* const button = button_map[button_id]; - if (button == nullptr) { - continue; - } - emulated_controller->SetButtonParam(button_id, {}); - } - - for (int analog_id = 0; analog_id < Settings::NativeAnalog::NumAnalogs; ++analog_id) { - for (int sub_button_id = 0; sub_button_id < ANALOG_SUB_BUTTONS_NUM; ++sub_button_id) { - const auto* const analog_button = analog_map_buttons[analog_id][sub_button_id]; - if (analog_button == nullptr) { - continue; - } - emulated_controller->SetStickParam(analog_id, {}); - } - } - - for (int motion_id = 0; motion_id < Settings::NativeMotion::NumMotions; ++motion_id) { - const auto* const motion_button = motion_map[motion_id]; - if (motion_button == nullptr) { - continue; - } - emulated_controller->SetMotionParam(motion_id, {}); - } - - UpdateUI(); - UpdateInputDevices(); -} - -void ConfigureInputPlayer::UpdateUI() { - for (int button = 0; button < Settings::NativeButton::NumButtons; ++button) { - const Common::ParamPackage param = emulated_controller->GetButtonParam(button); - button_map[button]->setText(ButtonToText(param)); - } - - const Common::ParamPackage ZL_param = - emulated_controller->GetButtonParam(Settings::NativeButton::ZL); - if (ZL_param.Has("threshold")) { - const int button_threshold = static_cast<int>(ZL_param.Get("threshold", 0.5f) * 100.0f); - ui->sliderZLThreshold->setValue(button_threshold); - } - - const Common::ParamPackage ZR_param = - emulated_controller->GetButtonParam(Settings::NativeButton::ZR); - if (ZR_param.Has("threshold")) { - const int button_threshold = static_cast<int>(ZR_param.Get("threshold", 0.5f) * 100.0f); - ui->sliderZRThreshold->setValue(button_threshold); - } - - for (int motion_id = 0; motion_id < Settings::NativeMotion::NumMotions; ++motion_id) { - const Common::ParamPackage param = emulated_controller->GetMotionParam(motion_id); - motion_map[motion_id]->setText(ButtonToText(param)); - } - - for (int analog_id = 0; analog_id < Settings::NativeAnalog::NumAnalogs; ++analog_id) { - const Common::ParamPackage param = emulated_controller->GetStickParam(analog_id); - for (int sub_button_id = 0; sub_button_id < ANALOG_SUB_BUTTONS_NUM; ++sub_button_id) { - auto* const analog_button = analog_map_buttons[analog_id][sub_button_id]; - - if (analog_button == nullptr) { - continue; - } - - analog_button->setText(AnalogToText(param, analog_sub_buttons[sub_button_id])); - } - - analog_map_modifier_button[analog_id]->setText( - ButtonToText(Common::ParamPackage{param.Get("modifier", "")})); - - const auto deadzone_label = analog_map_deadzone_label[analog_id]; - const auto deadzone_slider = analog_map_deadzone_slider[analog_id]; - const auto modifier_groupbox = analog_map_modifier_groupbox[analog_id]; - const auto modifier_label = analog_map_modifier_label[analog_id]; - const auto modifier_slider = analog_map_modifier_slider[analog_id]; - const auto range_groupbox = analog_map_range_groupbox[analog_id]; - const auto range_spinbox = analog_map_range_spinbox[analog_id]; - - int slider_value; - const bool is_controller = input_subsystem->IsController(param); - - if (is_controller) { - 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", 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)); - modifier_slider->setValue(slider_value); - } - - deadzone_label->setVisible(is_controller); - deadzone_slider->setVisible(is_controller); - modifier_groupbox->setVisible(!is_controller); - modifier_label->setVisible(!is_controller); - modifier_slider->setVisible(!is_controller); - range_groupbox->setVisible(is_controller); - } -} - -void ConfigureInputPlayer::SetConnectableControllers() { - const auto npad_style_set = hid_core.GetSupportedStyleTag(); - index_controller_type_pairs.clear(); - ui->comboControllerType->clear(); - - const auto add_item = [&](Core::HID::NpadStyleIndex controller_type, - const QString& controller_name) { - index_controller_type_pairs.emplace_back(ui->comboControllerType->count(), controller_type); - ui->comboControllerType->addItem(controller_name); - }; - - if (npad_style_set.fullkey == 1) { - add_item(Core::HID::NpadStyleIndex::Fullkey, tr("Pro Controller")); - } - - if (npad_style_set.joycon_dual == 1) { - add_item(Core::HID::NpadStyleIndex::JoyconDual, tr("Dual Joycons")); - } - - if (npad_style_set.joycon_left == 1) { - add_item(Core::HID::NpadStyleIndex::JoyconLeft, tr("Left Joycon")); - } - - if (npad_style_set.joycon_right == 1) { - add_item(Core::HID::NpadStyleIndex::JoyconRight, tr("Right Joycon")); - } - - if (player_index == 0 && npad_style_set.handheld == 1) { - add_item(Core::HID::NpadStyleIndex::Handheld, tr("Handheld")); - } - - if (npad_style_set.gamecube == 1) { - add_item(Core::HID::NpadStyleIndex::GameCube, tr("GameCube Controller")); - } - - // Disable all unsupported controllers - if (!Settings::values.enable_all_controllers) { - return; - } - - if (npad_style_set.palma == 1) { - add_item(Core::HID::NpadStyleIndex::Pokeball, tr("Poke Ball Plus")); - } - - if (npad_style_set.lark == 1) { - add_item(Core::HID::NpadStyleIndex::NES, tr("NES Controller")); - } - - if (npad_style_set.lucia == 1) { - add_item(Core::HID::NpadStyleIndex::SNES, tr("SNES Controller")); - } - - if (npad_style_set.lagoon == 1) { - add_item(Core::HID::NpadStyleIndex::N64, tr("N64 Controller")); - } - - if (npad_style_set.lager == 1) { - add_item(Core::HID::NpadStyleIndex::SegaGenesis, tr("Sega Genesis")); - } -} - -Core::HID::NpadStyleIndex ConfigureInputPlayer::GetControllerTypeFromIndex(int index) const { - const auto it = - std::find_if(index_controller_type_pairs.begin(), index_controller_type_pairs.end(), - [index](const auto& pair) { return pair.first == index; }); - - if (it == index_controller_type_pairs.end()) { - return Core::HID::NpadStyleIndex::Fullkey; - } - - return it->second; -} - -int ConfigureInputPlayer::GetIndexFromControllerType(Core::HID::NpadStyleIndex type) const { - const auto it = - std::find_if(index_controller_type_pairs.begin(), index_controller_type_pairs.end(), - [type](const auto& pair) { return pair.second == type; }); - - if (it == index_controller_type_pairs.end()) { - return -1; - } - - return it->first; -} - -void ConfigureInputPlayer::UpdateInputDevices() { - input_devices = input_subsystem->GetInputDevices(); - ui->comboDevices->clear(); - for (const auto& device : input_devices) { - ui->comboDevices->addItem(QString::fromStdString(device.Get("display", "Unknown")), {}); - } -} - -void ConfigureInputPlayer::UpdateControllerAvailableButtons() { - auto layout = GetControllerTypeFromIndex(ui->comboControllerType->currentIndex()); - if (debug) { - layout = Core::HID::NpadStyleIndex::Fullkey; - } - - // List of all the widgets that will be hidden by any of the following layouts that need - // "unhidden" after the controller type changes - const std::array<QWidget*, 14> layout_show = { - ui->buttonShoulderButtonsSLSRLeft, - ui->buttonShoulderButtonsSLSRRight, - ui->horizontalSpacerShoulderButtonsWidget, - ui->horizontalSpacerShoulderButtonsWidget2, - ui->horizontalSpacerShoulderButtonsWidget3, - ui->horizontalSpacerShoulderButtonsWidget4, - ui->buttonShoulderButtonsLeft, - ui->buttonMiscButtonsMinusScreenshot, - ui->bottomLeft, - ui->buttonShoulderButtonsRight, - ui->buttonMiscButtonsPlusHome, - ui->bottomRight, - ui->buttonMiscButtonsMinusGroup, - ui->buttonMiscButtonsScreenshotGroup, - }; - - for (auto* widget : layout_show) { - widget->show(); - } - - std::vector<QWidget*> layout_hidden; - switch (layout) { - case Core::HID::NpadStyleIndex::Fullkey: - case Core::HID::NpadStyleIndex::Handheld: - layout_hidden = { - ui->buttonShoulderButtonsSLSRLeft, - ui->buttonShoulderButtonsSLSRRight, - ui->horizontalSpacerShoulderButtonsWidget2, - ui->horizontalSpacerShoulderButtonsWidget4, - }; - break; - case Core::HID::NpadStyleIndex::JoyconLeft: - layout_hidden = { - ui->buttonShoulderButtonsSLSRRight, - ui->horizontalSpacerShoulderButtonsWidget2, - ui->horizontalSpacerShoulderButtonsWidget3, - ui->buttonShoulderButtonsRight, - ui->buttonMiscButtonsPlusHome, - ui->bottomRight, - }; - break; - case Core::HID::NpadStyleIndex::JoyconRight: - layout_hidden = { - ui->buttonShoulderButtonsSLSRLeft, ui->horizontalSpacerShoulderButtonsWidget, - ui->horizontalSpacerShoulderButtonsWidget4, ui->buttonShoulderButtonsLeft, - ui->buttonMiscButtonsMinusScreenshot, ui->bottomLeft, - }; - break; - case Core::HID::NpadStyleIndex::GameCube: - layout_hidden = { - ui->buttonShoulderButtonsSLSRLeft, - ui->buttonShoulderButtonsSLSRRight, - ui->horizontalSpacerShoulderButtonsWidget2, - ui->horizontalSpacerShoulderButtonsWidget4, - ui->buttonMiscButtonsMinusGroup, - ui->buttonMiscButtonsScreenshotGroup, - }; - break; - default: - break; - } - - for (auto* widget : layout_hidden) { - widget->hide(); - } -} - -void ConfigureInputPlayer::UpdateControllerEnabledButtons() { - auto layout = GetControllerTypeFromIndex(ui->comboControllerType->currentIndex()); - if (debug) { - layout = Core::HID::NpadStyleIndex::Fullkey; - } - - // List of all the widgets that will be disabled by any of the following layouts that need - // "enabled" after the controller type changes - const std::array<QWidget*, 3> layout_enable = { - ui->buttonLStickPressedGroup, - ui->groupRStickPressed, - ui->buttonShoulderButtonsButtonLGroup, - }; - - for (auto* widget : layout_enable) { - widget->setEnabled(true); - } - - std::vector<QWidget*> layout_disable; - switch (layout) { - case Core::HID::NpadStyleIndex::Fullkey: - case Core::HID::NpadStyleIndex::JoyconDual: - case Core::HID::NpadStyleIndex::Handheld: - case Core::HID::NpadStyleIndex::JoyconLeft: - case Core::HID::NpadStyleIndex::JoyconRight: - break; - case Core::HID::NpadStyleIndex::GameCube: - layout_disable = { - ui->buttonHome, - ui->buttonLStickPressedGroup, - ui->groupRStickPressed, - ui->buttonShoulderButtonsButtonLGroup, - }; - break; - default: - break; - } - - for (auto* widget : layout_disable) { - widget->setEnabled(false); - } -} - -void ConfigureInputPlayer::UpdateMotionButtons() { - if (debug) { - // Motion isn't used with the debug controller, hide both groupboxes. - ui->buttonMotionLeftGroup->hide(); - ui->buttonMotionRightGroup->hide(); - return; - } - - // Show/hide the "Motion 1/2" groupboxes depending on the currently selected controller. - switch (GetControllerTypeFromIndex(ui->comboControllerType->currentIndex())) { - case Core::HID::NpadStyleIndex::Fullkey: - case Core::HID::NpadStyleIndex::JoyconLeft: - case Core::HID::NpadStyleIndex::Handheld: - // Show "Motion 1" and hide "Motion 2". - ui->buttonMotionLeftGroup->show(); - ui->buttonMotionRightGroup->hide(); - break; - case Core::HID::NpadStyleIndex::JoyconRight: - // Show "Motion 2" and hide "Motion 1". - ui->buttonMotionLeftGroup->hide(); - ui->buttonMotionRightGroup->show(); - break; - case Core::HID::NpadStyleIndex::GameCube: - // Hide both "Motion 1/2". - ui->buttonMotionLeftGroup->hide(); - ui->buttonMotionRightGroup->hide(); - break; - case Core::HID::NpadStyleIndex::JoyconDual: - default: - // Show both "Motion 1/2". - ui->buttonMotionLeftGroup->show(); - ui->buttonMotionRightGroup->show(); - break; - } -} - -void ConfigureInputPlayer::UpdateControllerButtonNames() { - auto layout = GetControllerTypeFromIndex(ui->comboControllerType->currentIndex()); - if (debug) { - layout = Core::HID::NpadStyleIndex::Fullkey; - } - - switch (layout) { - case Core::HID::NpadStyleIndex::Fullkey: - case Core::HID::NpadStyleIndex::JoyconDual: - case Core::HID::NpadStyleIndex::Handheld: - case Core::HID::NpadStyleIndex::JoyconLeft: - case Core::HID::NpadStyleIndex::JoyconRight: - ui->buttonMiscButtonsPlusGroup->setTitle(tr("Plus")); - ui->buttonShoulderButtonsButtonZLGroup->setTitle(tr("ZL")); - ui->buttonShoulderButtonsZRGroup->setTitle(tr("ZR")); - ui->buttonShoulderButtonsRGroup->setTitle(tr("R")); - ui->LStick->setTitle(tr("Left Stick")); - ui->RStick->setTitle(tr("Right Stick")); - break; - case Core::HID::NpadStyleIndex::GameCube: - ui->buttonMiscButtonsPlusGroup->setTitle(tr("Start / Pause")); - ui->buttonShoulderButtonsButtonZLGroup->setTitle(tr("L")); - ui->buttonShoulderButtonsZRGroup->setTitle(tr("R")); - ui->buttonShoulderButtonsRGroup->setTitle(tr("Z")); - ui->LStick->setTitle(tr("Control Stick")); - ui->RStick->setTitle(tr("C-Stick")); - break; - default: - break; - } -} - -void ConfigureInputPlayer::UpdateMappingWithDefaults() { - if (ui->comboDevices->currentIndex() == 0) { - return; - } - - for (int button_id = 0; button_id < Settings::NativeButton::NumButtons; ++button_id) { - const auto* const button = button_map[button_id]; - if (button == nullptr) { - continue; - } - emulated_controller->SetButtonParam(button_id, {}); - } - - for (int analog_id = 0; analog_id < Settings::NativeAnalog::NumAnalogs; ++analog_id) { - for (int sub_button_id = 0; sub_button_id < ANALOG_SUB_BUTTONS_NUM; ++sub_button_id) { - const auto* const analog_button = analog_map_buttons[analog_id][sub_button_id]; - if (analog_button == nullptr) { - continue; - } - emulated_controller->SetStickParam(analog_id, {}); - } - } - - for (int motion_id = 0; motion_id < Settings::NativeMotion::NumMotions; ++motion_id) { - const auto* const motion_button = motion_map[motion_id]; - if (motion_button == nullptr) { - continue; - } - emulated_controller->SetMotionParam(motion_id, {}); - } - - // Reset keyboard or mouse bindings - if (ui->comboDevices->currentIndex() == 1 || ui->comboDevices->currentIndex() == 2) { - for (int button_id = 0; button_id < Settings::NativeButton::NumButtons; ++button_id) { - emulated_controller->SetButtonParam( - button_id, Common::ParamPackage{InputCommon::GenerateKeyboardParam( - QtConfig::default_buttons[button_id])}); - } - for (int analog_id = 0; analog_id < Settings::NativeAnalog::NumAnalogs; ++analog_id) { - Common::ParamPackage analog_param{}; - for (int sub_button_id = 0; sub_button_id < ANALOG_SUB_BUTTONS_NUM; ++sub_button_id) { - Common::ParamPackage params{InputCommon::GenerateKeyboardParam( - QtConfig::default_analogs[analog_id][sub_button_id])}; - SetAnalogParam(params, analog_param, analog_sub_buttons[sub_button_id]); - } - - analog_param.Set("modifier", InputCommon::GenerateKeyboardParam( - QtConfig::default_stick_mod[analog_id])); - emulated_controller->SetStickParam(analog_id, analog_param); - } - - for (int motion_id = 0; motion_id < Settings::NativeMotion::NumMotions; ++motion_id) { - emulated_controller->SetMotionParam( - motion_id, Common::ParamPackage{InputCommon::GenerateKeyboardParam( - QtConfig::default_motions[motion_id])}); - } - - // If mouse is selected we want to override with mappings from the driver - if (ui->comboDevices->currentIndex() == 1) { - UpdateUI(); - return; - } - } - - // Reset controller bindings - const auto& device = input_devices[ui->comboDevices->currentIndex()]; - auto button_mappings = input_subsystem->GetButtonMappingForDevice(device); - auto analog_mappings = input_subsystem->GetAnalogMappingForDevice(device); - auto motion_mappings = input_subsystem->GetMotionMappingForDevice(device); - - for (const auto& button_mapping : button_mappings) { - const std::size_t index = button_mapping.first; - emulated_controller->SetButtonParam(index, button_mapping.second); - } - for (const auto& analog_mapping : analog_mappings) { - const std::size_t index = analog_mapping.first; - emulated_controller->SetStickParam(index, analog_mapping.second); - } - for (const auto& motion_mapping : motion_mappings) { - const std::size_t index = motion_mapping.first; - emulated_controller->SetMotionParam(index, motion_mapping.second); - } - - UpdateUI(); -} - -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 { - button->setText(tr("[waiting]")); - } - button->setFocus(); - - input_setter = std::move(new_input_setter); - - input_subsystem->BeginMapping(type); - - QWidget::grabMouse(); - QWidget::grabKeyboard(); - - if (type == InputCommon::Polling::InputType::Button) { - ui->controllerFrame->BeginMappingButton(button_id); - } else if (type == InputCommon::Polling::InputType::Stick) { - ui->controllerFrame->BeginMappingAnalog(button_id); - } - - timeout_timer->start(4000); // Cancel after 4 seconds - poll_timer->start(25); // Check for new inputs every 25ms -} - -void ConfigureInputPlayer::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(); - UpdateInputDeviceCombobox(); - ui->controllerFrame->EndMapping(); - - input_setter = std::nullopt; -} - -bool ConfigureInputPlayer::IsInputAcceptable(const Common::ParamPackage& params) const { - if (ui->comboDevices->currentIndex() == 0) { - return true; - } - - if (params.Has("motion")) { - return true; - } - - // Keyboard/Mouse - if (ui->comboDevices->currentIndex() == 1 || ui->comboDevices->currentIndex() == 2) { - return params.Get("engine", "") == "keyboard" || params.Get("engine", "") == "mouse"; - } - - const auto& current_input_device = input_devices[ui->comboDevices->currentIndex()]; - return params.Get("engine", "") == current_input_device.Get("engine", "") && - (params.Get("guid", "") == current_input_device.Get("guid", "") || - params.Get("guid", "") == current_input_device.Get("guid2", "")) && - params.Get("port", 0) == current_input_device.Get("port", 0); -} - -void ConfigureInputPlayer::mousePressEvent(QMouseEvent* event) { - if (!input_setter || !event) { - return; - } - - const auto button = GRenderWindow::QtButtonToMouseButton(event->button()); - input_subsystem->GetMouse()->PressButton(0, 0, button); -} - -void ConfigureInputPlayer::wheelEvent(QWheelEvent* event) { - const int x = event->angleDelta().x(); - const int y = event->angleDelta().y(); - input_subsystem->GetMouse()->MouseWheelChange(x, y); -} - -void ConfigureInputPlayer::keyPressEvent(QKeyEvent* event) { - if (!input_setter || !event) { - return; - } - event->ignore(); - if (event->key() != Qt::Key_Escape) { - input_subsystem->GetKeyboard()->PressKey(event->key()); - } -} - -bool ConfigureInputPlayer::eventFilter(QObject* object, QEvent* event) { - if (object == ui->comboDevices && event->type() == QEvent::MouseButtonPress) { - RefreshInputDevices(); - } - return object->eventFilter(object, event); -} - -void ConfigureInputPlayer::CreateProfile() { - const auto profile_name = - LimitableInputDialog::GetText(this, tr("New Profile"), tr("Enter a profile name:"), 1, 30, - LimitableInputDialog::InputLimiter::Filesystem); - - if (profile_name.isEmpty()) { - return; - } - - if (!InputProfiles::IsProfileNameValid(profile_name.toStdString())) { - QMessageBox::critical(this, tr("Create Input Profile"), - tr("The given profile name is not valid!")); - return; - } - - ApplyConfiguration(); - - if (!profiles->CreateProfile(profile_name.toStdString(), player_index)) { - QMessageBox::critical(this, tr("Create Input Profile"), - tr("Failed to create the input profile \"%1\"").arg(profile_name)); - UpdateInputProfiles(); - emit RefreshInputProfiles(player_index); - return; - } - - emit RefreshInputProfiles(player_index); - - ui->comboProfiles->addItem(profile_name); - ui->comboProfiles->setCurrentIndex(ui->comboProfiles->count() - 1); -} - -void ConfigureInputPlayer::DeleteProfile() { - const QString profile_name = ui->comboProfiles->itemText(ui->comboProfiles->currentIndex()); - - if (profile_name.isEmpty()) { - return; - } - - if (!profiles->DeleteProfile(profile_name.toStdString())) { - QMessageBox::critical(this, tr("Delete Input Profile"), - tr("Failed to delete the input profile \"%1\"").arg(profile_name)); - UpdateInputProfiles(); - emit RefreshInputProfiles(player_index); - return; - } - - emit RefreshInputProfiles(player_index); - - ui->comboProfiles->removeItem(ui->comboProfiles->currentIndex()); - ui->comboProfiles->setCurrentIndex(-1); -} - -void ConfigureInputPlayer::LoadProfile() { - const QString profile_name = ui->comboProfiles->itemText(ui->comboProfiles->currentIndex()); - - if (profile_name.isEmpty()) { - return; - } - - ApplyConfiguration(); - - if (!profiles->LoadProfile(profile_name.toStdString(), player_index)) { - QMessageBox::critical(this, tr("Load Input Profile"), - tr("Failed to load the input profile \"%1\"").arg(profile_name)); - UpdateInputProfiles(); - emit RefreshInputProfiles(player_index); - return; - } - - LoadConfiguration(); -} - -void ConfigureInputPlayer::SaveProfile() { - static constexpr size_t HANDHELD_INDEX = 8; - const QString profile_name = ui->comboProfiles->itemText(ui->comboProfiles->currentIndex()); - - if (profile_name.isEmpty()) { - return; - } - - ApplyConfiguration(); - - // When we're in handheld mode, only the handheld emulated controller bindings are updated - const bool is_handheld = player_index == 0 && emulated_controller->GetNpadIdType() == - Core::HID::NpadIdType::Handheld; - const auto profile_player_index = is_handheld ? HANDHELD_INDEX : player_index; - - if (!profiles->SaveProfile(profile_name.toStdString(), profile_player_index)) { - QMessageBox::critical(this, tr("Save Input Profile"), - tr("Failed to save the input profile \"%1\"").arg(profile_name)); - UpdateInputProfiles(); - emit RefreshInputProfiles(player_index); - return; - } -} - -void ConfigureInputPlayer::UpdateInputProfiles() { - ui->comboProfiles->clear(); - - // Set current profile as empty by default - int profile_index = -1; - - // Add every available profile and search the player profile to set it as current one - auto& current_profile = Settings::values.players.GetValue()[player_index].profile_name; - std::vector<std::string> profile_names = profiles->GetInputProfileNames(); - std::string profile_name; - for (size_t i = 0; i < profile_names.size(); i++) { - profile_name = profile_names[i]; - ui->comboProfiles->addItem(QString::fromStdString(profile_name)); - if (current_profile == profile_name) { - profile_index = (int)i; - } - } - - LOG_DEBUG(Frontend, "Setting the current input profile to index {}", profile_index); - ui->comboProfiles->setCurrentIndex(profile_index); -} diff --git a/src/yuzu/configuration/configure_input_player.h b/src/yuzu/configuration/configure_input_player.h deleted file mode 100644 index fda09e925..000000000 --- a/src/yuzu/configuration/configure_input_player.h +++ /dev/null @@ -1,228 +0,0 @@ -// SPDX-FileCopyrightText: 2016 Citra Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include <array> -#include <functional> -#include <memory> -#include <optional> -#include <string> -#include <vector> - -#include <QWidget> - -#include "common/param_package.h" -#include "common/settings.h" -#include "ui_configure_input.h" - -class QCheckBox; -class QKeyEvent; -class QLabel; -class QPushButton; -class QSlider; -class QSpinBox; -class QString; -class QTimer; -class QWidget; - -class InputProfiles; - -namespace InputCommon { -class InputSubsystem; -} - -namespace InputCommon::Polling { -enum class InputType; -} // namespace InputCommon::Polling - -namespace Ui { -class ConfigureInputPlayer; -} // namespace Ui - -namespace Core::HID { -class HIDCore; -class EmulatedController; -enum class NpadStyleIndex : u8; -} // namespace Core::HID - -class ConfigureInputPlayer : public QWidget { - Q_OBJECT - -public: - explicit 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 = false); - ~ConfigureInputPlayer() override; - - /// Save all button configurations to settings file. - void ApplyConfiguration(); - - /// Set the connection state checkbox (used to sync state). - void ConnectPlayer(bool connected); - - /// Update the input devices combobox. - void UpdateInputDeviceCombobox(); - - /// Updates the list of controller profiles. - void UpdateInputProfiles(); - - /// Restore all buttons to their default values. - void RestoreDefaults(); - - /// Clear all input configuration. - void ClearAll(); - -signals: - /// Emitted when this controller is (dis)connected by the user. - void Connected(bool connected); - /// Emitted when the Handheld mode is selected (undocked with dual joycons attached). - void HandheldStateChanged(bool is_handheld); - /// Emitted when the input devices combobox is being refreshed. - void RefreshInputDevices(); - /** - * Emitted when the input profiles combobox is being refreshed. - * The player_index represents the current player's index, and the profile combobox - * will not be updated for this index as they are already updated by other mechanisms. - */ - void RefreshInputProfiles(std::size_t player_index); - -protected: - void showEvent(QShowEvent* event) override; - -private: - QString ButtonToText(const Common::ParamPackage& param); - - QString AnalogToText(const Common::ParamPackage& param, const std::string& dir); - - void changeEvent(QEvent* event) override; - void RetranslateUI(); - - /// Load configuration settings. - void LoadConfiguration(); - - /// Called when the button was pressed. - void HandleClick(QPushButton* button, std::size_t button_id, - 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 mouse wheel move events. - void wheelEvent(QWheelEvent* event) override; - - /// Handle key press events. - void keyPressEvent(QKeyEvent* event) override; - - /// Handle combobox list refresh - bool eventFilter(QObject* object, QEvent* event) override; - - /// Update UI to reflect current configuration. - void UpdateUI(); - - /// Sets the available controllers. - void SetConnectableControllers(); - - /// Gets the Controller Type for a given controller combobox index. - Core::HID::NpadStyleIndex GetControllerTypeFromIndex(int index) const; - - /// Gets the controller combobox index for a given Controller Type. - int GetIndexFromControllerType(Core::HID::NpadStyleIndex type) const; - - /// Update the available input devices. - void UpdateInputDevices(); - - /// Hides and disables controller settings based on the current controller type. - void UpdateControllerAvailableButtons(); - - /// Disables controller settings based on the current controller type. - void UpdateControllerEnabledButtons(); - - /// Shows or hides motion groupboxes based on the current controller type. - void UpdateMotionButtons(); - - /// Alters the button names based on the current controller type. - void UpdateControllerButtonNames(); - - /// Gets the default controller mapping for this device and auto configures the input to match. - void UpdateMappingWithDefaults(); - - /// Creates a controller profile. - void CreateProfile(); - - /// Deletes the selected controller profile. - void DeleteProfile(); - - /// Loads the selected controller profile. - void LoadProfile(); - - /// Saves the current controller configuration into a selected controller profile. - void SaveProfile(); - - std::unique_ptr<Ui::ConfigureInputPlayer> ui; - - std::size_t player_index; - bool debug; - bool is_powered_on; - - InputCommon::InputSubsystem* input_subsystem; - - InputProfiles* profiles; - - std::unique_ptr<QTimer> timeout_timer; - std::unique_ptr<QTimer> poll_timer; - - /// Stores a pair of "Connected Controllers" combobox index and Controller Type enum. - std::vector<std::pair<int, Core::HID::NpadStyleIndex>> index_controller_type_pairs; - - /// This will be the the setting function when an input is awaiting configuration. - std::optional<std::function<void(const Common::ParamPackage&)>> input_setter; - - Core::HID::EmulatedController* emulated_controller; - - static constexpr int ANALOG_SUB_BUTTONS_NUM = 4; - - /// Each button input is represented by a QPushButton. - std::array<QPushButton*, Settings::NativeButton::NumButtons> button_map; - - /// A group of four QPushButtons represent one analog input. The buttons each represent up, - /// down, left, right, respectively. - std::array<std::array<QPushButton*, ANALOG_SUB_BUTTONS_NUM>, Settings::NativeAnalog::NumAnalogs> - analog_map_buttons; - - /// Each motion input is represented by a QPushButton. - std::array<QPushButton*, Settings::NativeMotion::NumMotions> motion_map; - - std::array<QLabel*, Settings::NativeAnalog::NumAnalogs> analog_map_deadzone_label; - std::array<QSlider*, Settings::NativeAnalog::NumAnalogs> analog_map_deadzone_slider; - std::array<QGroupBox*, Settings::NativeAnalog::NumAnalogs> analog_map_modifier_groupbox; - std::array<QPushButton*, Settings::NativeAnalog::NumAnalogs> analog_map_modifier_button; - std::array<QLabel*, Settings::NativeAnalog::NumAnalogs> analog_map_modifier_label; - std::array<QSlider*, Settings::NativeAnalog::NumAnalogs> analog_map_modifier_slider; - std::array<QGroupBox*, Settings::NativeAnalog::NumAnalogs> analog_map_range_groupbox; - std::array<QSpinBox*, Settings::NativeAnalog::NumAnalogs> analog_map_range_spinbox; - - static const std::array<std::string, ANALOG_SUB_BUTTONS_NUM> analog_sub_buttons; - - /// A flag to indicate that the "Map Analog Stick" pop-up has been shown and accepted once. - bool map_analog_stick_accepted{}; - - /// List of physical devices users can map with. If a SDL backed device is selected, then you - /// can use this device to get a default mapping. - std::vector<Common::ParamPackage> input_devices; - - /// Bottom row is where console wide settings are held, and its "owned" by the parent - /// ConfigureInput widget. On show, add this widget to the main layout. This will change the - /// parent of the widget to this widget (but that's fine). - QWidget* bottom_row; - - Core::HID::HIDCore& hid_core; -}; diff --git a/src/yuzu/configuration/configure_input_player.ui b/src/yuzu/configuration/configure_input_player.ui deleted file mode 100644 index 5518cccd1..000000000 --- a/src/yuzu/configuration/configure_input_player.ui +++ /dev/null @@ -1,3323 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>ConfigureInputPlayer</class> - <widget class="QWidget" name="ConfigureInputPlayer"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>780</width> - <height>487</height> - </rect> - </property> - <property name="windowTitle"> - <string>Configure Input</string> - </property> - <layout class="QHBoxLayout" name="horizontalLayout_2"> - <property name="spacing"> - <number>0</number> - </property> - <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="QVBoxLayout" name="main"> - <property name="spacing"> - <number>0</number> - </property> - <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="top" stretch="0,1,2"> - <property name="spacing"> - <number>3</number> - </property> - <property name="topMargin"> - <number>0</number> - </property> - <item> - <widget class="QGroupBox" name="groupConnectedController"> - <property name="layoutDirection"> - <enum>Qt::LeftToRight</enum> - </property> - <property name="title"> - <string>Connect Controller</string> - </property> - <property name="flat"> - <bool>false</bool> - </property> - <property name="checkable"> - <bool>true</bool> - </property> - <layout class="QHBoxLayout" name="horizontalLayout_3"> - <property name="leftMargin"> - <number>5</number> - </property> - <property name="topMargin"> - <number>5</number> - </property> - <property name="rightMargin"> - <number>5</number> - </property> - <property name="bottomMargin"> - <number>5</number> - </property> - <item> - <widget class="QComboBox" name="comboControllerType"> - <property name="minimumSize"> - <size> - <width>0</width> - <height>21</height> - </size> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QGroupBox" name="devicesGroup"> - <property name="title"> - <string>Input Device</string> - </property> - <layout class="QHBoxLayout" name="horizontalLayout_5"> - <property name="spacing"> - <number>3</number> - </property> - <property name="leftMargin"> - <number>5</number> - </property> - <property name="topMargin"> - <number>5</number> - </property> - <property name="rightMargin"> - <number>5</number> - </property> - <property name="bottomMargin"> - <number>5</number> - </property> - <item> - <widget class="QComboBox" name="comboDevices"> - <property name="minimumContentsLength"> - <number>60</number> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QGroupBox" name="profilesGroup"> - <property name="minimumSize"> - <size> - <width>0</width> - <height>0</height> - </size> - </property> - <property name="title"> - <string>Profile</string> - </property> - <layout class="QHBoxLayout" name="horizontalLayout_4" stretch="2,0,0,0"> - <property name="spacing"> - <number>3</number> - </property> - <property name="leftMargin"> - <number>5</number> - </property> - <property name="topMargin"> - <number>5</number> - </property> - <property name="rightMargin"> - <number>5</number> - </property> - <property name="bottomMargin"> - <number>5</number> - </property> - <item> - <widget class="QComboBox" name="comboProfiles"> - <property name="minimumSize"> - <size> - <width>0</width> - <height>21</height> - </size> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="buttonProfilesSave"> - <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>Save</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="buttonProfilesNew"> - <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>New</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="buttonProfilesDelete"> - <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>Delete</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </item> - <item> - <widget class="QFrame" name="bottom"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <layout class="QHBoxLayout" name="_2"> - <property name="sizeConstraint"> - <enum>QLayout::SetMinimumSize</enum> - </property> - <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="QWidget" name="bottomLeft" native="true"> - <layout class="QVBoxLayout" name="bottomLeftLayout" stretch="0,0,0,0"> - <property name="spacing"> - <number>0</number> - </property> - <property name="sizeConstraint"> - <enum>QLayout::SetDefaultConstraint</enum> - </property> - <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="QGroupBox" name="LStick"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="title"> - <string>Left Stick</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> - <widget class="QWidget" name="buttonLStickUpWidget" native="true"> - <layout class="QHBoxLayout" name="horizontalLayout_20"> - <property name="spacing"> - <number>0</number> - </property> - <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> - <spacer name="horizontalSpacerLStickUpLeft"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item alignment="Qt::AlignHCenter"> - <widget class="QGroupBox" name="buttonLStickUpGroup"> - <property name="title"> - <string>Up</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - <property name="flat"> - <bool>false</bool> - </property> - <layout class="QVBoxLayout" name="buttonLStickUpVerticalLayout"> - <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="buttonLStickUp"> - <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>Up</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <spacer name="horizontalSpacerLStickUpRight"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - </item> - <item> - <layout class="QHBoxLayout" name="buttonLStickLeftRightHorizontaLayout"> - <property name="spacing"> - <number>3</number> - </property> - <item alignment="Qt::AlignHCenter"> - <widget class="QGroupBox" name="buttonLStickLeftGroup"> - <property name="title"> - <string>Left</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - <layout class="QVBoxLayout" name="buttonLStickLeftVerticalLayout"> - <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="buttonLStickLeft"> - <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>Left</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item alignment="Qt::AlignHCenter"> - <widget class="QGroupBox" name="buttonLStickRightGroup"> - <property name="title"> - <string>Right</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - <layout class="QVBoxLayout" name="buttonLStickRightVerticalLayout"> - <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="buttonLStickRight"> - <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>Right</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </item> - <item> - <widget class="QWidget" name="buttonLStickDownWidget" native="true"> - <layout class="QHBoxLayout" name="horizontalLayout_22"> - <property name="spacing"> - <number>0</number> - </property> - <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> - <spacer name="horizontalSpacerLStickDownLeft"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item alignment="Qt::AlignHCenter"> - <widget class="QGroupBox" name="buttonLStickDownGroup"> - <property name="title"> - <string>Down</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - <layout class="QVBoxLayout" name="buttonLStickDownVerticalLayout"> - <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="buttonLStickDown"> - <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>Down</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <spacer name="horizontalSpacerLStickDownRight"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - </item> - <item> - <layout class="QHBoxLayout" name="buttonLStickPressedModifierHorizontalLayout"> - <property name="spacing"> - <number>3</number> - </property> - <item alignment="Qt::AlignHCenter"> - <widget class="QGroupBox" name="buttonLStickPressedGroup"> - <property name="title"> - <string>Pressed</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - <layout class="QVBoxLayout" name="buttonLStickPressedVerticalLayout" stretch="0"> - <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="buttonLStick"> - <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>Pressed</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item alignment="Qt::AlignHCenter"> - <widget class="QGroupBox" name="buttonLStickModGroup"> - <property name="title"> - <string>Modifier</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - <layout class="QVBoxLayout" name="buttonLStickModVerticalLayout"> - <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="buttonLStickMod"> - <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>Modifier</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QGroupBox" name="buttonLStickRangeGroup"> - <property name="title"> - <string>Range</string> - </property> - <layout class="QHBoxLayout" name="buttonLStickRangeGroupHorizontalLayout"> - <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="QSpinBox" name="spinboxLStickRange"> - <property name="minimumSize"> - <size> - <width>68</width> - <height>21</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>68</width> - <height>16777215</height> - </size> - </property> - <property name="suffix"> - <string>%</string> - </property> - <property name="minimum"> - <number>25</number> - </property> - <property name="maximum"> - <number>150</number> - </property> - <property name="value"> - <number>95</number> - </property> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </item> - <item> - <layout class="QVBoxLayout" name="sliderLStickDeadzoneModifierRangeVerticalLayout"> - <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>2</number> - </property> - <property name="rightMargin"> - <number>0</number> - </property> - <property name="bottomMargin"> - <number>3</number> - </property> - <item> - <layout class="QHBoxLayout" name="sliderLStickDeadzoneHorizontalLayout"> - <item> - <widget class="QLabel" name="labelLStickDeadzone"> - <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="sliderLStickDeadzone"> - <property name="maximum"> - <number>100</number> - </property> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - </widget> - </item> - <item> - <layout class="QHBoxLayout" name="sliderLStickModifierRangeHorizontalLayout"> - <item> - <widget class="QLabel" name="labelLStickModifierRange"> - <property name="text"> - <string>Modifier Range: 0%</string> - </property> - <property name="alignment"> - <set>Qt::AlignHCenter</set> - </property> - </widget> - </item> - </layout> - </item> - <item> - <widget class="QSlider" name="sliderLStickModifierRange"> - <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="verticalSpacerBottomLeft"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>0</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QGroupBox" name="Dpad"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="title"> - <string>D-Pad</string> - </property> - <property name="flat"> - <bool>false</bool> - </property> - <property name="checkable"> - <bool>false</bool> - </property> - <layout class="QVBoxLayout" name="verticalLayout_5"> - <property name="spacing"> - <number>0</number> - </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>3</number> - </property> - <item> - <widget class="QWidget" name="buttonDpadUpWidget" native="true"> - <layout class="QHBoxLayout" name="horizontalLayout_23"> - <property name="spacing"> - <number>0</number> - </property> - <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> - <spacer name="horizontalSpacerDpadUpLeft"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item alignment="Qt::AlignHCenter"> - <widget class="QGroupBox" name="buttonDpadUpGroup"> - <property name="title"> - <string>Up</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - <layout class="QVBoxLayout" name="buttonDpadUpVerticalLayout"> - <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="buttonDpadUp"> - <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>Up</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <spacer name="horizontalSpacerDpadUpRight"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - </item> - <item> - <layout class="QHBoxLayout" name="buttonDpadLeftRightHorizontalLayout"> - <property name="spacing"> - <number>3</number> - </property> - <item alignment="Qt::AlignHCenter"> - <widget class="QGroupBox" name="buttonDpadLeftGroup"> - <property name="title"> - <string>Left</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - <layout class="QVBoxLayout" name="buttonDpadLeftVerticalLayout"> - <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="buttonDpadLeft"> - <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>Left</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item alignment="Qt::AlignHCenter"> - <widget class="QGroupBox" name="buttonDpadRightGroup"> - <property name="title"> - <string>Right</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - <layout class="QVBoxLayout" name="buttonDpadRightVerticalLayout"> - <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="buttonDpadRight"> - <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>Right</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </item> - <item> - <widget class="QWidget" name="buttonDpadDownWidget" native="true"> - <layout class="QHBoxLayout" name="horizontalLayout_24"> - <property name="spacing"> - <number>0</number> - </property> - <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> - <spacer name="horizontalSpacerDpadDownLeft"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item alignment="Qt::AlignHCenter"> - <widget class="QGroupBox" name="buttonDpadDownGroup"> - <property name="title"> - <string>Down</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - <layout class="QVBoxLayout" name="buttonDpadDownVerticalLayout"> - <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="buttonDpadDown"> - <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>Down</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <spacer name="horizontalSpacerDpadDownRight"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <spacer name="verticalSpacerBottomLeft_2"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>0</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QWidget" name="bottomMiddle" native="true"> - <layout class="QVBoxLayout" stretch="0,0,0"> - <property name="spacing"> - <number>6</number> - </property> - <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="shoulderButtons"> - <property name="spacing"> - <number>3</number> - </property> - <item> - <widget class="QWidget" name="buttonShoulderButtonsSLSRLeft" native="true"> - <layout class="QVBoxLayout" name="buttonShoulderButtonsSLSRLeftVerticalLayout"> - <property name="spacing"> - <number>0</number> - </property> - <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 alignment="Qt::AlignHCenter"> - <widget class="QGroupBox" name="buttonShoulderButtonsSLLeftGroup"> - <property name="title"> - <string>SL</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - <layout class="QVBoxLayout" name="buttonShoulderButtonsSLLeftVerticalLayout"> - <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="buttonSLLeft"> - <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>SL</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item alignment="Qt::AlignHCenter"> - <widget class="QGroupBox" name="buttonShoulderButtonsSRLeftGroup"> - <property name="title"> - <string>SR</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - <layout class="QVBoxLayout" name="buttonShoulderButtonsSRLeftVerticalLayout"> - <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="buttonSRLeft"> - <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>SR</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QWidget" name="horizontalSpacerShoulderButtonsWidget4" native="true"> - <layout class="QHBoxLayout" name="horizontalSpacerShoulderButtonsWidget4Layout"> - <property name="spacing"> - <number>0</number> - </property> - <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> - <spacer name="horizontalSpacerShoulderButtons5"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>0</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QWidget" name="buttonShoulderButtonsLeft" native="true"> - <layout class="QVBoxLayout" name="buttonShoulderButtonsLeftVerticalLayout"> - <property name="spacing"> - <number>0</number> - </property> - <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="QGroupBox" name="buttonShoulderButtonsButtonLGroup"> - <property name="title"> - <string>L</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - <layout class="QVBoxLayout" name="buttonShoulderButtonsLVerticalLayout"> - <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="buttonL"> - <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>L</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QGroupBox" name="buttonShoulderButtonsButtonZLGroup"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Maximum" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="title"> - <string>ZL</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - <layout class="QVBoxLayout" name="buttonShoulderButtonsZLVerticalLayout"> - <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="buttonZL"> - <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>ZL</string> - </property> - </widget> - </item> - <item> - <widget class="QSlider" name="sliderZLThreshold"> - <property name="maximumSize"> - <size> - <width>70</width> - <height>15</height> - </size> - </property> - <property name="maximum"> - <number>100</number> - </property> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QWidget" name="horizontalSpacerShoulderButtonsWidget" native="true"> - <layout class="QHBoxLayout" name="horizontalSpacerShoulderButtonsWidgetLayout"> - <property name="spacing"> - <number>0</number> - </property> - <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> - <spacer name="horizontalSpacerShoulderButtons1"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>0</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QWidget" name="buttonMiscButtonsMinusScreenshot" native="true"> - <layout class="QVBoxLayout" name="buttonMiscButtonsMinusScreenshotVerticalLayout"> - <property name="spacing"> - <number>0</number> - </property> - <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 alignment="Qt::AlignHCenter"> - <widget class="QGroupBox" name="buttonMiscButtonsMinusGroup"> - <property name="title"> - <string>Minus</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - <layout class="QVBoxLayout" name="buttonMiscMinusVerticalLayout"> - <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="buttonMinus"> - <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>Minus</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item alignment="Qt::AlignHCenter"> - <widget class="QGroupBox" name="buttonMiscButtonsScreenshotGroup"> - <property name="title"> - <string>Capture</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - <layout class="QVBoxLayout" name="buttonMiscScrCapVerticalLayout"> - <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="buttonScreenshot"> - <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>Capture</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QWidget" name="buttonMiscButtonsPlusHome" native="true"> - <layout class="QVBoxLayout" name="buttonMiscButtonsPlusHomeVerticalLayout"> - <property name="spacing"> - <number>0</number> - </property> - <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 alignment="Qt::AlignHCenter"> - <widget class="QGroupBox" name="buttonMiscButtonsPlusGroup"> - <property name="title"> - <string>Plus</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - <layout class="QVBoxLayout" name="buttonMiscPlusVerticalLayout"> - <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="buttonPlus"> - <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>Plus</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item alignment="Qt::AlignHCenter"> - <widget class="QGroupBox" name="buttonMiscButtonsHomeGroup"> - <property name="title"> - <string>Home</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - <layout class="QVBoxLayout" name="buttonMiscHomeVerticalLayout"> - <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="buttonHome"> - <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>Home</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QWidget" name="horizontalSpacerShoulderButtonsWidget3" native="true"> - <layout class="QHBoxLayout" name="horizontalSpacerShoulderButtonsWidget3Layout"> - <property name="spacing"> - <number>0</number> - </property> - <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> - <spacer name="horizontalSpacerShoulderButtons2"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>0</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QWidget" name="buttonShoulderButtonsRight" native="true"> - <layout class="QVBoxLayout" name="buttonShoulderButtonsRightVerticalLayout"> - <property name="spacing"> - <number>0</number> - </property> - <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="QGroupBox" name="buttonShoulderButtonsRGroup"> - <property name="title"> - <string>R</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - <layout class="QVBoxLayout" name="buttonShoulderButtonsRVerticalLayout"> - <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="buttonR"> - <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>R</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QGroupBox" name="buttonShoulderButtonsZRGroup"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Maximum" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="title"> - <string>ZR</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - <layout class="QVBoxLayout" name="buttonShoulderButtonsZRVerticalLayout"> - <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="buttonZR"> - <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>ZR</string> - </property> - </widget> - </item> - <item> - <widget class="QSlider" name="sliderZRThreshold"> - <property name="maximumSize"> - <size> - <width>70</width> - <height>15</height> - </size> - </property> - <property name="maximum"> - <number>100</number> - </property> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QWidget" name="horizontalSpacerShoulderButtonsWidget2" native="true"> - <layout class="QHBoxLayout" name="horizontalSpacerShoulderButtonsWidget2Layout"> - <property name="spacing"> - <number>0</number> - </property> - <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> - <spacer name="horizontalSpacerShoulderButtons3"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>0</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QWidget" name="buttonShoulderButtonsSLSRRight" native="true"> - <layout class="QVBoxLayout" name="buttonShoulderButtonsSLSRRightVerticalLayout"> - <property name="spacing"> - <number>0</number> - </property> - <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 alignment="Qt::AlignHCenter"> - <widget class="QGroupBox" name="buttonShoulderButtonsSLRightGroup"> - <property name="title"> - <string>SL</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - <layout class="QVBoxLayout" name="buttonShoulderButtonsSLRightVerticalLayout"> - <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="buttonSLRight"> - <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>SL</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item alignment="Qt::AlignHCenter"> - <widget class="QGroupBox" name="buttonShoulderButtonsSRRightGroup"> - <property name="title"> - <string>SR</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - <layout class="QVBoxLayout" name="buttonShoulderButtonsSRRightVerticalLayout"> - <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="buttonSRRight"> - <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>SR</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </item> - <item> - <widget class="PlayerControlPreview" name="controllerFrame"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Expanding"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="font"> - <font> - <weight>75</weight> - <bold>true</bold> - </font> - </property> - <property name="styleSheet"> - <string notr="true">image: url(:/controller/pro);</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout_4"> - <property name="leftMargin"> - <number>0</number> - </property> - <property name="topMargin"> - <number>0</number> - </property> - <property name="rightMargin"> - <number>0</number> - </property> - <property name="bottomMargin"> - <number>0</number> - </property> - </layout> - </widget> - </item> - <item> - <layout class="QHBoxLayout" name="miscButtons"> - <property name="spacing"> - <number>3</number> - </property> - <property name="topMargin"> - <number>0</number> - </property> - <item> - <spacer name="horizontalSpacerMiscButtons1"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QGroupBox" name="buttonMotionLeftGroup"> - <property name="title"> - <string>Motion 1</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - <layout class="QVBoxLayout" name="buttonDpadLeftVerticalLayout_2"> - <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="buttonMotionLeft"> - <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>Left</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QGroupBox" name="buttonMotionRightGroup"> - <property name="title"> - <string>Motion 2</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - <layout class="QVBoxLayout" name="buttonDpadRightVerticalLayout_2"> - <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="buttonMotionRight"> - <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>Right</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <spacer name="horizontalSpacerMiscButtons4"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QWidget" name="bottomRight" native="true"> - <layout class="QVBoxLayout" name="bottomRightLayout"> - <property name="spacing"> - <number>0</number> - </property> - <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="QGroupBox" name="faceButtons"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="title"> - <string>Face Buttons</string> - </property> - <property name="flat"> - <bool>false</bool> - </property> - <property name="checkable"> - <bool>false</bool> - </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <property name="spacing"> - <number>0</number> - </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>3</number> - </property> - <item> - <widget class="QWidget" name="buttonFaceButtonsBWidget" native="true"> - <layout class="QHBoxLayout" name="horizontalLayout_6"> - <property name="spacing"> - <number>0</number> - </property> - <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> - <spacer name="horizontalSpacerBLeft"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item alignment="Qt::AlignHCenter"> - <widget class="QGroupBox" name="buttonFaceButtonsXGroup"> - <property name="title"> - <string>X</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - <layout class="QVBoxLayout" name="buttonFaceButtonsXVerticalLayout"> - <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="buttonX"> - <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>X</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <spacer name="horizontalSpacerBRight"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - </item> - <item> - <layout class="QHBoxLayout" name="buttonFaceButtonsYAHorizontalLayout"> - <property name="spacing"> - <number>3</number> - </property> - <item alignment="Qt::AlignHCenter"> - <widget class="QGroupBox" name="buttonFaceButtonsYGroup"> - <property name="title"> - <string>Y</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - <layout class="QVBoxLayout" name="buttonFaceButtonsYVerticalLayout"> - <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="buttonY"> - <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>Y</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item alignment="Qt::AlignHCenter"> - <widget class="QGroupBox" name="buttonFaceButtonsAGroup"> - <property name="title"> - <string>A</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - <layout class="QVBoxLayout" name="buttonFaceButtonsAVerticalLayout"> - <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="buttonA"> - <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>A</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </item> - <item> - <widget class="QWidget" name="buttonFaceButtonsXWidget" native="true"> - <layout class="QHBoxLayout" name="horizontalLayout_10"> - <property name="spacing"> - <number>0</number> - </property> - <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> - <spacer name="horizontalSpacerXLeft"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item alignment="Qt::AlignHCenter"> - <widget class="QGroupBox" name="buttonFaceButtonsBWidget_2"> - <property name="title"> - <string>B</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - <layout class="QVBoxLayout" name="buttonFaceButtonsBVerticalLayout"> - <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="buttonB"> - <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>B</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <spacer name="horizontalSpacerXRight"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <spacer name="verticalSpacerBottomRight"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>0</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QGroupBox" name="RStick"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="title"> - <string>Right Stick</string> - </property> - <property name="alignment"> - <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set> - </property> - <property name="flat"> - <bool>false</bool> - </property> - <property name="checkable"> - <bool>false</bool> - </property> - <layout class="QVBoxLayout" name="verticalLayout_2"> - <property name="spacing"> - <number>0</number> - </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> - <widget class="QWidget" name="buttonRStickUpWidget" native="true"> - <property name="minimumSize"> - <size> - <width>0</width> - <height>0</height> - </size> - </property> - <layout class="QHBoxLayout" name="horizontalLayout_9"> - <property name="spacing"> - <number>0</number> - </property> - <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> - <spacer name="horizontalSpacerRStickUpLeft"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item alignment="Qt::AlignHCenter"> - <widget class="QGroupBox" name="buttonRStickUpGroup"> - <property name="title"> - <string>Up</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - <layout class="QVBoxLayout" name="buttonRStickUpVerticalLayout"> - <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="buttonRStickUp"> - <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>Up</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <spacer name="horizontalSpacerRStickUpRight"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - </item> - <item> - <layout class="QHBoxLayout" name="buttonRStickLeftRightHorizontalLayout"> - <property name="spacing"> - <number>3</number> - </property> - <item alignment="Qt::AlignHCenter"> - <widget class="QGroupBox" name="buttonRStickLeftGroup"> - <property name="title"> - <string>Left</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - <layout class="QVBoxLayout" name="buttonRStickLeftVerticalLayout"> - <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="buttonRStickLeft"> - <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>Left</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item alignment="Qt::AlignHCenter"> - <widget class="QGroupBox" name="buttonRStickRightGroup"> - <property name="title"> - <string>Right</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - <layout class="QVBoxLayout" name="buttonRStickRightVerticalLayout"> - <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="buttonRStickRight"> - <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>Right</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </item> - <item> - <widget class="QWidget" name="buttonRStickDownWidget" native="true"> - <layout class="QHBoxLayout" name="horizontalLayout_11"> - <property name="spacing"> - <number>0</number> - </property> - <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> - <spacer name="horizontalSpacerRStickDownLeft"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QGroupBox" name="buttonRStickDownGroup"> - <property name="title"> - <string>Down</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - <layout class="QVBoxLayout" name="buttonRStickDownVerticalLayout"> - <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="buttonRStickDown"> - <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>Down</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <spacer name="horizontalSpacerRStickDownRight"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - </item> - <item> - <layout class="QHBoxLayout" name="buttonRStickPressedModifierHorizontalLayout"> - <property name="spacing"> - <number>3</number> - </property> - <item alignment="Qt::AlignHCenter"> - <widget class="QGroupBox" name="groupRStickPressed"> - <property name="title"> - <string>Pressed</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - <layout class="QVBoxLayout" name="buttonRStickPressedVerticalLayout"> - <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="buttonRStick"> - <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>Pressed</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item alignment="Qt::AlignHCenter"> - <widget class="QGroupBox" name="buttonRStickModGroup"> - <property name="title"> - <string>Modifier</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - <layout class="QVBoxLayout" name="buttonRStickModVerticalLayout"> - <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="buttonRStickMod"> - <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>Modifier</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QGroupBox" name="buttonRStickRangeGroup"> - <property name="title"> - <string>Range</string> - </property> - <layout class="QHBoxLayout" name="buttonRStickRangeGroupHorizontalLayout"> - <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="QSpinBox" name="spinboxRStickRange"> - <property name="minimumSize"> - <size> - <width>68</width> - <height>21</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>68</width> - <height>16777215</height> - </size> - </property> - <property name="suffix"> - <string>%</string> - </property> - <property name="minimum"> - <number>25</number> - </property> - <property name="maximum"> - <number>150</number> - </property> - <property name="value"> - <number>95</number> - </property> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </item> - <item> - <layout class="QVBoxLayout" name="sliderRStickDeadzoneModifierRangeVerticalLayout"> - <property name="spacing"> - <number>3</number> - </property> - <property name="leftMargin"> - <number>0</number> - </property> - <property name="topMargin"> - <number>2</number> - </property> - <property name="rightMargin"> - <number>0</number> - </property> - <property name="bottomMargin"> - <number>3</number> - </property> - <item> - <layout class="QHBoxLayout" name="sliderRStickDeadzoneHorizontalLayout"> - <item> - <widget class="QLabel" name="labelRStickDeadzone"> - <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="sliderRStickDeadzone"> - <property name="maximum"> - <number>100</number> - </property> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - </widget> - </item> - <item> - <layout class="QHBoxLayout" name="sliderRStickModifierRangeHorizontalLayout"> - <item> - <widget class="QLabel" name="labelRStickModifierRange"> - <property name="text"> - <string>Modifier Range: 0%</string> - </property> - <property name="alignment"> - <set>Qt::AlignHCenter</set> - </property> - </widget> - </item> - </layout> - </item> - <item> - <widget class="QSlider" name="sliderRStickModifierRange"> - <property name="maximum"> - <number>100</number> - </property> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - </widget> - </item> - </layout> - </item> - <item> - <widget class="QWidget" name="mousePanningWidget" native="true"> - <layout class="QHBoxLayout" name="mousePanningHorizontalLayout"> - <property name="spacing"> - <number>0</number> - </property> - <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>3</number> - </property> - <item> - <spacer name="mousePanningHorizontalSpacerLeft"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QGroupBox" name="mousePanningGroup"> - <property name="title"> - <string>Mouse panning</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - <layout class="QVBoxLayout" name="mousePanningVerticalLayout"> - <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="mousePanningButton"> - <property name="text"> - <string>Configure</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <spacer name="mousePanningHorizontalSpacerRight"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <spacer name="verticalSpacerBottomRight_2"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>0</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </item> - </layout> - </widget> - <customwidgets> - <customwidget> - <class>PlayerControlPreview</class> - <extends>QFrame</extends> - <header>yuzu/configuration/configure_input_player_widget.h</header> - <container>1</container> - </customwidget> - </customwidgets> - <resources> - <include location="../../../dist/icons/controller/controller.qrc"/> - </resources> - <connections/> -</ui> diff --git a/src/yuzu/configuration/configure_input_player_widget.cpp b/src/yuzu/configuration/configure_input_player_widget.cpp deleted file mode 100644 index b3d9d8006..000000000 --- a/src/yuzu/configuration/configure_input_player_widget.cpp +++ /dev/null @@ -1,3007 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include <algorithm> -#include <QMenu> -#include <QPainter> -#include <QTimer> - -#include "hid_core/frontend/emulated_controller.h" -#include "yuzu/configuration/configure_input_player_widget.h" - -PlayerControlPreview::PlayerControlPreview(QWidget* parent) : QFrame(parent) { - is_controller_set = false; - QTimer* timer = new QTimer(this); - connect(timer, &QTimer::timeout, this, QOverload<>::of(&PlayerControlPreview::UpdateInput)); - - // refresh at 60hz - timer->start(16); -} - -PlayerControlPreview::~PlayerControlPreview() { - UnloadController(); -}; - -void PlayerControlPreview::SetController(Core::HID::EmulatedController* controller_) { - UnloadController(); - is_controller_set = true; - controller = controller_; - Core::HID::ControllerUpdateCallback engine_callback{ - .on_change = [this](Core::HID::ControllerTriggerType type) { ControllerUpdate(type); }, - .is_npad_service = false, - }; - callback_key = controller->SetCallback(engine_callback); - ControllerUpdate(Core::HID::ControllerTriggerType::All); -} - -void PlayerControlPreview::UnloadController() { - if (is_controller_set) { - controller->DeleteCallback(callback_key); - is_controller_set = false; - } -} - -void PlayerControlPreview::BeginMappingButton(std::size_t button_id) { - button_mapping_index = button_id; - mapping_active = true; -} - -void PlayerControlPreview::BeginMappingAnalog(std::size_t stick_id) { - button_mapping_index = Settings::NativeButton::LStick + stick_id; - analog_mapping_index = stick_id; - mapping_active = true; -} - -void PlayerControlPreview::EndMapping() { - button_mapping_index = Settings::NativeButton::BUTTON_NS_END; - analog_mapping_index = Settings::NativeAnalog::NumAnalogs; - mapping_active = false; - blink_counter = 0; - ResetInputs(); -} - -void PlayerControlPreview::UpdateColors() { - if (QIcon::themeName().contains(QStringLiteral("dark")) || - QIcon::themeName().contains(QStringLiteral("midnight"))) { - colors.primary = QColor(204, 204, 204); - colors.button = QColor(35, 38, 41); - colors.button2 = QColor(26, 27, 30); - colors.slider_arrow = QColor(14, 15, 18); - colors.font2 = QColor(255, 255, 255); - colors.indicator = QColor(170, 238, 255); - colors.deadzone = QColor(204, 136, 136); - colors.slider_button = colors.button; - } - - if (QIcon::themeName().contains(QStringLiteral("dark"))) { - colors.outline = QColor(160, 160, 160); - } else if (QIcon::themeName().contains(QStringLiteral("midnight"))) { - colors.outline = QColor(145, 145, 145); - } else { - colors.outline = QColor(0, 0, 0); - colors.primary = QColor(225, 225, 225); - colors.button = QColor(109, 111, 114); - colors.button2 = QColor(77, 80, 84); - colors.slider_arrow = QColor(65, 68, 73); - colors.font2 = QColor(0, 0, 0); - colors.indicator = QColor(0, 0, 200); - colors.deadzone = QColor(170, 0, 0); - colors.slider_button = QColor(153, 149, 149); - } - - // Constant colors - colors.highlight = QColor(170, 0, 0); - colors.highlight2 = QColor(119, 0, 0); - colors.slider = QColor(103, 106, 110); - colors.transparent = QColor(0, 0, 0, 0); - colors.font = QColor(255, 255, 255); - colors.led_on = QColor(255, 255, 0); - colors.led_off = QColor(170, 238, 255); - colors.indicator2 = QColor(59, 165, 93); - colors.charging = QColor(250, 168, 26); - colors.button_turbo = QColor(217, 158, 4); - - colors.left = colors.primary; - colors.right = colors.primary; - - const auto color_left = controller->GetColorsValues()[0].body; - const auto color_right = controller->GetColorsValues()[1].body; - if (color_left != 0 && color_right != 0) { - colors.left = QColor(color_left); - colors.right = QColor(color_right); - } -} - -void PlayerControlPreview::ResetInputs() { - button_values.fill({ - .value = false, - }); - stick_values.fill({ - .x = {.value = 0, .properties = {0, 1, 0}}, - .y = {.value = 0, .properties = {0, 1, 0}}, - }); - trigger_values.fill({ - .analog = {.value = 0, .properties = {0, 1, 0}}, - .pressed = {.value = false}, - }); - update(); -} - -void PlayerControlPreview::ControllerUpdate(Core::HID::ControllerTriggerType type) { - if (type == Core::HID::ControllerTriggerType::All) { - ControllerUpdate(Core::HID::ControllerTriggerType::Color); - ControllerUpdate(Core::HID::ControllerTriggerType::Type); - ControllerUpdate(Core::HID::ControllerTriggerType::Connected); - ControllerUpdate(Core::HID::ControllerTriggerType::Button); - ControllerUpdate(Core::HID::ControllerTriggerType::Stick); - ControllerUpdate(Core::HID::ControllerTriggerType::Trigger); - ControllerUpdate(Core::HID::ControllerTriggerType::Battery); - return; - } - - switch (type) { - case Core::HID::ControllerTriggerType::Connected: - is_connected = true; - led_pattern = controller->GetLedPattern(); - needs_redraw = true; - break; - case Core::HID::ControllerTriggerType::Disconnected: - is_connected = false; - led_pattern.raw = 0; - needs_redraw = true; - break; - case Core::HID::ControllerTriggerType::Type: - controller_type = controller->GetNpadStyleIndex(true); - needs_redraw = true; - break; - case Core::HID::ControllerTriggerType::Color: - UpdateColors(); - needs_redraw = true; - break; - case Core::HID::ControllerTriggerType::Button: - button_values = controller->GetButtonsValues(); - needs_redraw = true; - break; - case Core::HID::ControllerTriggerType::Stick: - using namespace Settings::NativeAnalog; - stick_values = controller->GetSticksValues(); - // Y axis is inverted - stick_values[LStick].y.value = -stick_values[LStick].y.value; - stick_values[LStick].y.raw_value = -stick_values[LStick].y.raw_value; - stick_values[RStick].y.value = -stick_values[RStick].y.value; - stick_values[RStick].y.raw_value = -stick_values[RStick].y.raw_value; - needs_redraw = true; - break; - case Core::HID::ControllerTriggerType::Trigger: - trigger_values = controller->GetTriggersValues(); - needs_redraw = true; - break; - case Core::HID::ControllerTriggerType::Battery: - battery_values = controller->GetBatteryValues(); - needs_redraw = true; - break; - case Core::HID::ControllerTriggerType::Motion: - motion_values = controller->GetMotions(); - needs_redraw = true; - break; - default: - break; - } -} - -void PlayerControlPreview::UpdateInput() { - if (mapping_active) { - - for (std::size_t index = 0; index < button_values.size(); ++index) { - bool blink = index == button_mapping_index; - if (analog_mapping_index == Settings::NativeAnalog::NumAnalogs) { - blink &= blink_counter > 25; - } - if (button_values[index].value != blink) { - needs_redraw = true; - } - button_values[index].value = blink; - } - - for (std::size_t index = 0; index < stick_values.size(); ++index) { - const bool blink_analog = index == analog_mapping_index; - if (blink_analog) { - needs_redraw = true; - stick_values[index].x.value = blink_counter < 25 ? -blink_counter / 25.0f : 0; - stick_values[index].y.value = - blink_counter > 25 ? -(blink_counter - 25) / 25.0f : 0; - } - } - } - if (needs_redraw) { - update(); - } - - if (mapping_active) { - blink_counter = (blink_counter + 1) % 50; - } -} - -void PlayerControlPreview::paintEvent(QPaintEvent* event) { - QFrame::paintEvent(event); - QPainter p(this); - p.setRenderHint(QPainter::Antialiasing); - const QPointF center = rect().center(); - - switch (controller_type) { - case Core::HID::NpadStyleIndex::Handheld: - DrawHandheldController(p, center); - break; - case Core::HID::NpadStyleIndex::JoyconDual: - DrawDualController(p, center); - break; - case Core::HID::NpadStyleIndex::JoyconLeft: - DrawLeftController(p, center); - break; - case Core::HID::NpadStyleIndex::JoyconRight: - DrawRightController(p, center); - break; - case Core::HID::NpadStyleIndex::GameCube: - DrawGCController(p, center); - break; - case Core::HID::NpadStyleIndex::Fullkey: - default: - DrawProController(p, center); - break; - } -} - -void PlayerControlPreview::DrawLeftController(QPainter& p, const QPointF center) { - { - using namespace Settings::NativeButton; - - // Sideview left joystick - DrawJoystickSideview(p, center + QPoint(142, -69), - -stick_values[Settings::NativeAnalog::LStick].y.value, 1.15f, - button_values[LStick]); - - // Topview D-pad buttons - p.setPen(colors.outline); - button_color = colors.button; - DrawRoundButton(p, center + QPoint(-163, -21), button_values[DLeft], 11, 5, Direction::Up); - DrawRoundButton(p, center + QPoint(-117, -21), button_values[DRight], 11, 5, Direction::Up); - - // Topview left joystick - DrawJoystickSideview(p, center + QPointF(-140.5f, -28), - -stick_values[Settings::NativeAnalog::LStick].x.value + 15.0f, 1.15f, - button_values[LStick]); - - // Topview minus button - p.setPen(colors.outline); - button_color = colors.button; - DrawRoundButton(p, center + QPoint(-111, -22), button_values[Minus], 8, 4, Direction::Up, - 1); - - // Left trigger - DrawLeftTriggers(p, center, button_values[L]); - DrawRoundButton(p, center + QPoint(151, -146), button_values[L], 8, 4, Direction::Down); - DrawLeftZTriggers(p, center, button_values[ZL]); - - // Sideview D-pad buttons - DrawRoundButton(p, center + QPoint(135, 14), button_values[DLeft], 5, 11, Direction::Right); - DrawRoundButton(p, center + QPoint(135, 36), button_values[DDown], 5, 11, Direction::Right); - DrawRoundButton(p, center + QPoint(135, -10), button_values[DUp], 5, 11, Direction::Right); - DrawRoundButton(p, center + QPoint(135, 14), button_values[DRight], 5, 11, - Direction::Right); - DrawRoundButton(p, center + QPoint(135, 71), button_values[Screenshot], 3, 8, - Direction::Right, 1); - - // Sideview minus button - DrawRoundButton(p, center + QPoint(135, -118), button_values[Minus], 4, 2.66f, - Direction::Right, 1); - - // Sideview SL and SR buttons - button_color = colors.slider_button; - DrawRoundButton(p, center + QPoint(59, 52), button_values[SRLeft], 5, 12, Direction::Left); - DrawRoundButton(p, center + QPoint(59, -69), button_values[SLLeft], 5, 12, Direction::Left); - - DrawLeftBody(p, center); - - // Left trigger top view - DrawLeftTriggersTopView(p, center, button_values[L]); - DrawLeftZTriggersTopView(p, center, button_values[ZL]); - } - - { - // Draw joysticks - using namespace Settings::NativeAnalog; - DrawJoystick(p, - center + QPointF(9, -69) + - (QPointF(stick_values[LStick].x.value, stick_values[LStick].y.value) * 8), - 1.8f, button_values[Settings::NativeButton::LStick]); - DrawRawJoystick(p, center + QPointF(-140, 90), QPointF(0, 0)); - } - - { - // Draw motion cubes - using namespace Settings::NativeMotion; - p.setPen(colors.outline); - p.setBrush(colors.transparent); - Draw3dCube(p, center + QPointF(-140, 90), - motion_values[Settings::NativeMotion::MotionLeft].euler, 20.0f); - } - - using namespace Settings::NativeButton; - - // D-pad constants - const QPointF dpad_center = center + QPoint(9, 14); - constexpr int dpad_distance = 23; - constexpr int dpad_radius = 11; - constexpr float dpad_arrow_size = 1.2f; - - // D-pad buttons - p.setPen(colors.outline); - button_color = colors.button; - DrawCircleButton(p, dpad_center + QPoint(dpad_distance, 0), button_values[DRight], dpad_radius); - DrawCircleButton(p, dpad_center + QPoint(0, dpad_distance), button_values[DDown], dpad_radius); - DrawCircleButton(p, dpad_center + QPoint(0, -dpad_distance), button_values[DUp], dpad_radius); - DrawCircleButton(p, dpad_center + QPoint(-dpad_distance, 0), button_values[DLeft], dpad_radius); - - // D-pad arrows - p.setPen(colors.font2); - p.setBrush(colors.font2); - DrawArrow(p, dpad_center + QPoint(dpad_distance, 0), Direction::Right, dpad_arrow_size); - DrawArrow(p, dpad_center + QPoint(0, dpad_distance), Direction::Down, dpad_arrow_size); - DrawArrow(p, dpad_center + QPoint(0, -dpad_distance), Direction::Up, dpad_arrow_size); - DrawArrow(p, dpad_center + QPoint(-dpad_distance, 0), Direction::Left, dpad_arrow_size); - - // SR and SL buttons - p.setPen(colors.outline); - button_color = colors.slider_button; - DrawRoundButton(p, center + QPoint(155, 52), button_values[SRLeft], 5.2f, 12, Direction::None, - 4); - DrawRoundButton(p, center + QPoint(155, -69), button_values[SLLeft], 5.2f, 12, Direction::None, - 4); - - // SR and SL text - p.setPen(colors.transparent); - p.setBrush(colors.font2); - DrawSymbol(p, center + QPointF(155, 52), Symbol::SR, 1.0f); - DrawSymbol(p, center + QPointF(155, -69), Symbol::SL, 1.0f); - - // Minus button - button_color = colors.button; - DrawMinusButton(p, center + QPoint(39, -118), button_values[Minus], 16); - - // Screenshot button - DrawRoundButton(p, center + QPoint(26, 71), button_values[Screenshot], 8, 8); - p.setPen(colors.font2); - p.setBrush(colors.font2); - DrawCircle(p, center + QPoint(26, 71), 5); - - // Draw battery - DrawBattery(p, center + QPoint(-160, -140), - battery_values[Core::HID::EmulatedDeviceIndex::LeftIndex]); -} - -void PlayerControlPreview::DrawRightController(QPainter& p, const QPointF center) { - { - using namespace Settings::NativeButton; - - // Sideview right joystick - DrawJoystickSideview(p, center + QPoint(173 - 315, 11), - stick_values[Settings::NativeAnalog::RStick].y.value + 10.0f, 1.15f, - button_values[Settings::NativeButton::RStick]); - - // Topview right joystick - DrawJoystickSideview(p, center + QPointF(140, -28), - -stick_values[Settings::NativeAnalog::RStick].x.value + 15.0f, 1.15f, - button_values[RStick]); - - // Topview face buttons - p.setPen(colors.outline); - button_color = colors.button; - DrawRoundButton(p, center + QPoint(163, -21), button_values[A], 11, 5, Direction::Up); - DrawRoundButton(p, center + QPoint(140, -21), button_values[B], 11, 5, Direction::Up); - DrawRoundButton(p, center + QPoint(140, -21), button_values[X], 11, 5, Direction::Up); - DrawRoundButton(p, center + QPoint(117, -21), button_values[Y], 11, 5, Direction::Up); - - // Topview plus button - p.setPen(colors.outline); - button_color = colors.button; - DrawRoundButton(p, center + QPoint(111, -22), button_values[Plus], 8, 4, Direction::Up, 1); - DrawRoundButton(p, center + QPoint(111, -22), button_values[Plus], 2.66f, 4, Direction::Up, - 1); - - // Right trigger - p.setPen(colors.outline); - button_color = colors.button; - DrawRightTriggers(p, center, button_values[R]); - DrawRoundButton(p, center + QPoint(-151, -146), button_values[R], 8, 4, Direction::Down); - DrawRightZTriggers(p, center, button_values[ZR]); - - // Sideview face buttons - DrawRoundButton(p, center + QPoint(-135, -73), button_values[A], 5, 11, Direction::Left); - DrawRoundButton(p, center + QPoint(-135, -50), button_values[B], 5, 11, Direction::Left); - DrawRoundButton(p, center + QPoint(-135, -95), button_values[X], 5, 11, Direction::Left); - DrawRoundButton(p, center + QPoint(-135, -73), button_values[Y], 5, 11, Direction::Left); - - // Sideview home and plus button - DrawRoundButton(p, center + QPoint(-135, 66), button_values[Home], 3, 12, Direction::Left); - DrawRoundButton(p, center + QPoint(-135, -118), button_values[Plus], 4, 8, Direction::Left, - 1); - DrawRoundButton(p, center + QPoint(-135, -118), button_values[Plus], 4, 2.66f, - Direction::Left, 1); - - // Sideview SL and SR buttons - button_color = colors.slider_button; - DrawRoundButton(p, center + QPoint(-59, 52), button_values[SLRight], 5, 11, - Direction::Right); - DrawRoundButton(p, center + QPoint(-59, -69), button_values[SRRight], 5, 11, - Direction::Right); - - DrawRightBody(p, center); - - // Right trigger top view - DrawRightTriggersTopView(p, center, button_values[R]); - DrawRightZTriggersTopView(p, center, button_values[ZR]); - } - - { - // Draw joysticks - using namespace Settings::NativeAnalog; - DrawJoystick(p, - center + QPointF(-9, 11) + - (QPointF(stick_values[RStick].x.value, stick_values[RStick].y.value) * 8), - 1.8f, button_values[Settings::NativeButton::RStick]); - DrawRawJoystick(p, QPointF(0, 0), center + QPointF(140, 90)); - } - - { - // Draw motion cubes - using namespace Settings::NativeMotion; - p.setPen(colors.outline); - p.setBrush(colors.transparent); - Draw3dCube(p, center + QPointF(140, 90), - motion_values[Settings::NativeMotion::MotionRight].euler, 20.0f); - } - - using namespace Settings::NativeButton; - - // Face buttons constants - const QPointF face_center = center + QPoint(-9, -73); - constexpr int face_distance = 23; - constexpr int face_radius = 11; - constexpr float text_size = 1.1f; - - // Face buttons - p.setPen(colors.outline); - button_color = colors.button; - DrawCircleButton(p, face_center + QPoint(face_distance, 0), button_values[A], face_radius); - DrawCircleButton(p, face_center + QPoint(0, face_distance), button_values[B], face_radius); - DrawCircleButton(p, face_center + QPoint(0, -face_distance), button_values[X], face_radius); - DrawCircleButton(p, face_center + QPoint(-face_distance, 0), button_values[Y], face_radius); - - // Face buttons text - p.setPen(colors.transparent); - p.setBrush(colors.font); - DrawSymbol(p, face_center + QPoint(face_distance, 0), Symbol::A, text_size); - DrawSymbol(p, face_center + QPoint(0, face_distance), Symbol::B, text_size); - DrawSymbol(p, face_center + QPoint(0, -face_distance), Symbol::X, text_size); - DrawSymbol(p, face_center + QPoint(-face_distance, 1), Symbol::Y, text_size); - - // SR and SL buttons - p.setPen(colors.outline); - button_color = colors.slider_button; - DrawRoundButton(p, center + QPoint(-155, 52), button_values[SLRight], 5, 12, Direction::None, - 4.0f); - DrawRoundButton(p, center + QPoint(-155, -69), button_values[SRRight], 5, 12, Direction::None, - 4.0f); - - // SR and SL text - p.setPen(colors.transparent); - p.setBrush(colors.font2); - p.rotate(-180); - DrawSymbol(p, QPointF(-center.x(), -center.y()) + QPointF(155, 69), Symbol::SR, 1.0f); - DrawSymbol(p, QPointF(-center.x(), -center.y()) + QPointF(155, -52), Symbol::SL, 1.0f); - p.rotate(180); - - // Plus Button - DrawPlusButton(p, center + QPoint(-40, -118), button_values[Plus], 16); - - // Home Button - p.setPen(colors.outline); - button_color = colors.slider_button; - DrawCircleButton(p, center + QPoint(-26, 66), button_values[Home], 12); - button_color = colors.button; - DrawCircleButton(p, center + QPoint(-26, 66), button_values[Home], 9); - p.setPen(colors.transparent); - p.setBrush(colors.font2); - DrawSymbol(p, center + QPoint(-26, 66), Symbol::House, 5); - - // Draw battery - DrawBattery(p, center + QPoint(120, -140), - battery_values[Core::HID::EmulatedDeviceIndex::RightIndex]); -} - -void PlayerControlPreview::DrawDualController(QPainter& p, const QPointF center) { - { - using namespace Settings::NativeButton; - - // Left/Right trigger - DrawDualTriggers(p, center, button_values[L], button_values[R]); - - // Topview right joystick - DrawJoystickSideview(p, center + QPointF(180, -78), - -stick_values[Settings::NativeAnalog::RStick].x.value + 15.0f, 1, - button_values[RStick]); - - // Topview face buttons - p.setPen(colors.outline); - button_color = colors.button; - DrawRoundButton(p, center + QPoint(200, -71), button_values[A], 10, 5, Direction::Up); - DrawRoundButton(p, center + QPoint(180, -71), button_values[B], 10, 5, Direction::Up); - DrawRoundButton(p, center + QPoint(180, -71), button_values[X], 10, 5, Direction::Up); - DrawRoundButton(p, center + QPoint(160, -71), button_values[Y], 10, 5, Direction::Up); - - // Topview plus button - p.setPen(colors.outline); - button_color = colors.button; - DrawRoundButton(p, center + QPoint(154, -72), button_values[Plus], 7, 4, Direction::Up, 1); - DrawRoundButton(p, center + QPoint(154, -72), button_values[Plus], 2.33f, 4, Direction::Up, - 1); - - // Topview D-pad buttons - p.setPen(colors.outline); - button_color = colors.button; - DrawRoundButton(p, center + QPoint(-200, -71), button_values[DLeft], 10, 5, Direction::Up); - DrawRoundButton(p, center + QPoint(-160, -71), button_values[DRight], 10, 5, Direction::Up); - - // Topview left joystick - DrawJoystickSideview(p, center + QPointF(-180.5f, -78), - -stick_values[Settings::NativeAnalog::LStick].x.value + 15.0f, 1, - button_values[LStick]); - - // Topview minus button - p.setPen(colors.outline); - button_color = colors.button; - DrawRoundButton(p, center + QPoint(-154, -72), button_values[Minus], 7, 4, Direction::Up, - 1); - - // Left SR and SL sideview buttons - button_color = colors.slider_button; - DrawRoundButton(p, center + QPoint(-20, -62), button_values[SLLeft], 4, 11, - Direction::Left); - DrawRoundButton(p, center + QPoint(-20, 47), button_values[SRLeft], 4, 11, Direction::Left); - - // Right SR and SL sideview buttons - button_color = colors.slider_button; - DrawRoundButton(p, center + QPoint(20, 47), button_values[SLRight], 4, 11, - Direction::Right); - DrawRoundButton(p, center + QPoint(20, -62), button_values[SRRight], 4, 11, - Direction::Right); - - DrawDualBody(p, center); - - // Right trigger top view - DrawDualTriggersTopView(p, center, button_values[L], button_values[R]); - DrawDualZTriggersTopView(p, center, button_values[ZL], button_values[ZR]); - } - - { - // Draw joysticks - using namespace Settings::NativeAnalog; - const auto l_stick = QPointF(stick_values[LStick].x.value, stick_values[LStick].y.value); - const auto l_button = button_values[Settings::NativeButton::LStick]; - const auto r_stick = QPointF(stick_values[RStick].x.value, stick_values[RStick].y.value); - const auto r_button = button_values[Settings::NativeButton::RStick]; - - DrawJoystick(p, center + QPointF(-65, -65) + (l_stick * 7), 1.62f, l_button); - DrawJoystick(p, center + QPointF(65, 12) + (r_stick * 7), 1.62f, r_button); - DrawRawJoystick(p, center + QPointF(-180, 90), center + QPointF(180, 90)); - } - - { - // Draw motion cubes - using namespace Settings::NativeMotion; - p.setPen(colors.outline); - p.setBrush(colors.transparent); - Draw3dCube(p, center + QPointF(-180, 90), - motion_values[Settings::NativeMotion::MotionLeft].euler, 20.0f); - Draw3dCube(p, center + QPointF(180, 90), - motion_values[Settings::NativeMotion::MotionRight].euler, 20.0f); - } - - using namespace Settings::NativeButton; - - // Face buttons constants - const QPointF face_center = center + QPoint(65, -65); - constexpr int face_distance = 20; - constexpr int face_radius = 10; - constexpr float text_size = 1.0f; - - // Face buttons - p.setPen(colors.outline); - button_color = colors.button; - DrawCircleButton(p, face_center + QPoint(face_distance, 0), button_values[A], face_radius); - DrawCircleButton(p, face_center + QPoint(0, face_distance), button_values[B], face_radius); - DrawCircleButton(p, face_center + QPoint(0, -face_distance), button_values[X], face_radius); - DrawCircleButton(p, face_center + QPoint(-face_distance, 0), button_values[Y], face_radius); - - // Face buttons text - p.setPen(colors.transparent); - p.setBrush(colors.font); - DrawSymbol(p, face_center + QPoint(face_distance, 0), Symbol::A, text_size); - DrawSymbol(p, face_center + QPoint(0, face_distance), Symbol::B, text_size); - DrawSymbol(p, face_center + QPoint(0, -face_distance), Symbol::X, text_size); - DrawSymbol(p, face_center + QPoint(-face_distance, 1), Symbol::Y, text_size); - - // D-pad constants - const QPointF dpad_center = center + QPoint(-65, 12); - constexpr int dpad_distance = 20; - constexpr int dpad_radius = 10; - constexpr float dpad_arrow_size = 1.1f; - - // D-pad buttons - p.setPen(colors.outline); - button_color = colors.button; - DrawCircleButton(p, dpad_center + QPoint(dpad_distance, 0), button_values[DRight], dpad_radius); - DrawCircleButton(p, dpad_center + QPoint(0, dpad_distance), button_values[DDown], dpad_radius); - DrawCircleButton(p, dpad_center + QPoint(0, -dpad_distance), button_values[DUp], dpad_radius); - DrawCircleButton(p, dpad_center + QPoint(-dpad_distance, 0), button_values[DLeft], dpad_radius); - - // D-pad arrows - p.setPen(colors.font2); - p.setBrush(colors.font2); - DrawArrow(p, dpad_center + QPoint(dpad_distance, 0), Direction::Right, dpad_arrow_size); - DrawArrow(p, dpad_center + QPoint(0, dpad_distance), Direction::Down, dpad_arrow_size); - DrawArrow(p, dpad_center + QPoint(0, -dpad_distance), Direction::Up, dpad_arrow_size); - DrawArrow(p, dpad_center + QPoint(-dpad_distance, 0), Direction::Left, dpad_arrow_size); - - // Minus and Plus button - button_color = colors.button; - DrawMinusButton(p, center + QPoint(-39, -106), button_values[Minus], 14); - DrawPlusButton(p, center + QPoint(39, -106), button_values[Plus], 14); - - // Screenshot button - p.setPen(colors.outline); - DrawRoundButton(p, center + QPoint(-52, 63), button_values[Screenshot], 8, 8); - p.setPen(colors.font2); - p.setBrush(colors.font2); - DrawCircle(p, center + QPoint(-52, 63), 5); - - // Home Button - p.setPen(colors.outline); - button_color = colors.slider_button; - DrawCircleButton(p, center + QPoint(50, 60), button_values[Home], 11); - button_color = colors.button; - DrawCircleButton(p, center + QPoint(50, 60), button_values[Home], 8.5f); - p.setPen(colors.transparent); - p.setBrush(colors.font2); - DrawSymbol(p, center + QPoint(50, 60), Symbol::House, 4.2f); - - // Draw battery - DrawBattery(p, center + QPoint(-200, -10), - battery_values[Core::HID::EmulatedDeviceIndex::LeftIndex]); - DrawBattery(p, center + QPoint(160, -10), - battery_values[Core::HID::EmulatedDeviceIndex::RightIndex]); -} - -void PlayerControlPreview::DrawHandheldController(QPainter& p, const QPointF center) { - DrawHandheldTriggers(p, center, button_values[Settings::NativeButton::L], - button_values[Settings::NativeButton::R]); - DrawHandheldBody(p, center); - { - // Draw joysticks - using namespace Settings::NativeAnalog; - const auto l_stick = QPointF(stick_values[LStick].x.value, stick_values[LStick].y.value); - const auto l_button = button_values[Settings::NativeButton::LStick]; - const auto r_stick = QPointF(stick_values[RStick].x.value, stick_values[RStick].y.value); - const auto r_button = button_values[Settings::NativeButton::RStick]; - - DrawJoystick(p, center + QPointF(-171, -41) + (l_stick * 4), 1.0f, l_button); - DrawJoystick(p, center + QPointF(171, 8) + (r_stick * 4), 1.0f, r_button); - DrawRawJoystick(p, center + QPointF(-50, 0), center + QPointF(50, 0)); - } - - { - // Draw motion cubes - using namespace Settings::NativeMotion; - p.setPen(colors.outline); - p.setBrush(colors.transparent); - Draw3dCube(p, center + QPointF(0, -115), - motion_values[Settings::NativeMotion::MotionLeft].euler, 15.0f); - } - - using namespace Settings::NativeButton; - - // Face buttons constants - const QPointF face_center = center + QPoint(171, -41); - constexpr float face_distance = 12.8f; - constexpr float face_radius = 6.4f; - constexpr float text_size = 0.6f; - - // Face buttons - p.setPen(colors.outline); - button_color = colors.button; - DrawCircleButton(p, face_center + QPointF(face_distance, 0), button_values[A], face_radius); - DrawCircleButton(p, face_center + QPointF(0, face_distance), button_values[B], face_radius); - DrawCircleButton(p, face_center + QPointF(0, -face_distance), button_values[X], face_radius); - DrawCircleButton(p, face_center + QPointF(-face_distance, 0), button_values[Y], face_radius); - - // Face buttons text - p.setPen(colors.transparent); - p.setBrush(colors.font); - DrawSymbol(p, face_center + QPointF(face_distance, 0), Symbol::A, text_size); - DrawSymbol(p, face_center + QPointF(0, face_distance), Symbol::B, text_size); - DrawSymbol(p, face_center + QPointF(0, -face_distance), Symbol::X, text_size); - DrawSymbol(p, face_center + QPointF(-face_distance, 1), Symbol::Y, text_size); - - // D-pad constants - const QPointF dpad_center = center + QPoint(-171, 8); - constexpr float dpad_distance = 12.8f; - constexpr float dpad_radius = 6.4f; - constexpr float dpad_arrow_size = 0.68f; - - // D-pad buttons - p.setPen(colors.outline); - button_color = colors.button; - DrawCircleButton(p, dpad_center + QPointF(dpad_distance, 0), button_values[DRight], - dpad_radius); - DrawCircleButton(p, dpad_center + QPointF(0, dpad_distance), button_values[DDown], dpad_radius); - DrawCircleButton(p, dpad_center + QPointF(0, -dpad_distance), button_values[DUp], dpad_radius); - DrawCircleButton(p, dpad_center + QPointF(-dpad_distance, 0), button_values[DLeft], - dpad_radius); - - // D-pad arrows - p.setPen(colors.font2); - p.setBrush(colors.font2); - DrawArrow(p, dpad_center + QPointF(dpad_distance, 0), Direction::Right, dpad_arrow_size); - DrawArrow(p, dpad_center + QPointF(0, dpad_distance), Direction::Down, dpad_arrow_size); - DrawArrow(p, dpad_center + QPointF(0, -dpad_distance), Direction::Up, dpad_arrow_size); - DrawArrow(p, dpad_center + QPointF(-dpad_distance, 0), Direction::Left, dpad_arrow_size); - - // ZL and ZR buttons - p.setPen(colors.outline); - DrawTriggerButton(p, center + QPoint(-210, -120), Direction::Left, button_values[ZL]); - DrawTriggerButton(p, center + QPoint(210, -120), Direction::Right, button_values[ZR]); - p.setPen(colors.transparent); - p.setBrush(colors.font); - DrawSymbol(p, center + QPoint(-210, -120), Symbol::ZL, 1.5f); - DrawSymbol(p, center + QPoint(210, -120), Symbol::ZR, 1.5f); - - // Minus and Plus button - p.setPen(colors.outline); - button_color = colors.button; - DrawMinusButton(p, center + QPoint(-155, -67), button_values[Minus], 8); - DrawPlusButton(p, center + QPoint(155, -67), button_values[Plus], 8); - - // Screenshot button - p.setPen(colors.outline); - DrawRoundButton(p, center + QPoint(-162, 39), button_values[Screenshot], 5, 5); - p.setPen(colors.font2); - p.setBrush(colors.font2); - DrawCircle(p, center + QPoint(-162, 39), 3); - - // Home Button - p.setPen(colors.outline); - button_color = colors.slider_button; - DrawCircleButton(p, center + QPoint(161, 37), button_values[Home], 7); - button_color = colors.button; - DrawCircleButton(p, center + QPoint(161, 37), button_values[Home], 5); - p.setPen(colors.transparent); - p.setBrush(colors.font2); - DrawSymbol(p, center + QPoint(161, 37), Symbol::House, 2.75f); - - // Draw battery - DrawBattery(p, center + QPoint(-188, 95), - battery_values[Core::HID::EmulatedDeviceIndex::LeftIndex]); - DrawBattery(p, center + QPoint(150, 95), - battery_values[Core::HID::EmulatedDeviceIndex::RightIndex]); -} - -void PlayerControlPreview::DrawProController(QPainter& p, const QPointF center) { - DrawProTriggers(p, center, button_values[Settings::NativeButton::L], - button_values[Settings::NativeButton::R]); - DrawProBody(p, center); - { - // Draw joysticks - using namespace Settings::NativeAnalog; - const auto l_stick = QPointF(stick_values[LStick].x.value, stick_values[LStick].y.value); - const auto r_stick = QPointF(stick_values[RStick].x.value, stick_values[RStick].y.value); - DrawProJoystick(p, center + QPointF(-111, -55), l_stick, 11, - button_values[Settings::NativeButton::LStick]); - DrawProJoystick(p, center + QPointF(51, 0), r_stick, 11, - button_values[Settings::NativeButton::RStick]); - DrawRawJoystick(p, center + QPointF(-50, 105), center + QPointF(50, 105)); - } - - { - // Draw motion cubes - using namespace Settings::NativeMotion; - p.setPen(colors.button); - p.setBrush(colors.transparent); - Draw3dCube(p, center + QPointF(0, -100), - motion_values[Settings::NativeMotion::MotionLeft].euler, 15.0f); - } - - using namespace Settings::NativeButton; - - // Face buttons constants - const QPointF face_center = center + QPoint(105, -56); - constexpr int face_distance = 31; - constexpr int face_radius = 15; - constexpr float text_size = 1.5f; - - // Face buttons - p.setPen(colors.outline); - button_color = colors.button; - DrawCircleButton(p, face_center + QPoint(face_distance, 0), button_values[A], face_radius); - DrawCircleButton(p, face_center + QPoint(0, face_distance), button_values[B], face_radius); - DrawCircleButton(p, face_center + QPoint(0, -face_distance), button_values[X], face_radius); - DrawCircleButton(p, face_center + QPoint(-face_distance, 0), button_values[Y], face_radius); - - // Face buttons text - p.setPen(colors.transparent); - p.setBrush(colors.font); - DrawSymbol(p, face_center + QPoint(face_distance, 0), Symbol::A, text_size); - DrawSymbol(p, face_center + QPoint(0, face_distance), Symbol::B, text_size); - DrawSymbol(p, face_center + QPoint(0, -face_distance), Symbol::X, text_size); - DrawSymbol(p, face_center + QPoint(-face_distance, 1), Symbol::Y, text_size); - - // D-pad buttons - const QPointF dpad_position = center + QPoint(-61, 0); - DrawArrowButton(p, dpad_position, Direction::Up, button_values[DUp]); - DrawArrowButton(p, dpad_position, Direction::Left, button_values[DLeft]); - DrawArrowButton(p, dpad_position, Direction::Right, button_values[DRight]); - DrawArrowButton(p, dpad_position, Direction::Down, button_values[DDown]); - DrawArrowButtonOutline(p, dpad_position); - - // ZL and ZR buttons - p.setPen(colors.outline); - DrawTriggerButton(p, center + QPoint(-210, -120), Direction::Left, button_values[ZL]); - DrawTriggerButton(p, center + QPoint(210, -120), Direction::Right, button_values[ZR]); - p.setPen(colors.transparent); - p.setBrush(colors.font); - DrawSymbol(p, center + QPoint(-210, -120), Symbol::ZL, 1.5f); - DrawSymbol(p, center + QPoint(210, -120), Symbol::ZR, 1.5f); - - // Minus and Plus buttons - p.setPen(colors.outline); - DrawCircleButton(p, center + QPoint(-50, -86), button_values[Minus], 9); - DrawCircleButton(p, center + QPoint(50, -86), button_values[Plus], 9); - - // Minus and Plus symbols - p.setPen(colors.font2); - p.setBrush(colors.font2); - DrawRectangle(p, center + QPoint(-50, -86), 9, 1.5f); - DrawRectangle(p, center + QPoint(50, -86), 9, 1.5f); - DrawRectangle(p, center + QPoint(50, -86), 1.5f, 9); - - // Screenshot button - p.setPen(colors.outline); - DrawRoundButton(p, center + QPoint(-29, -56), button_values[Screenshot], 7, 7); - p.setPen(colors.font2); - p.setBrush(colors.font2); - DrawCircle(p, center + QPoint(-29, -56), 4.5f); - - // Home Button - p.setPen(colors.outline); - button_color = colors.slider_button; - DrawCircleButton(p, center + QPoint(29, -56), button_values[Home], 10.0f); - button_color = colors.button; - DrawCircleButton(p, center + QPoint(29, -56), button_values[Home], 7.1f); - p.setPen(colors.transparent); - p.setBrush(colors.font2); - DrawSymbol(p, center + QPoint(29, -56), Symbol::House, 3.9f); - - // Draw battery - DrawBattery(p, center + QPoint(-20, -160), - battery_values[Core::HID::EmulatedDeviceIndex::LeftIndex]); -} - -void PlayerControlPreview::DrawGCController(QPainter& p, const QPointF center) { - DrawGCTriggers(p, center, trigger_values[0], trigger_values[1]); - DrawGCButtonZ(p, center, button_values[Settings::NativeButton::R]); - DrawGCBody(p, center); - { - // Draw joysticks - using namespace Settings::NativeAnalog; - const auto l_stick = QPointF(stick_values[LStick].x.value, stick_values[LStick].y.value); - const auto r_stick = QPointF(stick_values[RStick].x.value, stick_values[RStick].y.value); - DrawGCJoystick(p, center + QPointF(-111, -44) + (l_stick * 10), {}); - button_color = colors.button2; - DrawCircleButton(p, center + QPointF(61, 37) + (r_stick * 9.5f), {}, 15); - p.setPen(colors.transparent); - p.setBrush(colors.font); - DrawSymbol(p, center + QPointF(61, 37) + (r_stick * 9.5f), Symbol::C, 1.0f); - DrawRawJoystick(p, center + QPointF(-198, -125), center + QPointF(198, -125)); - } - - using namespace Settings::NativeButton; - - // Face buttons constants - constexpr float text_size = 1.1f; - - // Face buttons - p.setPen(colors.outline); - button_color = colors.button; - DrawCircleButton(p, center + QPoint(111, -44), button_values[A], 21); - DrawCircleButton(p, center + QPoint(70, -23), button_values[B], 13); - DrawGCButtonX(p, center, button_values[Settings::NativeButton::X]); - DrawGCButtonY(p, center, button_values[Settings::NativeButton::Y]); - - // Face buttons text - p.setPen(colors.transparent); - p.setBrush(colors.font); - DrawSymbol(p, center + QPoint(111, -44), Symbol::A, 1.5f); - DrawSymbol(p, center + QPoint(70, -23), Symbol::B, text_size); - DrawSymbol(p, center + QPoint(151, -53), Symbol::X, text_size); - DrawSymbol(p, center + QPoint(100, -83), Symbol::Y, text_size); - - // D-pad buttons - const QPointF dpad_position = center + QPoint(-61, 37); - const float dpad_size = 0.8f; - DrawArrowButton(p, dpad_position, Direction::Up, button_values[DUp], dpad_size); - DrawArrowButton(p, dpad_position, Direction::Left, button_values[DLeft], dpad_size); - DrawArrowButton(p, dpad_position, Direction::Right, button_values[DRight], dpad_size); - DrawArrowButton(p, dpad_position, Direction::Down, button_values[DDown], dpad_size); - DrawArrowButtonOutline(p, dpad_position, dpad_size); - - // Minus and Plus buttons - p.setPen(colors.outline); - DrawCircleButton(p, center + QPoint(0, -44), button_values[Plus], 8); - - // Draw battery - DrawBattery(p, center + QPoint(-20, 110), - battery_values[Core::HID::EmulatedDeviceIndex::LeftIndex]); -} - -constexpr std::array<float, 13 * 2> symbol_a = { - -1.085f, -5.2f, 1.085f, -5.2f, 5.085f, 5.0f, 2.785f, 5.0f, 1.785f, - 2.65f, -1.785f, 2.65f, -2.785f, 5.0f, -5.085f, 5.0f, -1.4f, 1.0f, - 0.0f, -2.8f, 1.4f, 1.0f, -1.4f, 1.0f, -5.085f, 5.0f, -}; -constexpr std::array<float, 134 * 2> symbol_b = { - -4.0f, 0.0f, -4.0f, 0.0f, -4.0f, -0.1f, -3.8f, -5.1f, 1.8f, -5.0f, 2.3f, -4.9f, 2.6f, - -4.8f, 2.8f, -4.7f, 2.9f, -4.6f, 3.1f, -4.5f, 3.2f, -4.4f, 3.4f, -4.3f, 3.4f, -4.2f, - 3.5f, -4.1f, 3.7f, -4.0f, 3.7f, -3.9f, 3.8f, -3.8f, 3.8f, -3.7f, 3.9f, -3.6f, 3.9f, - -3.5f, 4.0f, -3.4f, 4.0f, -3.3f, 4.1f, -3.1f, 4.1f, -3.0f, 4.0f, -2.0f, 4.0f, -1.9f, - 3.9f, -1.7f, 3.9f, -1.6f, 3.8f, -1.5f, 3.8f, -1.4f, 3.7f, -1.3f, 3.7f, -1.2f, 3.6f, - -1.1f, 3.6f, -1.0f, 3.5f, -0.9f, 3.3f, -0.8f, 3.3f, -0.7f, 3.2f, -0.6f, 3.0f, -0.5f, - 2.9f, -0.4f, 2.7f, -0.3f, 2.9f, -0.2f, 3.2f, -0.1f, 3.3f, 0.0f, 3.5f, 0.1f, 3.6f, - 0.2f, 3.8f, 0.3f, 3.9f, 0.4f, 4.0f, 0.6f, 4.1f, 0.7f, 4.3f, 0.8f, 4.3f, 0.9f, - 4.4f, 1.0f, 4.4f, 1.1f, 4.5f, 1.3f, 4.5f, 1.4f, 4.6f, 1.6f, 4.6f, 1.7f, 4.5f, - 2.8f, 4.5f, 2.9f, 4.4f, 3.1f, 4.4f, 3.2f, 4.3f, 3.4f, 4.3f, 3.5f, 4.2f, 3.6f, - 4.2f, 3.7f, 4.1f, 3.8f, 4.1f, 3.9f, 4.0f, 4.0f, 3.9f, 4.2f, 3.8f, 4.3f, 3.6f, - 4.4f, 3.6f, 4.5f, 3.4f, 4.6f, 3.3f, 4.7f, 3.1f, 4.8f, 2.8f, 4.9f, 2.6f, 5.0f, - 2.1f, 5.1f, -4.0f, 5.0f, -4.0f, 4.9f, - - -4.0f, 0.0f, 1.1f, 3.4f, 1.1f, 3.4f, 1.5f, 3.3f, 1.8f, 3.2f, 2.0f, 3.1f, 2.1f, - 3.0f, 2.3f, 2.9f, 2.3f, 2.8f, 2.4f, 2.7f, 2.4f, 2.6f, 2.5f, 2.3f, 2.5f, 2.2f, - 2.4f, 1.7f, 2.4f, 1.6f, 2.3f, 1.4f, 2.3f, 1.3f, 2.2f, 1.2f, 2.2f, 1.1f, 2.1f, - 1.0f, 1.9f, 0.9f, 1.6f, 0.8f, 1.4f, 0.7f, -1.9f, 0.6f, -1.9f, 0.7f, -1.8f, 3.4f, - 1.1f, 3.4f, -4.0f, 0.0f, - - 0.3f, -1.1f, 0.3f, -1.1f, 1.3f, -1.2f, 1.5f, -1.3f, 1.8f, -1.4f, 1.8f, -1.5f, 1.9f, - -1.6f, 2.0f, -1.8f, 2.0f, -1.9f, 2.1f, -2.0f, 2.1f, -2.1f, 2.0f, -2.7f, 2.0f, -2.8f, - 1.9f, -2.9f, 1.9f, -3.0f, 1.8f, -3.1f, 1.6f, -3.2f, 1.6f, -3.3f, 1.3f, -3.4f, -1.9f, - -3.3f, -1.9f, -3.2f, -1.8f, -1.0f, 0.2f, -1.1f, 0.3f, -1.1f, -4.0f, 0.0f, -}; - -constexpr std::array<float, 9 * 2> symbol_y = { - -4.79f, -4.9f, -2.44f, -4.9f, 0.0f, -0.9f, 2.44f, -4.9f, 4.79f, - -4.9f, 1.05f, 1.0f, 1.05f, 5.31f, -1.05f, 5.31f, -1.05f, 1.0f, - -}; - -constexpr std::array<float, 12 * 2> symbol_x = { - -4.4f, -5.0f, -2.0f, -5.0f, 0.0f, -1.7f, 2.0f, -5.0f, 4.4f, -5.0f, 1.2f, 0.0f, - 4.4f, 5.0f, 2.0f, 5.0f, 0.0f, 1.7f, -2.0f, 5.0f, -4.4f, 5.0f, -1.2f, 0.0f, - -}; - -constexpr std::array<float, 7 * 2> symbol_l = { - 2.4f, -3.23f, 2.4f, 2.1f, 5.43f, 2.1f, 5.43f, 3.22f, 0.98f, 3.22f, 0.98f, -3.23f, 2.4f, -3.23f, -}; - -constexpr std::array<float, 98 * 2> symbol_r = { - 1.0f, 0.0f, 1.0f, -0.1f, 1.1f, -3.3f, 4.3f, -3.2f, 5.1f, -3.1f, 5.4f, -3.0f, 5.6f, -2.9f, - 5.7f, -2.8f, 5.9f, -2.7f, 5.9f, -2.6f, 6.0f, -2.5f, 6.1f, -2.3f, 6.2f, -2.2f, 6.2f, -2.1f, - 6.3f, -2.0f, 6.3f, -1.9f, 6.2f, -0.8f, 6.2f, -0.7f, 6.1f, -0.6f, 6.1f, -0.5f, 6.0f, -0.4f, - 6.0f, -0.3f, 5.9f, -0.2f, 5.7f, -0.1f, 5.7f, 0.0f, 5.6f, 0.1f, 5.4f, 0.2f, 5.1f, 0.3f, - 4.7f, 0.4f, 4.7f, 0.5f, 4.9f, 0.6f, 5.0f, 0.7f, 5.2f, 0.8f, 5.2f, 0.9f, 5.3f, 1.0f, - 5.5f, 1.1f, 5.5f, 1.2f, 5.6f, 1.3f, 5.7f, 1.5f, 5.8f, 1.6f, 5.9f, 1.8f, 6.0f, 1.9f, - 6.1f, 2.1f, 6.2f, 2.2f, 6.2f, 2.3f, 6.3f, 2.4f, 6.4f, 2.6f, 6.5f, 2.7f, 6.6f, 2.9f, - 6.7f, 3.0f, 6.7f, 3.1f, 6.8f, 3.2f, 6.8f, 3.3f, 5.3f, 3.2f, 5.2f, 3.1f, 5.2f, 3.0f, - 5.1f, 2.9f, 5.0f, 2.7f, 4.9f, 2.6f, 4.8f, 2.4f, 4.7f, 2.3f, 4.6f, 2.1f, 4.5f, 2.0f, - 4.4f, 1.8f, 4.3f, 1.7f, 4.1f, 1.4f, 4.0f, 1.3f, 3.9f, 1.1f, 3.8f, 1.0f, 3.6f, 0.9f, - 3.6f, 0.8f, 3.5f, 0.7f, 3.3f, 0.6f, 2.9f, 0.5f, 2.3f, 0.6f, 2.3f, 0.7f, 2.2f, 3.3f, - 1.0f, 3.2f, 1.0f, 3.1f, 1.0f, 0.0f, - - 4.2f, -0.5f, 4.4f, -0.6f, 4.7f, -0.7f, 4.8f, -0.8f, 4.9f, -1.0f, 5.0f, -1.1f, 5.0f, -1.2f, - 4.9f, -1.7f, 4.9f, -1.8f, 4.8f, -1.9f, 4.8f, -2.0f, 4.6f, -2.1f, 4.3f, -2.2f, 2.3f, -2.1f, - 2.3f, -2.0f, 2.4f, -0.5f, 4.2f, -0.5f, 1.0f, 0.0f, -}; - -constexpr std::array<float, 18 * 2> symbol_zl = { - -2.6f, -2.13f, -5.6f, -2.13f, -5.6f, -3.23f, -0.8f, -3.23f, -0.8f, -2.13f, -4.4f, 2.12f, - -0.7f, 2.12f, -0.7f, 3.22f, -6.0f, 3.22f, -6.0f, 2.12f, 2.4f, -3.23f, 2.4f, 2.1f, - 5.43f, 2.1f, 5.43f, 3.22f, 0.98f, 3.22f, 0.98f, -3.23f, 2.4f, -3.23f, -6.0f, 2.12f, -}; - -constexpr std::array<float, 57 * 2> symbol_sl = { - -3.0f, -3.65f, -2.76f, -4.26f, -2.33f, -4.76f, -1.76f, -5.09f, -1.13f, -5.26f, -0.94f, - -4.77f, -0.87f, -4.11f, -1.46f, -3.88f, -1.91f, -3.41f, -2.05f, -2.78f, -1.98f, -2.13f, - -1.59f, -1.61f, -0.96f, -1.53f, -0.56f, -2.04f, -0.38f, -2.67f, -0.22f, -3.31f, 0.0f, - -3.93f, 0.34f, -4.49f, 0.86f, -4.89f, 1.49f, -5.05f, 2.14f, -4.95f, 2.69f, -4.6f, - 3.07f, -4.07f, 3.25f, -3.44f, 3.31f, -2.78f, 3.25f, -2.12f, 3.07f, -1.49f, 2.7f, - -0.95f, 2.16f, -0.58f, 1.52f, -0.43f, 1.41f, -0.99f, 1.38f, -1.65f, 1.97f, -1.91f, - 2.25f, -2.49f, 2.25f, -3.15f, 1.99f, -3.74f, 1.38f, -3.78f, 1.06f, -3.22f, 0.88f, - -2.58f, 0.71f, -1.94f, 0.49f, -1.32f, 0.13f, -0.77f, -0.4f, -0.4f, -1.04f, -0.25f, - -1.69f, -0.32f, -2.28f, -0.61f, -2.73f, -1.09f, -2.98f, -1.69f, -3.09f, -2.34f, - - 3.23f, 2.4f, -2.1f, 2.4f, -2.1f, 5.43f, -3.22f, 5.43f, -3.22f, 0.98f, 3.23f, - 0.98f, 3.23f, 2.4f, -3.09f, -2.34f, -}; -constexpr std::array<float, 109 * 2> symbol_zr = { - -2.6f, -2.13f, -5.6f, -2.13f, -5.6f, -3.23f, -0.8f, -3.23f, -0.8f, -2.13f, -4.4f, 2.12f, -0.7f, - 2.12f, -0.7f, 3.22f, -6.0f, 3.22f, -6.0f, 2.12f, - - 1.0f, 0.0f, 1.0f, -0.1f, 1.1f, -3.3f, 4.3f, -3.2f, 5.1f, -3.1f, 5.4f, -3.0f, 5.6f, - -2.9f, 5.7f, -2.8f, 5.9f, -2.7f, 5.9f, -2.6f, 6.0f, -2.5f, 6.1f, -2.3f, 6.2f, -2.2f, - 6.2f, -2.1f, 6.3f, -2.0f, 6.3f, -1.9f, 6.2f, -0.8f, 6.2f, -0.7f, 6.1f, -0.6f, 6.1f, - -0.5f, 6.0f, -0.4f, 6.0f, -0.3f, 5.9f, -0.2f, 5.7f, -0.1f, 5.7f, 0.0f, 5.6f, 0.1f, - 5.4f, 0.2f, 5.1f, 0.3f, 4.7f, 0.4f, 4.7f, 0.5f, 4.9f, 0.6f, 5.0f, 0.7f, 5.2f, - 0.8f, 5.2f, 0.9f, 5.3f, 1.0f, 5.5f, 1.1f, 5.5f, 1.2f, 5.6f, 1.3f, 5.7f, 1.5f, - 5.8f, 1.6f, 5.9f, 1.8f, 6.0f, 1.9f, 6.1f, 2.1f, 6.2f, 2.2f, 6.2f, 2.3f, 6.3f, - 2.4f, 6.4f, 2.6f, 6.5f, 2.7f, 6.6f, 2.9f, 6.7f, 3.0f, 6.7f, 3.1f, 6.8f, 3.2f, - 6.8f, 3.3f, 5.3f, 3.2f, 5.2f, 3.1f, 5.2f, 3.0f, 5.1f, 2.9f, 5.0f, 2.7f, 4.9f, - 2.6f, 4.8f, 2.4f, 4.7f, 2.3f, 4.6f, 2.1f, 4.5f, 2.0f, 4.4f, 1.8f, 4.3f, 1.7f, - 4.1f, 1.4f, 4.0f, 1.3f, 3.9f, 1.1f, 3.8f, 1.0f, 3.6f, 0.9f, 3.6f, 0.8f, 3.5f, - 0.7f, 3.3f, 0.6f, 2.9f, 0.5f, 2.3f, 0.6f, 2.3f, 0.7f, 2.2f, 3.3f, 1.0f, 3.2f, - 1.0f, 3.1f, 1.0f, 0.0f, - - 4.2f, -0.5f, 4.4f, -0.6f, 4.7f, -0.7f, 4.8f, -0.8f, 4.9f, -1.0f, 5.0f, -1.1f, 5.0f, - -1.2f, 4.9f, -1.7f, 4.9f, -1.8f, 4.8f, -1.9f, 4.8f, -2.0f, 4.6f, -2.1f, 4.3f, -2.2f, - 2.3f, -2.1f, 2.3f, -2.0f, 2.4f, -0.5f, 4.2f, -0.5f, 1.0f, 0.0f, -6.0f, 2.12f, -}; - -constexpr std::array<float, 148 * 2> symbol_sr = { - -3.0f, -3.65f, -2.76f, -4.26f, -2.33f, -4.76f, -1.76f, -5.09f, -1.13f, -5.26f, -0.94f, -4.77f, - -0.87f, -4.11f, -1.46f, -3.88f, -1.91f, -3.41f, -2.05f, -2.78f, -1.98f, -2.13f, -1.59f, -1.61f, - -0.96f, -1.53f, -0.56f, -2.04f, -0.38f, -2.67f, -0.22f, -3.31f, 0.0f, -3.93f, 0.34f, -4.49f, - 0.86f, -4.89f, 1.49f, -5.05f, 2.14f, -4.95f, 2.69f, -4.6f, 3.07f, -4.07f, 3.25f, -3.44f, - 3.31f, -2.78f, 3.25f, -2.12f, 3.07f, -1.49f, 2.7f, -0.95f, 2.16f, -0.58f, 1.52f, -0.43f, - 1.41f, -0.99f, 1.38f, -1.65f, 1.97f, -1.91f, 2.25f, -2.49f, 2.25f, -3.15f, 1.99f, -3.74f, - 1.38f, -3.78f, 1.06f, -3.22f, 0.88f, -2.58f, 0.71f, -1.94f, 0.49f, -1.32f, 0.13f, -0.77f, - -0.4f, -0.4f, -1.04f, -0.25f, -1.69f, -0.32f, -2.28f, -0.61f, -2.73f, -1.09f, -2.98f, -1.69f, - -3.09f, -2.34f, - - -1.0f, 0.0f, 0.1f, 1.0f, 3.3f, 1.1f, 3.2f, 4.3f, 3.1f, 5.1f, 3.0f, 5.4f, - 2.9f, 5.6f, 2.8f, 5.7f, 2.7f, 5.9f, 2.6f, 5.9f, 2.5f, 6.0f, 2.3f, 6.1f, - 2.2f, 6.2f, 2.1f, 6.2f, 2.0f, 6.3f, 1.9f, 6.3f, 0.8f, 6.2f, 0.7f, 6.2f, - 0.6f, 6.1f, 0.5f, 6.1f, 0.4f, 6.0f, 0.3f, 6.0f, 0.2f, 5.9f, 0.1f, 5.7f, - 0.0f, 5.7f, -0.1f, 5.6f, -0.2f, 5.4f, -0.3f, 5.1f, -0.4f, 4.7f, -0.5f, 4.7f, - -0.6f, 4.9f, -0.7f, 5.0f, -0.8f, 5.2f, -0.9f, 5.2f, -1.0f, 5.3f, -1.1f, 5.5f, - -1.2f, 5.5f, -1.3f, 5.6f, -1.5f, 5.7f, -1.6f, 5.8f, -1.8f, 5.9f, -1.9f, 6.0f, - -2.1f, 6.1f, -2.2f, 6.2f, -2.3f, 6.2f, -2.4f, 6.3f, -2.6f, 6.4f, -2.7f, 6.5f, - -2.9f, 6.6f, -3.0f, 6.7f, -3.1f, 6.7f, -3.2f, 6.8f, -3.3f, 6.8f, -3.2f, 5.3f, - -3.1f, 5.2f, -3.0f, 5.2f, -2.9f, 5.1f, -2.7f, 5.0f, -2.6f, 4.9f, -2.4f, 4.8f, - -2.3f, 4.7f, -2.1f, 4.6f, -2.0f, 4.5f, -1.8f, 4.4f, -1.7f, 4.3f, -1.4f, 4.1f, - -1.3f, 4.0f, -1.1f, 3.9f, -1.0f, 3.8f, -0.9f, 3.6f, -0.8f, 3.6f, -0.7f, 3.5f, - -0.6f, 3.3f, -0.5f, 2.9f, -0.6f, 2.3f, -0.7f, 2.3f, -3.3f, 2.2f, -3.2f, 1.0f, - -3.1f, 1.0f, 0.0f, 1.0f, - - 0.5f, 4.2f, 0.6f, 4.4f, 0.7f, 4.7f, 0.8f, 4.8f, 1.0f, 4.9f, 1.1f, 5.0f, - 1.2f, 5.0f, 1.7f, 4.9f, 1.8f, 4.9f, 1.9f, 4.8f, 2.0f, 4.8f, 2.1f, 4.6f, - 2.2f, 4.3f, 2.1f, 2.3f, 2.0f, 2.3f, 0.5f, 2.4f, 0.5f, 4.2f, -0.0f, 1.0f, - -3.09f, -2.34f, - -}; - -constexpr std::array<float, 30 * 2> symbol_c = { - 2.86f, 7.57f, 0.99f, 7.94f, -0.91f, 7.87f, -2.73f, 7.31f, -4.23f, 6.14f, -5.2f, 4.51f, - -5.65f, 2.66f, -5.68f, 0.75f, -5.31f, -1.12f, -4.43f, -2.81f, -3.01f, -4.08f, -1.24f, -4.78f, - 0.66f, -4.94f, 2.54f, -4.67f, 4.33f, -4.0f, 4.63f, -2.27f, 3.37f, -2.7f, 1.6f, -3.4f, - -0.3f, -3.5f, -2.09f, -2.87f, -3.34f, -1.45f, -3.91f, 0.37f, -3.95f, 2.27f, -3.49f, 4.12f, - -2.37f, 5.64f, -0.65f, 6.44f, 1.25f, 6.47f, 3.06f, 5.89f, 4.63f, 4.92f, 4.63f, 6.83f, -}; - -constexpr std::array<float, 6 * 2> symbol_charging = { - 6.5f, -1.0f, 1.0f, -1.0f, 1.0f, -3.0f, -6.5f, 1.0f, -1.0f, 1.0f, -1.0f, 3.0f, -}; - -constexpr std::array<float, 12 * 2> house = { - -1.3f, 0.0f, -0.93f, 0.0f, -0.93f, 1.15f, 0.93f, 1.15f, 0.93f, 0.0f, 1.3f, 0.0f, - 0.0f, -1.2f, -1.3f, 0.0f, -0.43f, 0.0f, -0.43f, .73f, 0.43f, .73f, 0.43f, 0.0f, -}; - -constexpr std::array<float, 11 * 2> up_arrow_button = { - 9.1f, -9.1f, 9.1f, -30.0f, 8.1f, -30.1f, 7.7f, -30.1f, -8.6f, -30.0f, -9.0f, - -29.8f, -9.3f, -29.5f, -9.5f, -29.1f, -9.1f, -28.7f, -9.1f, -9.1f, 0.0f, 0.6f, -}; - -constexpr std::array<float, 3 * 2> up_arrow_symbol = { - 0.0f, -3.0f, -3.0f, 2.0f, 3.0f, 2.0f, -}; - -constexpr std::array<float, 64 * 2> trigger_button = { - 5.5f, -12.6f, 5.8f, -12.6f, 6.7f, -12.5f, 8.1f, -12.3f, 8.6f, -12.2f, 9.2f, -12.0f, - 9.5f, -11.9f, 9.9f, -11.8f, 10.6f, -11.5f, 11.0f, -11.3f, 11.2f, -11.2f, 11.4f, -11.1f, - 11.8f, -10.9f, 12.0f, -10.8f, 12.2f, -10.7f, 12.4f, -10.5f, 12.6f, -10.4f, 12.8f, -10.3f, - 13.6f, -9.7f, 13.8f, -9.6f, 13.9f, -9.4f, 14.1f, -9.3f, 14.8f, -8.6f, 15.0f, -8.5f, - 15.1f, -8.3f, 15.6f, -7.8f, 15.7f, -7.6f, 16.1f, -7.0f, 16.3f, -6.8f, 16.4f, -6.6f, - 16.5f, -6.4f, 16.8f, -6.0f, 16.9f, -5.8f, 17.0f, -5.6f, 17.1f, -5.4f, 17.2f, -5.2f, - 17.3f, -5.0f, 17.4f, -4.8f, 17.5f, -4.6f, 17.6f, -4.4f, 17.7f, -4.1f, 17.8f, -3.9f, - 17.9f, -3.5f, 18.0f, -3.3f, 18.1f, -3.0f, 18.2f, -2.6f, 18.2f, -2.3f, 18.3f, -2.1f, - 18.3f, -1.9f, 18.4f, -1.4f, 18.5f, -1.2f, 18.6f, -0.3f, 18.6f, 0.0f, 18.3f, 13.9f, - -17.0f, 13.8f, -17.0f, 13.6f, -16.4f, -11.4f, -16.3f, -11.6f, -16.1f, -11.8f, -15.7f, -12.0f, - -15.5f, -12.1f, -15.1f, -12.3f, -14.6f, -12.4f, -13.4f, -12.5f, -}; - -constexpr std::array<float, 36 * 2> pro_left_trigger = { - -65.2f, -132.6f, -68.2f, -134.1f, -71.3f, -135.5f, -74.4f, -136.7f, -77.6f, - -137.6f, -80.9f, -138.1f, -84.3f, -138.3f, -87.6f, -138.3f, -91.0f, -138.1f, - -94.3f, -137.8f, -97.6f, -137.3f, -100.9f, -136.7f, -107.5f, -135.3f, -110.7f, - -134.5f, -120.4f, -131.8f, -123.6f, -130.8f, -126.8f, -129.7f, -129.9f, -128.5f, - -132.9f, -127.1f, -135.9f, -125.6f, -138.8f, -123.9f, -141.6f, -122.0f, -144.1f, - -119.8f, -146.3f, -117.3f, -148.4f, -114.7f, -150.4f, -112.0f, -152.3f, -109.2f, - -155.3f, -104.0f, -152.0f, -104.3f, -148.7f, -104.5f, -145.3f, -104.8f, -35.5f, - -117.2f, -38.5f, -118.7f, -41.4f, -120.3f, -44.4f, -121.8f, -50.4f, -124.9f, -}; - -constexpr std::array<float, 14 * 2> pro_body_top = { - 0.0f, -115.4f, -4.4f, -116.1f, -69.7f, -131.3f, -66.4f, -131.9f, -63.1f, -132.3f, - -56.4f, -133.0f, -53.1f, -133.3f, -49.8f, -133.5f, -43.1f, -133.8f, -39.8f, -134.0f, - -36.5f, -134.1f, -16.4f, -134.4f, -13.1f, -134.4f, 0.0f, -134.1f, -}; - -constexpr std::array<float, 145 * 2> pro_left_handle = { - -178.7f, -47.5f, -179.0f, -46.1f, -179.3f, -44.6f, -182.0f, -29.8f, -182.3f, -28.4f, - -182.6f, -26.9f, -182.8f, -25.4f, -183.1f, -23.9f, -183.3f, -22.4f, -183.6f, -21.0f, - -183.8f, -19.5f, -184.1f, -18.0f, -184.3f, -16.5f, -184.6f, -15.1f, -184.8f, -13.6f, - -185.1f, -12.1f, -185.3f, -10.6f, -185.6f, -9.1f, -185.8f, -7.7f, -186.1f, -6.2f, - -186.3f, -4.7f, -186.6f, -3.2f, -186.8f, -1.7f, -187.1f, -0.3f, -187.3f, 1.2f, - -187.6f, 2.7f, -187.8f, 4.2f, -188.3f, 7.1f, -188.5f, 8.6f, -188.8f, 10.1f, - -189.0f, 11.6f, -189.3f, 13.1f, -189.5f, 14.5f, -190.0f, 17.5f, -190.2f, 19.0f, - -190.5f, 20.5f, -190.7f, 21.9f, -191.2f, 24.9f, -191.4f, 26.4f, -191.7f, 27.9f, - -191.9f, 29.3f, -192.4f, 32.3f, -192.6f, 33.8f, -193.1f, 36.8f, -193.3f, 38.2f, - -193.8f, 41.2f, -194.0f, 42.7f, -194.7f, 47.1f, -194.9f, 48.6f, -199.0f, 82.9f, - -199.1f, 84.4f, -199.1f, 85.9f, -199.2f, 87.4f, -199.2f, 88.9f, -199.1f, 94.9f, - -198.9f, 96.4f, -198.8f, 97.8f, -198.5f, 99.3f, -198.3f, 100.8f, -198.0f, 102.3f, - -197.7f, 103.7f, -197.4f, 105.2f, -197.0f, 106.7f, -196.6f, 108.1f, -195.7f, 111.0f, - -195.2f, 112.4f, -194.1f, 115.2f, -193.5f, 116.5f, -192.8f, 117.9f, -192.1f, 119.2f, - -190.6f, 121.8f, -189.8f, 123.1f, -188.9f, 124.3f, -187.0f, 126.6f, -186.0f, 127.7f, - -183.9f, 129.8f, -182.7f, 130.8f, -180.3f, 132.6f, -179.1f, 133.4f, -177.8f, 134.1f, - -176.4f, 134.8f, -175.1f, 135.5f, -173.7f, 136.0f, -169.4f, 137.3f, -167.9f, 137.7f, - -166.5f, 138.0f, -165.0f, 138.3f, -163.5f, 138.4f, -162.0f, 138.4f, -160.5f, 138.3f, - -159.0f, 138.0f, -157.6f, 137.7f, -156.1f, 137.3f, -154.7f, 136.9f, -153.2f, 136.5f, - -151.8f, 136.0f, -150.4f, 135.4f, -149.1f, 134.8f, -147.7f, 134.1f, -146.5f, 133.3f, - -145.2f, 132.5f, -144.0f, 131.6f, -142.8f, 130.6f, -141.7f, 129.6f, -139.6f, 127.5f, - -138.6f, 126.4f, -137.7f, 125.2f, -135.1f, 121.5f, -134.3f, 120.3f, -133.5f, 119.0f, - -131.9f, 116.5f, -131.1f, 115.2f, -128.8f, 111.3f, -128.0f, 110.1f, -127.2f, 108.8f, - -126.5f, 107.5f, -125.7f, 106.2f, -125.0f, 104.9f, -124.2f, 103.6f, -123.5f, 102.3f, - -122.0f, 99.6f, -121.3f, 98.3f, -115.8f, 87.7f, -115.1f, 86.4f, -114.4f, 85.0f, - -113.7f, 83.7f, -112.3f, 81.0f, -111.6f, 79.7f, -110.1f, 77.1f, -109.4f, 75.8f, - -108.0f, 73.1f, -107.2f, 71.8f, -106.4f, 70.6f, -105.7f, 69.3f, -104.8f, 68.0f, - -104.0f, 66.8f, -103.1f, 65.6f, -101.1f, 63.3f, -100.0f, 62.3f, -98.8f, 61.4f, - -97.6f, 60.6f, -97.9f, 59.5f, -98.8f, 58.3f, -101.5f, 54.6f, -102.4f, 53.4f, -}; - -constexpr std::array<float, 245 * 2> pro_body = { - -0.7f, -129.1f, -54.3f, -129.1f, -55.0f, -129.1f, -57.8f, -129.0f, -58.5f, -129.0f, - -60.7f, -128.9f, -61.4f, -128.9f, -62.8f, -128.8f, -63.5f, -128.8f, -65.7f, -128.7f, - -66.4f, -128.7f, -67.8f, -128.6f, -68.5f, -128.6f, -69.2f, -128.5f, -70.0f, -128.5f, - -70.7f, -128.4f, -71.4f, -128.4f, -72.1f, -128.3f, -72.8f, -128.3f, -73.5f, -128.2f, - -74.2f, -128.2f, -74.9f, -128.1f, -75.7f, -128.1f, -76.4f, -128.0f, -77.1f, -128.0f, - -77.8f, -127.9f, -78.5f, -127.9f, -79.2f, -127.8f, -80.6f, -127.7f, -81.4f, -127.6f, - -82.1f, -127.5f, -82.8f, -127.5f, -83.5f, -127.4f, -84.9f, -127.3f, -85.6f, -127.2f, - -87.0f, -127.1f, -87.7f, -127.0f, -88.5f, -126.9f, -89.2f, -126.8f, -89.9f, -126.8f, - -90.6f, -126.7f, -94.1f, -126.3f, -94.8f, -126.2f, -113.2f, -123.3f, -113.9f, -123.2f, - -114.6f, -123.0f, -115.3f, -122.9f, -116.7f, -122.6f, -117.4f, -122.5f, -118.1f, -122.3f, - -118.8f, -122.2f, -119.5f, -122.0f, -120.9f, -121.7f, -121.6f, -121.5f, -122.3f, -121.4f, - -122.9f, -121.2f, -123.6f, -121.0f, -126.4f, -120.3f, -127.1f, -120.1f, -127.8f, -119.8f, - -128.4f, -119.6f, -129.1f, -119.4f, -131.2f, -118.7f, -132.5f, -118.3f, -133.2f, -118.0f, - -133.8f, -117.7f, -134.5f, -117.4f, -135.1f, -117.2f, -135.8f, -116.9f, -136.4f, -116.5f, - -137.0f, -116.2f, -137.7f, -115.8f, -138.3f, -115.4f, -138.9f, -115.1f, -139.5f, -114.7f, - -160.0f, -100.5f, -160.5f, -100.0f, -162.5f, -97.9f, -162.9f, -97.4f, -163.4f, -96.8f, - -163.8f, -96.2f, -165.3f, -93.8f, -165.7f, -93.2f, -166.0f, -92.6f, -166.4f, -91.9f, - -166.7f, -91.3f, -167.3f, -90.0f, -167.6f, -89.4f, -167.8f, -88.7f, -168.1f, -88.0f, - -168.4f, -87.4f, -168.6f, -86.7f, -168.9f, -86.0f, -169.1f, -85.4f, -169.3f, -84.7f, - -169.6f, -84.0f, -169.8f, -83.3f, -170.2f, -82.0f, -170.4f, -81.3f, -172.8f, -72.3f, - -173.0f, -71.6f, -173.5f, -69.5f, -173.7f, -68.8f, -173.9f, -68.2f, -174.0f, -67.5f, - -174.2f, -66.8f, -174.5f, -65.4f, -174.7f, -64.7f, -174.8f, -64.0f, -175.0f, -63.3f, - -175.3f, -61.9f, -175.5f, -61.2f, -175.8f, -59.8f, -176.0f, -59.1f, -176.1f, -58.4f, - -176.3f, -57.7f, -176.6f, -56.3f, -176.8f, -55.6f, -176.9f, -54.9f, -177.1f, -54.2f, - -177.3f, -53.6f, -177.4f, -52.9f, -177.6f, -52.2f, -177.9f, -50.8f, -178.1f, -50.1f, - -178.2f, -49.4f, -178.2f, -48.7f, -177.8f, -48.1f, -177.1f, -46.9f, -176.7f, -46.3f, - -176.4f, -45.6f, -176.0f, -45.0f, -175.3f, -43.8f, -174.9f, -43.2f, -174.2f, -42.0f, - -173.4f, -40.7f, -173.1f, -40.1f, -172.7f, -39.5f, -172.0f, -38.3f, -171.6f, -37.7f, - -170.5f, -35.9f, -170.1f, -35.3f, -169.7f, -34.6f, -169.3f, -34.0f, -168.6f, -32.8f, - -168.2f, -32.2f, -166.3f, -29.2f, -165.9f, -28.6f, -163.2f, -24.4f, -162.8f, -23.8f, - -141.8f, 6.8f, -141.4f, 7.4f, -139.4f, 10.3f, -139.0f, 10.9f, -138.5f, 11.5f, - -138.1f, 12.1f, -137.3f, 13.2f, -136.9f, 13.8f, -136.0f, 15.0f, -135.6f, 15.6f, - -135.2f, 16.1f, -134.8f, 16.7f, -133.9f, 17.9f, -133.5f, 18.4f, -133.1f, 19.0f, - -131.8f, 20.7f, -131.4f, 21.3f, -130.1f, 23.0f, -129.7f, 23.6f, -128.4f, 25.3f, - -128.0f, 25.9f, -126.7f, 27.6f, -126.3f, 28.2f, -125.4f, 29.3f, -125.0f, 29.9f, - -124.1f, 31.0f, -123.7f, 31.6f, -122.8f, 32.7f, -122.4f, 33.3f, -121.5f, 34.4f, - -121.1f, 35.0f, -120.6f, 35.6f, -120.2f, 36.1f, -119.7f, 36.7f, -119.3f, 37.2f, - -118.9f, 37.8f, -118.4f, 38.4f, -118.0f, 38.9f, -117.5f, 39.5f, -117.1f, 40.0f, - -116.6f, 40.6f, -116.2f, 41.1f, -115.7f, 41.7f, -115.2f, 42.2f, -114.8f, 42.8f, - -114.3f, 43.3f, -113.9f, 43.9f, -113.4f, 44.4f, -112.4f, 45.5f, -112.0f, 46.0f, - -111.5f, 46.5f, -110.5f, 47.6f, -110.0f, 48.1f, -109.6f, 48.6f, -109.1f, 49.2f, - -108.6f, 49.7f, -107.7f, 50.8f, -107.2f, 51.3f, -105.7f, 52.9f, -105.3f, 53.4f, - -104.8f, 53.9f, -104.3f, 54.5f, -103.8f, 55.0f, -100.7f, 58.0f, -100.2f, 58.4f, - -99.7f, 58.9f, -99.1f, 59.3f, -97.2f, 60.3f, -96.5f, 60.1f, -95.9f, 59.7f, - -95.3f, 59.4f, -94.6f, 59.1f, -93.9f, 58.9f, -92.6f, 58.5f, -91.9f, 58.4f, - -91.2f, 58.2f, -90.5f, 58.1f, -89.7f, 58.0f, -89.0f, 57.9f, -86.2f, 57.6f, - -85.5f, 57.5f, -84.1f, 57.4f, -83.4f, 57.3f, -82.6f, 57.3f, -81.9f, 57.2f, - -81.2f, 57.2f, -80.5f, 57.1f, -79.8f, 57.1f, -78.4f, 57.0f, -77.7f, 57.0f, - -75.5f, 56.9f, -74.8f, 56.9f, -71.9f, 56.8f, -71.2f, 56.8f, 0.0f, 56.8f, -}; - -constexpr std::array<float, 199 * 2> gc_body = { - 0.0f, -138.03f, -4.91f, -138.01f, -8.02f, -137.94f, -11.14f, -137.82f, -14.25f, - -137.67f, -17.37f, -137.48f, -20.48f, -137.25f, -23.59f, -137.0f, -26.69f, -136.72f, - -29.8f, -136.41f, -32.9f, -136.07f, -35.99f, -135.71f, -39.09f, -135.32f, -42.18f, - -134.91f, -45.27f, -134.48f, -48.35f, -134.03f, -51.43f, -133.55f, -54.51f, -133.05f, - -57.59f, -132.52f, -60.66f, -131.98f, -63.72f, -131.41f, -66.78f, -130.81f, -69.84f, - -130.2f, -72.89f, -129.56f, -75.94f, -128.89f, -78.98f, -128.21f, -82.02f, -127.49f, - -85.05f, -126.75f, -88.07f, -125.99f, -91.09f, -125.19f, -94.1f, -124.37f, -97.1f, - -123.52f, -100.09f, -122.64f, -103.07f, -121.72f, -106.04f, -120.77f, -109.0f, -119.79f, - -111.95f, -118.77f, -114.88f, -117.71f, -117.8f, -116.61f, -120.7f, -115.46f, -123.58f, - -114.27f, -126.44f, -113.03f, -129.27f, -111.73f, -132.08f, -110.38f, -134.86f, -108.96f, - -137.6f, -107.47f, -140.3f, -105.91f, -142.95f, -104.27f, -145.55f, -102.54f, -148.07f, - -100.71f, -150.51f, -98.77f, -152.86f, -96.71f, -155.09f, -94.54f, -157.23f, -92.27f, - -159.26f, -89.9f, -161.2f, -87.46f, -163.04f, -84.94f, -164.78f, -82.35f, -166.42f, - -79.7f, -167.97f, -77.0f, -169.43f, -74.24f, -170.8f, -71.44f, -172.09f, -68.6f, - -173.29f, -65.72f, -174.41f, -62.81f, -175.45f, -59.87f, -176.42f, -56.91f, -177.31f, - -53.92f, -178.14f, -50.91f, -178.9f, -47.89f, -179.6f, -44.85f, -180.24f, -41.8f, - -180.82f, -38.73f, -181.34f, -35.66f, -181.8f, -32.57f, -182.21f, -29.48f, -182.57f, - -26.38f, -182.88f, -23.28f, -183.15f, -20.17f, -183.36f, -17.06f, -183.54f, -13.95f, - -183.71f, -10.84f, -184.0f, -7.73f, -184.23f, -4.62f, -184.44f, -1.51f, -184.62f, - 1.6f, -184.79f, 4.72f, -184.95f, 7.83f, -185.11f, 10.95f, -185.25f, 14.06f, - -185.38f, 17.18f, -185.51f, 20.29f, -185.63f, 23.41f, -185.74f, 26.53f, -185.85f, - 29.64f, -185.95f, 32.76f, -186.04f, 35.88f, -186.12f, 39.0f, -186.19f, 42.11f, - -186.26f, 45.23f, -186.32f, 48.35f, -186.37f, 51.47f, -186.41f, 54.59f, -186.44f, - 57.7f, -186.46f, 60.82f, -186.46f, 63.94f, -186.44f, 70.18f, -186.41f, 73.3f, - -186.36f, 76.42f, -186.3f, 79.53f, -186.22f, 82.65f, -186.12f, 85.77f, -185.99f, - 88.88f, -185.84f, 92.0f, -185.66f, 95.11f, -185.44f, 98.22f, -185.17f, 101.33f, - -184.85f, 104.43f, -184.46f, 107.53f, -183.97f, 110.61f, -183.37f, 113.67f, -182.65f, - 116.7f, -181.77f, 119.69f, -180.71f, 122.62f, -179.43f, 125.47f, -177.89f, 128.18f, - -176.05f, 130.69f, -173.88f, 132.92f, -171.36f, 134.75f, -168.55f, 136.1f, -165.55f, - 136.93f, -162.45f, 137.29f, -156.23f, 137.03f, -153.18f, 136.41f, -150.46f, 134.9f, - -148.14f, 132.83f, -146.14f, 130.43f, -144.39f, 127.85f, -142.83f, 125.16f, -141.41f, - 122.38f, -140.11f, 119.54f, -138.9f, 116.67f, -137.77f, 113.76f, -136.7f, 110.84f, - -135.68f, 107.89f, -134.71f, 104.93f, -133.77f, 101.95f, -132.86f, 98.97f, -131.97f, - 95.98f, -131.09f, 92.99f, -130.23f, 89.99f, -129.36f, 86.99f, -128.49f, 84.0f, - -127.63f, 81.0f, -126.76f, 78.01f, -125.9f, 75.01f, -124.17f, 69.02f, -123.31f, - 66.02f, -121.59f, 60.03f, -120.72f, 57.03f, -119.86f, 54.03f, -118.13f, 48.04f, - -117.27f, 45.04f, -115.55f, 39.05f, -114.68f, 36.05f, -113.82f, 33.05f, -112.96f, - 30.06f, -110.4f, 28.29f, -107.81f, 26.55f, -105.23f, 24.8f, -97.48f, 19.55f, - -94.9f, 17.81f, -92.32f, 16.06f, -87.15f, 12.56f, -84.57f, 10.81f, -81.99f, - 9.07f, -79.4f, 7.32f, -76.82f, 5.57f, -69.07f, 0.33f, -66.49f, -1.42f, - -58.74f, -6.66f, -56.16f, -8.41f, -48.4f, -13.64f, -45.72f, -15.22f, -42.93f, - -16.62f, -40.07f, -17.86f, -37.15f, -18.96f, -34.19f, -19.94f, -31.19f, -20.79f, - -28.16f, -21.55f, -25.12f, -22.21f, -22.05f, -22.79f, -18.97f, -23.28f, -15.88f, - -23.7f, -12.78f, -24.05f, -9.68f, -24.33f, -6.57f, -24.55f, -3.45f, -24.69f, - 0.0f, -24.69f, -}; - -constexpr std::array<float, 99 * 2> gc_left_body = { - -74.59f, -97.22f, -70.17f, -94.19f, -65.95f, -90.89f, -62.06f, -87.21f, -58.58f, - -83.14f, -55.58f, -78.7f, -53.08f, -73.97f, -51.05f, -69.01f, -49.46f, -63.89f, - -48.24f, -58.67f, -47.36f, -53.39f, -46.59f, -48.09f, -45.7f, -42.8f, -44.69f, - -37.54f, -43.54f, -32.31f, -42.25f, -27.11f, -40.8f, -21.95f, -39.19f, -16.84f, - -37.38f, -11.8f, -35.34f, -6.84f, -33.04f, -2.0f, -30.39f, 2.65f, -27.26f, - 7.0f, -23.84f, 11.11f, -21.19f, 15.76f, -19.18f, 20.73f, -17.73f, 25.88f, - -16.82f, 31.16f, -16.46f, 36.5f, -16.7f, 41.85f, -17.63f, 47.13f, -19.31f, - 52.21f, -21.8f, 56.95f, -24.91f, 61.3f, -28.41f, 65.36f, -32.28f, 69.06f, - -36.51f, 72.35f, -41.09f, 75.13f, -45.97f, 77.32f, -51.1f, 78.86f, -56.39f, - 79.7f, -61.74f, 79.84f, -67.07f, 79.3f, -72.3f, 78.15f, -77.39f, 76.48f, - -82.29f, 74.31f, -86.76f, 71.37f, -90.7f, 67.75f, -94.16f, 63.66f, -97.27f, - 59.3f, -100.21f, 54.81f, -103.09f, 50.3f, -106.03f, 45.82f, -109.11f, 41.44f, - -112.37f, 37.19f, -115.85f, 33.11f, -119.54f, 29.22f, -123.45f, 25.56f, -127.55f, - 22.11f, -131.77f, 18.81f, -136.04f, 15.57f, -140.34f, 12.37f, -144.62f, 9.15f, - -148.86f, 5.88f, -153.03f, 2.51f, -157.05f, -1.03f, -160.83f, -4.83f, -164.12f, - -9.05f, -166.71f, -13.73f, -168.91f, -18.62f, -170.77f, -23.64f, -172.3f, -28.78f, - -173.49f, -34.0f, -174.3f, -39.3f, -174.72f, -44.64f, -174.72f, -49.99f, -174.28f, - -55.33f, -173.37f, -60.61f, -172.0f, -65.79f, -170.17f, -70.82f, -167.79f, -75.62f, - -164.84f, -80.09f, -161.43f, -84.22f, -157.67f, -88.03f, -153.63f, -91.55f, -149.37f, - -94.81f, -144.94f, -97.82f, -140.37f, -100.61f, -135.65f, -103.16f, -130.73f, -105.26f, - -125.62f, -106.86f, -120.37f, -107.95f, -115.05f, -108.56f, -109.7f, -108.69f, -104.35f, - -108.36f, -99.05f, -107.6f, -93.82f, -106.41f, -88.72f, -104.79f, -83.78f, -102.7f, -}; - -constexpr std::array<float, 47 * 2> left_gc_trigger = { - -99.69f, -125.04f, -101.81f, -126.51f, -104.02f, -127.85f, -106.3f, -129.06f, -108.65f, - -130.12f, -111.08f, -130.99f, -113.58f, -131.62f, -116.14f, -131.97f, -121.26f, -131.55f, - -123.74f, -130.84f, -126.17f, -129.95f, -128.53f, -128.9f, -130.82f, -127.71f, -133.03f, - -126.38f, -135.15f, -124.92f, -137.18f, -123.32f, -139.11f, -121.6f, -140.91f, -119.75f, - -142.55f, -117.77f, -144.0f, -115.63f, -145.18f, -113.34f, -146.17f, -110.95f, -147.05f, - -108.53f, -147.87f, -106.08f, -148.64f, -103.61f, -149.37f, -101.14f, -149.16f, -100.12f, - -147.12f, -101.71f, -144.99f, -103.16f, -142.8f, -104.53f, -140.57f, -105.83f, -138.31f, - -107.08f, -136.02f, -108.27f, -133.71f, -109.42f, -131.38f, -110.53f, -129.04f, -111.61f, - -126.68f, -112.66f, -124.31f, -113.68f, -121.92f, -114.67f, -119.53f, -115.64f, -117.13f, - -116.58f, -114.72f, -117.51f, -112.3f, -118.41f, -109.87f, -119.29f, -107.44f, -120.16f, - -105.0f, -121.0f, -100.11f, -122.65f, -}; - -constexpr std::array<float, 50 * 2> gc_button_x = { - 142.1f, -50.67f, 142.44f, -48.65f, 142.69f, -46.62f, 142.8f, -44.57f, 143.0f, -42.54f, - 143.56f, -40.57f, 144.42f, -38.71f, 145.59f, -37.04f, 147.08f, -35.64f, 148.86f, -34.65f, - 150.84f, -34.11f, 152.88f, -34.03f, 154.89f, -34.38f, 156.79f, -35.14f, 158.49f, -36.28f, - 159.92f, -37.74f, 161.04f, -39.45f, 161.85f, -41.33f, 162.4f, -43.3f, 162.72f, -45.32f, - 162.85f, -47.37f, 162.82f, -49.41f, 162.67f, -51.46f, 162.39f, -53.48f, 162.0f, -55.5f, - 161.51f, -57.48f, 160.9f, -59.44f, 160.17f, -61.35f, 159.25f, -63.18f, 158.19f, -64.93f, - 157.01f, -66.61f, 155.72f, -68.2f, 154.31f, -69.68f, 152.78f, -71.04f, 151.09f, -72.2f, - 149.23f, -73.04f, 147.22f, -73.36f, 145.19f, -73.11f, 143.26f, -72.42f, 141.51f, -71.37f, - 140.0f, -69.99f, 138.82f, -68.32f, 138.13f, -66.4f, 138.09f, -64.36f, 138.39f, -62.34f, - 139.05f, -60.41f, 139.91f, -58.55f, 140.62f, -56.63f, 141.21f, -54.67f, 141.67f, -52.67f, -}; - -constexpr std::array<float, 50 * 2> gc_button_y = { - 104.02f, -75.23f, 106.01f, -75.74f, 108.01f, -76.15f, 110.04f, -76.42f, 112.05f, -76.78f, - 113.97f, -77.49f, 115.76f, -78.49f, 117.33f, -79.79f, 118.6f, -81.39f, 119.46f, -83.25f, - 119.84f, -85.26f, 119.76f, -87.3f, 119.24f, -89.28f, 118.33f, -91.11f, 117.06f, -92.71f, - 115.49f, -94.02f, 113.7f, -95.01f, 111.77f, -95.67f, 109.76f, -96.05f, 107.71f, -96.21f, - 105.67f, -96.18f, 103.63f, -95.99f, 101.61f, -95.67f, 99.61f, -95.24f, 97.63f, -94.69f, - 95.69f, -94.04f, 93.79f, -93.28f, 91.94f, -92.4f, 90.19f, -91.34f, 88.53f, -90.14f, - 86.95f, -88.84f, 85.47f, -87.42f, 84.1f, -85.9f, 82.87f, -84.26f, 81.85f, -82.49f, - 81.15f, -80.57f, 81.0f, -78.54f, 81.41f, -76.54f, 82.24f, -74.67f, 83.43f, -73.01f, - 84.92f, -71.61f, 86.68f, -70.57f, 88.65f, -70.03f, 90.69f, -70.15f, 92.68f, -70.61f, - 94.56f, -71.42f, 96.34f, -72.43f, 98.2f, -73.29f, 100.11f, -74.03f, 102.06f, -74.65f, -}; - -constexpr std::array<float, 47 * 2> gc_button_z = { - 95.74f, -126.41f, 98.34f, -126.38f, 100.94f, -126.24f, 103.53f, -126.01f, 106.11f, -125.7f, - 108.69f, -125.32f, 111.25f, -124.87f, 113.8f, -124.34f, 116.33f, -123.73f, 118.84f, -123.05f, - 121.33f, -122.3f, 123.79f, -121.47f, 126.23f, -120.56f, 128.64f, -119.58f, 131.02f, -118.51f, - 133.35f, -117.37f, 135.65f, -116.14f, 137.9f, -114.84f, 140.1f, -113.46f, 142.25f, -111.99f, - 144.35f, -110.45f, 146.38f, -108.82f, 148.35f, -107.13f, 150.25f, -105.35f, 151.89f, -103.38f, - 151.43f, -100.86f, 149.15f, -100.15f, 146.73f, -101.06f, 144.36f, -102.12f, 141.98f, -103.18f, - 139.6f, -104.23f, 137.22f, -105.29f, 134.85f, -106.35f, 132.47f, -107.41f, 127.72f, -109.53f, - 125.34f, -110.58f, 122.96f, -111.64f, 120.59f, -112.7f, 118.21f, -113.76f, 113.46f, -115.88f, - 111.08f, -116.93f, 108.7f, -117.99f, 106.33f, -119.05f, 103.95f, -120.11f, 99.2f, -122.23f, - 96.82f, -123.29f, 94.44f, -124.34f, -}; - -constexpr std::array<float, 84 * 2> left_joycon_body = { - -145.0f, -78.9f, -145.0f, -77.9f, -145.0f, 85.6f, -145.0f, 85.6f, -168.3f, 85.5f, - -169.3f, 85.4f, -171.3f, 85.1f, -172.3f, 84.9f, -173.4f, 84.7f, -174.3f, 84.5f, - -175.3f, 84.2f, -176.3f, 83.8f, -177.3f, 83.5f, -178.2f, 83.1f, -179.2f, 82.7f, - -180.1f, 82.2f, -181.0f, 81.8f, -181.9f, 81.3f, -182.8f, 80.7f, -183.7f, 80.2f, - -184.5f, 79.6f, -186.2f, 78.3f, -186.9f, 77.7f, -187.7f, 77.0f, -189.2f, 75.6f, - -189.9f, 74.8f, -190.6f, 74.1f, -191.3f, 73.3f, -191.9f, 72.5f, -192.5f, 71.6f, - -193.1f, 70.8f, -193.7f, 69.9f, -194.3f, 69.1f, -194.8f, 68.2f, -196.2f, 65.5f, - -196.6f, 64.5f, -197.0f, 63.6f, -197.4f, 62.6f, -198.1f, 60.7f, -198.4f, 59.7f, - -198.6f, 58.7f, -199.2f, 55.6f, -199.3f, 54.6f, -199.5f, 51.5f, -199.5f, 50.5f, - -199.5f, -49.4f, -199.4f, -50.5f, -199.3f, -51.5f, -199.1f, -52.5f, -198.2f, -56.5f, - -197.9f, -57.5f, -197.2f, -59.4f, -196.8f, -60.4f, -196.4f, -61.3f, -195.9f, -62.2f, - -194.3f, -64.9f, -193.7f, -65.7f, -193.1f, -66.6f, -192.5f, -67.4f, -191.8f, -68.2f, - -191.2f, -68.9f, -190.4f, -69.7f, -188.2f, -71.8f, -187.4f, -72.5f, -186.6f, -73.1f, - -185.8f, -73.8f, -185.0f, -74.4f, -184.1f, -74.9f, -183.2f, -75.5f, -182.4f, -76.0f, - -181.5f, -76.5f, -179.6f, -77.5f, -178.7f, -77.9f, -177.8f, -78.4f, -176.8f, -78.8f, - -175.9f, -79.1f, -174.9f, -79.5f, -173.9f, -79.8f, -170.9f, -80.6f, -169.9f, -80.8f, - -167.9f, -81.1f, -166.9f, -81.2f, -165.8f, -81.2f, -145.0f, -80.9f, -}; - -constexpr std::array<float, 84 * 2> left_joycon_trigger = { - -166.8f, -83.3f, -167.9f, -83.2f, -168.9f, -83.1f, -170.0f, -83.0f, -171.0f, -82.8f, - -172.1f, -82.6f, -173.1f, -82.4f, -174.2f, -82.1f, -175.2f, -81.9f, -176.2f, -81.5f, - -177.2f, -81.2f, -178.2f, -80.8f, -180.1f, -80.0f, -181.1f, -79.5f, -182.0f, -79.0f, - -183.0f, -78.5f, -183.9f, -78.0f, -184.8f, -77.4f, -185.7f, -76.9f, -186.6f, -76.3f, - -187.4f, -75.6f, -188.3f, -75.0f, -189.1f, -74.3f, -192.2f, -71.5f, -192.9f, -70.7f, - -193.7f, -69.9f, -194.3f, -69.1f, -195.0f, -68.3f, -195.6f, -67.4f, -196.8f, -65.7f, - -197.3f, -64.7f, -197.8f, -63.8f, -198.2f, -62.8f, -198.9f, -60.8f, -198.6f, -59.8f, - -197.6f, -59.7f, -196.6f, -60.0f, -195.6f, -60.5f, -194.7f, -60.9f, -193.7f, -61.4f, - -192.8f, -61.9f, -191.8f, -62.4f, -190.9f, -62.8f, -189.9f, -63.3f, -189.0f, -63.8f, - -187.1f, -64.8f, -186.2f, -65.2f, -185.2f, -65.7f, -184.3f, -66.2f, -183.3f, -66.7f, - -182.4f, -67.1f, -181.4f, -67.6f, -180.5f, -68.1f, -179.5f, -68.6f, -178.6f, -69.0f, - -177.6f, -69.5f, -176.7f, -70.0f, -175.7f, -70.5f, -174.8f, -70.9f, -173.8f, -71.4f, - -172.9f, -71.9f, -171.9f, -72.4f, -171.0f, -72.8f, -170.0f, -73.3f, -169.1f, -73.8f, - -168.1f, -74.3f, -167.2f, -74.7f, -166.2f, -75.2f, -165.3f, -75.7f, -164.3f, -76.2f, - -163.4f, -76.6f, -162.4f, -77.1f, -161.5f, -77.6f, -160.5f, -78.1f, -159.6f, -78.5f, - -158.7f, -79.0f, -157.7f, -79.5f, -156.8f, -80.0f, -155.8f, -80.4f, -154.9f, -80.9f, - -154.2f, -81.6f, -154.3f, -82.6f, -155.2f, -83.3f, -156.2f, -83.3f, -}; - -constexpr std::array<float, 70 * 2> handheld_body = { - -137.3f, -81.9f, -137.6f, -81.8f, -137.8f, -81.6f, -138.0f, -81.3f, -138.1f, -81.1f, - -138.1f, -80.8f, -138.2f, -78.7f, -138.2f, -78.4f, -138.3f, -78.1f, -138.7f, -77.3f, - -138.9f, -77.0f, -139.0f, -76.8f, -139.2f, -76.5f, -139.5f, -76.3f, -139.7f, -76.1f, - -139.9f, -76.0f, -140.2f, -75.8f, -140.5f, -75.7f, -140.7f, -75.6f, -141.0f, -75.5f, - -141.9f, -75.3f, -142.2f, -75.3f, -142.5f, -75.2f, -143.0f, -74.9f, -143.2f, -74.7f, - -143.3f, -74.4f, -143.0f, -74.1f, -143.0f, 85.3f, -143.0f, 85.6f, -142.7f, 85.8f, - -142.4f, 85.9f, -142.2f, 85.9f, 143.0f, 85.6f, 143.1f, 85.4f, 143.3f, 85.1f, - 143.0f, 84.8f, 143.0f, -74.9f, 142.8f, -75.1f, 142.5f, -75.2f, 141.9f, -75.3f, - 141.6f, -75.3f, 141.3f, -75.4f, 141.1f, -75.4f, 140.8f, -75.5f, 140.5f, -75.7f, - 140.2f, -75.8f, 140.0f, -76.0f, 139.7f, -76.1f, 139.5f, -76.3f, 139.1f, -76.8f, - 138.9f, -77.0f, 138.6f, -77.5f, 138.4f, -77.8f, 138.3f, -78.1f, 138.3f, -78.3f, - 138.2f, -78.6f, 138.2f, -78.9f, 138.1f, -79.2f, 138.1f, -79.5f, 138.0f, -81.3f, - 137.8f, -81.6f, 137.6f, -81.8f, 137.3f, -81.9f, 137.1f, -81.9f, 120.0f, -70.0f, - -120.0f, -70.0f, -120.0f, 70.0f, 120.0f, 70.0f, 120.0f, -70.0f, 137.1f, -81.9f, -}; - -constexpr std::array<float, 40 * 2> handheld_bezel = { - -131.4f, -75.9f, -132.2f, -75.7f, -132.9f, -75.3f, -134.2f, -74.3f, -134.7f, -73.6f, - -135.1f, -72.8f, -135.4f, -72.0f, -135.5f, -71.2f, -135.5f, -70.4f, -135.2f, 76.7f, - -134.8f, 77.5f, -134.3f, 78.1f, -133.7f, 78.8f, -133.1f, 79.2f, -132.3f, 79.6f, - -131.5f, 79.9f, -130.7f, 80.0f, -129.8f, 80.0f, 132.2f, 79.7f, 133.0f, 79.3f, - 133.7f, 78.8f, 134.3f, 78.3f, 134.8f, 77.6f, 135.1f, 76.8f, 135.5f, 75.2f, - 135.5f, 74.3f, 135.2f, -72.7f, 134.8f, -73.5f, 134.4f, -74.2f, 133.8f, -74.8f, - 133.1f, -75.3f, 132.3f, -75.6f, 130.7f, -76.0f, 129.8f, -76.0f, -112.9f, -62.2f, - 112.9f, -62.2f, 112.9f, 62.2f, -112.9f, 62.2f, -112.9f, -62.2f, 129.8f, -76.0f, -}; - -constexpr std::array<float, 58 * 2> handheld_buttons = { - -82.48f, -82.95f, -82.53f, -82.95f, -106.69f, -82.96f, -106.73f, -82.98f, -106.78f, -83.01f, - -106.81f, -83.05f, -106.83f, -83.1f, -106.83f, -83.15f, -106.82f, -83.93f, -106.81f, -83.99f, - -106.8f, -84.04f, -106.78f, -84.08f, -106.76f, -84.13f, -106.73f, -84.18f, -106.7f, -84.22f, - -106.6f, -84.34f, -106.56f, -84.37f, -106.51f, -84.4f, -106.47f, -84.42f, -106.42f, -84.45f, - -106.37f, -84.47f, -106.32f, -84.48f, -106.17f, -84.5f, -98.9f, -84.48f, -98.86f, -84.45f, - -98.83f, -84.41f, -98.81f, -84.36f, -98.8f, -84.31f, -98.8f, -84.26f, -98.79f, -84.05f, - -90.26f, -84.1f, -90.26f, -84.15f, -90.25f, -84.36f, -90.23f, -84.41f, -90.2f, -84.45f, - -90.16f, -84.48f, -90.11f, -84.5f, -82.79f, -84.49f, -82.74f, -84.48f, -82.69f, -84.46f, - -82.64f, -84.45f, -82.59f, -84.42f, -82.55f, -84.4f, -82.5f, -84.37f, -82.46f, -84.33f, - -82.42f, -84.3f, -82.39f, -84.26f, -82.3f, -84.13f, -82.28f, -84.08f, -82.25f, -83.98f, - -82.24f, -83.93f, -82.23f, -83.83f, -82.23f, -83.78f, -82.24f, -83.1f, -82.26f, -83.05f, - -82.29f, -83.01f, -82.33f, -82.97f, -82.38f, -82.95f, -}; - -constexpr std::array<float, 47 * 2> left_joycon_slider = { - -23.7f, -118.2f, -23.7f, -117.3f, -23.7f, 96.6f, -22.8f, 96.6f, -21.5f, 97.2f, -21.5f, - 98.1f, -21.2f, 106.7f, -20.8f, 107.5f, -20.1f, 108.2f, -19.2f, 108.2f, -16.4f, 108.1f, - -15.8f, 107.5f, -15.8f, 106.5f, -15.8f, 62.8f, -16.3f, 61.9f, -15.8f, 61.0f, -17.3f, - 60.3f, -19.1f, 58.9f, -19.1f, 58.1f, -19.1f, 57.2f, -19.1f, 34.5f, -17.9f, 33.9f, - -17.2f, 33.2f, -16.6f, 32.4f, -16.2f, 31.6f, -15.8f, 30.7f, -15.8f, 29.7f, -15.8f, - 28.8f, -15.8f, -46.4f, -16.3f, -47.3f, -15.8f, -48.1f, -17.4f, -48.8f, -19.1f, -49.4f, - -19.1f, -50.1f, -19.1f, -51.0f, -19.1f, -51.9f, -19.1f, -73.7f, -19.1f, -74.5f, -17.5f, - -75.2f, -16.4f, -76.7f, -16.0f, -77.6f, -15.8f, -78.5f, -15.8f, -79.4f, -15.8f, -80.4f, - -15.8f, -118.2f, -15.8f, -118.2f, -18.3f, -118.2f, -}; - -constexpr std::array<float, 66 * 2> left_joycon_sideview = { - -158.8f, -133.5f, -159.8f, -133.5f, -173.5f, -133.3f, -174.5f, -133.0f, -175.4f, -132.6f, - -176.2f, -132.1f, -177.0f, -131.5f, -177.7f, -130.9f, -178.3f, -130.1f, -179.4f, -128.5f, - -179.8f, -127.6f, -180.4f, -125.7f, -180.6f, -124.7f, -180.7f, -123.8f, -180.7f, -122.8f, - -180.0f, 128.8f, -179.6f, 129.7f, -179.1f, 130.5f, -177.9f, 132.1f, -177.2f, 132.7f, - -176.4f, 133.3f, -175.6f, 133.8f, -174.7f, 134.3f, -173.8f, 134.6f, -172.8f, 134.8f, - -170.9f, 135.0f, -169.9f, 135.0f, -156.1f, 134.8f, -155.2f, 134.6f, -154.2f, 134.3f, - -153.3f, 134.0f, -152.4f, 133.6f, -151.6f, 133.1f, -150.7f, 132.6f, -149.9f, 132.0f, - -149.2f, 131.4f, -148.5f, 130.7f, -147.1f, 129.2f, -146.5f, 128.5f, -146.0f, 127.7f, - -145.5f, 126.8f, -145.0f, 126.0f, -144.6f, 125.1f, -144.2f, 124.1f, -143.9f, 123.2f, - -143.7f, 122.2f, -143.6f, 121.3f, -143.5f, 120.3f, -143.5f, 119.3f, -144.4f, -123.4f, - -144.8f, -124.3f, -145.3f, -125.1f, -145.8f, -126.0f, -146.3f, -126.8f, -147.0f, -127.5f, - -147.6f, -128.3f, -148.3f, -129.0f, -149.0f, -129.6f, -149.8f, -130.3f, -150.6f, -130.8f, - -151.4f, -131.4f, -152.2f, -131.9f, -153.1f, -132.3f, -155.9f, -133.3f, -156.8f, -133.5f, - -157.8f, -133.5f, -}; - -constexpr std::array<float, 40 * 2> left_joycon_body_trigger = { - -146.1f, -124.3f, -146.0f, -122.0f, -145.8f, -119.7f, -145.7f, -117.4f, -145.4f, -112.8f, - -145.3f, -110.5f, -145.0f, -105.9f, -144.9f, -103.6f, -144.6f, -99.1f, -144.5f, -96.8f, - -144.5f, -89.9f, -144.5f, -87.6f, -144.5f, -83.0f, -144.5f, -80.7f, -144.5f, -80.3f, - -142.4f, -82.4f, -141.4f, -84.5f, -140.2f, -86.4f, -138.8f, -88.3f, -137.4f, -90.1f, - -134.5f, -93.6f, -133.0f, -95.3f, -130.0f, -98.8f, -128.5f, -100.6f, -127.1f, -102.4f, - -125.8f, -104.3f, -124.7f, -106.3f, -123.9f, -108.4f, -125.1f, -110.2f, -127.4f, -110.3f, - -129.7f, -110.3f, -134.2f, -110.5f, -136.4f, -111.4f, -138.1f, -112.8f, -139.4f, -114.7f, - -140.5f, -116.8f, -141.4f, -118.9f, -143.3f, -123.1f, -144.6f, -124.9f, -146.2f, -126.0f, -}; - -constexpr std::array<float, 49 * 2> left_joycon_topview = { - -184.8f, -20.8f, -185.6f, -21.1f, -186.4f, -21.5f, -187.1f, -22.1f, -187.8f, -22.6f, - -188.4f, -23.2f, -189.6f, -24.5f, -190.2f, -25.2f, -190.7f, -25.9f, -191.1f, -26.7f, - -191.4f, -27.5f, -191.6f, -28.4f, -191.7f, -29.2f, -191.7f, -30.1f, -191.5f, -47.7f, - -191.2f, -48.5f, -191.0f, -49.4f, -190.7f, -50.2f, -190.3f, -51.0f, -190.0f, -51.8f, - -189.6f, -52.6f, -189.1f, -53.4f, -188.6f, -54.1f, -187.5f, -55.4f, -186.9f, -56.1f, - -186.2f, -56.7f, -185.5f, -57.2f, -184.0f, -58.1f, -183.3f, -58.5f, -182.5f, -58.9f, - -181.6f, -59.2f, -180.8f, -59.5f, -179.9f, -59.7f, -179.1f, -59.9f, -178.2f, -60.0f, - -174.7f, -60.1f, -168.5f, -60.2f, -162.4f, -60.3f, -156.2f, -60.4f, -149.2f, -60.5f, - -143.0f, -60.6f, -136.9f, -60.7f, -130.7f, -60.8f, -123.7f, -60.9f, -117.5f, -61.0f, - -110.5f, -61.1f, -94.4f, -60.4f, -94.4f, -59.5f, -94.4f, -20.6f, -}; - -constexpr std::array<float, 41 * 2> left_joycon_slider_topview = { - -95.1f, -51.5f, -95.0f, -51.5f, -91.2f, -51.6f, -91.2f, -51.7f, -91.1f, -52.4f, -91.1f, -52.6f, - -91.0f, -54.1f, -86.3f, -54.0f, -86.0f, -53.9f, -85.9f, -53.8f, -85.6f, -53.4f, -85.5f, -53.2f, - -85.5f, -53.1f, -85.4f, -52.9f, -85.4f, -52.8f, -85.3f, -52.4f, -85.3f, -52.3f, -85.4f, -27.2f, - -85.4f, -27.1f, -85.5f, -27.0f, -85.5f, -26.9f, -85.6f, -26.7f, -85.6f, -26.6f, -85.7f, -26.5f, - -85.9f, -26.4f, -86.0f, -26.3f, -86.4f, -26.0f, -86.5f, -25.9f, -86.7f, -25.8f, -87.1f, -25.7f, - -90.4f, -25.8f, -90.7f, -25.9f, -90.8f, -26.0f, -90.9f, -26.3f, -91.0f, -26.4f, -91.0f, -26.5f, - -91.1f, -26.7f, -91.1f, -26.9f, -91.2f, -28.9f, -95.2f, -29.1f, -95.2f, -29.2f, -}; - -constexpr std::array<float, 42 * 2> left_joycon_sideview_zl = { - -148.9f, -128.2f, -148.7f, -126.6f, -148.4f, -124.9f, -148.2f, -123.3f, -147.9f, -121.7f, - -147.7f, -120.1f, -147.4f, -118.5f, -147.2f, -116.9f, -146.9f, -115.3f, -146.4f, -112.1f, - -146.1f, -110.5f, -145.9f, -108.9f, -145.6f, -107.3f, -144.2f, -107.3f, -142.6f, -107.5f, - -141.0f, -107.8f, -137.8f, -108.3f, -136.2f, -108.6f, -131.4f, -109.4f, -129.8f, -109.7f, - -125.6f, -111.4f, -124.5f, -112.7f, -123.9f, -114.1f, -123.8f, -115.8f, -123.8f, -117.4f, - -123.9f, -120.6f, -124.5f, -122.1f, -125.8f, -123.1f, -127.4f, -123.4f, -129.0f, -123.6f, - -130.6f, -124.0f, -132.1f, -124.4f, -133.7f, -124.8f, -135.3f, -125.3f, -136.8f, -125.9f, - -138.3f, -126.4f, -139.9f, -126.9f, -141.4f, -127.5f, -142.9f, -128.0f, -144.5f, -128.5f, - -146.0f, -129.0f, -147.6f, -129.4f, -}; - -constexpr std::array<float, 72 * 2> left_joystick_sideview = { - -14.7f, -3.8f, -15.2f, -5.6f, -15.2f, -7.6f, -15.5f, -17.6f, -17.4f, -18.3f, -19.4f, -18.2f, - -21.3f, -17.6f, -22.8f, -16.4f, -23.4f, -14.5f, -23.4f, -12.5f, -24.1f, -8.6f, -24.8f, -6.7f, - -25.3f, -4.8f, -25.7f, -2.8f, -25.9f, -0.8f, -26.0f, 1.2f, -26.0f, 3.2f, -25.8f, 5.2f, - -25.5f, 7.2f, -25.0f, 9.2f, -24.4f, 11.1f, -23.7f, 13.0f, -23.4f, 14.9f, -23.4f, 16.9f, - -23.3f, 18.9f, -22.0f, 20.5f, -20.2f, 21.3f, -18.3f, 21.6f, -16.3f, 21.4f, -15.3f, 19.9f, - -15.3f, 17.8f, -15.2f, 7.8f, -13.5f, 6.4f, -12.4f, 7.2f, -11.4f, 8.9f, -10.2f, 10.5f, - -8.7f, 11.8f, -7.1f, 13.0f, -5.3f, 14.0f, -3.5f, 14.7f, -1.5f, 15.0f, 0.5f, 15.0f, - 2.5f, 14.7f, 4.4f, 14.2f, 6.3f, 13.4f, 8.0f, 12.4f, 9.6f, 11.1f, 10.9f, 9.6f, - 12.0f, 7.9f, 12.7f, 6.0f, 13.2f, 4.1f, 13.3f, 2.1f, 13.2f, 0.1f, 12.9f, -1.9f, - 12.2f, -3.8f, 11.3f, -5.6f, 10.2f, -7.2f, 8.8f, -8.6f, 7.1f, -9.8f, 5.4f, -10.8f, - 3.5f, -11.5f, 1.5f, -11.9f, -0.5f, -12.0f, -2.5f, -11.8f, -4.4f, -11.3f, -6.2f, -10.4f, - -8.0f, -9.4f, -9.6f, -8.2f, -10.9f, -6.7f, -11.9f, -4.9f, -12.8f, -3.2f, -13.5f, -3.8f, -}; - -constexpr std::array<float, 63 * 2> left_joystick_L_topview = { - -186.7f, -43.7f, -186.4f, -43.7f, -110.6f, -43.4f, -110.6f, -43.1f, -110.7f, -34.3f, - -110.7f, -34.0f, -110.8f, -33.7f, -111.1f, -32.9f, -111.2f, -32.6f, -111.4f, -32.3f, - -111.5f, -32.1f, -111.7f, -31.8f, -111.8f, -31.5f, -112.0f, -31.3f, -112.2f, -31.0f, - -112.4f, -30.8f, -112.8f, -30.3f, -113.0f, -30.1f, -114.1f, -29.1f, -114.3f, -28.9f, - -114.6f, -28.7f, -114.8f, -28.6f, -115.1f, -28.4f, -115.3f, -28.3f, -115.6f, -28.1f, - -115.9f, -28.0f, -116.4f, -27.8f, -116.7f, -27.7f, -117.3f, -27.6f, -117.6f, -27.5f, - -182.9f, -27.6f, -183.5f, -27.7f, -183.8f, -27.8f, -184.4f, -27.9f, -184.6f, -28.1f, - -184.9f, -28.2f, -185.4f, -28.5f, -185.7f, -28.7f, -185.9f, -28.8f, -186.2f, -29.0f, - -186.4f, -29.2f, -187.0f, -29.9f, -187.2f, -30.1f, -187.6f, -30.6f, -187.8f, -30.8f, - -187.9f, -31.1f, -188.1f, -31.3f, -188.2f, -31.6f, -188.4f, -31.9f, -188.5f, -32.1f, - -188.6f, -32.4f, -188.8f, -33.3f, -188.9f, -33.6f, -188.9f, -33.9f, -188.8f, -39.9f, - -188.8f, -40.2f, -188.7f, -41.1f, -188.7f, -41.4f, -188.6f, -41.7f, -188.0f, -43.1f, - -187.9f, -43.4f, -187.6f, -43.6f, -187.3f, -43.7f, -}; - -constexpr std::array<float, 44 * 2> left_joystick_ZL_topview = { - -179.4f, -53.3f, -177.4f, -53.3f, -111.2f, -53.3f, -111.3f, -53.3f, -111.5f, -58.6f, - -111.8f, -60.5f, -112.2f, -62.4f, -113.1f, -66.1f, -113.8f, -68.0f, -114.5f, -69.8f, - -115.3f, -71.5f, -116.3f, -73.2f, -117.3f, -74.8f, -118.5f, -76.4f, -119.8f, -77.8f, - -121.2f, -79.1f, -122.8f, -80.2f, -124.4f, -81.2f, -126.2f, -82.0f, -128.1f, -82.6f, - -130.0f, -82.9f, -131.9f, -83.0f, -141.5f, -82.9f, -149.3f, -82.8f, -153.1f, -82.6f, - -155.0f, -82.1f, -156.8f, -81.6f, -158.7f, -80.9f, -160.4f, -80.2f, -162.2f, -79.3f, - -163.8f, -78.3f, -165.4f, -77.2f, -166.9f, -76.0f, -168.4f, -74.7f, -169.7f, -73.3f, - -172.1f, -70.3f, -173.2f, -68.7f, -174.2f, -67.1f, -175.2f, -65.4f, -176.1f, -63.7f, - -178.7f, -58.5f, -179.6f, -56.8f, -180.4f, -55.1f, -181.3f, -53.3f, -}; - -void PlayerControlPreview::DrawProBody(QPainter& p, const QPointF center) { - std::array<QPointF, pro_left_handle.size() / 2> qleft_handle; - std::array<QPointF, pro_left_handle.size() / 2> qright_handle; - std::array<QPointF, pro_body.size()> qbody; - constexpr int radius1 = 32; - - for (std::size_t point = 0; point < pro_left_handle.size() / 2; ++point) { - const float left_x = pro_left_handle[point * 2 + 0]; - const float left_y = pro_left_handle[point * 2 + 1]; - - qleft_handle[point] = center + QPointF(left_x, left_y); - qright_handle[point] = center + QPointF(-left_x, left_y); - } - for (std::size_t point = 0; point < pro_body.size() / 2; ++point) { - const float body_x = pro_body[point * 2 + 0]; - const float body_y = pro_body[point * 2 + 1]; - - qbody[point] = center + QPointF(body_x, body_y); - qbody[pro_body.size() - 1 - point] = center + QPointF(-body_x, body_y); - } - - // Draw left handle body - p.setPen(colors.outline); - p.setBrush(colors.left); - DrawPolygon(p, qleft_handle); - - // Draw right handle body - p.setBrush(colors.right); - DrawPolygon(p, qright_handle); - - // Draw body - p.setBrush(colors.primary); - DrawPolygon(p, qbody); - - // Draw joycon circles - p.setBrush(colors.transparent); - p.drawEllipse(center + QPoint(-111, -55), radius1, radius1); - p.drawEllipse(center + QPoint(51, 0), radius1, radius1); -} - -void PlayerControlPreview::DrawGCBody(QPainter& p, const QPointF center) { - std::array<QPointF, gc_left_body.size() / 2> qleft_handle; - std::array<QPointF, gc_left_body.size() / 2> qright_handle; - std::array<QPointF, gc_body.size()> qbody; - std::array<QPointF, 8> left_hex; - std::array<QPointF, 8> right_hex; - constexpr float angle = 2 * 3.1415f / 8; - - for (std::size_t point = 0; point < gc_left_body.size() / 2; ++point) { - const float body_x = gc_left_body[point * 2 + 0]; - const float body_y = gc_left_body[point * 2 + 1]; - - qleft_handle[point] = center + QPointF(body_x, body_y); - qright_handle[point] = center + QPointF(-body_x, body_y); - } - for (std::size_t point = 0; point < gc_body.size() / 2; ++point) { - const float body_x = gc_body[point * 2 + 0]; - const float body_y = gc_body[point * 2 + 1]; - - qbody[point] = center + QPointF(body_x, body_y); - qbody[gc_body.size() - 1 - point] = center + QPointF(-body_x, body_y); - } - for (std::size_t point = 0; point < 8; ++point) { - const float point_cos = std::cos(point * angle); - const float point_sin = std::sin(point * angle); - - left_hex[point] = center + QPointF(34 * point_cos - 111, 34 * point_sin - 44); - right_hex[point] = center + QPointF(26 * point_cos + 61, 26 * point_sin + 37); - } - - // Draw body - p.setPen(colors.outline); - p.setBrush(colors.primary); - DrawPolygon(p, qbody); - - // Draw left handle body - p.setBrush(colors.left); - DrawPolygon(p, qleft_handle); - - // Draw right handle body - p.setBrush(colors.right); - DrawPolygon(p, qright_handle); - - DrawText(p, center + QPoint(0, -58), 4.7f, tr("START/PAUSE")); - - // Draw right joystick body - p.setBrush(colors.button); - DrawCircle(p, center + QPointF(61, 37), 23.5f); - - // Draw joystick details - p.setBrush(colors.transparent); - DrawPolygon(p, left_hex); - DrawPolygon(p, right_hex); -} - -void PlayerControlPreview::DrawHandheldBody(QPainter& p, const QPointF center) { - const std::size_t body_outline_end = handheld_body.size() / 2 - 6; - const std::size_t bezel_outline_end = handheld_bezel.size() / 2 - 6; - const std::size_t bezel_inline_size = 4; - const std::size_t bezel_inline_start = 35; - std::array<QPointF, left_joycon_body.size() / 2> left_joycon; - std::array<QPointF, left_joycon_body.size() / 2> right_joycon; - std::array<QPointF, handheld_body.size() / 2> qhandheld_body; - std::array<QPointF, body_outline_end> qhandheld_body_outline; - std::array<QPointF, handheld_bezel.size() / 2> qhandheld_bezel; - std::array<QPointF, bezel_inline_size> qhandheld_bezel_inline; - std::array<QPointF, bezel_outline_end> qhandheld_bezel_outline; - std::array<QPointF, handheld_buttons.size() / 2> qhandheld_buttons; - - for (std::size_t point = 0; point < left_joycon_body.size() / 2; ++point) { - left_joycon[point] = - center + QPointF(left_joycon_body[point * 2], left_joycon_body[point * 2 + 1]); - right_joycon[point] = - center + QPointF(-left_joycon_body[point * 2], left_joycon_body[point * 2 + 1]); - } - for (std::size_t point = 0; point < body_outline_end; ++point) { - qhandheld_body_outline[point] = - center + QPointF(handheld_body[point * 2], handheld_body[point * 2 + 1]); - } - for (std::size_t point = 0; point < handheld_body.size() / 2; ++point) { - qhandheld_body[point] = - center + QPointF(handheld_body[point * 2], handheld_body[point * 2 + 1]); - } - for (std::size_t point = 0; point < handheld_bezel.size() / 2; ++point) { - qhandheld_bezel[point] = - center + QPointF(handheld_bezel[point * 2], handheld_bezel[point * 2 + 1]); - } - for (std::size_t point = 0; point < bezel_outline_end; ++point) { - qhandheld_bezel_outline[point] = - center + QPointF(handheld_bezel[point * 2], handheld_bezel[point * 2 + 1]); - } - for (std::size_t point = 0; point < bezel_inline_size; ++point) { - qhandheld_bezel_inline[point] = - center + QPointF(handheld_bezel[(point + bezel_inline_start) * 2], - handheld_bezel[(point + bezel_inline_start) * 2 + 1]); - } - for (std::size_t point = 0; point < handheld_buttons.size() / 2; ++point) { - qhandheld_buttons[point] = - center + QPointF(handheld_buttons[point * 2], handheld_buttons[point * 2 + 1]); - } - - // Draw left joycon - p.setPen(colors.outline); - p.setBrush(colors.left); - DrawPolygon(p, left_joycon); - - // Draw right joycon - p.setPen(colors.outline); - p.setBrush(colors.right); - DrawPolygon(p, right_joycon); - - // Draw Handheld buttons - p.setPen(colors.outline); - p.setBrush(colors.button); - DrawPolygon(p, qhandheld_buttons); - - // Draw handheld body - p.setPen(colors.transparent); - p.setBrush(colors.primary); - DrawPolygon(p, qhandheld_body); - p.setPen(colors.outline); - p.setBrush(colors.transparent); - DrawPolygon(p, qhandheld_body_outline); - - // Draw Handheld bezel - p.setPen(colors.transparent); - p.setBrush(colors.button); - DrawPolygon(p, qhandheld_bezel); - p.setPen(colors.outline); - p.setBrush(colors.transparent); - DrawPolygon(p, qhandheld_bezel_outline); - DrawPolygon(p, qhandheld_bezel_inline); -} - -void PlayerControlPreview::DrawDualBody(QPainter& p, const QPointF center) { - std::array<QPointF, left_joycon_body.size() / 2> left_joycon; - std::array<QPointF, left_joycon_body.size() / 2> right_joycon; - std::array<QPointF, left_joycon_slider.size() / 2> qleft_joycon_slider; - std::array<QPointF, left_joycon_slider.size() / 2> qright_joycon_slider; - std::array<QPointF, left_joycon_slider_topview.size() / 2> qleft_joycon_slider_topview; - std::array<QPointF, left_joycon_slider_topview.size() / 2> qright_joycon_slider_topview; - std::array<QPointF, left_joycon_topview.size() / 2> qleft_joycon_topview; - std::array<QPointF, left_joycon_topview.size() / 2> qright_joycon_topview; - constexpr float size = 1.61f; - constexpr float size2 = 0.9f; - constexpr float offset = 209.3f; - - for (std::size_t point = 0; point < left_joycon_body.size() / 2; ++point) { - const float body_x = left_joycon_body[point * 2 + 0]; - const float body_y = left_joycon_body[point * 2 + 1]; - - left_joycon[point] = center + QPointF(body_x * size + offset, body_y * size - 1); - right_joycon[point] = center + QPointF(-body_x * size - offset, body_y * size - 1); - } - for (std::size_t point = 0; point < left_joycon_slider.size() / 2; ++point) { - const float slider_x = left_joycon_slider[point * 2 + 0]; - const float slider_y = left_joycon_slider[point * 2 + 1]; - - qleft_joycon_slider[point] = center + QPointF(slider_x, slider_y); - qright_joycon_slider[point] = center + QPointF(-slider_x, slider_y); - } - for (std::size_t point = 0; point < left_joycon_topview.size() / 2; ++point) { - const float top_view_x = left_joycon_topview[point * 2 + 0]; - const float top_view_y = left_joycon_topview[point * 2 + 1]; - - qleft_joycon_topview[point] = - center + QPointF(top_view_x * size2 - 52, top_view_y * size2 - 52); - qright_joycon_topview[point] = - center + QPointF(-top_view_x * size2 + 52, top_view_y * size2 - 52); - } - for (std::size_t point = 0; point < left_joycon_slider_topview.size() / 2; ++point) { - const float top_view_x = left_joycon_slider_topview[point * 2 + 0]; - const float top_view_y = left_joycon_slider_topview[point * 2 + 1]; - - qleft_joycon_slider_topview[point] = - center + QPointF(top_view_x * size2 - 52, top_view_y * size2 - 52); - qright_joycon_slider_topview[point] = - center + QPointF(-top_view_x * size2 + 52, top_view_y * size2 - 52); - } - - // right joycon body - p.setPen(colors.outline); - p.setBrush(colors.right); - DrawPolygon(p, right_joycon); - - // Left joycon body - p.setPen(colors.outline); - p.setBrush(colors.left); - DrawPolygon(p, left_joycon); - - // Slider release button top view - p.setBrush(colors.button); - DrawRoundRectangle(p, center + QPoint(-149, -108), 12, 11, 2); - DrawRoundRectangle(p, center + QPoint(149, -108), 12, 11, 2); - - // Joycon slider top view - p.setBrush(colors.slider); - DrawPolygon(p, qleft_joycon_slider_topview); - p.drawLine(center + QPointF(-133.8f, -99.0f), center + QPointF(-133.8f, -78.5f)); - DrawPolygon(p, qright_joycon_slider_topview); - p.drawLine(center + QPointF(133.8f, -99.0f), center + QPointF(133.8f, -78.5f)); - - // Joycon body top view - p.setBrush(colors.left); - DrawPolygon(p, qleft_joycon_topview); - p.setBrush(colors.right); - DrawPolygon(p, qright_joycon_topview); - - // Right Sideview body - p.setBrush(colors.slider); - DrawPolygon(p, qright_joycon_slider); - - // Left Sideview body - p.setBrush(colors.slider); - DrawPolygon(p, qleft_joycon_slider); -} - -void PlayerControlPreview::DrawLeftBody(QPainter& p, const QPointF center) { - std::array<QPointF, left_joycon_body.size() / 2> left_joycon; - std::array<QPointF, left_joycon_sideview.size() / 2> qleft_joycon_sideview; - std::array<QPointF, left_joycon_body_trigger.size() / 2> qleft_joycon_trigger; - std::array<QPointF, left_joycon_slider.size() / 2> qleft_joycon_slider; - std::array<QPointF, left_joycon_slider_topview.size() / 2> qleft_joycon_slider_topview; - std::array<QPointF, left_joycon_topview.size() / 2> qleft_joycon_topview; - constexpr float size = 1.78f; - constexpr float size2 = 1.1115f; - constexpr float offset = 312.39f; - constexpr float offset2 = 335; - - for (std::size_t point = 0; point < left_joycon_body.size() / 2; ++point) { - left_joycon[point] = center + QPointF(left_joycon_body[point * 2] * size + offset, - left_joycon_body[point * 2 + 1] * size - 1); - } - - for (std::size_t point = 0; point < left_joycon_sideview.size() / 2; ++point) { - qleft_joycon_sideview[point] = - center + QPointF(left_joycon_sideview[point * 2] * size2 + offset2, - left_joycon_sideview[point * 2 + 1] * size2 + 2); - } - for (std::size_t point = 0; point < left_joycon_slider.size() / 2; ++point) { - qleft_joycon_slider[point] = center + QPointF(left_joycon_slider[point * 2] * size2 + 81, - left_joycon_slider[point * 2 + 1] * size2); - } - for (std::size_t point = 0; point < left_joycon_body_trigger.size() / 2; ++point) { - qleft_joycon_trigger[point] = - center + QPointF(left_joycon_body_trigger[point * 2] * size2 + offset2, - left_joycon_body_trigger[point * 2 + 1] * size2 + 2); - } - for (std::size_t point = 0; point < left_joycon_topview.size() / 2; ++point) { - qleft_joycon_topview[point] = - center + QPointF(left_joycon_topview[point * 2], left_joycon_topview[point * 2 + 1]); - } - for (std::size_t point = 0; point < left_joycon_slider_topview.size() / 2; ++point) { - qleft_joycon_slider_topview[point] = - center + QPointF(left_joycon_slider_topview[point * 2], - left_joycon_slider_topview[point * 2 + 1]); - } - - // Joycon body - p.setPen(colors.outline); - p.setBrush(colors.left); - DrawPolygon(p, left_joycon); - DrawPolygon(p, qleft_joycon_trigger); - - // Slider release button top view - p.setBrush(colors.button); - DrawRoundRectangle(p, center + QPoint(-107, -62), 14, 12, 2); - - // Joycon slider top view - p.setBrush(colors.slider); - DrawPolygon(p, qleft_joycon_slider_topview); - p.drawLine(center + QPointF(-91.1f, -51.7f), center + QPointF(-91.1f, -26.5f)); - - // Joycon body top view - p.setBrush(colors.left); - DrawPolygon(p, qleft_joycon_topview); - - // Slider release button - p.setBrush(colors.button); - DrawRoundRectangle(p, center + QPoint(175, -110), 12, 14, 2); - - // Sideview body - p.setBrush(colors.left); - DrawPolygon(p, qleft_joycon_sideview); - p.setBrush(colors.slider); - DrawPolygon(p, qleft_joycon_slider); - - const QPointF sideview_center = QPointF(155, 0) + center; - - // Sideview slider body - p.setBrush(colors.slider); - DrawRoundRectangle(p, sideview_center + QPointF(0, -5), 28, 253, 3); - p.setBrush(colors.button2); - DrawRoundRectangle(p, sideview_center + QPointF(0, 97), 22.44f, 44.66f, 3); - - // Slider decorations - p.setPen(colors.outline); - p.setBrush(colors.slider_arrow); - DrawArrow(p, sideview_center + QPoint(0, 83), Direction::Down, 2.2f); - DrawArrow(p, sideview_center + QPoint(0, 96), Direction::Down, 2.2f); - DrawArrow(p, sideview_center + QPoint(0, 109), Direction::Down, 2.2f); - DrawCircle(p, sideview_center + QPointF(0, 19), 4.44f); - - // LED indicators - const float led_size = 5.0f; - const QPointF led_position = sideview_center + QPointF(0, -36); - int led_count = 0; - p.setBrush(led_pattern.position1 ? colors.led_on : colors.led_off); - DrawRectangle(p, led_position + QPointF(0, 12 * led_count++), led_size, led_size); - p.setBrush(led_pattern.position2 ? colors.led_on : colors.led_off); - DrawRectangle(p, led_position + QPointF(0, 12 * led_count++), led_size, led_size); - p.setBrush(led_pattern.position3 ? colors.led_on : colors.led_off); - DrawRectangle(p, led_position + QPointF(0, 12 * led_count++), led_size, led_size); - p.setBrush(led_pattern.position4 ? colors.led_on : colors.led_off); - DrawRectangle(p, led_position + QPointF(0, 12 * led_count++), led_size, led_size); -} - -void PlayerControlPreview::DrawRightBody(QPainter& p, const QPointF center) { - std::array<QPointF, left_joycon_body.size() / 2> right_joycon; - std::array<QPointF, left_joycon_sideview.size() / 2> qright_joycon_sideview; - std::array<QPointF, left_joycon_body_trigger.size() / 2> qright_joycon_trigger; - std::array<QPointF, left_joycon_slider.size() / 2> qright_joycon_slider; - std::array<QPointF, left_joycon_slider_topview.size() / 2> qright_joycon_slider_topview; - std::array<QPointF, left_joycon_topview.size() / 2> qright_joycon_topview; - constexpr float size = 1.78f; - constexpr float size2 = 1.1115f; - constexpr float offset = 312.39f; - constexpr float offset2 = 335; - - for (std::size_t point = 0; point < left_joycon_body.size() / 2; ++point) { - right_joycon[point] = center + QPointF(-left_joycon_body[point * 2] * size - offset, - left_joycon_body[point * 2 + 1] * size - 1); - } - - for (std::size_t point = 0; point < left_joycon_sideview.size() / 2; ++point) { - qright_joycon_sideview[point] = - center + QPointF(-left_joycon_sideview[point * 2] * size2 - offset2, - left_joycon_sideview[point * 2 + 1] * size2 + 2); - } - for (std::size_t point = 0; point < left_joycon_body_trigger.size() / 2; ++point) { - qright_joycon_trigger[point] = - center + QPointF(-left_joycon_body_trigger[point * 2] * size2 - offset2, - left_joycon_body_trigger[point * 2 + 1] * size2 + 2); - } - for (std::size_t point = 0; point < left_joycon_slider.size() / 2; ++point) { - qright_joycon_slider[point] = center + QPointF(-left_joycon_slider[point * 2] * size2 - 81, - left_joycon_slider[point * 2 + 1] * size2); - } - for (std::size_t point = 0; point < left_joycon_topview.size() / 2; ++point) { - qright_joycon_topview[point] = - center + QPointF(-left_joycon_topview[point * 2], left_joycon_topview[point * 2 + 1]); - } - for (std::size_t point = 0; point < left_joycon_slider_topview.size() / 2; ++point) { - qright_joycon_slider_topview[point] = - center + QPointF(-left_joycon_slider_topview[point * 2], - left_joycon_slider_topview[point * 2 + 1]); - } - - // Joycon body - p.setPen(colors.outline); - p.setBrush(colors.left); - DrawPolygon(p, right_joycon); - DrawPolygon(p, qright_joycon_trigger); - - // Slider release button top view - p.setBrush(colors.button); - DrawRoundRectangle(p, center + QPoint(107, -62), 14, 12, 2); - - // Joycon slider top view - p.setBrush(colors.slider); - DrawPolygon(p, qright_joycon_slider_topview); - p.drawLine(center + QPointF(91.1f, -51.7f), center + QPointF(91.1f, -26.5f)); - - // Joycon body top view - p.setBrush(colors.left); - DrawPolygon(p, qright_joycon_topview); - - // Slider release button - p.setBrush(colors.button); - DrawRoundRectangle(p, center + QPoint(-175, -110), 12, 14, 2); - - // Sideview body - p.setBrush(colors.left); - DrawPolygon(p, qright_joycon_sideview); - p.setBrush(colors.slider); - DrawPolygon(p, qright_joycon_slider); - - const QPointF sideview_center = QPointF(-155, 0) + center; - - // Sideview slider body - p.setBrush(colors.slider); - DrawRoundRectangle(p, sideview_center + QPointF(0, -5), 28, 253, 3); - p.setBrush(colors.button2); - DrawRoundRectangle(p, sideview_center + QPointF(0, 97), 22.44f, 44.66f, 3); - - // Slider decorations - p.setPen(colors.outline); - p.setBrush(colors.slider_arrow); - DrawArrow(p, sideview_center + QPoint(0, 83), Direction::Down, 2.2f); - DrawArrow(p, sideview_center + QPoint(0, 96), Direction::Down, 2.2f); - DrawArrow(p, sideview_center + QPoint(0, 109), Direction::Down, 2.2f); - DrawCircle(p, sideview_center + QPointF(0, 19), 4.44f); - - // LED indicators - const float led_size = 5.0f; - const QPointF led_position = sideview_center + QPointF(0, -36); - int led_count = 0; - p.setBrush(led_pattern.position1 ? colors.led_on : colors.led_off); - DrawRectangle(p, led_position + QPointF(0, 12 * led_count++), led_size, led_size); - p.setBrush(led_pattern.position2 ? colors.led_on : colors.led_off); - DrawRectangle(p, led_position + QPointF(0, 12 * led_count++), led_size, led_size); - p.setBrush(led_pattern.position3 ? colors.led_on : colors.led_off); - DrawRectangle(p, led_position + QPointF(0, 12 * led_count++), led_size, led_size); - p.setBrush(led_pattern.position4 ? colors.led_on : colors.led_off); - DrawRectangle(p, led_position + QPointF(0, 12 * led_count++), led_size, led_size); -} - -void PlayerControlPreview::DrawProTriggers(QPainter& p, const QPointF center, - const Common::Input::ButtonStatus& left_pressed, - const Common::Input::ButtonStatus& right_pressed) { - std::array<QPointF, pro_left_trigger.size() / 2> qleft_trigger; - std::array<QPointF, pro_left_trigger.size() / 2> qright_trigger; - std::array<QPointF, pro_body_top.size()> qbody_top; - - for (std::size_t point = 0; point < pro_left_trigger.size() / 2; ++point) { - const float trigger_x = pro_left_trigger[point * 2 + 0]; - const float trigger_y = pro_left_trigger[point * 2 + 1]; - - qleft_trigger[point] = - center + QPointF(trigger_x, trigger_y + (left_pressed.value ? 2 : 0)); - qright_trigger[point] = - center + QPointF(-trigger_x, trigger_y + (right_pressed.value ? 2 : 0)); - } - - for (std::size_t point = 0; point < pro_body_top.size() / 2; ++point) { - const float top_x = pro_body_top[point * 2 + 0]; - const float top_y = pro_body_top[point * 2 + 1]; - - qbody_top[pro_body_top.size() - 1 - point] = center + QPointF(-top_x, top_y); - qbody_top[point] = center + QPointF(top_x, top_y); - } - - // Pro body detail - p.setPen(colors.outline); - p.setBrush(colors.primary); - DrawPolygon(p, qbody_top); - - // Left trigger - p.setBrush(left_pressed.value ? colors.highlight : colors.button); - DrawPolygon(p, qleft_trigger); - - // Right trigger - p.setBrush(right_pressed.value ? colors.highlight : colors.button); - DrawPolygon(p, qright_trigger); -} - -void PlayerControlPreview::DrawGCTriggers(QPainter& p, const QPointF center, - Common::Input::TriggerStatus left_trigger, - Common::Input::TriggerStatus right_trigger) { - std::array<QPointF, left_gc_trigger.size() / 2> qleft_trigger; - std::array<QPointF, left_gc_trigger.size() / 2> qright_trigger; - - for (std::size_t point = 0; point < left_gc_trigger.size() / 2; ++point) { - const float trigger_x = left_gc_trigger[point * 2 + 0]; - const float trigger_y = left_gc_trigger[point * 2 + 1]; - - qleft_trigger[point] = - center + QPointF(trigger_x, trigger_y + (left_trigger.analog.value * 10.0f)); - qright_trigger[point] = - center + QPointF(-trigger_x, trigger_y + (right_trigger.analog.value * 10.0f)); - } - - // Left trigger - p.setPen(colors.outline); - p.setBrush(left_trigger.pressed.value ? colors.highlight : colors.button); - DrawPolygon(p, qleft_trigger); - - // Right trigger - p.setBrush(right_trigger.pressed.value ? colors.highlight : colors.button); - DrawPolygon(p, qright_trigger); - - // Draw L text - p.setPen(colors.transparent); - p.setBrush(colors.font); - DrawSymbol(p, center + QPointF(-132, -119 + (left_trigger.analog.value * 10.0f)), Symbol::L, - 1.7f); - - // Draw R text - p.setPen(colors.transparent); - p.setBrush(colors.font); - DrawSymbol(p, center + QPointF(121.5f, -119 + (right_trigger.analog.value * 10.0f)), Symbol::R, - 1.7f); -} - -void PlayerControlPreview::DrawHandheldTriggers(QPainter& p, const QPointF center, - const Common::Input::ButtonStatus& left_pressed, - const Common::Input::ButtonStatus& right_pressed) { - std::array<QPointF, left_joycon_trigger.size() / 2> qleft_trigger; - std::array<QPointF, left_joycon_trigger.size() / 2> qright_trigger; - - for (std::size_t point = 0; point < left_joycon_trigger.size() / 2; ++point) { - const float left_trigger_x = left_joycon_trigger[point * 2 + 0]; - const float left_trigger_y = left_joycon_trigger[point * 2 + 1]; - - qleft_trigger[point] = - center + QPointF(left_trigger_x, left_trigger_y + (left_pressed.value ? 0.5f : 0)); - qright_trigger[point] = - center + QPointF(-left_trigger_x, left_trigger_y + (right_pressed.value ? 0.5f : 0)); - } - - // Left trigger - p.setPen(colors.outline); - p.setBrush(left_pressed.value ? colors.highlight : colors.button); - DrawPolygon(p, qleft_trigger); - - // Right trigger - p.setBrush(right_pressed.value ? colors.highlight : colors.button); - DrawPolygon(p, qright_trigger); -} - -void PlayerControlPreview::DrawDualTriggers(QPainter& p, const QPointF center, - const Common::Input::ButtonStatus& left_pressed, - const Common::Input::ButtonStatus& right_pressed) { - std::array<QPointF, left_joycon_trigger.size() / 2> qleft_trigger; - std::array<QPointF, left_joycon_trigger.size() / 2> qright_trigger; - constexpr float size = 1.62f; - constexpr float offset = 210.6f; - for (std::size_t point = 0; point < left_joycon_trigger.size() / 2; ++point) { - const float left_trigger_x = left_joycon_trigger[point * 2 + 0]; - const float left_trigger_y = left_joycon_trigger[point * 2 + 1]; - - qleft_trigger[point] = - center + QPointF(left_trigger_x * size + offset, - left_trigger_y * size + (left_pressed.value ? 0.5f : 0)); - qright_trigger[point] = - center + QPointF(-left_trigger_x * size - offset, - left_trigger_y * size + (right_pressed.value ? 0.5f : 0)); - } - - // Left trigger - p.setPen(colors.outline); - p.setBrush(left_pressed.value ? colors.highlight : colors.button); - DrawPolygon(p, qleft_trigger); - - // Right trigger - p.setBrush(right_pressed.value ? colors.highlight : colors.button); - DrawPolygon(p, qright_trigger); -} - -void PlayerControlPreview::DrawDualTriggersTopView( - QPainter& p, const QPointF center, const Common::Input::ButtonStatus& left_pressed, - const Common::Input::ButtonStatus& right_pressed) { - std::array<QPointF, left_joystick_L_topview.size() / 2> qleft_trigger; - std::array<QPointF, left_joystick_L_topview.size() / 2> qright_trigger; - constexpr float size = 0.9f; - - for (std::size_t point = 0; point < left_joystick_L_topview.size() / 2; ++point) { - const float top_view_x = left_joystick_L_topview[point * 2 + 0]; - const float top_view_y = left_joystick_L_topview[point * 2 + 1]; - - qleft_trigger[point] = center + QPointF(top_view_x * size - 50, top_view_y * size - 52); - } - for (std::size_t point = 0; point < left_joystick_L_topview.size() / 2; ++point) { - const float top_view_x = left_joystick_L_topview[point * 2 + 0]; - const float top_view_y = left_joystick_L_topview[point * 2 + 1]; - - qright_trigger[point] = center + QPointF(-top_view_x * size + 50, top_view_y * size - 52); - } - - p.setPen(colors.outline); - p.setBrush(left_pressed.value ? colors.highlight : colors.button); - DrawPolygon(p, qleft_trigger); - p.setBrush(right_pressed.value ? colors.highlight : colors.button); - DrawPolygon(p, qright_trigger); - - // Draw L text - p.setPen(colors.transparent); - p.setBrush(colors.font2); - DrawSymbol(p, center + QPointF(-183, -84), Symbol::L, 1.0f); - - // Draw R text - p.setPen(colors.transparent); - p.setBrush(colors.font2); - DrawSymbol(p, center + QPointF(177, -84), Symbol::R, 1.0f); -} - -void PlayerControlPreview::DrawDualZTriggersTopView( - QPainter& p, const QPointF center, const Common::Input::ButtonStatus& left_pressed, - const Common::Input::ButtonStatus& right_pressed) { - std::array<QPointF, left_joystick_ZL_topview.size() / 2> qleft_trigger; - std::array<QPointF, left_joystick_ZL_topview.size() / 2> qright_trigger; - constexpr float size = 0.9f; - - for (std::size_t point = 0; point < left_joystick_ZL_topview.size() / 2; ++point) { - qleft_trigger[point] = - center + QPointF(left_joystick_ZL_topview[point * 2] * size - 52, - left_joystick_ZL_topview[point * 2 + 1] * size - 52); - } - for (std::size_t point = 0; point < left_joystick_ZL_topview.size() / 2; ++point) { - qright_trigger[point] = - center + QPointF(-left_joystick_ZL_topview[point * 2] * size + 52, - left_joystick_ZL_topview[point * 2 + 1] * size - 52); - } - - p.setPen(colors.outline); - p.setBrush(left_pressed.value ? colors.highlight : colors.button); - DrawPolygon(p, qleft_trigger); - p.setBrush(right_pressed.value ? colors.highlight : colors.button); - DrawPolygon(p, qright_trigger); - - // Draw ZL text - p.setPen(colors.transparent); - p.setBrush(colors.font2); - DrawSymbol(p, center + QPointF(-180, -113), Symbol::ZL, 1.0f); - - // Draw ZR text - p.setPen(colors.transparent); - p.setBrush(colors.font2); - DrawSymbol(p, center + QPointF(180, -113), Symbol::ZR, 1.0f); -} - -void PlayerControlPreview::DrawLeftTriggers(QPainter& p, const QPointF center, - const Common::Input::ButtonStatus& left_pressed) { - std::array<QPointF, left_joycon_trigger.size() / 2> qleft_trigger; - constexpr float size = 1.78f; - constexpr float offset = 311.5f; - - for (std::size_t point = 0; point < left_joycon_trigger.size() / 2; ++point) { - qleft_trigger[point] = center + QPointF(left_joycon_trigger[point * 2] * size + offset, - left_joycon_trigger[point * 2 + 1] * size - - (left_pressed.value ? 0.5f : 1.0f)); - } - - p.setPen(colors.outline); - p.setBrush(left_pressed.value ? colors.highlight : colors.button); - DrawPolygon(p, qleft_trigger); -} - -void PlayerControlPreview::DrawLeftZTriggers(QPainter& p, const QPointF center, - const Common::Input::ButtonStatus& left_pressed) { - std::array<QPointF, left_joycon_sideview_zl.size() / 2> qleft_trigger; - constexpr float size = 1.1115f; - constexpr float offset2 = 335; - - for (std::size_t point = 0; point < left_joycon_sideview_zl.size() / 2; ++point) { - qleft_trigger[point] = center + QPointF(left_joycon_sideview_zl[point * 2] * size + offset2, - left_joycon_sideview_zl[point * 2 + 1] * size + - (left_pressed.value ? 1.5f : 1.0f)); - } - - p.setPen(colors.outline); - p.setBrush(left_pressed.value ? colors.highlight : colors.button); - DrawPolygon(p, qleft_trigger); - p.drawArc(center.x() + 158, center.y() + (left_pressed.value ? -203.5f : -204.0f), 77, 77, - 225 * 16, 44 * 16); -} - -void PlayerControlPreview::DrawLeftTriggersTopView( - QPainter& p, const QPointF center, const Common::Input::ButtonStatus& left_pressed) { - std::array<QPointF, left_joystick_L_topview.size() / 2> qleft_trigger; - - for (std::size_t point = 0; point < left_joystick_L_topview.size() / 2; ++point) { - qleft_trigger[point] = center + QPointF(left_joystick_L_topview[point * 2], - left_joystick_L_topview[point * 2 + 1]); - } - - p.setPen(colors.outline); - p.setBrush(left_pressed.value ? colors.highlight : colors.button); - DrawPolygon(p, qleft_trigger); - - // Draw L text - p.setPen(colors.transparent); - p.setBrush(colors.font2); - DrawSymbol(p, center + QPointF(-143, -36), Symbol::L, 1.0f); -} - -void PlayerControlPreview::DrawLeftZTriggersTopView( - QPainter& p, const QPointF center, const Common::Input::ButtonStatus& left_pressed) { - std::array<QPointF, left_joystick_ZL_topview.size() / 2> qleft_trigger; - - for (std::size_t point = 0; point < left_joystick_ZL_topview.size() / 2; ++point) { - qleft_trigger[point] = center + QPointF(left_joystick_ZL_topview[point * 2], - left_joystick_ZL_topview[point * 2 + 1]); - } - - p.setPen(colors.outline); - p.setBrush(left_pressed.value ? colors.highlight : colors.button); - DrawPolygon(p, qleft_trigger); - - // Draw ZL text - p.setPen(colors.transparent); - p.setBrush(colors.font2); - DrawSymbol(p, center + QPointF(-140, -68), Symbol::ZL, 1.0f); -} - -void PlayerControlPreview::DrawRightTriggers(QPainter& p, const QPointF center, - const Common::Input::ButtonStatus& right_pressed) { - std::array<QPointF, left_joycon_trigger.size() / 2> qright_trigger; - constexpr float size = 1.78f; - constexpr float offset = 311.5f; - - for (std::size_t point = 0; point < left_joycon_trigger.size() / 2; ++point) { - qright_trigger[point] = center + QPointF(-left_joycon_trigger[point * 2] * size - offset, - left_joycon_trigger[point * 2 + 1] * size - - (right_pressed.value ? 0.5f : 1.0f)); - } - - p.setPen(colors.outline); - p.setBrush(right_pressed.value ? colors.highlight : colors.button); - DrawPolygon(p, qright_trigger); -} - -void PlayerControlPreview::DrawRightZTriggers(QPainter& p, const QPointF center, - const Common::Input::ButtonStatus& right_pressed) { - std::array<QPointF, left_joycon_sideview_zl.size() / 2> qright_trigger; - constexpr float size = 1.1115f; - constexpr float offset2 = 335; - - for (std::size_t point = 0; point < left_joycon_sideview_zl.size() / 2; ++point) { - qright_trigger[point] = - center + QPointF(-left_joycon_sideview_zl[point * 2] * size - offset2, - left_joycon_sideview_zl[point * 2 + 1] * size + - (right_pressed.value ? 0.5f : 0) + 1); - } - - p.setPen(colors.outline); - p.setBrush(right_pressed.value ? colors.highlight : colors.button); - DrawPolygon(p, qright_trigger); - p.drawArc(center.x() - 236, center.y() + (right_pressed.value ? -203.5f : -204.0f), 77, 77, - 271 * 16, 44 * 16); -} - -void PlayerControlPreview::DrawRightTriggersTopView( - QPainter& p, const QPointF center, const Common::Input::ButtonStatus& right_pressed) { - std::array<QPointF, left_joystick_L_topview.size() / 2> qright_trigger; - - for (std::size_t point = 0; point < left_joystick_L_topview.size() / 2; ++point) { - qright_trigger[point] = center + QPointF(-left_joystick_L_topview[point * 2], - left_joystick_L_topview[point * 2 + 1]); - } - - p.setPen(colors.outline); - p.setBrush(right_pressed.value ? colors.highlight : colors.button); - DrawPolygon(p, qright_trigger); - - // Draw R text - p.setPen(colors.transparent); - p.setBrush(colors.font2); - DrawSymbol(p, center + QPointF(137, -36), Symbol::R, 1.0f); -} - -void PlayerControlPreview::DrawRightZTriggersTopView( - QPainter& p, const QPointF center, const Common::Input::ButtonStatus& right_pressed) { - std::array<QPointF, left_joystick_ZL_topview.size() / 2> qright_trigger; - - for (std::size_t point = 0; point < left_joystick_ZL_topview.size() / 2; ++point) { - qright_trigger[point] = center + QPointF(-left_joystick_ZL_topview[point * 2], - left_joystick_ZL_topview[point * 2 + 1]); - } - - p.setPen(colors.outline); - p.setBrush(right_pressed.value ? colors.highlight : colors.button); - DrawPolygon(p, qright_trigger); - - // Draw ZR text - p.setPen(colors.transparent); - p.setBrush(colors.font2); - DrawSymbol(p, center + QPointF(140, -68), Symbol::ZR, 1.0f); -} - -void PlayerControlPreview::DrawJoystick(QPainter& p, const QPointF center, float size, - const Common::Input::ButtonStatus& pressed) { - const float radius1 = 13.0f * size; - const float radius2 = 9.0f * size; - - // Outer circle - p.setPen(colors.outline); - p.setBrush(pressed.value ? colors.highlight : colors.button); - DrawCircle(p, center, radius1); - - // Cross - p.drawLine(center - QPoint(radius1, 0), center + QPoint(radius1, 0)); - p.drawLine(center - QPoint(0, radius1), center + QPoint(0, radius1)); - - // Inner circle - p.setBrush(pressed.value ? colors.highlight2 : colors.button2); - DrawCircle(p, center, radius2); -} - -void PlayerControlPreview::DrawJoystickSideview(QPainter& p, const QPointF center, float angle, - float size, - const Common::Input::ButtonStatus& pressed) { - QVector<QPointF> joystick; - joystick.reserve(static_cast<int>(left_joystick_sideview.size() / 2)); - - for (std::size_t point = 0; point < left_joystick_sideview.size() / 2; ++point) { - joystick.append(QPointF(left_joystick_sideview[point * 2] * size + (pressed.value ? 1 : 0), - left_joystick_sideview[point * 2 + 1] * size - 1)); - } - - // Rotate joystick - QTransform t; - t.translate(center.x(), center.y()); - t.rotate(18 * angle); - QPolygonF p2 = t.map(QPolygonF(joystick)); - - // Draw joystick - p.setPen(colors.outline); - p.setBrush(pressed.value ? colors.highlight : colors.button); - p.drawPolygon(p2); - p.drawLine(p2.at(1), p2.at(30)); - p.drawLine(p2.at(32), p2.at(71)); -} - -void PlayerControlPreview::DrawProJoystick(QPainter& p, const QPointF center, const QPointF offset, - float offset_scalar, - const Common::Input::ButtonStatus& pressed) { - const float radius1 = 24.0f; - const float radius2 = 17.0f; - - const QPointF offset_center = center + offset * offset_scalar; - - const auto amplitude = static_cast<float>( - 1.0 - std::sqrt((offset.x() * offset.x()) + (offset.y() * offset.y())) * 0.1f); - - const float rotation = - ((offset.x() == 0) ? atan(1) * 2 : atan(offset.y() / offset.x())) * (180 / (atan(1) * 4)); - - p.save(); - p.translate(offset_center); - p.rotate(rotation); - - // Outer circle - p.setPen(colors.outline); - p.setBrush(pressed.value ? colors.highlight : colors.button); - p.drawEllipse(QPointF(0, 0), radius1 * amplitude, radius1); - - // Inner circle - p.setBrush(pressed.value ? colors.highlight2 : colors.button2); - - const float inner_offset = - (radius1 - radius2) * 0.4f * ((offset.x() == 0 && offset.y() < 0) ? -1.0f : 1.0f); - const float offset_factor = (1.0f - amplitude) / 0.1f; - - p.drawEllipse(QPointF((offset.x() < 0) ? -inner_offset : inner_offset, 0) * offset_factor, - radius2 * amplitude, radius2); - - p.restore(); -} - -void PlayerControlPreview::DrawGCJoystick(QPainter& p, const QPointF center, - const Common::Input::ButtonStatus& pressed) { - // Outer circle - p.setPen(colors.outline); - p.setBrush(pressed.value ? colors.highlight : colors.button); - DrawCircle(p, center, 26.0f); - - // Inner circle - p.setBrush(pressed.value ? colors.highlight2 : colors.button2); - DrawCircle(p, center, 19.0f); - p.setBrush(colors.transparent); - DrawCircle(p, center, 13.5f); - DrawCircle(p, center, 7.5f); -} - -void PlayerControlPreview::DrawRawJoystick(QPainter& p, QPointF center_left, QPointF center_right) { - using namespace Settings::NativeAnalog; - if (center_right != QPointF(0, 0)) { - DrawJoystickProperties(p, center_right, stick_values[RStick].x.properties); - p.setPen(colors.indicator); - p.setBrush(colors.indicator); - DrawJoystickDot(p, center_right, stick_values[RStick], true); - p.setPen(colors.indicator2); - p.setBrush(colors.indicator2); - DrawJoystickDot(p, center_right, stick_values[RStick], false); - } - - if (center_left != QPointF(0, 0)) { - DrawJoystickProperties(p, center_left, stick_values[LStick].x.properties); - p.setPen(colors.indicator); - p.setBrush(colors.indicator); - DrawJoystickDot(p, center_left, stick_values[LStick], true); - p.setPen(colors.indicator2); - p.setBrush(colors.indicator2); - DrawJoystickDot(p, center_left, stick_values[LStick], false); - } -} - -void PlayerControlPreview::DrawJoystickProperties( - QPainter& p, const QPointF center, const Common::Input::AnalogProperties& properties) { - constexpr float size = 45.0f; - const float range = size * properties.range; - const float deadzone = size * properties.deadzone; - - // Max range zone circle - p.setPen(colors.outline); - p.setBrush(colors.transparent); - QPen pen = p.pen(); - pen.setStyle(Qt::DotLine); - p.setPen(pen); - DrawCircle(p, center, range); - - // Deadzone circle - pen.setColor(colors.deadzone); - p.setPen(pen); - DrawCircle(p, center, deadzone); -} - -void PlayerControlPreview::DrawJoystickDot(QPainter& p, const QPointF center, - const Common::Input::StickStatus& stick, bool raw) { - constexpr float size = 45.0f; - const float range = size * stick.x.properties.range; - - if (raw) { - const QPointF value = QPointF(stick.x.raw_value, stick.y.raw_value) * size; - DrawCircle(p, center + value, 2); - return; - } - - const QPointF value = QPointF(stick.x.value, stick.y.value) * range; - DrawCircle(p, center + value, 2); -} - -void PlayerControlPreview::DrawRoundButton(QPainter& p, QPointF center, - const Common::Input::ButtonStatus& pressed, float width, - float height, Direction direction, float radius) { - if (pressed.value) { - switch (direction) { - case Direction::Left: - center.setX(center.x() - 1); - break; - case Direction::Right: - center.setX(center.x() + 1); - break; - case Direction::Down: - center.setY(center.y() + 1); - break; - case Direction::Up: - center.setY(center.y() - 1); - break; - case Direction::None: - break; - } - } - QRectF rect = {center.x() - width, center.y() - height, width * 2.0f, height * 2.0f}; - p.setBrush(GetButtonColor(button_color, pressed.value, pressed.turbo)); - p.drawRoundedRect(rect, radius, radius); -} -void PlayerControlPreview::DrawMinusButton(QPainter& p, const QPointF center, - const Common::Input::ButtonStatus& pressed, - int button_size) { - p.setPen(colors.outline); - p.setBrush(GetButtonColor(colors.button, pressed.value, pressed.turbo)); - DrawRectangle(p, center, button_size, button_size / 3.0f); -} -void PlayerControlPreview::DrawPlusButton(QPainter& p, const QPointF center, - const Common::Input::ButtonStatus& pressed, - int button_size) { - // Draw outer line - p.setPen(colors.outline); - p.setBrush(GetButtonColor(colors.button, pressed.value, pressed.turbo)); - DrawRectangle(p, center, button_size, button_size / 3.0f); - DrawRectangle(p, center, button_size / 3.0f, button_size); - - // Scale down size - button_size *= 0.88f; - - // Draw inner color - p.setPen(colors.transparent); - DrawRectangle(p, center, button_size, button_size / 3.0f); - DrawRectangle(p, center, button_size / 3.0f, button_size); -} - -void PlayerControlPreview::DrawGCButtonX(QPainter& p, const QPointF center, - const Common::Input::ButtonStatus& pressed) { - std::array<QPointF, gc_button_x.size() / 2> button_x; - - for (std::size_t point = 0; point < gc_button_x.size() / 2; ++point) { - button_x[point] = center + QPointF(gc_button_x[point * 2], gc_button_x[point * 2 + 1]); - } - - p.setPen(colors.outline); - p.setBrush(GetButtonColor(colors.button, pressed.value, pressed.turbo)); - DrawPolygon(p, button_x); -} - -void PlayerControlPreview::DrawGCButtonY(QPainter& p, const QPointF center, - const Common::Input::ButtonStatus& pressed) { - std::array<QPointF, gc_button_y.size() / 2> button_x; - - for (std::size_t point = 0; point < gc_button_y.size() / 2; ++point) { - button_x[point] = center + QPointF(gc_button_y[point * 2], gc_button_y[point * 2 + 1]); - } - - p.setPen(colors.outline); - p.setBrush(GetButtonColor(colors.button, pressed.value, pressed.turbo)); - DrawPolygon(p, button_x); -} - -void PlayerControlPreview::DrawGCButtonZ(QPainter& p, const QPointF center, - const Common::Input::ButtonStatus& pressed) { - std::array<QPointF, gc_button_z.size() / 2> button_x; - - for (std::size_t point = 0; point < gc_button_z.size() / 2; ++point) { - button_x[point] = center + QPointF(gc_button_z[point * 2], - gc_button_z[point * 2 + 1] + (pressed.value ? 1 : 0)); - } - - p.setPen(colors.outline); - p.setBrush(GetButtonColor(colors.button2, pressed.value, pressed.turbo)); - DrawPolygon(p, button_x); -} - -void PlayerControlPreview::DrawCircleButton(QPainter& p, const QPointF center, - const Common::Input::ButtonStatus& pressed, - float button_size) { - - p.setBrush(GetButtonColor(button_color, pressed.value, pressed.turbo)); - p.drawEllipse(center, button_size, button_size); -} - -void PlayerControlPreview::DrawArrowButtonOutline(QPainter& p, const QPointF center, float size) { - const std::size_t arrow_points = up_arrow_button.size() / 2; - std::array<QPointF, (arrow_points - 1) * 4> arrow_button_outline; - - for (std::size_t point = 0; point < arrow_points - 1; ++point) { - const float up_arrow_x = up_arrow_button[point * 2 + 0]; - const float up_arrow_y = up_arrow_button[point * 2 + 1]; - - arrow_button_outline[point] = center + QPointF(up_arrow_x * size, up_arrow_y * size); - arrow_button_outline[(arrow_points - 1) * 2 - point - 1] = - center + QPointF(up_arrow_y * size, up_arrow_x * size); - arrow_button_outline[(arrow_points - 1) * 2 + point] = - center + QPointF(-up_arrow_x * size, -up_arrow_y * size); - arrow_button_outline[(arrow_points - 1) * 4 - point - 1] = - center + QPointF(-up_arrow_y * size, -up_arrow_x * size); - } - // Draw arrow button outline - p.setPen(colors.outline); - p.setBrush(colors.transparent); - DrawPolygon(p, arrow_button_outline); -} - -void PlayerControlPreview::DrawArrowButton(QPainter& p, const QPointF center, - const Direction direction, - const Common::Input::ButtonStatus& pressed, float size) { - std::array<QPointF, up_arrow_button.size() / 2> arrow_button; - QPoint offset; - - for (std::size_t point = 0; point < up_arrow_button.size() / 2; ++point) { - const float up_arrow_x = up_arrow_button[point * 2 + 0]; - const float up_arrow_y = up_arrow_button[point * 2 + 1]; - - switch (direction) { - case Direction::Up: - arrow_button[point] = center + QPointF(up_arrow_x * size, up_arrow_y * size); - break; - case Direction::Right: - arrow_button[point] = center + QPointF(-up_arrow_y * size, up_arrow_x * size); - break; - case Direction::Down: - arrow_button[point] = center + QPointF(up_arrow_x * size, -up_arrow_y * size); - break; - case Direction::Left: - // Compiler doesn't optimize this correctly check why - arrow_button[point] = center + QPointF(up_arrow_y * size, up_arrow_x * size); - break; - case Direction::None: - break; - } - } - - // Draw arrow button - p.setPen(pressed.value ? colors.highlight : colors.button); - p.setBrush(GetButtonColor(colors.button, pressed.value, pressed.turbo)); - DrawPolygon(p, arrow_button); - - switch (direction) { - case Direction::Up: - offset = QPoint(0, -20 * size); - break; - case Direction::Right: - offset = QPoint(20 * size, 0); - break; - case Direction::Down: - offset = QPoint(0, 20 * size); - break; - case Direction::Left: - offset = QPoint(-20 * size, 0); - break; - case Direction::None: - offset = QPoint(0, 0); - break; - } - - // Draw arrow icon - p.setPen(colors.font2); - p.setBrush(colors.font2); - DrawArrow(p, center + offset, direction, size); -} - -void PlayerControlPreview::DrawTriggerButton(QPainter& p, const QPointF center, - const Direction direction, - const Common::Input::ButtonStatus& pressed) { - std::array<QPointF, trigger_button.size() / 2> qtrigger_button; - - for (std::size_t point = 0; point < trigger_button.size() / 2; ++point) { - const float trigger_button_x = trigger_button[point * 2 + 0]; - const float trigger_button_y = trigger_button[point * 2 + 1]; - - switch (direction) { - case Direction::Left: - qtrigger_button[point] = center + QPointF(-trigger_button_x, trigger_button_y); - break; - case Direction::Right: - qtrigger_button[point] = center + QPointF(trigger_button_x, trigger_button_y); - break; - case Direction::Up: - case Direction::Down: - case Direction::None: - break; - } - } - - // Draw arrow button - p.setPen(colors.outline); - p.setBrush(GetButtonColor(colors.button, pressed.value, pressed.turbo)); - DrawPolygon(p, qtrigger_button); -} - -QColor PlayerControlPreview::GetButtonColor(QColor default_color, bool is_pressed, bool turbo) { - if (is_pressed && turbo) { - return colors.button_turbo; - } - if (is_pressed) { - return colors.highlight; - } - return default_color; -} - -void PlayerControlPreview::DrawBattery(QPainter& p, QPointF center, - Common::Input::BatteryLevel battery) { - if (battery == Common::Input::BatteryLevel::None) { - return; - } - // Draw outline - p.setPen(QPen(colors.button, 5)); - p.setBrush(colors.transparent); - p.drawRoundedRect(center.x(), center.y(), 34, 16, 2, 2); - - p.setPen(QPen(colors.button, 3)); - p.drawRect(center.x() + 35, center.y() + 4.5f, 4, 7); - - // Draw Battery shape - p.setPen(QPen(colors.indicator2, 3)); - p.setBrush(colors.transparent); - p.drawRoundedRect(center.x(), center.y(), 34, 16, 2, 2); - - p.setPen(QPen(colors.indicator2, 1)); - p.setBrush(colors.indicator2); - p.drawRect(center.x() + 35, center.y() + 4.5f, 4, 7); - switch (battery) { - case Common::Input::BatteryLevel::Charging: - p.drawRect(center.x(), center.y(), 34, 16); - p.setPen(colors.slider); - p.setBrush(colors.charging); - DrawSymbol(p, center + QPointF(17.0f, 8.0f), Symbol::Charging, 2.1f); - break; - case Common::Input::BatteryLevel::Full: - p.drawRect(center.x(), center.y(), 34, 16); - break; - case Common::Input::BatteryLevel::Medium: - p.drawRect(center.x(), center.y(), 25, 16); - break; - case Common::Input::BatteryLevel::Low: - p.drawRect(center.x(), center.y(), 17, 16); - break; - case Common::Input::BatteryLevel::Critical: - p.drawRect(center.x(), center.y(), 6, 16); - break; - case Common::Input::BatteryLevel::Empty: - p.drawRect(center.x(), center.y(), 3, 16); - break; - default: - break; - } -} - -void PlayerControlPreview::DrawSymbol(QPainter& p, const QPointF center, Symbol symbol, - float icon_size) { - std::array<QPointF, house.size() / 2> house_icon; - std::array<QPointF, symbol_a.size() / 2> a_icon; - std::array<QPointF, symbol_b.size() / 2> b_icon; - std::array<QPointF, symbol_x.size() / 2> x_icon; - std::array<QPointF, symbol_y.size() / 2> y_icon; - std::array<QPointF, symbol_l.size() / 2> l_icon; - std::array<QPointF, symbol_r.size() / 2> r_icon; - std::array<QPointF, symbol_c.size() / 2> c_icon; - std::array<QPointF, symbol_zl.size() / 2> zl_icon; - std::array<QPointF, symbol_sl.size() / 2> sl_icon; - std::array<QPointF, symbol_zr.size() / 2> zr_icon; - std::array<QPointF, symbol_sr.size() / 2> sr_icon; - std::array<QPointF, symbol_charging.size() / 2> charging_icon; - switch (symbol) { - case Symbol::House: - for (std::size_t point = 0; point < house.size() / 2; ++point) { - house_icon[point] = center + QPointF(house[point * 2] * icon_size, - (house[point * 2 + 1] - 0.025f) * icon_size); - } - p.drawPolygon(house_icon.data(), static_cast<int>(house_icon.size())); - break; - case Symbol::A: - for (std::size_t point = 0; point < symbol_a.size() / 2; ++point) { - a_icon[point] = center + QPointF(symbol_a[point * 2] * icon_size, - symbol_a[point * 2 + 1] * icon_size); - } - p.drawPolygon(a_icon.data(), static_cast<int>(a_icon.size())); - break; - case Symbol::B: - for (std::size_t point = 0; point < symbol_b.size() / 2; ++point) { - b_icon[point] = center + QPointF(symbol_b[point * 2] * icon_size, - symbol_b[point * 2 + 1] * icon_size); - } - p.drawPolygon(b_icon.data(), static_cast<int>(b_icon.size())); - break; - case Symbol::X: - for (std::size_t point = 0; point < symbol_x.size() / 2; ++point) { - x_icon[point] = center + QPointF(symbol_x[point * 2] * icon_size, - symbol_x[point * 2 + 1] * icon_size); - } - p.drawPolygon(x_icon.data(), static_cast<int>(x_icon.size())); - break; - case Symbol::Y: - for (std::size_t point = 0; point < symbol_y.size() / 2; ++point) { - y_icon[point] = center + QPointF(symbol_y[point * 2] * icon_size, - (symbol_y[point * 2 + 1] - 1.0f) * icon_size); - } - p.drawPolygon(y_icon.data(), static_cast<int>(y_icon.size())); - break; - case Symbol::L: - for (std::size_t point = 0; point < symbol_l.size() / 2; ++point) { - l_icon[point] = center + QPointF(symbol_l[point * 2] * icon_size, - (symbol_l[point * 2 + 1] - 1.0f) * icon_size); - } - p.drawPolygon(l_icon.data(), static_cast<int>(l_icon.size())); - break; - case Symbol::R: - for (std::size_t point = 0; point < symbol_r.size() / 2; ++point) { - r_icon[point] = center + QPointF(symbol_r[point * 2] * icon_size, - (symbol_r[point * 2 + 1] - 1.0f) * icon_size); - } - p.drawPolygon(r_icon.data(), static_cast<int>(r_icon.size())); - break; - case Symbol::C: - for (std::size_t point = 0; point < symbol_c.size() / 2; ++point) { - c_icon[point] = center + QPointF(symbol_c[point * 2] * icon_size, - (symbol_c[point * 2 + 1] - 1.0f) * icon_size); - } - p.drawPolygon(c_icon.data(), static_cast<int>(c_icon.size())); - break; - case Symbol::ZL: - for (std::size_t point = 0; point < symbol_zl.size() / 2; ++point) { - zl_icon[point] = center + QPointF(symbol_zl[point * 2] * icon_size, - symbol_zl[point * 2 + 1] * icon_size); - } - p.drawPolygon(zl_icon.data(), static_cast<int>(zl_icon.size())); - break; - case Symbol::SL: - for (std::size_t point = 0; point < symbol_sl.size() / 2; ++point) { - sl_icon[point] = center + QPointF(symbol_sl[point * 2] * icon_size, - symbol_sl[point * 2 + 1] * icon_size); - } - p.drawPolygon(sl_icon.data(), static_cast<int>(sl_icon.size())); - break; - case Symbol::ZR: - for (std::size_t point = 0; point < symbol_zr.size() / 2; ++point) { - zr_icon[point] = center + QPointF(symbol_zr[point * 2] * icon_size, - symbol_zr[point * 2 + 1] * icon_size); - } - p.drawPolygon(zr_icon.data(), static_cast<int>(zr_icon.size())); - break; - case Symbol::SR: - for (std::size_t point = 0; point < symbol_sr.size() / 2; ++point) { - sr_icon[point] = center + QPointF(symbol_sr[point * 2] * icon_size, - symbol_sr[point * 2 + 1] * icon_size); - } - p.drawPolygon(sr_icon.data(), static_cast<int>(sr_icon.size())); - break; - case Symbol::Charging: - for (std::size_t point = 0; point < symbol_charging.size() / 2; ++point) { - charging_icon[point] = center + QPointF(symbol_charging[point * 2] * icon_size, - symbol_charging[point * 2 + 1] * icon_size); - } - p.drawPolygon(charging_icon.data(), static_cast<int>(charging_icon.size())); - break; - } -} - -void PlayerControlPreview::DrawArrow(QPainter& p, const QPointF center, const Direction direction, - float size) { - - std::array<QPointF, up_arrow_symbol.size() / 2> arrow_symbol; - - for (std::size_t point = 0; point < up_arrow_symbol.size() / 2; ++point) { - const float up_arrow_x = up_arrow_symbol[point * 2 + 0]; - const float up_arrow_y = up_arrow_symbol[point * 2 + 1]; - - switch (direction) { - case Direction::Up: - arrow_symbol[point] = center + QPointF(up_arrow_x * size, up_arrow_y * size); - break; - case Direction::Left: - arrow_symbol[point] = center + QPointF(up_arrow_y * size, up_arrow_x * size); - break; - case Direction::Right: - arrow_symbol[point] = center + QPointF(-up_arrow_y * size, up_arrow_x * size); - break; - case Direction::Down: - arrow_symbol[point] = center + QPointF(up_arrow_x * size, -up_arrow_y * size); - break; - case Direction::None: - break; - } - } - - DrawPolygon(p, arrow_symbol); -} - -// Draw motion functions -void PlayerControlPreview::Draw3dCube(QPainter& p, QPointF center, const Common::Vec3f& euler, - float size) { - std::array<Common::Vec3f, 8> cube{ - Common::Vec3f{-0.7f, -1, -0.5f}, - {-0.7f, 1, -0.5f}, - {0.7f, 1, -0.5f}, - {0.7f, -1, -0.5f}, - {-0.7f, -1, 0.5f}, - {-0.7f, 1, 0.5f}, - {0.7f, 1, 0.5f}, - {0.7f, -1, 0.5f}, - }; - - for (Common::Vec3f& point : cube) { - point.RotateFromOrigin(euler.x, euler.y, euler.z); - point *= size; - } - - const std::array<QPointF, 4> front_face{ - center + QPointF{cube[0].x, cube[0].y}, - center + QPointF{cube[1].x, cube[1].y}, - center + QPointF{cube[2].x, cube[2].y}, - center + QPointF{cube[3].x, cube[3].y}, - }; - const std::array<QPointF, 4> back_face{ - center + QPointF{cube[4].x, cube[4].y}, - center + QPointF{cube[5].x, cube[5].y}, - center + QPointF{cube[6].x, cube[6].y}, - center + QPointF{cube[7].x, cube[7].y}, - }; - - DrawPolygon(p, front_face); - DrawPolygon(p, back_face); - p.drawLine(center + QPointF{cube[0].x, cube[0].y}, center + QPointF{cube[4].x, cube[4].y}); - p.drawLine(center + QPointF{cube[1].x, cube[1].y}, center + QPointF{cube[5].x, cube[5].y}); - p.drawLine(center + QPointF{cube[2].x, cube[2].y}, center + QPointF{cube[6].x, cube[6].y}); - p.drawLine(center + QPointF{cube[3].x, cube[3].y}, center + QPointF{cube[7].x, cube[7].y}); -} - -template <size_t N> -void PlayerControlPreview::DrawPolygon(QPainter& p, const std::array<QPointF, N>& polygon) { - p.drawPolygon(polygon.data(), static_cast<int>(polygon.size())); -} - -void PlayerControlPreview::DrawCircle(QPainter& p, const QPointF center, float size) { - p.drawEllipse(center, size, size); -} - -void PlayerControlPreview::DrawRectangle(QPainter& p, const QPointF center, float width, - float height) { - const QRectF rect = QRectF(center.x() - (width / 2), center.y() - (height / 2), width, height); - p.drawRect(rect); -} -void PlayerControlPreview::DrawRoundRectangle(QPainter& p, const QPointF center, float width, - float height, float round) { - const QRectF rect = QRectF(center.x() - (width / 2), center.y() - (height / 2), width, height); - p.drawRoundedRect(rect, round, round); -} - -void PlayerControlPreview::DrawText(QPainter& p, const QPointF center, float text_size, - const QString& text) { - SetTextFont(p, text_size); - const QFontMetrics fm(p.font()); - const QPointF offset = {fm.horizontalAdvance(text) / 2.0f, -text_size / 2.0f}; - p.drawText(center - offset, text); -} - -void PlayerControlPreview::SetTextFont(QPainter& p, float text_size, const QString& font_family) { - QFont font = p.font(); - font.setPointSizeF(text_size); - font.setFamily(font_family); - p.setFont(font); -} diff --git a/src/yuzu/configuration/configure_input_player_widget.h b/src/yuzu/configuration/configure_input_player_widget.h deleted file mode 100644 index 76340912d..000000000 --- a/src/yuzu/configuration/configure_input_player_widget.h +++ /dev/null @@ -1,230 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include <array> -#include <QFrame> -#include <QPointer> - -#include "common/input.h" -#include "common/settings_input.h" -#include "common/vector_math.h" -#include "hid_core/frontend/emulated_controller.h" -#include "hid_core/hid_types.h" - -class QLabel; - -using AnalogParam = std::array<Common::ParamPackage, Settings::NativeAnalog::NumAnalogs>; -using ButtonParam = std::array<Common::ParamPackage, Settings::NativeButton::NumButtons>; - -// Widget for representing controller animations -class PlayerControlPreview : public QFrame { - Q_OBJECT - -public: - explicit PlayerControlPreview(QWidget* parent); - ~PlayerControlPreview() override; - - // Sets the emulated controller to be displayed - void SetController(Core::HID::EmulatedController* controller); - - // Disables events from the emulated controller - void UnloadController(); - - // Starts blinking animation at the button specified - void BeginMappingButton(std::size_t button_id); - - // Starts moving animation at the stick specified - void BeginMappingAnalog(std::size_t stick_id); - - // Stops any ongoing animation - void EndMapping(); - - // Handles emulated controller events - void ControllerUpdate(Core::HID::ControllerTriggerType type); - - // Updates input on scheduled interval - void UpdateInput(); - -protected: - void paintEvent(QPaintEvent* event) override; - -private: - enum class Direction : std::size_t { - None, - Up, - Right, - Down, - Left, - }; - - enum class Symbol { - House, - A, - B, - X, - Y, - L, - R, - C, - SL, - ZL, - ZR, - SR, - Charging, - }; - - struct ColorMapping { - QColor outline{}; - QColor primary{}; - QColor left{}; - QColor right{}; - QColor button{}; - QColor button2{}; - QColor button_turbo{}; - QColor font{}; - QColor font2{}; - QColor highlight{}; - QColor highlight2{}; - QColor transparent{}; - QColor indicator{}; - QColor indicator2{}; - QColor led_on{}; - QColor led_off{}; - QColor slider{}; - QColor slider_button{}; - QColor slider_arrow{}; - QColor deadzone{}; - QColor charging{}; - }; - - void UpdateColors(); - void ResetInputs(); - - // Draw controller functions - void DrawHandheldController(QPainter& p, QPointF center); - void DrawDualController(QPainter& p, QPointF center); - void DrawLeftController(QPainter& p, QPointF center); - void DrawRightController(QPainter& p, QPointF center); - void DrawProController(QPainter& p, QPointF center); - void DrawGCController(QPainter& p, QPointF center); - - // Draw body functions - void DrawHandheldBody(QPainter& p, QPointF center); - void DrawDualBody(QPainter& p, QPointF center); - void DrawLeftBody(QPainter& p, QPointF center); - void DrawRightBody(QPainter& p, QPointF center); - void DrawProBody(QPainter& p, QPointF center); - void DrawGCBody(QPainter& p, QPointF center); - - // Draw triggers functions - void DrawProTriggers(QPainter& p, QPointF center, - const Common::Input::ButtonStatus& left_pressed, - const Common::Input::ButtonStatus& right_pressed); - void DrawGCTriggers(QPainter& p, QPointF center, Common::Input::TriggerStatus left_trigger, - Common::Input::TriggerStatus right_trigger); - void DrawHandheldTriggers(QPainter& p, QPointF center, - const Common::Input::ButtonStatus& left_pressed, - const Common::Input::ButtonStatus& right_pressed); - void DrawDualTriggers(QPainter& p, QPointF center, - const Common::Input::ButtonStatus& left_pressed, - const Common::Input::ButtonStatus& right_pressed); - void DrawDualTriggersTopView(QPainter& p, QPointF center, - const Common::Input::ButtonStatus& left_pressed, - const Common::Input::ButtonStatus& right_pressed); - void DrawDualZTriggersTopView(QPainter& p, QPointF center, - const Common::Input::ButtonStatus& left_pressed, - const Common::Input::ButtonStatus& right_pressed); - void DrawLeftTriggers(QPainter& p, QPointF center, - const Common::Input::ButtonStatus& left_pressed); - void DrawLeftZTriggers(QPainter& p, QPointF center, - const Common::Input::ButtonStatus& left_pressed); - void DrawLeftTriggersTopView(QPainter& p, QPointF center, - const Common::Input::ButtonStatus& left_pressed); - void DrawLeftZTriggersTopView(QPainter& p, QPointF center, - const Common::Input::ButtonStatus& left_pressed); - void DrawRightTriggers(QPainter& p, QPointF center, - const Common::Input::ButtonStatus& right_pressed); - void DrawRightZTriggers(QPainter& p, QPointF center, - const Common::Input::ButtonStatus& right_pressed); - void DrawRightTriggersTopView(QPainter& p, QPointF center, - const Common::Input::ButtonStatus& right_pressed); - void DrawRightZTriggersTopView(QPainter& p, QPointF center, - const Common::Input::ButtonStatus& right_pressed); - - // Draw joystick functions - void DrawJoystick(QPainter& p, QPointF center, float size, - const Common::Input::ButtonStatus& pressed); - void DrawJoystickSideview(QPainter& p, QPointF center, float angle, float size, - const Common::Input::ButtonStatus& pressed); - void DrawRawJoystick(QPainter& p, QPointF center_left, QPointF center_right); - void DrawJoystickProperties(QPainter& p, QPointF center, - const Common::Input::AnalogProperties& properties); - void DrawJoystickDot(QPainter& p, QPointF center, const Common::Input::StickStatus& stick, - bool raw); - void DrawProJoystick(QPainter& p, QPointF center, QPointF offset, float scalar, - const Common::Input::ButtonStatus& pressed); - void DrawGCJoystick(QPainter& p, QPointF center, const Common::Input::ButtonStatus& pressed); - - // Draw button functions - void DrawCircleButton(QPainter& p, QPointF center, const Common::Input::ButtonStatus& pressed, - float button_size); - void DrawRoundButton(QPainter& p, QPointF center, const Common::Input::ButtonStatus& pressed, - float width, float height, Direction direction = Direction::None, - float radius = 2); - void DrawMinusButton(QPainter& p, QPointF center, const Common::Input::ButtonStatus& pressed, - int button_size); - void DrawPlusButton(QPainter& p, QPointF center, const Common::Input::ButtonStatus& pressed, - int button_size); - void DrawGCButtonX(QPainter& p, QPointF center, const Common::Input::ButtonStatus& pressed); - void DrawGCButtonY(QPainter& p, QPointF center, const Common::Input::ButtonStatus& pressed); - void DrawGCButtonZ(QPainter& p, QPointF center, const Common::Input::ButtonStatus& pressed); - void DrawArrowButtonOutline(QPainter& p, const QPointF center, float size = 1.0f); - void DrawArrowButton(QPainter& p, QPointF center, Direction direction, - const Common::Input::ButtonStatus& pressed, float size = 1.0f); - void DrawTriggerButton(QPainter& p, QPointF center, Direction direction, - const Common::Input::ButtonStatus& pressed); - QColor GetButtonColor(QColor default_color, bool is_pressed, bool turbo); - - // Draw battery functions - void DrawBattery(QPainter& p, QPointF center, Common::Input::BatteryLevel battery); - - // Draw icon functions - void DrawSymbol(QPainter& p, QPointF center, Symbol symbol, float icon_size); - void DrawArrow(QPainter& p, QPointF center, Direction direction, float size); - - // Draw motion functions - void Draw3dCube(QPainter& p, QPointF center, const Common::Vec3f& euler, float size); - - // Draw primitive types - template <size_t N> - void DrawPolygon(QPainter& p, const std::array<QPointF, N>& polygon); - void DrawCircle(QPainter& p, QPointF center, float size); - void DrawRectangle(QPainter& p, QPointF center, float width, float height); - void DrawRoundRectangle(QPainter& p, QPointF center, float width, float height, float round); - void DrawText(QPainter& p, QPointF center, float text_size, const QString& text); - void SetTextFont(QPainter& p, float text_size, - const QString& font_family = QStringLiteral("sans-serif")); - - bool is_controller_set{}; - bool is_connected{}; - bool needs_redraw{}; - Core::HID::NpadStyleIndex controller_type; - - bool mapping_active{}; - int blink_counter{}; - int callback_key; - QColor button_color{}; - ColorMapping colors{}; - Core::HID::LedPattern led_pattern{0, 0, 0, 0}; - std::size_t player_index{}; - Core::HID::EmulatedController* controller; - std::size_t button_mapping_index{Settings::NativeButton::NumButtons}; - std::size_t analog_mapping_index{Settings::NativeAnalog::NumAnalogs}; - Core::HID::ButtonValues button_values{}; - Core::HID::SticksValues stick_values{}; - Core::HID::TriggerValues trigger_values{}; - Core::HID::BatteryValues battery_values{}; - Core::HID::MotionState motion_values{}; -}; diff --git a/src/yuzu/configuration/configure_input_profile_dialog.cpp b/src/yuzu/configuration/configure_input_profile_dialog.cpp deleted file mode 100644 index 58dffda51..000000000 --- a/src/yuzu/configuration/configure_input_profile_dialog.cpp +++ /dev/null @@ -1,39 +0,0 @@ -// 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" -#include "yuzu/configuration/configure_input_player.h" -#include "yuzu/configuration/configure_input_profile_dialog.h" - -ConfigureInputProfileDialog::ConfigureInputProfileDialog( - QWidget* parent, InputCommon::InputSubsystem* input_subsystem, InputProfiles* profiles, - Core::System& system) - : QDialog(parent), ui(std::make_unique<Ui::ConfigureInputProfileDialog>()), - profile_widget(new ConfigureInputPlayer(this, 9, nullptr, input_subsystem, profiles, - system.HIDCore(), system.IsPoweredOn(), false)) { - ui->setupUi(this); - - ui->controllerLayout->addWidget(profile_widget); - - connect(ui->clear_all_button, &QPushButton::clicked, this, - [this] { profile_widget->ClearAll(); }); - connect(ui->restore_defaults_button, &QPushButton::clicked, this, - [this] { profile_widget->RestoreDefaults(); }); - - RetranslateUI(); -} - -ConfigureInputProfileDialog::~ConfigureInputProfileDialog() = default; - -void ConfigureInputProfileDialog::changeEvent(QEvent* event) { - if (event->type() == QEvent::LanguageChange) { - RetranslateUI(); - } - - QDialog::changeEvent(event); -} - -void ConfigureInputProfileDialog::RetranslateUI() { - ui->retranslateUi(this); -} diff --git a/src/yuzu/configuration/configure_input_profile_dialog.h b/src/yuzu/configuration/configure_input_profile_dialog.h deleted file mode 100644 index 956cdf954..000000000 --- a/src/yuzu/configuration/configure_input_profile_dialog.h +++ /dev/null @@ -1,43 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include <memory> -#include <QDialog> - -class QPushButton; - -class ConfigureInputPlayer; - -class InputProfiles; - -namespace Core { -class System; -} - -namespace InputCommon { -class InputSubsystem; -} - -namespace Ui { -class ConfigureInputProfileDialog; -} - -class ConfigureInputProfileDialog : public QDialog { - Q_OBJECT - -public: - explicit ConfigureInputProfileDialog(QWidget* parent, - InputCommon::InputSubsystem* input_subsystem, - InputProfiles* profiles, Core::System& system); - ~ConfigureInputProfileDialog() override; - -private: - void changeEvent(QEvent* event) override; - void RetranslateUI(); - - std::unique_ptr<Ui::ConfigureInputProfileDialog> ui; - - ConfigureInputPlayer* profile_widget; -}; diff --git a/src/yuzu/configuration/configure_input_profile_dialog.ui b/src/yuzu/configuration/configure_input_profile_dialog.ui deleted file mode 100644 index 726cf6905..000000000 --- a/src/yuzu/configuration/configure_input_profile_dialog.ui +++ /dev/null @@ -1,71 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>ConfigureInputProfileDialog</class> - <widget class="QDialog" name="ConfigureInputProfileDialog"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>70</width> - <height>540</height> - </rect> - </property> - <property name="windowTitle"> - <string>Create Input Profile</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <property name="spacing"> - <number>2</number> - </property> - <property name="leftMargin"> - <number>9</number> - </property> - <property name="topMargin"> - <number>9</number> - </property> - <property name="rightMargin"> - <number>9</number> - </property> - <property name="bottomMargin"> - <number>9</number> - </property> - <item> - <layout class="QHBoxLayout" name="controllerLayout"/> - </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayout"> - <item> - <widget class="QPushButton" name="clear_all_button"> - <property name="text"> - <string>Clear</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="restore_defaults_button"> - <property name="text"> - <string>Defaults</string> - </property> - </widget> - </item> - <item> - <widget class="QDialogButtonBox" name="buttonBox"> - <property name="standardButtons"> - <set>QDialogButtonBox::Ok</set> - </property> - </widget> - </item> - </layout> - </item> - </layout> - </widget> - <resources/> - <connections> - <connection> - <sender>buttonBox</sender> - <signal>accepted()</signal> - <receiver>ConfigureInputProfileDialog</receiver> - <slot>accept()</slot> - </connection> - </connections> -</ui> diff --git a/src/yuzu/configuration/configure_linux_tab.cpp b/src/yuzu/configuration/configure_linux_tab.cpp deleted file mode 100644 index ab3d18816..000000000 --- a/src/yuzu/configuration/configure_linux_tab.cpp +++ /dev/null @@ -1,75 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include "common/settings.h" -#include "core/core.h" -#include "ui_configure_linux_tab.h" -#include "yuzu/configuration/configuration_shared.h" -#include "yuzu/configuration/configure_linux_tab.h" -#include "yuzu/configuration/shared_widget.h" - -ConfigureLinuxTab::ConfigureLinuxTab(const Core::System& system_, - std::shared_ptr<std::vector<ConfigurationShared::Tab*>> group_, - const ConfigurationShared::Builder& builder, QWidget* parent) - : Tab(group_, parent), ui(std::make_unique<Ui::ConfigureLinuxTab>()), system{system_} { - ui->setupUi(this); - - Setup(builder); - - SetConfiguration(); -} - -ConfigureLinuxTab::~ConfigureLinuxTab() = default; - -void ConfigureLinuxTab::SetConfiguration() {} -void ConfigureLinuxTab::Setup(const ConfigurationShared::Builder& builder) { - QLayout& linux_layout = *ui->linux_widget->layout(); - - std::map<u32, QWidget*> linux_hold{}; - - std::vector<Settings::BasicSetting*> settings; - const auto push = [&](Settings::Category category) { - for (const auto setting : Settings::values.linkage.by_category[category]) { - settings.push_back(setting); - } - }; - - push(Settings::Category::Linux); - - for (auto* setting : settings) { - auto* widget = builder.BuildWidget(setting, apply_funcs); - - if (widget == nullptr) { - continue; - } - if (!widget->Valid()) { - widget->deleteLater(); - continue; - } - - linux_hold.insert({setting->Id(), widget}); - } - - for (const auto& [id, widget] : linux_hold) { - linux_layout.addWidget(widget); - } -} - -void ConfigureLinuxTab::ApplyConfiguration() { - const bool is_powered_on = system.IsPoweredOn(); - for (const auto& apply_func : apply_funcs) { - apply_func(is_powered_on); - } -} - -void ConfigureLinuxTab::changeEvent(QEvent* event) { - if (event->type() == QEvent::LanguageChange) { - RetranslateUI(); - } - - QWidget::changeEvent(event); -} - -void ConfigureLinuxTab::RetranslateUI() { - ui->retranslateUi(this); -} diff --git a/src/yuzu/configuration/configure_linux_tab.h b/src/yuzu/configuration/configure_linux_tab.h deleted file mode 100644 index 2f402079c..000000000 --- a/src/yuzu/configuration/configure_linux_tab.h +++ /dev/null @@ -1,44 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include <QWidget> - -namespace Core { -class System; -} - -namespace Ui { -class ConfigureLinuxTab; -} - -namespace ConfigurationShared { -class Builder; -} - -class ConfigureLinuxTab : public ConfigurationShared::Tab { - Q_OBJECT - -public: - explicit ConfigureLinuxTab(const Core::System& system_, - std::shared_ptr<std::vector<ConfigurationShared::Tab*>> group, - const ConfigurationShared::Builder& builder, - QWidget* parent = nullptr); - ~ConfigureLinuxTab() override; - - void ApplyConfiguration() override; - void SetConfiguration() override; - -private: - void changeEvent(QEvent* event) override; - void RetranslateUI(); - - void Setup(const ConfigurationShared::Builder& builder); - - std::unique_ptr<Ui::ConfigureLinuxTab> ui; - - const Core::System& system; - - std::vector<std::function<void(bool)>> apply_funcs{}; -}; diff --git a/src/yuzu/configuration/configure_linux_tab.ui b/src/yuzu/configuration/configure_linux_tab.ui deleted file mode 100644 index f8e07f581..000000000 --- a/src/yuzu/configuration/configure_linux_tab.ui +++ /dev/null @@ -1,53 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>ConfigureLinuxTab</class> - <widget class="QWidget" name="ConfigureLinuxTab"> - <property name="accessibleName"> - <string>Linux</string> - </property> - <layout class="QVBoxLayout"> - <item> - <widget class="QGroupBox" name="LinuxGroupBox"> - <property name="title"> - <string>Linux</string> - </property> - <layout class="QVBoxLayout" name="LinuxVerticalLayout_1"> - <item> - <widget class="QWidget" name="linux_widget" native="true"> - <layout class="QVBoxLayout" name="LinuxVerticalLayout_2"> - <property name="leftMargin"> - <number>0</number> - </property> - <property name="topMargin"> - <number>0</number> - </property> - <property name="rightMargin"> - <number>0</number> - </property> - <property name="bottomMargin"> - <number>0</number> - </property> - </layout> - </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> - </layout> - </widget> - <resources/> - <connections/> -</ui> diff --git a/src/yuzu/configuration/configure_motion_touch.cpp b/src/yuzu/configuration/configure_motion_touch.cpp deleted file mode 100644 index fb1292f07..000000000 --- a/src/yuzu/configuration/configure_motion_touch.cpp +++ /dev/null @@ -1,326 +0,0 @@ -// SPDX-FileCopyrightText: 2018 Citra Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include <sstream> - -#include <QCloseEvent> -#include <QMessageBox> -#include <QStringListModel> - -#include "common/logging/log.h" -#include "common/settings.h" -#include "input_common/drivers/udp_client.h" -#include "input_common/helpers/udp_protocol.h" -#include "input_common/main.h" -#include "ui_configure_motion_touch.h" -#include "yuzu/configuration/configure_motion_touch.h" -#include "yuzu/configuration/configure_touch_from_button.h" - -CalibrationConfigurationDialog::CalibrationConfigurationDialog(QWidget* parent, - const std::string& host, u16 port) - : QDialog(parent) { - layout = new QVBoxLayout; - status_label = new QLabel(tr("Communicating with the server...")); - cancel_button = new QPushButton(tr("Cancel")); - connect(cancel_button, &QPushButton::clicked, this, [this] { - if (!completed) { - job->Stop(); - } - accept(); - }); - layout->addWidget(status_label); - layout->addWidget(cancel_button); - setLayout(layout); - - using namespace InputCommon::CemuhookUDP; - job = std::make_unique<CalibrationConfigurationJob>( - host, port, - [this](CalibrationConfigurationJob::Status status) { - QMetaObject::invokeMethod(this, [status, this] { - QString text; - switch (status) { - case CalibrationConfigurationJob::Status::Ready: - text = tr("Touch the top left corner <br>of your touchpad."); - break; - case CalibrationConfigurationJob::Status::Stage1Completed: - text = tr("Now touch the bottom right corner <br>of your touchpad."); - break; - case CalibrationConfigurationJob::Status::Completed: - text = tr("Configuration completed!"); - break; - default: - break; - } - UpdateLabelText(text); - }); - if (status == CalibrationConfigurationJob::Status::Completed) { - QMetaObject::invokeMethod(this, [this] { UpdateButtonText(tr("OK")); }); - } - }, - [this](u16 min_x_, u16 min_y_, u16 max_x_, u16 max_y_) { - completed = true; - min_x = min_x_; - min_y = min_y_; - max_x = max_x_; - max_y = max_y_; - }); -} - -CalibrationConfigurationDialog::~CalibrationConfigurationDialog() = default; - -void CalibrationConfigurationDialog::UpdateLabelText(const QString& text) { - status_label->setText(text); -} - -void CalibrationConfigurationDialog::UpdateButtonText(const QString& text) { - cancel_button->setText(text); -} - -ConfigureMotionTouch::ConfigureMotionTouch(QWidget* parent, - InputCommon::InputSubsystem* input_subsystem_) - : QDialog(parent), input_subsystem{input_subsystem_}, - ui(std::make_unique<Ui::ConfigureMotionTouch>()) { - ui->setupUi(this); - - ui->udp_learn_more->setOpenExternalLinks(true); - ui->udp_learn_more->setText( - tr("<a " - "href='https://yuzu-emu.org/wiki/" - "using-a-controller-or-android-phone-for-motion-or-touch-input'><span " - "style=\"text-decoration: underline; color:#039be5;\">Learn More</span></a>")); - - SetConfiguration(); - UpdateUiDisplay(); - ConnectEvents(); -} - -ConfigureMotionTouch::~ConfigureMotionTouch() = default; - -void ConfigureMotionTouch::SetConfiguration() { - const Common::ParamPackage touch_param(Settings::values.touch_device.GetValue()); - - touch_from_button_maps = Settings::values.touch_from_button_maps; - for (const auto& touch_map : touch_from_button_maps) { - ui->touch_from_button_map->addItem(QString::fromStdString(touch_map.name)); - } - ui->touch_from_button_map->setCurrentIndex( - Settings::values.touch_from_button_map_index.GetValue()); - - min_x = touch_param.Get("min_x", 100); - min_y = touch_param.Get("min_y", 50); - max_x = touch_param.Get("max_x", 1800); - max_y = touch_param.Get("max_y", 850); - - ui->udp_server->setText(QString::fromStdString("127.0.0.1")); - ui->udp_port->setText(QString::number(26760)); - - udp_server_list_model = new QStringListModel(this); - udp_server_list_model->setStringList({}); - ui->udp_server_list->setModel(udp_server_list_model); - - std::stringstream ss(Settings::values.udp_input_servers.GetValue()); - std::string token; - - while (std::getline(ss, token, ',')) { - const int row = udp_server_list_model->rowCount(); - udp_server_list_model->insertRows(row, 1); - const QModelIndex index = udp_server_list_model->index(row); - udp_server_list_model->setData(index, QString::fromStdString(token)); - } -} - -void ConfigureMotionTouch::UpdateUiDisplay() { - const QString cemuhook_udp = QStringLiteral("cemuhookudp"); - - ui->touch_calibration->setVisible(true); - ui->touch_calibration_config->setVisible(true); - ui->touch_calibration_label->setVisible(true); - ui->touch_calibration->setText( - QStringLiteral("(%1, %2) - (%3, %4)").arg(min_x).arg(min_y).arg(max_x).arg(max_y)); - - ui->udp_config_group_box->setVisible(true); -} - -void ConfigureMotionTouch::ConnectEvents() { - connect(ui->udp_test, &QPushButton::clicked, this, &ConfigureMotionTouch::OnCemuhookUDPTest); - connect(ui->udp_add, &QPushButton::clicked, this, &ConfigureMotionTouch::OnUDPAddServer); - connect(ui->udp_remove, &QPushButton::clicked, this, &ConfigureMotionTouch::OnUDPDeleteServer); - connect(ui->touch_calibration_config, &QPushButton::clicked, this, - &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(); - } - }); -} - -void ConfigureMotionTouch::OnUDPAddServer() { - // Validator for IP address - const QRegularExpression re(QStringLiteral( - R"re(^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$)re")); - bool ok; - const QString port_text = ui->udp_port->text(); - const QString server_text = ui->udp_server->text(); - const QString server_string = tr("%1:%2").arg(server_text, port_text); - const int port_number = port_text.toInt(&ok, 10); - const int row = udp_server_list_model->rowCount(); - - if (!ok) { - QMessageBox::warning(this, tr("yuzu"), tr("Port number has invalid characters")); - return; - } - if (port_number < 0 || port_number > 65353) { - QMessageBox::warning(this, tr("yuzu"), tr("Port has to be in range 0 and 65353")); - return; - } - if (!re.match(server_text).hasMatch()) { - QMessageBox::warning(this, tr("yuzu"), tr("IP address is not valid")); - return; - } - // Search for duplicates - for (const auto& item : udp_server_list_model->stringList()) { - if (item == server_string) { - QMessageBox::warning(this, tr("yuzu"), tr("This UDP server already exists")); - return; - } - } - // Limit server count to 8 - if (row == 8) { - QMessageBox::warning(this, tr("yuzu"), tr("Unable to add more than 8 servers")); - return; - } - - udp_server_list_model->insertRows(row, 1); - QModelIndex index = udp_server_list_model->index(row); - udp_server_list_model->setData(index, server_string); - ui->udp_server_list->setCurrentIndex(index); -} - -void ConfigureMotionTouch::OnUDPDeleteServer() { - udp_server_list_model->removeRows(ui->udp_server_list->currentIndex().row(), 1); -} - -void ConfigureMotionTouch::OnCemuhookUDPTest() { - ui->udp_test->setEnabled(false); - ui->udp_test->setText(tr("Testing")); - udp_test_in_progress = true; - InputCommon::CemuhookUDP::TestCommunication( - ui->udp_server->text().toStdString(), static_cast<u16>(ui->udp_port->text().toInt()), - [this] { - LOG_INFO(Frontend, "UDP input test success"); - QMetaObject::invokeMethod(this, [this] { ShowUDPTestResult(true); }); - }, - [this] { - LOG_ERROR(Frontend, "UDP input test failed"); - QMetaObject::invokeMethod(this, [this] { ShowUDPTestResult(false); }); - }); -} - -void ConfigureMotionTouch::OnConfigureTouchCalibration() { - ui->touch_calibration_config->setEnabled(false); - ui->touch_calibration_config->setText(tr("Configuring")); - CalibrationConfigurationDialog dialog(this, ui->udp_server->text().toStdString(), - static_cast<u16>(ui->udp_port->text().toUInt())); - dialog.exec(); - if (dialog.completed) { - min_x = dialog.min_x; - min_y = dialog.min_y; - max_x = dialog.max_x; - max_y = dialog.max_y; - LOG_INFO(Frontend, - "UDP touchpad calibration config success: min_x={}, min_y={}, max_x={}, max_y={}", - min_x, min_y, max_x, max_y); - UpdateUiDisplay(); - } else { - LOG_ERROR(Frontend, "UDP touchpad calibration config failed"); - } - ui->touch_calibration_config->setEnabled(true); - ui->touch_calibration_config->setText(tr("Configure")); -} - -void ConfigureMotionTouch::closeEvent(QCloseEvent* event) { - if (CanCloseDialog()) { - event->accept(); - } else { - event->ignore(); - } -} - -void ConfigureMotionTouch::ShowUDPTestResult(bool result) { - udp_test_in_progress = false; - if (result) { - QMessageBox::information(this, tr("Test Successful"), - tr("Successfully received data from the server.")); - } else { - QMessageBox::warning(this, tr("Test Failed"), - tr("Could not receive valid data from the server.<br>Please verify " - "that the server is set up correctly and " - "the address and port are correct.")); - } - ui->udp_test->setEnabled(true); - ui->udp_test->setText(tr("Test")); -} - -void ConfigureMotionTouch::OnConfigureTouchFromButton() { - ConfigureTouchFromButton dialog{this, touch_from_button_maps, input_subsystem, - ui->touch_from_button_map->currentIndex()}; - if (dialog.exec() != QDialog::Accepted) { - return; - } - touch_from_button_maps = dialog.GetMaps(); - - while (ui->touch_from_button_map->count() > 0) { - ui->touch_from_button_map->removeItem(0); - } - for (const auto& touch_map : touch_from_button_maps) { - ui->touch_from_button_map->addItem(QString::fromStdString(touch_map.name)); - } - ui->touch_from_button_map->setCurrentIndex(dialog.GetSelectedIndex()); -} - -bool ConfigureMotionTouch::CanCloseDialog() { - if (udp_test_in_progress) { - QMessageBox::warning(this, tr("yuzu"), - tr("UDP Test or calibration configuration is in progress.<br>Please " - "wait for them to finish.")); - return false; - } - return true; -} - -void ConfigureMotionTouch::ApplyConfiguration() { - if (!CanCloseDialog()) { - return; - } - - Common::ParamPackage touch_param{}; - touch_param.Set("min_x", min_x); - touch_param.Set("min_y", min_y); - touch_param.Set("max_x", max_x); - touch_param.Set("max_y", max_y); - - Settings::values.touch_device = touch_param.Serialize(); - Settings::values.touch_from_button_map_index = ui->touch_from_button_map->currentIndex(); - Settings::values.touch_from_button_maps = touch_from_button_maps; - Settings::values.udp_input_servers = GetUDPServerString(); - input_subsystem->ReloadInputDevices(); - - accept(); -} - -std::string ConfigureMotionTouch::GetUDPServerString() const { - QString input_servers; - - for (const auto& item : udp_server_list_model->stringList()) { - input_servers += item; - input_servers += QLatin1Char{','}; - } - - // Remove last comma - input_servers.chop(1); - return input_servers.toStdString(); -} diff --git a/src/yuzu/configuration/configure_motion_touch.h b/src/yuzu/configuration/configure_motion_touch.h deleted file mode 100644 index a5db0de51..000000000 --- a/src/yuzu/configuration/configure_motion_touch.h +++ /dev/null @@ -1,93 +0,0 @@ -// SPDX-FileCopyrightText: 2018 Citra Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include <memory> -#include <QDialog> - -class QLabel; -class QPushButton; -class QStringListModel; -class QVBoxLayout; - -namespace InputCommon { -class InputSubsystem; -} - -namespace InputCommon::CemuhookUDP { -class CalibrationConfigurationJob; -} - -namespace Ui { -class ConfigureMotionTouch; -} - -/// A dialog for touchpad calibration configuration. -class CalibrationConfigurationDialog : public QDialog { - Q_OBJECT - -public: - explicit CalibrationConfigurationDialog(QWidget* parent, const std::string& host, u16 port); - ~CalibrationConfigurationDialog() override; - -private: - Q_INVOKABLE void UpdateLabelText(const QString& text); - Q_INVOKABLE void UpdateButtonText(const QString& text); - - QVBoxLayout* layout; - QLabel* status_label; - QPushButton* cancel_button; - std::unique_ptr<InputCommon::CemuhookUDP::CalibrationConfigurationJob> job; - - // Configuration results - bool completed{}; - u16 min_x{}; - u16 min_y{}; - u16 max_x{}; - u16 max_y{}; - - friend class ConfigureMotionTouch; -}; - -class ConfigureMotionTouch : public QDialog { - Q_OBJECT - -public: - explicit ConfigureMotionTouch(QWidget* parent, InputCommon::InputSubsystem* input_subsystem_); - ~ConfigureMotionTouch() override; - -public slots: - void ApplyConfiguration(); - -private slots: - void OnUDPAddServer(); - void OnUDPDeleteServer(); - void OnCemuhookUDPTest(); - void OnConfigureTouchCalibration(); - void OnConfigureTouchFromButton(); - -private: - void closeEvent(QCloseEvent* event) override; - Q_INVOKABLE void ShowUDPTestResult(bool result); - void SetConfiguration(); - void UpdateUiDisplay(); - void ConnectEvents(); - bool CanCloseDialog(); - std::string GetUDPServerString() const; - - InputCommon::InputSubsystem* input_subsystem; - - std::unique_ptr<Ui::ConfigureMotionTouch> ui; - QStringListModel* udp_server_list_model; - - // Coordinate system of the CemuhookUDP touch provider - int min_x{}; - int min_y{}; - int max_x{}; - int max_y{}; - - bool udp_test_in_progress{}; - - std::vector<Settings::TouchFromButtonMap> touch_from_button_maps; -}; diff --git a/src/yuzu/configuration/configure_motion_touch.ui b/src/yuzu/configuration/configure_motion_touch.ui deleted file mode 100644 index 0237fae54..000000000 --- a/src/yuzu/configuration/configure_motion_touch.ui +++ /dev/null @@ -1,297 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>ConfigureMotionTouch</class> - <widget class="QDialog" name="ConfigureMotionTouch"> - <property name="windowTitle"> - <string>Configure Motion / Touch</string> - </property> - <property name="styleSheet"> - <string notr="true"/> - </property> - <layout class="QVBoxLayout"> - <item> - <widget class="QGroupBox" name="touch_group_box"> - <property name="title"> - <string>Touch</string> - </property> - <layout class="QVBoxLayout"> - <item> - <layout class="QHBoxLayout"> - <item> - <widget class="QLabel" name="touch_calibration_label"> - <property name="text"> - <string>UDP Calibration:</string> - </property> - </widget> - </item> - <item> - <widget class="QLabel" name="touch_calibration"> - <property name="text"> - <string>(100, 50) - (1800, 850)</string> - </property> - <property name="alignment"> - <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="touch_calibration_config"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Maximum" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string>Configure</string> - </property> - </widget> - </item> - </layout> - </item> - <item> - <layout class="QHBoxLayout"> - <item> - <widget class="QLabel" name="touch_from_button_label"> - <property name="text"> - <string>Touch from button profile:</string> - </property> - </widget> - </item> - <item> - <widget class="QComboBox" name="touch_from_button_map"/> - </item> - <item> - <widget class="QPushButton" name="touch_from_button_config_btn"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Maximum" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string>Configure</string> - </property> - </widget> - </item> - </layout> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QGroupBox" name="udp_config_group_box"> - <property name="title"> - <string>CemuhookUDP Config</string> - </property> - <layout class="QVBoxLayout"> - <item> - <widget class="QLabel" name="udp_help"> - <property name="text"> - <string>You may use any Cemuhook compatible UDP input source to provide motion and touch input.</string> - </property> - <property name="alignment"> - <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> - </property> - <property name="wordWrap"> - <bool>true</bool> - </property> - </widget> - </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayout"> - <item> - <widget class="QListView" name="udp_server_list"/> - </item> - <item> - <layout class="QVBoxLayout" name="verticalLayout"> - <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"> - <property name="leftMargin"> - <number>3</number> - </property> - <property name="topMargin"> - <number>3</number> - </property> - <property name="rightMargin"> - <number>0</number> - </property> - <item> - <widget class="QLabel" name="udp_server_label"> - <property name="text"> - <string>Server:</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="udp_server"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - </widget> - </item> - </layout> - </item> - <item> - <layout class="QHBoxLayout"> - <property name="leftMargin"> - <number>3</number> - </property> - <property name="rightMargin"> - <number>0</number> - </property> - <item> - <widget class="QLabel" name="udp_port_label"> - <property name="text"> - <string>Port:</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="udp_port"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - </widget> - </item> - </layout> - </item> - <item> - <layout class="QHBoxLayout"> - <property name="leftMargin"> - <number>3</number> - </property> - <property name="rightMargin"> - <number>0</number> - </property> - <item> - <widget class="QLabel" name="udp_learn_more"> - <property name="text"> - <string>Learn More</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="udp_test"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Maximum" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string>Test</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="udp_add"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Maximum" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string>Add Server</string> - </property> - </widget> - </item> - </layout> - </item> - <item> - <spacer name="verticalSpacer_3"> - <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_2"> - <property name="topMargin"> - <number>0</number> - </property> - <item> - <widget class="QPushButton" name="udp_remove"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Maximum" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string>Remove Server</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> - </layout> - </item> - </layout> - </item> - </layout> - </item> - </layout> - </widget> - </item> - <item> - <spacer> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>167</width> - <height>55</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QDialogButtonBox" name="buttonBox"> - <property name="standardButtons"> - <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> - </property> - </widget> - </item> - </layout> - </widget> - <resources/> - <connections/> -</ui> diff --git a/src/yuzu/configuration/configure_mouse_panning.cpp b/src/yuzu/configuration/configure_mouse_panning.cpp deleted file mode 100644 index e37c546b0..000000000 --- a/src/yuzu/configuration/configure_mouse_panning.cpp +++ /dev/null @@ -1,90 +0,0 @@ -// SPDX-FileCopyrightText: 2023 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include <QCloseEvent> -#include <QMessageBox> - -#include "common/settings.h" -#include "ui_configure_mouse_panning.h" -#include "yuzu/configuration/configure_mouse_panning.h" - -ConfigureMousePanning::ConfigureMousePanning(QWidget* parent, - InputCommon::InputSubsystem* input_subsystem_, - float right_stick_deadzone, float right_stick_range) - : QDialog(parent), input_subsystem{input_subsystem_}, - ui(std::make_unique<Ui::ConfigureMousePanning>()) { - ui->setupUi(this); - SetConfiguration(right_stick_deadzone, right_stick_range); - ConnectEvents(); -} - -ConfigureMousePanning::~ConfigureMousePanning() = default; - -void ConfigureMousePanning::closeEvent(QCloseEvent* event) { - event->accept(); -} - -void ConfigureMousePanning::SetConfiguration(float right_stick_deadzone, float right_stick_range) { - ui->enable->setChecked(Settings::values.mouse_panning.GetValue()); - ui->x_sensitivity->setValue(Settings::values.mouse_panning_x_sensitivity.GetValue()); - ui->y_sensitivity->setValue(Settings::values.mouse_panning_y_sensitivity.GetValue()); - ui->deadzone_counterweight->setValue( - Settings::values.mouse_panning_deadzone_counterweight.GetValue()); - ui->decay_strength->setValue(Settings::values.mouse_panning_decay_strength.GetValue()); - ui->min_decay->setValue(Settings::values.mouse_panning_min_decay.GetValue()); - - if (right_stick_deadzone > 0.0f || right_stick_range != 1.0f) { - const QString right_stick_deadzone_str = - QString::fromStdString(std::to_string(static_cast<int>(right_stick_deadzone * 100.0f))); - const QString right_stick_range_str = - QString::fromStdString(std::to_string(static_cast<int>(right_stick_range * 100.0f))); - - ui->warning_label->setText( - tr("Mouse panning works better with a deadzone of 0% and a range of 100%.\nCurrent " - "values are %1% and %2% respectively.") - .arg(right_stick_deadzone_str, right_stick_range_str)); - } - - if (Settings::values.mouse_enabled) { - ui->warning_label->setText( - tr("Emulated mouse is enabled. This is incompatible with mouse panning.")); - } -} - -void ConfigureMousePanning::SetDefaultConfiguration() { - ui->x_sensitivity->setValue(Settings::values.mouse_panning_x_sensitivity.GetDefault()); - ui->y_sensitivity->setValue(Settings::values.mouse_panning_y_sensitivity.GetDefault()); - ui->deadzone_counterweight->setValue( - Settings::values.mouse_panning_deadzone_counterweight.GetDefault()); - ui->decay_strength->setValue(Settings::values.mouse_panning_decay_strength.GetDefault()); - ui->min_decay->setValue(Settings::values.mouse_panning_min_decay.GetDefault()); -} - -void ConfigureMousePanning::ConnectEvents() { - connect(ui->default_button, &QPushButton::clicked, this, - &ConfigureMousePanning::SetDefaultConfiguration); - connect(ui->button_box, &QDialogButtonBox::accepted, this, - &ConfigureMousePanning::ApplyConfiguration); - connect(ui->button_box, &QDialogButtonBox::rejected, this, [this] { reject(); }); -} - -void ConfigureMousePanning::ApplyConfiguration() { - Settings::values.mouse_panning = ui->enable->isChecked(); - Settings::values.mouse_panning_x_sensitivity = static_cast<float>(ui->x_sensitivity->value()); - Settings::values.mouse_panning_y_sensitivity = static_cast<float>(ui->y_sensitivity->value()); - Settings::values.mouse_panning_deadzone_counterweight = - static_cast<float>(ui->deadzone_counterweight->value()); - Settings::values.mouse_panning_decay_strength = static_cast<float>(ui->decay_strength->value()); - Settings::values.mouse_panning_min_decay = static_cast<float>(ui->min_decay->value()); - - if (Settings::values.mouse_enabled && Settings::values.mouse_panning) { - Settings::values.mouse_panning = false; - QMessageBox::critical( - this, tr("Emulated mouse is enabled"), - tr("Real mouse input and mouse panning are incompatible. Please disable the " - "emulated mouse in input advanced settings to allow mouse panning.")); - return; - } - - accept(); -} diff --git a/src/yuzu/configuration/configure_mouse_panning.h b/src/yuzu/configuration/configure_mouse_panning.h deleted file mode 100644 index f5e62ee13..000000000 --- a/src/yuzu/configuration/configure_mouse_panning.h +++ /dev/null @@ -1,36 +0,0 @@ -// SPDX-FileCopyrightText: 2023 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include <memory> -#include <QDialog> - -namespace InputCommon { -class InputSubsystem; -} - -namespace Ui { -class ConfigureMousePanning; -} - -class ConfigureMousePanning : public QDialog { - Q_OBJECT - -public: - explicit ConfigureMousePanning(QWidget* parent, InputCommon::InputSubsystem* input_subsystem_, - float right_stick_deadzone, float right_stick_range); - ~ConfigureMousePanning() override; - -public slots: - void ApplyConfiguration(); - -private: - void closeEvent(QCloseEvent* event) override; - void SetConfiguration(float right_stick_deadzone, float right_stick_range); - void SetDefaultConfiguration(); - void ConnectEvents(); - - InputCommon::InputSubsystem* input_subsystem; - std::unique_ptr<Ui::ConfigureMousePanning> ui; -}; diff --git a/src/yuzu/configuration/configure_mouse_panning.ui b/src/yuzu/configuration/configure_mouse_panning.ui deleted file mode 100644 index 84fb7ee80..000000000 --- a/src/yuzu/configuration/configure_mouse_panning.ui +++ /dev/null @@ -1,212 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>ConfigureMousePanning</class> - <widget class="QDialog" name="configure_mouse_panning"> - <property name="windowTitle"> - <string>Configure mouse panning</string> - </property> - <layout class="QVBoxLayout"> - <item> - <widget class="QCheckBox" name="enable"> - <property name="text"> - <string>Enable mouse panning</string> - </property> - <property name="toolTip"> - <string>Can be toggled via a hotkey. Default hotkey is Ctrl + F9</string> - </property> - </widget> - </item> - <item> - <layout class="QHBoxLayout"> - <item> - <widget class="QGroupBox" name="sensitivity_box"> - <property name="title"> - <string>Sensitivity</string> - </property> - <layout class="QGridLayout"> - <item row="0" column="0"> - <widget class="QLabel" name="x_sensitivity_label"> - <property name="text"> - <string>Horizontal</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QSpinBox" name="x_sensitivity"> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - <property name="suffix"> - <string>%</string> - </property> - <property name="minimum"> - <number>1</number> - </property> - <property name="maximum"> - <number>100</number> - </property> - <property name="value"> - <number>50</number> - </property> - </widget> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="y_sensitivity_label"> - <property name="text"> - <string>Vertical</string> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QSpinBox" name="y_sensitivity"> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - <property name="suffix"> - <string>%</string> - </property> - <property name="minimum"> - <number>1</number> - </property> - <property name="maximum"> - <number>100</number> - </property> - <property name="value"> - <number>50</number> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QGroupBox" name="deadzone_counterweight_box"> - <property name="title"> - <string>Deadzone counterweight</string> - </property> - <property name="toolTip"> - <string>Counteracts a game's built-in deadzone</string> - </property> - <layout class="QGridLayout"> - <item row="0" column="0"> - <widget class="QLabel" name="deadzone_counterweight_label"> - <property name="text"> - <string>Deadzone</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QSpinBox" name="deadzone_counterweight"> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - <property name="suffix"> - <string>%</string> - </property> - <property name="minimum"> - <number>0</number> - </property> - <property name="maximum"> - <number>100</number> - </property> - <property name="value"> - <number>0</number> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QGroupBox" name="decay_box"> - <property name="title"> - <string>Stick decay</string> - </property> - <layout class="QGridLayout"> - <item row="0" column="0"> - <widget class="QLabel" name="decay_strength_label"> - <property name="text"> - <string>Strength</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QSpinBox" name="decay_strength"> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - <property name="suffix"> - <string>%</string> - </property> - <property name="minimum"> - <number>0</number> - </property> - <property name="maximum"> - <number>100</number> - </property> - <property name="value"> - <number>22</number> - </property> - </widget> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="min_decay_label"> - <property name="text"> - <string>Minimum</string> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QSpinBox" name="min_decay"> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - <property name="suffix"> - <string>%</string> - </property> - <property name="minimum"> - <number>0</number> - </property> - <property name="maximum"> - <number>100</number> - </property> - <property name="value"> - <number>5</number> - </property> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </item> - <item> - <widget class="QLabel" name="warning_label"> - <property name="text"> - <string/> - </property> - </widget> - </item> - <item> - <layout class="QHBoxLayout"> - <item> - <widget class="QPushButton" name="default_button"> - <property name="text"> - <string>Default</string> - </property> - </widget> - </item> - <item> - <widget class="QDialogButtonBox" name="button_box"> - <property name="standardButtons"> - <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> - </property> - </widget> - </item> - </layout> - </item> - </layout> - </widget> - <resources/> - <connections/> -</ui> diff --git a/src/yuzu/configuration/configure_network.cpp b/src/yuzu/configuration/configure_network.cpp deleted file mode 100644 index ba1986eb1..000000000 --- a/src/yuzu/configuration/configure_network.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include <QtConcurrent/QtConcurrent> -#include "common/settings.h" -#include "core/core.h" -#include "core/internal_network/network_interface.h" -#include "ui_configure_network.h" -#include "yuzu/configuration/configure_network.h" - -ConfigureNetwork::ConfigureNetwork(const Core::System& system_, QWidget* parent) - : QWidget(parent), ui(std::make_unique<Ui::ConfigureNetwork>()), system{system_} { - ui->setupUi(this); - - ui->network_interface->addItem(tr("None")); - for (const auto& iface : Network::GetAvailableNetworkInterfaces()) { - ui->network_interface->addItem(QString::fromStdString(iface.name)); - } - - this->SetConfiguration(); -} - -ConfigureNetwork::~ConfigureNetwork() = default; - -void ConfigureNetwork::ApplyConfiguration() { - Settings::values.network_interface = ui->network_interface->currentText().toStdString(); -} - -void ConfigureNetwork::changeEvent(QEvent* event) { - if (event->type() == QEvent::LanguageChange) { - RetranslateUI(); - } - - QWidget::changeEvent(event); -} - -void ConfigureNetwork::RetranslateUI() { - ui->retranslateUi(this); -} - -void ConfigureNetwork::SetConfiguration() { - const bool runtime_lock = !system.IsPoweredOn(); - - const std::string& network_interface = Settings::values.network_interface.GetValue(); - - ui->network_interface->setCurrentText(QString::fromStdString(network_interface)); - ui->network_interface->setEnabled(runtime_lock); -} diff --git a/src/yuzu/configuration/configure_network.h b/src/yuzu/configuration/configure_network.h deleted file mode 100644 index f666edbd1..000000000 --- a/src/yuzu/configuration/configure_network.h +++ /dev/null @@ -1,30 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include <memory> -#include <QWidget> - -namespace Ui { -class ConfigureNetwork; -} - -class ConfigureNetwork : public QWidget { - Q_OBJECT - -public: - explicit ConfigureNetwork(const Core::System& system_, QWidget* parent = nullptr); - ~ConfigureNetwork() override; - - void ApplyConfiguration(); - -private: - void changeEvent(QEvent*) override; - void RetranslateUI(); - void SetConfiguration(); - - std::unique_ptr<Ui::ConfigureNetwork> ui; - - const Core::System& system; -}; diff --git a/src/yuzu/configuration/configure_network.ui b/src/yuzu/configuration/configure_network.ui deleted file mode 100644 index f10e973b1..000000000 --- a/src/yuzu/configuration/configure_network.ui +++ /dev/null @@ -1,60 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>ConfigureNetwork</class> - <widget class="QWidget" name="ConfigureNetwork"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>433</width> - <height>561</height> - </rect> - </property> - <property name="windowTitle"> - <string>Form</string> - </property> - <property name="accessibleName"> - <string>Network</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <layout class="QVBoxLayout" name="verticalLayout_3"> - <item> - <widget class="QGroupBox" name="groupBox_2"> - <property name="title"> - <string>General</string> - </property> - <layout class="QGridLayout" name="gridLayout_2"> - <item row="1" column="1"> - <widget class="QComboBox" name="network_interface"/> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="label_4"> - <property name="text"> - <string>Network Interface</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </item> - <item> - <spacer name="verticalSpacer"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>40</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - <resources/> - <connections/> -</ui> diff --git a/src/yuzu/configuration/configure_per_game.cpp b/src/yuzu/configuration/configure_per_game.cpp deleted file mode 100644 index 4dbe801a9..000000000 --- a/src/yuzu/configuration/configure_per_game.cpp +++ /dev/null @@ -1,204 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include <algorithm> -#include <filesystem> -#include <memory> -#include <string> -#include <utility> -#include <vector> - -#include <fmt/format.h> - -#include <QAbstractButton> -#include <QCheckBox> -#include <QPushButton> -#include <QString> -#include <QTimer> - -#include "common/fs/fs_util.h" -#include "common/settings_enums.h" -#include "common/settings_input.h" -#include "configuration/shared_widget.h" -#include "core/core.h" -#include "core/file_sys/control_metadata.h" -#include "core/file_sys/patch_manager.h" -#include "core/file_sys/xts_archive.h" -#include "core/loader/loader.h" -#include "frontend_common/config.h" -#include "ui_configure_per_game.h" -#include "yuzu/configuration/configuration_shared.h" -#include "yuzu/configuration/configure_audio.h" -#include "yuzu/configuration/configure_cpu.h" -#include "yuzu/configuration/configure_graphics.h" -#include "yuzu/configuration/configure_graphics_advanced.h" -#include "yuzu/configuration/configure_input_per_game.h" -#include "yuzu/configuration/configure_linux_tab.h" -#include "yuzu/configuration/configure_per_game.h" -#include "yuzu/configuration/configure_per_game_addons.h" -#include "yuzu/configuration/configure_system.h" -#include "yuzu/uisettings.h" -#include "yuzu/util/util.h" -#include "yuzu/vk_device_info.h" - -ConfigurePerGame::ConfigurePerGame(QWidget* parent, u64 title_id_, const std::string& file_name, - std::vector<VkDeviceInfo::Record>& vk_device_records, - Core::System& system_) - : QDialog(parent), - ui(std::make_unique<Ui::ConfigurePerGame>()), title_id{title_id_}, system{system_}, - builder{std::make_unique<ConfigurationShared::Builder>(this, !system_.IsPoweredOn())}, - tab_group{std::make_shared<std::vector<ConfigurationShared::Tab*>>()} { - 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<QtConfig>(config_file_name, Config::ConfigType::PerGameConfig); - addons_tab = std::make_unique<ConfigurePerGameAddons>(system_, this); - audio_tab = std::make_unique<ConfigureAudio>(system_, tab_group, *builder, this); - cpu_tab = std::make_unique<ConfigureCpu>(system_, tab_group, *builder, this); - graphics_advanced_tab = - std::make_unique<ConfigureGraphicsAdvanced>(system_, tab_group, *builder, this); - graphics_tab = std::make_unique<ConfigureGraphics>( - system_, vk_device_records, [&]() { graphics_advanced_tab->ExposeComputeOption(); }, - [](Settings::AspectRatio, Settings::ResolutionSetup) {}, tab_group, *builder, this); - input_tab = std::make_unique<ConfigureInputPerGame>(system_, game_config.get(), this); - linux_tab = std::make_unique<ConfigureLinuxTab>(system_, tab_group, *builder, this); - system_tab = std::make_unique<ConfigureSystem>(system_, tab_group, *builder, this); - - ui->setupUi(this); - - ui->tabWidget->addTab(addons_tab.get(), tr("Add-Ons")); - ui->tabWidget->addTab(system_tab.get(), tr("System")); - ui->tabWidget->addTab(cpu_tab.get(), tr("CPU")); - ui->tabWidget->addTab(graphics_tab.get(), tr("Graphics")); - ui->tabWidget->addTab(graphics_advanced_tab.get(), tr("Adv. Graphics")); - ui->tabWidget->addTab(audio_tab.get(), tr("Audio")); - ui->tabWidget->addTab(input_tab.get(), tr("Input Profiles")); - - // Only show Linux tab on Unix - linux_tab->setVisible(false); -#ifdef __unix__ - linux_tab->setVisible(true); - ui->tabWidget->addTab(linux_tab.get(), tr("Linux")); -#endif - - setFocusPolicy(Qt::ClickFocus); - setWindowTitle(tr("Properties")); - - addons_tab->SetTitleId(title_id); - - scene = new QGraphicsScene; - ui->icon_view->setScene(scene); - - if (system.IsPoweredOn()) { - QPushButton* apply_button = ui->buttonBox->addButton(QDialogButtonBox::Apply); - connect(apply_button, &QAbstractButton::clicked, this, - &ConfigurePerGame::HandleApplyButtonClicked); - } - - LoadConfiguration(); -} - -ConfigurePerGame::~ConfigurePerGame() = default; - -void ConfigurePerGame::ApplyConfiguration() { - for (const auto tab : *tab_group) { - tab->ApplyConfiguration(); - } - addons_tab->ApplyConfiguration(); - input_tab->ApplyConfiguration(); - - if (Settings::IsDockedMode() && Settings::values.players.GetValue()[0].controller_type == - Settings::ControllerType::Handheld) { - Settings::values.use_docked_mode.SetValue(Settings::ConsoleMode::Handheld); - Settings::values.use_docked_mode.SetGlobal(true); - } - - system.ApplySettings(); - Settings::LogSettings(); - - game_config->SaveAllValues(); -} - -void ConfigurePerGame::changeEvent(QEvent* event) { - if (event->type() == QEvent::LanguageChange) { - RetranslateUI(); - } - - QDialog::changeEvent(event); -} - -void ConfigurePerGame::RetranslateUI() { - ui->retranslateUi(this); -} - -void ConfigurePerGame::HandleApplyButtonClicked() { - UISettings::values.configuration_applied = true; - ApplyConfiguration(); -} - -void ConfigurePerGame::LoadFromFile(FileSys::VirtualFile file_) { - file = std::move(file_); - LoadConfiguration(); -} - -void ConfigurePerGame::LoadConfiguration() { - if (file == nullptr) { - return; - } - - addons_tab->LoadFromFile(file); - - ui->display_title_id->setText( - QStringLiteral("%1").arg(title_id, 16, 16, QLatin1Char{'0'}).toUpper()); - - const FileSys::PatchManager pm{title_id, system.GetFileSystemController(), - system.GetContentProvider()}; - const auto control = pm.GetControlMetadata(); - const auto loader = Loader::GetLoader(system, file); - - if (control.first != nullptr) { - ui->display_version->setText(QString::fromStdString(control.first->GetVersionString())); - ui->display_name->setText(QString::fromStdString(control.first->GetApplicationName())); - ui->display_developer->setText(QString::fromStdString(control.first->GetDeveloperName())); - } else { - std::string title; - if (loader->ReadTitle(title) == Loader::ResultStatus::Success) - ui->display_name->setText(QString::fromStdString(title)); - - FileSys::NACP nacp; - if (loader->ReadControlData(nacp) == Loader::ResultStatus::Success) - ui->display_developer->setText(QString::fromStdString(nacp.GetDeveloperName())); - - ui->display_version->setText(QStringLiteral("1.0.0")); - } - - if (control.second != nullptr) { - scene->clear(); - - QPixmap map; - const auto bytes = control.second->ReadAllBytes(); - map.loadFromData(bytes.data(), static_cast<u32>(bytes.size())); - - scene->addPixmap(map.scaled(ui->icon_view->width(), ui->icon_view->height(), - Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); - } else { - std::vector<u8> bytes; - if (loader->ReadIcon(bytes) == Loader::ResultStatus::Success) { - scene->clear(); - - QPixmap map; - map.loadFromData(bytes.data(), static_cast<u32>(bytes.size())); - - scene->addPixmap(map.scaled(ui->icon_view->width(), ui->icon_view->height(), - Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); - } - } - - ui->display_filename->setText(QString::fromStdString(file->GetName())); - - ui->display_format->setText( - QString::fromStdString(Loader::GetFileTypeString(loader->GetFileType()))); - - const auto valueText = ReadableByteSize(file->GetSize()); - ui->display_size->setText(valueText); -} diff --git a/src/yuzu/configuration/configure_per_game.h b/src/yuzu/configuration/configure_per_game.h deleted file mode 100644 index 196cb32e6..000000000 --- a/src/yuzu/configuration/configure_per_game.h +++ /dev/null @@ -1,91 +0,0 @@ -// 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> - -#include "configuration/shared_widget.h" -#include "core/file_sys/vfs/vfs_types.h" -#include "frontend_common/config.h" -#include "vk_device_info.h" -#include "yuzu/configuration/configuration_shared.h" -#include "yuzu/configuration/qt_config.h" -#include "yuzu/configuration/shared_translation.h" - -namespace Core { -class System; -} - -namespace InputCommon { -class InputSubsystem; -} - -class ConfigurePerGameAddons; -class ConfigureAudio; -class ConfigureCpu; -class ConfigureGraphics; -class ConfigureGraphicsAdvanced; -class ConfigureInputPerGame; -class ConfigureLinuxTab; -class ConfigureSystem; - -class QGraphicsScene; -class QStandardItem; -class QStandardItemModel; -class QTreeView; -class QVBoxLayout; - -namespace Ui { -class ConfigurePerGame; -} - -class ConfigurePerGame : public QDialog { - Q_OBJECT - -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, - std::vector<VkDeviceInfo::Record>& vk_device_records, - Core::System& system_); - ~ConfigurePerGame() override; - - /// Save all button configurations to settings file - void ApplyConfiguration(); - - void LoadFromFile(FileSys::VirtualFile file_); - -private: - void changeEvent(QEvent* event) override; - void RetranslateUI(); - - void HandleApplyButtonClicked(); - - void LoadConfiguration(); - - std::unique_ptr<Ui::ConfigurePerGame> ui; - FileSys::VirtualFile file; - u64 title_id; - - QGraphicsScene* scene; - - std::unique_ptr<QtConfig> game_config; - - Core::System& system; - std::unique_ptr<ConfigurationShared::Builder> builder; - std::shared_ptr<std::vector<ConfigurationShared::Tab*>> tab_group; - - std::unique_ptr<ConfigurePerGameAddons> addons_tab; - std::unique_ptr<ConfigureAudio> audio_tab; - std::unique_ptr<ConfigureCpu> cpu_tab; - std::unique_ptr<ConfigureGraphicsAdvanced> graphics_advanced_tab; - std::unique_ptr<ConfigureGraphics> graphics_tab; - std::unique_ptr<ConfigureInputPerGame> input_tab; - std::unique_ptr<ConfigureLinuxTab> linux_tab; - std::unique_ptr<ConfigureSystem> system_tab; -}; diff --git a/src/yuzu/configuration/configure_per_game.ui b/src/yuzu/configuration/configure_per_game.ui deleted file mode 100644 index 99ba2fd18..000000000 --- a/src/yuzu/configuration/configure_per_game.ui +++ /dev/null @@ -1,299 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>ConfigurePerGame</class> - <widget class="QDialog" name="ConfigurePerGame"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>900</width> - <height>607</height> - </rect> - </property> - <property name="minimumSize"> - <size> - <width>900</width> - <height>0</height> - </size> - </property> - <property name="windowTitle"> - <string>Dialog</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout_3"> - <item> - <layout class="QHBoxLayout" name="horizontalLayout"> - <item> - <widget class="QGroupBox" name="groupBox"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Maximum" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="title"> - <string>Info</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <item alignment="Qt::AlignHCenter"> - <widget class="QGraphicsView" name="icon_view"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Maximum" vsizetype="Maximum"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimumSize"> - <size> - <width>256</width> - <height>256</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>256</width> - <height>256</height> - </size> - </property> - <property name="verticalScrollBarPolicy"> - <enum>Qt::ScrollBarAlwaysOff</enum> - </property> - <property name="horizontalScrollBarPolicy"> - <enum>Qt::ScrollBarAlwaysOff</enum> - </property> - <property name="interactive"> - <bool>false</bool> - </property> - </widget> - </item> - <item> - <layout class="QGridLayout" name="gridLayout_2"> - <item row="6" column="1"> - <widget class="QLineEdit" name="display_size"> - <property name="enabled"> - <bool>true</bool> - </property> - <property name="readOnly"> - <bool>true</bool> - </property> - </widget> - </item> - <item row="3" column="1"> - <widget class="QLineEdit" name="display_version"> - <property name="enabled"> - <bool>true</bool> - </property> - <property name="readOnly"> - <bool>true</bool> - </property> - </widget> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="label"> - <property name="text"> - <string>Name</string> - </property> - </widget> - </item> - <item row="4" column="0"> - <widget class="QLabel" name="label_4"> - <property name="text"> - <string>Title ID</string> - </property> - </widget> - </item> - <item row="4" column="1"> - <widget class="QLineEdit" name="display_title_id"> - <property name="enabled"> - <bool>true</bool> - </property> - <property name="readOnly"> - <bool>true</bool> - </property> - </widget> - </item> - <item row="7" column="1"> - <widget class="QLineEdit" name="display_filename"> - <property name="enabled"> - <bool>true</bool> - </property> - <property name="readOnly"> - <bool>true</bool> - </property> - </widget> - </item> - <item row="5" column="1"> - <widget class="QLineEdit" name="display_format"> - <property name="enabled"> - <bool>true</bool> - </property> - <property name="readOnly"> - <bool>true</bool> - </property> - </widget> - </item> - <item row="7" column="0"> - <widget class="QLabel" name="label_7"> - <property name="text"> - <string>Filename</string> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QLineEdit" name="display_name"> - <property name="enabled"> - <bool>true</bool> - </property> - <property name="readOnly"> - <bool>true</bool> - </property> - </widget> - </item> - <item row="2" column="1"> - <widget class="QLineEdit" name="display_developer"> - <property name="enabled"> - <bool>true</bool> - </property> - <property name="readOnly"> - <bool>true</bool> - </property> - </widget> - </item> - <item row="5" column="0"> - <widget class="QLabel" name="label_5"> - <property name="text"> - <string>Format</string> - </property> - </widget> - </item> - <item row="3" column="0"> - <widget class="QLabel" name="label_3"> - <property name="text"> - <string>Version</string> - </property> - </widget> - </item> - <item row="6" column="0"> - <widget class="QLabel" name="label_6"> - <property name="text"> - <string>Size</string> - </property> - </widget> - </item> - <item row="2" column="0"> - <widget class="QLabel" name="label_2"> - <property name="text"> - <string>Developer</string> - </property> - </widget> - </item> - </layout> - </item> - <item> - <spacer name="verticalSpacer"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>40</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - </item> - <item> - <layout class="QVBoxLayout" name="VerticalLayout"> - <item> - <layout class="QVBoxLayout" name="verticalLayout_2"/> - </item> - <item> - <widget class="QTabWidget" name="tabWidget"> - <property name="enabled"> - <bool>true</bool> - </property> - <property name="currentIndex"> - <number>-1</number> - </property> - <property name="usesScrollButtons"> - <bool>true</bool> - </property> - <property name="documentMode"> - <bool>false</bool> - </property> - <property name="tabsClosable"> - <bool>false</bool> - </property> - </widget> - </item> - </layout> - </item> - </layout> - </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayout_2"> - <item> - <widget class="QLabel" name="label_8"> - <property name="text"> - <string>Some settings are only available when a game is not running.</string> - </property> - </widget> - </item> - <item> - <widget class="QDialogButtonBox" name="buttonBox"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <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>ConfigurePerGame</receiver> - <slot>accept()</slot> - <hints> - <hint type="sourcelabel"> - <x>20</x> - <y>20</y> - </hint> - <hint type="destinationlabel"> - <x>20</x> - <y>20</y> - </hint> - </hints> - </connection> - <connection> - <sender>buttonBox</sender> - <signal>rejected()</signal> - <receiver>ConfigurePerGame</receiver> - <slot>reject()</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> -</ui> diff --git a/src/yuzu/configuration/configure_per_game_addons.cpp b/src/yuzu/configuration/configure_per_game_addons.cpp deleted file mode 100644 index 568775027..000000000 --- a/src/yuzu/configuration/configure_per_game_addons.cpp +++ /dev/null @@ -1,143 +0,0 @@ -// SPDX-FileCopyrightText: 2016 Citra Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include <algorithm> -#include <memory> -#include <utility> - -#include <QHeaderView> -#include <QMenu> -#include <QStandardItemModel> -#include <QString> -#include <QTimer> -#include <QTreeView> - -#include "common/fs/fs.h" -#include "common/fs/path_util.h" -#include "core/core.h" -#include "core/file_sys/patch_manager.h" -#include "core/file_sys/xts_archive.h" -#include "core/loader/loader.h" -#include "ui_configure_per_game_addons.h" -#include "yuzu/configuration/configure_input.h" -#include "yuzu/configuration/configure_per_game_addons.h" -#include "yuzu/uisettings.h" - -ConfigurePerGameAddons::ConfigurePerGameAddons(Core::System& system_, QWidget* parent) - : QWidget(parent), ui{std::make_unique<Ui::ConfigurePerGameAddons>()}, system{system_} { - ui->setupUi(this); - - layout = new QVBoxLayout; - tree_view = new QTreeView; - item_model = new QStandardItemModel(tree_view); - tree_view->setModel(item_model); - tree_view->setAlternatingRowColors(true); - tree_view->setSelectionMode(QHeaderView::SingleSelection); - tree_view->setSelectionBehavior(QHeaderView::SelectRows); - tree_view->setVerticalScrollMode(QHeaderView::ScrollPerPixel); - tree_view->setHorizontalScrollMode(QHeaderView::ScrollPerPixel); - tree_view->setSortingEnabled(true); - tree_view->setEditTriggers(QHeaderView::NoEditTriggers); - tree_view->setUniformRowHeights(true); - tree_view->setContextMenuPolicy(Qt::NoContextMenu); - - item_model->insertColumns(0, 2); - 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*>"); - - layout->setContentsMargins(0, 0, 0, 0); - layout->setSpacing(0); - layout->addWidget(tree_view); - - ui->scrollArea->setLayout(layout); - - ui->scrollArea->setEnabled(!system.IsPoweredOn()); - - connect(item_model, &QStandardItemModel::itemChanged, - [] { UISettings::values.is_game_list_reload_pending.exchange(true); }); -} - -ConfigurePerGameAddons::~ConfigurePerGameAddons() = default; - -void ConfigurePerGameAddons::ApplyConfiguration() { - std::vector<std::string> disabled_addons; - - for (const auto& item : list_items) { - const auto disabled = item.front()->checkState() == Qt::Unchecked; - if (disabled) - disabled_addons.push_back(item.front()->text().toStdString()); - } - - auto current = Settings::values.disabled_addons[title_id]; - std::sort(disabled_addons.begin(), disabled_addons.end()); - std::sort(current.begin(), current.end()); - if (disabled_addons != current) { - Common::FS::RemoveFile(Common::FS::GetYuzuPath(Common::FS::YuzuPath::CacheDir) / - "game_list" / fmt::format("{:016X}.pv.txt", title_id)); - } - - Settings::values.disabled_addons[title_id] = disabled_addons; -} - -void ConfigurePerGameAddons::LoadFromFile(FileSys::VirtualFile file_) { - file = std::move(file_); - LoadConfiguration(); -} - -void ConfigurePerGameAddons::SetTitleId(u64 id) { - this->title_id = id; -} - -void ConfigurePerGameAddons::changeEvent(QEvent* event) { - if (event->type() == QEvent::LanguageChange) { - RetranslateUI(); - } - - QWidget::changeEvent(event); -} - -void ConfigurePerGameAddons::RetranslateUI() { - ui->retranslateUi(this); -} - -void ConfigurePerGameAddons::LoadConfiguration() { - if (file == nullptr) { - return; - } - - const FileSys::PatchManager pm{title_id, system.GetFileSystemController(), - system.GetContentProvider()}; - const auto loader = Loader::GetLoader(system, file); - - FileSys::VirtualFile update_raw; - loader->ReadUpdateRaw(update_raw); - - const auto& disabled = Settings::values.disabled_addons[title_id]; - - for (const auto& patch : pm.GetPatches(update_raw)) { - const auto name = QString::fromStdString(patch.name); - - auto* const first_item = new QStandardItem; - first_item->setText(name); - first_item->setCheckable(true); - - const auto patch_disabled = - std::find(disabled.begin(), disabled.end(), name.toStdString()) != disabled.end(); - - first_item->setCheckState(patch_disabled ? Qt::Unchecked : Qt::Checked); - - list_items.push_back(QList<QStandardItem*>{ - first_item, new QStandardItem{QString::fromStdString(patch.version)}}); - item_model->appendRow(list_items.back()); - } - - tree_view->resizeColumnToContents(1); -} diff --git a/src/yuzu/configuration/configure_per_game_addons.h b/src/yuzu/configuration/configure_per_game_addons.h deleted file mode 100644 index 32dc5dde6..000000000 --- a/src/yuzu/configuration/configure_per_game_addons.h +++ /dev/null @@ -1,58 +0,0 @@ -// SPDX-FileCopyrightText: 2016 Citra Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include <memory> -#include <vector> - -#include <QList> - -#include "core/file_sys/vfs/vfs_types.h" - -namespace Core { -class System; -} - -class QGraphicsScene; -class QStandardItem; -class QStandardItemModel; -class QTreeView; -class QVBoxLayout; - -namespace Ui { -class ConfigurePerGameAddons; -} - -class ConfigurePerGameAddons : public QWidget { - Q_OBJECT - -public: - explicit ConfigurePerGameAddons(Core::System& system_, QWidget* parent = nullptr); - ~ConfigurePerGameAddons() override; - - /// Save all button configurations to settings file - void ApplyConfiguration(); - - void LoadFromFile(FileSys::VirtualFile file_); - - void SetTitleId(u64 id); - -private: - void changeEvent(QEvent* event) override; - void RetranslateUI(); - - void LoadConfiguration(); - - std::unique_ptr<Ui::ConfigurePerGameAddons> ui; - FileSys::VirtualFile file; - u64 title_id; - - QVBoxLayout* layout; - QTreeView* tree_view; - QStandardItemModel* item_model; - - std::vector<QList<QStandardItem*>> list_items; - - Core::System& system; -}; diff --git a/src/yuzu/configuration/configure_per_game_addons.ui b/src/yuzu/configuration/configure_per_game_addons.ui deleted file mode 100644 index f9cf6f2c3..000000000 --- a/src/yuzu/configuration/configure_per_game_addons.ui +++ /dev/null @@ -1,41 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>ConfigurePerGameAddons</class> - <widget class="QWidget" name="ConfigurePerGameAddons"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>400</width> - <height>300</height> - </rect> - </property> - <property name="windowTitle"> - <string>Form</string> - </property> - <property name="accessibleDescription"> - <string>Add-Ons</string> - </property> - <layout class="QGridLayout" name="gridLayout"> - <item row="0" column="0"> - <widget class="QScrollArea" name="scrollArea"> - <property name="widgetResizable"> - <bool>true</bool> - </property> - <widget class="QWidget" name="scrollAreaWidgetContents"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>380</width> - <height>280</height> - </rect> - </property> - </widget> - </widget> - </item> - </layout> - </widget> - <resources/> - <connections/> -</ui> diff --git a/src/yuzu/configuration/configure_profile_manager.cpp b/src/yuzu/configuration/configure_profile_manager.cpp deleted file mode 100644 index 12a04b9a0..000000000 --- a/src/yuzu/configuration/configure_profile_manager.cpp +++ /dev/null @@ -1,372 +0,0 @@ -// SPDX-FileCopyrightText: 2016 Citra Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include <algorithm> -#include <functional> -#include <QDialog> -#include <QDialogButtonBox> -#include <QFileDialog> -#include <QGraphicsItem> -#include <QHeaderView> -#include <QMessageBox> -#include <QStandardItemModel> -#include <QTreeView> -#include "common/assert.h" -#include "common/fs/path_util.h" -#include "common/settings.h" -#include "common/string_util.h" -#include "core/core.h" -#include "core/hle/service/acc/profile_manager.h" -#include "ui_configure_profile_manager.h" -#include "yuzu/configuration/configure_profile_manager.h" -#include "yuzu/util/limitable_input_dialog.h" - -namespace { -// Same backup JPEG used by acc IProfile::GetImage if no jpeg found -constexpr std::array<u8, 107> backup_jpeg{ - 0xff, 0xd8, 0xff, 0xdb, 0x00, 0x43, 0x00, 0x03, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 0x02, 0x02, - 0x02, 0x03, 0x03, 0x03, 0x03, 0x04, 0x06, 0x04, 0x04, 0x04, 0x04, 0x04, 0x08, 0x06, 0x06, 0x05, - 0x06, 0x09, 0x08, 0x0a, 0x0a, 0x09, 0x08, 0x09, 0x09, 0x0a, 0x0c, 0x0f, 0x0c, 0x0a, 0x0b, 0x0e, - 0x0b, 0x09, 0x09, 0x0d, 0x11, 0x0d, 0x0e, 0x0f, 0x10, 0x10, 0x11, 0x10, 0x0a, 0x0c, 0x12, 0x13, - 0x12, 0x10, 0x13, 0x0f, 0x10, 0x10, 0x10, 0xff, 0xc9, 0x00, 0x0b, 0x08, 0x00, 0x01, 0x00, 0x01, - 0x01, 0x01, 0x11, 0x00, 0xff, 0xcc, 0x00, 0x06, 0x00, 0x10, 0x10, 0x05, 0xff, 0xda, 0x00, 0x08, - 0x01, 0x01, 0x00, 0x00, 0x3f, 0x00, 0xd2, 0xcf, 0x20, 0xff, 0xd9, -}; - -QString GetImagePath(const Common::UUID& uuid) { - const auto path = - Common::FS::GetYuzuPath(Common::FS::YuzuPath::NANDDir) / - fmt::format("system/save/8000000000000010/su/avators/{}.jpg", uuid.FormattedString()); - return QString::fromStdString(Common::FS::PathToUTF8String(path)); -} - -QString GetAccountUsername(const Service::Account::ProfileManager& manager, Common::UUID uuid) { - Service::Account::ProfileBase profile{}; - if (!manager.GetProfileBase(uuid, profile)) { - return {}; - } - - const auto text = Common::StringFromFixedZeroTerminatedBuffer( - reinterpret_cast<const char*>(profile.username.data()), profile.username.size()); - return QString::fromStdString(text); -} - -QString FormatUserEntryText(const QString& username, Common::UUID uuid) { - return ConfigureProfileManager::tr("%1\n%2", - "%1 is the profile username, %2 is the formatted UUID (e.g. " - "00112233-4455-6677-8899-AABBCCDDEEFF))") - .arg(username, QString::fromStdString(uuid.FormattedString())); -} - -QPixmap GetIcon(const Common::UUID& uuid) { - QPixmap icon{GetImagePath(uuid)}; - - if (!icon) { - icon.fill(Qt::black); - icon.loadFromData(backup_jpeg.data(), static_cast<u32>(backup_jpeg.size())); - } - - return icon.scaled(64, 64, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); -} - -QString GetProfileUsernameFromUser(QWidget* parent, const QString& description_text) { - return LimitableInputDialog::GetText(parent, ConfigureProfileManager::tr("Enter Username"), - description_text, 1, - static_cast<int>(Service::Account::profile_username_size)); -} -} // Anonymous namespace - -ConfigureProfileManager::ConfigureProfileManager(Core::System& system_, QWidget* parent) - : QWidget(parent), ui{std::make_unique<Ui::ConfigureProfileManager>()}, - profile_manager{system_.GetProfileManager()}, system{system_} { - ui->setupUi(this); - - tree_view = new QTreeView; - item_model = new QStandardItemModel(tree_view); - item_model->insertColumns(0, 1); - tree_view->setModel(item_model); - tree_view->setAlternatingRowColors(true); - tree_view->setSelectionMode(QHeaderView::SingleSelection); - tree_view->setSelectionBehavior(QHeaderView::SelectRows); - tree_view->setVerticalScrollMode(QHeaderView::ScrollPerPixel); - tree_view->setHorizontalScrollMode(QHeaderView::ScrollPerPixel); - tree_view->setSortingEnabled(true); - tree_view->setEditTriggers(QHeaderView::NoEditTriggers); - tree_view->setUniformRowHeights(true); - tree_view->setIconSize({64, 64}); - tree_view->setContextMenuPolicy(Qt::NoContextMenu); - - // 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 umbrells of custom types. - qRegisterMetaType<QList<QStandardItem*>>("QList<QStandardItem*>"); - - layout = new QVBoxLayout; - layout->setContentsMargins(0, 0, 0, 0); - layout->setSpacing(0); - layout->addWidget(tree_view); - - ui->scrollArea->setLayout(layout); - - connect(tree_view, &QTreeView::clicked, this, &ConfigureProfileManager::SelectUser); - - connect(ui->pm_add, &QPushButton::clicked, this, &ConfigureProfileManager::AddUser); - connect(ui->pm_rename, &QPushButton::clicked, this, &ConfigureProfileManager::RenameUser); - connect(ui->pm_remove, &QPushButton::clicked, this, - &ConfigureProfileManager::ConfirmDeleteUser); - connect(ui->pm_set_image, &QPushButton::clicked, this, &ConfigureProfileManager::SetUserImage); - - confirm_dialog = new ConfigureProfileManagerDeleteDialog(this); - - scene = new QGraphicsScene; - ui->current_user_icon->setScene(scene); - - RetranslateUI(); - SetConfiguration(); -} - -ConfigureProfileManager::~ConfigureProfileManager() = default; - -void ConfigureProfileManager::changeEvent(QEvent* event) { - if (event->type() == QEvent::LanguageChange) { - RetranslateUI(); - } - - QWidget::changeEvent(event); -} - -void ConfigureProfileManager::RetranslateUI() { - ui->retranslateUi(this); - item_model->setHeaderData(0, Qt::Horizontal, tr("Users")); -} - -void ConfigureProfileManager::SetConfiguration() { - enabled = !system.IsPoweredOn(); - item_model->removeRows(0, item_model->rowCount()); - list_items.clear(); - - PopulateUserList(); - UpdateCurrentUser(); -} - -void ConfigureProfileManager::PopulateUserList() { - const auto& profiles = profile_manager.GetAllUsers(); - for (const auto& user : profiles) { - Service::Account::ProfileBase profile{}; - if (!profile_manager.GetProfileBase(user, profile)) - continue; - - const auto username = Common::StringFromFixedZeroTerminatedBuffer( - reinterpret_cast<const char*>(profile.username.data()), profile.username.size()); - - list_items.push_back(QList<QStandardItem*>{new QStandardItem{ - GetIcon(user), FormatUserEntryText(QString::fromStdString(username), user)}}); - } - - for (const auto& item : list_items) - item_model->appendRow(item); -} - -void ConfigureProfileManager::UpdateCurrentUser() { - ui->pm_add->setEnabled(profile_manager.GetUserCount() < Service::Account::MAX_USERS); - - const auto& current_user = profile_manager.GetUser(Settings::values.current_user.GetValue()); - ASSERT(current_user); - const auto username = GetAccountUsername(profile_manager, *current_user); - - scene->clear(); - scene->addPixmap( - GetIcon(*current_user).scaled(48, 48, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); - ui->current_user_username->setText(username); -} - -void ConfigureProfileManager::ApplyConfiguration() { - if (!enabled) { - return; - } -} - -void ConfigureProfileManager::SelectUser(const QModelIndex& index) { - Settings::values.current_user = - std::clamp<s32>(index.row(), 0, static_cast<s32>(profile_manager.GetUserCount() - 1)); - - UpdateCurrentUser(); - - ui->pm_remove->setEnabled(profile_manager.GetUserCount() >= 2); - ui->pm_rename->setEnabled(true); - ui->pm_set_image->setEnabled(true); -} - -void ConfigureProfileManager::AddUser() { - const auto username = - GetProfileUsernameFromUser(this, tr("Enter a username for the new user:")); - if (username.isEmpty()) { - return; - } - - const auto uuid = Common::UUID::MakeRandom(); - profile_manager.CreateNewUser(uuid, username.toStdString()); - profile_manager.WriteUserSaveFile(); - - item_model->appendRow(new QStandardItem{GetIcon(uuid), FormatUserEntryText(username, uuid)}); -} - -void ConfigureProfileManager::RenameUser() { - const auto user = tree_view->currentIndex().row(); - const auto uuid = profile_manager.GetUser(user); - ASSERT(uuid); - - Service::Account::ProfileBase profile{}; - if (!profile_manager.GetProfileBase(*uuid, profile)) - return; - - const auto new_username = GetProfileUsernameFromUser(this, tr("Enter a new username:")); - if (new_username.isEmpty()) { - return; - } - - const auto username_std = new_username.toStdString(); - std::fill(profile.username.begin(), profile.username.end(), '\0'); - std::copy(username_std.begin(), username_std.end(), profile.username.begin()); - - profile_manager.SetProfileBase(*uuid, profile); - profile_manager.WriteUserSaveFile(); - - item_model->setItem( - user, 0, - new QStandardItem{GetIcon(*uuid), - FormatUserEntryText(QString::fromStdString(username_std), *uuid)}); - UpdateCurrentUser(); -} - -void ConfigureProfileManager::ConfirmDeleteUser() { - const auto index = tree_view->currentIndex().row(); - const auto uuid = profile_manager.GetUser(index); - ASSERT(uuid); - const auto username = GetAccountUsername(profile_manager, *uuid); - - confirm_dialog->SetInfo(username, *uuid, [this, uuid]() { DeleteUser(*uuid); }); - confirm_dialog->show(); -} - -void ConfigureProfileManager::DeleteUser(const Common::UUID& uuid) { - if (Settings::values.current_user.GetValue() == tree_view->currentIndex().row()) { - Settings::values.current_user = 0; - } - UpdateCurrentUser(); - - if (!profile_manager.RemoveUser(uuid)) { - return; - } - - profile_manager.WriteUserSaveFile(); - - item_model->removeRows(tree_view->currentIndex().row(), 1); - tree_view->clearSelection(); - - ui->pm_remove->setEnabled(false); - ui->pm_rename->setEnabled(false); -} - -void ConfigureProfileManager::SetUserImage() { - const auto index = tree_view->currentIndex().row(); - const auto uuid = profile_manager.GetUser(index); - ASSERT(uuid); - - const auto file = QFileDialog::getOpenFileName(this, tr("Select User Image"), QString(), - tr("JPEG Images (*.jpg *.jpeg)")); - - if (file.isEmpty()) { - return; - } - - const auto image_path = GetImagePath(*uuid); - if (QFile::exists(image_path) && !QFile::remove(image_path)) { - QMessageBox::warning( - this, tr("Error deleting image"), - tr("Error occurred attempting to overwrite previous image at: %1.").arg(image_path)); - return; - } - - const auto raw_path = QString::fromStdString(Common::FS::PathToUTF8String( - Common::FS::GetYuzuPath(Common::FS::YuzuPath::NANDDir) / "system/save/8000000000000010")); - const QFileInfo raw_info{raw_path}; - if (raw_info.exists() && !raw_info.isDir() && !QFile::remove(raw_path)) { - QMessageBox::warning(this, tr("Error deleting file"), - tr("Unable to delete existing file: %1.").arg(raw_path)); - return; - } - - const QString absolute_dst_path = QFileInfo{image_path}.absolutePath(); - if (!QDir{raw_path}.mkpath(absolute_dst_path)) { - QMessageBox::warning( - this, tr("Error creating user image directory"), - tr("Unable to create directory %1 for storing user images.").arg(absolute_dst_path)); - return; - } - - if (!QFile::copy(file, image_path)) { - QMessageBox::warning(this, tr("Error copying user image"), - tr("Unable to copy image from %1 to %2").arg(file, image_path)); - return; - } - - // Profile image must be 256x256 - QImage image(image_path); - if (image.width() != 256 || image.height() != 256) { - image = image.scaled(256, 256, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation); - if (!image.save(image_path)) { - QMessageBox::warning(this, tr("Error resizing user image"), - tr("Unable to resize image")); - return; - } - } - - const auto username = GetAccountUsername(profile_manager, *uuid); - item_model->setItem(index, 0, - new QStandardItem{GetIcon(*uuid), FormatUserEntryText(username, *uuid)}); - UpdateCurrentUser(); -} - -ConfigureProfileManagerDeleteDialog::ConfigureProfileManagerDeleteDialog(QWidget* parent) - : QDialog{parent} { - auto dialog_vbox_layout = new QVBoxLayout(this); - dialog_button_box = - new QDialogButtonBox(QDialogButtonBox::Yes | QDialogButtonBox::No, Qt::Horizontal, parent); - auto label_message = - new QLabel(tr("Delete this user? All of the user's save data will be deleted."), this); - label_info = new QLabel(this); - auto dialog_hbox_layout_widget = new QWidget(this); - auto dialog_hbox_layout = new QHBoxLayout(dialog_hbox_layout_widget); - icon_scene = new QGraphicsScene(0, 0, 64, 64, this); - auto icon_view = new QGraphicsView(icon_scene, this); - - dialog_hbox_layout_widget->setLayout(dialog_hbox_layout); - icon_view->setMaximumSize(64, 64); - icon_view->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - icon_view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - this->setLayout(dialog_vbox_layout); - this->setWindowTitle(tr("Confirm Delete")); - this->setSizeGripEnabled(false); - dialog_vbox_layout->addWidget(label_message); - dialog_vbox_layout->addWidget(dialog_hbox_layout_widget); - dialog_vbox_layout->addWidget(dialog_button_box); - dialog_hbox_layout->addWidget(icon_view); - dialog_hbox_layout->addWidget(label_info); - - connect(dialog_button_box, &QDialogButtonBox::rejected, this, [this]() { close(); }); -} - -ConfigureProfileManagerDeleteDialog::~ConfigureProfileManagerDeleteDialog() = default; - -void ConfigureProfileManagerDeleteDialog::SetInfo(const QString& username, const Common::UUID& uuid, - std::function<void()> accept_callback) { - label_info->setText( - tr("Name: %1\nUUID: %2").arg(username, QString::fromStdString(uuid.FormattedString()))); - icon_scene->clear(); - icon_scene->addPixmap(GetIcon(uuid)); - - connect(dialog_button_box, &QDialogButtonBox::accepted, this, [this, accept_callback]() { - close(); - accept_callback(); - }); -} diff --git a/src/yuzu/configuration/configure_profile_manager.h b/src/yuzu/configuration/configure_profile_manager.h deleted file mode 100644 index 39560fdd9..000000000 --- a/src/yuzu/configuration/configure_profile_manager.h +++ /dev/null @@ -1,90 +0,0 @@ -// SPDX-FileCopyrightText: 2016 Citra Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include <functional> -#include <memory> - -#include <QDialog> -#include <QList> -#include <QWidget> - -namespace Common { -struct UUID; -} - -namespace Core { -class System; -} - -class QGraphicsScene; -class QDialogButtonBox; -class QLabel; -class QStandardItem; -class QStandardItemModel; -class QTreeView; -class QVBoxLayout; - -namespace Service::Account { -class ProfileManager; -} - -namespace Ui { -class ConfigureProfileManager; -} - -class ConfigureProfileManagerDeleteDialog : public QDialog { -public: - explicit ConfigureProfileManagerDeleteDialog(QWidget* parent); - ~ConfigureProfileManagerDeleteDialog(); - - void SetInfo(const QString& username, const Common::UUID& uuid, - std::function<void()> accept_callback); - -private: - QDialogButtonBox* dialog_button_box; - QGraphicsScene* icon_scene; - QLabel* label_info; -}; - -class ConfigureProfileManager : public QWidget { - Q_OBJECT - -public: - explicit ConfigureProfileManager(Core::System& system_, QWidget* parent = nullptr); - ~ConfigureProfileManager() override; - - void ApplyConfiguration(); - -private: - void changeEvent(QEvent* event) override; - void RetranslateUI(); - - void SetConfiguration(); - - void PopulateUserList(); - void UpdateCurrentUser(); - - void SelectUser(const QModelIndex& index); - void AddUser(); - void RenameUser(); - void ConfirmDeleteUser(); - void DeleteUser(const Common::UUID& uuid); - void SetUserImage(); - - QVBoxLayout* layout; - QTreeView* tree_view; - QStandardItemModel* item_model; - QGraphicsScene* scene; - - ConfigureProfileManagerDeleteDialog* confirm_dialog; - - std::vector<QList<QStandardItem*>> list_items; - - std::unique_ptr<Ui::ConfigureProfileManager> ui; - bool enabled = false; - - Service::Account::ProfileManager& profile_manager; - const Core::System& system; -}; diff --git a/src/yuzu/configuration/configure_profile_manager.ui b/src/yuzu/configuration/configure_profile_manager.ui deleted file mode 100644 index bd6dea4f4..000000000 --- a/src/yuzu/configuration/configure_profile_manager.ui +++ /dev/null @@ -1,181 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>ConfigureProfileManager</class> - <widget class="QWidget" name="ConfigureProfileManager"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>390</width> - <height>483</height> - </rect> - </property> - <property name="windowTitle"> - <string>Form</string> - </property> - <property name="accessibleName"> - <string>Profiles</string> - </property> - <layout class="QHBoxLayout" name="horizontalLayout"> - <item> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <widget class="QGroupBox" name="gridGroupBox"> - <property name="title"> - <string>Profile Manager</string> - </property> - <layout class="QGridLayout" name="gridLayout_2"> - <property name="sizeConstraint"> - <enum>QLayout::SetNoConstraint</enum> - </property> - <item row="0" column="0"> - <layout class="QHBoxLayout" name="horizontalLayout_2"> - <item> - <widget class="QLabel" name="label"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Minimum"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string>Current User</string> - </property> - </widget> - </item> - <item> - <widget class="QGraphicsView" name="current_user_icon"> - <property name="minimumSize"> - <size> - <width>48</width> - <height>48</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>48</width> - <height>48</height> - </size> - </property> - <property name="frameShape"> - <enum>QFrame::NoFrame</enum> - </property> - <property name="frameShadow"> - <enum>QFrame::Plain</enum> - </property> - <property name="verticalScrollBarPolicy"> - <enum>Qt::ScrollBarAlwaysOff</enum> - </property> - <property name="horizontalScrollBarPolicy"> - <enum>Qt::ScrollBarAlwaysOff</enum> - </property> - <property name="interactive"> - <bool>false</bool> - </property> - </widget> - </item> - <item> - <widget class="QLabel" name="current_user_username"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Minimum"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string>Username</string> - </property> - </widget> - </item> - </layout> - </item> - <item row="1" column="0"> - <widget class="QScrollArea" name="scrollArea"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Expanding"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="frameShape"> - <enum>QFrame::StyledPanel</enum> - </property> - <property name="widgetResizable"> - <bool>false</bool> - </property> - </widget> - </item> - <item row="2" column="0"> - <layout class="QHBoxLayout" name="horizontalLayout_3"> - <item> - <widget class="QPushButton" name="pm_set_image"> - <property name="enabled"> - <bool>false</bool> - </property> - <property name="text"> - <string>Set Image</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="pm_add"> - <property name="text"> - <string>Add</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="pm_rename"> - <property name="enabled"> - <bool>false</bool> - </property> - <property name="text"> - <string>Rename</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="pm_remove"> - <property name="enabled"> - <bool>false</bool> - </property> - <property name="text"> - <string>Remove</string> - </property> - </widget> - </item> - </layout> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QLabel" name="label_disable_info"> - <property name="text"> - <string>Profile management is available only when game is not running.</string> - </property> - <property name="wordWrap"> - <bool>true</bool> - </property> - </widget> - </item> - </layout> - </item> - </layout> - </widget> - <resources/> - <connections/> -</ui> diff --git a/src/yuzu/configuration/configure_ringcon.cpp b/src/yuzu/configuration/configure_ringcon.cpp deleted file mode 100644 index 9fd094ab6..000000000 --- a/src/yuzu/configuration/configure_ringcon.cpp +++ /dev/null @@ -1,497 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include <memory> -#include <QKeyEvent> -#include <QMenu> -#include <QMessageBox> -#include <QTimer> -#include <fmt/format.h> - -#include "configuration/qt_config.h" -#include "hid_core/frontend/emulated_controller.h" -#include "hid_core/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/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_controller = hid_core_.GetEmulatedController(Core::HID::NpadIdType::Player1); - emulated_controller->SaveCurrentConfig(); - emulated_controller->EnableConfiguration(); - - Core::HID::ControllerUpdateCallback engine_callback{ - .on_change = [this](Core::HID::ControllerTriggerType type) { ControllerUpdate(type); }, - .is_npad_service = false, - }; - callback_key = emulated_controller->SetCallback(engine_callback); - is_controller_set = true; - - 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_controller->GetRingParam(); - SetAnalogParam(params, param, analog_sub_buttons[sub_button_id]); - emulated_controller->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_controller->GetRingParam(); - context_menu.addAction(tr("Clear"), [&] { - emulated_controller->SetRingParam(param); - 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_controller->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_controller->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_controller->SetRingParam(param); - }); - - connect(ui->restore_defaults_button, &QPushButton::clicked, this, - &ConfigureRingController::RestoreDefaults); - - connect(ui->enable_ring_controller_button, &QPushButton::clicked, this, - &ConfigureRingController::EnableRingController); - - 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_controller->SetPollingMode(Core::HID::EmulatedDeviceIndex::RightIndex, - Common::Input::PollingMode::Active); - emulated_controller->DisableConfiguration(); - - if (is_controller_set) { - emulated_controller->DeleteCallback(callback_key); - is_controller_set = false; - } -}; - -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_controller->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_controller->DisableConfiguration(); - emulated_controller->SaveCurrentConfig(); - emulated_controller->EnableConfiguration(); -} - -void ConfigureRingController::LoadConfiguration() { - UpdateUI(); -} - -void ConfigureRingController::RestoreDefaults() { - const std::string default_ring_string = InputCommon::GenerateAnalogParamFromKeys( - 0, 0, QtConfig::default_ringcon_analogs[0], QtConfig::default_ringcon_analogs[1], 0, 0.05f); - emulated_controller->SetRingParam(Common::ParamPackage(default_ring_string)); - UpdateUI(); -} - -void ConfigureRingController::EnableRingController() { - const auto dialog_title = tr("Error enabling ring input"); - - is_ring_enabled = false; - ui->ring_controller_sensor_value->setText(tr("Not connected")); - - if (!Settings::values.enable_joycon_driver) { - QMessageBox::warning(this, dialog_title, tr("Direct Joycon driver is not enabled")); - return; - } - - ui->enable_ring_controller_button->setEnabled(false); - ui->enable_ring_controller_button->setText(tr("Configuring")); - // SetPollingMode is blocking. Allow to update the button status before calling the command - repaint(); - - const auto result = emulated_controller->SetPollingMode( - Core::HID::EmulatedDeviceIndex::RightIndex, Common::Input::PollingMode::Ring); - switch (result) { - case Common::Input::DriverResult::Success: - is_ring_enabled = true; - break; - case Common::Input::DriverResult::NotSupported: - QMessageBox::warning(this, dialog_title, - tr("The current mapped device doesn't support the ring controller")); - break; - case Common::Input::DriverResult::NoDeviceDetected: - QMessageBox::warning(this, dialog_title, - tr("The current mapped device doesn't have a ring attached")); - break; - case Common::Input::DriverResult::InvalidHandle: - QMessageBox::warning(this, dialog_title, tr("The current mapped device is not connected")); - break; - default: - QMessageBox::warning(this, dialog_title, - tr("Unexpected driver result %1").arg(static_cast<int>(result))); - break; - } - ui->enable_ring_controller_button->setEnabled(true); - ui->enable_ring_controller_button->setText(tr("Enable")); -} - -void ConfigureRingController::ControllerUpdate(Core::HID::ControllerTriggerType type) { - if (!is_ring_enabled) { - return; - } - if (type != Core::HID::ControllerTriggerType::RingController) { - return; - } - - const auto value = emulated_controller->GetRingSensorValues(); - const auto tex_value = QString::fromStdString(fmt::format("{:.3f}", value.raw_value)); - ui->ring_controller_sensor_value->setText(tex_value); -} - -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, 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]"); -} diff --git a/src/yuzu/configuration/configure_ringcon.h b/src/yuzu/configuration/configure_ringcon.h deleted file mode 100644 index 6fd95e2b8..000000000 --- a/src/yuzu/configuration/configure_ringcon.h +++ /dev/null @@ -1,94 +0,0 @@ -// 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 EmulatedController; -} // 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(); - - /// Sets current polling mode to ring input - void EnableRingController(); - - // Handles emulated controller events - void ControllerUpdate(Core::HID::ControllerTriggerType type); - - /// 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::EmulatedController* emulated_controller; - - bool is_ring_enabled{}; - bool is_controller_set{}; - int callback_key; - - std::unique_ptr<Ui::ConfigureRingController> ui; -}; diff --git a/src/yuzu/configuration/configure_ringcon.ui b/src/yuzu/configuration/configure_ringcon.ui deleted file mode 100644 index 38ecccc3d..000000000 --- a/src/yuzu/configuration/configure_ringcon.ui +++ /dev/null @@ -1,374 +0,0 @@ -<?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>315</width> - <height>400</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>To use Ring-Con, configure player 1 as right Joy-Con (both physical and emulated), and player 2 as left Joy-Con (left physical and dual emulated) before starting the game.</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>Virtual Ring Sensor Parameters</string> - </property> - <property name="alignment"> - <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> - </property> - <layout class="QVBoxLayout" name="verticalLayout_1"> - <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>70</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>70</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> - <widget class="QGroupBox" name="RingDriver"> - <property name="title"> - <string>Direct Joycon Driver</string> - </property> - <property name="alignment"> - <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> - </property> - <layout class="QVBoxLayout" name="verticalLayout_2"> - <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>10</number> - </property> - <item> - <layout class="QGridLayout" name="gridLayout"> - <property name="leftMargin"> - <number>10</number> - </property> - <property name="topMargin"> - <number>6</number> - </property> - <property name="rightMargin"> - <number>10</number> - </property> - <property name="bottomMargin"> - <number>10</number> - </property> - <property name="verticalSpacing"> - <number>10</number> - </property> - <item row="0" column="1"> - <spacer name="horizontalSpacer"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeType"> - <enum>QSizePolicy::Fixed</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>76</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item row="0" column="0"> - <widget class="QLabel" name="enable_ring_controller_label"> - <property name="text"> - <string>Enable Ring Input</string> - </property> - </widget> - </item> - <item row="0" column="2"> - <widget class="QPushButton" name="enable_ring_controller_button"> - <property name="text"> - <string>Enable</string> - </property> - </widget> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="ring_controller_sensor_label"> - <property name="text"> - <string>Ring Sensor Value</string> - </property> - </widget> - </item> - <item row="1" column="2"> - <widget class="QLabel" name="ring_controller_sensor_value"> - <property name="text"> - <string>Not connected</string> - </property> - <property name="alignment"> - <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> - </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 deleted file mode 100644 index e193b5f95..000000000 --- a/src/yuzu/configuration/configure_system.cpp +++ /dev/null @@ -1,206 +0,0 @@ -// SPDX-FileCopyrightText: 2016 Citra Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include <chrono> -#include <optional> -#include <vector> - -#include <QCheckBox> -#include <QComboBox> -#include <QDateTimeEdit> -#include <QFileDialog> -#include <QGraphicsItem> -#include <QLineEdit> -#include <QMessageBox> -#include <QSpinBox> - -#include "common/settings.h" -#include "core/core.h" -#include "ui_configure_system.h" -#include "yuzu/configuration/configuration_shared.h" -#include "yuzu/configuration/configure_system.h" -#include "yuzu/configuration/shared_widget.h" - -constexpr std::array<u32, 7> LOCALE_BLOCKLIST{ - // pzzefezrpnkzeidfej - // thhsrnhutlohsternp - // BHH4CG U - // Raa1AB S - // nn9 - // ts - 0b0100011100001100000, // Japan - 0b0000001101001100100, // Americas - 0b0100110100001000010, // Europe - 0b0100110100001000010, // Australia - 0b0000000000000000000, // China - 0b0100111100001000000, // Korea - 0b0100111100001000000, // Taiwan -}; - -static bool IsValidLocale(u32 region_index, u32 language_index) { - if (region_index >= LOCALE_BLOCKLIST.size()) { - return false; - } - return ((LOCALE_BLOCKLIST.at(region_index) >> language_index) & 1) == 0; -} - -ConfigureSystem::ConfigureSystem(Core::System& system_, - std::shared_ptr<std::vector<ConfigurationShared::Tab*>> group_, - const ConfigurationShared::Builder& builder, QWidget* parent) - : Tab(group_, parent), ui{std::make_unique<Ui::ConfigureSystem>()}, system{system_} { - ui->setupUi(this); - - const auto posix_time = std::chrono::system_clock::now().time_since_epoch(); - const auto current_time_s = - std::chrono::duration_cast<std::chrono::seconds>(posix_time).count(); - previous_time = current_time_s + Settings::values.custom_rtc_offset.GetValue(); - - Setup(builder); - - const auto locale_check = [this]() { - const auto region_index = combo_region->currentIndex(); - const auto language_index = combo_language->currentIndex(); - const bool valid_locale = IsValidLocale(region_index, language_index); - ui->label_warn_invalid_locale->setVisible(!valid_locale); - if (!valid_locale) { - ui->label_warn_invalid_locale->setText( - tr("Warning: \"%1\" is not a valid language for region \"%2\"") - .arg(combo_language->currentText()) - .arg(combo_region->currentText())); - } - }; - - const auto update_date_offset = [this]() { - if (!checkbox_rtc->isChecked()) { - return; - } - auto offset = date_rtc_offset->value(); - offset += date_rtc->dateTime().toSecsSinceEpoch() - previous_time; - previous_time = date_rtc->dateTime().toSecsSinceEpoch(); - date_rtc_offset->setValue(offset); - }; - const auto update_rtc_date = [this]() { UpdateRtcTime(); }; - - connect(combo_language, qOverload<int>(&QComboBox::currentIndexChanged), this, locale_check); - connect(combo_region, qOverload<int>(&QComboBox::currentIndexChanged), this, locale_check); - connect(checkbox_rtc, qOverload<int>(&QCheckBox::stateChanged), this, update_rtc_date); - connect(date_rtc_offset, qOverload<int>(&QSpinBox::valueChanged), this, update_rtc_date); - connect(date_rtc, &QDateTimeEdit::dateTimeChanged, this, update_date_offset); - - ui->label_warn_invalid_locale->setVisible(false); - locale_check(); - - SetConfiguration(); - UpdateRtcTime(); -} - -ConfigureSystem::~ConfigureSystem() = default; - -void ConfigureSystem::changeEvent(QEvent* event) { - if (event->type() == QEvent::LanguageChange) { - RetranslateUI(); - } - - QWidget::changeEvent(event); -} - -void ConfigureSystem::RetranslateUI() { - ui->retranslateUi(this); -} - -void ConfigureSystem::Setup(const ConfigurationShared::Builder& builder) { - auto& core_layout = *ui->core_widget->layout(); - auto& system_layout = *ui->system_widget->layout(); - - std::map<u32, QWidget*> core_hold{}; - std::map<u32, QWidget*> system_hold{}; - - std::vector<Settings::BasicSetting*> settings; - auto push = [&settings](auto& list) { - for (auto setting : list) { - settings.push_back(setting); - } - }; - - push(Settings::values.linkage.by_category[Settings::Category::Core]); - push(Settings::values.linkage.by_category[Settings::Category::System]); - - for (auto setting : settings) { - if (setting->Id() == Settings::values.use_docked_mode.Id() && - Settings::IsConfiguringGlobal()) { - continue; - } - - ConfigurationShared::Widget* widget = builder.BuildWidget(setting, apply_funcs); - - if (widget == nullptr) { - continue; - } - if (!widget->Valid()) { - widget->deleteLater(); - continue; - } - - // Keep track of the region_index (and language_index) combobox to validate the selected - // settings - if (setting->Id() == Settings::values.region_index.Id()) { - combo_region = widget->combobox; - } - - if (setting->Id() == Settings::values.language_index.Id()) { - combo_language = widget->combobox; - } - - if (setting->Id() == Settings::values.custom_rtc.Id()) { - checkbox_rtc = widget->checkbox; - } - - if (setting->Id() == Settings::values.custom_rtc.Id()) { - date_rtc = widget->date_time_edit; - } - - if (setting->Id() == Settings::values.custom_rtc_offset.Id()) { - date_rtc_offset = widget->spinbox; - } - - switch (setting->GetCategory()) { - case Settings::Category::Core: - core_hold.emplace(setting->Id(), widget); - break; - case Settings::Category::System: - system_hold.emplace(setting->Id(), widget); - break; - default: - widget->deleteLater(); - } - } - for (const auto& [label, widget] : core_hold) { - core_layout.addWidget(widget); - } - for (const auto& [id, widget] : system_hold) { - system_layout.addWidget(widget); - } -} - -void ConfigureSystem::UpdateRtcTime() { - const auto posix_time = std::chrono::system_clock::now().time_since_epoch(); - previous_time = std::chrono::duration_cast<std::chrono::seconds>(posix_time).count(); - date_rtc_offset->setEnabled(checkbox_rtc->isChecked()); - - if (checkbox_rtc->isChecked()) { - previous_time += date_rtc_offset->value(); - } - - const auto date = QDateTime::fromSecsSinceEpoch(previous_time); - date_rtc->setDateTime(date); -} - -void ConfigureSystem::SetConfiguration() {} - -void ConfigureSystem::ApplyConfiguration() { - const bool powered_on = system.IsPoweredOn(); - for (const auto& func : apply_funcs) { - func(powered_on); - } - UpdateRtcTime(); -} diff --git a/src/yuzu/configuration/configure_system.h b/src/yuzu/configuration/configure_system.h deleted file mode 100644 index a01c29dcf..000000000 --- a/src/yuzu/configuration/configure_system.h +++ /dev/null @@ -1,63 +0,0 @@ -// SPDX-FileCopyrightText: 2016 Citra Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include <functional> -#include <memory> -#include <vector> - -#include <QWidget> -#include "yuzu/configuration/configuration_shared.h" - -class QCheckBox; -class QLineEdit; -class QComboBox; -class QDateTimeEdit; -namespace Core { -class System; -} - -namespace Ui { -class ConfigureSystem; -} - -namespace ConfigurationShared { -class Builder; -} - -class ConfigureSystem : public ConfigurationShared::Tab { - Q_OBJECT - -public: - explicit ConfigureSystem(Core::System& system_, - std::shared_ptr<std::vector<ConfigurationShared::Tab*>> group, - const ConfigurationShared::Builder& builder, - QWidget* parent = nullptr); - ~ConfigureSystem() override; - - void ApplyConfiguration() override; - void SetConfiguration() override; - -private: - void changeEvent(QEvent* event) override; - void RetranslateUI(); - - void Setup(const ConfigurationShared::Builder& builder); - - void UpdateRtcTime(); - - std::vector<std::function<void(bool)>> apply_funcs{}; - - std::unique_ptr<Ui::ConfigureSystem> ui; - bool enabled = false; - - Core::System& system; - - QComboBox* combo_region; - QComboBox* combo_language; - QCheckBox* checkbox_rtc; - QDateTimeEdit* date_rtc; - QSpinBox* date_rtc_offset; - u64 previous_time; -}; diff --git a/src/yuzu/configuration/configure_system.ui b/src/yuzu/configuration/configure_system.ui deleted file mode 100644 index 04b771129..000000000 --- a/src/yuzu/configuration/configure_system.ui +++ /dev/null @@ -1,105 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>ConfigureSystem</class> - <widget class="QWidget" name="ConfigureSystem"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>605</width> - <height>483</height> - </rect> - </property> - <property name="windowTitle"> - <string>Form</string> - </property> - <property name="accessibleName"> - <string>System</string> - </property> - <layout class="QHBoxLayout" name="horizontalLayout"> - <item> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <widget class="QGroupBox" name="group_system_settings"> - <property name="title"> - <string>System</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout_2"> - <item> - <widget class="QWidget" name="system_widget" native="true"> - <layout class="QVBoxLayout" name="verticalLayout_3"> - <property name="leftMargin"> - <number>0</number> - </property> - <property name="topMargin"> - <number>0</number> - </property> - <property name="rightMargin"> - <number>0</number> - </property> - <property name="bottomMargin"> - <number>0</number> - </property> - </layout> - </widget> - </item> - <item> - <widget class="QLabel" name="label_warn_invalid_locale"> - <property name="text"> - <string/> - </property> - <property name="wordWrap"> - <bool>true</bool> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QGroupBox" name="coreGroup"> - <property name="title"> - <string>Core</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout_6"> - <item> - <widget class="QWidget" name="core_widget" native="true"> - <layout class="QVBoxLayout" name="verticalLayout_5"> - <property name="leftMargin"> - <number>0</number> - </property> - <property name="topMargin"> - <number>0</number> - </property> - <property name="rightMargin"> - <number>0</number> - </property> - <property name="bottomMargin"> - <number>0</number> - </property> - </layout> - </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> - </layout> - </item> - </layout> - </widget> - <resources/> - <connections/> -</ui> diff --git a/src/yuzu/configuration/configure_tas.cpp b/src/yuzu/configuration/configure_tas.cpp deleted file mode 100644 index 5a545aa70..000000000 --- a/src/yuzu/configuration/configure_tas.cpp +++ /dev/null @@ -1,81 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include <QFileDialog> -#include <QMessageBox> -#include "common/fs/fs.h" -#include "common/fs/path_util.h" -#include "common/settings.h" -#include "ui_configure_tas.h" -#include "yuzu/configuration/configure_tas.h" -#include "yuzu/uisettings.h" - -ConfigureTasDialog::ConfigureTasDialog(QWidget* parent) - : QDialog(parent), ui(std::make_unique<Ui::ConfigureTas>()) { - - ui->setupUi(this); - - setFocusPolicy(Qt::ClickFocus); - setWindowTitle(tr("TAS Configuration")); - - connect(ui->tas_path_button, &QToolButton::pressed, this, - [this] { SetDirectory(DirectoryTarget::TAS, ui->tas_path_edit); }); - - LoadConfiguration(); -} - -ConfigureTasDialog::~ConfigureTasDialog() = default; - -void ConfigureTasDialog::LoadConfiguration() { - ui->tas_path_edit->setText( - QString::fromStdString(Common::FS::GetYuzuPathString(Common::FS::YuzuPath::TASDir))); - ui->tas_enable->setChecked(Settings::values.tas_enable.GetValue()); - ui->tas_loop_script->setChecked(Settings::values.tas_loop.GetValue()); - ui->tas_pause_on_load->setChecked(Settings::values.pause_tas_on_load.GetValue()); -} - -void ConfigureTasDialog::ApplyConfiguration() { - Common::FS::SetYuzuPath(Common::FS::YuzuPath::TASDir, ui->tas_path_edit->text().toStdString()); - Settings::values.tas_enable.SetValue(ui->tas_enable->isChecked()); - Settings::values.tas_loop.SetValue(ui->tas_loop_script->isChecked()); - Settings::values.pause_tas_on_load.SetValue(ui->tas_pause_on_load->isChecked()); -} - -void ConfigureTasDialog::SetDirectory(DirectoryTarget target, QLineEdit* edit) { - QString caption; - - switch (target) { - case DirectoryTarget::TAS: - caption = tr("Select TAS Load Directory..."); - break; - } - - QString str = QFileDialog::getExistingDirectory(this, caption, edit->text()); - - if (str.isEmpty()) { - return; - } - - if (str.back() != QChar::fromLatin1('/')) { - str.append(QChar::fromLatin1('/')); - } - - edit->setText(str); -} - -void ConfigureTasDialog::changeEvent(QEvent* event) { - if (event->type() == QEvent::LanguageChange) { - RetranslateUI(); - } - - QDialog::changeEvent(event); -} - -void ConfigureTasDialog::RetranslateUI() { - ui->retranslateUi(this); -} - -void ConfigureTasDialog::HandleApplyButtonClicked() { - UISettings::values.configuration_applied = true; - ApplyConfiguration(); -} diff --git a/src/yuzu/configuration/configure_tas.h b/src/yuzu/configuration/configure_tas.h deleted file mode 100644 index a91891906..000000000 --- a/src/yuzu/configuration/configure_tas.h +++ /dev/null @@ -1,39 +0,0 @@ -// 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; -} - -class ConfigureTasDialog : public QDialog { - Q_OBJECT - -public: - explicit ConfigureTasDialog(QWidget* parent); - ~ConfigureTasDialog() override; - - /// Save all button configurations to settings file - void ApplyConfiguration(); - -private: - enum class DirectoryTarget { - TAS, - }; - - void LoadConfiguration(); - - void SetDirectory(DirectoryTarget target, QLineEdit* edit); - - void changeEvent(QEvent* event) override; - void RetranslateUI(); - - void HandleApplyButtonClicked(); - - std::unique_ptr<Ui::ConfigureTas> ui; -}; diff --git a/src/yuzu/configuration/configure_tas.ui b/src/yuzu/configuration/configure_tas.ui deleted file mode 100644 index 625af0c89..000000000 --- a/src/yuzu/configuration/configure_tas.ui +++ /dev/null @@ -1,182 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>ConfigureTas</class> - <widget class="QDialog" name="ConfigureTas"> - <layout class="QVBoxLayout" name="verticalLayout_1"> - <item> - <layout class="QHBoxLayout" name="horizontalLayout_1"> - <item> - <widget class="QGroupBox" name="groupBox_1"> - <property name="title"> - <string>TAS</string> - </property> - <layout class="QGridLayout" name="gridLayout_1"> - <item row="0" column="0" colspan="4"> - <widget class="QLabel" name="label_1"> - <property name="text"> - <string><html><head/><body><p>Reads controller input from scripts in the same format as TAS-nx scripts.<br/>For a more detailed explanation, please consult the <a href="https://yuzu-emu.org/help/feature/tas/"><span style=" text-decoration: underline; color:#039be5;">help page</span></a> on the yuzu website.</p></body></html></string> - </property> - <property name="openExternalLinks"> - <bool>true</bool> - </property> - </widget> - </item> - <item row="1" column="0" colspan="4"> - <widget class="QLabel" name="label_2"> - <property name="text"> - <string>To check which hotkeys control the playback/recording, please refer to the Hotkey settings (Configure -> General -> Hotkeys).</string> - </property> - <property name="wordWrap"> - <bool>true</bool> - </property> - </widget> - </item> - <item row="2" column="0" colspan="4"> - <widget class="QLabel" name="label_3"> - <property name="text"> - <string>WARNING: This is an experimental feature.<br/>It will not play back scripts frame perfectly with the current, imperfect syncing method.</string> - </property> - <property name="wordWrap"> - <bool>true</bool> - </property> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayout_2"> - <item> - <widget class="QGroupBox" name="groupBox_2"> - <property name="title"> - <string>Settings</string> - </property> - <layout class="QGridLayout" name="gridLayout_2"> - <item row="0" column="0" colspan="4"> - <widget class="QCheckBox" name="tas_enable"> - <property name="text"> - <string>Enable TAS features</string> - </property> - </widget> - </item> - <item row="1" column="0" colspan="4"> - <widget class="QCheckBox" name="tas_loop_script"> - <property name="text"> - <string>Loop script</string> - </property> - </widget> - </item> - <item row="2" column="0" colspan="4"> - <widget class="QCheckBox" name="tas_pause_on_load"> - <property name="enabled"> - <bool>false</bool> - </property> - <property name="text"> - <string>Pause execution during loads</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayout_3"> - <item> - <widget class="QGroupBox" name="groupBox_3"> - <property name="title"> - <string>Script Directory</string> - </property> - <layout class="QGridLayout" name="gridLayout_3"> - <item row="0" column="0"> - <widget class="QLabel" name="label_4"> - <property name="text"> - <string>Path</string> - </property> - </widget> - </item> - <item row="0" column="3"> - <widget class="QToolButton" name="tas_path_button"> - <property name="text"> - <string>...</string> - </property> - </widget> - </item> - <item row="0" column="2"> - <widget class="QLineEdit" name="tas_path_edit"/> - </item> - </layout> - </widget> - </item> - </layout> - </item> - <item> - <spacer name="verticalSpacer"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>40</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QDialogButtonBox" name="buttonBox"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="standardButtons"> - <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> - </property> - </widget> - </item> - </layout> - </widget> - <resources/> - <connections> - <connection> - <sender>buttonBox</sender> - <signal>accepted()</signal> - <receiver>ConfigureTas</receiver> - <slot>accept()</slot> - <hints> - <hint type="sourcelabel"> - <x>20</x> - <y>20</y> - </hint> - <hint type="destinationlabel"> - <x>20</x> - <y>20</y> - </hint> - </hints> - </connection> - <connection> - <sender>buttonBox</sender> - <signal>rejected()</signal> - <receiver>ConfigureTas</receiver> - <slot>reject()</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> -</ui> diff --git a/src/yuzu/configuration/configure_touch_from_button.cpp b/src/yuzu/configuration/configure_touch_from_button.cpp deleted file mode 100644 index 18e2eba69..000000000 --- a/src/yuzu/configuration/configure_touch_from_button.cpp +++ /dev/null @@ -1,617 +0,0 @@ -// SPDX-FileCopyrightText: 2020 Citra Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include <QInputDialog> -#include <QKeyEvent> -#include <QMessageBox> -#include <QMouseEvent> -#include <QStandardItemModel> -#include <QTimer> -#include "common/param_package.h" -#include "common/settings.h" -#include "core/frontend/framebuffer_layout.h" -#include "input_common/main.h" -#include "ui_configure_touch_from_button.h" -#include "yuzu/configuration/configure_touch_from_button.h" -#include "yuzu/configuration/configure_touch_widget.h" - -static 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 QString{}; - default: - return QKeySequence(key_code).toString(); - } -} - -static QString ButtonToText(const Common::ParamPackage& param) { - if (!param.Has("engine")) { - return QObject::tr("[not set]"); - } - - if (param.Get("engine", "") == "keyboard") { - return GetKeyName(param.Get("code", 0)); - } - - if (param.Get("engine", "") == "sdl") { - if (param.Has("hat")) { - const QString hat_str = QString::fromStdString(param.Get("hat", "")); - const QString direction_str = QString::fromStdString(param.Get("direction", "")); - - return QObject::tr("Hat %1 %2").arg(hat_str, direction_str); - } - - if (param.Has("axis")) { - const QString axis_str = QString::fromStdString(param.Get("axis", "")); - const QString direction_str = QString::fromStdString(param.Get("direction", "")); - - return QObject::tr("Axis %1%2").arg(axis_str, direction_str); - } - - if (param.Has("button")) { - const QString button_str = QString::fromStdString(param.Get("button", "")); - - return QObject::tr("Button %1").arg(button_str); - } - - return {}; - } - - return QObject::tr("[unknown]"); -} - -ConfigureTouchFromButton::ConfigureTouchFromButton( - 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}, - timeout_timer(std::make_unique<QTimer>()), poll_timer(std::make_unique<QTimer>()) { - ui->setupUi(this); - binding_list_model = new QStandardItemModel(0, 3, this); - binding_list_model->setHorizontalHeaderLabels( - {tr("Button"), tr("X", "X axis"), tr("Y", "Y axis")}); - ui->binding_list->setModel(binding_list_model); - ui->bottom_screen->SetCoordLabel(ui->coord_label); - - SetConfiguration(); - UpdateUiDisplay(); - ConnectEvents(); -} - -ConfigureTouchFromButton::~ConfigureTouchFromButton() = default; - -void ConfigureTouchFromButton::showEvent(QShowEvent* ev) { - QWidget::showEvent(ev); - - // width values are not valid in the constructor - const int w = - ui->binding_list->viewport()->contentsRect().width() / binding_list_model->columnCount(); - if (w <= 0) { - return; - } - ui->binding_list->setColumnWidth(0, w); - ui->binding_list->setColumnWidth(1, w); - ui->binding_list->setColumnWidth(2, w); -} - -void ConfigureTouchFromButton::SetConfiguration() { - for (const auto& touch_map : touch_maps) { - ui->mapping->addItem(QString::fromStdString(touch_map.name)); - } - - ui->mapping->setCurrentIndex(selected_index); -} - -void ConfigureTouchFromButton::UpdateUiDisplay() { - ui->button_delete->setEnabled(touch_maps.size() > 1); - ui->button_delete_bind->setEnabled(false); - - binding_list_model->removeRows(0, binding_list_model->rowCount()); - - for (const auto& button_str : touch_maps[selected_index].buttons) { - Common::ParamPackage package{button_str}; - QStandardItem* button = new QStandardItem(ButtonToText(package)); - button->setData(QString::fromStdString(button_str)); - button->setEditable(false); - QStandardItem* xcoord = new QStandardItem(QString::number(package.Get("x", 0))); - QStandardItem* ycoord = new QStandardItem(QString::number(package.Get("y", 0))); - binding_list_model->appendRow({button, xcoord, ycoord}); - - const int dot = ui->bottom_screen->AddDot(package.Get("x", 0), package.Get("y", 0)); - button->setData(dot, DataRoleDot); - } -} - -void ConfigureTouchFromButton::ConnectEvents() { - connect(ui->mapping, qOverload<int>(&QComboBox::currentIndexChanged), this, [this](int index) { - SaveCurrentMapping(); - selected_index = index; - UpdateUiDisplay(); - }); - connect(ui->button_new, &QPushButton::clicked, this, &ConfigureTouchFromButton::NewMapping); - connect(ui->button_delete, &QPushButton::clicked, this, - &ConfigureTouchFromButton::DeleteMapping); - connect(ui->button_rename, &QPushButton::clicked, this, - &ConfigureTouchFromButton::RenameMapping); - connect(ui->button_delete_bind, &QPushButton::clicked, this, - &ConfigureTouchFromButton::DeleteBinding); - connect(ui->binding_list, &QTreeView::doubleClicked, this, - &ConfigureTouchFromButton::EditBinding); - connect(ui->binding_list->selectionModel(), &QItemSelectionModel::selectionChanged, this, - &ConfigureTouchFromButton::OnBindingSelection); - connect(binding_list_model, &QStandardItemModel::itemChanged, this, - &ConfigureTouchFromButton::OnBindingChanged); - connect(ui->binding_list->model(), &QStandardItemModel::rowsAboutToBeRemoved, this, - &ConfigureTouchFromButton::OnBindingDeleted); - connect(ui->bottom_screen, &TouchScreenPreview::DotAdded, this, - &ConfigureTouchFromButton::NewBinding); - connect(ui->bottom_screen, &TouchScreenPreview::DotSelected, this, - &ConfigureTouchFromButton::SetActiveBinding); - connect(ui->bottom_screen, &TouchScreenPreview::DotMoved, this, - &ConfigureTouchFromButton::SetCoordinates); - connect(ui->buttonBox, &QDialogButtonBox::accepted, this, - &ConfigureTouchFromButton::ApplyConfiguration); - - 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")) { - SetPollingResult(params, false); - return; - } - }); -} - -void ConfigureTouchFromButton::SaveCurrentMapping() { - auto& map = touch_maps[selected_index]; - map.buttons.clear(); - for (int i = 0, rc = binding_list_model->rowCount(); i < rc; ++i) { - const auto bind_str = binding_list_model->index(i, 0) - .data(Qt::ItemDataRole::UserRole + 1) - .toString() - .toStdString(); - if (bind_str.empty()) { - continue; - } - Common::ParamPackage params{bind_str}; - if (!params.Has("engine")) { - continue; - } - params.Set("x", binding_list_model->index(i, 1).data().toInt()); - params.Set("y", binding_list_model->index(i, 2).data().toInt()); - map.buttons.emplace_back(params.Serialize()); - } -} - -void ConfigureTouchFromButton::NewMapping() { - const QString name = - QInputDialog::getText(this, tr("New Profile"), tr("Enter the name for the new profile.")); - if (name.isEmpty()) { - return; - } - touch_maps.emplace_back(Settings::TouchFromButtonMap{name.toStdString(), {}}); - ui->mapping->addItem(name); - ui->mapping->setCurrentIndex(ui->mapping->count() - 1); -} - -void ConfigureTouchFromButton::DeleteMapping() { - const auto answer = QMessageBox::question( - this, tr("Delete Profile"), tr("Delete profile %1?").arg(ui->mapping->currentText())); - if (answer != QMessageBox::Yes) { - return; - } - const bool blocked = ui->mapping->blockSignals(true); - ui->mapping->removeItem(selected_index); - ui->mapping->blockSignals(blocked); - touch_maps.erase(touch_maps.begin() + selected_index); - selected_index = ui->mapping->currentIndex(); - UpdateUiDisplay(); -} - -void ConfigureTouchFromButton::RenameMapping() { - const QString new_name = QInputDialog::getText(this, tr("Rename Profile"), tr("New name:")); - if (new_name.isEmpty()) { - return; - } - ui->mapping->setItemText(selected_index, new_name); - touch_maps[selected_index].name = new_name.toStdString(); -} - -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, - const bool cancel) { - auto* cell = binding_list_model->item(row_index, 0); - if (cancel) { - if (is_new) { - binding_list_model->removeRow(row_index); - } else { - cell->setText( - ButtonToText(Common::ParamPackage{cell->data().toString().toStdString()})); - } - } else { - cell->setText(ButtonToText(params)); - cell->setData(QString::fromStdString(params.Serialize())); - } - }; - - input_subsystem->BeginMapping(InputCommon::Polling::InputType::Button); - - grabKeyboard(); - grabMouse(); - qApp->setOverrideCursor(QCursor(Qt::CursorShape::ArrowCursor)); - timeout_timer->start(5000); // Cancel after 5 seconds - poll_timer->start(200); // Check for new inputs every 200ms -} - -void ConfigureTouchFromButton::NewBinding(const QPoint& pos) { - auto* button = new QStandardItem(); - button->setEditable(false); - auto* x_coord = new QStandardItem(QString::number(pos.x())); - auto* y_coord = new QStandardItem(QString::number(pos.y())); - - const int dot_id = ui->bottom_screen->AddDot(pos.x(), pos.y()); - button->setData(dot_id, DataRoleDot); - - binding_list_model->appendRow({button, x_coord, y_coord}); - ui->binding_list->setFocus(); - ui->binding_list->setCurrentIndex(button->index()); - - GetButtonInput(binding_list_model->rowCount() - 1, true); -} - -void ConfigureTouchFromButton::EditBinding(const QModelIndex& qi) { - if (qi.row() >= 0 && qi.column() == 0) { - GetButtonInput(qi.row(), false); - } -} - -void ConfigureTouchFromButton::DeleteBinding() { - const int row_index = ui->binding_list->currentIndex().row(); - if (row_index < 0) { - return; - } - ui->bottom_screen->RemoveDot(binding_list_model->index(row_index, 0).data(DataRoleDot).toInt()); - binding_list_model->removeRow(row_index); -} - -void ConfigureTouchFromButton::OnBindingSelection(const QItemSelection& selected, - const QItemSelection& deselected) { - ui->button_delete_bind->setEnabled(!selected.isEmpty()); - if (!selected.isEmpty()) { - const auto dot_data = selected.indexes().first().data(DataRoleDot); - if (dot_data.isValid()) { - ui->bottom_screen->HighlightDot(dot_data.toInt()); - } - } - if (!deselected.isEmpty()) { - const auto dot_data = deselected.indexes().first().data(DataRoleDot); - if (dot_data.isValid()) { - ui->bottom_screen->HighlightDot(dot_data.toInt(), false); - } - } -} - -void ConfigureTouchFromButton::OnBindingChanged(QStandardItem* item) { - if (item->column() == 0) { - return; - } - - const bool blocked = binding_list_model->blockSignals(true); - item->setText(QString::number( - std::clamp(item->text().toInt(), 0, - static_cast<int>((item->column() == 1 ? Layout::ScreenUndocked::Width - : Layout::ScreenUndocked::Height) - - 1)))); - binding_list_model->blockSignals(blocked); - - const auto dot_data = binding_list_model->index(item->row(), 0).data(DataRoleDot); - if (dot_data.isValid()) { - ui->bottom_screen->MoveDot(dot_data.toInt(), - binding_list_model->item(item->row(), 1)->text().toInt(), - binding_list_model->item(item->row(), 2)->text().toInt()); - } -} - -void ConfigureTouchFromButton::OnBindingDeleted(const QModelIndex& parent, int first, int last) { - for (int i = first; i <= last; ++i) { - const auto ix = binding_list_model->index(i, 0); - if (!ix.isValid()) { - return; - } - const auto dot_data = ix.data(DataRoleDot); - if (dot_data.isValid()) { - ui->bottom_screen->RemoveDot(dot_data.toInt()); - } - } -} - -void ConfigureTouchFromButton::SetActiveBinding(const int dot_id) { - for (int i = 0; i < binding_list_model->rowCount(); ++i) { - if (binding_list_model->index(i, 0).data(DataRoleDot) == dot_id) { - ui->binding_list->setCurrentIndex(binding_list_model->index(i, 0)); - ui->binding_list->setFocus(); - return; - } - } -} - -void ConfigureTouchFromButton::SetCoordinates(const int dot_id, const QPoint& pos) { - for (int i = 0; i < binding_list_model->rowCount(); ++i) { - if (binding_list_model->item(i, 0)->data(DataRoleDot) == dot_id) { - binding_list_model->item(i, 1)->setText(QString::number(pos.x())); - binding_list_model->item(i, 2)->setText(QString::number(pos.y())); - return; - } - } -} - -void ConfigureTouchFromButton::SetPollingResult(const Common::ParamPackage& params, - const bool cancel) { - timeout_timer->stop(); - poll_timer->stop(); - input_subsystem->StopMapping(); - - releaseKeyboard(); - releaseMouse(); - qApp->restoreOverrideCursor(); - - if (input_setter) { - (*input_setter)(params, cancel); - input_setter.reset(); - } -} - -void ConfigureTouchFromButton::keyPressEvent(QKeyEvent* event) { - if (!input_setter && event->key() == Qt::Key_Delete) { - DeleteBinding(); - return; - } - - if (!input_setter) { - return QDialog::keyPressEvent(event); - } - - if (event->key() != Qt::Key_Escape) { - SetPollingResult(Common::ParamPackage{InputCommon::GenerateKeyboardParam(event->key())}, - false); - } else { - SetPollingResult({}, true); - } -} - -void ConfigureTouchFromButton::ApplyConfiguration() { - SaveCurrentMapping(); - accept(); -} - -int ConfigureTouchFromButton::GetSelectedIndex() const { - return selected_index; -} - -std::vector<Settings::TouchFromButtonMap> ConfigureTouchFromButton::GetMaps() const { - return touch_maps; -} - -TouchScreenPreview::TouchScreenPreview(QWidget* parent) : QFrame(parent) { - setBackgroundRole(QPalette::ColorRole::Base); -} - -TouchScreenPreview::~TouchScreenPreview() = default; - -void TouchScreenPreview::SetCoordLabel(QLabel* const label) { - coord_label = label; -} - -int TouchScreenPreview::AddDot(const int device_x, const int device_y) { - QFont dot_font{QStringLiteral("monospace")}; - dot_font.setStyleHint(QFont::Monospace); - dot_font.setPointSize(20); - - auto* dot = new QLabel(this); - dot->setAttribute(Qt::WA_TranslucentBackground); - dot->setFont(dot_font); - dot->setText(QChar(0xD7)); // U+00D7 Multiplication Sign - dot->setAlignment(Qt::AlignmentFlag::AlignCenter); - dot->setProperty(PropId, ++max_dot_id); - dot->setProperty(PropX, device_x); - dot->setProperty(PropY, device_y); - dot->setCursor(Qt::CursorShape::PointingHandCursor); - dot->setMouseTracking(true); - dot->installEventFilter(this); - dot->show(); - PositionDot(dot, device_x, device_y); - dots.emplace_back(max_dot_id, dot); - return max_dot_id; -} - -void TouchScreenPreview::RemoveDot(const int id) { - const auto iter = std::find_if(dots.begin(), dots.end(), - [id](const auto& entry) { return entry.first == id; }); - if (iter == dots.cend()) { - return; - } - - iter->second->deleteLater(); - dots.erase(iter); -} - -void TouchScreenPreview::HighlightDot(const int id, const bool active) const { - for (const auto& dot : dots) { - if (dot.first == id) { - // use color property from the stylesheet, or fall back to the default palette - if (dot_highlight_color.isValid()) { - dot.second->setStyleSheet( - active ? QStringLiteral("color: %1").arg(dot_highlight_color.name()) - : QString{}); - } else { - dot.second->setForegroundRole(active ? QPalette::ColorRole::LinkVisited - : QPalette::ColorRole::NoRole); - } - if (active) { - dot.second->raise(); - } - return; - } - } -} - -void TouchScreenPreview::MoveDot(const int id, const int device_x, const int device_y) const { - const auto iter = std::find_if(dots.begin(), dots.end(), - [id](const auto& entry) { return entry.first == id; }); - if (iter == dots.cend()) { - return; - } - - iter->second->setProperty(PropX, device_x); - iter->second->setProperty(PropY, device_y); - PositionDot(iter->second, device_x, device_y); -} - -void TouchScreenPreview::resizeEvent(QResizeEvent* event) { - if (ignore_resize) { - return; - } - - const int target_width = std::min(width(), height() * 4 / 3); - const int target_height = std::min(height(), width() * 3 / 4); - if (target_width == width() && target_height == height()) { - return; - } - ignore_resize = true; - setGeometry((parentWidget()->contentsRect().width() - target_width) / 2, y(), target_width, - target_height); - ignore_resize = false; - - if (event->oldSize().width() != target_width || event->oldSize().height() != target_height) { - for (const auto& dot : dots) { - PositionDot(dot.second); - } - } -} - -void TouchScreenPreview::mouseMoveEvent(QMouseEvent* event) { - if (!coord_label) { - return; - } - const auto pos = MapToDeviceCoords(event->x(), event->y()); - if (pos) { - coord_label->setText(QStringLiteral("X: %1, Y: %2").arg(pos->x()).arg(pos->y())); - } else { - coord_label->clear(); - } -} - -void TouchScreenPreview::leaveEvent(QEvent* event) { - if (coord_label) { - coord_label->clear(); - } -} - -void TouchScreenPreview::mousePressEvent(QMouseEvent* event) { - if (event->button() != Qt::MouseButton::LeftButton) { - return; - } - const auto pos = MapToDeviceCoords(event->x(), event->y()); - if (pos) { - emit DotAdded(*pos); - } -} - -bool TouchScreenPreview::eventFilter(QObject* obj, QEvent* event) { - switch (event->type()) { - case QEvent::Type::MouseButtonPress: { - const auto mouse_event = static_cast<QMouseEvent*>(event); - if (mouse_event->button() != Qt::MouseButton::LeftButton) { - break; - } - emit DotSelected(obj->property(PropId).toInt()); - - drag_state.dot = qobject_cast<QLabel*>(obj); - drag_state.start_pos = mouse_event->globalPos(); - return true; - } - case QEvent::Type::MouseMove: { - if (!drag_state.dot) { - break; - } - const auto mouse_event = static_cast<QMouseEvent*>(event); - if (!drag_state.active) { - drag_state.active = - (mouse_event->globalPos() - drag_state.start_pos).manhattanLength() >= - QApplication::startDragDistance(); - if (!drag_state.active) { - break; - } - } - auto current_pos = mapFromGlobal(mouse_event->globalPos()); - current_pos.setX(std::clamp(current_pos.x(), contentsMargins().left(), - contentsMargins().left() + contentsRect().width() - 1)); - current_pos.setY(std::clamp(current_pos.y(), contentsMargins().top(), - contentsMargins().top() + contentsRect().height() - 1)); - const auto device_coord = MapToDeviceCoords(current_pos.x(), current_pos.y()); - if (device_coord) { - drag_state.dot->setProperty(PropX, device_coord->x()); - drag_state.dot->setProperty(PropY, device_coord->y()); - PositionDot(drag_state.dot, device_coord->x(), device_coord->y()); - emit DotMoved(drag_state.dot->property(PropId).toInt(), *device_coord); - if (coord_label) { - coord_label->setText( - QStringLiteral("X: %1, Y: %2").arg(device_coord->x()).arg(device_coord->y())); - } - } - return true; - } - case QEvent::Type::MouseButtonRelease: { - drag_state.dot.clear(); - drag_state.active = false; - return true; - } - default: - break; - } - return obj->eventFilter(obj, event); -} - -std::optional<QPoint> TouchScreenPreview::MapToDeviceCoords(const int screen_x, - const int screen_y) const { - const float t_x = 0.5f + static_cast<float>(screen_x - contentsMargins().left()) * - (Layout::ScreenUndocked::Width - 1) / (contentsRect().width() - 1); - const float t_y = 0.5f + static_cast<float>(screen_y - contentsMargins().top()) * - (Layout::ScreenUndocked::Height - 1) / - (contentsRect().height() - 1); - if (t_x >= 0.5f && t_x < Layout::ScreenUndocked::Width && t_y >= 0.5f && - t_y < Layout::ScreenUndocked::Height) { - - return QPoint{static_cast<int>(t_x), static_cast<int>(t_y)}; - } - return std::nullopt; -} - -void TouchScreenPreview::PositionDot(QLabel* const dot, const int device_x, - const int device_y) const { - const float device_coord_x = - static_cast<float>(device_x >= 0 ? device_x : dot->property(PropX).toInt()); - int x_coord = static_cast<int>( - device_coord_x * (contentsRect().width() - 1) / (Layout::ScreenUndocked::Width - 1) + - contentsMargins().left() - static_cast<float>(dot->width()) / 2 + 0.5f); - - const float device_coord_y = - static_cast<float>(device_y >= 0 ? device_y : dot->property(PropY).toInt()); - const int y_coord = static_cast<int>( - device_coord_y * (contentsRect().height() - 1) / (Layout::ScreenUndocked::Height - 1) + - contentsMargins().top() - static_cast<float>(dot->height()) / 2 + 0.5f); - - dot->move(x_coord, y_coord); -} diff --git a/src/yuzu/configuration/configure_touch_from_button.h b/src/yuzu/configuration/configure_touch_from_button.h deleted file mode 100644 index 5a1416d00..000000000 --- a/src/yuzu/configuration/configure_touch_from_button.h +++ /dev/null @@ -1,86 +0,0 @@ -// SPDX-FileCopyrightText: 2020 Citra Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include <functional> -#include <memory> -#include <optional> -#include <vector> -#include <QDialog> - -class QItemSelection; -class QModelIndex; -class QStandardItemModel; -class QStandardItem; -class QTimer; - -namespace Common { -class ParamPackage; -} - -namespace InputCommon { -class InputSubsystem; -} - -namespace Settings { -struct TouchFromButtonMap; -} - -namespace Ui { -class ConfigureTouchFromButton; -} - -class ConfigureTouchFromButton : public QDialog { - Q_OBJECT - -public: - explicit ConfigureTouchFromButton(QWidget* parent, - const std::vector<Settings::TouchFromButtonMap>& touch_maps_, - InputCommon::InputSubsystem* input_subsystem_, - int default_index = 0); - ~ConfigureTouchFromButton() override; - - int GetSelectedIndex() const; - std::vector<Settings::TouchFromButtonMap> GetMaps() const; - -public slots: - void ApplyConfiguration(); - void NewBinding(const QPoint& pos); - void SetActiveBinding(int dot_id); - void SetCoordinates(int dot_id, const QPoint& pos); - -protected: - void showEvent(QShowEvent* ev) override; - void keyPressEvent(QKeyEvent* event) override; - -private slots: - void NewMapping(); - void DeleteMapping(); - void RenameMapping(); - void EditBinding(const QModelIndex& qi); - void DeleteBinding(); - void OnBindingSelection(const QItemSelection& selected, const QItemSelection& deselected); - void OnBindingChanged(QStandardItem* item); - void OnBindingDeleted(const QModelIndex& parent, int first, int last); - -private: - void SetConfiguration(); - void UpdateUiDisplay(); - void ConnectEvents(); - void GetButtonInput(int row_index, bool is_new); - void SetPollingResult(const Common::ParamPackage& params, bool cancel); - void SaveCurrentMapping(); - - std::unique_ptr<Ui::ConfigureTouchFromButton> ui; - std::vector<Settings::TouchFromButtonMap> touch_maps; - QStandardItemModel* binding_list_model; - InputCommon::InputSubsystem* input_subsystem; - int selected_index; - - std::unique_ptr<QTimer> timeout_timer; - std::unique_ptr<QTimer> poll_timer; - std::optional<std::function<void(const Common::ParamPackage&, bool)>> input_setter; - - static constexpr int DataRoleDot = Qt::ItemDataRole::UserRole + 2; -}; diff --git a/src/yuzu/configuration/configure_touch_from_button.ui b/src/yuzu/configuration/configure_touch_from_button.ui deleted file mode 100644 index 757219d54..000000000 --- a/src/yuzu/configuration/configure_touch_from_button.ui +++ /dev/null @@ -1,221 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>ConfigureTouchFromButton</class> - <widget class="QDialog" name="ConfigureTouchFromButton"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>500</width> - <height>500</height> - </rect> - </property> - <property name="windowTitle"> - <string>Configure Touchscreen Mappings</string> - </property> - <layout class="QVBoxLayout"> - <item> - <layout class="QHBoxLayout" name="horizontalLayout"> - <item> - <widget class="QLabel" name="label"> - <property name="text"> - <string>Mapping:</string> - </property> - <property name="textFormat"> - <enum>Qt::PlainText</enum> - </property> - </widget> - </item> - <item> - <widget class="QComboBox" name="mapping"> - <property name="sizePolicy"> - <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="button_new"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Maximum" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string>New</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="button_delete"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Maximum" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string>Delete</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="button_rename"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Maximum" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string>Rename</string> - </property> - </widget> - </item> - </layout> - </item> - <item> - <widget class="Line" name="line"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - </widget> - </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayout_2"> - <item> - <widget class="QLabel" name="label_2"> - <property name="text"> - <string>Click the bottom area to add a point, then press a button to bind. -Drag points to change position, or double-click table cells to edit values.</string> - </property> - <property name="textFormat"> - <enum>Qt::PlainText</enum> - </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="button_delete_bind"> - <property name="text"> - <string>Delete Point</string> - </property> - </widget> - </item> - </layout> - </item> - <item> - <widget class="QTreeView" name="binding_list"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Expanding"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="rootIsDecorated"> - <bool>false</bool> - </property> - <property name="uniformRowHeights"> - <bool>true</bool> - </property> - <property name="itemsExpandable"> - <bool>false</bool> - </property> - </widget> - </item> - <item> - <widget class="TouchScreenPreview" name="bottom_screen"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Expanding"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimumSize"> - <size> - <width>160</width> - <height>120</height> - </size> - </property> - <property name="baseSize"> - <size> - <width>320</width> - <height>240</height> - </size> - </property> - <property name="cursor"> - <cursorShape>CrossCursor</cursorShape> - </property> - <property name="mouseTracking"> - <bool>true</bool> - </property> - <property name="autoFillBackground"> - <bool>true</bool> - </property> - <property name="frameShape"> - <enum>QFrame::StyledPanel</enum> - </property> - <property name="frameShadow"> - <enum>QFrame::Sunken</enum> - </property> - </widget> - </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayout_3"> - <item> - <widget class="QLabel" name="coord_label"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="textFormat"> - <enum>Qt::PlainText</enum> - </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> - <customwidgets> - <customwidget> - <class>TouchScreenPreview</class> - <extends>QFrame</extends> - <header>yuzu/configuration/configure_touch_widget.h</header> - <container>1</container> - </customwidget> - </customwidgets> - <resources/> - <connections> - <connection> - <sender>buttonBox</sender> - <signal>rejected()</signal> - <receiver>ConfigureTouchFromButton</receiver> - <slot>reject()</slot> - </connection> - </connections> -</ui> diff --git a/src/yuzu/configuration/configure_touch_widget.h b/src/yuzu/configuration/configure_touch_widget.h deleted file mode 100644 index 49f533afe..000000000 --- a/src/yuzu/configuration/configure_touch_widget.h +++ /dev/null @@ -1,61 +0,0 @@ -// SPDX-FileCopyrightText: 2020 Citra Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include <optional> -#include <utility> -#include <vector> -#include <QFrame> -#include <QPointer> - -class QLabel; - -// Widget for representing touchscreen coordinates -class TouchScreenPreview : public QFrame { - Q_OBJECT - Q_PROPERTY(QColor dotHighlightColor MEMBER dot_highlight_color) - -public: - explicit TouchScreenPreview(QWidget* parent); - ~TouchScreenPreview() override; - - void SetCoordLabel(QLabel*); - int AddDot(int device_x, int device_y); - void RemoveDot(int id); - void HighlightDot(int id, bool active = true) const; - void MoveDot(int id, int device_x, int device_y) const; - -signals: - void DotAdded(const QPoint& pos); - void DotSelected(int dot_id); - void DotMoved(int dot_id, const QPoint& pos); - -protected: - void resizeEvent(QResizeEvent*) override; - void mouseMoveEvent(QMouseEvent*) override; - void leaveEvent(QEvent*) override; - void mousePressEvent(QMouseEvent*) override; - bool eventFilter(QObject*, QEvent*) override; - -private: - std::optional<QPoint> MapToDeviceCoords(int screen_x, int screen_y) const; - void PositionDot(QLabel* dot, int device_x = -1, int device_y = -1) const; - - bool ignore_resize = false; - QPointer<QLabel> coord_label; - - std::vector<std::pair<int, QLabel*>> dots; - int max_dot_id = 0; - QColor dot_highlight_color; - static constexpr char PropId[] = "dot_id"; - static constexpr char PropX[] = "device_x"; - static constexpr char PropY[] = "device_y"; - - struct DragState { - bool active = false; - QPointer<QLabel> dot; - QPoint start_pos; - }; - DragState drag_state; -}; diff --git a/src/yuzu/configuration/configure_touchscreen_advanced.cpp b/src/yuzu/configuration/configure_touchscreen_advanced.cpp deleted file mode 100644 index 94df6d9d3..000000000 --- a/src/yuzu/configuration/configure_touchscreen_advanced.cpp +++ /dev/null @@ -1,50 +0,0 @@ -// SPDX-FileCopyrightText: 2016 Citra Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include <memory> -#include "common/settings.h" -#include "ui_configure_touchscreen_advanced.h" -#include "yuzu/configuration/configure_touchscreen_advanced.h" - -ConfigureTouchscreenAdvanced::ConfigureTouchscreenAdvanced(QWidget* parent) - : QDialog(parent), ui(std::make_unique<Ui::ConfigureTouchscreenAdvanced>()) { - ui->setupUi(this); - - connect(ui->restore_defaults_button, &QPushButton::clicked, this, - &ConfigureTouchscreenAdvanced::RestoreDefaults); - - LoadConfiguration(); - resize(0, 0); -} - -ConfigureTouchscreenAdvanced::~ConfigureTouchscreenAdvanced() = default; - -void ConfigureTouchscreenAdvanced::changeEvent(QEvent* event) { - if (event->type() == QEvent::LanguageChange) { - RetranslateUI(); - } - - QDialog::changeEvent(event); -} - -void ConfigureTouchscreenAdvanced::RetranslateUI() { - ui->retranslateUi(this); -} - -void ConfigureTouchscreenAdvanced::ApplyConfiguration() { - Settings::values.touchscreen.diameter_x = ui->diameter_x_box->value(); - Settings::values.touchscreen.diameter_y = ui->diameter_y_box->value(); - Settings::values.touchscreen.rotation_angle = ui->angle_box->value(); -} - -void ConfigureTouchscreenAdvanced::LoadConfiguration() { - ui->diameter_x_box->setValue(Settings::values.touchscreen.diameter_x); - ui->diameter_y_box->setValue(Settings::values.touchscreen.diameter_y); - ui->angle_box->setValue(Settings::values.touchscreen.rotation_angle); -} - -void ConfigureTouchscreenAdvanced::RestoreDefaults() { - ui->diameter_x_box->setValue(15); - ui->diameter_y_box->setValue(15); - ui->angle_box->setValue(0); -} diff --git a/src/yuzu/configuration/configure_touchscreen_advanced.h b/src/yuzu/configuration/configure_touchscreen_advanced.h deleted file mode 100644 index b6fdffdc8..000000000 --- a/src/yuzu/configuration/configure_touchscreen_advanced.h +++ /dev/null @@ -1,32 +0,0 @@ -// SPDX-FileCopyrightText: 2016 Citra Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include <memory> -#include <QDialog> - -namespace Ui { -class ConfigureTouchscreenAdvanced; -} - -class ConfigureTouchscreenAdvanced : public QDialog { - Q_OBJECT - -public: - explicit ConfigureTouchscreenAdvanced(QWidget* parent); - ~ConfigureTouchscreenAdvanced() 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(); - - std::unique_ptr<Ui::ConfigureTouchscreenAdvanced> ui; -}; diff --git a/src/yuzu/configuration/configure_touchscreen_advanced.ui b/src/yuzu/configuration/configure_touchscreen_advanced.ui deleted file mode 100644 index 88e7cf050..000000000 --- a/src/yuzu/configuration/configure_touchscreen_advanced.ui +++ /dev/null @@ -1,162 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>ConfigureTouchscreenAdvanced</class> - <widget class="QDialog" name="ConfigureTouchscreenAdvanced"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>298</width> - <height>339</height> - </rect> - </property> - <property name="windowTitle"> - <string>Configure Touchscreen</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>Warning: The settings in this page affect the inner workings of yuzu's emulated touchscreen. Changing them may result in undesirable behavior, such as the touchscreen partially or not working. You should only use this page if you know what you are doing.</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>Touch Parameters</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="1" column="1"> - <widget class="QLabel" name="label_4"> - <property name="text"> - <string>Touch Diameter Y</string> - </property> - </widget> - </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> - <item row="0" column="1"> - <widget class="QLabel" name="label_3"> - <property name="text"> - <string>Touch Diameter X</string> - </property> - </widget> - </item> - <item row="2" column="1"> - <widget class="QLabel" name="label_5"> - <property name="text"> - <string>Rotational Angle</string> - </property> - </widget> - </item> - <item row="0" column="2"> - <widget class="QSpinBox" name="diameter_x_box"/> - </item> - <item row="1" column="2"> - <widget class="QSpinBox" name="diameter_y_box"/> - </item> - <item row="2" column="2"> - <widget class="QSpinBox" name="angle_box"/> - </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>ConfigureTouchscreenAdvanced</receiver> - <slot>accept()</slot> - </connection> - <connection> - <sender>buttonBox</sender> - <signal>rejected()</signal> - <receiver>ConfigureTouchscreenAdvanced</receiver> - <slot>reject()</slot> - </connection> - </connections> -</ui> diff --git a/src/yuzu/configuration/configure_ui.cpp b/src/yuzu/configuration/configure_ui.cpp deleted file mode 100644 index f3c91586c..000000000 --- a/src/yuzu/configuration/configure_ui.cpp +++ /dev/null @@ -1,354 +0,0 @@ -// SPDX-FileCopyrightText: 2016 Citra Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include "yuzu/configuration/configure_ui.h" - -#include <array> -#include <cstdlib> -#include <set> -#include <stdexcept> -#include <string> -#include <utility> - -#include <QCheckBox> -#include <QComboBox> -#include <QCoreApplication> -#include <QDirIterator> -#include <QFileDialog> -#include <QString> -#include <QToolButton> -#include <QVariant> - -#include "common/common_types.h" -#include "common/fs/path_util.h" -#include "common/logging/log.h" -#include "common/settings.h" -#include "common/settings_enums.h" -#include "core/core.h" -#include "core/frontend/framebuffer_layout.h" -#include "ui_configure_ui.h" -#include "yuzu/uisettings.h" - -namespace { -constexpr std::array default_game_icon_sizes{ - std::make_pair(0, QT_TRANSLATE_NOOP("ConfigureUI", "None")), - std::make_pair(32, QT_TRANSLATE_NOOP("ConfigureUI", "Small (32x32)")), - std::make_pair(64, QT_TRANSLATE_NOOP("ConfigureUI", "Standard (64x64)")), - std::make_pair(128, QT_TRANSLATE_NOOP("ConfigureUI", "Large (128x128)")), - std::make_pair(256, QT_TRANSLATE_NOOP("ConfigureUI", "Full Size (256x256)")), -}; - -constexpr std::array default_folder_icon_sizes{ - std::make_pair(0, QT_TRANSLATE_NOOP("ConfigureUI", "None")), - std::make_pair(24, QT_TRANSLATE_NOOP("ConfigureUI", "Small (24x24)")), - std::make_pair(48, QT_TRANSLATE_NOOP("ConfigureUI", "Standard (48x48)")), - std::make_pair(72, QT_TRANSLATE_NOOP("ConfigureUI", "Large (72x72)")), -}; - -// clang-format off -constexpr std::array row_text_names{ - QT_TRANSLATE_NOOP("ConfigureUI", "Filename"), - QT_TRANSLATE_NOOP("ConfigureUI", "Filetype"), - QT_TRANSLATE_NOOP("ConfigureUI", "Title ID"), - QT_TRANSLATE_NOOP("ConfigureUI", "Title Name"), - QT_TRANSLATE_NOOP("ConfigureUI", "None"), -}; -// clang-format on - -QString GetTranslatedGameIconSize(size_t index) { - return QCoreApplication::translate("ConfigureUI", default_game_icon_sizes[index].second); -} - -QString GetTranslatedFolderIconSize(size_t index) { - return QCoreApplication::translate("ConfigureUI", default_folder_icon_sizes[index].second); -} - -QString GetTranslatedRowTextName(size_t index) { - return QCoreApplication::translate("ConfigureUI", row_text_names[index]); -} -} // Anonymous namespace - -static float GetUpFactor(Settings::ResolutionSetup res_setup) { - Settings::ResolutionScalingInfo info{}; - Settings::TranslateResolutionInfo(res_setup, info); - return info.up_factor; -} - -static void PopulateResolutionComboBox(QComboBox* screenshot_height, QWidget* parent) { - screenshot_height->clear(); - - const auto& enumeration = - Settings::EnumMetadata<Settings::ResolutionSetup>::Canonicalizations(); - std::set<u32> resolutions{}; - for (const auto& [name, value] : enumeration) { - const float up_factor = GetUpFactor(value); - u32 height_undocked = Layout::ScreenUndocked::Height * up_factor; - u32 height_docked = Layout::ScreenDocked::Height * up_factor; - resolutions.emplace(height_undocked); - resolutions.emplace(height_docked); - } - - screenshot_height->addItem(parent->tr("Auto", "Screenshot height option")); - for (const auto res : resolutions) { - screenshot_height->addItem(QString::fromStdString(std::to_string(res))); - } -} - -static u32 ScreenshotDimensionToInt(const QString& height) { - return std::strtoul(height.toUtf8(), nullptr, 0); -} - -ConfigureUi::ConfigureUi(Core::System& system_, QWidget* parent) - : QWidget(parent), ui{std::make_unique<Ui::ConfigureUi>()}, - ratio{Settings::values.aspect_ratio.GetValue()}, - resolution_setting{Settings::values.resolution_setup.GetValue()}, system{system_} { - ui->setupUi(this); - - InitializeLanguageComboBox(); - - for (const auto& theme : UISettings::themes) { - ui->theme_combobox->addItem(QString::fromUtf8(theme.first), - QString::fromUtf8(theme.second)); - } - - InitializeIconSizeComboBox(); - InitializeRowComboBoxes(); - - PopulateResolutionComboBox(ui->screenshot_height, this); - - SetConfiguration(); - - // Force game list reload if any of the relevant settings are changed. - connect(ui->show_add_ons, &QCheckBox::stateChanged, this, &ConfigureUi::RequestGameListUpdate); - connect(ui->show_compat, &QCheckBox::stateChanged, this, &ConfigureUi::RequestGameListUpdate); - connect(ui->show_size, &QCheckBox::stateChanged, this, &ConfigureUi::RequestGameListUpdate); - connect(ui->show_types, &QCheckBox::stateChanged, this, &ConfigureUi::RequestGameListUpdate); - connect(ui->show_play_time, &QCheckBox::stateChanged, this, - &ConfigureUi::RequestGameListUpdate); - connect(ui->game_icon_size_combobox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, - &ConfigureUi::RequestGameListUpdate); - connect(ui->folder_icon_size_combobox, QOverload<int>::of(&QComboBox::currentIndexChanged), - this, &ConfigureUi::RequestGameListUpdate); - connect(ui->row_1_text_combobox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, - &ConfigureUi::RequestGameListUpdate); - connect(ui->row_2_text_combobox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, - &ConfigureUi::RequestGameListUpdate); - - // Update text ComboBoxes after user interaction. - connect(ui->row_1_text_combobox, QOverload<int>::of(&QComboBox::activated), - [this] { ConfigureUi::UpdateSecondRowComboBox(); }); - connect(ui->row_2_text_combobox, QOverload<int>::of(&QComboBox::activated), - [this] { ConfigureUi::UpdateFirstRowComboBox(); }); - - // Set screenshot path to user specification. - connect(ui->screenshot_path_button, &QToolButton::pressed, this, [this] { - auto dir = - QFileDialog::getExistingDirectory(this, tr("Select Screenshots Path..."), - QString::fromStdString(Common::FS::GetYuzuPathString( - Common::FS::YuzuPath::ScreenshotsDir))); - if (!dir.isEmpty()) { - if (dir.back() != QChar::fromLatin1('/')) { - dir.append(QChar::fromLatin1('/')); - } - - ui->screenshot_path_edit->setText(dir); - } - }); - - connect(ui->screenshot_height, &QComboBox::currentTextChanged, [this]() { UpdateWidthText(); }); - - UpdateWidthText(); -} - -ConfigureUi::~ConfigureUi() = default; - -void ConfigureUi::ApplyConfiguration() { - UISettings::values.theme = - ui->theme_combobox->itemData(ui->theme_combobox->currentIndex()).toString().toStdString(); - UISettings::values.show_add_ons = ui->show_add_ons->isChecked(); - UISettings::values.show_compat = ui->show_compat->isChecked(); - UISettings::values.show_size = ui->show_size->isChecked(); - UISettings::values.show_types = ui->show_types->isChecked(); - UISettings::values.show_play_time = ui->show_play_time->isChecked(); - UISettings::values.game_icon_size = ui->game_icon_size_combobox->currentData().toUInt(); - UISettings::values.folder_icon_size = ui->folder_icon_size_combobox->currentData().toUInt(); - UISettings::values.row_1_text_id = ui->row_1_text_combobox->currentData().toUInt(); - UISettings::values.row_2_text_id = ui->row_2_text_combobox->currentData().toUInt(); - - UISettings::values.enable_screenshot_save_as = ui->enable_screenshot_save_as->isChecked(); - Common::FS::SetYuzuPath(Common::FS::YuzuPath::ScreenshotsDir, - ui->screenshot_path_edit->text().toStdString()); - - const u32 height = ScreenshotDimensionToInt(ui->screenshot_height->currentText()); - UISettings::values.screenshot_height.SetValue(height); - - RequestGameListUpdate(); - system.ApplySettings(); -} - -void ConfigureUi::RequestGameListUpdate() { - UISettings::values.is_game_list_reload_pending.exchange(true); -} - -void ConfigureUi::SetConfiguration() { - ui->theme_combobox->setCurrentIndex( - ui->theme_combobox->findData(QString::fromStdString(UISettings::values.theme))); - ui->language_combobox->setCurrentIndex(ui->language_combobox->findData( - QString::fromStdString(UISettings::values.language.GetValue()))); - ui->show_add_ons->setChecked(UISettings::values.show_add_ons.GetValue()); - ui->show_compat->setChecked(UISettings::values.show_compat.GetValue()); - ui->show_size->setChecked(UISettings::values.show_size.GetValue()); - ui->show_types->setChecked(UISettings::values.show_types.GetValue()); - ui->show_play_time->setChecked(UISettings::values.show_play_time.GetValue()); - ui->game_icon_size_combobox->setCurrentIndex( - ui->game_icon_size_combobox->findData(UISettings::values.game_icon_size.GetValue())); - ui->folder_icon_size_combobox->setCurrentIndex( - ui->folder_icon_size_combobox->findData(UISettings::values.folder_icon_size.GetValue())); - - ui->enable_screenshot_save_as->setChecked( - UISettings::values.enable_screenshot_save_as.GetValue()); - ui->screenshot_path_edit->setText(QString::fromStdString( - Common::FS::GetYuzuPathString(Common::FS::YuzuPath::ScreenshotsDir))); - - const auto height = UISettings::values.screenshot_height.GetValue(); - if (height == 0) { - ui->screenshot_height->setCurrentIndex(0); - } else { - ui->screenshot_height->setCurrentText(QStringLiteral("%1").arg(height)); - } -} - -void ConfigureUi::changeEvent(QEvent* event) { - if (event->type() == QEvent::LanguageChange) { - RetranslateUI(); - } - - QWidget::changeEvent(event); -} - -void ConfigureUi::RetranslateUI() { - ui->retranslateUi(this); - - for (int i = 0; i < ui->game_icon_size_combobox->count(); i++) { - ui->game_icon_size_combobox->setItemText(i, - GetTranslatedGameIconSize(static_cast<size_t>(i))); - } - - for (int i = 0; i < ui->folder_icon_size_combobox->count(); i++) { - ui->folder_icon_size_combobox->setItemText( - i, GetTranslatedFolderIconSize(static_cast<size_t>(i))); - } - - for (int i = 0; i < ui->row_1_text_combobox->count(); i++) { - const QString name = GetTranslatedRowTextName(static_cast<size_t>(i)); - - ui->row_1_text_combobox->setItemText(i, name); - ui->row_2_text_combobox->setItemText(i, name); - } -} - -void ConfigureUi::InitializeLanguageComboBox() { - 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(); - locale.truncate(locale.lastIndexOf(QLatin1Char{'.'})); - locale.remove(0, locale.lastIndexOf(QLatin1Char{'/'}) + 1); - const QString lang = QLocale::languageToString(QLocale(locale).language()); - const QString country = QLocale::countryToString(QLocale(locale).country()); - ui->language_combobox->addItem(QStringLiteral("%1 (%2)").arg(lang, country), locale); - } - - // Unlike other configuration changes, interface language changes need to be reflected on the - // interface immediately. This is done by passing a signal to the main window, and then - // retranslating when passing back. - connect(ui->language_combobox, qOverload<int>(&QComboBox::currentIndexChanged), this, - &ConfigureUi::OnLanguageChanged); -} - -void ConfigureUi::InitializeIconSizeComboBox() { - for (size_t i = 0; i < default_game_icon_sizes.size(); i++) { - const auto size = default_game_icon_sizes[i].first; - ui->game_icon_size_combobox->addItem(GetTranslatedGameIconSize(i), size); - } - for (size_t i = 0; i < default_folder_icon_sizes.size(); i++) { - const auto size = default_folder_icon_sizes[i].first; - ui->folder_icon_size_combobox->addItem(GetTranslatedFolderIconSize(i), size); - } -} - -void ConfigureUi::InitializeRowComboBoxes() { - UpdateFirstRowComboBox(true); - UpdateSecondRowComboBox(true); -} - -void ConfigureUi::UpdateFirstRowComboBox(bool init) { - const int currentIndex = - init ? UISettings::values.row_1_text_id.GetValue() - : ui->row_1_text_combobox->findData(ui->row_1_text_combobox->currentData()); - - ui->row_1_text_combobox->clear(); - - for (std::size_t i = 0; i < row_text_names.size(); i++) { - const QString row_text_name = GetTranslatedRowTextName(i); - ui->row_1_text_combobox->addItem(row_text_name, QVariant::fromValue(i)); - } - - ui->row_1_text_combobox->setCurrentIndex(ui->row_1_text_combobox->findData(currentIndex)); - - ui->row_1_text_combobox->removeItem(4); // None - ui->row_1_text_combobox->removeItem( - ui->row_1_text_combobox->findData(ui->row_2_text_combobox->currentData())); -} - -void ConfigureUi::UpdateSecondRowComboBox(bool init) { - const int currentIndex = - init ? UISettings::values.row_2_text_id.GetValue() - : ui->row_2_text_combobox->findData(ui->row_2_text_combobox->currentData()); - - ui->row_2_text_combobox->clear(); - - for (std::size_t i = 0; i < row_text_names.size(); ++i) { - const QString row_text_name = GetTranslatedRowTextName(i); - ui->row_2_text_combobox->addItem(row_text_name, QVariant::fromValue(i)); - } - - ui->row_2_text_combobox->setCurrentIndex(ui->row_2_text_combobox->findData(currentIndex)); - - ui->row_2_text_combobox->removeItem( - ui->row_2_text_combobox->findData(ui->row_1_text_combobox->currentData())); -} - -void ConfigureUi::OnLanguageChanged(int index) { - if (index == -1) - return; - - emit LanguageChanged(ui->language_combobox->itemData(index).toString()); -} - -void ConfigureUi::UpdateWidthText() { - const u32 height = ScreenshotDimensionToInt(ui->screenshot_height->currentText()); - const u32 width = UISettings::CalculateWidth(height, ratio); - if (height == 0) { - const auto up_factor = GetUpFactor(resolution_setting); - const u32 height_docked = Layout::ScreenDocked::Height * up_factor; - const u32 width_docked = UISettings::CalculateWidth(height_docked, ratio); - const u32 height_undocked = Layout::ScreenUndocked::Height * up_factor; - const u32 width_undocked = UISettings::CalculateWidth(height_undocked, ratio); - ui->screenshot_width->setText(tr("Auto (%1 x %2, %3 x %4)", "Screenshot width value") - .arg(width_undocked) - .arg(height_undocked) - .arg(width_docked) - .arg(height_docked)); - } else { - ui->screenshot_width->setText(QStringLiteral("%1 x").arg(width)); - } -} - -void ConfigureUi::UpdateScreenshotInfo(Settings::AspectRatio ratio_, - Settings::ResolutionSetup resolution_setting_) { - ratio = ratio_; - resolution_setting = resolution_setting_; - UpdateWidthText(); -} diff --git a/src/yuzu/configuration/configure_ui.h b/src/yuzu/configuration/configure_ui.h deleted file mode 100644 index 2a2563a13..000000000 --- a/src/yuzu/configuration/configure_ui.h +++ /dev/null @@ -1,58 +0,0 @@ -// SPDX-FileCopyrightText: 2016 Citra Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include <memory> -#include <QWidget> -#include "common/settings_enums.h" - -namespace Core { -class System; -} - -namespace Ui { -class ConfigureUi; -} - -class ConfigureUi : public QWidget { - Q_OBJECT - -public: - explicit ConfigureUi(Core::System& system_, QWidget* parent = nullptr); - ~ConfigureUi() override; - - void ApplyConfiguration(); - - void UpdateScreenshotInfo(Settings::AspectRatio ratio, - Settings::ResolutionSetup resolution_info); - -private slots: - void OnLanguageChanged(int index); - -signals: - void LanguageChanged(const QString& locale); - -private: - void RequestGameListUpdate(); - - void SetConfiguration(); - - void changeEvent(QEvent*) override; - void RetranslateUI(); - - void InitializeLanguageComboBox(); - void InitializeIconSizeComboBox(); - void InitializeRowComboBoxes(); - - void UpdateFirstRowComboBox(bool init = false); - void UpdateSecondRowComboBox(bool init = false); - - void UpdateWidthText(); - - std::unique_ptr<Ui::ConfigureUi> ui; - - Settings::AspectRatio ratio; - Settings::ResolutionSetup resolution_setting; - Core::System& system; -}; diff --git a/src/yuzu/configuration/configure_ui.ui b/src/yuzu/configuration/configure_ui.ui deleted file mode 100644 index b8e648381..000000000 --- a/src/yuzu/configuration/configure_ui.ui +++ /dev/null @@ -1,268 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>ConfigureUi</class> - <widget class="QWidget" name="ConfigureUi"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>363</width> - <height>603</height> - </rect> - </property> - <property name="windowTitle"> - <string>Form</string> - </property> - <property name="accessibleName"> - <string>UI</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <widget class="QGroupBox" name="general_groupBox"> - <property name="title"> - <string>General</string> - </property> - <layout class="QHBoxLayout" name="horizontalLayout"> - <item> - <layout class="QVBoxLayout" name="verticalLayout_2"> - <item> - <widget class="QLabel" name="label_change_language_info"> - <property name="text"> - <string>Note: Changing language will apply your configuration.</string> - </property> - <property name="wordWrap"> - <bool>true</bool> - </property> - </widget> - </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayout_2"> - <item> - <widget class="QLabel" name="language_label"> - <property name="text"> - <string>Interface language:</string> - </property> - </widget> - </item> - <item> - <widget class="QComboBox" name="language_combobox"/> - </item> - </layout> - </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayout_3"> - <item> - <widget class="QLabel" name="theme_label"> - <property name="text"> - <string>Theme:</string> - </property> - </widget> - </item> - <item> - <widget class="QComboBox" name="theme_combobox"/> - </item> - </layout> - </item> - </layout> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QGroupBox" name="GameListGroupBox"> - <property name="title"> - <string>Game List</string> - </property> - <layout class="QHBoxLayout" name="GameListHorizontalLayout"> - <item> - <layout class="QVBoxLayout" name="GeneralVerticalLayout"> - <item> - <widget class="QCheckBox" name="show_compat"> - <property name="text"> - <string>Show Compatibility List</string> - </property> - </widget> - </item> - <item> - <widget class="QCheckBox" name="show_add_ons"> - <property name="text"> - <string>Show Add-Ons Column</string> - </property> - </widget> - </item> - <item> - <widget class="QCheckBox" name="show_size"> - <property name="text"> - <string>Show Size Column</string> - </property> - </widget> - </item> - <item> - <widget class="QCheckBox" name="show_types"> - <property name="text"> - <string>Show File Types Column</string> - </property> - </widget> - </item> - <item> - <widget class="QCheckBox" name="show_play_time"> - <property name="text"> - <string>Show Play Time Column</string> - </property> - </widget> - </item> - <item> - <layout class="QHBoxLayout" name="game_icon_size_qhbox_layout_2"> - <item> - <widget class="QLabel" name="game_icon_size_label"> - <property name="text"> - <string>Game Icon Size:</string> - </property> - </widget> - </item> - <item> - <widget class="QComboBox" name="game_icon_size_combobox"/> - </item> - </layout> - </item> - <item> - <layout class="QHBoxLayout" name="folder_icon_size_qhbox_layout_2"> - <item> - <widget class="QLabel" name="folder_icon_size_label"> - <property name="text"> - <string>Folder Icon Size:</string> - </property> - </widget> - </item> - <item> - <widget class="QComboBox" name="folder_icon_size_combobox"/> - </item> - </layout> - </item> - <item> - <layout class="QHBoxLayout" name="row_1_qhbox_layout"> - <item> - <widget class="QLabel" name="row_1_label"> - <property name="text"> - <string>Row 1 Text:</string> - </property> - </widget> - </item> - <item> - <widget class="QComboBox" name="row_1_text_combobox"/> - </item> - </layout> - </item> - <item> - <layout class="QHBoxLayout" name="row_2_qhbox_layout"> - <item> - <widget class="QLabel" name="row_2_label"> - <property name="text"> - <string>Row 2 Text:</string> - </property> - </widget> - </item> - <item> - <widget class="QComboBox" name="row_2_text_combobox"/> - </item> - </layout> - </item> - </layout> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QGroupBox" name="screenshots_GroupBox"> - <property name="title"> - <string>Screenshots</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout_4"> - <item> - <layout class="QVBoxLayout" name="verticalLayout_3"> - <item> - <widget class="QCheckBox" name="enable_screenshot_save_as"> - <property name="text"> - <string>Ask Where To Save Screenshots (Windows Only)</string> - </property> - </widget> - </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayout_4"> - <item> - <widget class="QLabel" name="label"> - <property name="text"> - <string>Screenshots Path: </string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="screenshot_path_edit"/> - </item> - <item> - <widget class="QToolButton" name="screenshot_path_button"> - <property name="text"> - <string>...</string> - </property> - </widget> - </item> - </layout> - </item> - <item> - <layout class="QGridLayout" name="gridLayout"> - <property name="spacing"> - <number>6</number> - </property> - <item row="0" column="1"> - <layout class="QHBoxLayout" name="horizontalLayout_5"> - <item> - <widget class="QLabel" name="screenshot_width"> - <property name="text"> - <string>TextLabel</string> - </property> - <property name="alignment"> - <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> - </property> - </widget> - </item> - <item> - <widget class="QComboBox" name="screenshot_height"> - <property name="editable"> - <bool>true</bool> - </property> - </widget> - </item> - </layout> - </item> - <item row="0" column="0"> - <widget class="QLabel" name="label_3"> - <property name="text"> - <string>Resolution:</string> - </property> - </widget> - </item> - </layout> - </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> - </layout> - </widget> - <resources/> - <connections/> -</ui> diff --git a/src/yuzu/configuration/configure_vibration.cpp b/src/yuzu/configuration/configure_vibration.cpp deleted file mode 100644 index 6b1f4527b..000000000 --- a/src/yuzu/configuration/configure_vibration.cpp +++ /dev/null @@ -1,133 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include "common/settings.h" -#include "hid_core/frontend/emulated_controller.h" -#include "hid_core/hid_core.h" -#include "hid_core/hid_types.h" -#include "ui_configure_vibration.h" -#include "yuzu/configuration/configure_vibration.h" - -ConfigureVibration::ConfigureVibration(QWidget* parent, Core::HID::HIDCore& hid_core_) - : QDialog(parent), ui(std::make_unique<Ui::ConfigureVibration>()), hid_core{hid_core_} { - ui->setupUi(this); - - vibration_groupboxes = { - ui->vibrationGroupPlayer1, ui->vibrationGroupPlayer2, ui->vibrationGroupPlayer3, - ui->vibrationGroupPlayer4, ui->vibrationGroupPlayer5, ui->vibrationGroupPlayer6, - ui->vibrationGroupPlayer7, ui->vibrationGroupPlayer8, - }; - - vibration_spinboxes = { - ui->vibrationSpinPlayer1, ui->vibrationSpinPlayer2, ui->vibrationSpinPlayer3, - ui->vibrationSpinPlayer4, ui->vibrationSpinPlayer5, ui->vibrationSpinPlayer6, - ui->vibrationSpinPlayer7, ui->vibrationSpinPlayer8, - }; - - const auto& players = Settings::values.players.GetValue(); - - for (std::size_t i = 0; i < NUM_PLAYERS; ++i) { - auto controller = hid_core.GetEmulatedControllerByIndex(i); - Core::HID::ControllerUpdateCallback engine_callback{ - .on_change = [this, - i](Core::HID::ControllerTriggerType type) { VibrateController(type, i); }, - .is_npad_service = false, - }; - controller_callback_key[i] = controller->SetCallback(engine_callback); - vibration_groupboxes[i]->setChecked(players[i].vibration_enabled); - vibration_spinboxes[i]->setValue(players[i].vibration_strength); - } - - ui->checkBoxAccurateVibration->setChecked( - Settings::values.enable_accurate_vibrations.GetValue()); - - if (!Settings::IsConfiguringGlobal()) { - ui->checkBoxAccurateVibration->setDisabled(true); - } - - RetranslateUI(); -} - -ConfigureVibration::~ConfigureVibration() { - StopVibrations(); - - for (std::size_t i = 0; i < NUM_PLAYERS; ++i) { - auto controller = hid_core.GetEmulatedControllerByIndex(i); - controller->DeleteCallback(controller_callback_key[i]); - } -}; - -void ConfigureVibration::ApplyConfiguration() { - auto& players = Settings::values.players.GetValue(); - - for (std::size_t i = 0; i < NUM_PLAYERS; ++i) { - players[i].vibration_enabled = vibration_groupboxes[i]->isChecked(); - players[i].vibration_strength = vibration_spinboxes[i]->value(); - } - - Settings::values.enable_accurate_vibrations.SetValue( - ui->checkBoxAccurateVibration->isChecked()); -} - -void ConfigureVibration::changeEvent(QEvent* event) { - if (event->type() == QEvent::LanguageChange) { - RetranslateUI(); - } - - QDialog::changeEvent(event); -} - -void ConfigureVibration::RetranslateUI() { - ui->retranslateUi(this); -} - -void ConfigureVibration::VibrateController(Core::HID::ControllerTriggerType type, - std::size_t player_index) { - if (type != Core::HID::ControllerTriggerType::Button) { - return; - } - - auto& player = Settings::values.players.GetValue()[player_index]; - auto controller = hid_core.GetEmulatedControllerByIndex(player_index); - const int vibration_strength = vibration_spinboxes[player_index]->value(); - const auto& buttons = controller->GetButtonsValues(); - - bool button_is_pressed = false; - for (std::size_t i = 0; i < buttons.size(); ++i) { - if (buttons[i].value) { - button_is_pressed = true; - break; - } - } - - if (!button_is_pressed) { - StopVibrations(); - return; - } - - const bool old_vibration_enabled = player.vibration_enabled; - const int old_vibration_strength = player.vibration_strength; - player.vibration_enabled = true; - player.vibration_strength = vibration_strength; - - const Core::HID::VibrationValue vibration{ - .low_amplitude = 1.0f, - .low_frequency = 160.0f, - .high_amplitude = 1.0f, - .high_frequency = 320.0f, - }; - controller->SetVibration(Core::HID::DeviceIndex::Left, vibration); - controller->SetVibration(Core::HID::DeviceIndex::Right, vibration); - - // Restore previous values - player.vibration_enabled = old_vibration_enabled; - player.vibration_strength = old_vibration_strength; -} - -void ConfigureVibration::StopVibrations() { - for (std::size_t i = 0; i < NUM_PLAYERS; ++i) { - auto controller = hid_core.GetEmulatedControllerByIndex(i); - controller->SetVibration(Core::HID::DeviceIndex::Left, Core::HID::DEFAULT_VIBRATION_VALUE); - controller->SetVibration(Core::HID::DeviceIndex::Right, Core::HID::DEFAULT_VIBRATION_VALUE); - } -} diff --git a/src/yuzu/configuration/configure_vibration.h b/src/yuzu/configuration/configure_vibration.h deleted file mode 100644 index e9d05df51..000000000 --- a/src/yuzu/configuration/configure_vibration.h +++ /dev/null @@ -1,51 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include <array> -#include <memory> -#include <QDialog> - -class QGroupBox; -class QSpinBox; - -namespace Ui { -class ConfigureVibration; -} - -namespace Core::HID { -enum class ControllerTriggerType; -class HIDCore; -} // namespace Core::HID - -class ConfigureVibration : public QDialog { - Q_OBJECT - -public: - explicit ConfigureVibration(QWidget* parent, Core::HID::HIDCore& hid_core_); - ~ConfigureVibration() override; - - void ApplyConfiguration(); - -private: - void changeEvent(QEvent* event) override; - void RetranslateUI(); - void VibrateController(Core::HID::ControllerTriggerType type, std::size_t player_index); - void StopVibrations(); - - std::unique_ptr<Ui::ConfigureVibration> ui; - - static constexpr std::size_t NUM_PLAYERS = 8; - - /// Groupboxes encapsulating the vibration strength spinbox. - std::array<QGroupBox*, NUM_PLAYERS> vibration_groupboxes; - - /// Spinboxes representing the vibration strength percentage. - std::array<QSpinBox*, NUM_PLAYERS> vibration_spinboxes; - - /// Callback index to stop the controllers events - std::array<int, NUM_PLAYERS> controller_callback_key; - - Core::HID::HIDCore& hid_core; -}; diff --git a/src/yuzu/configuration/configure_vibration.ui b/src/yuzu/configuration/configure_vibration.ui deleted file mode 100644 index 447a18eb1..000000000 --- a/src/yuzu/configuration/configure_vibration.ui +++ /dev/null @@ -1,553 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>ConfigureVibration</class> - <widget class="QDialog" name="ConfigureVibration"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>364</width> - <height>242</height> - </rect> - </property> - <property name="windowTitle"> - <string>Configure Vibration</string> - </property> - <property name="styleSheet"> - <string notr="true"/> - </property> - <layout class="QVBoxLayout"> - <item row="0" column="0" colspan="4"> - <widget class="QLabel" name="label_1"> - <property name="text"> - <string>Press any controller button to vibrate the controller.</string> - </property> - </widget> - </item> - <item> - <widget class="QGroupBox" name="vibrationStrengthGroup"> - <property name="title"> - <string>Vibration</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout_3" stretch="0,0"> - <property name="leftMargin"> - <number>9</number> - </property> - <property name="topMargin"> - <number>9</number> - </property> - <property name="rightMargin"> - <number>9</number> - </property> - <property name="bottomMargin"> - <number>9</number> - </property> - <item> - <widget class="QWidget" name="player14Widget" native="true"> - <layout class="QHBoxLayout" name="horizontalLayout_4"> - <property name="leftMargin"> - <number>0</number> - </property> - <property name="topMargin"> - <number>0</number> - </property> - <property name="rightMargin"> - <number>0</number> - </property> - <property name="bottomMargin"> - <number>0</number> - </property> - <item> - <widget class="QGroupBox" name="vibrationGroupPlayer1"> - <property name="title"> - <string>Player 1</string> - </property> - <property name="checkable"> - <bool>true</bool> - </property> - <layout class="QHBoxLayout" name="horizontalLayout_8"> - <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="QSpinBox" name="vibrationSpinPlayer1"> - <property name="minimumSize"> - <size> - <width>68</width> - <height>21</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>68</width> - <height>16777215</height> - </size> - </property> - <property name="suffix"> - <string>%</string> - </property> - <property name="minimum"> - <number>1</number> - </property> - <property name="maximum"> - <number>150</number> - </property> - <property name="value"> - <number>100</number> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QGroupBox" name="vibrationGroupPlayer2"> - <property name="title"> - <string>Player 2</string> - </property> - <property name="checkable"> - <bool>true</bool> - </property> - <layout class="QHBoxLayout" name="horizontalLayout_9"> - <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="QSpinBox" name="vibrationSpinPlayer2"> - <property name="minimumSize"> - <size> - <width>68</width> - <height>21</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>68</width> - <height>16777215</height> - </size> - </property> - <property name="suffix"> - <string>%</string> - </property> - <property name="minimum"> - <number>1</number> - </property> - <property name="maximum"> - <number>150</number> - </property> - <property name="value"> - <number>100</number> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QGroupBox" name="vibrationGroupPlayer3"> - <property name="title"> - <string>Player 3</string> - </property> - <property name="checkable"> - <bool>true</bool> - </property> - <layout class="QHBoxLayout" name="horizontalLayout_10"> - <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="QSpinBox" name="vibrationSpinPlayer3"> - <property name="minimumSize"> - <size> - <width>68</width> - <height>21</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>68</width> - <height>16777215</height> - </size> - </property> - <property name="suffix"> - <string>%</string> - </property> - <property name="minimum"> - <number>1</number> - </property> - <property name="maximum"> - <number>150</number> - </property> - <property name="value"> - <number>100</number> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QGroupBox" name="vibrationGroupPlayer4"> - <property name="title"> - <string>Player 4</string> - </property> - <property name="checkable"> - <bool>true</bool> - </property> - <layout class="QHBoxLayout" name="horizontalLayout_11"> - <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="QSpinBox" name="vibrationSpinPlayer4"> - <property name="minimumSize"> - <size> - <width>68</width> - <height>21</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>68</width> - <height>16777215</height> - </size> - </property> - <property name="suffix"> - <string>%</string> - </property> - <property name="minimum"> - <number>1</number> - </property> - <property name="maximum"> - <number>150</number> - </property> - <property name="value"> - <number>100</number> - </property> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QWidget" name="player58Widget" native="true"> - <layout class="QHBoxLayout" name="horizontalLayout_6"> - <property name="leftMargin"> - <number>0</number> - </property> - <property name="topMargin"> - <number>0</number> - </property> - <property name="rightMargin"> - <number>0</number> - </property> - <property name="bottomMargin"> - <number>0</number> - </property> - <item> - <widget class="QGroupBox" name="vibrationGroupPlayer7"> - <property name="title"> - <string>Player 5</string> - </property> - <property name="checkable"> - <bool>true</bool> - </property> - <layout class="QHBoxLayout" name="horizontalLayout_14"> - <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="QSpinBox" name="vibrationSpinPlayer7"> - <property name="minimumSize"> - <size> - <width>68</width> - <height>21</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>68</width> - <height>16777215</height> - </size> - </property> - <property name="suffix"> - <string>%</string> - </property> - <property name="minimum"> - <number>1</number> - </property> - <property name="maximum"> - <number>150</number> - </property> - <property name="value"> - <number>100</number> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QGroupBox" name="vibrationGroupPlayer8"> - <property name="title"> - <string>Player 6</string> - </property> - <property name="checkable"> - <bool>true</bool> - </property> - <layout class="QHBoxLayout" name="horizontalLayout_15"> - <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="QSpinBox" name="vibrationSpinPlayer8"> - <property name="minimumSize"> - <size> - <width>68</width> - <height>21</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>68</width> - <height>16777215</height> - </size> - </property> - <property name="suffix"> - <string>%</string> - </property> - <property name="minimum"> - <number>1</number> - </property> - <property name="maximum"> - <number>150</number> - </property> - <property name="value"> - <number>100</number> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QGroupBox" name="vibrationGroupPlayer5"> - <property name="title"> - <string>Player 7</string> - </property> - <property name="checkable"> - <bool>true</bool> - </property> - <layout class="QHBoxLayout" name="horizontalLayout_12"> - <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="QSpinBox" name="vibrationSpinPlayer5"> - <property name="minimumSize"> - <size> - <width>68</width> - <height>21</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>68</width> - <height>16777215</height> - </size> - </property> - <property name="suffix"> - <string>%</string> - </property> - <property name="minimum"> - <number>1</number> - </property> - <property name="maximum"> - <number>150</number> - </property> - <property name="value"> - <number>100</number> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QGroupBox" name="vibrationGroupPlayer6"> - <property name="title"> - <string>Player 8</string> - </property> - <property name="checkable"> - <bool>true</bool> - </property> - <layout class="QHBoxLayout" name="horizontalLayout_13"> - <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="QSpinBox" name="vibrationSpinPlayer6"> - <property name="minimumSize"> - <size> - <width>68</width> - <height>21</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>68</width> - <height>16777215</height> - </size> - </property> - <property name="suffix"> - <string>%</string> - </property> - <property name="minimum"> - <number>1</number> - </property> - <property name="maximum"> - <number>150</number> - </property> - <property name="value"> - <number>100</number> - </property> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QGroupBox" name="vibrationSettingsGroup"> - <property name="title"> - <string>Settings</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <widget class="QCheckBox" name="checkBoxAccurateVibration"> - <property name="text"> - <string>Enable Accurate Vibration</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <spacer name="spacerVibration"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>167</width> - <height>55</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QDialogButtonBox" name="buttonBoxVibration"> - <property name="standardButtons"> - <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> - </property> - </widget> - </item> - </layout> - </widget> - <resources/> - <connections> - <connection> - <sender>buttonBoxVibration</sender> - <signal>accepted()</signal> - <receiver>ConfigureVibration</receiver> - <slot>accept()</slot> - </connection> - <connection> - <sender>buttonBoxVibration</sender> - <signal>rejected()</signal> - <receiver>ConfigureVibration</receiver> - <slot>reject()</slot> - </connection> - </connections> -</ui> diff --git a/src/yuzu/configuration/configure_web.cpp b/src/yuzu/configuration/configure_web.cpp deleted file mode 100644 index ab526e4ca..000000000 --- a/src/yuzu/configuration/configure_web.cpp +++ /dev/null @@ -1,180 +0,0 @@ -// SPDX-FileCopyrightText: 2017 Citra Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include <QIcon> -#include <QMessageBox> -#include <QtConcurrent/QtConcurrentRun> -#include "common/settings.h" -#include "core/telemetry_session.h" -#include "ui_configure_web.h" -#include "yuzu/configuration/configure_web.h" -#include "yuzu/uisettings.h" - -static constexpr char token_delimiter{':'}; - -static std::string GenerateDisplayToken(const std::string& username, const std::string& token) { - if (username.empty() || token.empty()) { - return {}; - } - - const std::string unencoded_display_token{username + token_delimiter + token}; - QByteArray b{unencoded_display_token.c_str()}; - QByteArray b64 = b.toBase64(); - return b64.toStdString(); -} - -static std::string UsernameFromDisplayToken(const std::string& display_token) { - const std::string unencoded_display_token{ - QByteArray::fromBase64(display_token.c_str()).toStdString()}; - return unencoded_display_token.substr(0, unencoded_display_token.find(token_delimiter)); -} - -static std::string TokenFromDisplayToken(const std::string& display_token) { - const std::string unencoded_display_token{ - QByteArray::fromBase64(display_token.c_str()).toStdString()}; - return unencoded_display_token.substr(unencoded_display_token.find(token_delimiter) + 1); -} - -ConfigureWeb::ConfigureWeb(QWidget* parent) - : QWidget(parent), ui(std::make_unique<Ui::ConfigureWeb>()) { - ui->setupUi(this); - connect(ui->button_regenerate_telemetry_id, &QPushButton::clicked, this, - &ConfigureWeb::RefreshTelemetryID); - connect(ui->button_verify_login, &QPushButton::clicked, this, &ConfigureWeb::VerifyLogin); - connect(&verify_watcher, &QFutureWatcher<bool>::finished, this, &ConfigureWeb::OnLoginVerified); - -#ifndef USE_DISCORD_PRESENCE - ui->discord_group->setVisible(false); -#endif - - SetConfiguration(); - RetranslateUI(); -} - -ConfigureWeb::~ConfigureWeb() = default; - -void ConfigureWeb::changeEvent(QEvent* event) { - if (event->type() == QEvent::LanguageChange) { - RetranslateUI(); - } - - QWidget::changeEvent(event); -} - -void ConfigureWeb::RetranslateUI() { - ui->retranslateUi(this); - - ui->telemetry_learn_more->setText( - tr("<a href='https://yuzu-emu.org/help/feature/telemetry/'><span style=\"text-decoration: " - "underline; color:#039be5;\">Learn more</span></a>")); - - ui->web_signup_link->setText( - tr("<a href='https://profile.yuzu-emu.org/'><span style=\"text-decoration: underline; " - "color:#039be5;\">Sign up</span></a>")); - - ui->web_token_info_link->setText( - tr("<a href='https://yuzu-emu.org/wiki/yuzu-web-service/'><span style=\"text-decoration: " - "underline; color:#039be5;\">What is my token?</span></a>")); - - ui->label_telemetry_id->setText( - tr("Telemetry ID: 0x%1").arg(QString::number(Core::GetTelemetryId(), 16).toUpper())); -} - -void ConfigureWeb::SetConfiguration() { - ui->web_credentials_disclaimer->setWordWrap(true); - - ui->telemetry_learn_more->setOpenExternalLinks(true); - ui->web_signup_link->setOpenExternalLinks(true); - ui->web_token_info_link->setOpenExternalLinks(true); - - if (Settings::values.yuzu_username.GetValue().empty()) { - ui->username->setText(tr("Unspecified")); - } else { - ui->username->setText(QString::fromStdString(Settings::values.yuzu_username.GetValue())); - } - - ui->toggle_telemetry->setChecked(Settings::values.enable_telemetry.GetValue()); - ui->edit_token->setText(QString::fromStdString(GenerateDisplayToken( - Settings::values.yuzu_username.GetValue(), Settings::values.yuzu_token.GetValue()))); - - // Connect after setting the values, to avoid calling OnLoginChanged now - connect(ui->edit_token, &QLineEdit::textChanged, this, &ConfigureWeb::OnLoginChanged); - - user_verified = true; - - ui->toggle_discordrpc->setChecked(UISettings::values.enable_discord_presence.GetValue()); -} - -void ConfigureWeb::ApplyConfiguration() { - Settings::values.enable_telemetry = ui->toggle_telemetry->isChecked(); - UISettings::values.enable_discord_presence = ui->toggle_discordrpc->isChecked(); - if (user_verified) { - Settings::values.yuzu_username = - UsernameFromDisplayToken(ui->edit_token->text().toStdString()); - Settings::values.yuzu_token = TokenFromDisplayToken(ui->edit_token->text().toStdString()); - } else { - QMessageBox::warning( - this, tr("Token not verified"), - tr("Token was not verified. The change to your token has not been saved.")); - } -} - -void ConfigureWeb::RefreshTelemetryID() { - const u64 new_telemetry_id{Core::RegenerateTelemetryId()}; - ui->label_telemetry_id->setText( - tr("Telemetry ID: 0x%1").arg(QString::number(new_telemetry_id, 16).toUpper())); -} - -void ConfigureWeb::OnLoginChanged() { - if (ui->edit_token->text().isEmpty()) { - user_verified = true; - // Empty = no icon - ui->label_token_verified->setPixmap(QPixmap()); - ui->label_token_verified->setToolTip(QString()); - } else { - user_verified = false; - - // 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())] { - return Core::VerifyLogin(username, token); - })); -} - -void ConfigureWeb::OnLoginVerified() { - ui->button_verify_login->setEnabled(true); - ui->button_verify_login->setText(tr("Verify")); - if (verify_watcher.result()) { - user_verified = true; - - 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 { - 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 deleted file mode 100644 index 03feb55f8..000000000 --- a/src/yuzu/configuration/configure_web.h +++ /dev/null @@ -1,39 +0,0 @@ -// SPDX-FileCopyrightText: 2017 Citra Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include <memory> -#include <QFutureWatcher> -#include <QWidget> - -namespace Ui { -class ConfigureWeb; -} - -class ConfigureWeb : public QWidget { - Q_OBJECT - -public: - explicit ConfigureWeb(QWidget* parent = nullptr); - ~ConfigureWeb() override; - - void ApplyConfiguration(); - void SetWebServiceConfigEnabled(bool enabled); - -private: - void changeEvent(QEvent* event) override; - void RetranslateUI(); - - void RefreshTelemetryID(); - void OnLoginChanged(); - void VerifyLogin(); - void OnLoginVerified(); - - void SetConfiguration(); - - bool user_verified = true; - QFutureWatcher<bool> verify_watcher; - - std::unique_ptr<Ui::ConfigureWeb> ui; -}; diff --git a/src/yuzu/configuration/configure_web.ui b/src/yuzu/configuration/configure_web.ui deleted file mode 100644 index 3ac3864be..000000000 --- a/src/yuzu/configuration/configure_web.ui +++ /dev/null @@ -1,210 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>ConfigureWeb</class> - <widget class="QWidget" name="ConfigureWeb"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>926</width> - <height>561</height> - </rect> - </property> - <property name="windowTitle"> - <string>Form</string> - </property> - <property name="accessibleName"> - <string>Web</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <layout class="QVBoxLayout" name="verticalLayout_3"> - <item> - <widget class="QGroupBox" name="groupBoxWebConfig"> - <property name="title"> - <string>yuzu Web Service</string> - </property> - <layout class="QVBoxLayout" name="verticalLayoutYuzuWebService"> - <item> - <widget class="QLabel" name="web_credentials_disclaimer"> - <property name="text"> - <string>By providing your username and token, you agree to allow yuzu to collect additional usage data, which may include user identifying information.</string> - </property> - </widget> - </item> - <item> - <layout class="QGridLayout" name="gridLayoutYuzuUsername"> - <item row="2" column="3"> - <widget class="QPushButton" name="button_verify_login"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="layoutDirection"> - <enum>Qt::RightToLeft</enum> - </property> - <property name="text"> - <string>Verify</string> - </property> - </widget> - </item> - <item row="2" column="0"> - <widget class="QLabel" name="web_signup_link"> - <property name="text"> - <string>Sign up</string> - </property> - </widget> - </item> - <item row="0" column="1" colspan="3"> - <widget class="QLabel" name="username"/> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="label_token"> - <property name="text"> - <string>Token: </string> - </property> - </widget> - </item> - <item row="1" column="4"> - <widget class="QLabel" name="label_token_verified"/> - </item> - <item row="0" column="0"> - <widget class="QLabel" name="label_username"> - <property name="text"> - <string>Username: </string> - </property> - </widget> - </item> - <item row="1" column="1" colspan="3"> - <widget class="QLineEdit" name="edit_token"> - <property name="maxLength"> - <number>80</number> - </property> - <property name="echoMode"> - <enum>QLineEdit::Password</enum> - </property> - </widget> - </item> - <item row="2" column="1"> - <widget class="QLabel" name="web_token_info_link"> - <property name="text"> - <string>What is my token?</string> - </property> - </widget> - </item> - <item row="2" column="2"> - <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> - </layout> - </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> - </property> - <layout class="QVBoxLayout" name="verticalLayout_2"> - <item> - <widget class="QCheckBox" name="toggle_telemetry"> - <property name="text"> - <string>Share anonymous usage data with the yuzu team</string> - </property> - </widget> - </item> - <item> - <widget class="QLabel" name="telemetry_learn_more"> - <property name="text"> - <string>Learn more</string> - </property> - </widget> - </item> - <item> - <layout class="QGridLayout" name="gridLayoutTelemetryId"> - <item row="0" column="0"> - <widget class="QLabel" name="label_telemetry_id"> - <property name="text"> - <string>Telemetry ID:</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QPushButton" name="button_regenerate_telemetry_id"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="layoutDirection"> - <enum>Qt::RightToLeft</enum> - </property> - <property name="text"> - <string>Regenerate</string> - </property> - </widget> - </item> - </layout> - </item> - </layout> - </widget> - </item> - </layout> - </item> - <item> - <widget class="QGroupBox" name="discord_group"> - <property name="title"> - <string>Discord Presence</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout_21"> - <item> - <widget class="QCheckBox" name="toggle_discordrpc"> - <property name="text"> - <string>Show Current Game in your Discord Status</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> - </layout> - </widget> - <resources/> - <connections/> -</ui> diff --git a/src/yuzu/configuration/input_profiles.cpp b/src/yuzu/configuration/input_profiles.cpp deleted file mode 100644 index ebebadc94..000000000 --- a/src/yuzu/configuration/input_profiles.cpp +++ /dev/null @@ -1,134 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include <fmt/format.h> - -#include "common/fs/fs.h" -#include "common/fs/path_util.h" -#include "common/logging/log.h" -#include "frontend_common/config.h" -#include "yuzu/configuration/input_profiles.h" - -namespace FS = Common::FS; - -namespace { - -bool ProfileExistsInFilesystem(std::string_view profile_name) { - return FS::Exists(FS::GetYuzuPath(FS::YuzuPath::ConfigDir) / "input" / - fmt::format("{}.ini", profile_name)); -} - -bool IsINI(const std::filesystem::path& filename) { - return filename.extension() == ".ini"; -} - -std::filesystem::path GetNameWithoutExtension(std::filesystem::path filename) { - return filename.replace_extension(); -} - -} // namespace - -InputProfiles::InputProfiles() { - const auto input_profile_loc = FS::GetYuzuPath(FS::YuzuPath::ConfigDir) / "input"; - - if (!FS::IsDir(input_profile_loc)) { - return; - } - - FS::IterateDirEntries( - input_profile_loc, - [this](const std::filesystem::path& full_path) { - const auto filename = full_path.filename(); - const auto name_without_ext = - Common::FS::PathToUTF8String(GetNameWithoutExtension(filename)); - - if (IsINI(filename) && IsProfileNameValid(name_without_ext)) { - map_profiles.insert_or_assign( - name_without_ext, - std::make_unique<QtConfig>(name_without_ext, Config::ConfigType::InputProfile)); - } - - return true; - }, - FS::DirEntryFilter::File); -} - -InputProfiles::~InputProfiles() = default; - -std::vector<std::string> InputProfiles::GetInputProfileNames() { - std::vector<std::string> profile_names; - profile_names.reserve(map_profiles.size()); - - auto it = map_profiles.cbegin(); - while (it != map_profiles.cend()) { - const auto& [profile_name, config] = *it; - if (!ProfileExistsInFilesystem(profile_name)) { - it = map_profiles.erase(it); - continue; - } - - profile_names.push_back(profile_name); - ++it; - } - - std::stable_sort(profile_names.begin(), profile_names.end()); - - return profile_names; -} - -bool InputProfiles::IsProfileNameValid(std::string_view profile_name) { - return profile_name.find_first_of("<>:;\"/\\|,.!?*") == std::string::npos; -} - -bool InputProfiles::CreateProfile(const std::string& profile_name, std::size_t player_index) { - if (ProfileExistsInMap(profile_name)) { - return false; - } - - map_profiles.insert_or_assign( - profile_name, std::make_unique<QtConfig>(profile_name, Config::ConfigType::InputProfile)); - - return SaveProfile(profile_name, player_index); -} - -bool InputProfiles::DeleteProfile(const std::string& profile_name) { - if (!ProfileExistsInMap(profile_name)) { - return false; - } - - if (!ProfileExistsInFilesystem(profile_name) || - FS::RemoveFile(map_profiles[profile_name]->GetConfigFilePath())) { - map_profiles.erase(profile_name); - } - - return !ProfileExistsInMap(profile_name) && !ProfileExistsInFilesystem(profile_name); -} - -bool InputProfiles::LoadProfile(const std::string& profile_name, std::size_t player_index) { - if (!ProfileExistsInMap(profile_name)) { - return false; - } - - if (!ProfileExistsInFilesystem(profile_name)) { - map_profiles.erase(profile_name); - return false; - } - - LOG_INFO(Config, "Loading input profile `{}`", profile_name); - - map_profiles[profile_name]->ReadQtControlPlayerValues(player_index); - return true; -} - -bool InputProfiles::SaveProfile(const std::string& profile_name, std::size_t player_index) { - if (!ProfileExistsInMap(profile_name)) { - return false; - } - - map_profiles[profile_name]->SaveQtControlPlayerValues(player_index); - return true; -} - -bool InputProfiles::ProfileExistsInMap(const std::string& profile_name) const { - return map_profiles.find(profile_name) != map_profiles.end(); -} diff --git a/src/yuzu/configuration/input_profiles.h b/src/yuzu/configuration/input_profiles.h deleted file mode 100644 index 023ec74a6..000000000 --- a/src/yuzu/configuration/input_profiles.h +++ /dev/null @@ -1,36 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include <string> -#include <unordered_map> - -#include "configuration/qt_config.h" - -namespace Core { -class System; -} - -class Config; - -class InputProfiles { - -public: - explicit InputProfiles(); - virtual ~InputProfiles(); - - std::vector<std::string> GetInputProfileNames(); - - static bool IsProfileNameValid(std::string_view profile_name); - - bool CreateProfile(const std::string& profile_name, std::size_t player_index); - bool DeleteProfile(const std::string& profile_name); - bool LoadProfile(const std::string& profile_name, std::size_t player_index); - bool SaveProfile(const std::string& profile_name, std::size_t player_index); - -private: - bool ProfileExistsInMap(const std::string& profile_name) const; - - std::unordered_map<std::string, std::unique_ptr<QtConfig>> map_profiles; -}; diff --git a/src/yuzu/configuration/qt_config.cpp b/src/yuzu/configuration/qt_config.cpp deleted file mode 100644 index 37951b9c8..000000000 --- a/src/yuzu/configuration/qt_config.cpp +++ /dev/null @@ -1,560 +0,0 @@ -// SPDX-FileCopyrightText: 2023 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include "common/logging/log.h" -#include "input_common/main.h" -#include "qt_config.h" -#include "uisettings.h" - -const std::array<int, Settings::NativeButton::NumButtons> QtConfig::default_buttons = { - Qt::Key_C, Qt::Key_X, Qt::Key_V, Qt::Key_Z, Qt::Key_F, - Qt::Key_G, Qt::Key_Q, Qt::Key_E, Qt::Key_R, Qt::Key_T, - Qt::Key_M, Qt::Key_N, Qt::Key_Left, Qt::Key_Up, Qt::Key_Right, - Qt::Key_Down, Qt::Key_Q, Qt::Key_E, 0, 0, - Qt::Key_Q, Qt::Key_E, -}; - -const std::array<int, Settings::NativeMotion::NumMotions> QtConfig::default_motions = { - Qt::Key_7, - Qt::Key_8, -}; - -const std::array<std::array<int, 4>, Settings::NativeAnalog::NumAnalogs> QtConfig::default_analogs{{ - { - Qt::Key_W, - Qt::Key_S, - Qt::Key_A, - Qt::Key_D, - }, - { - Qt::Key_I, - Qt::Key_K, - Qt::Key_J, - Qt::Key_L, - }, -}}; - -const std::array<int, 2> QtConfig::default_stick_mod = { - Qt::Key_Shift, - 0, -}; - -const std::array<int, 2> QtConfig::default_ringcon_analogs{{ - Qt::Key_A, - Qt::Key_D, -}}; - -QtConfig::QtConfig(const std::string& config_name, const ConfigType config_type) - : Config(config_type) { - Initialize(config_name); - if (config_type != ConfigType::InputProfile) { - ReadQtValues(); - SaveQtValues(); - } -} - -QtConfig::~QtConfig() { - if (global) { - QtConfig::SaveAllValues(); - } -} - -void QtConfig::ReloadAllValues() { - Reload(); - ReadQtValues(); - SaveQtValues(); -} - -void QtConfig::SaveAllValues() { - SaveValues(); - SaveQtValues(); -} - -void QtConfig::ReadQtValues() { - if (global) { - ReadUIValues(); - } - ReadQtControlValues(); -} - -void QtConfig::ReadQtPlayerValues(const std::size_t player_index) { - std::string player_prefix; - if (type != ConfigType::InputProfile) { - player_prefix.append("player_").append(ToString(player_index)).append("_"); - } - - auto& player = Settings::values.players.GetValue()[player_index]; - if (IsCustomConfig()) { - const auto profile_name = - ReadStringSetting(std::string(player_prefix).append("profile_name")); - if (profile_name.empty()) { - // Use the global input config - player = Settings::values.players.GetValue(true)[player_index]; - player.profile_name = ""; - return; - } - } - - for (int i = 0; i < Settings::NativeButton::NumButtons; ++i) { - const std::string default_param = InputCommon::GenerateKeyboardParam(default_buttons[i]); - auto& player_buttons = player.buttons[i]; - - player_buttons = ReadStringSetting( - std::string(player_prefix).append(Settings::NativeButton::mapping[i]), default_param); - if (player_buttons.empty()) { - player_buttons = default_param; - } - } - - for (int i = 0; i < Settings::NativeAnalog::NumAnalogs; ++i) { - const std::string default_param = InputCommon::GenerateAnalogParamFromKeys( - default_analogs[i][0], default_analogs[i][1], default_analogs[i][2], - default_analogs[i][3], default_stick_mod[i], 0.5f); - auto& player_analogs = player.analogs[i]; - - player_analogs = ReadStringSetting( - std::string(player_prefix).append(Settings::NativeAnalog::mapping[i]), default_param); - if (player_analogs.empty()) { - player_analogs = default_param; - } - } - - for (int i = 0; i < Settings::NativeMotion::NumMotions; ++i) { - const std::string default_param = InputCommon::GenerateKeyboardParam(default_motions[i]); - auto& player_motions = player.motions[i]; - - player_motions = ReadStringSetting( - std::string(player_prefix).append(Settings::NativeMotion::mapping[i]), default_param); - if (player_motions.empty()) { - player_motions = default_param; - } - } -} - -void QtConfig::ReadHidbusValues() { - 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 = ReadStringSetting(std::string("ring_controller"), default_param); - if (ringcon_analogs.empty()) { - ringcon_analogs = default_param; - } -} - -void QtConfig::ReadDebugControlValues() { - for (int i = 0; i < Settings::NativeButton::NumButtons; ++i) { - const std::string default_param = InputCommon::GenerateKeyboardParam(default_buttons[i]); - auto& debug_pad_buttons = Settings::values.debug_pad_buttons[i]; - - debug_pad_buttons = ReadStringSetting( - std::string("debug_pad_").append(Settings::NativeButton::mapping[i]), default_param); - if (debug_pad_buttons.empty()) { - debug_pad_buttons = default_param; - } - } - - for (int i = 0; i < Settings::NativeAnalog::NumAnalogs; ++i) { - const std::string default_param = InputCommon::GenerateAnalogParamFromKeys( - default_analogs[i][0], default_analogs[i][1], default_analogs[i][2], - default_analogs[i][3], default_stick_mod[i], 0.5f); - auto& debug_pad_analogs = Settings::values.debug_pad_analogs[i]; - - debug_pad_analogs = ReadStringSetting( - std::string("debug_pad_").append(Settings::NativeAnalog::mapping[i]), default_param); - if (debug_pad_analogs.empty()) { - debug_pad_analogs = default_param; - } - } -} - -void QtConfig::ReadQtControlValues() { - BeginGroup(Settings::TranslateCategory(Settings::Category::Controls)); - - Settings::values.players.SetGlobal(!IsCustomConfig()); - for (std::size_t p = 0; p < Settings::values.players.GetValue().size(); ++p) { - ReadQtPlayerValues(p); - } - if (IsCustomConfig()) { - EndGroup(); - return; - } - ReadDebugControlValues(); - ReadHidbusValues(); - - EndGroup(); -} - -void QtConfig::ReadPathValues() { - BeginGroup(Settings::TranslateCategory(Settings::Category::Paths)); - - UISettings::values.roms_path = ReadStringSetting(std::string("romsPath")); - UISettings::values.game_dir_deprecated = - ReadStringSetting(std::string("gameListRootDir"), std::string(".")); - UISettings::values.game_dir_deprecated_deepscan = - ReadBooleanSetting(std::string("gameListDeepScan"), std::make_optional(false)); - - const int gamedirs_size = BeginArray(std::string("gamedirs")); - for (int i = 0; i < gamedirs_size; ++i) { - SetArrayIndex(i); - UISettings::GameDir game_dir; - game_dir.path = ReadStringSetting(std::string("path")); - game_dir.deep_scan = - ReadBooleanSetting(std::string("deep_scan"), std::make_optional(false)); - game_dir.expanded = ReadBooleanSetting(std::string("expanded"), std::make_optional(true)); - UISettings::values.game_dirs.append(game_dir); - } - EndArray(); - - // Create NAND and SD card directories if empty, these are not removable through the UI, - // also carries over old game list settings if present - if (UISettings::values.game_dirs.empty()) { - UISettings::GameDir game_dir; - game_dir.path = std::string("SDMC"); - game_dir.expanded = true; - UISettings::values.game_dirs.append(game_dir); - game_dir.path = std::string("UserNAND"); - UISettings::values.game_dirs.append(game_dir); - game_dir.path = std::string("SysNAND"); - UISettings::values.game_dirs.append(game_dir); - if (UISettings::values.game_dir_deprecated != std::string(".")) { - game_dir.path = UISettings::values.game_dir_deprecated; - game_dir.deep_scan = UISettings::values.game_dir_deprecated_deepscan; - UISettings::values.game_dirs.append(game_dir); - } - } - UISettings::values.recent_files = - QString::fromStdString(ReadStringSetting(std::string("recentFiles"))) - .split(QStringLiteral(", "), Qt::SkipEmptyParts, Qt::CaseSensitive); - - ReadCategory(Settings::Category::Paths); - - EndGroup(); -} - -void QtConfig::ReadShortcutValues() { - BeginGroup(Settings::TranslateCategory(Settings::Category::Shortcuts)); - - for (const auto& [name, group, shortcut] : UISettings::default_hotkeys) { - BeginGroup(group); - BeginGroup(name); - - // No longer using ReadSetting for shortcut.second as it inaccurately returns a value of 1 - // for WidgetWithChildrenShortcut which is a value of 3. Needed to fix shortcuts the open - // a file dialog in windowed mode - UISettings::values.shortcuts.push_back( - {name, - group, - {ReadStringSetting(std::string("KeySeq"), shortcut.keyseq), - ReadStringSetting(std::string("Controller_KeySeq"), shortcut.controller_keyseq), - shortcut.context, - ReadBooleanSetting(std::string("Repeat"), std::optional(shortcut.repeat))}}); - - EndGroup(); // name - EndGroup(); // group - } - - EndGroup(); -} - -void QtConfig::ReadUIValues() { - BeginGroup(Settings::TranslateCategory(Settings::Category::Ui)); - - UISettings::values.theme = ReadStringSetting( - std::string("theme"), - std::string(UISettings::themes[static_cast<size_t>(UISettings::default_theme)].second)); - - ReadUIGamelistValues(); - ReadUILayoutValues(); - ReadPathValues(); - ReadScreenshotValues(); - ReadShortcutValues(); - ReadMultiplayerValues(); - - ReadCategory(Settings::Category::Ui); - ReadCategory(Settings::Category::UiGeneral); - - EndGroup(); -} - -void QtConfig::ReadUIGamelistValues() { - BeginGroup(Settings::TranslateCategory(Settings::Category::UiGameList)); - - ReadCategory(Settings::Category::UiGameList); - - const int favorites_size = BeginArray("favorites"); - for (int i = 0; i < favorites_size; i++) { - SetArrayIndex(i); - UISettings::values.favorited_ids.append( - ReadUnsignedIntegerSetting(std::string("program_id"))); - } - EndArray(); - - EndGroup(); -} - -void QtConfig::ReadUILayoutValues() { - BeginGroup(Settings::TranslateCategory(Settings::Category::UiGameList)); - - ReadCategory(Settings::Category::UiLayout); - - EndGroup(); -} - -void QtConfig::ReadMultiplayerValues() { - BeginGroup(Settings::TranslateCategory(Settings::Category::Multiplayer)); - - ReadCategory(Settings::Category::Multiplayer); - - // Read ban list back - int size = BeginArray(std::string("username_ban_list")); - UISettings::values.multiplayer_ban_list.first.resize(size); - for (int i = 0; i < size; ++i) { - SetArrayIndex(i); - UISettings::values.multiplayer_ban_list.first[i] = - ReadStringSetting(std::string("username"), std::string("")); - } - EndArray(); - - size = BeginArray(std::string("ip_ban_list")); - UISettings::values.multiplayer_ban_list.second.resize(size); - for (int i = 0; i < size; ++i) { - UISettings::values.multiplayer_ban_list.second[i] = - ReadStringSetting("username", std::string("")); - } - EndArray(); - - EndGroup(); -} - -void QtConfig::SaveQtValues() { - if (global) { - LOG_DEBUG(Config, "Saving global Qt configuration values"); - SaveUIValues(); - } else { - LOG_DEBUG(Config, "Saving Qt configuration values"); - } - SaveQtControlValues(); - - WriteToIni(); -} - -void QtConfig::SaveQtPlayerValues(const std::size_t player_index) { - std::string player_prefix; - if (type != ConfigType::InputProfile) { - player_prefix = std::string("player_").append(ToString(player_index)).append("_"); - } - - const auto& player = Settings::values.players.GetValue()[player_index]; - if (IsCustomConfig() && player.profile_name.empty()) { - // No custom profile selected - return; - } - - for (int i = 0; i < Settings::NativeButton::NumButtons; ++i) { - const std::string default_param = InputCommon::GenerateKeyboardParam(default_buttons[i]); - WriteStringSetting(std::string(player_prefix).append(Settings::NativeButton::mapping[i]), - player.buttons[i], std::make_optional(default_param)); - } - for (int i = 0; i < Settings::NativeAnalog::NumAnalogs; ++i) { - const std::string default_param = InputCommon::GenerateAnalogParamFromKeys( - default_analogs[i][0], default_analogs[i][1], default_analogs[i][2], - default_analogs[i][3], default_stick_mod[i], 0.5f); - WriteStringSetting(std::string(player_prefix).append(Settings::NativeAnalog::mapping[i]), - player.analogs[i], std::make_optional(default_param)); - } - for (int i = 0; i < Settings::NativeMotion::NumMotions; ++i) { - const std::string default_param = InputCommon::GenerateKeyboardParam(default_motions[i]); - WriteStringSetting(std::string(player_prefix).append(Settings::NativeMotion::mapping[i]), - player.motions[i], std::make_optional(default_param)); - } -} - -void QtConfig::SaveDebugControlValues() { - for (int i = 0; i < Settings::NativeButton::NumButtons; ++i) { - const std::string default_param = InputCommon::GenerateKeyboardParam(default_buttons[i]); - WriteStringSetting(std::string("debug_pad_").append(Settings::NativeButton::mapping[i]), - Settings::values.debug_pad_buttons[i], - std::make_optional(default_param)); - } - for (int i = 0; i < Settings::NativeAnalog::NumAnalogs; ++i) { - const std::string default_param = InputCommon::GenerateAnalogParamFromKeys( - default_analogs[i][0], default_analogs[i][1], default_analogs[i][2], - default_analogs[i][3], default_stick_mod[i], 0.5f); - WriteStringSetting(std::string("debug_pad_").append(Settings::NativeAnalog::mapping[i]), - Settings::values.debug_pad_analogs[i], - std::make_optional(default_param)); - } -} - -void QtConfig::SaveHidbusValues() { - const std::string default_param = InputCommon::GenerateAnalogParamFromKeys( - 0, 0, default_ringcon_analogs[0], default_ringcon_analogs[1], 0, 0.05f); - WriteStringSetting(std::string("ring_controller"), Settings::values.ringcon_analogs, - std::make_optional(default_param)); -} - -void QtConfig::SaveQtControlValues() { - BeginGroup(Settings::TranslateCategory(Settings::Category::Controls)); - - Settings::values.players.SetGlobal(!IsCustomConfig()); - for (std::size_t p = 0; p < Settings::values.players.GetValue().size(); ++p) { - SaveQtPlayerValues(p); - } - if (IsCustomConfig()) { - EndGroup(); - return; - } - SaveDebugControlValues(); - SaveHidbusValues(); - - EndGroup(); -} - -void QtConfig::SavePathValues() { - BeginGroup(Settings::TranslateCategory(Settings::Category::Paths)); - - WriteCategory(Settings::Category::Paths); - - WriteStringSetting(std::string("romsPath"), UISettings::values.roms_path); - BeginArray(std::string("gamedirs")); - for (int i = 0; i < UISettings::values.game_dirs.size(); ++i) { - SetArrayIndex(i); - const auto& game_dir = UISettings::values.game_dirs[i]; - WriteStringSetting(std::string("path"), game_dir.path); - WriteBooleanSetting(std::string("deep_scan"), game_dir.deep_scan, - std::make_optional(false)); - WriteBooleanSetting(std::string("expanded"), game_dir.expanded, std::make_optional(true)); - } - EndArray(); - - WriteStringSetting(std::string("recentFiles"), - UISettings::values.recent_files.join(QStringLiteral(", ")).toStdString()); - - EndGroup(); -} - -void QtConfig::SaveShortcutValues() { - BeginGroup(Settings::TranslateCategory(Settings::Category::Shortcuts)); - - // Lengths of UISettings::values.shortcuts & default_hotkeys are same. - // However, their ordering must also be the same. - for (std::size_t i = 0; i < UISettings::default_hotkeys.size(); i++) { - const auto& [name, group, shortcut] = UISettings::values.shortcuts[i]; - const auto& default_hotkey = UISettings::default_hotkeys[i].shortcut; - - BeginGroup(group); - BeginGroup(name); - - WriteStringSetting(std::string("KeySeq"), shortcut.keyseq, - std::make_optional(default_hotkey.keyseq)); - WriteStringSetting(std::string("Controller_KeySeq"), shortcut.controller_keyseq, - std::make_optional(default_hotkey.controller_keyseq)); - WriteIntegerSetting(std::string("Context"), shortcut.context, - std::make_optional(default_hotkey.context)); - WriteBooleanSetting(std::string("Repeat"), shortcut.repeat, - std::make_optional(default_hotkey.repeat)); - - EndGroup(); // name - EndGroup(); // group - } - - EndGroup(); -} - -void QtConfig::SaveUIValues() { - BeginGroup(Settings::TranslateCategory(Settings::Category::Ui)); - - WriteCategory(Settings::Category::Ui); - WriteCategory(Settings::Category::UiGeneral); - - WriteStringSetting( - std::string("theme"), UISettings::values.theme, - std::make_optional(std::string( - UISettings::themes[static_cast<size_t>(UISettings::default_theme)].second))); - - SaveUIGamelistValues(); - SaveUILayoutValues(); - SavePathValues(); - SaveScreenshotValues(); - SaveShortcutValues(); - SaveMultiplayerValues(); - - EndGroup(); -} - -void QtConfig::SaveUIGamelistValues() { - BeginGroup(Settings::TranslateCategory(Settings::Category::UiGameList)); - - WriteCategory(Settings::Category::UiGameList); - - BeginArray(std::string("favorites")); - for (int i = 0; i < UISettings::values.favorited_ids.size(); i++) { - SetArrayIndex(i); - WriteIntegerSetting(std::string("program_id"), UISettings::values.favorited_ids[i]); - } - EndArray(); // favorites - - EndGroup(); -} - -void QtConfig::SaveUILayoutValues() { - BeginGroup(Settings::TranslateCategory(Settings::Category::UiLayout)); - - WriteCategory(Settings::Category::UiLayout); - - EndGroup(); -} - -void QtConfig::SaveMultiplayerValues() { - BeginGroup(std::string("Multiplayer")); - - WriteCategory(Settings::Category::Multiplayer); - - // Write ban list - BeginArray(std::string("username_ban_list")); - for (std::size_t i = 0; i < UISettings::values.multiplayer_ban_list.first.size(); ++i) { - SetArrayIndex(static_cast<int>(i)); - WriteStringSetting(std::string("username"), - UISettings::values.multiplayer_ban_list.first[i]); - } - EndArray(); // username_ban_list - - BeginArray(std::string("ip_ban_list")); - for (std::size_t i = 0; i < UISettings::values.multiplayer_ban_list.second.size(); ++i) { - SetArrayIndex(static_cast<int>(i)); - WriteStringSetting(std::string("ip"), UISettings::values.multiplayer_ban_list.second[i]); - } - EndArray(); // ip_ban_list - - EndGroup(); -} - -std::vector<Settings::BasicSetting*>& QtConfig::FindRelevantList(Settings::Category category) { - auto& map = Settings::values.linkage.by_category; - if (map.contains(category)) { - return Settings::values.linkage.by_category[category]; - } - return UISettings::values.linkage.by_category[category]; -} - -void QtConfig::ReadQtControlPlayerValues(std::size_t player_index) { - BeginGroup(Settings::TranslateCategory(Settings::Category::Controls)); - - ReadPlayerValues(player_index); - ReadQtPlayerValues(player_index); - - EndGroup(); -} - -void QtConfig::SaveQtControlPlayerValues(std::size_t player_index) { - BeginGroup(Settings::TranslateCategory(Settings::Category::Controls)); - - LOG_DEBUG(Config, "Saving players control configuration values"); - SavePlayerValues(player_index); - SaveQtPlayerValues(player_index); - - EndGroup(); - - WriteToIni(); -} diff --git a/src/yuzu/configuration/qt_config.h b/src/yuzu/configuration/qt_config.h deleted file mode 100644 index dc2dceb4d..000000000 --- a/src/yuzu/configuration/qt_config.h +++ /dev/null @@ -1,55 +0,0 @@ -// SPDX-FileCopyrightText: 2023 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include <QMetaType> - -#include "frontend_common/config.h" - -class QtConfig final : public Config { -public: - explicit QtConfig(const std::string& config_name = "qt-config", - ConfigType config_type = ConfigType::GlobalConfig); - ~QtConfig() override; - - void ReloadAllValues() override; - void SaveAllValues() override; - - void ReadQtControlPlayerValues(std::size_t player_index); - void SaveQtControlPlayerValues(std::size_t player_index); - -protected: - void ReadQtValues(); - void ReadQtPlayerValues(std::size_t player_index); - void ReadQtControlValues(); - void ReadHidbusValues() override; - void ReadDebugControlValues() override; - void ReadPathValues() override; - void ReadShortcutValues() override; - void ReadUIValues() override; - void ReadUIGamelistValues() override; - void ReadUILayoutValues() override; - void ReadMultiplayerValues() override; - - void SaveQtValues(); - void SaveQtPlayerValues(std::size_t player_index); - void SaveQtControlValues(); - void SaveHidbusValues() override; - void SaveDebugControlValues() override; - void SavePathValues() override; - void SaveShortcutValues() override; - void SaveUIValues() override; - void SaveUIGamelistValues() override; - void SaveUILayoutValues() override; - void SaveMultiplayerValues() override; - - std::vector<Settings::BasicSetting*>& FindRelevantList(Settings::Category category) override; - -public: - static const std::array<int, Settings::NativeButton::NumButtons> default_buttons; - 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; -}; diff --git a/src/yuzu/configuration/shared_translation.cpp b/src/yuzu/configuration/shared_translation.cpp deleted file mode 100644 index 0549e8ae4..000000000 --- a/src/yuzu/configuration/shared_translation.cpp +++ /dev/null @@ -1,537 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include "yuzu/configuration/shared_translation.h" - -#include <map> -#include <memory> -#include <tuple> -#include <utility> -#include <QCoreApplication> -#include <QWidget> -#include "common/settings.h" -#include "common/settings_enums.h" -#include "common/settings_setting.h" -#include "common/time_zone.h" -#include "yuzu/uisettings.h" - -namespace ConfigurationShared { - -std::unique_ptr<TranslationMap> InitializeTranslations(QWidget* parent) { - std::unique_ptr<TranslationMap> translations = std::make_unique<TranslationMap>(); - const auto& tr = [parent](const char* text) -> QString { return parent->tr(text); }; - -#define INSERT(SETTINGS, ID, NAME, TOOLTIP) \ - translations->insert(std::pair{SETTINGS::values.ID.Id(), std::pair{(NAME), (TOOLTIP)}}) - - // A setting can be ignored by giving it a blank name - - // Applets - INSERT(Settings, cabinet_applet_mode, tr("Amiibo editor"), QStringLiteral()); - INSERT(Settings, controller_applet_mode, tr("Controller configuration"), QStringLiteral()); - INSERT(Settings, data_erase_applet_mode, tr("Data erase"), QStringLiteral()); - INSERT(Settings, error_applet_mode, tr("Error"), QStringLiteral()); - INSERT(Settings, net_connect_applet_mode, tr("Net connect"), QStringLiteral()); - INSERT(Settings, player_select_applet_mode, tr("Player select"), QStringLiteral()); - INSERT(Settings, swkbd_applet_mode, tr("Software keyboard"), QStringLiteral()); - INSERT(Settings, mii_edit_applet_mode, tr("Mii Edit"), QStringLiteral()); - INSERT(Settings, web_applet_mode, tr("Online web"), QStringLiteral()); - INSERT(Settings, shop_applet_mode, tr("Shop"), QStringLiteral()); - INSERT(Settings, photo_viewer_applet_mode, tr("Photo viewer"), QStringLiteral()); - INSERT(Settings, offline_web_applet_mode, tr("Offline web"), QStringLiteral()); - INSERT(Settings, login_share_applet_mode, tr("Login share"), QStringLiteral()); - INSERT(Settings, wifi_web_auth_applet_mode, tr("Wifi web auth"), QStringLiteral()); - INSERT(Settings, my_page_applet_mode, tr("My page"), QStringLiteral()); - - // Audio - INSERT(Settings, sink_id, tr("Output Engine:"), QStringLiteral()); - INSERT(Settings, audio_output_device_id, tr("Output Device:"), QStringLiteral()); - INSERT(Settings, audio_input_device_id, tr("Input Device:"), QStringLiteral()); - INSERT(Settings, audio_muted, tr("Mute audio"), QStringLiteral()); - INSERT(Settings, volume, tr("Volume:"), QStringLiteral()); - INSERT(Settings, dump_audio_commands, QStringLiteral(), QStringLiteral()); - INSERT(UISettings, mute_when_in_background, tr("Mute audio when in background"), - QStringLiteral()); - - // Core - INSERT( - Settings, use_multi_core, tr("Multicore CPU Emulation"), - tr("This option increases CPU emulation thread use from 1 to the Switch’s maximum of 4.\n" - "This is mainly a debug option and shouldn’t be disabled.")); - INSERT( - Settings, memory_layout_mode, tr("Memory Layout"), - tr("Increases the amount of emulated RAM from the stock 4GB of the retail Switch to the " - "developer kit's 8/6GB.\nIt’s doesn’t improve stability or performance and is intended " - "to let big texture mods fit in emulated RAM.\nEnabling it will increase memory " - "use. It is not recommended to enable unless a specific game with a texture mod needs " - "it.")); - INSERT(Settings, use_speed_limit, QStringLiteral(), QStringLiteral()); - INSERT(Settings, speed_limit, tr("Limit Speed Percent"), - tr("Controls the game's maximum rendering speed, but it’s up to each game if it runs " - "faster or not.\n200% for a 30 FPS game is 60 FPS, and for a " - "60 FPS game it will be 120 FPS.\nDisabling it means unlocking the framerate to the " - "maximum your PC can reach.")); - - // Cpu - INSERT(Settings, cpu_accuracy, tr("Accuracy:"), - tr("This setting controls the accuracy of the emulated CPU.\nDon't change this unless " - "you know what you are doing.")); - INSERT(Settings, cpu_backend, tr("Backend:"), QStringLiteral()); - - // Cpu Debug - - // Cpu Unsafe - INSERT( - Settings, cpuopt_unsafe_unfuse_fma, - tr("Unfuse FMA (improve performance on CPUs without FMA)"), - tr("This option improves speed by reducing accuracy of fused-multiply-add instructions on " - "CPUs without native FMA support.")); - INSERT( - Settings, cpuopt_unsafe_reduce_fp_error, tr("Faster FRSQRTE and FRECPE"), - tr("This option improves the speed of some approximate floating-point functions by using " - "less accurate native approximations.")); - INSERT(Settings, cpuopt_unsafe_ignore_standard_fpcr, - tr("Faster ASIMD instructions (32 bits only)"), - tr("This option improves the speed of 32 bits ASIMD floating-point functions by running " - "with incorrect rounding modes.")); - INSERT(Settings, cpuopt_unsafe_inaccurate_nan, tr("Inaccurate NaN handling"), - tr("This option improves speed by removing NaN checking.\nPlease note this also reduces " - "accuracy of certain floating-point instructions.")); - INSERT(Settings, cpuopt_unsafe_fastmem_check, tr("Disable address space checks"), - tr("This option improves speed by eliminating a safety check before every memory " - "read/write in guest.\nDisabling it may allow a game to read/write the emulator's " - "memory.")); - INSERT( - Settings, cpuopt_unsafe_ignore_global_monitor, tr("Ignore global monitor"), - tr("This option improves speed by relying only on the semantics of cmpxchg to ensure " - "safety of exclusive access instructions.\nPlease note this may result in deadlocks and " - "other race conditions.")); - - // Renderer - INSERT( - Settings, renderer_backend, tr("API:"), - tr("Switches between the available graphics APIs.\nVulkan is recommended in most cases.")); - INSERT(Settings, vulkan_device, tr("Device:"), - tr("This setting selects the GPU to use with the Vulkan backend.")); - INSERT(Settings, shader_backend, tr("Shader Backend:"), - tr("The shader backend to use for the OpenGL renderer.\nGLSL is the fastest in " - "performance and the best in rendering accuracy.\n" - "GLASM is a deprecated NVIDIA-only backend that offers much better shader building " - "performance at the cost of FPS and rendering accuracy.\n" - "SPIR-V compiles the fastest, but yields poor results on most GPU drivers.")); - INSERT(Settings, resolution_setup, tr("Resolution:"), - tr("Forces the game to render at a different resolution.\nHigher resolutions require " - "much more VRAM and bandwidth.\n" - "Options lower than 1X can cause rendering issues.")); - INSERT(Settings, scaling_filter, tr("Window Adapting Filter:"), QStringLiteral()); - INSERT(Settings, fsr_sharpening_slider, tr("FSR Sharpness:"), - tr("Determines how sharpened the image will look while using FSR’s dynamic contrast.")); - INSERT(Settings, anti_aliasing, tr("Anti-Aliasing Method:"), - tr("The anti-aliasing method to use.\nSMAA offers the best quality.\nFXAA has a " - "lower performance impact and can produce a better and more stable picture under " - "very low resolutions.")); - INSERT(Settings, fullscreen_mode, tr("Fullscreen Mode:"), - tr("The method used to render the window in fullscreen.\nBorderless offers the best " - "compatibility with the on-screen keyboard that some games request for " - "input.\nExclusive " - "fullscreen may offer better performance and better Freesync/Gsync support.")); - INSERT(Settings, aspect_ratio, tr("Aspect Ratio:"), - tr("Stretches the game to fit the specified aspect ratio.\nSwitch games only support " - "16:9, so custom game mods are required to get other ratios.\nAlso controls the " - "aspect ratio of captured screenshots.")); - INSERT(Settings, use_disk_shader_cache, tr("Use disk pipeline cache"), - tr("Allows saving shaders to storage for faster loading on following game " - "boots.\nDisabling " - "it is only intended for debugging.")); - INSERT( - Settings, use_asynchronous_gpu_emulation, tr("Use asynchronous GPU emulation"), - tr("Uses an extra CPU thread for rendering.\nThis option should always remain enabled.")); - INSERT(Settings, nvdec_emulation, tr("NVDEC emulation:"), - tr("Specifies how videos should be decoded.\nIt can either use the CPU or the GPU for " - "decoding, or perform no decoding at all (black screen on videos).\n" - "In most cases, GPU decoding provides the best performance.")); - INSERT(Settings, accelerate_astc, tr("ASTC Decoding Method:"), - tr("This option controls how ASTC textures should be decoded.\n" - "CPU: Use the CPU for decoding, slowest but safest method.\n" - "GPU: Use the GPU's compute shaders to decode ASTC textures, recommended for most " - "games and users.\n" - "CPU Asynchronously: Use the CPU to decode ASTC textures as they arrive. Completely " - "eliminates ASTC decoding\nstuttering at the cost of rendering issues while the " - "texture is being decoded.")); - INSERT( - Settings, astc_recompression, tr("ASTC Recompression Method:"), - tr("Almost all desktop and laptop dedicated GPUs lack support for ASTC textures, forcing " - "the emulator to decompress to an intermediate format any card supports, RGBA8.\n" - "This option recompresses RGBA8 to either the BC1 or BC3 format, saving VRAM but " - "negatively affecting image quality.")); - INSERT(Settings, vram_usage_mode, tr("VRAM Usage Mode:"), - tr("Selects whether the emulator should prefer to conserve memory or make maximum usage " - "of available video memory for performance. Has no effect on integrated graphics. " - "Aggressive mode may severely impact the performance of other applications such as " - "recording software.")); - INSERT( - Settings, vsync_mode, tr("VSync Mode:"), - tr("FIFO (VSync) does not drop frames or exhibit tearing but is limited by the screen " - "refresh rate.\nFIFO Relaxed is similar to FIFO but allows tearing as it recovers from " - "a slow down.\nMailbox can have lower latency than FIFO and does not tear but may drop " - "frames.\nImmediate (no synchronization) just presents whatever is available and can " - "exhibit tearing.")); - INSERT(Settings, bg_red, QStringLiteral(), QStringLiteral()); - INSERT(Settings, bg_green, QStringLiteral(), QStringLiteral()); - INSERT(Settings, bg_blue, QStringLiteral(), QStringLiteral()); - - // Renderer (Advanced Graphics) - INSERT(Settings, async_presentation, tr("Enable asynchronous presentation (Vulkan only)"), - tr("Slightly improves performance by moving presentation to a separate CPU thread.")); - INSERT( - Settings, renderer_force_max_clock, tr("Force maximum clocks (Vulkan only)"), - tr("Runs work in the background while waiting for graphics commands to keep the GPU from " - "lowering its clock speed.")); - INSERT(Settings, max_anisotropy, tr("Anisotropic Filtering:"), - tr("Controls the quality of texture rendering at oblique angles.\nIt’s a light setting " - "and safe to set at 16x on most GPUs.")); - INSERT(Settings, gpu_accuracy, tr("Accuracy Level:"), - tr("GPU emulation accuracy.\nMost games render fine with Normal, but High is still " - "required for some.\nParticles tend to only render correctly with High " - "accuracy.\nExtreme should only be used for debugging.\nThis option can " - "be changed while playing.\nSome games may require booting on high to render " - "properly.")); - INSERT(Settings, use_asynchronous_shaders, tr("Use asynchronous shader building (Hack)"), - tr("Enables asynchronous shader compilation, which may reduce shader stutter.\nThis " - "feature " - "is experimental.")); - INSERT(Settings, use_fast_gpu_time, tr("Use Fast GPU Time (Hack)"), - tr("Enables Fast GPU Time. This option will force most games to run at their highest " - "native resolution.")); - INSERT(Settings, use_vulkan_driver_pipeline_cache, tr("Use Vulkan pipeline cache"), - tr("Enables GPU vendor-specific pipeline cache.\nThis option can improve shader loading " - "time significantly in cases where the Vulkan driver does not store pipeline cache " - "files internally.")); - INSERT( - Settings, enable_compute_pipelines, tr("Enable Compute Pipelines (Intel Vulkan Only)"), - tr("Enable compute pipelines, required by some games.\nThis setting only exists for Intel " - "proprietary drivers, and may crash if enabled.\nCompute pipelines are always enabled " - "on all other drivers.")); - INSERT( - Settings, use_reactive_flushing, tr("Enable Reactive Flushing"), - tr("Uses reactive flushing instead of predictive flushing, allowing more accurate memory " - "syncing.")); - INSERT(Settings, use_video_framerate, tr("Sync to framerate of video playback"), - tr("Run the game at normal speed during video playback, even when the framerate is " - "unlocked.")); - INSERT(Settings, barrier_feedback_loops, tr("Barrier feedback loops"), - tr("Improves rendering of transparency effects in specific games.")); - - // Renderer (Debug) - - // System - INSERT(Settings, rng_seed, tr("RNG Seed"), - tr("Controls the seed of the random number generator.\nMainly used for speedrunning " - "purposes.")); - INSERT(Settings, rng_seed_enabled, QStringLiteral(), QStringLiteral()); - INSERT(Settings, device_name, tr("Device Name"), tr("The name of the emulated Switch.")); - INSERT(Settings, custom_rtc, tr("Custom RTC Date:"), - tr("This option allows to change the emulated clock of the Switch.\n" - "Can be used to manipulate time in games.")); - INSERT(Settings, custom_rtc_enabled, QStringLiteral(), QStringLiteral()); - INSERT(Settings, custom_rtc_offset, QStringLiteral(" "), - QStringLiteral("The number of seconds from the current unix time")); - INSERT(Settings, language_index, tr("Language:"), - tr("Note: this can be overridden when region setting is auto-select")); - INSERT(Settings, region_index, tr("Region:"), tr("The region of the emulated Switch.")); - INSERT(Settings, time_zone_index, tr("Time Zone:"), - tr("The time zone of the emulated Switch.")); - INSERT(Settings, sound_index, tr("Sound Output Mode:"), QStringLiteral()); - INSERT(Settings, use_docked_mode, tr("Console Mode:"), - tr("Selects if the console is emulated in Docked or Handheld mode.\nGames will change " - "their resolution, details and supported controllers and depending on this setting.\n" - "Setting to Handheld can help improve performance for low end systems.")); - INSERT(Settings, current_user, QStringLiteral(), QStringLiteral()); - - // Controls - - // Data Storage - - // Debugging - - // Debugging Graphics - - // Network - - // Web Service - - // Ui - - // Ui General - INSERT(UISettings, select_user_on_boot, tr("Prompt for user on game boot"), - tr("Ask to select a user profile on each boot, useful if multiple people use yuzu on " - "the same PC.")); - INSERT(UISettings, pause_when_in_background, tr("Pause emulation when in background"), - tr("This setting pauses yuzu when focusing other windows.")); - INSERT(UISettings, confirm_before_stopping, tr("Confirm before stopping emulation"), - tr("This setting overrides game prompts asking to confirm stopping the game.\nEnabling " - "it bypasses such prompts and directly exits the emulation.")); - INSERT(UISettings, hide_mouse, tr("Hide mouse on inactivity"), - tr("This setting hides the mouse after 2.5s of inactivity.")); - INSERT(UISettings, controller_applet_disabled, tr("Disable controller applet"), - tr("Forcibly disables the use of the controller applet by guests.\nWhen a guest " - "attempts to open the controller applet, it is immediately closed.")); - - // Linux - INSERT(Settings, enable_gamemode, tr("Enable Gamemode"), QStringLiteral()); - - // Ui Debugging - - // Ui Multiplayer - - // Ui Games list - -#undef INSERT - - return translations; -} - -std::unique_ptr<ComboboxTranslationMap> ComboboxEnumeration(QWidget* parent) { - std::unique_ptr<ComboboxTranslationMap> translations = - std::make_unique<ComboboxTranslationMap>(); - const auto& tr = [&](const char* text, const char* context = "") { - return parent->tr(text, context); - }; - -#define PAIR(ENUM, VALUE, TRANSLATION) {static_cast<u32>(Settings::ENUM::VALUE), (TRANSLATION)} - - // Intentionally skipping VSyncMode to let the UI fill that one out - translations->insert({Settings::EnumMetadata<Settings::AppletMode>::Index(), - { - PAIR(AppletMode, HLE, tr("Custom frontend")), - PAIR(AppletMode, LLE, tr("Real applet")), - }}); - - translations->insert({Settings::EnumMetadata<Settings::AstcDecodeMode>::Index(), - { - PAIR(AstcDecodeMode, Cpu, tr("CPU")), - PAIR(AstcDecodeMode, Gpu, tr("GPU")), - PAIR(AstcDecodeMode, CpuAsynchronous, tr("CPU Asynchronous")), - }}); - translations->insert( - {Settings::EnumMetadata<Settings::AstcRecompression>::Index(), - { - PAIR(AstcRecompression, Uncompressed, tr("Uncompressed (Best quality)")), - PAIR(AstcRecompression, Bc1, tr("BC1 (Low quality)")), - PAIR(AstcRecompression, Bc3, tr("BC3 (Medium quality)")), - }}); - translations->insert({Settings::EnumMetadata<Settings::VramUsageMode>::Index(), - { - PAIR(VramUsageMode, Conservative, tr("Conservative")), - PAIR(VramUsageMode, Aggressive, tr("Aggressive")), - }}); - translations->insert({Settings::EnumMetadata<Settings::RendererBackend>::Index(), - { -#ifdef HAS_OPENGL - PAIR(RendererBackend, OpenGL, tr("OpenGL")), -#endif - PAIR(RendererBackend, Vulkan, tr("Vulkan")), - PAIR(RendererBackend, Null, tr("Null")), - }}); - translations->insert( - {Settings::EnumMetadata<Settings::ShaderBackend>::Index(), - { - PAIR(ShaderBackend, Glsl, tr("GLSL")), - PAIR(ShaderBackend, Glasm, tr("GLASM (Assembly Shaders, NVIDIA Only)")), - PAIR(ShaderBackend, SpirV, tr("SPIR-V (Experimental, AMD/Mesa Only)")), - }}); - translations->insert({Settings::EnumMetadata<Settings::GpuAccuracy>::Index(), - { - PAIR(GpuAccuracy, Normal, tr("Normal")), - PAIR(GpuAccuracy, High, tr("High")), - PAIR(GpuAccuracy, Extreme, tr("Extreme")), - }}); - translations->insert( - {Settings::EnumMetadata<Settings::CpuAccuracy>::Index(), - { - PAIR(CpuAccuracy, Auto, tr("Auto")), - PAIR(CpuAccuracy, Accurate, tr("Accurate")), - PAIR(CpuAccuracy, Unsafe, tr("Unsafe")), - PAIR(CpuAccuracy, Paranoid, tr("Paranoid (disables most optimizations)")), - }}); - translations->insert({Settings::EnumMetadata<Settings::CpuBackend>::Index(), - { - PAIR(CpuBackend, Dynarmic, tr("Dynarmic")), - PAIR(CpuBackend, Nce, tr("NCE")), - }}); - translations->insert({Settings::EnumMetadata<Settings::FullscreenMode>::Index(), - { - PAIR(FullscreenMode, Borderless, tr("Borderless Windowed")), - PAIR(FullscreenMode, Exclusive, tr("Exclusive Fullscreen")), - }}); - translations->insert({Settings::EnumMetadata<Settings::NvdecEmulation>::Index(), - { - PAIR(NvdecEmulation, Off, tr("No Video Output")), - PAIR(NvdecEmulation, Cpu, tr("CPU Video Decoding")), - PAIR(NvdecEmulation, Gpu, tr("GPU Video Decoding (Default)")), - }}); - translations->insert( - {Settings::EnumMetadata<Settings::ResolutionSetup>::Index(), - { - PAIR(ResolutionSetup, Res1_2X, tr("0.5X (360p/540p) [EXPERIMENTAL]")), - PAIR(ResolutionSetup, Res3_4X, tr("0.75X (540p/810p) [EXPERIMENTAL]")), - PAIR(ResolutionSetup, Res1X, tr("1X (720p/1080p)")), - PAIR(ResolutionSetup, Res3_2X, tr("1.5X (1080p/1620p) [EXPERIMENTAL]")), - PAIR(ResolutionSetup, Res2X, tr("2X (1440p/2160p)")), - PAIR(ResolutionSetup, Res3X, tr("3X (2160p/3240p)")), - PAIR(ResolutionSetup, Res4X, tr("4X (2880p/4320p)")), - PAIR(ResolutionSetup, Res5X, tr("5X (3600p/5400p)")), - PAIR(ResolutionSetup, Res6X, tr("6X (4320p/6480p)")), - PAIR(ResolutionSetup, Res7X, tr("7X (5040p/7560p)")), - PAIR(ResolutionSetup, Res8X, tr("8X (5760p/8640p)")), - }}); - translations->insert({Settings::EnumMetadata<Settings::ScalingFilter>::Index(), - { - PAIR(ScalingFilter, NearestNeighbor, tr("Nearest Neighbor")), - PAIR(ScalingFilter, Bilinear, tr("Bilinear")), - PAIR(ScalingFilter, Bicubic, tr("Bicubic")), - PAIR(ScalingFilter, Gaussian, tr("Gaussian")), - PAIR(ScalingFilter, ScaleForce, tr("ScaleForce")), - PAIR(ScalingFilter, Fsr, tr("AMD FidelityFX™️ Super Resolution")), - }}); - translations->insert({Settings::EnumMetadata<Settings::AntiAliasing>::Index(), - { - PAIR(AntiAliasing, None, tr("None")), - PAIR(AntiAliasing, Fxaa, tr("FXAA")), - PAIR(AntiAliasing, Smaa, tr("SMAA")), - }}); - translations->insert({Settings::EnumMetadata<Settings::AspectRatio>::Index(), - { - PAIR(AspectRatio, R16_9, tr("Default (16:9)")), - PAIR(AspectRatio, R4_3, tr("Force 4:3")), - PAIR(AspectRatio, R21_9, tr("Force 21:9")), - PAIR(AspectRatio, R16_10, tr("Force 16:10")), - PAIR(AspectRatio, Stretch, tr("Stretch to Window")), - }}); - translations->insert({Settings::EnumMetadata<Settings::AnisotropyMode>::Index(), - { - PAIR(AnisotropyMode, Automatic, tr("Automatic")), - PAIR(AnisotropyMode, Default, tr("Default")), - PAIR(AnisotropyMode, X2, tr("2x")), - PAIR(AnisotropyMode, X4, tr("4x")), - PAIR(AnisotropyMode, X8, tr("8x")), - PAIR(AnisotropyMode, X16, tr("16x")), - }}); - translations->insert( - {Settings::EnumMetadata<Settings::Language>::Index(), - { - PAIR(Language, Japanese, tr("Japanese (日本語)")), - PAIR(Language, EnglishAmerican, tr("American English")), - PAIR(Language, French, tr("French (français)")), - PAIR(Language, German, tr("German (Deutsch)")), - PAIR(Language, Italian, tr("Italian (italiano)")), - PAIR(Language, Spanish, tr("Spanish (español)")), - PAIR(Language, Chinese, tr("Chinese")), - PAIR(Language, Korean, tr("Korean (한국어)")), - PAIR(Language, Dutch, tr("Dutch (Nederlands)")), - PAIR(Language, Portuguese, tr("Portuguese (português)")), - PAIR(Language, Russian, tr("Russian (Русский)")), - PAIR(Language, Taiwanese, tr("Taiwanese")), - PAIR(Language, EnglishBritish, tr("British English")), - PAIR(Language, FrenchCanadian, tr("Canadian French")), - PAIR(Language, SpanishLatin, tr("Latin American Spanish")), - PAIR(Language, ChineseSimplified, tr("Simplified Chinese")), - PAIR(Language, ChineseTraditional, tr("Traditional Chinese (正體中文)")), - PAIR(Language, PortugueseBrazilian, tr("Brazilian Portuguese (português do Brasil)")), - }}); - translations->insert({Settings::EnumMetadata<Settings::Region>::Index(), - { - PAIR(Region, Japan, tr("Japan")), - PAIR(Region, Usa, tr("USA")), - PAIR(Region, Europe, tr("Europe")), - PAIR(Region, Australia, tr("Australia")), - PAIR(Region, China, tr("China")), - PAIR(Region, Korea, tr("Korea")), - PAIR(Region, Taiwan, tr("Taiwan")), - }}); - translations->insert( - {Settings::EnumMetadata<Settings::TimeZone>::Index(), - { - {static_cast<u32>(Settings::TimeZone::Auto), - tr("Auto (%1)", "Auto select time zone") - .arg(QString::fromStdString( - Settings::GetTimeZoneString(Settings::TimeZone::Auto)))}, - {static_cast<u32>(Settings::TimeZone::Default), - tr("Default (%1)", "Default time zone") - .arg(QString::fromStdString(Common::TimeZone::GetDefaultTimeZone()))}, - PAIR(TimeZone, Cet, tr("CET")), - PAIR(TimeZone, Cst6Cdt, tr("CST6CDT")), - PAIR(TimeZone, Cuba, tr("Cuba")), - PAIR(TimeZone, Eet, tr("EET")), - PAIR(TimeZone, Egypt, tr("Egypt")), - PAIR(TimeZone, Eire, tr("Eire")), - PAIR(TimeZone, Est, tr("EST")), - PAIR(TimeZone, Est5Edt, tr("EST5EDT")), - PAIR(TimeZone, Gb, tr("GB")), - PAIR(TimeZone, GbEire, tr("GB-Eire")), - PAIR(TimeZone, Gmt, tr("GMT")), - PAIR(TimeZone, GmtPlusZero, tr("GMT+0")), - PAIR(TimeZone, GmtMinusZero, tr("GMT-0")), - PAIR(TimeZone, GmtZero, tr("GMT0")), - PAIR(TimeZone, Greenwich, tr("Greenwich")), - PAIR(TimeZone, Hongkong, tr("Hongkong")), - PAIR(TimeZone, Hst, tr("HST")), - PAIR(TimeZone, Iceland, tr("Iceland")), - PAIR(TimeZone, Iran, tr("Iran")), - PAIR(TimeZone, Israel, tr("Israel")), - PAIR(TimeZone, Jamaica, tr("Jamaica")), - PAIR(TimeZone, Japan, tr("Japan")), - PAIR(TimeZone, Kwajalein, tr("Kwajalein")), - PAIR(TimeZone, Libya, tr("Libya")), - PAIR(TimeZone, Met, tr("MET")), - PAIR(TimeZone, Mst, tr("MST")), - PAIR(TimeZone, Mst7Mdt, tr("MST7MDT")), - PAIR(TimeZone, Navajo, tr("Navajo")), - PAIR(TimeZone, Nz, tr("NZ")), - PAIR(TimeZone, NzChat, tr("NZ-CHAT")), - PAIR(TimeZone, Poland, tr("Poland")), - PAIR(TimeZone, Portugal, tr("Portugal")), - PAIR(TimeZone, Prc, tr("PRC")), - PAIR(TimeZone, Pst8Pdt, tr("PST8PDT")), - PAIR(TimeZone, Roc, tr("ROC")), - PAIR(TimeZone, Rok, tr("ROK")), - PAIR(TimeZone, Singapore, tr("Singapore")), - PAIR(TimeZone, Turkey, tr("Turkey")), - PAIR(TimeZone, Uct, tr("UCT")), - PAIR(TimeZone, Universal, tr("Universal")), - PAIR(TimeZone, Utc, tr("UTC")), - PAIR(TimeZone, WSu, tr("W-SU")), - PAIR(TimeZone, Wet, tr("WET")), - PAIR(TimeZone, Zulu, tr("Zulu")), - }}); - translations->insert({Settings::EnumMetadata<Settings::AudioMode>::Index(), - { - PAIR(AudioMode, Mono, tr("Mono")), - PAIR(AudioMode, Stereo, tr("Stereo")), - PAIR(AudioMode, Surround, tr("Surround")), - }}); - translations->insert({Settings::EnumMetadata<Settings::MemoryLayout>::Index(), - { - PAIR(MemoryLayout, Memory_4Gb, tr("4GB DRAM (Default)")), - PAIR(MemoryLayout, Memory_6Gb, tr("6GB DRAM (Unsafe)")), - PAIR(MemoryLayout, Memory_8Gb, tr("8GB DRAM (Unsafe)")), - }}); - translations->insert({Settings::EnumMetadata<Settings::ConsoleMode>::Index(), - { - PAIR(ConsoleMode, Docked, tr("Docked")), - PAIR(ConsoleMode, Handheld, tr("Handheld")), - }}); - translations->insert( - {Settings::EnumMetadata<Settings::ConfirmStop>::Index(), - { - PAIR(ConfirmStop, Ask_Always, tr("Always ask (Default)")), - PAIR(ConfirmStop, Ask_Based_On_Game, tr("Only if game specifies not to stop")), - PAIR(ConfirmStop, Ask_Never, tr("Never ask")), - }}); - -#undef PAIR -#undef CTX_PAIR - - return translations; -} -} // namespace ConfigurationShared diff --git a/src/yuzu/configuration/shared_translation.h b/src/yuzu/configuration/shared_translation.h deleted file mode 100644 index d5fc3b8de..000000000 --- a/src/yuzu/configuration/shared_translation.h +++ /dev/null @@ -1,68 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include <map> -#include <memory> -#include <typeindex> -#include <utility> -#include <vector> -#include <QString> -#include "common/common_types.h" -#include "common/settings.h" - -class QWidget; - -namespace ConfigurationShared { -using TranslationMap = std::map<u32, std::pair<QString, QString>>; -using ComboboxTranslations = std::vector<std::pair<u32, QString>>; -using ComboboxTranslationMap = std::map<u32, ComboboxTranslations>; - -std::unique_ptr<TranslationMap> InitializeTranslations(QWidget* parent); - -std::unique_ptr<ComboboxTranslationMap> ComboboxEnumeration(QWidget* parent); - -static const std::map<Settings::AntiAliasing, QString> anti_aliasing_texts_map = { - {Settings::AntiAliasing::None, QStringLiteral(QT_TRANSLATE_NOOP("GMainWindow", "None"))}, - {Settings::AntiAliasing::Fxaa, QStringLiteral(QT_TRANSLATE_NOOP("GMainWindow", "FXAA"))}, - {Settings::AntiAliasing::Smaa, QStringLiteral(QT_TRANSLATE_NOOP("GMainWindow", "SMAA"))}, -}; - -static const std::map<Settings::ScalingFilter, QString> scaling_filter_texts_map = { - {Settings::ScalingFilter::NearestNeighbor, - QStringLiteral(QT_TRANSLATE_NOOP("GMainWindow", "Nearest"))}, - {Settings::ScalingFilter::Bilinear, - QStringLiteral(QT_TRANSLATE_NOOP("GMainWindow", "Bilinear"))}, - {Settings::ScalingFilter::Bicubic, QStringLiteral(QT_TRANSLATE_NOOP("GMainWindow", "Bicubic"))}, - {Settings::ScalingFilter::Gaussian, - QStringLiteral(QT_TRANSLATE_NOOP("GMainWindow", "Gaussian"))}, - {Settings::ScalingFilter::ScaleForce, - QStringLiteral(QT_TRANSLATE_NOOP("GMainWindow", "ScaleForce"))}, - {Settings::ScalingFilter::Fsr, QStringLiteral(QT_TRANSLATE_NOOP("GMainWindow", "FSR"))}, -}; - -static const std::map<Settings::ConsoleMode, QString> use_docked_mode_texts_map = { - {Settings::ConsoleMode::Docked, QStringLiteral(QT_TRANSLATE_NOOP("GMainWindow", "Docked"))}, - {Settings::ConsoleMode::Handheld, QStringLiteral(QT_TRANSLATE_NOOP("GMainWindow", "Handheld"))}, -}; - -static const std::map<Settings::GpuAccuracy, QString> gpu_accuracy_texts_map = { - {Settings::GpuAccuracy::Normal, QStringLiteral(QT_TRANSLATE_NOOP("GMainWindow", "Normal"))}, - {Settings::GpuAccuracy::High, QStringLiteral(QT_TRANSLATE_NOOP("GMainWindow", "High"))}, - {Settings::GpuAccuracy::Extreme, QStringLiteral(QT_TRANSLATE_NOOP("GMainWindow", "Extreme"))}, -}; - -static const std::map<Settings::RendererBackend, QString> renderer_backend_texts_map = { - {Settings::RendererBackend::Vulkan, QStringLiteral(QT_TRANSLATE_NOOP("GMainWindow", "Vulkan"))}, - {Settings::RendererBackend::OpenGL, QStringLiteral(QT_TRANSLATE_NOOP("GMainWindow", "OpenGL"))}, - {Settings::RendererBackend::Null, QStringLiteral(QT_TRANSLATE_NOOP("GMainWindow", "Null"))}, -}; - -static const std::map<Settings::ShaderBackend, QString> shader_backend_texts_map = { - {Settings::ShaderBackend::Glsl, QStringLiteral(QT_TRANSLATE_NOOP("GMainWindow", "GLSL"))}, - {Settings::ShaderBackend::Glasm, QStringLiteral(QT_TRANSLATE_NOOP("GMainWindow", "GLASM"))}, - {Settings::ShaderBackend::SpirV, QStringLiteral(QT_TRANSLATE_NOOP("GMainWindow", "SPIRV"))}, -}; - -} // namespace ConfigurationShared diff --git a/src/yuzu/configuration/shared_widget.cpp b/src/yuzu/configuration/shared_widget.cpp deleted file mode 100644 index 85f4f7655..000000000 --- a/src/yuzu/configuration/shared_widget.cpp +++ /dev/null @@ -1,802 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include "yuzu/configuration/shared_widget.h" - -#include <functional> -#include <limits> -#include <typeindex> -#include <typeinfo> -#include <utility> -#include <vector> - -#include <QAbstractButton> -#include <QAbstractSlider> -#include <QBoxLayout> -#include <QCheckBox> -#include <QComboBox> -#include <QDateTime> -#include <QDateTimeEdit> -#include <QIcon> -#include <QLabel> -#include <QLayout> -#include <QLineEdit> -#include <QObject> -#include <QPushButton> -#include <QRadioButton> -#include <QRegularExpression> -#include <QSizePolicy> -#include <QSlider> -#include <QSpinBox> -#include <QStyle> -#include <QValidator> -#include <QVariant> -#include <QtCore/qglobal.h> -#include <QtCore/qobjectdefs.h> -#include <fmt/core.h> -#include <qglobal.h> -#include <qnamespace.h> - -#include "common/assert.h" -#include "common/common_types.h" -#include "common/logging/log.h" -#include "common/settings.h" -#include "common/settings_common.h" -#include "yuzu/configuration/shared_translation.h" - -namespace ConfigurationShared { - -static int restore_button_count = 0; - -static std::string RelevantDefault(const Settings::BasicSetting& setting) { - return Settings::IsConfiguringGlobal() ? setting.DefaultToString() : setting.ToStringGlobal(); -} - -static QString DefaultSuffix(QWidget* parent, Settings::BasicSetting& setting) { - const auto tr = [parent](const char* text, const char* context) { - return parent->tr(text, context); - }; - - if ((setting.Specialization() & Settings::SpecializationAttributeMask) == - Settings::Specialization::Percentage) { - std::string context{fmt::format("{} percentage (e.g. 50%)", setting.GetLabel())}; - return tr("%", context.c_str()); - } - - return default_suffix; -} - -QPushButton* Widget::CreateRestoreGlobalButton(bool using_global, QWidget* parent) { - restore_button_count++; - - QStyle* style = parent->style(); - QIcon* icon = new QIcon(style->standardIcon(QStyle::SP_LineEditClearButton)); - QPushButton* restore_button = new QPushButton(*icon, QStringLiteral(), parent); - restore_button->setObjectName(QStringLiteral("RestoreButton%1").arg(restore_button_count)); - restore_button->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); - - // Workaround for dark theme causing min-width to be much larger than 0 - restore_button->setStyleSheet( - QStringLiteral("QAbstractButton#%1 { min-width: 0px }").arg(restore_button->objectName())); - - QSizePolicy sp_retain = restore_button->sizePolicy(); - sp_retain.setRetainSizeWhenHidden(true); - restore_button->setSizePolicy(sp_retain); - - restore_button->setEnabled(!using_global); - restore_button->setVisible(!using_global); - - return restore_button; -} - -QLabel* Widget::CreateLabel(const QString& text) { - QLabel* qt_label = new QLabel(text, this->parent); - qt_label->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); - return qt_label; -} - -QWidget* Widget::CreateCheckBox(Settings::BasicSetting* bool_setting, const QString& label, - std::function<std::string()>& serializer, - std::function<void()>& restore_func, - const std::function<void()>& touch) { - checkbox = new QCheckBox(label, this); - checkbox->setCheckState(bool_setting->ToString() == "true" ? Qt::CheckState::Checked - : Qt::CheckState::Unchecked); - checkbox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); - - if (!bool_setting->Save() && !Settings::IsConfiguringGlobal() && runtime_lock) { - checkbox->setEnabled(false); - } - - serializer = [this]() { - return checkbox->checkState() == Qt::CheckState::Checked ? "true" : "false"; - }; - - restore_func = [this, bool_setting]() { - checkbox->setCheckState(RelevantDefault(*bool_setting) == "true" ? Qt::Checked - : Qt::Unchecked); - }; - - if (!Settings::IsConfiguringGlobal()) { - QObject::connect(checkbox, &QCheckBox::clicked, [touch]() { touch(); }); - } - - return checkbox; -} - -QWidget* Widget::CreateCombobox(std::function<std::string()>& serializer, - std::function<void()>& restore_func, - const std::function<void()>& touch) { - const auto type = setting.EnumIndex(); - - combobox = new QComboBox(this); - combobox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); - - const ComboboxTranslations* enumeration{nullptr}; - if (combobox_enumerations.contains(type)) { - enumeration = &combobox_enumerations.at(type); - for (const auto& [id, name] : *enumeration) { - combobox->addItem(name); - } - } else { - return combobox; - } - - const auto find_index = [=](u32 value) -> int { - for (u32 i = 0; i < enumeration->size(); i++) { - if (enumeration->at(i).first == value) { - return i; - } - } - return -1; - }; - - const u32 setting_value = std::strtoul(setting.ToString().c_str(), nullptr, 0); - combobox->setCurrentIndex(find_index(setting_value)); - - serializer = [this, enumeration]() { - int current = combobox->currentIndex(); - return std::to_string(enumeration->at(current).first); - }; - - restore_func = [this, find_index]() { - const u32 global_value = std::strtoul(RelevantDefault(setting).c_str(), nullptr, 0); - combobox->setCurrentIndex(find_index(global_value)); - }; - - if (!Settings::IsConfiguringGlobal()) { - QObject::connect(combobox, QOverload<int>::of(&QComboBox::activated), - [touch]() { touch(); }); - } - - return combobox; -} - -QWidget* Widget::CreateRadioGroup(std::function<std::string()>& serializer, - std::function<void()>& restore_func, - const std::function<void()>& touch) { - const auto type = setting.EnumIndex(); - - QWidget* group = new QWidget(this); - QHBoxLayout* layout = new QHBoxLayout(group); - layout->setContentsMargins(0, 0, 0, 0); - group->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); - - const ComboboxTranslations* enumeration{nullptr}; - if (combobox_enumerations.contains(type)) { - enumeration = &combobox_enumerations.at(type); - for (const auto& [id, name] : *enumeration) { - QRadioButton* radio_button = new QRadioButton(name, group); - layout->addWidget(radio_button); - radio_buttons.push_back({id, radio_button}); - } - } else { - return group; - } - - const auto get_selected = [this]() -> int { - for (const auto& [id, button] : radio_buttons) { - if (button->isChecked()) { - return id; - } - } - return -1; - }; - - const auto set_index = [this](u32 value) { - for (const auto& [id, button] : radio_buttons) { - button->setChecked(id == value); - } - }; - - const u32 setting_value = std::strtoul(setting.ToString().c_str(), nullptr, 0); - set_index(setting_value); - - serializer = [get_selected]() { - int current = get_selected(); - return std::to_string(current); - }; - - restore_func = [this, set_index]() { - const u32 global_value = std::strtoul(RelevantDefault(setting).c_str(), nullptr, 0); - set_index(global_value); - }; - - if (!Settings::IsConfiguringGlobal()) { - for (const auto& [id, button] : radio_buttons) { - QObject::connect(button, &QAbstractButton::clicked, [touch]() { touch(); }); - } - } - - return group; -} - -QWidget* Widget::CreateLineEdit(std::function<std::string()>& serializer, - std::function<void()>& restore_func, - const std::function<void()>& touch, bool managed) { - const QString text = QString::fromStdString(setting.ToString()); - line_edit = new QLineEdit(this); - line_edit->setText(text); - - serializer = [this]() { return line_edit->text().toStdString(); }; - - if (!managed) { - return line_edit; - } - - restore_func = [this]() { - line_edit->setText(QString::fromStdString(RelevantDefault(setting))); - }; - - if (!Settings::IsConfiguringGlobal()) { - QObject::connect(line_edit, &QLineEdit::textChanged, [touch]() { touch(); }); - } - - return line_edit; -} - -static void CreateIntSlider(Settings::BasicSetting& setting, bool reversed, float multiplier, - QLabel* feedback, const QString& use_format, QSlider* slider, - std::function<std::string()>& serializer, - std::function<void()>& restore_func) { - const int max_val = std::strtol(setting.MaxVal().c_str(), nullptr, 0); - - const auto update_feedback = [=](int value) { - int present = (reversed ? max_val - value : value) * multiplier + 0.5f; - feedback->setText(use_format.arg(QVariant::fromValue(present).value<QString>())); - }; - - QObject::connect(slider, &QAbstractSlider::valueChanged, update_feedback); - update_feedback(std::strtol(setting.ToString().c_str(), nullptr, 0)); - - slider->setMinimum(std::strtol(setting.MinVal().c_str(), nullptr, 0)); - slider->setMaximum(max_val); - slider->setValue(std::strtol(setting.ToString().c_str(), nullptr, 0)); - - serializer = [slider]() { return std::to_string(slider->value()); }; - restore_func = [slider, &setting]() { - slider->setValue(std::strtol(RelevantDefault(setting).c_str(), nullptr, 0)); - }; -} - -static void CreateFloatSlider(Settings::BasicSetting& setting, bool reversed, float multiplier, - QLabel* feedback, const QString& use_format, QSlider* slider, - std::function<std::string()>& serializer, - std::function<void()>& restore_func) { - const float max_val = std::strtof(setting.MaxVal().c_str(), nullptr); - const float min_val = std::strtof(setting.MinVal().c_str(), nullptr); - const float use_multiplier = - multiplier == default_multiplier ? default_float_multiplier : multiplier; - - const auto update_feedback = [=](float value) { - int present = (reversed ? max_val - value : value) + 0.5f; - feedback->setText(use_format.arg(QVariant::fromValue(present).value<QString>())); - }; - - QObject::connect(slider, &QAbstractSlider::valueChanged, update_feedback); - update_feedback(std::strtof(setting.ToString().c_str(), nullptr)); - - slider->setMinimum(min_val * use_multiplier); - slider->setMaximum(max_val * use_multiplier); - slider->setValue(std::strtof(setting.ToString().c_str(), nullptr) * use_multiplier); - - serializer = [slider, use_multiplier]() { - return std::to_string(slider->value() / use_multiplier); - }; - restore_func = [slider, &setting, use_multiplier]() { - slider->setValue(std::strtof(RelevantDefault(setting).c_str(), nullptr) * use_multiplier); - }; -} - -QWidget* Widget::CreateSlider(bool reversed, float multiplier, const QString& given_suffix, - std::function<std::string()>& serializer, - std::function<void()>& restore_func, - const std::function<void()>& touch) { - if (!setting.Ranged()) { - LOG_ERROR(Frontend, "\"{}\" is not a ranged setting, but a slider was requested.", - setting.GetLabel()); - return nullptr; - } - - QWidget* container = new QWidget(this); - QHBoxLayout* layout = new QHBoxLayout(container); - - slider = new QSlider(Qt::Horizontal, this); - QLabel* feedback = new QLabel(this); - - layout->addWidget(slider); - layout->addWidget(feedback); - - container->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); - - layout->setContentsMargins(0, 0, 0, 0); - - QString suffix = given_suffix == default_suffix ? DefaultSuffix(this, setting) : given_suffix; - - const QString use_format = QStringLiteral("%1").append(suffix); - - if (setting.IsIntegral()) { - CreateIntSlider(setting, reversed, multiplier, feedback, use_format, slider, serializer, - restore_func); - } else { - CreateFloatSlider(setting, reversed, multiplier, feedback, use_format, slider, serializer, - restore_func); - } - - slider->setInvertedAppearance(reversed); - - if (!Settings::IsConfiguringGlobal()) { - QObject::connect(slider, &QAbstractSlider::actionTriggered, [touch]() { touch(); }); - } - - return container; -} - -QWidget* Widget::CreateSpinBox(const QString& given_suffix, - std::function<std::string()>& serializer, - std::function<void()>& restore_func, - const std::function<void()>& touch) { - const auto min_val = std::strtol(setting.MinVal().c_str(), nullptr, 0); - const auto max_val = std::strtol(setting.MaxVal().c_str(), nullptr, 0); - const auto default_val = std::strtol(setting.ToString().c_str(), nullptr, 0); - - QString suffix = given_suffix == default_suffix ? DefaultSuffix(this, setting) : given_suffix; - - spinbox = new QSpinBox(this); - spinbox->setRange(min_val, max_val); - spinbox->setValue(default_val); - spinbox->setSuffix(suffix); - spinbox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); - - serializer = [this]() { return std::to_string(spinbox->value()); }; - - restore_func = [this]() { - auto value{std::strtol(RelevantDefault(setting).c_str(), nullptr, 0)}; - spinbox->setValue(value); - }; - - if (!Settings::IsConfiguringGlobal()) { - QObject::connect(spinbox, QOverload<int>::of(&QSpinBox::valueChanged), [this, touch]() { - if (spinbox->value() != std::strtol(setting.ToStringGlobal().c_str(), nullptr, 0)) { - touch(); - } - }); - } - - return spinbox; -} - -QWidget* Widget::CreateDoubleSpinBox(const QString& given_suffix, - std::function<std::string()>& serializer, - std::function<void()>& restore_func, - const std::function<void()>& touch) { - const auto min_val = std::strtod(setting.MinVal().c_str(), nullptr); - const auto max_val = std::strtod(setting.MaxVal().c_str(), nullptr); - const auto default_val = std::strtod(setting.ToString().c_str(), nullptr); - - QString suffix = given_suffix == default_suffix ? DefaultSuffix(this, setting) : given_suffix; - - double_spinbox = new QDoubleSpinBox(this); - double_spinbox->setRange(min_val, max_val); - double_spinbox->setValue(default_val); - double_spinbox->setSuffix(suffix); - double_spinbox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); - - serializer = [this]() { return fmt::format("{:f}", double_spinbox->value()); }; - - restore_func = [this]() { - auto value{std::strtod(RelevantDefault(setting).c_str(), nullptr)}; - double_spinbox->setValue(value); - }; - - if (!Settings::IsConfiguringGlobal()) { - QObject::connect(double_spinbox, QOverload<double>::of(&QDoubleSpinBox::valueChanged), - [this, touch]() { - if (double_spinbox->value() != - std::strtod(setting.ToStringGlobal().c_str(), nullptr)) { - touch(); - } - }); - } - - return double_spinbox; -} - -QWidget* Widget::CreateHexEdit(std::function<std::string()>& serializer, - std::function<void()>& restore_func, - const std::function<void()>& touch) { - auto* data_component = CreateLineEdit(serializer, restore_func, touch, false); - if (data_component == nullptr) { - return nullptr; - } - - auto to_hex = [=](const std::string& input) { - return QString::fromStdString( - fmt::format("{:08x}", std::strtoul(input.c_str(), nullptr, 0))); - }; - - QRegularExpressionValidator* regex = new QRegularExpressionValidator( - QRegularExpression{QStringLiteral("^[0-9a-fA-F]{0,8}$")}, line_edit); - - const QString default_val = to_hex(setting.ToString()); - - line_edit->setText(default_val); - line_edit->setMaxLength(8); - line_edit->setValidator(regex); - - auto hex_to_dec = [this]() -> std::string { - return std::to_string(std::strtoul(line_edit->text().toStdString().c_str(), nullptr, 16)); - }; - - serializer = [hex_to_dec]() { return hex_to_dec(); }; - - restore_func = [this, to_hex]() { line_edit->setText(to_hex(RelevantDefault(setting))); }; - - if (!Settings::IsConfiguringGlobal()) { - - QObject::connect(line_edit, &QLineEdit::textChanged, [touch]() { touch(); }); - } - - return line_edit; -} - -QWidget* Widget::CreateDateTimeEdit(bool disabled, bool restrict, - std::function<std::string()>& serializer, - std::function<void()>& restore_func, - const std::function<void()>& touch) { - const long long current_time = QDateTime::currentSecsSinceEpoch(); - const s64 the_time = - disabled ? current_time : std::strtoll(setting.ToString().c_str(), nullptr, 0); - const auto default_val = QDateTime::fromSecsSinceEpoch(the_time); - - date_time_edit = new QDateTimeEdit(this); - date_time_edit->setDateTime(default_val); - date_time_edit->setMinimumDateTime(QDateTime::fromSecsSinceEpoch(0)); - date_time_edit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); - - serializer = [this]() { return std::to_string(date_time_edit->dateTime().toSecsSinceEpoch()); }; - - auto get_clear_val = [this, restrict, current_time]() { - return QDateTime::fromSecsSinceEpoch([this, restrict, current_time]() { - if (restrict && checkbox->checkState() == Qt::Checked) { - return std::strtoll(RelevantDefault(setting).c_str(), nullptr, 0); - } - return current_time; - }()); - }; - - restore_func = [this, get_clear_val]() { date_time_edit->setDateTime(get_clear_val()); }; - - if (!Settings::IsConfiguringGlobal()) { - QObject::connect(date_time_edit, &QDateTimeEdit::editingFinished, - [this, get_clear_val, touch]() { - if (date_time_edit->dateTime() != get_clear_val()) { - touch(); - } - }); - } - - return date_time_edit; -} - -void Widget::SetupComponent(const QString& label, std::function<void()>& load_func, bool managed, - RequestType request, float multiplier, - Settings::BasicSetting* other_setting, const QString& suffix) { - created = true; - const auto type = setting.TypeId(); - - QLayout* layout = new QHBoxLayout(this); - layout->setContentsMargins(0, 0, 0, 0); - - if (other_setting == nullptr) { - other_setting = setting.PairedSetting(); - } - - const bool require_checkbox = - other_setting != nullptr && other_setting->TypeId() == typeid(bool); - - if (other_setting != nullptr && other_setting->TypeId() != typeid(bool)) { - LOG_WARNING( - Frontend, - "Extra setting \"{}\" specified but is not bool, refusing to create checkbox for it.", - other_setting->GetLabel()); - } - - std::function<std::string()> checkbox_serializer = []() -> std::string { return {}; }; - std::function<void()> checkbox_restore_func = []() {}; - - std::function<void()> touch = []() {}; - std::function<std::string()> serializer = []() -> std::string { return {}; }; - std::function<void()> restore_func = []() {}; - - QWidget* data_component{nullptr}; - - request = [&]() { - if (request != RequestType::Default) { - return request; - } - switch (setting.Specialization() & Settings::SpecializationTypeMask) { - case Settings::Specialization::Default: - return RequestType::Default; - case Settings::Specialization::Time: - return RequestType::DateTimeEdit; - case Settings::Specialization::Hex: - return RequestType::HexEdit; - case Settings::Specialization::RuntimeList: - managed = false; - [[fallthrough]]; - case Settings::Specialization::List: - return RequestType::ComboBox; - case Settings::Specialization::Scalar: - return RequestType::Slider; - case Settings::Specialization::Countable: - return RequestType::SpinBox; - case Settings::Specialization::Radio: - return RequestType::RadioGroup; - default: - break; - } - return request; - }(); - - if (!Settings::IsConfiguringGlobal() && managed) { - restore_button = CreateRestoreGlobalButton(setting.UsingGlobal(), this); - - touch = [this]() { - LOG_DEBUG(Frontend, "Enabling custom setting for \"{}\"", setting.GetLabel()); - restore_button->setEnabled(true); - restore_button->setVisible(true); - }; - } - - if (require_checkbox) { - QWidget* lhs = - CreateCheckBox(other_setting, label, checkbox_serializer, checkbox_restore_func, touch); - layout->addWidget(lhs); - } else if (setting.TypeId() != typeid(bool)) { - QLabel* qt_label = CreateLabel(label); - layout->addWidget(qt_label); - } - - if (setting.TypeId() == typeid(bool)) { - data_component = CreateCheckBox(&setting, label, serializer, restore_func, touch); - } else if (setting.IsEnum()) { - if (request == RequestType::RadioGroup) { - data_component = CreateRadioGroup(serializer, restore_func, touch); - } else { - data_component = CreateCombobox(serializer, restore_func, touch); - } - } else if (setting.IsIntegral()) { - switch (request) { - case RequestType::Slider: - case RequestType::ReverseSlider: - data_component = CreateSlider(request == RequestType::ReverseSlider, multiplier, suffix, - serializer, restore_func, touch); - break; - case RequestType::Default: - case RequestType::LineEdit: - data_component = CreateLineEdit(serializer, restore_func, touch); - break; - case RequestType::DateTimeEdit: - data_component = CreateDateTimeEdit(other_setting->ToString() != "true", true, - serializer, restore_func, touch); - break; - case RequestType::SpinBox: - data_component = CreateSpinBox(suffix, serializer, restore_func, touch); - break; - case RequestType::HexEdit: - data_component = CreateHexEdit(serializer, restore_func, touch); - break; - case RequestType::ComboBox: - data_component = CreateCombobox(serializer, restore_func, touch); - break; - default: - UNIMPLEMENTED(); - } - } else if (setting.IsFloatingPoint()) { - switch (request) { - case RequestType::Default: - case RequestType::SpinBox: - data_component = CreateDoubleSpinBox(suffix, serializer, restore_func, touch); - break; - case RequestType::Slider: - case RequestType::ReverseSlider: - data_component = CreateSlider(request == RequestType::ReverseSlider, multiplier, suffix, - serializer, restore_func, touch); - break; - default: - UNIMPLEMENTED(); - } - } else if (type == typeid(std::string)) { - switch (request) { - case RequestType::Default: - case RequestType::LineEdit: - data_component = CreateLineEdit(serializer, restore_func, touch); - break; - case RequestType::ComboBox: - data_component = CreateCombobox(serializer, restore_func, touch); - break; - default: - UNIMPLEMENTED(); - } - } - - if (data_component == nullptr) { - LOG_ERROR(Frontend, "Failed to create widget for \"{}\"", setting.GetLabel()); - created = false; - return; - } - - layout->addWidget(data_component); - - if (!managed) { - return; - } - - if (Settings::IsConfiguringGlobal()) { - load_func = [this, serializer, checkbox_serializer, require_checkbox, other_setting]() { - if (require_checkbox && other_setting->UsingGlobal()) { - other_setting->LoadString(checkbox_serializer()); - } - if (setting.UsingGlobal()) { - setting.LoadString(serializer()); - } - }; - } else { - layout->addWidget(restore_button); - - QObject::connect(restore_button, &QAbstractButton::clicked, - [this, restore_func, checkbox_restore_func](bool) { - LOG_DEBUG(Frontend, "Restore global state for \"{}\"", - setting.GetLabel()); - - restore_button->setEnabled(false); - restore_button->setVisible(false); - - checkbox_restore_func(); - restore_func(); - }); - - load_func = [this, serializer, require_checkbox, checkbox_serializer, other_setting]() { - bool using_global = !restore_button->isEnabled(); - setting.SetGlobal(using_global); - if (!using_global) { - setting.LoadString(serializer()); - } - if (require_checkbox) { - other_setting->SetGlobal(using_global); - if (!using_global) { - other_setting->LoadString(checkbox_serializer()); - } - } - }; - } - - if (other_setting != nullptr) { - const auto reset = [restore_func, data_component](int state) { - data_component->setEnabled(state == Qt::Checked); - if (state != Qt::Checked) { - restore_func(); - } - }; - connect(checkbox, &QCheckBox::stateChanged, reset); - reset(checkbox->checkState()); - } -} - -bool Widget::Valid() const { - return created; -} - -Widget::~Widget() = default; - -Widget::Widget(Settings::BasicSetting* setting_, const TranslationMap& translations_, - const ComboboxTranslationMap& combobox_translations_, QWidget* parent_, - bool runtime_lock_, std::vector<std::function<void(bool)>>& apply_funcs_, - RequestType request, bool managed, float multiplier, - Settings::BasicSetting* other_setting, const QString& suffix) - : QWidget(parent_), parent{parent_}, translations{translations_}, - combobox_enumerations{combobox_translations_}, setting{*setting_}, apply_funcs{apply_funcs_}, - runtime_lock{runtime_lock_} { - if (!Settings::IsConfiguringGlobal() && !setting.Switchable()) { - LOG_DEBUG(Frontend, "\"{}\" is not switchable, skipping...", setting.GetLabel()); - return; - } - - const int id = setting.Id(); - - const auto [label, tooltip] = [&]() { - const auto& setting_label = setting.GetLabel(); - if (translations.contains(id)) { - return std::pair{translations.at(id).first, translations.at(id).second}; - } - LOG_WARNING(Frontend, "Translation table lacks entry for \"{}\"", setting_label); - return std::pair{QString::fromStdString(setting_label), QStringLiteral()}; - }(); - - if (label == QStringLiteral()) { - LOG_DEBUG(Frontend, "Translation table has empty entry for \"{}\", skipping...", - setting.GetLabel()); - return; - } - - std::function<void()> load_func = []() {}; - - SetupComponent(label, load_func, managed, request, multiplier, other_setting, suffix); - - if (!created) { - LOG_WARNING(Frontend, "No widget was created for \"{}\"", setting.GetLabel()); - return; - } - - apply_funcs.push_back([load_func, setting_](bool powered_on) { - if (setting_->RuntimeModifiable() || !powered_on) { - load_func(); - } - }); - - bool enable = runtime_lock || setting.RuntimeModifiable(); - if (setting.Switchable() && Settings::IsConfiguringGlobal() && !runtime_lock) { - enable &= setting.UsingGlobal(); - } - this->setEnabled(enable); - - this->setToolTip(tooltip); -} - -Builder::Builder(QWidget* parent_, bool runtime_lock_) - : translations{InitializeTranslations(parent_)}, - combobox_translations{ComboboxEnumeration(parent_)}, parent{parent_}, runtime_lock{ - runtime_lock_} {} - -Builder::~Builder() = default; - -Widget* Builder::BuildWidget(Settings::BasicSetting* setting, - std::vector<std::function<void(bool)>>& apply_funcs, - RequestType request, bool managed, float multiplier, - Settings::BasicSetting* other_setting, const QString& suffix) const { - if (!Settings::IsConfiguringGlobal() && !setting->Switchable()) { - return nullptr; - } - - if (setting->Specialization() == Settings::Specialization::Paired) { - LOG_DEBUG(Frontend, "\"{}\" has specialization Paired: ignoring", setting->GetLabel()); - return nullptr; - } - - return new Widget(setting, *translations, *combobox_translations, parent, runtime_lock, - apply_funcs, request, managed, multiplier, other_setting, suffix); -} - -Widget* Builder::BuildWidget(Settings::BasicSetting* setting, - std::vector<std::function<void(bool)>>& apply_funcs, - Settings::BasicSetting* other_setting, RequestType request, - const QString& suffix) const { - return BuildWidget(setting, apply_funcs, request, true, 1.0f, other_setting, suffix); -} - -const ComboboxTranslationMap& Builder::ComboboxTranslations() const { - return *combobox_translations; -} - -} // namespace ConfigurationShared diff --git a/src/yuzu/configuration/shared_widget.h b/src/yuzu/configuration/shared_widget.h deleted file mode 100644 index 226284cf3..000000000 --- a/src/yuzu/configuration/shared_widget.h +++ /dev/null @@ -1,178 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include <functional> -#include <memory> -#include <string> -#include <vector> -#include <QString> -#include <QStringLiteral> -#include <QWidget> -#include <qobjectdefs.h> -#include "yuzu/configuration/shared_translation.h" - -class QCheckBox; -class QComboBox; -class QDateTimeEdit; -class QLabel; -class QLineEdit; -class QObject; -class QPushButton; -class QSlider; -class QSpinBox; -class QDoubleSpinBox; -class QRadioButton; - -namespace Settings { -class BasicSetting; -} // namespace Settings - -namespace ConfigurationShared { - -enum class RequestType { - Default, - ComboBox, - SpinBox, - Slider, - ReverseSlider, - LineEdit, - HexEdit, - DateTimeEdit, - RadioGroup, - MaxEnum, -}; - -constexpr float default_multiplier{1.f}; -constexpr float default_float_multiplier{100.f}; -static const QString default_suffix = QStringLiteral(); - -class Widget : public QWidget { - Q_OBJECT - -public: - /** - * @param setting The primary Setting to create the Widget for - * @param translations Map of translations to display on the left side label/checkbox - * @param combobox_translations Map of translations for enumerating combo boxes - * @param parent Qt parent - * @param runtime_lock Emulated guest powered on state, for use on settings that should be - * configured during guest execution - * @param apply_funcs_ List to append, functions to run to apply the widget state to the setting - * @param request What type of data representation component to create -- not always respected - * for the Setting data type - * @param managed Set true if the caller will set up component data and handling - * @param multiplier Value to multiply the slider feedback label - * @param other_setting Second setting to modify, to replace the label with a checkbox - * @param suffix Set to specify formats for Slider feedback labels or SpinBox - */ - explicit Widget(Settings::BasicSetting* setting, const TranslationMap& translations, - const ComboboxTranslationMap& combobox_translations, QWidget* parent, - bool runtime_lock, std::vector<std::function<void(bool)>>& apply_funcs_, - RequestType request = RequestType::Default, bool managed = true, - float multiplier = default_multiplier, - Settings::BasicSetting* other_setting = nullptr, - const QString& suffix = default_suffix); - virtual ~Widget(); - - /** - * @returns True if the Widget successfully created the components for the setting - */ - bool Valid() const; - - /** - * Creates a button to appear when a setting has been modified. This exists for custom - * configurations and wasn't designed to work for the global configuration. It has public access - * for settings that need to be unmanaged but can be custom. - * - * @param using_global The global state of the setting this button is for - * @param parent QWidget parent - */ - [[nodiscard]] static QPushButton* CreateRestoreGlobalButton(bool using_global, QWidget* parent); - - // Direct handles to sub components created - QPushButton* restore_button{}; ///< Restore button for custom configurations - QLineEdit* line_edit{}; ///< QLineEdit, used for LineEdit and HexEdit - QSpinBox* spinbox{}; - QDoubleSpinBox* double_spinbox{}; - QCheckBox* checkbox{}; - QSlider* slider{}; - QComboBox* combobox{}; - QDateTimeEdit* date_time_edit{}; - std::vector<std::pair<u32, QRadioButton*>> radio_buttons{}; - -private: - void SetupComponent(const QString& label, std::function<void()>& load_func, bool managed, - RequestType request, float multiplier, - Settings::BasicSetting* other_setting, const QString& suffix); - - QLabel* CreateLabel(const QString& text); - QWidget* CreateCheckBox(Settings::BasicSetting* bool_setting, const QString& label, - std::function<std::string()>& serializer, - std::function<void()>& restore_func, - const std::function<void()>& touch); - - QWidget* CreateCombobox(std::function<std::string()>& serializer, - std::function<void()>& restore_func, - const std::function<void()>& touch); - QWidget* CreateRadioGroup(std::function<std::string()>& serializer, - std::function<void()>& restore_func, - const std::function<void()>& touch); - QWidget* CreateLineEdit(std::function<std::string()>& serializer, - std::function<void()>& restore_func, const std::function<void()>& touch, - bool managed = true); - QWidget* CreateHexEdit(std::function<std::string()>& serializer, - std::function<void()>& restore_func, const std::function<void()>& touch); - QWidget* CreateSlider(bool reversed, float multiplier, const QString& suffix, - std::function<std::string()>& serializer, - std::function<void()>& restore_func, const std::function<void()>& touch); - QWidget* CreateDateTimeEdit(bool disabled, bool restrict, - std::function<std::string()>& serializer, - std::function<void()>& restore_func, - const std::function<void()>& touch); - QWidget* CreateSpinBox(const QString& suffix, std::function<std::string()>& serializer, - std::function<void()>& restore_func, const std::function<void()>& touch); - QWidget* CreateDoubleSpinBox(const QString& suffix, std::function<std::string()>& serializer, - std::function<void()>& restore_func, - const std::function<void()>& touch); - - QWidget* parent; - const TranslationMap& translations; - const ComboboxTranslationMap& combobox_enumerations; - Settings::BasicSetting& setting; - std::vector<std::function<void(bool)>>& apply_funcs; - - bool created{false}; - bool runtime_lock{false}; -}; - -class Builder { -public: - explicit Builder(QWidget* parent, bool runtime_lock); - ~Builder(); - - Widget* BuildWidget(Settings::BasicSetting* setting, - std::vector<std::function<void(bool)>>& apply_funcs, - RequestType request = RequestType::Default, bool managed = true, - float multiplier = default_multiplier, - Settings::BasicSetting* other_setting = nullptr, - const QString& suffix = default_suffix) const; - - Widget* BuildWidget(Settings::BasicSetting* setting, - std::vector<std::function<void(bool)>>& apply_funcs, - Settings::BasicSetting* other_setting, - RequestType request = RequestType::Default, - const QString& suffix = default_suffix) const; - - const ComboboxTranslationMap& ComboboxTranslations() const; - -private: - std::unique_ptr<TranslationMap> translations; - std::unique_ptr<ComboboxTranslationMap> combobox_translations; - - QWidget* parent; - const bool runtime_lock; -}; - -} // namespace ConfigurationShared diff --git a/src/yuzu/debugger/console.cpp b/src/yuzu/debugger/console.cpp deleted file mode 100644 index 1c1342ff1..000000000 --- a/src/yuzu/debugger/console.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#ifdef _WIN32 -#include <windows.h> - -#include <wincon.h> -#endif - -#include "common/logging/backend.h" -#include "yuzu/debugger/console.h" -#include "yuzu/uisettings.h" - -namespace Debugger { -void ToggleConsole() { - static bool console_shown = false; - if (console_shown == UISettings::values.show_console.GetValue()) { - return; - } else { - console_shown = UISettings::values.show_console.GetValue(); - } - - using namespace Common::Log; -#if defined(_WIN32) && !defined(_DEBUG) - FILE* temp; - if (UISettings::values.show_console) { - if (AllocConsole()) { - // The first parameter for freopen_s is a out parameter, so we can just ignore it - freopen_s(&temp, "CONIN$", "r", stdin); - freopen_s(&temp, "CONOUT$", "w", stdout); - freopen_s(&temp, "CONOUT$", "w", stderr); - SetConsoleOutputCP(65001); - SetColorConsoleBackendEnabled(true); - } - } else { - if (FreeConsole()) { - // In order to close the console, we have to also detach the streams on it. - // Just redirect them to NUL if there is no console window - SetColorConsoleBackendEnabled(false); - freopen_s(&temp, "NUL", "r", stdin); - freopen_s(&temp, "NUL", "w", stdout); - freopen_s(&temp, "NUL", "w", stderr); - } - } -#else - SetColorConsoleBackendEnabled(UISettings::values.show_console.GetValue()); -#endif -} -} // namespace Debugger diff --git a/src/yuzu/debugger/console.h b/src/yuzu/debugger/console.h deleted file mode 100644 index 2491d1ec1..000000000 --- a/src/yuzu/debugger/console.h +++ /dev/null @@ -1,13 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -namespace Debugger { - -/** - * Uses the WINAPI to hide or show the stderr console. This function is a placeholder until we can - * get a real qt logging window which would work for all platforms. - */ -void ToggleConsole(); -} // namespace Debugger diff --git a/src/yuzu/debugger/controller.cpp b/src/yuzu/debugger/controller.cpp deleted file mode 100644 index 216d2974d..000000000 --- a/src/yuzu/debugger/controller.cpp +++ /dev/null @@ -1,116 +0,0 @@ -// SPDX-FileCopyrightText: 2015 Citra Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include <QAction> -#include <QLayout> -#include <QString> -#include "common/settings.h" -#include "hid_core/frontend/emulated_controller.h" -#include "hid_core/hid_core.h" -#include "input_common/drivers/tas_input.h" -#include "input_common/main.h" -#include "yuzu/configuration/configure_input_player_widget.h" -#include "yuzu/debugger/controller.h" - -ControllerDialog::ControllerDialog(Core::HID::HIDCore& hid_core_, - std::shared_ptr<InputCommon::InputSubsystem> input_subsystem_, - QWidget* parent) - : QWidget(parent, Qt::Dialog), hid_core{hid_core_}, input_subsystem{input_subsystem_} { - setObjectName(QStringLiteral("Controller")); - setWindowTitle(tr("Controller P1")); - resize(500, 350); - setMinimumSize(500, 350); - // Enable the maximize button - setWindowFlags(windowFlags() | Qt::WindowMaximizeButtonHint); - - widget = new PlayerControlPreview(this); - refreshConfiguration(); - QLayout* layout = new QVBoxLayout(this); - layout->setContentsMargins(0, 0, 0, 0); - layout->addWidget(widget); - setLayout(layout); - - // Configure focus so that widget is focusable and the dialog automatically forwards focus to - // it. - setFocusProxy(widget); - widget->setFocusPolicy(Qt::StrongFocus); - widget->setFocus(); -} - -void ControllerDialog::refreshConfiguration() { - UnloadController(); - auto* player_1 = hid_core.GetEmulatedController(Core::HID::NpadIdType::Player1); - auto* handheld = hid_core.GetEmulatedController(Core::HID::NpadIdType::Handheld); - // Display the correct controller - controller = handheld->IsConnected() ? handheld : player_1; - - Core::HID::ControllerUpdateCallback engine_callback{ - .on_change = [this](Core::HID::ControllerTriggerType type) { ControllerUpdate(type); }, - .is_npad_service = true, - }; - callback_key = controller->SetCallback(engine_callback); - widget->SetController(controller); - is_controller_set = true; -} - -QAction* ControllerDialog::toggleViewAction() { - if (toggle_view_action == nullptr) { - toggle_view_action = new QAction(tr("&Controller P1"), this); - toggle_view_action->setCheckable(true); - toggle_view_action->setChecked(isVisible()); - connect(toggle_view_action, &QAction::toggled, this, &ControllerDialog::setVisible); - } - - return toggle_view_action; -} - -void ControllerDialog::UnloadController() { - widget->UnloadController(); - if (is_controller_set) { - controller->DeleteCallback(callback_key); - is_controller_set = false; - } -} - -void ControllerDialog::showEvent(QShowEvent* ev) { - if (toggle_view_action) { - toggle_view_action->setChecked(isVisible()); - } - QWidget::showEvent(ev); -} - -void ControllerDialog::hideEvent(QHideEvent* ev) { - if (toggle_view_action) { - toggle_view_action->setChecked(isVisible()); - } - QWidget::hideEvent(ev); -} - -void ControllerDialog::ControllerUpdate(Core::HID::ControllerTriggerType type) { - // TODO(german77): Remove TAS from here - switch (type) { - case Core::HID::ControllerTriggerType::Button: - case Core::HID::ControllerTriggerType::Stick: { - const auto buttons_values = controller->GetButtonsValues(); - const auto stick_values = controller->GetSticks(); - u64 buttons = 0; - std::size_t index = 0; - for (const auto& button : buttons_values) { - buttons |= button.value ? 1LLU << index : 0; - index++; - } - const InputCommon::TasInput::TasAnalog left_axis = { - .x = stick_values.left.x / 32767.f, - .y = stick_values.left.y / 32767.f, - }; - const InputCommon::TasInput::TasAnalog right_axis = { - .x = stick_values.right.x / 32767.f, - .y = stick_values.right.y / 32767.f, - }; - input_subsystem->GetTas()->RecordInput(buttons, left_axis, right_axis); - break; - } - default: - break; - } -} diff --git a/src/yuzu/debugger/controller.h b/src/yuzu/debugger/controller.h deleted file mode 100644 index 9651dfaa9..000000000 --- a/src/yuzu/debugger/controller.h +++ /dev/null @@ -1,56 +0,0 @@ -// SPDX-FileCopyrightText: 2015 Citra Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include <QWidget> - -class QAction; -class QHideEvent; -class QShowEvent; -class PlayerControlPreview; - -namespace InputCommon { -class InputSubsystem; -} - -namespace Core::HID { -class HIDCore; -class EmulatedController; -enum class ControllerTriggerType; -} // namespace Core::HID - -class ControllerDialog : public QWidget { - Q_OBJECT - -public: - explicit ControllerDialog(Core::HID::HIDCore& hid_core_, - std::shared_ptr<InputCommon::InputSubsystem> input_subsystem_, - QWidget* parent = nullptr); - - /// Returns a QAction that can be used to toggle visibility of this dialog. - QAction* toggleViewAction(); - - /// Reloads the widget to apply any changes in the configuration - void refreshConfiguration(); - - /// Disables events from the emulated controller - void UnloadController(); - -protected: - void showEvent(QShowEvent* ev) override; - void hideEvent(QHideEvent* ev) override; - -private: - /// Redirects input from the widget to the TAS driver - void ControllerUpdate(Core::HID::ControllerTriggerType type); - - int callback_key; - bool is_controller_set{}; - Core::HID::EmulatedController* controller; - - QAction* toggle_view_action = nullptr; - PlayerControlPreview* widget; - Core::HID::HIDCore& hid_core; - std::shared_ptr<InputCommon::InputSubsystem> input_subsystem; -}; diff --git a/src/yuzu/debugger/profiler.cpp b/src/yuzu/debugger/profiler.cpp deleted file mode 100644 index 493ee0b17..000000000 --- a/src/yuzu/debugger/profiler.cpp +++ /dev/null @@ -1,229 +0,0 @@ -// SPDX-FileCopyrightText: 2015 Citra Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include <QAction> -#include <QLayout> -#include <QMouseEvent> -#include <QPainter> -#include <QString> -#include <QTimer> -#include "common/common_types.h" -#include "common/microprofile.h" -#include "yuzu/debugger/profiler.h" -#include "yuzu/util/util.h" - -// Include the implementation of the UI in this file. This isn't in microprofile.cpp because the -// non-Qt frontends don't need it (and don't implement the UI drawing hooks either). -#if MICROPROFILE_ENABLED -#define MICROPROFILEUI_IMPL 1 -#include "common/microprofileui.h" - -class MicroProfileWidget : public QWidget { -public: - MicroProfileWidget(QWidget* parent = nullptr); - -protected: - void paintEvent(QPaintEvent* ev) override; - void showEvent(QShowEvent* ev) override; - void hideEvent(QHideEvent* ev) override; - - void mouseMoveEvent(QMouseEvent* ev) override; - void mousePressEvent(QMouseEvent* ev) override; - void mouseReleaseEvent(QMouseEvent* ev) override; - void wheelEvent(QWheelEvent* ev) override; - - void keyPressEvent(QKeyEvent* ev) override; - void keyReleaseEvent(QKeyEvent* ev) override; - -private: - /// This timer is used to redraw the widget's contents continuously. To save resources, it only - /// runs while the widget is visible. - QTimer update_timer; - /// Scale the coordinate system appropriately when dpi != 96. - qreal x_scale = 1.0, y_scale = 1.0; -}; - -#endif - -MicroProfileDialog::MicroProfileDialog(QWidget* parent) : QWidget(parent, Qt::Dialog) { - setObjectName(QStringLiteral("MicroProfile")); - setWindowTitle(tr("&MicroProfile")); - resize(1000, 600); - // Enable the maximize button - setWindowFlags(windowFlags() | Qt::WindowMaximizeButtonHint); - -#if MICROPROFILE_ENABLED - - MicroProfileWidget* widget = new MicroProfileWidget(this); - - QLayout* layout = new QVBoxLayout(this); - layout->setContentsMargins(0, 0, 0, 0); - layout->addWidget(widget); - setLayout(layout); - - // Configure focus so that widget is focusable and the dialog automatically forwards focus to - // it. - setFocusProxy(widget); - widget->setFocusPolicy(Qt::StrongFocus); - widget->setFocus(); -#endif -} - -QAction* MicroProfileDialog::toggleViewAction() { - if (toggle_view_action == nullptr) { - toggle_view_action = new QAction(windowTitle(), this); - toggle_view_action->setCheckable(true); - toggle_view_action->setChecked(isVisible()); - connect(toggle_view_action, &QAction::toggled, this, &MicroProfileDialog::setVisible); - } - - return toggle_view_action; -} - -void MicroProfileDialog::showEvent(QShowEvent* ev) { - if (toggle_view_action) { - toggle_view_action->setChecked(isVisible()); - } - QWidget::showEvent(ev); -} - -void MicroProfileDialog::hideEvent(QHideEvent* ev) { - if (toggle_view_action) { - toggle_view_action->setChecked(isVisible()); - } - QWidget::hideEvent(ev); -} - -#if MICROPROFILE_ENABLED - -/// There's no way to pass a user pointer to MicroProfile, so this variable is used to make the -/// QPainter available inside the drawing callbacks. -static QPainter* mp_painter = nullptr; - -MicroProfileWidget::MicroProfileWidget(QWidget* parent) : QWidget(parent) { - // Send mouse motion events even when not dragging. - setMouseTracking(true); - - MicroProfileSetDisplayMode(1); // Timers screen - MicroProfileInitUI(); - - connect(&update_timer, &QTimer::timeout, this, qOverload<>(&MicroProfileWidget::update)); -} - -void MicroProfileWidget::paintEvent(QPaintEvent* ev) { - QPainter painter(this); - - // The units used by Microprofile for drawing are based in pixels on a 96 dpi display. - x_scale = qreal(painter.device()->logicalDpiX()) / 96.0; - y_scale = qreal(painter.device()->logicalDpiY()) / 96.0; - painter.scale(x_scale, y_scale); - - painter.setBackground(Qt::black); - painter.eraseRect(rect()); - - QFont font = GetMonospaceFont(); - font.setPixelSize(MICROPROFILE_TEXT_HEIGHT); - painter.setFont(font); - - mp_painter = &painter; - MicroProfileDraw(rect().width() / x_scale, rect().height() / y_scale); - mp_painter = nullptr; -} - -void MicroProfileWidget::showEvent(QShowEvent* ev) { - update_timer.start(15); // ~60 Hz - QWidget::showEvent(ev); -} - -void MicroProfileWidget::hideEvent(QHideEvent* ev) { - update_timer.stop(); - QWidget::hideEvent(ev); -} - -void MicroProfileWidget::mouseMoveEvent(QMouseEvent* ev) { - const auto mouse_position = ev->pos(); - MicroProfileMousePosition(mouse_position.x() / x_scale, mouse_position.y() / y_scale, 0); - ev->accept(); -} - -void MicroProfileWidget::mousePressEvent(QMouseEvent* ev) { - const auto mouse_position = ev->pos(); - MicroProfileMousePosition(mouse_position.x() / x_scale, mouse_position.y() / y_scale, 0); - MicroProfileMouseButton(ev->buttons() & Qt::LeftButton, ev->buttons() & Qt::RightButton); - ev->accept(); -} - -void MicroProfileWidget::mouseReleaseEvent(QMouseEvent* ev) { - const auto mouse_position = ev->pos(); - MicroProfileMousePosition(mouse_position.x() / x_scale, mouse_position.y() / y_scale, 0); - MicroProfileMouseButton(ev->buttons() & Qt::LeftButton, ev->buttons() & Qt::RightButton); - ev->accept(); -} - -void MicroProfileWidget::wheelEvent(QWheelEvent* ev) { - const auto wheel_position = ev->position().toPoint(); - MicroProfileMousePosition(wheel_position.x() / x_scale, wheel_position.y() / y_scale, - ev->angleDelta().y() / 120); - ev->accept(); -} - -void MicroProfileWidget::keyPressEvent(QKeyEvent* ev) { - if (ev->key() == Qt::Key_Control) { - // Inform MicroProfile that the user is holding Ctrl. - MicroProfileModKey(1); - } - QWidget::keyPressEvent(ev); -} - -void MicroProfileWidget::keyReleaseEvent(QKeyEvent* ev) { - if (ev->key() == Qt::Key_Control) { - MicroProfileModKey(0); - } - QWidget::keyReleaseEvent(ev); -} - -// These functions are called by MicroProfileDraw to draw the interface elements on the screen. - -void MicroProfileDrawText(int x, int y, u32 hex_color, const char* text, u32 text_length) { - // hex_color does not include an alpha, so it must be assumed to be 255 - mp_painter->setPen(QColor::fromRgb(hex_color)); - - // It's impossible to draw a string using a monospaced font with a fixed width per cell in a - // way that's reliable across different platforms and fonts as far as I (yuriks) can tell, so - // draw each character individually in order to precisely control the text advance. - for (u32 i = 0; i < text_length; ++i) { - // Position the text baseline 1 pixel above the bottom of the text cell, this gives nice - // vertical alignment of text for a wide range of tested fonts. - mp_painter->drawText(x, y + MICROPROFILE_TEXT_HEIGHT - 2, QString{QLatin1Char{text[i]}}); - x += MICROPROFILE_TEXT_WIDTH + 1; - } -} - -void MicroProfileDrawBox(int left, int top, int right, int bottom, u32 hex_color, - MicroProfileBoxType type) { - QColor color = QColor::fromRgba(hex_color); - QBrush brush = color; - if (type == MicroProfileBoxTypeBar) { - QLinearGradient gradient(left, top, left, bottom); - gradient.setColorAt(0.f, color.lighter(125)); - gradient.setColorAt(1.f, color.darker(125)); - brush = gradient; - } - mp_painter->fillRect(left, top, right - left, bottom - top, brush); -} - -void MicroProfileDrawLine2D(u32 vertices_length, float* vertices, u32 hex_color) { - // Temporary vector used to convert between the float array and QPointF. Marked static to reuse - // the allocation across calls. - static std::vector<QPointF> point_buf; - - for (u32 i = 0; i < vertices_length; ++i) { - point_buf.emplace_back(vertices[i * 2 + 0], vertices[i * 2 + 1]); - } - - // hex_color does not include an alpha, so it must be assumed to be 255 - mp_painter->setPen(QColor::fromRgb(hex_color)); - mp_painter->drawPolyline(point_buf.data(), vertices_length); - point_buf.clear(); -} -#endif diff --git a/src/yuzu/debugger/profiler.h b/src/yuzu/debugger/profiler.h deleted file mode 100644 index 4c8ccd3c2..000000000 --- a/src/yuzu/debugger/profiler.h +++ /dev/null @@ -1,27 +0,0 @@ -// SPDX-FileCopyrightText: 2015 Citra Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include <QWidget> - -class QAction; -class QHideEvent; -class QShowEvent; - -class MicroProfileDialog : public QWidget { - Q_OBJECT - -public: - explicit MicroProfileDialog(QWidget* parent = nullptr); - - /// Returns a QAction that can be used to toggle visibility of this dialog. - QAction* toggleViewAction(); - -protected: - void showEvent(QShowEvent* ev) override; - void hideEvent(QHideEvent* ev) override; - -private: - QAction* toggle_view_action = nullptr; -}; diff --git a/src/yuzu/debugger/wait_tree.cpp b/src/yuzu/debugger/wait_tree.cpp deleted file mode 100644 index c05a05057..000000000 --- a/src/yuzu/debugger/wait_tree.cpp +++ /dev/null @@ -1,431 +0,0 @@ -// 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 "core/arm/debug.h" -#include "core/core.h" -#include "core/hle/kernel/k_class_token.h" -#include "core/hle/kernel/k_handle_table.h" -#include "core/hle/kernel/k_process.h" -#include "core/hle/kernel/k_readable_event.h" -#include "core/hle/kernel/k_scheduler.h" -#include "core/hle/kernel/k_synchronization_object.h" -#include "core/hle/kernel/k_thread.h" -#include "core/hle/kernel/svc_common.h" -#include "core/hle/kernel/svc_types.h" -#include "core/memory.h" - -namespace { - -constexpr std::array<std::array<Qt::GlobalColor, 2>, 10> WaitTreeColors{{ - {Qt::GlobalColor::darkGreen, Qt::GlobalColor::green}, - {Qt::GlobalColor::darkBlue, Qt::GlobalColor::cyan}, - {Qt::GlobalColor::lightGray, Qt::GlobalColor::lightGray}, - {Qt::GlobalColor::lightGray, Qt::GlobalColor::lightGray}, - {Qt::GlobalColor::darkRed, Qt::GlobalColor::red}, - {Qt::GlobalColor::darkYellow, Qt::GlobalColor::yellow}, - {Qt::GlobalColor::red, Qt::GlobalColor::red}, - {Qt::GlobalColor::darkCyan, Qt::GlobalColor::cyan}, - {Qt::GlobalColor::gray, Qt::GlobalColor::gray}, -}}; - -bool IsDarkTheme() { - const auto& theme = UISettings::values.theme; - return theme == std::string("qdarkstyle") || theme == std::string("qdarkstyle_midnight_blue") || - theme == std::string("colorful_dark") || theme == std::string("colorful_midnight_blue"); -} - -} // namespace - -WaitTreeItem::WaitTreeItem() = default; -WaitTreeItem::~WaitTreeItem() = default; - -QColor WaitTreeItem::GetColor() const { - if (IsDarkTheme()) { - return QColor(Qt::GlobalColor::white); - } else { - return QColor(Qt::GlobalColor::black); - } -} - -std::vector<std::unique_ptr<WaitTreeItem>> WaitTreeItem::GetChildren() const { - return {}; -} - -void WaitTreeItem::Expand() { - if (IsExpandable() && !expanded) { - children = GetChildren(); - for (std::size_t i = 0; i < children.size(); ++i) { - children[i]->parent = this; - children[i]->row = i; - } - expanded = true; - } -} - -WaitTreeItem* WaitTreeItem::Parent() const { - return parent; -} - -const std::vector<std::unique_ptr<WaitTreeItem>>& WaitTreeItem::Children() const { - return children; -} - -bool WaitTreeItem::IsExpandable() const { - return false; -} - -std::size_t WaitTreeItem::Row() const { - return row; -} - -std::vector<std::unique_ptr<WaitTreeThread>> WaitTreeItem::MakeThreadItemList( - Core::System& system) { - std::vector<std::unique_ptr<WaitTreeThread>> item_list; - std::size_t row = 0; - auto add_threads = [&](const std::vector<Kernel::KThread*>& threads) { - for (std::size_t i = 0; i < threads.size(); ++i) { - if (threads[i]->GetThreadType() == Kernel::ThreadType::User) { - item_list.push_back(std::make_unique<WaitTreeThread>(*threads[i], system)); - item_list.back()->row = row; - } - ++row; - } - }; - - add_threads(system.GlobalSchedulerContext().GetThreadList()); - - return item_list; -} - -WaitTreeText::WaitTreeText(QString t) : text(std::move(t)) {} -WaitTreeText::~WaitTreeText() = default; - -QString WaitTreeText::GetText() const { - return text; -} - -WaitTreeCallstack::WaitTreeCallstack(const Kernel::KThread& thread_, Core::System& system_) - : thread{thread_}, system{system_} {} -WaitTreeCallstack::~WaitTreeCallstack() = default; - -QString WaitTreeCallstack::GetText() const { - return tr("Call stack"); -} - -std::vector<std::unique_ptr<WaitTreeItem>> WaitTreeCallstack::GetChildren() const { - std::vector<std::unique_ptr<WaitTreeItem>> list; - - if (thread.GetThreadType() != Kernel::ThreadType::User) { - return list; - } - - if (thread.GetOwnerProcess() == nullptr || !thread.GetOwnerProcess()->Is64Bit()) { - return list; - } - - auto backtrace = Core::GetBacktraceFromContext(thread.GetOwnerProcess(), thread.GetContext()); - - for (auto& entry : backtrace) { - std::string s = fmt::format("{:20}{:016X} {:016X} {:016X} {}", entry.module, entry.address, - entry.original_address, entry.offset, entry.name); - list.push_back(std::make_unique<WaitTreeText>(QString::fromStdString(s))); - } - - return list; -} - -WaitTreeSynchronizationObject::WaitTreeSynchronizationObject( - const Kernel::KSynchronizationObject& object_, Core::System& system_) - : object{object_}, system{system_} {} -WaitTreeSynchronizationObject::~WaitTreeSynchronizationObject() = default; - -WaitTreeExpandableItem::WaitTreeExpandableItem() = default; -WaitTreeExpandableItem::~WaitTreeExpandableItem() = default; - -bool WaitTreeExpandableItem::IsExpandable() const { - return true; -} - -QString WaitTreeSynchronizationObject::GetText() const { - return tr("[%1] %2") - .arg(object.GetId()) - .arg(QString::fromStdString(object.GetTypeObj().GetName())); -} - -std::unique_ptr<WaitTreeSynchronizationObject> WaitTreeSynchronizationObject::make( - const Kernel::KSynchronizationObject& object, Core::System& system) { - const auto type = - static_cast<Kernel::KClassTokenGenerator::ObjectType>(object.GetTypeObj().GetClassToken()); - switch (type) { - case Kernel::KClassTokenGenerator::ObjectType::KReadableEvent: - return std::make_unique<WaitTreeEvent>(static_cast<const Kernel::KReadableEvent&>(object), - system); - case Kernel::KClassTokenGenerator::ObjectType::KThread: - return std::make_unique<WaitTreeThread>(static_cast<const Kernel::KThread&>(object), - system); - default: - return std::make_unique<WaitTreeSynchronizationObject>(object, system); - } -} - -std::vector<std::unique_ptr<WaitTreeItem>> WaitTreeSynchronizationObject::GetChildren() const { - std::vector<std::unique_ptr<WaitTreeItem>> list; - - auto threads = object.GetWaitingThreadsForDebugging(); - if (threads.empty()) { - list.push_back(std::make_unique<WaitTreeText>(tr("waited by no thread"))); - } else { - list.push_back(std::make_unique<WaitTreeThreadList>(std::move(threads), system)); - } - - return list; -} - -WaitTreeThread::WaitTreeThread(const Kernel::KThread& thread, Core::System& system_) - : WaitTreeSynchronizationObject(thread, system_), system{system_} {} -WaitTreeThread::~WaitTreeThread() = default; - -QString WaitTreeThread::GetText() const { - const auto& thread = static_cast<const Kernel::KThread&>(object); - QString status; - switch (thread.GetState()) { - case Kernel::ThreadState::Runnable: - if (!thread.IsSuspended()) { - status = tr("runnable"); - } else { - status = tr("paused"); - } - break; - case Kernel::ThreadState::Waiting: - switch (thread.GetWaitReasonForDebugging()) { - case Kernel::ThreadWaitReasonForDebugging::Sleep: - status = tr("sleeping"); - break; - case Kernel::ThreadWaitReasonForDebugging::IPC: - status = tr("waiting for IPC reply"); - break; - case Kernel::ThreadWaitReasonForDebugging::Synchronization: - status = tr("waiting for objects"); - break; - case Kernel::ThreadWaitReasonForDebugging::ConditionVar: - status = tr("waiting for condition variable"); - break; - case Kernel::ThreadWaitReasonForDebugging::Arbitration: - status = tr("waiting for address arbiter"); - break; - case Kernel::ThreadWaitReasonForDebugging::Suspended: - status = tr("waiting for suspend resume"); - break; - default: - status = tr("waiting"); - break; - } - break; - case Kernel::ThreadState::Initialized: - status = tr("initialized"); - break; - case Kernel::ThreadState::Terminated: - status = tr("terminated"); - break; - default: - status = tr("unknown"); - break; - } - - const auto& context = thread.GetContext(); - const QString pc_info = tr(" PC = 0x%1 LR = 0x%2") - .arg(context.pc, 8, 16, QLatin1Char{'0'}) - .arg(context.lr, 8, 16, QLatin1Char{'0'}); - return QStringLiteral("%1%2 (%3) ") - .arg(WaitTreeSynchronizationObject::GetText(), pc_info, status); -} - -QColor WaitTreeThread::GetColor() const { - const std::size_t color_index = IsDarkTheme() ? 1 : 0; - - const auto& thread = static_cast<const Kernel::KThread&>(object); - switch (thread.GetState()) { - case Kernel::ThreadState::Runnable: - if (!thread.IsSuspended()) { - return QColor(WaitTreeColors[0][color_index]); - } else { - return QColor(WaitTreeColors[2][color_index]); - } - case Kernel::ThreadState::Waiting: - switch (thread.GetWaitReasonForDebugging()) { - case Kernel::ThreadWaitReasonForDebugging::IPC: - return QColor(WaitTreeColors[4][color_index]); - case Kernel::ThreadWaitReasonForDebugging::Sleep: - return QColor(WaitTreeColors[5][color_index]); - case Kernel::ThreadWaitReasonForDebugging::Synchronization: - case Kernel::ThreadWaitReasonForDebugging::ConditionVar: - case Kernel::ThreadWaitReasonForDebugging::Arbitration: - case Kernel::ThreadWaitReasonForDebugging::Suspended: - return QColor(WaitTreeColors[6][color_index]); - break; - default: - return QColor(WaitTreeColors[3][color_index]); - } - case Kernel::ThreadState::Initialized: - return QColor(WaitTreeColors[7][color_index]); - case Kernel::ThreadState::Terminated: - return QColor(WaitTreeColors[8][color_index]); - default: - return WaitTreeItem::GetColor(); - } -} - -std::vector<std::unique_ptr<WaitTreeItem>> WaitTreeThread::GetChildren() const { - std::vector<std::unique_ptr<WaitTreeItem>> list(WaitTreeSynchronizationObject::GetChildren()); - - const auto& thread = static_cast<const Kernel::KThread&>(object); - - QString processor; - switch (thread.GetActiveCore()) { - case Kernel::Svc::IdealCoreUseProcessValue: - processor = tr("ideal"); - break; - default: - processor = tr("core %1").arg(thread.GetActiveCore()); - break; - } - - list.push_back(std::make_unique<WaitTreeText>(tr("processor = %1").arg(processor))); - list.push_back(std::make_unique<WaitTreeText>( - tr("affinity mask = %1").arg(thread.GetAffinityMask().GetAffinityMask()))); - list.push_back(std::make_unique<WaitTreeText>(tr("thread id = %1").arg(thread.GetThreadId()))); - list.push_back(std::make_unique<WaitTreeText>(tr("priority = %1(current) / %2(normal)") - .arg(thread.GetPriority()) - .arg(thread.GetBasePriority()))); - list.push_back(std::make_unique<WaitTreeText>( - tr("last running ticks = %1").arg(thread.GetLastScheduledTick()))); - - list.push_back(std::make_unique<WaitTreeCallstack>(thread, system)); - - return list; -} - -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_) - : thread_list(std::move(list)), system{system_} {} -WaitTreeThreadList::~WaitTreeThreadList() = default; - -QString WaitTreeThreadList::GetText() const { - return tr("waited by thread"); -} - -std::vector<std::unique_ptr<WaitTreeItem>> WaitTreeThreadList::GetChildren() const { - std::vector<std::unique_ptr<WaitTreeItem>> list(thread_list.size()); - std::transform(thread_list.begin(), thread_list.end(), list.begin(), - [this](const auto& t) { return std::make_unique<WaitTreeThread>(*t, system); }); - return list; -} - -WaitTreeModel::WaitTreeModel(Core::System& system_, QObject* parent) - : QAbstractItemModel(parent), system{system_} {} -WaitTreeModel::~WaitTreeModel() = default; - -QModelIndex WaitTreeModel::index(int row, int column, const QModelIndex& parent) const { - if (!hasIndex(row, column, parent)) - return {}; - - if (parent.isValid()) { - WaitTreeItem* parent_item = static_cast<WaitTreeItem*>(parent.internalPointer()); - parent_item->Expand(); - return createIndex(row, column, parent_item->Children()[row].get()); - } - - return createIndex(row, column, thread_items[row].get()); -} - -QModelIndex WaitTreeModel::parent(const QModelIndex& index) const { - if (!index.isValid()) - return {}; - - WaitTreeItem* parent_item = static_cast<WaitTreeItem*>(index.internalPointer())->Parent(); - if (!parent_item) { - return QModelIndex(); - } - return createIndex(static_cast<int>(parent_item->Row()), 0, parent_item); -} - -int WaitTreeModel::rowCount(const QModelIndex& parent) const { - if (!parent.isValid()) - return static_cast<int>(thread_items.size()); - - WaitTreeItem* parent_item = static_cast<WaitTreeItem*>(parent.internalPointer()); - parent_item->Expand(); - return static_cast<int>(parent_item->Children().size()); -} - -int WaitTreeModel::columnCount(const QModelIndex&) const { - return 1; -} - -QVariant WaitTreeModel::data(const QModelIndex& index, int role) const { - if (!index.isValid()) - return {}; - - switch (role) { - case Qt::DisplayRole: - return static_cast<WaitTreeItem*>(index.internalPointer())->GetText(); - case Qt::ForegroundRole: - return static_cast<WaitTreeItem*>(index.internalPointer())->GetColor(); - default: - return {}; - } -} - -void WaitTreeModel::ClearItems() { - thread_items.clear(); -} - -void WaitTreeModel::InitItems() { - thread_items = WaitTreeItem::MakeThreadItemList(system); -} - -WaitTreeWidget::WaitTreeWidget(Core::System& system_, QWidget* parent) - : QDockWidget(tr("&Wait Tree"), parent), system{system_} { - setObjectName(QStringLiteral("WaitTreeWidget")); - view = new QTreeView(this); - view->setHeaderHidden(true); - setWidget(view); - setEnabled(false); -} - -WaitTreeWidget::~WaitTreeWidget() = default; - -void WaitTreeWidget::OnDebugModeEntered() { - if (!system.IsPoweredOn()) - return; - model->InitItems(); - view->setModel(model); - setEnabled(true); -} - -void WaitTreeWidget::OnDebugModeLeft() { - setEnabled(false); - view->setModel(nullptr); - model->ClearItems(); -} - -void WaitTreeWidget::OnEmulationStarting(EmuThread* emu_thread) { - model = new WaitTreeModel(system, this); - view->setModel(model); - setEnabled(false); -} - -void WaitTreeWidget::OnEmulationStopping() { - view->setModel(nullptr); - delete model; - setEnabled(false); -} diff --git a/src/yuzu/debugger/wait_tree.h b/src/yuzu/debugger/wait_tree.h deleted file mode 100644 index 23c329fbe..000000000 --- a/src/yuzu/debugger/wait_tree.h +++ /dev/null @@ -1,188 +0,0 @@ -// SPDX-FileCopyrightText: 2016 Citra Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include <cstddef> -#include <memory> -#include <vector> - -#include <QDockWidget> -#include <QTreeView> - -#include "common/common_types.h" -#include "core/hle/kernel/k_auto_object.h" -#include "core/hle/kernel/svc_common.h" - -class EmuThread; - -namespace Core { -class System; -} - -namespace Kernel { -class KHandleTable; -class KReadableEvent; -class KSynchronizationObject; -class KThread; -} // namespace Kernel - -class WaitTreeThread; - -class WaitTreeItem : public QObject { - Q_OBJECT -public: - WaitTreeItem(); - ~WaitTreeItem() override; - - virtual bool IsExpandable() const; - virtual std::vector<std::unique_ptr<WaitTreeItem>> GetChildren() const; - virtual QString GetText() const = 0; - virtual QColor GetColor() const; - - void Expand(); - WaitTreeItem* Parent() const; - const std::vector<std::unique_ptr<WaitTreeItem>>& Children() const; - std::size_t Row() const; - static std::vector<std::unique_ptr<WaitTreeThread>> MakeThreadItemList(Core::System& system); - -private: - std::size_t row; - bool expanded = false; - WaitTreeItem* parent = nullptr; - std::vector<std::unique_ptr<WaitTreeItem>> children; -}; - -class WaitTreeText : public WaitTreeItem { - Q_OBJECT -public: - explicit WaitTreeText(QString text); - ~WaitTreeText() override; - - QString GetText() const override; - -private: - QString text; -}; - -class WaitTreeExpandableItem : public WaitTreeItem { - Q_OBJECT -public: - WaitTreeExpandableItem(); - ~WaitTreeExpandableItem() override; - - bool IsExpandable() const override; -}; - -class WaitTreeCallstack : public WaitTreeExpandableItem { - Q_OBJECT -public: - explicit WaitTreeCallstack(const Kernel::KThread& thread_, Core::System& system_); - ~WaitTreeCallstack() override; - - QString GetText() const override; - std::vector<std::unique_ptr<WaitTreeItem>> GetChildren() const override; - -private: - const Kernel::KThread& thread; - - Core::System& system; -}; - -class WaitTreeSynchronizationObject : public WaitTreeExpandableItem { - Q_OBJECT -public: - explicit WaitTreeSynchronizationObject(const Kernel::KSynchronizationObject& object_, - Core::System& system_); - ~WaitTreeSynchronizationObject() override; - - static std::unique_ptr<WaitTreeSynchronizationObject> make( - const Kernel::KSynchronizationObject& object, Core::System& system); - QString GetText() const override; - std::vector<std::unique_ptr<WaitTreeItem>> GetChildren() const override; - -protected: - const Kernel::KSynchronizationObject& object; - -private: - Core::System& system; -}; - -class WaitTreeThread : public WaitTreeSynchronizationObject { - Q_OBJECT -public: - explicit WaitTreeThread(const Kernel::KThread& thread, Core::System& system_); - ~WaitTreeThread() override; - - QString GetText() const override; - QColor GetColor() const override; - std::vector<std::unique_ptr<WaitTreeItem>> GetChildren() const override; - -private: - Core::System& system; -}; - -class WaitTreeEvent : public WaitTreeSynchronizationObject { - Q_OBJECT -public: - explicit WaitTreeEvent(const Kernel::KReadableEvent& object_, Core::System& system_); - ~WaitTreeEvent() override; -}; - -class WaitTreeThreadList : public WaitTreeExpandableItem { - Q_OBJECT -public: - explicit WaitTreeThreadList(std::vector<Kernel::KThread*>&& list, Core::System& system_); - ~WaitTreeThreadList() override; - - QString GetText() const override; - std::vector<std::unique_ptr<WaitTreeItem>> GetChildren() const override; - -private: - std::vector<Kernel::KThread*> thread_list; - - Core::System& system; -}; - -class WaitTreeModel : public QAbstractItemModel { - Q_OBJECT - -public: - explicit WaitTreeModel(Core::System& system_, QObject* parent = nullptr); - ~WaitTreeModel() override; - - QVariant data(const QModelIndex& index, int role) const override; - QModelIndex index(int row, int column, const QModelIndex& parent) const override; - QModelIndex parent(const QModelIndex& index) const override; - int rowCount(const QModelIndex& parent) const override; - int columnCount(const QModelIndex& parent) const override; - - void ClearItems(); - void InitItems(); - -private: - std::vector<std::unique_ptr<WaitTreeThread>> thread_items; - - Core::System& system; -}; - -class WaitTreeWidget : public QDockWidget { - Q_OBJECT - -public: - explicit WaitTreeWidget(Core::System& system_, QWidget* parent = nullptr); - ~WaitTreeWidget() override; - -public slots: - void OnDebugModeEntered(); - void OnDebugModeLeft(); - - void OnEmulationStarting(EmuThread* emu_thread); - void OnEmulationStopping(); - -private: - QTreeView* view; - WaitTreeModel* model; - - Core::System& system; -}; diff --git a/src/yuzu/discord.h b/src/yuzu/discord.h deleted file mode 100644 index e08784498..000000000 --- a/src/yuzu/discord.h +++ /dev/null @@ -1,24 +0,0 @@ -// SPDX-FileCopyrightText: 2018 Citra Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -namespace DiscordRPC { - -class DiscordInterface { -public: - virtual ~DiscordInterface() = default; - - virtual void Pause() = 0; - virtual void Update() = 0; -}; - -class NullImpl : public DiscordInterface { -public: - ~NullImpl() = default; - - void Pause() override {} - void Update() override {} -}; - -} // namespace DiscordRPC diff --git a/src/yuzu/discord_impl.cpp b/src/yuzu/discord_impl.cpp deleted file mode 100644 index 57b50abd0..000000000 --- a/src/yuzu/discord_impl.cpp +++ /dev/null @@ -1,117 +0,0 @@ -// SPDX-FileCopyrightText: 2018 Citra Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include <chrono> -#include <string> - -#include <QEventLoop> -#include <QNetworkAccessManager> -#include <QNetworkReply> - -#include <discord_rpc.h> -#include <fmt/format.h> - -#include "common/common_types.h" -#include "common/string_util.h" -#include "core/core.h" -#include "core/loader/loader.h" -#include "yuzu/discord_impl.h" -#include "yuzu/uisettings.h" - -namespace DiscordRPC { - -DiscordImpl::DiscordImpl(Core::System& system_) : system{system_} { - DiscordEventHandlers handlers{}; - // The number is the client ID for yuzu, it's used for images and the - // application name - Discord_Initialize("712465656758665259", &handlers, 1, nullptr); -} - -DiscordImpl::~DiscordImpl() { - Discord_ClearPresence(); - Discord_Shutdown(); -} - -void DiscordImpl::Pause() { - Discord_ClearPresence(); -} - -std::string DiscordImpl::GetGameString(const std::string& title) { - // Convert to lowercase - std::string icon_name = Common::ToLower(title); - - // Replace spaces with dashes - std::replace(icon_name.begin(), icon_name.end(), ' ', '-'); - - // Remove non-alphanumeric characters but keep dashes - std::erase_if(icon_name, [](char c) { return !std::isalnum(c) && c != '-'; }); - - // Remove dashes from the start and end of the string - icon_name.erase(icon_name.begin(), std::find_if(icon_name.begin(), icon_name.end(), - [](int ch) { return ch != '-'; })); - icon_name.erase( - std::find_if(icon_name.rbegin(), icon_name.rend(), [](int ch) { return ch != '-'; }).base(), - icon_name.end()); - - // Remove double dashes - icon_name.erase(std::unique(icon_name.begin(), icon_name.end(), - [](char a, char b) { return a == '-' && b == '-'; }), - icon_name.end()); - - return icon_name; -} - -void DiscordImpl::UpdateGameStatus(bool use_default) { - const std::string default_text = "yuzu is an emulator for the Nintendo Switch"; - const std::string default_image = "yuzu_logo"; - const std::string url = use_default ? default_image : game_url; - s64 start_time = std::chrono::duration_cast<std::chrono::seconds>( - std::chrono::system_clock::now().time_since_epoch()) - .count(); - DiscordRichPresence presence{}; - - presence.largeImageKey = url.c_str(); - presence.largeImageText = game_title.c_str(); - presence.smallImageKey = default_image.c_str(); - presence.smallImageText = default_text.c_str(); - presence.state = game_title.c_str(); - presence.details = "Currently in game"; - presence.startTimestamp = start_time; - Discord_UpdatePresence(&presence); -} - -void DiscordImpl::Update() { - const std::string default_text = "yuzu is an emulator for the Nintendo Switch"; - const std::string default_image = "yuzu_logo"; - - if (system.IsPoweredOn()) { - system.GetAppLoader().ReadTitle(game_title); - - // Used to format Icon URL for yuzu website game compatibility page - std::string icon_name = GetGameString(game_title); - game_url = fmt::format("https://yuzu-emu.org/images/game/boxart/{}.png", icon_name); - - QNetworkAccessManager manager; - QNetworkRequest request; - request.setUrl(QUrl(QString::fromStdString(game_url))); - request.setTransferTimeout(3000); - QNetworkReply* reply = manager.head(request); - QEventLoop request_event_loop; - QObject::connect(reply, &QNetworkReply::finished, &request_event_loop, &QEventLoop::quit); - request_event_loop.exec(); - UpdateGameStatus(reply->error()); - return; - } - - s64 start_time = std::chrono::duration_cast<std::chrono::seconds>( - std::chrono::system_clock::now().time_since_epoch()) - .count(); - - DiscordRichPresence presence{}; - presence.largeImageKey = default_image.c_str(); - presence.largeImageText = default_text.c_str(); - presence.details = "Currently not in game"; - presence.startTimestamp = start_time; - Discord_UpdatePresence(&presence); -} -} // namespace DiscordRPC diff --git a/src/yuzu/discord_impl.h b/src/yuzu/discord_impl.h deleted file mode 100644 index eb6cf9ae0..000000000 --- a/src/yuzu/discord_impl.h +++ /dev/null @@ -1,32 +0,0 @@ -// SPDX-FileCopyrightText: 2018 Citra Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include "yuzu/discord.h" - -namespace Core { -class System; -} - -namespace DiscordRPC { - -class DiscordImpl : public DiscordInterface { -public: - DiscordImpl(Core::System& system_); - ~DiscordImpl() override; - - void Pause() override; - void Update() override; - -private: - std::string GetGameString(const std::string& title); - void UpdateGameStatus(bool use_default); - - std::string game_url{}; - std::string game_title{}; - - Core::System& system; -}; - -} // namespace DiscordRPC diff --git a/src/yuzu/game_list.cpp b/src/yuzu/game_list.cpp deleted file mode 100644 index b40af957c..000000000 --- a/src/yuzu/game_list.cpp +++ /dev/null @@ -1,970 +0,0 @@ -// SPDX-FileCopyrightText: 2015 Citra Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include <regex> -#include <QApplication> -#include <QDir> -#include <QFileInfo> -#include <QHeaderView> -#include <QJsonArray> -#include <QJsonDocument> -#include <QJsonObject> -#include <QList> -#include <QMenu> -#include <QThreadPool> -#include <QToolButton> -#include <fmt/format.h> -#include "common/common_types.h" -#include "common/logging/log.h" -#include "core/core.h" -#include "core/file_sys/patch_manager.h" -#include "core/file_sys/registered_cache.h" -#include "yuzu/compatibility_list.h" -#include "yuzu/game_list.h" -#include "yuzu/game_list_p.h" -#include "yuzu/game_list_worker.h" -#include "yuzu/main.h" -#include "yuzu/uisettings.h" -#include "yuzu/util/controller_navigation.h" - -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) { - // If it isn't a KeyRelease event then continue with standard event processing - if (event->type() != QEvent::KeyRelease) - return QObject::eventFilter(obj, event); - - QKeyEvent* keyEvent = static_cast<QKeyEvent*>(event); - QString edit_filter_text = gamelist->search_field->edit_filter->text().toLower(); - - // If the searchfield's text hasn't changed special function keys get checked - // If no function key changes the searchfield's text the filter doesn't need to get reloaded - if (edit_filter_text == edit_filter_text_old) { - switch (keyEvent->key()) { - // Escape: Resets the searchfield - case Qt::Key_Escape: { - if (edit_filter_text_old.isEmpty()) { - return QObject::eventFilter(obj, event); - } else { - gamelist->search_field->edit_filter->clear(); - edit_filter_text.clear(); - } - break; - } - // Return and Enter - // If the enter key gets pressed first checks how many and which entry is visible - // If there is only one result launch this game - case Qt::Key_Return: - case Qt::Key_Enter: { - if (gamelist->search_field->visible == 1) { - const QString file_path = gamelist->GetLastFilterResultItem(); - - // To avoid loading error dialog loops while confirming them using enter - // Also users usually want to run a different game after closing one - gamelist->search_field->edit_filter->clear(); - edit_filter_text.clear(); - emit gamelist->GameChosen(file_path); - } else { - return QObject::eventFilter(obj, event); - } - break; - } - default: - return QObject::eventFilter(obj, event); - } - } - edit_filter_text_old = edit_filter_text; - return QObject::eventFilter(obj, event); -} - -void GameListSearchField::setFilterResult(int visible_, int total_) { - visible = visible_; - total = total_; - - label_filter_result->setText(tr("%1 of %n result(s)", "", total).arg(visible)); -} - -QString GameListSearchField::filterText() const { - return edit_filter->text(); -} - -QString GameList::GetLastFilterResultItem() const { - QString file_path; - - for (int i = 1; i < item_model->rowCount() - 1; ++i) { - const QStandardItem* folder = item_model->item(i, 0); - const QModelIndex folder_index = folder->index(); - const int children_count = folder->rowCount(); - - for (int j = 0; j < children_count; ++j) { - if (tree_view->isRowHidden(j, folder_index)) { - continue; - } - - const QStandardItem* child = folder->child(j, 0); - file_path = child->data(GameListItemPath::FullPathRole).toString(); - } - } - - return file_path; -} - -void GameListSearchField::clear() { - edit_filter->clear(); -} - -void GameListSearchField::setFocus() { - if (edit_filter->isVisible()) { - edit_filter->setFocus(); - } -} - -GameListSearchField::GameListSearchField(GameList* parent) : QWidget{parent} { - auto* const key_release_eater = new KeyReleaseEater(parent, this); - layout_filter = new QHBoxLayout; - layout_filter->setContentsMargins(8, 8, 8, 8); - label_filter = new QLabel; - edit_filter = new QLineEdit; - edit_filter->clear(); - edit_filter->installEventFilter(key_release_eater); - edit_filter->setClearButtonEnabled(true); - connect(edit_filter, &QLineEdit::textChanged, parent, &GameList::OnTextChanged); - label_filter_result = new QLabel; - button_filter_close = new QToolButton(this); - button_filter_close->setText(QStringLiteral("X")); - button_filter_close->setCursor(Qt::ArrowCursor); - button_filter_close->setStyleSheet( - QStringLiteral("QToolButton{ border: none; padding: 0px; color: " - "#000000; font-weight: bold; background: #F0F0F0; }" - "QToolButton:hover{ border: none; padding: 0px; color: " - "#EEEEEE; font-weight: bold; background: #E81123}")); - connect(button_filter_close, &QToolButton::clicked, parent, &GameList::OnFilterCloseClicked); - layout_filter->setSpacing(10); - layout_filter->addWidget(label_filter); - layout_filter->addWidget(edit_filter); - layout_filter->addWidget(label_filter_result); - layout_filter->addWidget(button_filter_close); - setLayout(layout_filter); - RetranslateUI(); -} - -/** - * Checks if all words separated by spaces are contained in another string - * This offers a word order insensitive search function - * - * @param haystack String that gets checked if it contains all words of the userinput string - * @param userinput String containing all words getting checked - * @return true if the haystack contains all words of userinput - */ -static bool ContainsAllWords(const QString& haystack, const QString& userinput) { - const QStringList userinput_split = userinput.split(QLatin1Char{' '}, Qt::SkipEmptyParts); - - return std::all_of(userinput_split.begin(), userinput_split.end(), - [&haystack](const QString& s) { return haystack.contains(s); }); -} - -// Syncs the expanded state of Game Directories with settings to persist across sessions -void GameList::OnItemExpanded(const QModelIndex& item) { - const auto type = item.data(GameListItem::TypeRole).value<GameListItemType>(); - const bool is_dir = type == GameListItemType::CustomDir || type == GameListItemType::SdmcDir || - type == GameListItemType::UserNandDir || - type == GameListItemType::SysNandDir; - const bool is_fave = type == GameListItemType::Favorites; - if (!is_dir && !is_fave) { - return; - } - const bool is_expanded = tree_view->isExpanded(item); - if (is_fave) { - UISettings::values.favorites_expanded = is_expanded; - return; - } - const int item_dir_index = item.data(GameListDir::GameDirRole).toInt(); - UISettings::values.game_dirs[item_dir_index].expanded = is_expanded; -} - -// Event in order to filter the gamelist after editing the searchfield -void GameList::OnTextChanged(const QString& new_text) { - QString edit_filter_text = new_text.toLower(); - QStandardItem* folder; - int children_total = 0; - - // If the searchfield is empty every item is visible - // Otherwise the filter gets applied - if (edit_filter_text.isEmpty()) { - tree_view->setRowHidden(0, item_model->invisibleRootItem()->index(), - UISettings::values.favorited_ids.size() == 0); - for (int i = 1; i < item_model->rowCount() - 1; ++i) { - folder = item_model->item(i, 0); - const QModelIndex folder_index = folder->index(); - const int children_count = folder->rowCount(); - for (int j = 0; j < children_count; ++j) { - ++children_total; - tree_view->setRowHidden(j, folder_index, false); - } - } - search_field->setFilterResult(children_total, children_total); - } else { - tree_view->setRowHidden(0, item_model->invisibleRootItem()->index(), true); - int result_count = 0; - for (int i = 1; i < item_model->rowCount() - 1; ++i) { - folder = item_model->item(i, 0); - const QModelIndex folder_index = folder->index(); - const int children_count = folder->rowCount(); - for (int j = 0; j < children_count; ++j) { - ++children_total; - - const QStandardItem* child = folder->child(j, 0); - - const auto program_id = child->data(GameListItemPath::ProgramIdRole).toULongLong(); - - const QString file_path = - child->data(GameListItemPath::FullPathRole).toString().toLower(); - const QString file_title = - child->data(GameListItemPath::TitleRole).toString().toLower(); - const QString file_program_id = - QStringLiteral("%1").arg(program_id, 16, 16, QLatin1Char{'0'}); - - // Only items which filename in combination with its title contains all words - // that are in the searchfield will be visible in the gamelist - // The search is case insensitive because of toLower() - // I decided not to use Qt::CaseInsensitive in containsAllWords to prevent - // multiple conversions of edit_filter_text for each game in the gamelist - const QString file_name = - file_path.mid(file_path.lastIndexOf(QLatin1Char{'/'}) + 1) + QLatin1Char{' '} + - file_title; - if (ContainsAllWords(file_name, edit_filter_text) || - (file_program_id.count() == 16 && file_program_id.contains(edit_filter_text))) { - tree_view->setRowHidden(j, folder_index, false); - ++result_count; - } else { - tree_view->setRowHidden(j, folder_index, true); - } - } - } - search_field->setFilterResult(result_count, children_total); - } -} - -void GameList::OnUpdateThemedIcons() { - for (int i = 0; i < item_model->invisibleRootItem()->rowCount(); i++) { - QStandardItem* child = item_model->invisibleRootItem()->child(i); - - const int icon_size = UISettings::values.folder_icon_size.GetValue(); - - switch (child->data(GameListItem::TypeRole).value<GameListItemType>()) { - case GameListItemType::SdmcDir: - child->setData( - QIcon::fromTheme(QStringLiteral("sd_card")) - .pixmap(icon_size) - .scaled(icon_size, icon_size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation), - Qt::DecorationRole); - break; - case GameListItemType::UserNandDir: - child->setData( - QIcon::fromTheme(QStringLiteral("chip")) - .pixmap(icon_size) - .scaled(icon_size, icon_size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation), - Qt::DecorationRole); - break; - case GameListItemType::SysNandDir: - child->setData( - QIcon::fromTheme(QStringLiteral("chip")) - .pixmap(icon_size) - .scaled(icon_size, icon_size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation), - Qt::DecorationRole); - break; - case GameListItemType::CustomDir: { - const UISettings::GameDir& game_dir = - UISettings::values.game_dirs[child->data(GameListDir::GameDirRole).toInt()]; - const QString icon_name = QFileInfo::exists(QString::fromStdString(game_dir.path)) - ? QStringLiteral("folder") - : QStringLiteral("bad_folder"); - child->setData( - QIcon::fromTheme(icon_name).pixmap(icon_size).scaled( - icon_size, icon_size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation), - Qt::DecorationRole); - break; - } - case GameListItemType::AddDir: - child->setData( - QIcon::fromTheme(QStringLiteral("list-add")) - .pixmap(icon_size) - .scaled(icon_size, icon_size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation), - Qt::DecorationRole); - break; - case GameListItemType::Favorites: - child->setData( - QIcon::fromTheme(QStringLiteral("star")) - .pixmap(icon_size) - .scaled(icon_size, icon_size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation), - Qt::DecorationRole); - break; - default: - break; - } - } -} - -void GameList::OnFilterCloseClicked() { - main_window->filterBarSetChecked(false); -} - -GameList::GameList(FileSys::VirtualFilesystem vfs_, FileSys::ManualContentProvider* provider_, - PlayTime::PlayTimeManager& play_time_manager_, Core::System& system_, - GMainWindow* parent) - : QWidget{parent}, vfs{std::move(vfs_)}, provider{provider_}, - play_time_manager{play_time_manager_}, system{system_} { - watcher = new QFileSystemWatcher(this); - connect(watcher, &QFileSystemWatcher::directoryChanged, this, &GameList::RefreshGameDirectory); - - this->main_window = parent; - layout = new QVBoxLayout; - tree_view = new QTreeView; - controller_navigation = new ControllerNavigation(system.HIDCore(), this); - search_field = new GameListSearchField(this); - item_model = new QStandardItemModel(tree_view); - tree_view->setModel(item_model); - - tree_view->setAlternatingRowColors(true); - tree_view->setSelectionMode(QHeaderView::SingleSelection); - tree_view->setSelectionBehavior(QHeaderView::SelectRows); - tree_view->setVerticalScrollMode(QHeaderView::ScrollPerPixel); - tree_view->setHorizontalScrollMode(QHeaderView::ScrollPerPixel); - tree_view->setSortingEnabled(true); - tree_view->setEditTriggers(QHeaderView::NoEditTriggers); - tree_view->setContextMenuPolicy(Qt::CustomContextMenu); - tree_view->setStyleSheet(QStringLiteral("QTreeView{ border: none; }")); - - item_model->insertColumns(0, COLUMN_COUNT); - RetranslateUI(); - - tree_view->setColumnHidden(COLUMN_ADD_ONS, !UISettings::values.show_add_ons); - tree_view->setColumnHidden(COLUMN_COMPATIBILITY, !UISettings::values.show_compat); - tree_view->setColumnHidden(COLUMN_PLAY_TIME, !UISettings::values.show_play_time); - item_model->setSortRole(GameListItemPath::SortRole); - - connect(main_window, &GMainWindow::UpdateThemedIcons, this, &GameList::OnUpdateThemedIcons); - connect(tree_view, &QTreeView::activated, this, &GameList::ValidateEntry); - connect(tree_view, &QTreeView::customContextMenuRequested, this, &GameList::PopupContextMenu); - connect(tree_view, &QTreeView::expanded, this, &GameList::OnItemExpanded); - connect(tree_view, &QTreeView::collapsed, this, &GameList::OnItemExpanded); - connect(controller_navigation, &ControllerNavigation::TriggerKeyboardEvent, - [this](Qt::Key key) { - // Avoid pressing buttons while playing - if (system.IsPoweredOn()) { - return; - } - if (!this->isActiveWindow()) { - return; - } - QKeyEvent* event = new QKeyEvent(QEvent::KeyPress, key, Qt::NoModifier); - QCoreApplication::postEvent(tree_view, event); - }); - - // 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 umbrells of custom types. - qRegisterMetaType<QList<QStandardItem*>>("QList<QStandardItem*>"); - - layout->setContentsMargins(0, 0, 0, 0); - layout->setSpacing(0); - layout->addWidget(tree_view); - layout->addWidget(search_field); - setLayout(layout); -} - -void GameList::UnloadController() { - controller_navigation->UnloadController(); -} - -GameList::~GameList() { - UnloadController(); -} - -void GameList::SetFilterFocus() { - if (tree_view->model()->rowCount() > 0) { - search_field->setFocus(); - } -} - -void GameList::SetFilterVisible(bool visibility) { - search_field->setVisible(visibility); -} - -void GameList::ClearFilter() { - search_field->clear(); -} - -void GameList::WorkerEvent() { - current_worker->ProcessEvents(this); -} - -void GameList::AddDirEntry(GameListDir* entry_items) { - item_model->invisibleRootItem()->appendRow(entry_items); - tree_view->setExpanded( - entry_items->index(), - UISettings::values.game_dirs[entry_items->data(GameListDir::GameDirRole).toInt()].expanded); -} - -void GameList::AddEntry(const QList<QStandardItem*>& entry_items, GameListDir* parent) { - parent->appendRow(entry_items); -} - -void GameList::ValidateEntry(const QModelIndex& item) { - const auto selected = item.sibling(item.row(), 0); - - switch (selected.data(GameListItem::TypeRole).value<GameListItemType>()) { - case GameListItemType::Game: { - const QString file_path = selected.data(GameListItemPath::FullPathRole).toString(); - if (file_path.isEmpty()) - return; - const QFileInfo file_info(file_path); - if (!file_info.exists()) - return; - - if (file_info.isDir()) { - const QDir dir{file_path}; - const QStringList matching_main = dir.entryList({QStringLiteral("main")}, QDir::Files); - if (matching_main.size() == 1) { - emit GameChosen(dir.path() + QDir::separator() + matching_main[0]); - } - return; - } - - const auto title_id = selected.data(GameListItemPath::ProgramIdRole).toULongLong(); - - // Users usually want to run a different game after closing one - search_field->clear(); - emit GameChosen(file_path, title_id); - break; - } - case GameListItemType::AddDir: - emit AddDirectory(); - break; - default: - break; - } -} - -bool GameList::IsEmpty() const { - for (int i = 0; i < item_model->rowCount(); i++) { - const QStandardItem* child = item_model->invisibleRootItem()->child(i); - const auto type = static_cast<GameListItemType>(child->type()); - - if (!child->hasChildren() && - (type == GameListItemType::SdmcDir || type == GameListItemType::UserNandDir || - type == GameListItemType::SysNandDir)) { - item_model->invisibleRootItem()->removeRow(child->row()); - i--; - } - } - - return !item_model->invisibleRootItem()->hasChildren(); -} - -void GameList::DonePopulating(const QStringList& watch_list) { - emit ShowList(!IsEmpty()); - - item_model->invisibleRootItem()->appendRow(new GameListAddDir()); - - // Add favorites row - item_model->invisibleRootItem()->insertRow(0, new GameListFavorites()); - tree_view->setRowHidden(0, item_model->invisibleRootItem()->index(), - UISettings::values.favorited_ids.size() == 0); - tree_view->setExpanded(item_model->invisibleRootItem()->child(0)->index(), - UISettings::values.favorites_expanded.GetValue()); - for (const auto id : UISettings::values.favorited_ids) { - AddFavorite(id); - } - - // Clear out the old directories to watch for changes and add the new ones - auto watch_dirs = watcher->directories(); - if (!watch_dirs.isEmpty()) { - watcher->removePaths(watch_dirs); - } - // Workaround: Add the watch paths in chunks to allow the gui to refresh - // This prevents the UI from stalling when a large number of watch paths are added - // 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(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(); - } - tree_view->setEnabled(true); - int children_total = 0; - for (int i = 1; i < item_model->rowCount() - 1; ++i) { - children_total += item_model->item(i, 0)->rowCount(); - } - search_field->setFilterResult(children_total, children_total); - if (children_total > 0) { - search_field->setFocus(); - } - item_model->sort(tree_view->header()->sortIndicatorSection(), - tree_view->header()->sortIndicatorOrder()); - - emit PopulatingCompleted(); -} - -void GameList::PopupContextMenu(const QPoint& menu_location) { - QModelIndex item = tree_view->indexAt(menu_location); - if (!item.isValid()) - return; - - const auto selected = item.sibling(item.row(), 0); - QMenu context_menu; - switch (selected.data(GameListItem::TypeRole).value<GameListItemType>()) { - case GameListItemType::Game: - AddGamePopup(context_menu, selected.data(GameListItemPath::ProgramIdRole).toULongLong(), - selected.data(GameListItemPath::FullPathRole).toString().toStdString()); - break; - case GameListItemType::CustomDir: - AddPermDirPopup(context_menu, selected); - AddCustomDirPopup(context_menu, selected); - break; - case GameListItemType::SdmcDir: - case GameListItemType::UserNandDir: - case GameListItemType::SysNandDir: - AddPermDirPopup(context_menu, selected); - break; - case GameListItemType::Favorites: - AddFavoritesPopup(context_menu); - break; - default: - break; - } - context_menu.exec(tree_view->viewport()->mapToGlobal(menu_location)); -} - -void GameList::AddGamePopup(QMenu& context_menu, u64 program_id, const std::string& path) { - QAction* favorite = context_menu.addAction(tr("Favorite")); - context_menu.addSeparator(); - QAction* start_game = context_menu.addAction(tr("Start Game")); - QAction* start_game_global = - context_menu.addAction(tr("Start Game without Custom Configuration")); - context_menu.addSeparator(); - QAction* open_save_location = context_menu.addAction(tr("Open Save Data Location")); - QAction* open_mod_location = context_menu.addAction(tr("Open Mod Data Location")); - QAction* open_transferable_shader_cache = - context_menu.addAction(tr("Open Transferable Pipeline Cache")); - context_menu.addSeparator(); - QMenu* remove_menu = context_menu.addMenu(tr("Remove")); - QAction* remove_update = remove_menu->addAction(tr("Remove Installed Update")); - QAction* remove_dlc = remove_menu->addAction(tr("Remove All Installed DLC")); - QAction* remove_custom_config = remove_menu->addAction(tr("Remove Custom Configuration")); - QAction* remove_play_time_data = remove_menu->addAction(tr("Remove Play Time Data")); - QAction* remove_cache_storage = remove_menu->addAction(tr("Remove Cache Storage")); - QAction* remove_gl_shader_cache = remove_menu->addAction(tr("Remove OpenGL Pipeline Cache")); - QAction* remove_vk_shader_cache = remove_menu->addAction(tr("Remove Vulkan Pipeline Cache")); - remove_menu->addSeparator(); - QAction* remove_shader_cache = remove_menu->addAction(tr("Remove All Pipeline Caches")); - QAction* remove_all_content = remove_menu->addAction(tr("Remove All Installed Contents")); - QMenu* dump_romfs_menu = context_menu.addMenu(tr("Dump RomFS")); - QAction* dump_romfs = dump_romfs_menu->addAction(tr("Dump RomFS")); - QAction* dump_romfs_sdmc = dump_romfs_menu->addAction(tr("Dump RomFS to SDMC")); - QAction* verify_integrity = context_menu.addAction(tr("Verify Integrity")); - QAction* copy_tid = context_menu.addAction(tr("Copy Title ID to Clipboard")); - QAction* navigate_to_gamedb_entry = context_menu.addAction(tr("Navigate to GameDB entry")); -// TODO: Implement shortcut creation for macOS -#if !defined(__APPLE__) - QMenu* shortcut_menu = context_menu.addMenu(tr("Create Shortcut")); - QAction* create_desktop_shortcut = shortcut_menu->addAction(tr("Add to Desktop")); - QAction* create_applications_menu_shortcut = - shortcut_menu->addAction(tr("Add to Applications Menu")); -#endif - context_menu.addSeparator(); - QAction* properties = context_menu.addAction(tr("Properties")); - - favorite->setVisible(program_id != 0); - favorite->setCheckable(true); - favorite->setChecked(UISettings::values.favorited_ids.contains(program_id)); - open_save_location->setVisible(program_id != 0); - open_mod_location->setVisible(program_id != 0); - open_transferable_shader_cache->setVisible(program_id != 0); - remove_update->setVisible(program_id != 0); - remove_dlc->setVisible(program_id != 0); - remove_gl_shader_cache->setVisible(program_id != 0); - remove_vk_shader_cache->setVisible(program_id != 0); - remove_shader_cache->setVisible(program_id != 0); - remove_all_content->setVisible(program_id != 0); - auto it = FindMatchingCompatibilityEntry(compatibility_list, program_id); - navigate_to_gamedb_entry->setVisible(it != compatibility_list.end() && program_id != 0); - - connect(favorite, &QAction::triggered, [this, program_id]() { ToggleFavorite(program_id); }); - connect(open_save_location, &QAction::triggered, [this, program_id, path]() { - emit OpenFolderRequested(program_id, GameListOpenTarget::SaveData, path); - }); - connect(start_game, &QAction::triggered, - [this, path]() { emit BootGame(QString::fromStdString(path), StartGameType::Normal); }); - connect(start_game_global, &QAction::triggered, - [this, path]() { emit BootGame(QString::fromStdString(path), StartGameType::Global); }); - connect(open_mod_location, &QAction::triggered, [this, program_id, path]() { - emit OpenFolderRequested(program_id, GameListOpenTarget::ModData, path); - }); - connect(open_transferable_shader_cache, &QAction::triggered, - [this, program_id]() { emit OpenTransferableShaderCacheRequested(program_id); }); - connect(remove_all_content, &QAction::triggered, [this, program_id]() { - emit RemoveInstalledEntryRequested(program_id, InstalledEntryType::Game); - }); - connect(remove_update, &QAction::triggered, [this, program_id]() { - emit RemoveInstalledEntryRequested(program_id, InstalledEntryType::Update); - }); - connect(remove_dlc, &QAction::triggered, [this, program_id]() { - emit RemoveInstalledEntryRequested(program_id, InstalledEntryType::AddOnContent); - }); - connect(remove_gl_shader_cache, &QAction::triggered, [this, program_id, path]() { - emit RemoveFileRequested(program_id, GameListRemoveTarget::GlShaderCache, path); - }); - connect(remove_vk_shader_cache, &QAction::triggered, [this, program_id, path]() { - emit RemoveFileRequested(program_id, GameListRemoveTarget::VkShaderCache, path); - }); - connect(remove_shader_cache, &QAction::triggered, [this, program_id, path]() { - emit RemoveFileRequested(program_id, GameListRemoveTarget::AllShaderCache, path); - }); - connect(remove_custom_config, &QAction::triggered, [this, program_id, path]() { - emit RemoveFileRequested(program_id, GameListRemoveTarget::CustomConfiguration, path); - }); - connect(remove_play_time_data, &QAction::triggered, - [this, program_id]() { emit RemovePlayTimeRequested(program_id); }); - connect(remove_cache_storage, &QAction::triggered, [this, program_id, path] { - emit RemoveFileRequested(program_id, GameListRemoveTarget::CacheStorage, path); - }); - connect(dump_romfs, &QAction::triggered, [this, program_id, path]() { - emit DumpRomFSRequested(program_id, path, DumpRomFSTarget::Normal); - }); - connect(dump_romfs_sdmc, &QAction::triggered, [this, program_id, path]() { - emit DumpRomFSRequested(program_id, path, DumpRomFSTarget::SDMC); - }); - connect(verify_integrity, &QAction::triggered, - [this, path]() { emit VerifyIntegrityRequested(path); }); - connect(copy_tid, &QAction::triggered, - [this, program_id]() { emit CopyTIDRequested(program_id); }); - connect(navigate_to_gamedb_entry, &QAction::triggered, [this, program_id]() { - emit NavigateToGamedbEntryRequested(program_id, compatibility_list); - }); -// TODO: Implement shortcut creation for macOS -#if !defined(__APPLE__) - connect(create_desktop_shortcut, &QAction::triggered, [this, program_id, path]() { - emit CreateShortcut(program_id, path, GameListShortcutTarget::Desktop); - }); - connect(create_applications_menu_shortcut, &QAction::triggered, [this, program_id, path]() { - emit CreateShortcut(program_id, path, GameListShortcutTarget::Applications); - }); -#endif - connect(properties, &QAction::triggered, - [this, path]() { emit OpenPerGameGeneralRequested(path); }); -}; - -void GameList::AddCustomDirPopup(QMenu& context_menu, QModelIndex selected) { - UISettings::GameDir& game_dir = - UISettings::values.game_dirs[selected.data(GameListDir::GameDirRole).toInt()]; - - QAction* deep_scan = context_menu.addAction(tr("Scan Subfolders")); - QAction* delete_dir = context_menu.addAction(tr("Remove Game Directory")); - - deep_scan->setCheckable(true); - deep_scan->setChecked(game_dir.deep_scan); - - connect(deep_scan, &QAction::triggered, [this, &game_dir] { - game_dir.deep_scan = !game_dir.deep_scan; - PopulateAsync(UISettings::values.game_dirs); - }); - connect(delete_dir, &QAction::triggered, [this, &game_dir, selected] { - UISettings::values.game_dirs.removeOne(game_dir); - item_model->invisibleRootItem()->removeRow(selected.row()); - OnTextChanged(search_field->filterText()); - }); -} - -void GameList::AddPermDirPopup(QMenu& context_menu, QModelIndex selected) { - const int game_dir_index = selected.data(GameListDir::GameDirRole).toInt(); - - QAction* move_up = context_menu.addAction(tr("\u25B2 Move Up")); - QAction* move_down = context_menu.addAction(tr("\u25bc Move Down")); - QAction* open_directory_location = context_menu.addAction(tr("Open Directory Location")); - - const int row = selected.row(); - - move_up->setEnabled(row > 1); - move_down->setEnabled(row < item_model->rowCount() - 2); - - connect(move_up, &QAction::triggered, [this, selected, row, game_dir_index] { - const int other_index = selected.sibling(row - 1, 0).data(GameListDir::GameDirRole).toInt(); - // swap the items in the settings - std::swap(UISettings::values.game_dirs[game_dir_index], - UISettings::values.game_dirs[other_index]); - // swap the indexes held by the QVariants - item_model->setData(selected, QVariant(other_index), GameListDir::GameDirRole); - item_model->setData(selected.sibling(row - 1, 0), QVariant(game_dir_index), - GameListDir::GameDirRole); - // move the treeview items - QList<QStandardItem*> item = item_model->takeRow(row); - item_model->invisibleRootItem()->insertRow(row - 1, item); - tree_view->setExpanded(selected.sibling(row - 1, 0), - UISettings::values.game_dirs[other_index].expanded); - }); - - connect(move_down, &QAction::triggered, [this, selected, row, game_dir_index] { - const int other_index = selected.sibling(row + 1, 0).data(GameListDir::GameDirRole).toInt(); - // swap the items in the settings - std::swap(UISettings::values.game_dirs[game_dir_index], - UISettings::values.game_dirs[other_index]); - // swap the indexes held by the QVariants - item_model->setData(selected, QVariant(other_index), GameListDir::GameDirRole); - item_model->setData(selected.sibling(row + 1, 0), QVariant(game_dir_index), - GameListDir::GameDirRole); - // move the treeview items - const QList<QStandardItem*> item = item_model->takeRow(row); - item_model->invisibleRootItem()->insertRow(row + 1, item); - tree_view->setExpanded(selected.sibling(row + 1, 0), - UISettings::values.game_dirs[other_index].expanded); - }); - - connect(open_directory_location, &QAction::triggered, [this, game_dir_index] { - emit OpenDirectory( - QString::fromStdString(UISettings::values.game_dirs[game_dir_index].path)); - }); -} - -void GameList::AddFavoritesPopup(QMenu& context_menu) { - QAction* clear = context_menu.addAction(tr("Clear")); - - connect(clear, &QAction::triggered, [this] { - for (const auto id : UISettings::values.favorited_ids) { - RemoveFavorite(id); - } - UISettings::values.favorited_ids.clear(); - tree_view->setRowHidden(0, item_model->invisibleRootItem()->index(), true); - }); -} - -void GameList::LoadCompatibilityList() { - QFile compat_list{QStringLiteral(":compatibility_list/compatibility_list.json")}; - - if (!compat_list.open(QFile::ReadOnly | QFile::Text)) { - LOG_ERROR(Frontend, "Unable to open game compatibility list"); - return; - } - - if (compat_list.size() == 0) { - LOG_WARNING(Frontend, "Game compatibility list is empty"); - return; - } - - const QByteArray content = compat_list.readAll(); - if (content.isEmpty()) { - LOG_ERROR(Frontend, "Unable to completely read game compatibility list"); - return; - } - - const QJsonDocument json = QJsonDocument::fromJson(content); - const QJsonArray arr = json.array(); - - for (const QJsonValue value : arr) { - const QJsonObject game = value.toObject(); - const QString compatibility_key = QStringLiteral("compatibility"); - - if (!game.contains(compatibility_key) || !game[compatibility_key].isDouble()) { - continue; - } - - const int compatibility = game[compatibility_key].toInt(); - const QString directory = game[QStringLiteral("directory")].toString(); - const QJsonArray ids = game[QStringLiteral("releases")].toArray(); - - for (const QJsonValue id_ref : ids) { - const QJsonObject id_object = id_ref.toObject(); - const QString id = id_object[QStringLiteral("id")].toString(); - - compatibility_list.emplace(id.toUpper().toStdString(), - std::make_pair(QString::number(compatibility), directory)); - } - } -} - -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")); - item_model->setHeaderData(COLUMN_PLAY_TIME, Qt::Horizontal, tr("Play time")); -} - -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); - - // Update the columns in case UISettings has changed - tree_view->setColumnHidden(COLUMN_ADD_ONS, !UISettings::values.show_add_ons); - tree_view->setColumnHidden(COLUMN_COMPATIBILITY, !UISettings::values.show_compat); - tree_view->setColumnHidden(COLUMN_FILE_TYPE, !UISettings::values.show_types); - tree_view->setColumnHidden(COLUMN_SIZE, !UISettings::values.show_size); - tree_view->setColumnHidden(COLUMN_PLAY_TIME, !UISettings::values.show_play_time); - - // Cancel any existing worker. - current_worker.reset(); - - // Delete any rows that might already exist if we're repopulating - item_model->removeRows(0, item_model->rowCount()); - search_field->clear(); - - current_worker = std::make_unique<GameListWorker>(vfs, provider, game_dirs, compatibility_list, - play_time_manager, system); - - // Get events from the worker as data becomes available - connect(current_worker.get(), &GameListWorker::DataAvailable, this, &GameList::WorkerEvent, - Qt::QueuedConnection); - - QThreadPool::globalInstance()->start(current_worker.get()); -} - -void GameList::SaveInterfaceLayout() { - UISettings::values.gamelist_header_state = tree_view->header()->saveState(); -} - -void GameList::LoadInterfaceLayout() { - auto* header = tree_view->header(); - - if (header->restoreState(UISettings::values.gamelist_header_state)) { - return; - } - - // We are using the name column to display icons and titles - // so make it as large as possible as default. - header->resizeSection(COLUMN_NAME, header->width()); -} - -const QStringList GameList::supported_file_extensions = { - QStringLiteral("nso"), QStringLiteral("nro"), QStringLiteral("nca"), - QStringLiteral("xci"), QStringLiteral("nsp"), QStringLiteral("kip")}; - -void GameList::RefreshGameDirectory() { - if (!UISettings::values.game_dirs.empty() && current_worker != nullptr) { - LOG_INFO(Frontend, "Change detected in the games directory. Reloading game list."); - PopulateAsync(UISettings::values.game_dirs); - } -} - -void GameList::ToggleFavorite(u64 program_id) { - if (!UISettings::values.favorited_ids.contains(program_id)) { - tree_view->setRowHidden(0, item_model->invisibleRootItem()->index(), - !search_field->filterText().isEmpty()); - UISettings::values.favorited_ids.append(program_id); - AddFavorite(program_id); - item_model->sort(tree_view->header()->sortIndicatorSection(), - tree_view->header()->sortIndicatorOrder()); - } else { - UISettings::values.favorited_ids.removeOne(program_id); - RemoveFavorite(program_id); - if (UISettings::values.favorited_ids.size() == 0) { - tree_view->setRowHidden(0, item_model->invisibleRootItem()->index(), true); - } - } - SaveConfig(); -} - -void GameList::AddFavorite(u64 program_id) { - auto* favorites_row = item_model->item(0); - - for (int i = 1; i < item_model->rowCount() - 1; i++) { - const auto* folder = item_model->item(i); - for (int j = 0; j < folder->rowCount(); j++) { - if (folder->child(j)->data(GameListItemPath::ProgramIdRole).toULongLong() == - program_id) { - QList<QStandardItem*> list; - for (int k = 0; k < COLUMN_COUNT; k++) { - list.append(folder->child(j, k)->clone()); - } - list[0]->setData(folder->child(j)->data(GameListItem::SortRole), - GameListItem::SortRole); - list[0]->setText(folder->child(j)->data(Qt::DisplayRole).toString()); - - favorites_row->appendRow(list); - return; - } - } - } -} - -void GameList::RemoveFavorite(u64 program_id) { - auto* favorites_row = item_model->item(0); - - for (int i = 0; i < favorites_row->rowCount(); i++) { - const auto* game = favorites_row->child(i); - if (game->data(GameListItemPath::ProgramIdRole).toULongLong() == program_id) { - favorites_row->removeRow(i); - return; - } - } -} - -GameListPlaceholder::GameListPlaceholder(GMainWindow* parent) : QWidget{parent} { - connect(parent, &GMainWindow::UpdateThemedIcons, this, - &GameListPlaceholder::onUpdateThemedIcons); - - layout = new QVBoxLayout; - image = new QLabel; - text = new QLabel; - layout->setAlignment(Qt::AlignCenter); - image->setPixmap(QIcon::fromTheme(QStringLiteral("plus_folder")).pixmap(200)); - - RetranslateUI(); - QFont font = text->font(); - font.setPointSize(20); - text->setFont(font); - text->setAlignment(Qt::AlignHCenter); - image->setAlignment(Qt::AlignHCenter); - - layout->addWidget(image); - layout->addWidget(text); - setLayout(layout); -} - -GameListPlaceholder::~GameListPlaceholder() = default; - -void GameListPlaceholder::onUpdateThemedIcons() { - image->setPixmap(QIcon::fromTheme(QStringLiteral("plus_folder")).pixmap(200)); -} - -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 deleted file mode 100644 index 79f9c7ec0..000000000 --- a/src/yuzu/game_list.h +++ /dev/null @@ -1,204 +0,0 @@ -// SPDX-FileCopyrightText: 2015 Citra Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include <QFileSystemWatcher> -#include <QLabel> -#include <QLineEdit> -#include <QList> -#include <QStandardItemModel> -#include <QString> -#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" -#include "yuzu/play_time_manager.h" - -namespace Core { -class System; -} - -class ControllerNavigation; -class GameListWorker; -class GameListSearchField; -class GameListDir; -class GMainWindow; -enum class AmLaunchType; -enum class StartGameType; - -namespace FileSys { -class ManualContentProvider; -class VfsFilesystem; -} // namespace FileSys - -enum class GameListOpenTarget { - SaveData, - ModData, -}; - -enum class GameListRemoveTarget { - GlShaderCache, - VkShaderCache, - AllShaderCache, - CustomConfiguration, - CacheStorage, -}; - -enum class DumpRomFSTarget { - Normal, - SDMC, -}; - -enum class GameListShortcutTarget { - Desktop, - Applications, -}; - -enum class InstalledEntryType { - Game, - Update, - AddOnContent, -}; - -class GameList : public QWidget { - Q_OBJECT - -public: - enum { - COLUMN_NAME, - COLUMN_COMPATIBILITY, - COLUMN_ADD_ONS, - COLUMN_FILE_TYPE, - COLUMN_SIZE, - COLUMN_PLAY_TIME, - COLUMN_COUNT, // Number of columns - }; - - explicit GameList(std::shared_ptr<FileSys::VfsFilesystem> vfs_, - FileSys::ManualContentProvider* provider_, - PlayTime::PlayTimeManager& play_time_manager_, Core::System& system_, - GMainWindow* parent = nullptr); - ~GameList() override; - - QString GetLastFilterResultItem() const; - void ClearFilter(); - void SetFilterFocus(); - void SetFilterVisible(bool visibility); - bool IsEmpty() const; - - void LoadCompatibilityList(); - void PopulateAsync(QVector<UISettings::GameDir>& game_dirs); - - void SaveInterfaceLayout(); - void LoadInterfaceLayout(); - - QStandardItemModel* GetModel() const; - - /// Disables events from the emulated controller - void UnloadController(); - - static const QStringList supported_file_extensions; - -signals: - void BootGame(const QString& game_path, StartGameType type); - void GameChosen(const QString& game_path, const u64 title_id = 0); - void OpenFolderRequested(u64 program_id, GameListOpenTarget target, - const std::string& game_path); - void OpenTransferableShaderCacheRequested(u64 program_id); - void RemoveInstalledEntryRequested(u64 program_id, InstalledEntryType type); - void RemoveFileRequested(u64 program_id, GameListRemoveTarget target, - const std::string& game_path); - void RemovePlayTimeRequested(u64 program_id); - void DumpRomFSRequested(u64 program_id, const std::string& game_path, DumpRomFSTarget target); - void VerifyIntegrityRequested(const std::string& game_path); - void CopyTIDRequested(u64 program_id); - void CreateShortcut(u64 program_id, const std::string& game_path, - GameListShortcutTarget target); - void NavigateToGamedbEntryRequested(u64 program_id, - const CompatibilityList& compatibility_list); - void OpenPerGameGeneralRequested(const std::string& file); - void OpenDirectory(const QString& directory); - void AddDirectory(); - void ShowList(bool show); - void PopulatingCompleted(); - void SaveConfig(); - -private slots: - void OnItemExpanded(const QModelIndex& item); - void OnTextChanged(const QString& new_text); - void OnFilterCloseClicked(); - void OnUpdateThemedIcons(); - -private: - friend class GameListWorker; - void WorkerEvent(); - - void AddDirEntry(GameListDir* entry_items); - void AddEntry(const QList<QStandardItem*>& entry_items, GameListDir* parent); - void DonePopulating(const QStringList& watch_list); - -private: - void ValidateEntry(const QModelIndex& item); - - void RefreshGameDirectory(); - - void ToggleFavorite(u64 program_id); - void AddFavorite(u64 program_id); - void RemoveFavorite(u64 program_id); - - void PopupContextMenu(const QPoint& menu_location); - void AddGamePopup(QMenu& context_menu, u64 program_id, const std::string& path); - void AddCustomDirPopup(QMenu& context_menu, QModelIndex selected); - 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; - GMainWindow* main_window = nullptr; - QVBoxLayout* layout = nullptr; - QTreeView* tree_view = nullptr; - QStandardItemModel* item_model = nullptr; - std::unique_ptr<GameListWorker> current_worker; - QFileSystemWatcher* watcher = nullptr; - ControllerNavigation* controller_navigation = nullptr; - CompatibilityList compatibility_list; - - friend class GameListSearchField; - - const PlayTime::PlayTimeManager& play_time_manager; - Core::System& system; -}; - -class GameListPlaceholder : public QWidget { - Q_OBJECT -public: - explicit GameListPlaceholder(GMainWindow* parent = nullptr); - ~GameListPlaceholder(); - -signals: - void AddDirectory(); - -private slots: - void onUpdateThemedIcons(); - -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 deleted file mode 100644 index c330b574f..000000000 --- a/src/yuzu/game_list_p.h +++ /dev/null @@ -1,408 +0,0 @@ -// SPDX-FileCopyrightText: 2015 Citra Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include <array> -#include <map> -#include <string> -#include <utility> - -#include <QCoreApplication> -#include <QFileInfo> -#include <QObject> -#include <QStandardItem> -#include <QString> -#include <QWidget> - -#include "common/common_types.h" -#include "common/logging/log.h" -#include "common/string_util.h" -#include "yuzu/play_time_manager.h" -#include "yuzu/uisettings.h" -#include "yuzu/util/util.h" - -enum class GameListItemType { - Game = QStandardItem::UserType + 1, - CustomDir = QStandardItem::UserType + 2, - SdmcDir = QStandardItem::UserType + 3, - UserNandDir = QStandardItem::UserType + 4, - SysNandDir = QStandardItem::UserType + 5, - AddDir = QStandardItem::UserType + 6, - Favorites = QStandardItem::UserType + 7, -}; - -Q_DECLARE_METATYPE(GameListItemType); - -/** - * Gets the default icon (for games without valid title metadata) - * @param size The desired width and height of the default icon. - * @return QPixmap default icon - */ -static QPixmap GetDefaultIcon(u32 size) { - QPixmap icon(size, size); - icon.fill(Qt::transparent); - return icon; -} - -class GameListItem : public QStandardItem { - -public: - // used to access type from item index - static constexpr int TypeRole = Qt::UserRole + 1; - static constexpr int SortRole = Qt::UserRole + 2; - GameListItem() = default; - explicit GameListItem(const QString& string) : QStandardItem(string) { - setData(string, SortRole); - } -}; - -/** - * A specialization of GameListItem for path values. - * This class ensures that for every full path value it holds, a correct string representation - * of just the filename (with no extension) will be displayed to the user. - * If this class receives valid title metadata, it will also display game icons and titles. - */ -class GameListItemPath : public GameListItem { -public: - static constexpr int TitleRole = SortRole + 1; - static constexpr int FullPathRole = SortRole + 2; - static constexpr int ProgramIdRole = SortRole + 3; - static constexpr int FileTypeRole = SortRole + 4; - - GameListItemPath() = default; - GameListItemPath(const QString& game_path, const std::vector<u8>& picture_data, - const QString& game_name, const QString& game_type, u64 program_id) { - setData(type(), TypeRole); - setData(game_path, FullPathRole); - setData(game_name, TitleRole); - setData(qulonglong(program_id), ProgramIdRole); - setData(game_type, FileTypeRole); - - const u32 size = UISettings::values.game_icon_size.GetValue(); - - QPixmap picture; - if (!picture.loadFromData(picture_data.data(), static_cast<u32>(picture_data.size()))) { - picture = GetDefaultIcon(size); - } - picture = picture.scaled(size, size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); - - setData(picture, Qt::DecorationRole); - } - - int type() const override { - return static_cast<int>(GameListItemType::Game); - } - - QVariant data(int role) const override { - if (role == Qt::DisplayRole || role == SortRole) { - std::string filename; - Common::SplitPath(data(FullPathRole).toString().toStdString(), nullptr, &filename, - nullptr); - - const std::array<QString, 4> row_data{{ - QString::fromStdString(filename), - data(FileTypeRole).toString(), - QString::fromStdString(fmt::format("0x{:016X}", data(ProgramIdRole).toULongLong())), - data(TitleRole).toString(), - }}; - - const auto& row1 = row_data.at(UISettings::values.row_1_text_id.GetValue()); - const int row2_id = UISettings::values.row_2_text_id.GetValue(); - - if (role == SortRole) { - return row1.toLower(); - } - - // None - if (row2_id == 4) { - return row1; - } - - const auto& row2 = row_data.at(row2_id); - - if (row1 == row2) { - return row1; - } - - return QStringLiteral("%1\n %2").arg(row1, row2); - } - - return GameListItem::data(role); - } -}; - -class GameListItemCompat : public GameListItem { - Q_DECLARE_TR_FUNCTIONS(GameListItemCompat) -public: - static constexpr int CompatNumberRole = SortRole; - GameListItemCompat() = default; - explicit GameListItemCompat(const QString& compatibility) { - setData(type(), TypeRole); - - struct CompatStatus { - QString color; - const char* text; - const char* tooltip; - }; - // clang-format off - const auto ingame_status = - CompatStatus{QStringLiteral("#f2d624"), QT_TR_NOOP("Ingame"), QT_TR_NOOP("Game starts, but crashes or major glitches prevent it from being completed.")}; - static const std::map<QString, CompatStatus> status_data = { - {QStringLiteral("0"), {QStringLiteral("#5c93ed"), QT_TR_NOOP("Perfect"), QT_TR_NOOP("Game can be played without issues.")}}, - {QStringLiteral("1"), {QStringLiteral("#47d35c"), QT_TR_NOOP("Playable"), QT_TR_NOOP("Game functions with minor graphical or audio glitches and is playable from start to finish.")}}, - {QStringLiteral("2"), ingame_status}, - {QStringLiteral("3"), ingame_status}, // Fallback for the removed "Okay" category - {QStringLiteral("4"), {QStringLiteral("#FF0000"), QT_TR_NOOP("Intro/Menu"), QT_TR_NOOP("Game loads, but is unable to progress past the Start Screen.")}}, - {QStringLiteral("5"), {QStringLiteral("#828282"), QT_TR_NOOP("Won't Boot"), QT_TR_NOOP("The game crashes when attempting to startup.")}}, - {QStringLiteral("99"), {QStringLiteral("#000000"), QT_TR_NOOP("Not Tested"), QT_TR_NOOP("The game has not yet been tested.")}}, - }; - // clang-format on - - auto iterator = status_data.find(compatibility); - if (iterator == status_data.end()) { - LOG_WARNING(Frontend, "Invalid compatibility number {}", compatibility.toStdString()); - return; - } - const CompatStatus& status = iterator->second; - setData(compatibility, CompatNumberRole); - setText(tr(status.text)); - setToolTip(tr(status.tooltip)); - setData(CreateCirclePixmapFromColor(status.color), Qt::DecorationRole); - } - - int type() const override { - return static_cast<int>(GameListItemType::Game); - } - - bool operator<(const QStandardItem& other) const override { - return data(CompatNumberRole).value<QString>() < - other.data(CompatNumberRole).value<QString>(); - } -}; - -/** - * A specialization of GameListItem for size values. - * This class ensures that for every numerical size value it holds (in bytes), a correct - * human-readable string representation will be displayed to the user. - */ -class GameListItemSize : public GameListItem { -public: - static constexpr int SizeRole = SortRole; - - GameListItemSize() = default; - explicit GameListItemSize(const qulonglong size_bytes) { - setData(type(), TypeRole); - setData(size_bytes, SizeRole); - } - - void setData(const QVariant& value, int role) override { - // By specializing setData for SizeRole, we can ensure that the numerical and string - // representations of the data are always accurate and in the correct format. - if (role == SizeRole) { - qulonglong size_bytes = value.toULongLong(); - GameListItem::setData(ReadableByteSize(size_bytes), Qt::DisplayRole); - GameListItem::setData(value, SizeRole); - } else { - GameListItem::setData(value, role); - } - } - - int type() const override { - return static_cast<int>(GameListItemType::Game); - } - - /** - * This operator is, in practice, only used by the TreeView sorting systems. - * Override it so that it will correctly sort by numerical value instead of by string - * representation. - */ - bool operator<(const QStandardItem& other) const override { - return data(SizeRole).toULongLong() < other.data(SizeRole).toULongLong(); - } -}; - -/** - * GameListItem for Play Time values. - * This object stores the play time of a game in seconds, and its readable - * representation in minutes/hours - */ -class GameListItemPlayTime : public GameListItem { -public: - static constexpr int PlayTimeRole = SortRole; - - GameListItemPlayTime() = default; - explicit GameListItemPlayTime(const qulonglong time_seconds) { - setData(time_seconds, PlayTimeRole); - } - - void setData(const QVariant& value, int role) override { - qulonglong time_seconds = value.toULongLong(); - GameListItem::setData(PlayTime::ReadablePlayTime(time_seconds), Qt::DisplayRole); - GameListItem::setData(value, PlayTimeRole); - } - - bool operator<(const QStandardItem& other) const override { - return data(PlayTimeRole).toULongLong() < other.data(PlayTimeRole).toULongLong(); - } -}; - -class GameListDir : public GameListItem { -public: - static constexpr int GameDirRole = Qt::UserRole + 2; - - explicit GameListDir(UISettings::GameDir& directory, - GameListItemType dir_type_ = GameListItemType::CustomDir) - : dir_type{dir_type_} { - setData(type(), TypeRole); - - UISettings::GameDir* game_dir = &directory; - setData(QVariant(UISettings::values.game_dirs.indexOf(directory)), GameDirRole); - - const int icon_size = UISettings::values.folder_icon_size.GetValue(); - switch (dir_type) { - case GameListItemType::SdmcDir: - setData( - QIcon::fromTheme(QStringLiteral("sd_card")) - .pixmap(icon_size) - .scaled(icon_size, icon_size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation), - Qt::DecorationRole); - setData(QObject::tr("Installed SD Titles"), Qt::DisplayRole); - break; - case GameListItemType::UserNandDir: - setData( - QIcon::fromTheme(QStringLiteral("chip")) - .pixmap(icon_size) - .scaled(icon_size, icon_size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation), - Qt::DecorationRole); - setData(QObject::tr("Installed NAND Titles"), Qt::DisplayRole); - break; - case GameListItemType::SysNandDir: - setData( - QIcon::fromTheme(QStringLiteral("chip")) - .pixmap(icon_size) - .scaled(icon_size, icon_size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation), - Qt::DecorationRole); - setData(QObject::tr("System Titles"), Qt::DisplayRole); - break; - case GameListItemType::CustomDir: { - const QString path = QString::fromStdString(game_dir->path); - const QString icon_name = - QFileInfo::exists(path) ? QStringLiteral("folder") : QStringLiteral("bad_folder"); - setData(QIcon::fromTheme(icon_name).pixmap(icon_size).scaled( - icon_size, icon_size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation), - Qt::DecorationRole); - setData(path, Qt::DisplayRole); - break; - } - default: - break; - } - } - - int type() const override { - return static_cast<int>(dir_type); - } - - /** - * Override to prevent automatic sorting between folders and the addDir button. - */ - bool operator<(const QStandardItem& other) const override { - return false; - } - -private: - GameListItemType dir_type; -}; - -class GameListAddDir : public GameListItem { -public: - explicit GameListAddDir() { - setData(type(), TypeRole); - - const int icon_size = UISettings::values.folder_icon_size.GetValue(); - - setData(QIcon::fromTheme(QStringLiteral("list-add")) - .pixmap(icon_size) - .scaled(icon_size, icon_size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation), - Qt::DecorationRole); - setData(QObject::tr("Add New Game Directory"), Qt::DisplayRole); - } - - int type() const override { - return static_cast<int>(GameListItemType::AddDir); - } - - bool operator<(const QStandardItem& other) const override { - return false; - } -}; - -class GameListFavorites : public GameListItem { -public: - explicit GameListFavorites() { - setData(type(), TypeRole); - - const int icon_size = UISettings::values.folder_icon_size.GetValue(); - - setData(QIcon::fromTheme(QStringLiteral("star")) - .pixmap(icon_size) - .scaled(icon_size, icon_size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation), - Qt::DecorationRole); - setData(QObject::tr("Favorites"), Qt::DisplayRole); - } - - int type() const override { - return static_cast<int>(GameListItemType::Favorites); - } - - bool operator<(const QStandardItem& other) const override { - return false; - } -}; - -class GameList; -class QHBoxLayout; -class QTreeView; -class QLabel; -class QLineEdit; -class QToolButton; - -class GameListSearchField : public QWidget { - Q_OBJECT - -public: - explicit GameListSearchField(GameList* parent = nullptr); - - QString filterText() const; - 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); - - private: - GameList* gamelist = nullptr; - QString edit_filter_text_old; - - protected: - // EventFilter in order to process systemkeys while editing the searchfield - bool eventFilter(QObject* obj, QEvent* event) override; - }; - int visible; - int total; - - QHBoxLayout* layout_filter = nullptr; - QTreeView* tree_view = nullptr; - QLabel* label_filter = nullptr; - QLineEdit* edit_filter = nullptr; - QLabel* label_filter_result = nullptr; - QToolButton* button_filter_close = nullptr; -}; diff --git a/src/yuzu/game_list_worker.cpp b/src/yuzu/game_list_worker.cpp deleted file mode 100644 index 0cbf5f45e..000000000 --- a/src/yuzu/game_list_worker.cpp +++ /dev/null @@ -1,485 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include <memory> -#include <string> -#include <utility> -#include <vector> - -#include <QDir> -#include <QFile> -#include <QFileInfo> -#include <QSettings> - -#include "common/fs/fs.h" -#include "common/fs/path_util.h" -#include "core/core.h" -#include "core/file_sys/card_image.h" -#include "core/file_sys/content_archive.h" -#include "core/file_sys/control_metadata.h" -#include "core/file_sys/fs_filesystem.h" -#include "core/file_sys/nca_metadata.h" -#include "core/file_sys/patch_manager.h" -#include "core/file_sys/registered_cache.h" -#include "core/file_sys/submission_package.h" -#include "core/loader/loader.h" -#include "yuzu/compatibility_list.h" -#include "yuzu/game_list.h" -#include "yuzu/game_list_p.h" -#include "yuzu/game_list_worker.h" -#include "yuzu/uisettings.h" - -namespace { - -QString GetGameListCachedObject(const std::string& filename, const std::string& ext, - const std::function<QString()>& generator) { - if (!UISettings::values.cache_game_list || filename == "0000000000000000") { - return generator(); - } - - const auto path = - Common::FS::PathToUTF8String(Common::FS::GetYuzuPath(Common::FS::YuzuPath::CacheDir) / - "game_list" / fmt::format("{}.{}", filename, ext)); - - void(Common::FS::CreateParentDirs(path)); - - if (!Common::FS::Exists(path)) { - const auto str = generator(); - - QFile file{QString::fromStdString(path)}; - if (file.open(QFile::WriteOnly)) { - file.write(str.toUtf8()); - } - - return str; - } - - QFile file{QString::fromStdString(path)}; - if (file.open(QFile::ReadOnly)) { - return QString::fromUtf8(file.readAll()); - } - - return generator(); -} - -std::pair<std::vector<u8>, std::string> GetGameListCachedObject( - const std::string& filename, const std::string& ext, - const std::function<std::pair<std::vector<u8>, std::string>()>& generator) { - if (!UISettings::values.cache_game_list || filename == "0000000000000000") { - return generator(); - } - - const auto game_list_dir = - Common::FS::GetYuzuPath(Common::FS::YuzuPath::CacheDir) / "game_list"; - const auto jpeg_name = fmt::format("{}.jpeg", filename); - const auto app_name = fmt::format("{}.appname.txt", filename); - - const auto path1 = Common::FS::PathToUTF8String(game_list_dir / jpeg_name); - const auto path2 = Common::FS::PathToUTF8String(game_list_dir / app_name); - - void(Common::FS::CreateParentDirs(path1)); - - if (!Common::FS::Exists(path1) || !Common::FS::Exists(path2)) { - const auto [icon, nacp] = generator(); - - QFile file1{QString::fromStdString(path1)}; - if (!file1.open(QFile::WriteOnly)) { - LOG_ERROR(Frontend, "Failed to open cache file."); - return generator(); - } - - if (!file1.resize(icon.size())) { - LOG_ERROR(Frontend, "Failed to resize cache file to necessary size."); - return generator(); - } - - if (file1.write(reinterpret_cast<const char*>(icon.data()), icon.size()) != - s64(icon.size())) { - LOG_ERROR(Frontend, "Failed to write data to cache file."); - return generator(); - } - - QFile file2{QString::fromStdString(path2)}; - if (file2.open(QFile::WriteOnly)) { - file2.write(nacp.data(), nacp.size()); - } - - return std::make_pair(icon, nacp); - } - - QFile file1(QString::fromStdString(path1)); - QFile file2(QString::fromStdString(path2)); - - if (!file1.open(QFile::ReadOnly)) { - LOG_ERROR(Frontend, "Failed to open cache file for reading."); - return generator(); - } - - if (!file2.open(QFile::ReadOnly)) { - LOG_ERROR(Frontend, "Failed to open cache file for reading."); - return generator(); - } - - std::vector<u8> vec(file1.size()); - if (file1.read(reinterpret_cast<char*>(vec.data()), vec.size()) != - static_cast<s64>(vec.size())) { - return generator(); - } - - const auto data = file2.readAll(); - return std::make_pair(vec, data.toStdString()); -} - -void GetMetadataFromControlNCA(const FileSys::PatchManager& patch_manager, const FileSys::NCA& nca, - std::vector<u8>& icon, std::string& name) { - std::tie(icon, name) = GetGameListCachedObject( - fmt::format("{:016X}", patch_manager.GetTitleID()), {}, [&patch_manager, &nca] { - const auto [nacp, icon_f] = patch_manager.ParseControlNCA(nca); - return std::make_pair(icon_f->ReadAllBytes(), nacp->GetApplicationName()); - }); -} - -bool HasSupportedFileExtension(const std::string& file_name) { - const QFileInfo file = QFileInfo(QString::fromStdString(file_name)); - return GameList::supported_file_extensions.contains(file.suffix(), Qt::CaseInsensitive); -} - -bool IsExtractedNCAMain(const std::string& file_name) { - return QFileInfo(QString::fromStdString(file_name)).fileName() == QStringLiteral("main"); -} - -QString FormatGameName(const std::string& physical_name) { - const QString physical_name_as_qstring = QString::fromStdString(physical_name); - const QFileInfo file_info(physical_name_as_qstring); - - if (IsExtractedNCAMain(physical_name)) { - return file_info.dir().path(); - } - - return physical_name_as_qstring; -} - -QString FormatPatchNameVersions(const FileSys::PatchManager& patch_manager, - Loader::AppLoader& loader, bool updatable = true) { - QString out; - FileSys::VirtualFile update_raw; - loader.ReadUpdateRaw(update_raw); - for (const auto& patch : patch_manager.GetPatches(update_raw)) { - const bool is_update = patch.name == "Update"; - if (!updatable && is_update) { - continue; - } - - const QString type = - QString::fromStdString(patch.enabled ? patch.name : "[D] " + patch.name); - - if (patch.version.empty()) { - out.append(QStringLiteral("%1\n").arg(type)); - } else { - auto ver = patch.version; - - // Display container name for packed updates - if (is_update && ver == "PACKED") { - ver = Loader::GetFileTypeString(loader.GetFileType()); - } - - out.append(QStringLiteral("%1 (%2)\n").arg(type, QString::fromStdString(ver))); - } - } - - out.chop(1); - return out; -} - -QList<QStandardItem*> MakeGameListEntry(const std::string& path, const std::string& name, - const std::size_t size, const std::vector<u8>& icon, - Loader::AppLoader& loader, u64 program_id, - const CompatibilityList& compatibility_list, - const PlayTime::PlayTimeManager& play_time_manager, - const FileSys::PatchManager& patch) { - const auto it = FindMatchingCompatibilityEntry(compatibility_list, program_id); - - // The game list uses this as compatibility number for untested games - QString compatibility{QStringLiteral("99")}; - if (it != compatibility_list.end()) { - compatibility = it->second.first; - } - - const auto file_type = loader.GetFileType(); - const auto file_type_string = QString::fromStdString(Loader::GetFileTypeString(file_type)); - - QList<QStandardItem*> list{ - new GameListItemPath(FormatGameName(path), icon, QString::fromStdString(name), - file_type_string, program_id), - new GameListItemCompat(compatibility), - new GameListItem(file_type_string), - new GameListItemSize(size), - new GameListItemPlayTime(play_time_manager.GetPlayTime(program_id)), - }; - - const auto patch_versions = GetGameListCachedObject( - fmt::format("{:016X}", patch.GetTitleID()), "pv.txt", [&patch, &loader] { - return FormatPatchNameVersions(patch, loader, loader.IsRomFSUpdatable()); - }); - list.insert(2, new GameListItem(patch_versions)); - - return list; -} -} // Anonymous namespace - -GameListWorker::GameListWorker(FileSys::VirtualFilesystem vfs_, - FileSys::ManualContentProvider* provider_, - QVector<UISettings::GameDir>& game_dirs_, - const CompatibilityList& compatibility_list_, - const PlayTime::PlayTimeManager& play_time_manager_, - Core::System& system_) - : vfs{std::move(vfs_)}, provider{provider_}, game_dirs{game_dirs_}, - compatibility_list{compatibility_list_}, play_time_manager{play_time_manager_}, system{ - system_} { - // We want the game list to manage our lifetime. - setAutoDelete(false); -} - -GameListWorker::~GameListWorker() { - this->disconnect(); - stop_requested.store(true); - processing_completed.Wait(); -} - -void GameListWorker::ProcessEvents(GameList* game_list) { - while (true) { - std::function<void(GameList*)> func; - { - // Lock queue to protect concurrent modification. - std::scoped_lock lk(lock); - - // If we can't pop a function, return. - if (queued_events.empty()) { - return; - } - - // Pop a function. - func = std::move(queued_events.back()); - queued_events.pop_back(); - } - - // Run the function. - func(game_list); - } -} - -template <typename F> -void GameListWorker::RecordEvent(F&& func) { - { - // Lock queue to protect concurrent modification. - std::scoped_lock lk(lock); - - // Add the function into the front of the queue. - queued_events.emplace_front(std::move(func)); - } - - // Data now available. - emit DataAvailable(); -} - -void GameListWorker::AddTitlesToGameList(GameListDir* parent_dir) { - using namespace FileSys; - - const auto& cache = system.GetContentProviderUnion(); - - auto installed_games = cache.ListEntriesFilterOrigin(std::nullopt, TitleType::Application, - ContentRecordType::Program); - - if (parent_dir->type() == static_cast<int>(GameListItemType::SdmcDir)) { - installed_games = cache.ListEntriesFilterOrigin( - ContentProviderUnionSlot::SDMC, TitleType::Application, ContentRecordType::Program); - } else if (parent_dir->type() == static_cast<int>(GameListItemType::UserNandDir)) { - installed_games = cache.ListEntriesFilterOrigin( - ContentProviderUnionSlot::UserNAND, TitleType::Application, ContentRecordType::Program); - } else if (parent_dir->type() == static_cast<int>(GameListItemType::SysNandDir)) { - installed_games = cache.ListEntriesFilterOrigin( - ContentProviderUnionSlot::SysNAND, TitleType::Application, ContentRecordType::Program); - } - - for (const auto& [slot, game] : installed_games) { - if (slot == ContentProviderUnionSlot::FrontendManual) { - continue; - } - - const auto file = cache.GetEntryUnparsed(game.title_id, game.type); - std::unique_ptr<Loader::AppLoader> loader = Loader::GetLoader(system, file); - if (!loader) { - continue; - } - - std::vector<u8> icon; - std::string name; - u64 program_id = 0; - const auto result = loader->ReadProgramId(program_id); - - if (result != Loader::ResultStatus::Success) { - continue; - } - - const PatchManager patch{program_id, system.GetFileSystemController(), - system.GetContentProvider()}; - const auto control = cache.GetEntry(game.title_id, ContentRecordType::Control); - if (control != nullptr) { - GetMetadataFromControlNCA(patch, *control, icon, name); - } - - auto entry = MakeGameListEntry(file->GetFullPath(), name, file->GetSize(), icon, *loader, - program_id, compatibility_list, play_time_manager, patch); - RecordEvent([=](GameList* game_list) { game_list->AddEntry(entry, parent_dir); }); - } -} - -void GameListWorker::ScanFileSystem(ScanTarget target, const std::string& dir_path, bool deep_scan, - GameListDir* parent_dir) { - const auto callback = [this, target, parent_dir](const std::filesystem::path& path) -> bool { - if (stop_requested) { - // Breaks the callback loop. - return false; - } - - const auto physical_name = Common::FS::PathToUTF8String(path); - const auto is_dir = Common::FS::IsDir(path); - - if (!is_dir && - (HasSupportedFileExtension(physical_name) || IsExtractedNCAMain(physical_name))) { - const auto file = vfs->OpenFile(physical_name, FileSys::OpenMode::Read); - if (!file) { - return true; - } - - auto loader = Loader::GetLoader(system, file); - if (!loader) { - return true; - } - - const auto file_type = loader->GetFileType(); - if (file_type == Loader::FileType::Unknown || file_type == Loader::FileType::Error) { - return true; - } - - u64 program_id = 0; - const auto res2 = loader->ReadProgramId(program_id); - - if (target == ScanTarget::FillManualContentProvider) { - if (res2 == Loader::ResultStatus::Success && file_type == Loader::FileType::NCA) { - provider->AddEntry(FileSys::TitleType::Application, - FileSys::GetCRTypeFromNCAType(FileSys::NCA{file}.GetType()), - program_id, file); - } else if (res2 == Loader::ResultStatus::Success && - (file_type == Loader::FileType::XCI || - file_type == Loader::FileType::NSP)) { - const auto nsp = file_type == Loader::FileType::NSP - ? std::make_shared<FileSys::NSP>(file) - : FileSys::XCI{file}.GetSecurePartitionNSP(); - for (const auto& title : nsp->GetNCAs()) { - for (const auto& entry : title.second) { - provider->AddEntry(entry.first.first, entry.first.second, title.first, - entry.second->GetBaseFile()); - } - } - } - } else { - std::vector<u64> program_ids; - loader->ReadProgramIds(program_ids); - - if (res2 == Loader::ResultStatus::Success && program_ids.size() > 1 && - (file_type == Loader::FileType::XCI || file_type == Loader::FileType::NSP)) { - for (const auto id : program_ids) { - loader = Loader::GetLoader(system, file, id); - if (!loader) { - continue; - } - - std::vector<u8> icon; - [[maybe_unused]] const auto res1 = loader->ReadIcon(icon); - - std::string name = " "; - [[maybe_unused]] const auto res3 = loader->ReadTitle(name); - - const FileSys::PatchManager patch{id, system.GetFileSystemController(), - system.GetContentProvider()}; - - auto entry = MakeGameListEntry( - physical_name, name, Common::FS::GetSize(physical_name), icon, *loader, - id, compatibility_list, play_time_manager, patch); - - RecordEvent( - [=](GameList* game_list) { game_list->AddEntry(entry, parent_dir); }); - } - } else { - std::vector<u8> icon; - [[maybe_unused]] const auto res1 = loader->ReadIcon(icon); - - std::string name = " "; - [[maybe_unused]] const auto res3 = loader->ReadTitle(name); - - const FileSys::PatchManager patch{program_id, system.GetFileSystemController(), - system.GetContentProvider()}; - - auto entry = MakeGameListEntry( - physical_name, name, Common::FS::GetSize(physical_name), icon, *loader, - program_id, compatibility_list, play_time_manager, patch); - - RecordEvent( - [=](GameList* game_list) { game_list->AddEntry(entry, parent_dir); }); - } - } - } else if (is_dir) { - watch_list.append(QString::fromStdString(physical_name)); - } - - return true; - }; - - if (deep_scan) { - Common::FS::IterateDirEntriesRecursively(dir_path, callback, - Common::FS::DirEntryFilter::All); - } else { - Common::FS::IterateDirEntries(dir_path, callback, Common::FS::DirEntryFilter::File); - } -} - -void GameListWorker::run() { - watch_list.clear(); - provider->ClearAllEntries(); - - const auto DirEntryReady = [&](GameListDir* game_list_dir) { - RecordEvent([=](GameList* game_list) { game_list->AddDirEntry(game_list_dir); }); - }; - - for (UISettings::GameDir& game_dir : game_dirs) { - if (stop_requested) { - break; - } - - if (game_dir.path == std::string("SDMC")) { - auto* const game_list_dir = new GameListDir(game_dir, GameListItemType::SdmcDir); - DirEntryReady(game_list_dir); - AddTitlesToGameList(game_list_dir); - } else if (game_dir.path == std::string("UserNAND")) { - auto* const game_list_dir = new GameListDir(game_dir, GameListItemType::UserNandDir); - DirEntryReady(game_list_dir); - AddTitlesToGameList(game_list_dir); - } else if (game_dir.path == std::string("SysNAND")) { - auto* const game_list_dir = new GameListDir(game_dir, GameListItemType::SysNandDir); - DirEntryReady(game_list_dir); - AddTitlesToGameList(game_list_dir); - } else { - watch_list.append(QString::fromStdString(game_dir.path)); - auto* const game_list_dir = new GameListDir(game_dir); - DirEntryReady(game_list_dir); - ScanFileSystem(ScanTarget::FillManualContentProvider, game_dir.path, game_dir.deep_scan, - game_list_dir); - ScanFileSystem(ScanTarget::PopulateGameList, game_dir.path, game_dir.deep_scan, - game_list_dir); - } - } - - RecordEvent([this](GameList* game_list) { game_list->DonePopulating(watch_list); }); - processing_completed.Set(); -} diff --git a/src/yuzu/game_list_worker.h b/src/yuzu/game_list_worker.h deleted file mode 100644 index d5990fcde..000000000 --- a/src/yuzu/game_list_worker.h +++ /dev/null @@ -1,94 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include <atomic> -#include <deque> -#include <memory> -#include <string> - -#include <QList> -#include <QObject> -#include <QRunnable> -#include <QString> - -#include "common/thread.h" -#include "yuzu/compatibility_list.h" -#include "yuzu/play_time_manager.h" - -namespace Core { -class System; -} - -class GameList; -class QStandardItem; - -namespace FileSys { -class NCA; -class VfsFilesystem; -} // namespace FileSys - -/** - * Asynchronous worker object for populating the game list. - * Communicates with other threads through Qt's signal/slot system. - */ -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_, - const PlayTime::PlayTimeManager& play_time_manager_, - Core::System& system_); - ~GameListWorker() override; - - /// Starts the processing of directory tree information. - void run() override; - -public: - /** - * Synchronously processes any events queued by the worker. - * - * AddDirEntry is called on the game list for every discovered directory. - * AddEntry is called on the game list for every discovered program. - * DonePopulating is called on the game list when processing completes. - */ - void ProcessEvents(GameList* game_list); - -signals: - void DataAvailable(); - -private: - template <typename F> - void RecordEvent(F&& func); - -private: - void AddTitlesToGameList(GameListDir* parent_dir); - - enum class ScanTarget { - FillManualContentProvider, - PopulateGameList, - }; - - void ScanFileSystem(ScanTarget target, const std::string& dir_path, bool deep_scan, - GameListDir* parent_dir); - - std::shared_ptr<FileSys::VfsFilesystem> vfs; - FileSys::ManualContentProvider* provider; - QVector<UISettings::GameDir>& game_dirs; - const CompatibilityList& compatibility_list; - const PlayTime::PlayTimeManager& play_time_manager; - - QStringList watch_list; - - std::mutex lock; - std::condition_variable cv; - std::deque<std::function<void(GameList*)>> queued_events; - std::atomic_bool stop_requested = false; - Common::Event processing_completed; - - Core::System& system; -}; diff --git a/src/yuzu/hotkeys.cpp b/src/yuzu/hotkeys.cpp deleted file mode 100644 index 1931dcd1f..000000000 --- a/src/yuzu/hotkeys.cpp +++ /dev/null @@ -1,214 +0,0 @@ -// SPDX-FileCopyrightText: 2014 Citra Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include <sstream> -#include <QShortcut> -#include <QTreeWidgetItem> -#include <QtGlobal> - -#include "hid_core/frontend/emulated_controller.h" -#include "yuzu/hotkeys.h" -#include "yuzu/uisettings.h" - -HotkeyRegistry::HotkeyRegistry() = default; -HotkeyRegistry::~HotkeyRegistry() = default; - -void HotkeyRegistry::SaveHotkeys() { - UISettings::values.shortcuts.clear(); - for (const auto& group : hotkey_groups) { - for (const auto& hotkey : group.second) { - UISettings::values.shortcuts.push_back( - {hotkey.first, group.first, - UISettings::ContextualShortcut({hotkey.second.keyseq.toString().toStdString(), - hotkey.second.controller_keyseq, - hotkey.second.context, hotkey.second.repeat})}); - } - } -} - -void HotkeyRegistry::LoadHotkeys() { - // Make sure NOT to use a reference here because it would become invalid once we call - // beginGroup() - for (auto shortcut : UISettings::values.shortcuts) { - Hotkey& hk = hotkey_groups[shortcut.group][shortcut.name]; - if (!shortcut.shortcut.keyseq.empty()) { - hk.keyseq = QKeySequence::fromString(QString::fromStdString(shortcut.shortcut.keyseq), - QKeySequence::NativeText); - hk.context = static_cast<Qt::ShortcutContext>(shortcut.shortcut.context); - } - if (!shortcut.shortcut.controller_keyseq.empty()) { - hk.controller_keyseq = shortcut.shortcut.controller_keyseq; - } - if (hk.shortcut) { - hk.shortcut->disconnect(); - hk.shortcut->setKey(hk.keyseq); - } - if (hk.controller_shortcut) { - hk.controller_shortcut->disconnect(); - hk.controller_shortcut->SetKey(hk.controller_keyseq); - } - hk.repeat = shortcut.shortcut.repeat; - } -} - -QShortcut* HotkeyRegistry::GetHotkey(const std::string& group, const std::string& action, - QWidget* widget) { - Hotkey& hk = hotkey_groups[group][action]; - - if (!hk.shortcut) { - hk.shortcut = new QShortcut(hk.keyseq, widget, nullptr, nullptr, hk.context); - } - - hk.shortcut->setAutoRepeat(hk.repeat); - return hk.shortcut; -} - -ControllerShortcut* HotkeyRegistry::GetControllerHotkey(const std::string& group, - const std::string& action, - Core::HID::EmulatedController* controller) { - Hotkey& hk = hotkey_groups[group][action]; - - if (!hk.controller_shortcut) { - hk.controller_shortcut = new ControllerShortcut(controller); - hk.controller_shortcut->SetKey(hk.controller_keyseq); - } - - return hk.controller_shortcut; -} - -QKeySequence HotkeyRegistry::GetKeySequence(const std::string& group, const std::string& action) { - return hotkey_groups[group][action].keyseq; -} - -Qt::ShortcutContext HotkeyRegistry::GetShortcutContext(const std::string& group, - const std::string& action) { - return hotkey_groups[group][action].context; -} - -ControllerShortcut::ControllerShortcut(Core::HID::EmulatedController* controller) { - emulated_controller = controller; - Core::HID::ControllerUpdateCallback engine_callback{ - .on_change = [this](Core::HID::ControllerTriggerType type) { ControllerUpdateEvent(type); }, - .is_npad_service = false, - }; - callback_key = emulated_controller->SetCallback(engine_callback); - is_enabled = true; -} - -ControllerShortcut::~ControllerShortcut() { - emulated_controller->DeleteCallback(callback_key); -} - -void ControllerShortcut::SetKey(const ControllerButtonSequence& buttons) { - button_sequence = buttons; -} - -void ControllerShortcut::SetKey(const std::string& buttons_shortcut) { - ControllerButtonSequence sequence{}; - name = buttons_shortcut; - std::istringstream command_line(buttons_shortcut); - std::string line; - while (std::getline(command_line, line, '+')) { - if (line.empty()) { - continue; - } - if (line == "A") { - sequence.npad.a.Assign(1); - } - if (line == "B") { - sequence.npad.b.Assign(1); - } - if (line == "X") { - sequence.npad.x.Assign(1); - } - if (line == "Y") { - sequence.npad.y.Assign(1); - } - if (line == "L") { - sequence.npad.l.Assign(1); - } - if (line == "R") { - sequence.npad.r.Assign(1); - } - if (line == "ZL") { - sequence.npad.zl.Assign(1); - } - if (line == "ZR") { - sequence.npad.zr.Assign(1); - } - if (line == "Dpad_Left") { - sequence.npad.left.Assign(1); - } - if (line == "Dpad_Right") { - sequence.npad.right.Assign(1); - } - if (line == "Dpad_Up") { - sequence.npad.up.Assign(1); - } - if (line == "Dpad_Down") { - sequence.npad.down.Assign(1); - } - if (line == "Left_Stick") { - sequence.npad.stick_l.Assign(1); - } - if (line == "Right_Stick") { - sequence.npad.stick_r.Assign(1); - } - if (line == "Minus") { - sequence.npad.minus.Assign(1); - } - if (line == "Plus") { - sequence.npad.plus.Assign(1); - } - if (line == "Home") { - sequence.home.home.Assign(1); - } - if (line == "Screenshot") { - sequence.capture.capture.Assign(1); - } - } - - button_sequence = sequence; -} - -ControllerButtonSequence ControllerShortcut::ButtonSequence() const { - return button_sequence; -} - -void ControllerShortcut::SetEnabled(bool enable) { - is_enabled = enable; -} - -bool ControllerShortcut::IsEnabled() const { - return is_enabled; -} - -void ControllerShortcut::ControllerUpdateEvent(Core::HID::ControllerTriggerType type) { - if (!is_enabled) { - return; - } - if (type != Core::HID::ControllerTriggerType::Button) { - return; - } - if (button_sequence.npad.raw == Core::HID::NpadButton::None && - button_sequence.capture.raw == 0 && button_sequence.home.raw == 0) { - return; - } - - const auto player_npad_buttons = - emulated_controller->GetNpadButtons().raw & button_sequence.npad.raw; - const u64 player_capture_buttons = - emulated_controller->GetCaptureButtons().raw & button_sequence.capture.raw; - const u64 player_home_buttons = - emulated_controller->GetHomeButtons().raw & button_sequence.home.raw; - - if (player_npad_buttons == button_sequence.npad.raw && - player_capture_buttons == button_sequence.capture.raw && - player_home_buttons == button_sequence.home.raw && !active) { - // Force user to press the home or capture button again - active = true; - emit Activated(); - return; - } - active = false; -} diff --git a/src/yuzu/hotkeys.h b/src/yuzu/hotkeys.h deleted file mode 100644 index bdc081649..000000000 --- a/src/yuzu/hotkeys.h +++ /dev/null @@ -1,127 +0,0 @@ -// SPDX-FileCopyrightText: 2014 Citra Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include <map> -#include <QKeySequence> -#include <QString> -#include <QWidget> -#include "hid_core/hid_types.h" - -class QDialog; -class QSettings; -class QShortcut; -class ControllerShortcut; - -namespace Core::HID { -enum class ControllerTriggerType; -class EmulatedController; -} // namespace Core::HID - -struct ControllerButtonSequence { - Core::HID::CaptureButtonState capture{}; - Core::HID::HomeButtonState home{}; - Core::HID::NpadButtonState npad{}; -}; - -class ControllerShortcut : public QObject { - Q_OBJECT - -public: - explicit ControllerShortcut(Core::HID::EmulatedController* controller); - ~ControllerShortcut(); - - void SetKey(const ControllerButtonSequence& buttons); - void SetKey(const std::string& buttons_shortcut); - - ControllerButtonSequence ButtonSequence() const; - - void SetEnabled(bool enable); - bool IsEnabled() const; - -Q_SIGNALS: - void Activated(); - -private: - void ControllerUpdateEvent(Core::HID::ControllerTriggerType type); - - bool is_enabled{}; - bool active{}; - int callback_key{}; - ControllerButtonSequence button_sequence{}; - std::string name{}; - Core::HID::EmulatedController* emulated_controller = nullptr; -}; - -class HotkeyRegistry final { -public: - friend class ConfigureHotkeys; - - explicit HotkeyRegistry(); - ~HotkeyRegistry(); - - /** - * Loads hotkeys from the settings file. - * - * @note Yet unregistered hotkeys which are present in the settings will automatically be - * registered. - */ - void LoadHotkeys(); - - /** - * Saves all registered hotkeys to the settings file. - * - * @note Each hotkey group will be stored a settings group; For each hotkey inside that group, a - * settings group will be created to store the key sequence and the hotkey context. - */ - void SaveHotkeys(); - - /** - * Returns a QShortcut object whose activated() signal can be connected to other QObjects' - * slots. - * - * @param group General group this hotkey belongs to (e.g. "Main Window", "Debugger"). - * @param action Name of the action (e.g. "Start Emulation", "Load Image"). - * @param widget Parent widget of the returned QShortcut. - * @warning If multiple QWidgets' call this function for the same action, the returned QShortcut - * will be the same. Thus, you shouldn't rely on the caller really being the - * QShortcut's parent. - */ - QShortcut* GetHotkey(const std::string& group, const std::string& action, QWidget* widget); - ControllerShortcut* GetControllerHotkey(const std::string& group, const std::string& action, - Core::HID::EmulatedController* controller); - - /** - * Returns a QKeySequence object whose signal can be connected to QAction::setShortcut. - * - * @param group General group this hotkey belongs to (e.g. "Main Window", "Debugger"). - * @param action Name of the action (e.g. "Start Emulation", "Load Image"). - */ - QKeySequence GetKeySequence(const std::string& group, const std::string& action); - - /** - * Returns a Qt::ShortcutContext object who can be connected to other - * QAction::setShortcutContext. - * - * @param group General group this shortcut context belongs to (e.g. "Main Window", - * "Debugger"). - * @param action Name of the action (e.g. "Start Emulation", "Load Image"). - */ - Qt::ShortcutContext GetShortcutContext(const std::string& group, const std::string& action); - -private: - struct Hotkey { - QKeySequence keyseq; - std::string controller_keyseq; - QShortcut* shortcut = nullptr; - ControllerShortcut* controller_shortcut = nullptr; - Qt::ShortcutContext context = Qt::WindowShortcut; - bool repeat; - }; - - using HotkeyMap = std::map<std::string, Hotkey>; - using HotkeyGroupMap = std::map<std::string, HotkeyMap>; - - HotkeyGroupMap hotkey_groups; -}; diff --git a/src/yuzu/install_dialog.cpp b/src/yuzu/install_dialog.cpp deleted file mode 100644 index 673bbaa83..000000000 --- a/src/yuzu/install_dialog.cpp +++ /dev/null @@ -1,69 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include <QCheckBox> -#include <QDialogButtonBox> -#include <QFileInfo> -#include <QLabel> -#include <QListWidget> -#include <QVBoxLayout> -#include "yuzu/install_dialog.h" -#include "yuzu/uisettings.h" - -InstallDialog::InstallDialog(QWidget* parent, const QStringList& files) : QDialog(parent) { - file_list = new QListWidget(this); - - for (const QString& file : files) { - QListWidgetItem* item = new QListWidgetItem(QFileInfo(file).fileName(), file_list); - item->setData(Qt::UserRole, file); - item->setFlags(item->flags() | Qt::ItemIsUserCheckable); - item->setCheckState(Qt::Checked); - } - - file_list->setMinimumWidth((file_list->sizeHintForColumn(0) * 11) / 10); - - vbox_layout = new QVBoxLayout; - - hbox_layout = new QHBoxLayout; - - description = new QLabel(tr("Please confirm these are the files you wish to install.")); - - update_description = - new QLabel(tr("Installing an Update or DLC will overwrite the previously installed one.")); - - buttons = new QDialogButtonBox; - buttons->addButton(QDialogButtonBox::Cancel); - buttons->addButton(tr("Install"), QDialogButtonBox::AcceptRole); - - connect(buttons, &QDialogButtonBox::accepted, this, &InstallDialog::accept); - connect(buttons, &QDialogButtonBox::rejected, this, &InstallDialog::reject); - - hbox_layout->addWidget(buttons); - - vbox_layout->addWidget(description); - vbox_layout->addWidget(update_description); - vbox_layout->addWidget(file_list); - vbox_layout->addLayout(hbox_layout); - - setLayout(vbox_layout); - setWindowTitle(tr("Install Files to NAND")); -} - -InstallDialog::~InstallDialog() = default; - -QStringList InstallDialog::GetFiles() const { - QStringList files; - - for (int i = 0; i < file_list->count(); ++i) { - const QListWidgetItem* item = file_list->item(i); - if (item->checkState() == Qt::Checked) { - files.append(item->data(Qt::UserRole).toString()); - } - } - - return files; -} - -int InstallDialog::GetMinimumWidth() const { - return file_list->width(); -} diff --git a/src/yuzu/install_dialog.h b/src/yuzu/install_dialog.h deleted file mode 100644 index 4c7c3c158..000000000 --- a/src/yuzu/install_dialog.h +++ /dev/null @@ -1,34 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include <QDialog> - -class QCheckBox; -class QDialogButtonBox; -class QHBoxLayout; -class QLabel; -class QListWidget; -class QVBoxLayout; - -class InstallDialog : public QDialog { - Q_OBJECT - -public: - explicit InstallDialog(QWidget* parent, const QStringList& files); - ~InstallDialog() override; - - [[nodiscard]] QStringList GetFiles() const; - [[nodiscard]] int GetMinimumWidth() const; - -private: - QListWidget* file_list; - - QVBoxLayout* vbox_layout; - QHBoxLayout* hbox_layout; - - QLabel* description; - QLabel* update_description; - QDialogButtonBox* buttons; -}; diff --git a/src/yuzu/loading_screen.cpp b/src/yuzu/loading_screen.cpp deleted file mode 100644 index b081fff6b..000000000 --- a/src/yuzu/loading_screen.cpp +++ /dev/null @@ -1,202 +0,0 @@ -// 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 <QIODevice> -#include <QImage> -#include <QPainter> -#include <QPixmap> -#include <QPropertyAnimation> -#include <QStyleOption> -#include "core/frontend/framebuffer_layout.h" -#include "core/loader/loader.h" -#include "ui_loading_screen.h" -#include "video_core/rasterizer_interface.h" -#include "yuzu/loading_screen.h" - -// Mingw seems to not have QMovie at all. If QMovie is missing then use a single frame instead of an -// showing the full animation -#if !YUZU_QT_MOVIE_MISSING -#include <QMovie> -#endif - -constexpr char PROGRESSBAR_STYLE_PREPARE[] = R"( -QProgressBar {} -QProgressBar::chunk {})"; - -constexpr char PROGRESSBAR_STYLE_BUILD[] = R"( -QProgressBar { - background-color: black; - border: 2px solid white; - border-radius: 4px; - padding: 2px; -} -QProgressBar::chunk { - background-color: #ff3c28; - width: 1px; -})"; - -constexpr char PROGRESSBAR_STYLE_COMPLETE[] = R"( -QProgressBar { - background-color: #0ab9e6; - border: 2px solid white; - border-radius: 4px; - padding: 2px; -} -QProgressBar::chunk { - background-color: #ff3c28; -})"; - -LoadingScreen::LoadingScreen(QWidget* parent) - : QWidget(parent), ui(std::make_unique<Ui::LoadingScreen>()), - previous_stage(VideoCore::LoadCallbackStage::Complete) { - ui->setupUi(this); - setMinimumSize(Layout::MinimumSize::Width, Layout::MinimumSize::Height); - - // Create a fade out effect to hide this loading screen widget. - // When fading opacity, it will fade to the parent widgets background color, which is why we - // create an internal widget named fade_widget that we use the effect on, while keeping the - // loading screen widget's background color black. This way we can create a fade to black effect - opacity_effect = new QGraphicsOpacityEffect(this); - opacity_effect->setOpacity(1); - ui->fade_parent->setGraphicsEffect(opacity_effect); - fadeout_animation = std::make_unique<QPropertyAnimation>(opacity_effect, "opacity"); - fadeout_animation->setDuration(500); - fadeout_animation->setStartValue(1); - fadeout_animation->setEndValue(0); - fadeout_animation->setEasingCurve(QEasingCurve::OutBack); - - // After the fade completes, hide the widget and reset the opacity - connect(fadeout_animation.get(), &QPropertyAnimation::finished, [this] { - hide(); - opacity_effect->setOpacity(1); - emit Hidden(); - }); - connect(this, &LoadingScreen::LoadProgress, this, &LoadingScreen::OnLoadProgress, - Qt::QueuedConnection); - qRegisterMetaType<VideoCore::LoadCallbackStage>(); - - stage_translations = { - {VideoCore::LoadCallbackStage::Prepare, tr("Loading...")}, - {VideoCore::LoadCallbackStage::Build, tr("Loading Shaders %1 / %2")}, - {VideoCore::LoadCallbackStage::Complete, tr("Launching...")}, - }; - progressbar_style = { - {VideoCore::LoadCallbackStage::Prepare, PROGRESSBAR_STYLE_PREPARE}, - {VideoCore::LoadCallbackStage::Build, PROGRESSBAR_STYLE_BUILD}, - {VideoCore::LoadCallbackStage::Complete, PROGRESSBAR_STYLE_COMPLETE}, - }; -} - -LoadingScreen::~LoadingScreen() = default; - -void LoadingScreen::Prepare(Loader::AppLoader& loader) { - std::vector<u8> buffer; - if (loader.ReadBanner(buffer) == Loader::ResultStatus::Success) { -#ifdef YUZU_QT_MOVIE_MISSING - QPixmap map; - map.loadFromData(buffer.data(), buffer.size()); - ui->banner->setPixmap(map); -#else - backing_mem = std::make_unique<QByteArray>(reinterpret_cast<char*>(buffer.data()), - static_cast<int>(buffer.size())); - backing_buf = std::make_unique<QBuffer>(backing_mem.get()); - backing_buf->open(QIODevice::ReadOnly); - animation = std::make_unique<QMovie>(backing_buf.get(), QByteArray()); - animation->start(); - ui->banner->setMovie(animation.get()); -#endif - buffer.clear(); - } - if (loader.ReadLogo(buffer) == Loader::ResultStatus::Success) { - QPixmap map; - map.loadFromData(buffer.data(), static_cast<uint>(buffer.size())); - ui->logo->setPixmap(map); - } - - slow_shader_compile_start = false; - OnLoadProgress(VideoCore::LoadCallbackStage::Prepare, 0, 0); -} - -void LoadingScreen::OnLoadComplete() { - fadeout_animation->start(QPropertyAnimation::KeepWhenStopped); -} - -void LoadingScreen::OnLoadProgress(VideoCore::LoadCallbackStage stage, std::size_t value, - std::size_t total) { - using namespace std::chrono; - const auto now = steady_clock::now(); - // reset the timer if the stage changes - if (stage != previous_stage) { - ui->progress_bar->setStyleSheet(QString::fromUtf8(progressbar_style[stage])); - // Hide the progress bar during the prepare stage - if (stage == VideoCore::LoadCallbackStage::Prepare) { - ui->progress_bar->hide(); - } else { - ui->progress_bar->show(); - } - previous_stage = stage; - // reset back to fast shader compiling since the stage changed - slow_shader_compile_start = false; - } - // update the max of the progress bar if the number of shaders change - if (total != previous_total) { - 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 there's a drastic slowdown in the rate, then display an estimate - if (now - previous_time > milliseconds{50} || slow_shader_compile_start) { - if (!slow_shader_compile_start) { - slow_shader_start = steady_clock::now(); - slow_shader_compile_start = true; - slow_shader_first_value = value; - } - // only calculate an estimate time after a second has passed since stage change - const auto diff = duration_cast<milliseconds>(now - slow_shader_start); - if (diff > seconds{1}) { - const auto eta_mseconds = - static_cast<long>(static_cast<double>(total - slow_shader_first_value) / - (value - slow_shader_first_value) * diff.count()); - estimate = - tr("Estimated Time %1") - .arg(QTime(0, 0, 0, 0) - .addMSecs(std::max<long>(eta_mseconds - diff.count() + 1000, 1000)) - .toString(QStringLiteral("mm:ss"))); - } - } - - // update labels and progress bar - if (stage == VideoCore::LoadCallbackStage::Build) { - ui->stage->setText(stage_translations[stage].arg(value).arg(total)); - } else { - ui->stage->setText(stage_translations[stage]); - } - ui->value->setText(estimate); - ui->progress_bar->setValue(static_cast<int>(value)); - previous_time = now; -} - -void LoadingScreen::paintEvent(QPaintEvent* event) { - QStyleOption opt; - opt.initFrom(this); - QPainter p(this); - style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); - QWidget::paintEvent(event); -} - -void LoadingScreen::Clear() { -#ifndef YUZU_QT_MOVIE_MISSING - animation.reset(); - backing_buf.reset(); - backing_mem.reset(); -#endif -} diff --git a/src/yuzu/loading_screen.h b/src/yuzu/loading_screen.h deleted file mode 100644 index 17045595d..000000000 --- a/src/yuzu/loading_screen.h +++ /dev/null @@ -1,94 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include <chrono> -#include <memory> -#include <QString> -#include <QWidget> -#include <QtGlobal> - -#if !QT_CONFIG(movie) -#define YUZU_QT_MOVIE_MISSING 1 -#endif - -namespace Loader { -class AppLoader; -} - -namespace Ui { -class LoadingScreen; -} - -namespace VideoCore { -enum class LoadCallbackStage; -} - -class QBuffer; -class QByteArray; -class QGraphicsOpacityEffect; -class QMovie; -class QPropertyAnimation; - -class LoadingScreen : public QWidget { - Q_OBJECT - -public: - explicit LoadingScreen(QWidget* parent = nullptr); - - ~LoadingScreen(); - - /// Call before showing the loading screen to load the widgets with the logo and banner for the - /// currently loaded application. - void Prepare(Loader::AppLoader& loader); - - /// After the loading screen is hidden, the owner of this class can call this to clean up any - /// used resources such as the logo and banner. - void Clear(); - - /// Slot used to update the status of the progress bar - void OnLoadProgress(VideoCore::LoadCallbackStage stage, std::size_t value, std::size_t total); - - /// Hides the LoadingScreen with a fade out effect - void OnLoadComplete(); - - // In order to use a custom widget with a stylesheet, you need to override the paintEvent - // See https://wiki.qt.io/How_to_Change_the_Background_Color_of_QWidget - void paintEvent(QPaintEvent* event) override; - -signals: - void LoadProgress(VideoCore::LoadCallbackStage stage, std::size_t value, std::size_t total); - /// Signals that this widget is completely hidden now and should be replaced with the other - /// widget - void Hidden(); - -private: -#ifndef YUZU_QT_MOVIE_MISSING - std::unique_ptr<QMovie> animation; - std::unique_ptr<QBuffer> backing_buf; - std::unique_ptr<QByteArray> backing_mem; -#endif - std::unique_ptr<Ui::LoadingScreen> ui; - std::size_t previous_total = 0; - VideoCore::LoadCallbackStage previous_stage; - - QGraphicsOpacityEffect* opacity_effect = nullptr; - std::unique_ptr<QPropertyAnimation> fadeout_animation; - - // Definitions for the differences in text and styling for each stage - std::unordered_map<VideoCore::LoadCallbackStage, const char*> progressbar_style; - std::unordered_map<VideoCore::LoadCallbackStage, QString> stage_translations; - - // newly generated shaders are added to the end of the file, so when loading and compiling - // shaders, it will start quickly but end slow if new shaders were added since previous launch. - // These variables are used to detect the change in speed so we can generate an ETA - bool slow_shader_compile_start = false; - std::chrono::steady_clock::time_point slow_shader_start; - std::chrono::steady_clock::time_point previous_time; - 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/loading_screen.ui b/src/yuzu/loading_screen.ui deleted file mode 100644 index 820b47536..000000000 --- a/src/yuzu/loading_screen.ui +++ /dev/null @@ -1,164 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>LoadingScreen</class> - <widget class="QWidget" name="LoadingScreen"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>746</width> - <height>495</height> - </rect> - </property> - <property name="styleSheet"> - <string notr="true">background-color: rgb(0, 0, 0);</string> - </property> - <layout class="QVBoxLayout"> - <property name="spacing"> - <number>0</number> - </property> - <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="QWidget" name="fade_parent" native="true"> - <layout class="QVBoxLayout" name="verticalLayout_2"> - <property name="spacing"> - <number>0</number> - </property> - <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 alignment="Qt::AlignLeft|Qt::AlignTop"> - <widget class="QLabel" name="logo"> - <property name="text"> - <string/> - </property> - <property name="alignment"> - <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> - </property> - <property name="margin"> - <number>30</number> - </property> - </widget> - </item> - <item> - <layout class="QVBoxLayout" name="verticalLayout" stretch="1,0,1"> - <property name="spacing"> - <number>15</number> - </property> - <property name="sizeConstraint"> - <enum>QLayout::SetNoConstraint</enum> - </property> - <item alignment="Qt::AlignHCenter|Qt::AlignBottom"> - <widget class="QLabel" name="stage"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Minimum" vsizetype="Minimum"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="styleSheet"> - <string notr="true">background-color: black; color: white; -font: 75 20pt "Arial";</string> - </property> - <property name="text"> - <string>Loading Shaders 387 / 1628</string> - </property> - </widget> - </item> - <item alignment="Qt::AlignHCenter|Qt::AlignTop"> - <widget class="QProgressBar" name="progress_bar"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimumSize"> - <size> - <width>500</width> - <height>40</height> - </size> - </property> - <property name="styleSheet"> - <string notr="true">QProgressBar { -color: white; -border: 2px solid white; -outline-color: black; -border-radius: 20px; -} -QProgressBar::chunk { -background-color: white; -border-radius: 15px; -}</string> - </property> - <property name="value"> - <number>50</number> - </property> - <property name="textVisible"> - <bool>false</bool> - </property> - <property name="format"> - <string>Loading Shaders %v out of %m</string> - </property> - </widget> - </item> - <item alignment="Qt::AlignHCenter|Qt::AlignTop"> - <widget class="QLabel" name="value"> - <property name="toolTip"> - <string notr="true"/> - </property> - <property name="styleSheet"> - <string notr="true">background-color: black; color: white; -font: 75 15pt "Arial";</string> - </property> - <property name="text"> - <string>Estimated Time 5m 4s</string> - </property> - </widget> - </item> - </layout> - </item> - <item alignment="Qt::AlignRight|Qt::AlignBottom"> - <widget class="QLabel" name="banner"> - <property name="styleSheet"> - <string notr="true">background-color: black;</string> - </property> - <property name="text"> - <string/> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - <property name="margin"> - <number>30</number> - </property> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - <resources/> - <connections/> -</ui> diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp deleted file mode 100644 index 19aaff7c6..000000000 --- a/src/yuzu/main.cpp +++ /dev/null @@ -1,5343 +0,0 @@ -// SPDX-FileCopyrightText: 2014 Citra Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include <cinttypes> -#include <clocale> -#include <cmath> -#include <fstream> -#include <iostream> -#include <memory> -#include <thread> -#include "core/hle/service/am/applet_manager.h" -#include "core/loader/nca.h" -#include "core/tools/renderdoc.h" - -#ifdef __APPLE__ -#include <unistd.h> // for chdir -#endif -#ifdef __unix__ -#include <csignal> -#include <sys/socket.h> -#include "common/linux/gamemode.h" -#endif - -#include <boost/container/flat_set.hpp> - -// VFS includes must be before glad as they will conflict with Windows file api, which uses defines. -#include "applets/qt_amiibo_settings.h" -#include "applets/qt_controller.h" -#include "applets/qt_error.h" -#include "applets/qt_profile_select.h" -#include "applets/qt_software_keyboard.h" -#include "applets/qt_web_browser.h" -#include "common/nvidia_flags.h" -#include "common/settings_enums.h" -#include "configuration/configure_input.h" -#include "configuration/configure_per_game.h" -#include "configuration/configure_tas.h" -#include "core/file_sys/romfs_factory.h" -#include "core/file_sys/vfs/vfs.h" -#include "core/file_sys/vfs/vfs_real.h" -#include "core/frontend/applets/cabinet.h" -#include "core/frontend/applets/controller.h" -#include "core/frontend/applets/general.h" -#include "core/frontend/applets/mii_edit.h" -#include "core/frontend/applets/software_keyboard.h" -#include "core/hle/service/acc/profile_manager.h" -#include "core/hle/service/am/frontend/applets.h" -#include "core/hle/service/set/system_settings_server.h" -#include "frontend_common/content_manager.h" -#include "hid_core/frontend/emulated_controller.h" -#include "hid_core/hid_core.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 -// defines. -static FileSys::VirtualDir VfsFilesystemCreateDirectoryWrapper( - const FileSys::VirtualFilesystem& vfs, const std::string& path, FileSys::OpenMode mode) { - return vfs->CreateDirectory(path, mode); -} - -static FileSys::VirtualFile VfsDirectoryCreateFileWrapper(const FileSys::VirtualDir& dir, - const std::string& path) { - return dir->CreateFile(path); -} - -#include <fmt/ostream.h> -#include <glad/glad.h> - -#define QT_NO_OPENGL -#include <QClipboard> -#include <QDesktopServices> -#include <QDir> -#include <QFile> -#include <QFileDialog> -#include <QInputDialog> -#include <QMessageBox> -#include <QProgressBar> -#include <QProgressDialog> -#include <QPushButton> -#include <QScreen> -#include <QShortcut> -#include <QStandardPaths> -#include <QStatusBar> -#include <QString> -#include <QSysInfo> -#include <QUrl> -#include <QtConcurrent/QtConcurrent> - -#ifdef HAVE_SDL2 -#include <SDL.h> // For SDL ScreenSaver functions -#endif - -#include <fmt/format.h> -#include "common/detached_tasks.h" -#include "common/fs/fs.h" -#include "common/fs/path_util.h" -#include "common/literals.h" -#include "common/logging/backend.h" -#include "common/logging/log.h" -#include "common/memory_detect.h" -#include "common/microprofile.h" -#include "common/scm_rev.h" -#include "common/scope_exit.h" -#ifdef _WIN32 -#include <shlobj.h> -#include "common/windows/timer_resolution.h" -#endif -#ifdef ARCHITECTURE_x86_64 -#include "common/x64/cpu_detect.h" -#endif -#include "common/settings.h" -#include "common/telemetry.h" -#include "core/core.h" -#include "core/core_timing.h" -#include "core/crypto/key_manager.h" -#include "core/file_sys/card_image.h" -#include "core/file_sys/common_funcs.h" -#include "core/file_sys/content_archive.h" -#include "core/file_sys/control_metadata.h" -#include "core/file_sys/patch_manager.h" -#include "core/file_sys/registered_cache.h" -#include "core/file_sys/romfs.h" -#include "core/file_sys/savedata_factory.h" -#include "core/file_sys/submission_package.h" -#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/sm/sm.h" -#include "core/loader/loader.h" -#include "core/perf_stats.h" -#include "core/telemetry_session.h" -#include "frontend_common/config.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" -#include "video_core/gpu.h" -#include "video_core/renderer_base.h" -#include "video_core/shader_notify.h" -#include "yuzu/about_dialog.h" -#include "yuzu/bootmanager.h" -#include "yuzu/compatdb.h" -#include "yuzu/compatibility_list.h" -#include "yuzu/configuration/configure_dialog.h" -#include "yuzu/configuration/configure_input_per_game.h" -#include "yuzu/configuration/qt_config.h" -#include "yuzu/debugger/console.h" -#include "yuzu/debugger/controller.h" -#include "yuzu/debugger/profiler.h" -#include "yuzu/debugger/wait_tree.h" -#include "yuzu/discord.h" -#include "yuzu/game_list.h" -#include "yuzu/game_list_p.h" -#include "yuzu/hotkeys.h" -#include "yuzu/install_dialog.h" -#include "yuzu/loading_screen.h" -#include "yuzu/main.h" -#include "yuzu/play_time_manager.h" -#include "yuzu/startup_checks.h" -#include "yuzu/uisettings.h" -#include "yuzu/util/clickable_label.h" -#include "yuzu/vk_device_info.h" - -#ifdef YUZU_CRASH_DUMPS -#include "yuzu/breakpad.h" -#endif - -using namespace Common::Literals; - -#ifdef USE_DISCORD_PRESENCE -#include "yuzu/discord_impl.h" -#endif - -#ifdef QT_STATICPLUGIN -Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin); -#endif - -#ifdef _WIN32 -#include <windows.h> -extern "C" { -// tells Nvidia and AMD drivers to use the dedicated GPU by default on laptops with switchable -// graphics -__declspec(dllexport) unsigned long NvOptimusEnablement = 0x00000001; -__declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1; -} -#endif - -constexpr int default_mouse_hide_timeout = 2500; -constexpr int default_input_update_timeout = 1; - -constexpr size_t CopyBufferSize = 1_MiB; - -/** - * "Callouts" are one-time instructional messages shown to the user. In the config settings, there - * is a bitfield "callout_flags" options, used to track if a message has already been shown to the - * user. This is 32-bits - if we have more than 32 callouts, we should retire and recycle old ones. - */ -enum class CalloutFlag : uint32_t { - Telemetry = 0x1, - DRDDeprecation = 0x2, -}; - -void GMainWindow::ShowTelemetryCallout() { - if (UISettings::values.callout_flags.GetValue() & - static_cast<uint32_t>(CalloutFlag::Telemetry)) { - return; - } - - UISettings::values.callout_flags = - UISettings::values.callout_flags.GetValue() | static_cast<uint32_t>(CalloutFlag::Telemetry); - const QString telemetry_message = - tr("<a href='https://yuzu-emu.org/help/feature/telemetry/'>Anonymous " - "data is collected</a> to help improve yuzu. " - "<br/><br/>Would you like to share your usage data with us?"); - if (!question(this, tr("Telemetry"), telemetry_message)) { - Settings::values.enable_telemetry = false; - system->ApplySettings(); - } -} - -const int GMainWindow::max_recent_files_item; - -static void RemoveCachedContents() { - const auto cache_dir = Common::FS::GetYuzuPath(Common::FS::YuzuPath::CacheDir); - const auto offline_fonts = cache_dir / "fonts"; - const auto offline_manual = cache_dir / "offline_web_applet_manual"; - const auto offline_legal_information = cache_dir / "offline_web_applet_legal_information"; - const auto offline_system_data = cache_dir / "offline_web_applet_system_data"; - - Common::FS::RemoveDirRecursively(offline_fonts); - Common::FS::RemoveDirRecursively(offline_manual); - Common::FS::RemoveDirRecursively(offline_legal_information); - Common::FS::RemoveDirRecursively(offline_system_data); -} - -static void LogRuntimes() { -#ifdef _MSC_VER - // It is possible that the name of the dll will change. - // vcruntime140.dll is for 2015 and onwards - static 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 - LOG_INFO(Frontend, "Qt Compile: {} Runtime: {}", QT_VERSION_STR, qVersion()); -} - -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(); -} - -#ifdef _WIN32 -static void OverrideWindowsFont() { - // Qt5 chooses these fonts on Windows and they have fairly ugly alphanumeric/cyrillic characters - // Asking to use "MS Shell Dlg 2" gives better other chars while leaving the Chinese Characters. - const QString startup_font = QApplication::font().family(); - const QStringList ugly_fonts = {QStringLiteral("SimSun"), QStringLiteral("PMingLiU")}; - if (ugly_fonts.contains(startup_font)) { - QApplication::setFont(QFont(QStringLiteral("MS Shell Dlg 2"), 9, QFont::Normal)); - } -} -#endif - -bool GMainWindow::CheckDarkMode() { -#ifdef __unix__ - 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 // __unix__ -} - -GMainWindow::GMainWindow(std::unique_ptr<QtConfig> 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::move(config_)}, - vfs{std::make_shared<FileSys::RealVfsFilesystem>()}, - provider{std::make_unique<FileSys::ManualContentProvider>()} { -#ifdef __unix__ - SetupSigInterrupts(); - SetGamemodeEnabled(Settings::values.enable_gamemode.GetValue()); -#endif - system->Initialize(); - - Common::Log::Initialize(); - Common::Log::Start(); - - LoadTranslation(); - - setAcceptDrops(true); - 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(); - - play_time_manager = std::make_unique<PlayTime::PlayTimeManager>(system->GetProfileManager()); - - system->GetRoomNetwork().Init(); - - RegisterMetaTypes(); - - InitializeWidgets(); - InitializeDebugWidgets(); - InitializeRecentFileMenuActions(); - InitializeHotkeys(); - - SetDefaultUIGeometry(); - RestoreUIState(); - - ConnectMenuEvents(); - ConnectWidgetEvents(); - - system->HIDCore().ReloadInputDevices(); - controller_dialog->refreshConfiguration(); - - const auto branch_name = std::string(Common::g_scm_branch); - const auto description = std::string(Common::g_scm_desc); - const auto build_id = std::string(Common::g_build_id); - - const auto yuzu_build = fmt::format("yuzu Development Build | {}-{}", branch_name, description); - const auto override_build = - fmt::format(fmt::runtime(std::string(Common::g_title_bar_format_idle)), build_id); - const auto yuzu_build_version = override_build.empty() ? yuzu_build : override_build; - const auto processor_count = std::thread::hardware_concurrency(); - - 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.avx512f) { - cpu_string += " | AVX"; - if (caps.avx512f) { - cpu_string += "512"; - } else if (caps.avx2) { - cpu_string += '2'; - } - if (caps.fma || caps.fma4) { - cpu_string += " | FMA"; - } - } - LOG_INFO(Frontend, "Host CPU: {}", cpu_string); - if (std::optional<int> processor_core = Common::GetProcessorCount()) { - LOG_INFO(Frontend, "Host CPU Cores: {}", *processor_core); - } -#endif - LOG_INFO(Frontend, "Host CPU Threads: {}", processor_count); - 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}); -#ifdef _WIN32 - LOG_INFO(Frontend, "Host Timer Resolution: {:.4f} ms", - std::chrono::duration_cast<std::chrono::duration<f64, std::milli>>( - Common::Windows::SetCurrentTimerResolutionToMaximum()) - .count()); - system->CoreTiming().SetTimerResolutionNs(Common::Windows::GetCurrentTimerResolution()); -#endif - UpdateWindowTitle(); - - show(); - - system->SetContentProvider(std::make_unique<FileSys::ContentProviderUnion>()); - system->RegisterContentProvider(FileSys::ContentProviderUnionSlot::FrontendManual, - provider.get()); - system->GetFileSystemController().CreateFactories(*vfs); - - // Remove cached contents generated during the previous session - RemoveCachedContents(); - - // Gen keys if necessary - OnCheckFirmwareDecryption(); - - game_list->LoadCompatibilityList(); - game_list->PopulateAsync(UISettings::values.game_dirs); - - // Show one-time "callout" messages to the user - ShowTelemetryCallout(); - - // make sure menubar has the arrow cursor instead of inheriting from this - ui->menubar->setCursor(QCursor()); - statusBar()->setCursor(QCursor()); - - 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); - - update_input_timer.setInterval(default_input_update_timeout); - connect(&update_input_timer, &QTimer::timeout, this, &GMainWindow::UpdateInputDrivers); - update_input_timer.start(); - - MigrateConfigFiles(); - - if (has_broken_vulkan) { - 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>.")); - -#ifdef HAS_OPENGL - Settings::values.renderer_backend = Settings::RendererBackend::OpenGL; -#else - Settings::values.renderer_backend = Settings::RendererBackend::Null; -#endif - - UpdateAPIText(); - renderer_status_button->setDisabled(true); - renderer_status_button->setChecked(false); - } else { - VkDeviceInfo::PopulateRecords(vk_device_records, this->window()->windowHandle()); - } - -#if defined(HAVE_SDL2) && !defined(_WIN32) - SDL_InitSubSystem(SDL_INIT_VIDEO); - - // Set a screensaver inhibition reason string. Currently passed to DBus by SDL and visible to - // the user through their desktop environment. - //: TRANSLATORS: This string is shown to the user to explain why yuzu needs to prevent the - //: computer from sleeping - QByteArray wakelock_reason = tr("Running a game").toUtf8(); - SDL_SetHint(SDL_HINT_SCREENSAVER_INHIBIT_ACTIVITY_NAME, wakelock_reason.data()); - - // SDL disables the screen saver by default, and setting the hint - // SDL_HINT_VIDEO_ALLOW_SCREENSAVER doesn't seem to work, so we just enable the screen saver - // for now. - SDL_EnableScreenSaver(); -#endif - - SetupPrepareForSleep(); - - QStringList args = QApplication::arguments(); - - if (args.size() < 2) { - return; - } - - 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")) { - is_fullscreen = true; - continue; - } - - // Launch game with a specific user - if (args[i] == QStringLiteral("-u")) { - if (i >= args.size() - 1) { - continue; - } - - if (args[i + 1].startsWith(QChar::fromLatin1('-'))) { - continue; - } - - int user_arg_idx = ++i; - bool argument_ok; - std::size_t selected_user = args[user_arg_idx].toUInt(&argument_ok); - - if (!argument_ok) { - // try to look it up by username, only finds the first username that matches. - const std::string user_arg_str = args[user_arg_idx].toStdString(); - const auto user_idx = system->GetProfileManager().GetUserIndex(user_arg_str); - - if (user_idx == std::nullopt) { - LOG_ERROR(Frontend, "Invalid user argument"); - continue; - } - - selected_user = user_idx.value(); - } - - if (!system->GetProfileManager().UserExistsIndex(selected_user)) { - LOG_ERROR(Frontend, "Selected user doesn't exist"); - continue; - } - - Settings::values.current_user = static_cast<s32>(selected_user); - - user_flag_cmd_line = true; - continue; - } - - // Launch game at path - if (args[i] == QStringLiteral("-g")) { - if (i >= args.size() - 1) { - continue; - } - - if (args[i + 1].startsWith(QChar::fromLatin1('-'))) { - continue; - } - - 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, ApplicationAppletParameters()); - } -} - -GMainWindow::~GMainWindow() { - // will get automatically deleted otherwise - if (render_window->parent() == nullptr) { - delete render_window; - } - -#ifdef __unix__ - ::close(sig_interrupt_fds[0]); - ::close(sig_interrupt_fds[1]); -#endif -} - -void GMainWindow::RegisterMetaTypes() { - // Register integral and floating point types - qRegisterMetaType<u8>("u8"); - qRegisterMetaType<u16>("u16"); - qRegisterMetaType<u32>("u32"); - qRegisterMetaType<u64>("u64"); - qRegisterMetaType<u128>("u128"); - qRegisterMetaType<s8>("s8"); - qRegisterMetaType<s16>("s16"); - qRegisterMetaType<s32>("s32"); - qRegisterMetaType<s64>("s64"); - qRegisterMetaType<f32>("f32"); - qRegisterMetaType<f64>("f64"); - - // Register string types - qRegisterMetaType<std::string>("std::string"); - qRegisterMetaType<std::wstring>("std::wstring"); - qRegisterMetaType<std::u8string>("std::u8string"); - qRegisterMetaType<std::u16string>("std::u16string"); - qRegisterMetaType<std::u32string>("std::u32string"); - qRegisterMetaType<std::string_view>("std::string_view"); - qRegisterMetaType<std::wstring_view>("std::wstring_view"); - qRegisterMetaType<std::u8string_view>("std::u8string_view"); - qRegisterMetaType<std::u16string_view>("std::u16string_view"); - qRegisterMetaType<std::u32string_view>("std::u32string_view"); - - // Register applet types - - // Cabinet Applet - qRegisterMetaType<Core::Frontend::CabinetParameters>("Core::Frontend::CabinetParameters"); - qRegisterMetaType<std::shared_ptr<Service::NFC::NfcDevice>>( - "std::shared_ptr<Service::NFC::NfcDevice>"); - - // Controller Applet - qRegisterMetaType<Core::Frontend::ControllerParameters>("Core::Frontend::ControllerParameters"); - - // Profile Select Applet - qRegisterMetaType<Core::Frontend::ProfileSelectParameters>( - "Core::Frontend::ProfileSelectParameters"); - - // Software Keyboard Applet - qRegisterMetaType<Core::Frontend::KeyboardInitializeParameters>( - "Core::Frontend::KeyboardInitializeParameters"); - qRegisterMetaType<Core::Frontend::InlineAppearParameters>( - "Core::Frontend::InlineAppearParameters"); - qRegisterMetaType<Core::Frontend::InlineTextParameters>("Core::Frontend::InlineTextParameters"); - qRegisterMetaType<Service::AM::Frontend::SwkbdResult>("Service::AM::Frontend::SwkbdResult"); - qRegisterMetaType<Service::AM::Frontend::SwkbdTextCheckResult>( - "Service::AM::Frontend::SwkbdTextCheckResult"); - qRegisterMetaType<Service::AM::Frontend::SwkbdReplyType>( - "Service::AM::Frontend::SwkbdReplyType"); - - // Web Browser Applet - qRegisterMetaType<Service::AM::Frontend::WebExitReason>("Service::AM::Frontend::WebExitReason"); - - // Register loader types - qRegisterMetaType<Core::SystemResultStatus>("Core::SystemResultStatus"); -} - -void GMainWindow::AmiiboSettingsShowDialog(const Core::Frontend::CabinetParameters& parameters, - std::shared_ptr<Service::NFC::NfcDevice> nfp_device) { - cabinet_applet = - new QtAmiiboSettingsDialog(this, parameters, input_subsystem.get(), nfp_device); - SCOPE_EXIT { - cabinet_applet->deleteLater(); - cabinet_applet = nullptr; - }; - - cabinet_applet->setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint | - Qt::WindowTitleHint | Qt::WindowSystemMenuHint); - cabinet_applet->setWindowModality(Qt::WindowModal); - - if (cabinet_applet->exec() == QDialog::Rejected) { - emit AmiiboSettingsFinished(false, {}); - return; - } - - emit AmiiboSettingsFinished(true, cabinet_applet->GetName()); -} - -void GMainWindow::AmiiboSettingsRequestExit() { - if (cabinet_applet) { - cabinet_applet->reject(); - } -} - -void GMainWindow::ControllerSelectorReconfigureControllers( - const Core::Frontend::ControllerParameters& parameters) { - controller_applet = - new QtControllerSelectorDialog(this, parameters, input_subsystem.get(), *system); - SCOPE_EXIT { - controller_applet->deleteLater(); - controller_applet = nullptr; - }; - - controller_applet->setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | - Qt::WindowStaysOnTopHint | Qt::WindowTitleHint | - Qt::WindowSystemMenuHint); - controller_applet->setWindowModality(Qt::WindowModal); - bool is_success = controller_applet->exec() != QDialog::Rejected; - - // Don't forget to apply settings. - system->HIDCore().DisableAllControllerConfiguration(); - system->ApplySettings(); - config->SaveAllValues(); - - UpdateStatusButtons(); - - emit ControllerSelectorReconfigureFinished(is_success); -} - -void GMainWindow::ControllerSelectorRequestExit() { - if (controller_applet) { - controller_applet->reject(); - } -} - -void GMainWindow::ProfileSelectorSelectProfile( - const Core::Frontend::ProfileSelectParameters& parameters) { - profile_select_applet = new QtProfileSelectionDialog(*system, this, parameters); - SCOPE_EXIT { - profile_select_applet->deleteLater(); - profile_select_applet = nullptr; - }; - - profile_select_applet->setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | - Qt::WindowStaysOnTopHint | Qt::WindowTitleHint | - Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint); - profile_select_applet->setWindowModality(Qt::WindowModal); - if (profile_select_applet->exec() == QDialog::Rejected) { - emit ProfileSelectorFinishedSelection(std::nullopt); - return; - } - - const auto uuid = system->GetProfileManager().GetUser( - static_cast<std::size_t>(profile_select_applet->GetIndex())); - if (!uuid.has_value()) { - emit ProfileSelectorFinishedSelection(std::nullopt); - return; - } - - emit ProfileSelectorFinishedSelection(uuid); -} - -void GMainWindow::ProfileSelectorRequestExit() { - if (profile_select_applet) { - profile_select_applet->reject(); - } -} - -void GMainWindow::SoftwareKeyboardInitialize( - bool is_inline, Core::Frontend::KeyboardInitializeParameters initialize_parameters) { - if (software_keyboard) { - LOG_ERROR(Frontend, "The software keyboard is already initialized!"); - return; - } - - software_keyboard = new QtSoftwareKeyboardDialog(render_window, *system, is_inline, - std::move(initialize_parameters)); - - if (is_inline) { - connect( - software_keyboard, &QtSoftwareKeyboardDialog::SubmitInlineText, this, - [this](Service::AM::Frontend::SwkbdReplyType reply_type, std::u16string submitted_text, - s32 cursor_position) { - emit SoftwareKeyboardSubmitInlineText(reply_type, submitted_text, cursor_position); - }, - Qt::QueuedConnection); - } else { - connect( - software_keyboard, &QtSoftwareKeyboardDialog::SubmitNormalText, this, - [this](Service::AM::Frontend::SwkbdResult result, std::u16string submitted_text, - bool confirmed) { - emit SoftwareKeyboardSubmitNormalText(result, submitted_text, confirmed); - }, - Qt::QueuedConnection); - } -} - -void GMainWindow::SoftwareKeyboardShowNormal() { - if (!software_keyboard) { - LOG_ERROR(Frontend, "The software keyboard is not initialized!"); - return; - } - - const auto& layout = render_window->GetFramebufferLayout(); - - const auto x = layout.screen.left; - const auto y = layout.screen.top; - const auto w = layout.screen.GetWidth(); - const auto h = layout.screen.GetHeight(); - const auto scale_ratio = devicePixelRatioF(); - - software_keyboard->ShowNormalKeyboard(render_window->mapToGlobal(QPoint(x, y) / scale_ratio), - QSize(w, h) / scale_ratio); -} - -void GMainWindow::SoftwareKeyboardShowTextCheck( - Service::AM::Frontend::SwkbdTextCheckResult text_check_result, - std::u16string text_check_message) { - if (!software_keyboard) { - LOG_ERROR(Frontend, "The software keyboard is not initialized!"); - return; - } - - software_keyboard->ShowTextCheckDialog(text_check_result, text_check_message); -} - -void GMainWindow::SoftwareKeyboardShowInline( - Core::Frontend::InlineAppearParameters appear_parameters) { - if (!software_keyboard) { - LOG_ERROR(Frontend, "The software keyboard is not initialized!"); - return; - } - - const auto& layout = render_window->GetFramebufferLayout(); - - const auto x = - static_cast<int>(layout.screen.left + (0.5f * layout.screen.GetWidth() * - ((2.0f * appear_parameters.key_top_translate_x) + - (1.0f - appear_parameters.key_top_scale_x)))); - const auto y = - static_cast<int>(layout.screen.top + (layout.screen.GetHeight() * - ((2.0f * appear_parameters.key_top_translate_y) + - (1.0f - appear_parameters.key_top_scale_y)))); - const auto w = static_cast<int>(layout.screen.GetWidth() * appear_parameters.key_top_scale_x); - const auto h = static_cast<int>(layout.screen.GetHeight() * appear_parameters.key_top_scale_y); - const auto scale_ratio = devicePixelRatioF(); - - software_keyboard->ShowInlineKeyboard(std::move(appear_parameters), - render_window->mapToGlobal(QPoint(x, y) / scale_ratio), - QSize(w, h) / scale_ratio); -} - -void GMainWindow::SoftwareKeyboardHideInline() { - if (!software_keyboard) { - LOG_ERROR(Frontend, "The software keyboard is not initialized!"); - return; - } - - software_keyboard->HideInlineKeyboard(); -} - -void GMainWindow::SoftwareKeyboardInlineTextChanged( - Core::Frontend::InlineTextParameters text_parameters) { - if (!software_keyboard) { - LOG_ERROR(Frontend, "The software keyboard is not initialized!"); - return; - } - - software_keyboard->InlineTextChanged(std::move(text_parameters)); -} - -void GMainWindow::SoftwareKeyboardExit() { - if (!software_keyboard) { - return; - } - - software_keyboard->ExitKeyboard(); - - software_keyboard = nullptr; -} - -void GMainWindow::WebBrowserOpenWebPage(const std::string& main_url, - const std::string& additional_args, bool is_local) { -#ifdef YUZU_USE_QT_WEB_ENGINE - - // Raw input breaks with the web applet, Disable web applets if enabled - if (UISettings::values.disable_web_applet || Settings::values.enable_raw_input) { - emit WebBrowserClosed(Service::AM::Frontend::WebExitReason::WindowClosed, - "http://localhost/"); - return; - } - - web_applet = new QtNXWebEngineView(this, *system, input_subsystem.get()); - - ui->action_Pause->setEnabled(false); - ui->action_Restart->setEnabled(false); - ui->action_Stop->setEnabled(false); - - { - QProgressDialog loading_progress(this); - loading_progress.setLabelText(tr("Loading Web Applet...")); - loading_progress.setRange(0, 3); - loading_progress.setValue(0); - - if (is_local && !Common::FS::Exists(main_url)) { - loading_progress.show(); - - auto future = QtConcurrent::run([this] { emit WebBrowserExtractOfflineRomFS(); }); - - while (!future.isFinished()) { - QCoreApplication::processEvents(); - - std::this_thread::sleep_for(std::chrono::milliseconds(1)); - } - } - - loading_progress.setValue(1); - - if (is_local) { - web_applet->LoadLocalWebPage(main_url, additional_args); - } else { - web_applet->LoadExternalWebPage(main_url, additional_args); - } - - if (render_window->IsLoadingComplete()) { - render_window->hide(); - } - - const auto& layout = render_window->GetFramebufferLayout(); - const auto scale_ratio = devicePixelRatioF(); - web_applet->resize(layout.screen.GetWidth() / scale_ratio, - layout.screen.GetHeight() / scale_ratio); - web_applet->move(layout.screen.left / scale_ratio, - (layout.screen.top / scale_ratio) + menuBar()->height()); - web_applet->setZoomFactor(static_cast<qreal>(layout.screen.GetWidth() / scale_ratio) / - static_cast<qreal>(Layout::ScreenUndocked::Width)); - - web_applet->setFocus(); - web_applet->show(); - - loading_progress.setValue(2); - - QCoreApplication::processEvents(); - - loading_progress.setValue(3); - } - - bool exit_check = false; - - // TODO (Morph): Remove this - QAction* exit_action = new QAction(tr("Disable Web Applet"), this); - connect(exit_action, &QAction::triggered, this, [this] { - const auto result = QMessageBox::warning( - this, tr("Disable 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) { - UISettings::values.disable_web_applet = true; - web_applet->SetFinished(true); - } - }); - ui->menubar->addAction(exit_action); - - while (!web_applet->IsFinished()) { - QCoreApplication::processEvents(); - - if (!exit_check) { - web_applet->page()->runJavaScript( - QStringLiteral("end_applet;"), [&](const QVariant& variant) { - exit_check = false; - if (variant.toBool()) { - web_applet->SetFinished(true); - web_applet->SetExitReason( - Service::AM::Frontend::WebExitReason::EndButtonPressed); - } - }); - - exit_check = true; - } - - if (web_applet->GetCurrentURL().contains(QStringLiteral("localhost"))) { - if (!web_applet->IsFinished()) { - web_applet->SetFinished(true); - web_applet->SetExitReason(Service::AM::Frontend::WebExitReason::CallbackURL); - } - - web_applet->SetLastURL(web_applet->GetCurrentURL().toStdString()); - } - - std::this_thread::sleep_for(std::chrono::milliseconds(1)); - } - - const auto exit_reason = web_applet->GetExitReason(); - const auto last_url = web_applet->GetLastURL(); - - web_applet->hide(); - - render_window->setFocus(); - - if (render_window->IsLoadingComplete()) { - render_window->show(); - } - - ui->action_Pause->setEnabled(true); - ui->action_Restart->setEnabled(true); - ui->action_Stop->setEnabled(true); - - ui->menubar->removeAction(exit_action); - - QCoreApplication::processEvents(); - - emit WebBrowserClosed(exit_reason, last_url); - -#else - - // Utilize the same fallback as the default web browser applet. - emit WebBrowserClosed(Service::AM::Frontend::WebExitReason::WindowClosed, "http://localhost/"); - -#endif -} - -void GMainWindow::WebBrowserRequestExit() { -#ifdef YUZU_USE_QT_WEB_ENGINE - if (web_applet) { - web_applet->SetExitReason(Service::AM::Frontend::WebExitReason::ExitRequested); - web_applet->SetFinished(true); - } -#endif -} - -void GMainWindow::InitializeWidgets() { -#ifdef YUZU_ENABLE_COMPATIBILITY_REPORTING - ui->action_Report_Compatibility->setVisible(true); -#endif - render_window = new GRenderWindow(this, emu_thread.get(), input_subsystem, *system); - render_window->hide(); - - game_list = new GameList(vfs, provider.get(), *play_time_manager, *system, this); - ui->horizontalLayout->addWidget(game_list); - - game_list_placeholder = new GameListPlaceholder(this); - ui->horizontalLayout->addWidget(game_list_placeholder); - game_list_placeholder->setVisible(false); - - loading_screen = new LoadingScreen(this); - loading_screen->hide(); - ui->horizontalLayout->addWidget(loading_screen); - connect(loading_screen, &LoadingScreen::Hidden, [&] { - loading_screen->Clear(); - if (emulation_running) { - render_window->show(); - render_window->setFocus(); - } - }); - - 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 - message_label->setFrameStyle(QFrame::NoFrame); - message_label->setContentsMargins(4, 0, 4, 0); - message_label->setAlignment(Qt::AlignLeft); - statusBar()->addPermanentWidget(message_label, 1); - - shader_building_label = new QLabel(); - shader_building_label->setToolTip(tr("The amount of shaders currently being built")); - res_scale_label = new QLabel(); - res_scale_label->setToolTip(tr("The current selected resolution scaling multiplier.")); - emu_speed_label = new QLabel(); - emu_speed_label->setToolTip( - tr("Current emulation speed. Values higher or lower than 100% " - "indicate emulation is running faster or slower than a Switch.")); - game_fps_label = new QLabel(); - game_fps_label->setToolTip(tr("How many frames per second the game is currently displaying. " - "This will vary from game to game and scene to scene.")); - emu_frametime_label = new QLabel(); - emu_frametime_label->setToolTip( - tr("Time taken to emulate a Switch frame, not counting framelimiting or v-sync. For " - "full-speed emulation this should be at most 16.67 ms.")); - - for (auto& label : {shader_building_label, res_scale_label, emu_speed_label, game_fps_label, - emu_frametime_label}) { - label->setVisible(false); - label->setFrameStyle(QFrame::NoFrame); - label->setContentsMargins(4, 0, 4, 0); - statusBar()->addPermanentWidget(label); - } - - firmware_label = new QLabel(); - firmware_label->setObjectName(QStringLiteral("FirmwareLabel")); - firmware_label->setVisible(false); - firmware_label->setFocusPolicy(Qt::NoFocus); - statusBar()->addPermanentWidget(firmware_label); - - 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); - statusBar()->insertPermanentWidget(0, tas_label); - - volume_popup = new QWidget(this); - volume_popup->setWindowFlags(Qt::FramelessWindowHint | Qt::NoDropShadowWindowHint | Qt::Popup); - volume_popup->setLayout(new QVBoxLayout()); - volume_popup->setMinimumWidth(200); - - volume_slider = new QSlider(Qt::Horizontal); - volume_slider->setObjectName(QStringLiteral("volume_slider")); - volume_slider->setMaximum(200); - volume_slider->setPageStep(5); - volume_popup->layout()->addWidget(volume_slider); - - volume_button = new VolumeButton(); - volume_button->setObjectName(QStringLiteral("TogglableStatusBarButton")); - volume_button->setFocusPolicy(Qt::NoFocus); - volume_button->setCheckable(true); - UpdateVolumeUI(); - connect(volume_slider, &QSlider::valueChanged, this, [this](int percentage) { - Settings::values.audio_muted = false; - const auto volume = static_cast<u8>(percentage); - Settings::values.volume.SetValue(volume); - UpdateVolumeUI(); - }); - connect(volume_button, &QPushButton::clicked, this, [&] { - UpdateVolumeUI(); - volume_popup->setVisible(!volume_popup->isVisible()); - QRect rect = volume_button->geometry(); - QPoint bottomLeft = statusBar()->mapToGlobal(rect.topLeft()); - bottomLeft.setY(bottomLeft.y() - volume_popup->geometry().height()); - volume_popup->setGeometry(QRect(bottomLeft, QSize(rect.width(), rect.height()))); - }); - volume_button->setContextMenuPolicy(Qt::CustomContextMenu); - connect(volume_button, &QPushButton::customContextMenuRequested, - [this](const QPoint& menu_location) { - QMenu context_menu; - context_menu.addAction( - Settings::values.audio_muted ? tr("Unmute") : tr("Mute"), [this] { - Settings::values.audio_muted = !Settings::values.audio_muted; - UpdateVolumeUI(); - }); - - context_menu.addAction(tr("Reset Volume"), [this] { - Settings::values.volume.SetValue(100); - UpdateVolumeUI(); - }); - - context_menu.exec(volume_button->mapToGlobal(menu_location)); - volume_button->repaint(); - }); - connect(volume_button, &VolumeButton::VolumeChanged, this, &GMainWindow::UpdateVolumeUI); - - statusBar()->insertPermanentWidget(0, volume_button); - - // setup AA button - aa_status_button = new QPushButton(); - aa_status_button->setObjectName(QStringLiteral("TogglableStatusBarButton")); - aa_status_button->setFocusPolicy(Qt::NoFocus); - connect(aa_status_button, &QPushButton::clicked, [&] { - auto aa_mode = Settings::values.anti_aliasing.GetValue(); - aa_mode = static_cast<Settings::AntiAliasing>(static_cast<u32>(aa_mode) + 1); - if (aa_mode == Settings::AntiAliasing::MaxEnum) { - aa_mode = Settings::AntiAliasing::None; - } - Settings::values.anti_aliasing.SetValue(aa_mode); - aa_status_button->setChecked(true); - UpdateAAText(); - }); - UpdateAAText(); - aa_status_button->setCheckable(true); - aa_status_button->setChecked(true); - aa_status_button->setContextMenuPolicy(Qt::CustomContextMenu); - connect(aa_status_button, &QPushButton::customContextMenuRequested, - [this](const QPoint& menu_location) { - QMenu context_menu; - for (auto const& aa_text_pair : ConfigurationShared::anti_aliasing_texts_map) { - context_menu.addAction(aa_text_pair.second, [this, aa_text_pair] { - Settings::values.anti_aliasing.SetValue(aa_text_pair.first); - UpdateAAText(); - }); - } - context_menu.exec(aa_status_button->mapToGlobal(menu_location)); - aa_status_button->repaint(); - }); - statusBar()->insertPermanentWidget(0, aa_status_button); - - // Setup Filter button - filter_status_button = new QPushButton(); - filter_status_button->setObjectName(QStringLiteral("TogglableStatusBarButton")); - filter_status_button->setFocusPolicy(Qt::NoFocus); - connect(filter_status_button, &QPushButton::clicked, this, - &GMainWindow::OnToggleAdaptingFilter); - UpdateFilterText(); - filter_status_button->setCheckable(true); - filter_status_button->setChecked(true); - filter_status_button->setContextMenuPolicy(Qt::CustomContextMenu); - connect(filter_status_button, &QPushButton::customContextMenuRequested, - [this](const QPoint& menu_location) { - QMenu context_menu; - for (auto const& filter_text_pair : ConfigurationShared::scaling_filter_texts_map) { - context_menu.addAction(filter_text_pair.second, [this, filter_text_pair] { - Settings::values.scaling_filter.SetValue(filter_text_pair.first); - UpdateFilterText(); - }); - } - context_menu.exec(filter_status_button->mapToGlobal(menu_location)); - filter_status_button->repaint(); - }); - statusBar()->insertPermanentWidget(0, filter_status_button); - - // Setup Dock button - dock_status_button = new QPushButton(); - dock_status_button->setObjectName(QStringLiteral("DockingStatusBarButton")); - dock_status_button->setFocusPolicy(Qt::NoFocus); - connect(dock_status_button, &QPushButton::clicked, this, &GMainWindow::OnToggleDockedMode); - dock_status_button->setCheckable(true); - UpdateDockedButton(); - dock_status_button->setContextMenuPolicy(Qt::CustomContextMenu); - connect(dock_status_button, &QPushButton::customContextMenuRequested, - [this](const QPoint& menu_location) { - QMenu context_menu; - - for (auto const& pair : ConfigurationShared::use_docked_mode_texts_map) { - context_menu.addAction(pair.second, [this, &pair] { - if (pair.first != Settings::values.use_docked_mode.GetValue()) { - OnToggleDockedMode(); - } - }); - } - context_menu.exec(dock_status_button->mapToGlobal(menu_location)); - dock_status_button->repaint(); - }); - statusBar()->insertPermanentWidget(0, dock_status_button); - - // Setup GPU Accuracy button - gpu_accuracy_button = new QPushButton(); - gpu_accuracy_button->setObjectName(QStringLiteral("GPUStatusBarButton")); - gpu_accuracy_button->setCheckable(true); - gpu_accuracy_button->setFocusPolicy(Qt::NoFocus); - connect(gpu_accuracy_button, &QPushButton::clicked, this, &GMainWindow::OnToggleGpuAccuracy); - UpdateGPUAccuracyButton(); - gpu_accuracy_button->setContextMenuPolicy(Qt::CustomContextMenu); - connect(gpu_accuracy_button, &QPushButton::customContextMenuRequested, - [this](const QPoint& menu_location) { - QMenu context_menu; - - for (auto const& gpu_accuracy_pair : ConfigurationShared::gpu_accuracy_texts_map) { - if (gpu_accuracy_pair.first == Settings::GpuAccuracy::Extreme) { - continue; - } - context_menu.addAction(gpu_accuracy_pair.second, [this, gpu_accuracy_pair] { - Settings::values.gpu_accuracy.SetValue(gpu_accuracy_pair.first); - UpdateGPUAccuracyButton(); - }); - } - context_menu.exec(gpu_accuracy_button->mapToGlobal(menu_location)); - gpu_accuracy_button->repaint(); - }); - statusBar()->insertPermanentWidget(0, gpu_accuracy_button); - - // Setup Renderer API button - renderer_status_button = new QPushButton(); - renderer_status_button->setObjectName(QStringLiteral("RendererStatusBarButton")); - renderer_status_button->setCheckable(true); - renderer_status_button->setFocusPolicy(Qt::NoFocus); - connect(renderer_status_button, &QPushButton::clicked, this, &GMainWindow::OnToggleGraphicsAPI); - UpdateAPIText(); - renderer_status_button->setCheckable(true); - renderer_status_button->setChecked(Settings::values.renderer_backend.GetValue() == - Settings::RendererBackend::Vulkan); - renderer_status_button->setContextMenuPolicy(Qt::CustomContextMenu); - connect(renderer_status_button, &QPushButton::customContextMenuRequested, - [this](const QPoint& menu_location) { - QMenu context_menu; - - for (auto const& renderer_backend_pair : - ConfigurationShared::renderer_backend_texts_map) { - if (renderer_backend_pair.first == Settings::RendererBackend::Null) { - continue; - } - context_menu.addAction( - renderer_backend_pair.second, [this, renderer_backend_pair] { - Settings::values.renderer_backend.SetValue(renderer_backend_pair.first); - UpdateAPIText(); - }); - } - context_menu.exec(renderer_status_button->mapToGlobal(menu_location)); - renderer_status_button->repaint(); - }); - statusBar()->insertPermanentWidget(0, renderer_status_button); - - statusBar()->setVisible(true); - setStyleSheet(QStringLiteral("QStatusBar::item{border: none;}")); -} - -void GMainWindow::InitializeDebugWidgets() { - QMenu* debug_menu = ui->menu_View_Debugging; - -#if MICROPROFILE_ENABLED - microProfileDialog = new MicroProfileDialog(this); - microProfileDialog->hide(); - debug_menu->addAction(microProfileDialog->toggleViewAction()); -#endif - - waitTreeWidget = new WaitTreeWidget(*system, this); - addDockWidget(Qt::LeftDockWidgetArea, waitTreeWidget); - waitTreeWidget->hide(); - debug_menu->addAction(waitTreeWidget->toggleViewAction()); - - controller_dialog = new ControllerDialog(system->HIDCore(), input_subsystem, this); - controller_dialog->hide(); - debug_menu->addAction(controller_dialog->toggleViewAction()); - - connect(this, &GMainWindow::EmulationStarting, waitTreeWidget, - &WaitTreeWidget::OnEmulationStarting); - connect(this, &GMainWindow::EmulationStopping, waitTreeWidget, - &WaitTreeWidget::OnEmulationStopping); -} - -void GMainWindow::InitializeRecentFileMenuActions() { - for (int i = 0; i < max_recent_files_item; ++i) { - actions_recent_files[i] = new QAction(this); - actions_recent_files[i]->setVisible(false); - connect(actions_recent_files[i], &QAction::triggered, this, &GMainWindow::OnMenuRecentFile); - - ui->menu_recent_files->addAction(actions_recent_files[i]); - } - ui->menu_recent_files->addSeparator(); - QAction* action_clear_recent_files = new QAction(this); - action_clear_recent_files->setText(tr("&Clear Recent Files")); - connect(action_clear_recent_files, &QAction::triggered, this, [this] { - UISettings::values.recent_files.clear(); - UpdateRecentFiles(); - }); - ui->menu_recent_files->addAction(action_clear_recent_files); - - UpdateRecentFiles(); -} - -void GMainWindow::LinkActionShortcut(QAction* action, const QString& action_name, - const bool tas_allowed) { - static const auto main_window = std::string("Main Window"); - action->setShortcut(hotkey_registry.GetKeySequence(main_window, action_name.toStdString())); - action->setShortcutContext( - hotkey_registry.GetShortcutContext(main_window, action_name.toStdString())); - action->setAutoRepeat(false); - - this->addAction(action); - - auto* controller = system->HIDCore().GetEmulatedController(Core::HID::NpadIdType::Player1); - const auto* controller_hotkey = - hotkey_registry.GetControllerHotkey(main_window, action_name.toStdString(), controller); - connect( - controller_hotkey, &ControllerShortcut::Activated, this, - [action, tas_allowed, this] { - auto [tas_status, current_tas_frame, total_tas_frames] = - input_subsystem->GetTas()->GetStatus(); - if (tas_allowed || tas_status == InputCommon::TasInput::TasState::Stopped) { - 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/Remove Amiibo")); - LinkActionShortcut(ui->action_Exit, QStringLiteral("Exit yuzu")); - LinkActionShortcut(ui->action_Restart, QStringLiteral("Restart Emulation")); - LinkActionShortcut(ui->action_Pause, QStringLiteral("Continue/Pause Emulation")); - LinkActionShortcut(ui->action_Stop, QStringLiteral("Stop Emulation")); - LinkActionShortcut(ui->action_Show_Filter_Bar, QStringLiteral("Toggle Filter Bar")); - LinkActionShortcut(ui->action_Show_Status_Bar, QStringLiteral("Toggle Status Bar")); - LinkActionShortcut(ui->action_Fullscreen, QStringLiteral("Fullscreen")); - LinkActionShortcut(ui->action_Capture_Screenshot, QStringLiteral("Capture Screenshot")); - LinkActionShortcut(ui->action_TAS_Start, QStringLiteral("TAS Start/Stop"), true); - LinkActionShortcut(ui->action_TAS_Record, QStringLiteral("TAS Record"), true); - LinkActionShortcut(ui->action_TAS_Reset, QStringLiteral("TAS Reset"), true); - LinkActionShortcut(ui->action_View_Lobby, - QStringLiteral("Multiplayer Browse Public Game Lobby")); - LinkActionShortcut(ui->action_Start_Room, QStringLiteral("Multiplayer Create Room")); - LinkActionShortcut(ui->action_Connect_To_Room, - QStringLiteral("Multiplayer Direct Connect to Room")); - LinkActionShortcut(ui->action_Show_Room, QStringLiteral("Multiplayer Show Current Room")); - LinkActionShortcut(ui->action_Leave_Room, QStringLiteral("Multiplayer Leave Room")); - - static const QString main_window = QStringLiteral("Main Window"); - const auto connect_shortcut = [&]<typename Fn>(const QString& action_name, const Fn& function) { - const auto* hotkey = - hotkey_registry.GetHotkey(main_window.toStdString(), action_name.toStdString(), this); - auto* controller = system->HIDCore().GetEmulatedController(Core::HID::NpadIdType::Player1); - const auto* controller_hotkey = hotkey_registry.GetControllerHotkey( - main_window.toStdString(), action_name.toStdString(), controller); - connect(hotkey, &QShortcut::activated, this, function); - connect(controller_hotkey, &ControllerShortcut::Activated, this, function, - Qt::QueuedConnection); - }; - - connect_shortcut(QStringLiteral("Exit Fullscreen"), [&] { - if (emulation_running && ui->action_Fullscreen->isChecked()) { - ui->action_Fullscreen->setChecked(false); - ToggleFullscreen(); - } - }); - connect_shortcut(QStringLiteral("Change Adapting Filter"), - &GMainWindow::OnToggleAdaptingFilter); - connect_shortcut(QStringLiteral("Change Docked Mode"), &GMainWindow::OnToggleDockedMode); - connect_shortcut(QStringLiteral("Change GPU Accuracy"), &GMainWindow::OnToggleGpuAccuracy); - connect_shortcut(QStringLiteral("Audio Mute/Unmute"), &GMainWindow::OnMute); - connect_shortcut(QStringLiteral("Audio Volume Down"), &GMainWindow::OnDecreaseVolume); - connect_shortcut(QStringLiteral("Audio Volume Up"), &GMainWindow::OnIncreaseVolume); - connect_shortcut(QStringLiteral("Toggle Framerate Limit"), [] { - Settings::values.use_speed_limit.SetValue(!Settings::values.use_speed_limit.GetValue()); - }); - connect_shortcut(QStringLiteral("Toggle Renderdoc Capture"), [this] { - if (Settings::values.enable_renderdoc_hotkey) { - system->GetRenderdocAPI().ToggleCapture(); - } - }); - connect_shortcut(QStringLiteral("Toggle Mouse Panning"), [&] { - Settings::values.mouse_panning = !Settings::values.mouse_panning; - if (Settings::values.mouse_panning) { - render_window->installEventFilter(render_window); - render_window->setAttribute(Qt::WA_Hover, true); - } - }); -} - -void GMainWindow::SetDefaultUIGeometry() { - // geometry: 53% of the window contents are in the upper screen half, 47% in the lower half - const QRect screenRect = QGuiApplication::primaryScreen()->geometry(); - - const int w = screenRect.width() * 2 / 3; - const int h = screenRect.height() * 2 / 3; - const int x = (screenRect.x() + screenRect.width()) / 2 - w / 2; - const int y = (screenRect.y() + screenRect.height()) / 2 - h * 53 / 100; - - setGeometry(x, y, w, h); -} - -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); -#if MICROPROFILE_ENABLED - microProfileDialog->restoreGeometry(UISettings::values.microprofile_geometry); - microProfileDialog->setVisible(UISettings::values.microprofile_visible.GetValue()); -#endif - - game_list->LoadInterfaceLayout(); - - ui->action_Single_Window_Mode->setChecked(UISettings::values.single_window_mode.GetValue()); - ToggleWindowMode(); - - ui->action_Fullscreen->setChecked(UISettings::values.fullscreen.GetValue()); - - ui->action_Display_Dock_Widget_Headers->setChecked( - UISettings::values.display_titlebar.GetValue()); - OnDisplayTitleBars(ui->action_Display_Dock_Widget_Headers->isChecked()); - - ui->action_Show_Filter_Bar->setChecked(UISettings::values.show_filter_bar.GetValue()); - game_list->SetFilterVisible(ui->action_Show_Filter_Bar->isChecked()); - - ui->action_Show_Status_Bar->setChecked(UISettings::values.show_status_bar.GetValue()); - statusBar()->setVisible(ui->action_Show_Status_Bar->isChecked()); - Debugger::ToggleConsole(); -} - -void GMainWindow::OnAppFocusStateChanged(Qt::ApplicationState state) { - if (state != Qt::ApplicationHidden && state != Qt::ApplicationInactive && - state != Qt::ApplicationActive) { - LOG_DEBUG(Frontend, "ApplicationState unusual flag: {} ", state); - } - if (!emulation_running) { - return; - } - if (UISettings::values.pause_when_in_background) { - if (emu_thread->IsRunning() && - (state & (Qt::ApplicationHidden | Qt::ApplicationInactive))) { - auto_paused = true; - OnPauseGame(); - } else if (!emu_thread->IsRunning() && auto_paused && state == Qt::ApplicationActive) { - auto_paused = false; - OnStartGame(); - } - } - if (UISettings::values.mute_when_in_background) { - if (!Settings::values.audio_muted && - (state & (Qt::ApplicationHidden | Qt::ApplicationInactive))) { - Settings::values.audio_muted = true; - auto_muted = true; - } else if (auto_muted && state == Qt::ApplicationActive) { - Settings::values.audio_muted = false; - auto_muted = false; - } - UpdateVolumeUI(); - } -} - -void GMainWindow::ConnectWidgetEvents() { - connect(game_list, &GameList::BootGame, this, &GMainWindow::BootGameFromList); - connect(game_list, &GameList::GameChosen, this, &GMainWindow::OnGameListLoadFile); - connect(game_list, &GameList::OpenDirectory, this, &GMainWindow::OnGameListOpenDirectory); - connect(game_list, &GameList::OpenFolderRequested, this, &GMainWindow::OnGameListOpenFolder); - connect(game_list, &GameList::OpenTransferableShaderCacheRequested, this, - &GMainWindow::OnTransferableShaderCacheOpenFile); - connect(game_list, &GameList::RemoveInstalledEntryRequested, this, - &GMainWindow::OnGameListRemoveInstalledEntry); - connect(game_list, &GameList::RemoveFileRequested, this, &GMainWindow::OnGameListRemoveFile); - connect(game_list, &GameList::RemovePlayTimeRequested, this, - &GMainWindow::OnGameListRemovePlayTimeData); - connect(game_list, &GameList::DumpRomFSRequested, this, &GMainWindow::OnGameListDumpRomFS); - connect(game_list, &GameList::VerifyIntegrityRequested, this, - &GMainWindow::OnGameListVerifyIntegrity); - connect(game_list, &GameList::CopyTIDRequested, this, &GMainWindow::OnGameListCopyTID); - connect(game_list, &GameList::NavigateToGamedbEntryRequested, this, - &GMainWindow::OnGameListNavigateToGamedbEntry); - connect(game_list, &GameList::CreateShortcut, this, &GMainWindow::OnGameListCreateShortcut); - connect(game_list, &GameList::AddDirectory, this, &GMainWindow::OnGameListAddDirectory); - 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::SaveConfig, this, &GMainWindow::OnSaveConfig); - - connect(game_list, &GameList::OpenPerGameGeneralRequested, this, - &GMainWindow::OnGameListOpenPerGameProperties); - - connect(this, &GMainWindow::UpdateInstallProgress, this, - &GMainWindow::IncrementInstallProgress); - - connect(this, &GMainWindow::EmulationStarting, render_window, - &GRenderWindow::OnEmulationStarting); - connect(this, &GMainWindow::EmulationStopping, render_window, - &GRenderWindow::OnEmulationStopping); - - // Software Keyboard Applet - connect(this, &GMainWindow::EmulationStarting, this, &GMainWindow::SoftwareKeyboardExit); - 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() { - const auto connect_menu = [&]<typename Fn>(QAction* action, const Fn& event_fn) { - connect(action, &QAction::triggered, this, event_fn); - // Add actions to this window so that hiding menus in fullscreen won't disable them - addAction(action); - // Add actions to the render window so that they work outside of single window mode - render_window->addAction(action); - }; - - // File - connect_menu(ui->action_Load_File, &GMainWindow::OnMenuLoadFile); - connect_menu(ui->action_Load_Folder, &GMainWindow::OnMenuLoadFolder); - connect_menu(ui->action_Install_File_NAND, &GMainWindow::OnMenuInstallToNAND); - connect_menu(ui->action_Exit, &QMainWindow::close); - connect_menu(ui->action_Load_Amiibo, &GMainWindow::OnLoadAmiibo); - - // Emulation - connect_menu(ui->action_Pause, &GMainWindow::OnPauseContinueGame); - connect_menu(ui->action_Stop, &GMainWindow::OnStopGame); - connect_menu(ui->action_Report_Compatibility, &GMainWindow::OnMenuReportCompatibility); - connect_menu(ui->action_Open_Mods_Page, &GMainWindow::OnOpenModsPage); - connect_menu(ui->action_Open_Quickstart_Guide, &GMainWindow::OnOpenQuickstartGuide); - connect_menu(ui->action_Open_FAQ, &GMainWindow::OnOpenFAQ); - connect_menu(ui->action_Restart, &GMainWindow::OnRestartGame); - connect_menu(ui->action_Configure, &GMainWindow::OnConfigure); - connect_menu(ui->action_Configure_Current_Game, &GMainWindow::OnConfigurePerGame); - - // View - connect_menu(ui->action_Fullscreen, &GMainWindow::ToggleFullscreen); - connect_menu(ui->action_Single_Window_Mode, &GMainWindow::ToggleWindowMode); - connect_menu(ui->action_Display_Dock_Widget_Headers, &GMainWindow::OnDisplayTitleBars); - connect_menu(ui->action_Show_Filter_Bar, &GMainWindow::OnToggleFilterBar); - connect_menu(ui->action_Show_Status_Bar, &GMainWindow::OnToggleStatusBar); - - connect_menu(ui->action_Reset_Window_Size_720, &GMainWindow::ResetWindowSize720); - connect_menu(ui->action_Reset_Window_Size_900, &GMainWindow::ResetWindowSize900); - connect_menu(ui->action_Reset_Window_Size_1080, &GMainWindow::ResetWindowSize1080); - ui->menu_Reset_Window_Size->addActions({ui->action_Reset_Window_Size_720, - 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_Load_Album, &GMainWindow::OnAlbum); - connect_menu(ui->action_Load_Cabinet_Nickname_Owner, - [this]() { OnCabinet(Service::NFP::CabinetMode::StartNicknameAndOwnerSettings); }); - connect_menu(ui->action_Load_Cabinet_Eraser, - [this]() { OnCabinet(Service::NFP::CabinetMode::StartGameDataEraser); }); - connect_menu(ui->action_Load_Cabinet_Restorer, - [this]() { OnCabinet(Service::NFP::CabinetMode::StartRestorer); }); - connect_menu(ui->action_Load_Cabinet_Formatter, - [this]() { OnCabinet(Service::NFP::CabinetMode::StartFormatter); }); - connect_menu(ui->action_Load_Mii_Edit, &GMainWindow::OnMiiEdit); - connect_menu(ui->action_Open_Controller_Menu, &GMainWindow::OnOpenControllerMenu); - connect_menu(ui->action_Capture_Screenshot, &GMainWindow::OnCaptureScreenshot); - - // TAS - connect_menu(ui->action_TAS_Start, &GMainWindow::OnTasStartStop); - connect_menu(ui->action_TAS_Record, &GMainWindow::OnTasRecord); - connect_menu(ui->action_TAS_Reset, &GMainWindow::OnTasReset); - connect_menu(ui->action_Configure_Tas, &GMainWindow::OnConfigureTas); - - // Help - connect_menu(ui->action_Open_yuzu_Folder, &GMainWindow::OnOpenYuzuFolder); - connect_menu(ui->action_Verify_installed_contents, &GMainWindow::OnVerifyInstalledContents); - connect_menu(ui->action_Install_Firmware, &GMainWindow::OnInstallFirmware); - connect_menu(ui->action_Install_Keys, &GMainWindow::OnInstallDecryptionKeys); - connect_menu(ui->action_About, &GMainWindow::OnAbout); -} - -void GMainWindow::UpdateMenuState() { - const bool is_paused = emu_thread == nullptr || !emu_thread->IsRunning(); - const bool is_firmware_available = CheckFirmwarePresence(); - - const std::array running_actions{ - ui->action_Stop, - ui->action_Restart, - ui->action_Configure_Current_Game, - ui->action_Report_Compatibility, - ui->action_Load_Amiibo, - ui->action_Pause, - }; - - const std::array applet_actions{ui->action_Load_Album, - ui->action_Load_Cabinet_Nickname_Owner, - ui->action_Load_Cabinet_Eraser, - ui->action_Load_Cabinet_Restorer, - ui->action_Load_Cabinet_Formatter, - ui->action_Load_Mii_Edit, - ui->action_Open_Controller_Menu}; - - for (QAction* action : running_actions) { - action->setEnabled(emulation_running); - } - - ui->action_Install_Firmware->setEnabled(!emulation_running); - ui->action_Install_Keys->setEnabled(!emulation_running); - - for (QAction* action : applet_actions) { - action->setEnabled(is_firmware_available && !emulation_running); - } - - ui->action_Capture_Screenshot->setEnabled(emulation_running && !is_paused); - - if (emulation_running && is_paused) { - ui->action_Pause->setText(tr("&Continue")); - } else { - ui->action_Pause->setText(tr("&Pause")); - } - - multiplayer_state->UpdateNotificationStatus(); -} - -void GMainWindow::OnDisplayTitleBars(bool show) { - QList<QDockWidget*> widgets = findChildren<QDockWidget*>(); - - if (show) { - for (QDockWidget* widget : widgets) { - QWidget* old = widget->titleBarWidget(); - widget->setTitleBarWidget(nullptr); - if (old != nullptr) - delete old; - } - } else { - for (QDockWidget* widget : widgets) { - QWidget* old = widget->titleBarWidget(); - widget->setTitleBarWidget(new QWidget()); - if (old != nullptr) - delete old; - } - } -} - -void GMainWindow::SetupPrepareForSleep() { -#ifdef __unix__ - 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 // __unix__ -} - -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; - OnStartGame(); - } - } -} - -#ifdef __unix__ -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 // __unix__ - -void GMainWindow::PreventOSSleep() { -#ifdef _WIN32 - SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED | ES_DISPLAY_REQUIRED); -#elif defined(HAVE_SDL2) - SDL_DisableScreenSaver(); -#endif -} - -void GMainWindow::AllowOSSleep() { -#ifdef _WIN32 - SetThreadExecutionState(ES_CONTINUOUS); -#elif defined(HAVE_SDL2) - SDL_EnableScreenSaver(); -#endif -} - -bool GMainWindow::LoadROM(const QString& filename, Service::AM::FrontendAppletParameters params) { - // Shutdown previous session if the emu thread is still active... - if (emu_thread != nullptr) { - ShutdownGame(); - } - - if (!render_window->InitRenderTarget()) { - return false; - } - - system->SetFilesystem(vfs); - - if (params.launch_type == Service::AM::LaunchType::FrontendInitiated) { - system->GetUserChannel().clear(); - } - - system->SetFrontendAppletSet({ - std::make_unique<QtAmiiboSettings>(*this), // Amiibo Settings - (UISettings::values.controller_applet_disabled.GetValue() == true) - ? nullptr - : 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 - std::make_unique<QtSoftwareKeyboard>(*this), // Software Keyboard - std::make_unique<QtWebBrowser>(*this), // Web Browser - }); - - const Core::SystemResultStatus result{ - system->Load(*render_window, filename.toStdString(), params)}; - - const auto drd_callout = (UISettings::values.callout_flags.GetValue() & - static_cast<u32>(CalloutFlag::DRDDeprecation)) == 0; - - if (result == Core::SystemResultStatus::Success && - system->GetAppLoader().GetFileType() == Loader::FileType::DeconstructedRomDirectory && - drd_callout) { - UISettings::values.callout_flags = UISettings::values.callout_flags.GetValue() | - static_cast<u32>(CalloutFlag::DRDDeprecation); - QMessageBox::warning( - this, tr("Warning Outdated Game Format"), - tr("You are using the deconstructed ROM directory format for this game, which is an " - "outdated format that has been superseded by others such as NCA, NAX, XCI, or " - "NSP. Deconstructed ROM directories lack icons, metadata, and update " - "support.<br><br>For an explanation of the various Switch formats yuzu supports, <a " - "href='https://yuzu-emu.org/wiki/overview-of-switch-game-formats'>check out our " - "wiki</a>. This message will not be shown again.")); - } - - if (result != Core::SystemResultStatus::Success) { - switch (result) { - case Core::SystemResultStatus::ErrorGetLoader: - LOG_CRITICAL(Frontend, "Failed to obtain loader for {}!", filename.toStdString()); - QMessageBox::critical(this, tr("Error while loading ROM!"), - tr("The ROM format is not supported.")); - break; - case Core::SystemResultStatus::ErrorVideoCore: - QMessageBox::critical( - this, tr("An error occurred initializing the video core."), - tr("yuzu has encountered an error while running the video core. " - "This is usually caused by outdated GPU drivers, including integrated ones. " - "Please see the log for more details. " - "For more information on accessing the log, please see the following page: " - "<a href='https://yuzu-emu.org/help/reference/log-files/'>" - "How to Upload the Log File</a>. ")); - break; - default: - if (result > Core::SystemResultStatus::ErrorLoader) { - const u16 loader_id = static_cast<u16>(Core::SystemResultStatus::ErrorLoader); - const u16 error_id = static_cast<u16>(result) - loader_id; - const std::string error_code = fmt::format("({:04X}-{:04X})", loader_id, error_id); - LOG_CRITICAL(Frontend, "Failed to load ROM! {}", error_code); - - const auto title = - tr("Error while loading ROM! %1", "%1 signifies a numeric error code.") - .arg(QString::fromStdString(error_code)); - const auto description = - tr("%1<br>Please follow <a href='https://yuzu-emu.org/help/quickstart/'>the " - "yuzu quickstart guide</a> to redump your files.<br>You can refer " - "to the yuzu wiki</a> or the yuzu Discord</a> for help.", - "%1 signifies an error string.") - .arg(QString::fromStdString( - GetResultStatusString(static_cast<Loader::ResultStatus>(error_id)))); - - QMessageBox::critical(this, title, description); - } else { - QMessageBox::critical( - this, tr("Error while loading ROM!"), - tr("An unknown error occurred. Please see the log for more details.")); - } - break; - } - return false; - } - current_game_path = filename; - - system->TelemetrySession().AddField(Common::Telemetry::FieldType::App, "Frontend", "Qt"); - return true; -} - -bool GMainWindow::SelectAndSetCurrentUser( - const Core::Frontend::ProfileSelectParameters& parameters) { - QtProfileSelectionDialog dialog(*system, this, parameters); - dialog.setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | - Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint); - dialog.setWindowModality(Qt::WindowModal); - - if (dialog.exec() == QDialog::Rejected) { - return false; - } - - Settings::values.current_user = dialog.GetIndex(); - return true; -} - -void GMainWindow::ConfigureFilesystemProvider(const std::string& filepath) { - // Ensure all NCAs are registered before launching the game - const auto file = vfs->OpenFile(filepath, FileSys::OpenMode::Read); - if (!file) { - return; - } - - auto loader = Loader::GetLoader(*system, file); - if (!loader) { - return; - } - - const auto file_type = loader->GetFileType(); - if (file_type == Loader::FileType::Unknown || file_type == Loader::FileType::Error) { - return; - } - - u64 program_id = 0; - const auto res2 = loader->ReadProgramId(program_id); - if (res2 == Loader::ResultStatus::Success && file_type == Loader::FileType::NCA) { - provider->AddEntry(FileSys::TitleType::Application, - FileSys::GetCRTypeFromNCAType(FileSys::NCA{file}.GetType()), program_id, - file); - } else if (res2 == Loader::ResultStatus::Success && - (file_type == Loader::FileType::XCI || file_type == Loader::FileType::NSP)) { - const auto nsp = file_type == Loader::FileType::NSP - ? std::make_shared<FileSys::NSP>(file) - : FileSys::XCI{file}.GetSecurePartitionNSP(); - for (const auto& title : nsp->GetNCAs()) { - for (const auto& entry : title.second) { - provider->AddEntry(entry.first.first, entry.first.second, title.first, - entry.second->GetBaseFile()); - } - } - } -} - -void GMainWindow::BootGame(const QString& filename, Service::AM::FrontendAppletParameters params, - StartGameType type) { - LOG_INFO(Frontend, "yuzu starting..."); - - if (params.program_id == 0 || - params.program_id > static_cast<u64>(Service::AM::AppletProgramId::MaxProgramId)) { - StoreRecentFile(filename); // Put the filename on top of the list - } - - // Save configurations - UpdateUISettings(); - game_list->SaveInterfaceLayout(); - config->SaveAllValues(); - - u64 title_id{0}; - - last_filename_booted = filename; - - ConfigureFilesystemProvider(filename.toStdString()); - const auto v_file = Core::GetGameFileFromPath(vfs, filename.toUtf8().constData()); - const auto loader = Loader::GetLoader(*system, v_file, params.program_id, params.program_index); - - if (loader != nullptr && loader->ReadProgramId(title_id) == Loader::ResultStatus::Success && - type == StartGameType::Normal) { - // Load per game settings - 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); - QtConfig per_game_config(config_file_name, Config::ConfigType::PerGameConfig); - system->HIDCore().ReloadInputDevices(); - system->ApplySettings(); - } - - Settings::LogSettings(); - - if (UISettings::values.select_user_on_boot && !user_flag_cmd_line) { - const Core::Frontend::ProfileSelectParameters parameters{ - .mode = Service::AM::Frontend::UiMode::UserSelector, - .invalid_uid_list = {}, - .display_options = {}, - .purpose = Service::AM::Frontend::UserSelectionPurpose::General, - }; - if (SelectAndSetCurrentUser(parameters) == false) { - return; - } - } - - // If the user specifies -u (successfully) on the cmd line, don't prompt for a user on first - // game startup only. If the user stops emulation and starts a new one, go back to the expected - // behavior of asking. - user_flag_cmd_line = false; - - if (!LoadROM(filename, params)) { - return; - } - - system->SetShuttingDown(false); - game_list->setDisabled(true); - - // Create and start the emulation thread - emu_thread = std::make_unique<EmuThread>(*system); - emit EmulationStarting(emu_thread.get()); - emu_thread->start(); - - // 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_); }); - - system->RegisterExitCallback([this] { - emu_thread->ForceStop(); - render_window->Exit(); - }); - - connect(render_window, &GRenderWindow::Closed, this, &GMainWindow::OnStopGame); - connect(render_window, &GRenderWindow::MouseActivity, this, &GMainWindow::OnMouseActivity); - // BlockingQueuedConnection is important here, it makes sure we've finished refreshing our views - // before the CPU continues - connect(emu_thread.get(), &EmuThread::DebugModeEntered, waitTreeWidget, - &WaitTreeWidget::OnDebugModeEntered, Qt::BlockingQueuedConnection); - connect(emu_thread.get(), &EmuThread::DebugModeLeft, waitTreeWidget, - &WaitTreeWidget::OnDebugModeLeft, Qt::BlockingQueuedConnection); - - connect(emu_thread.get(), &EmuThread::LoadProgress, loading_screen, - &LoadingScreen::OnLoadProgress, Qt::QueuedConnection); - - // Update the GUI - UpdateStatusButtons(); - if (ui->action_Single_Window_Mode->isChecked()) { - game_list->hide(); - game_list_placeholder->hide(); - } - status_bar_update_timer.start(500); - renderer_status_button->setDisabled(true); - - if (UISettings::values.hide_mouse || Settings::values.mouse_panning) { - render_window->installEventFilter(render_window); - render_window->setAttribute(Qt::WA_Hover, true); - } - - if (UISettings::values.hide_mouse) { - mouse_hide_timer.start(); - } - - render_window->InitializeCamera(); - - std::string title_name; - std::string title_version; - const auto res = system->GetGameName(title_name); - - const auto metadata = [this, title_id] { - const FileSys::PatchManager pm(title_id, system->GetFileSystemController(), - system->GetContentProvider()); - return pm.GetControlMetadata(); - }(); - if (metadata.first != nullptr) { - title_version = metadata.first->GetVersionString(); - title_name = metadata.first->GetApplicationName(); - } - if (res != Loader::ResultStatus::Success || title_name.empty()) { - title_name = Common::FS::PathToUTF8String( - std::filesystem::path{Common::U16StringFromBuffer(filename.utf16(), filename.size())} - .filename()); - } - const bool is_64bit = system->Kernel().ApplicationProcess()->Is64Bit(); - const auto instruction_set_suffix = is_64bit ? tr("(64-bit)") : tr("(32-bit)"); - title_name = tr("%1 %2", "%1 is the title name. %2 indicates if the title is 64-bit or 32-bit") - .arg(QString::fromStdString(title_name), instruction_set_suffix) - .toStdString(); - LOG_INFO(Frontend, "Booting game: {:016X} | {} | {}", title_id, title_name, title_version); - const auto gpu_vendor = system->GPU().Renderer().GetDeviceVendor(); - UpdateWindowTitle(title_name, title_version, gpu_vendor); - - loading_screen->Prepare(system->GetAppLoader()); - loading_screen->show(); - - emulation_running = true; - if (ui->action_Fullscreen->isChecked()) { - ShowFullscreen(); - } - OnStartGame(); -} - -void GMainWindow::BootGameFromList(const QString& filename, StartGameType with_config) { - BootGame(filename, ApplicationAppletParameters(), with_config); -} - -bool GMainWindow::OnShutdownBegin() { - if (!emulation_running) { - return false; - } - - if (ui->action_Fullscreen->isChecked()) { - HideFullscreen(); - } - - AllowOSSleep(); - - // Disable unlimited frame rate - Settings::values.use_speed_limit.SetValue(true); - - if (system->IsShuttingDown()) { - return false; - } - - system->SetShuttingDown(true); - discord_rpc->Pause(); - - RequestGameExit(); - emu_thread->disconnect(); - emu_thread->SetRunning(true); - - emit EmulationStopping(); - - int shutdown_time = 1000; - - if (system->DebuggerEnabled()) { - shutdown_time = 0; - } else if (system->GetExitLocked()) { - shutdown_time = 5000; - } - - shutdown_timer.setSingleShot(true); - shutdown_timer.start(shutdown_time); - connect(&shutdown_timer, &QTimer::timeout, this, &GMainWindow::OnEmulationStopTimeExpired); - connect(emu_thread.get(), &QThread::finished, this, &GMainWindow::OnEmulationStopped); - - // Disable everything to prevent anything from being triggered here - ui->action_Pause->setEnabled(false); - ui->action_Restart->setEnabled(false); - ui->action_Stop->setEnabled(false); - - return true; -} - -void GMainWindow::OnShutdownBeginDialog() { - shutdown_dialog = new OverlayDialog(this, *system, QString{}, tr("Closing software..."), - QString{}, QString{}, Qt::AlignHCenter | Qt::AlignVCenter); - shutdown_dialog->open(); -} - -void GMainWindow::OnEmulationStopTimeExpired() { - if (emu_thread) { - emu_thread->ForceStop(); - } -} - -void GMainWindow::OnEmulationStopped() { - shutdown_timer.stop(); - if (emu_thread) { - emu_thread->disconnect(); - emu_thread->wait(); - emu_thread.reset(); - } - - if (shutdown_dialog) { - shutdown_dialog->deleteLater(); - shutdown_dialog = nullptr; - } - - emulation_running = false; - - discord_rpc->Update(); - -#ifdef __unix__ - Common::Linux::StopGamemode(); -#endif - - // The emulation is stopped, so closing the window or not does not matter anymore - disconnect(render_window, &GRenderWindow::Closed, this, &GMainWindow::OnStopGame); - - // Update the GUI - UpdateMenuState(); - - render_window->hide(); - loading_screen->hide(); - loading_screen->Clear(); - if (game_list->IsEmpty()) { - game_list_placeholder->show(); - } else { - game_list->show(); - } - game_list->SetFilterFocus(); - tas_label->clear(); - input_subsystem->GetTas()->Stop(); - OnTasStateChanged(); - render_window->FinalizeCamera(); - - system->GetFrontendAppletHolder().SetCurrentAppletId(Service::AM::AppletId::None); - - // Enable all controllers - system->HIDCore().SetSupportedStyleTag({Core::HID::NpadStyleSet::All}); - - render_window->removeEventFilter(render_window); - render_window->setAttribute(Qt::WA_Hover, false); - - UpdateWindowTitle(); - - // Disable status bar updates - status_bar_update_timer.stop(); - shader_building_label->setVisible(false); - res_scale_label->setVisible(false); - emu_speed_label->setVisible(false); - game_fps_label->setVisible(false); - emu_frametime_label->setVisible(false); - renderer_status_button->setEnabled(!UISettings::values.has_broken_vulkan); - - if (!firmware_label->text().isEmpty()) { - firmware_label->setVisible(true); - } - - current_game_path.clear(); - - // When closing the game, destroy the GLWindow to clear the context after the game is closed - render_window->ReleaseRenderTarget(); - - // Enable game list - game_list->setEnabled(true); - - Settings::RestoreGlobalState(system->IsPoweredOn()); - system->HIDCore().ReloadInputDevices(); - UpdateStatusButtons(); -} - -void GMainWindow::ShutdownGame() { - if (!emulation_running) { - return; - } - - play_time_manager->Stop(); - OnShutdownBegin(); - OnEmulationStopTimeExpired(); - OnEmulationStopped(); -} - -void GMainWindow::StoreRecentFile(const QString& filename) { - UISettings::values.recent_files.prepend(filename); - UISettings::values.recent_files.removeDuplicates(); - while (UISettings::values.recent_files.size() > max_recent_files_item) { - UISettings::values.recent_files.removeLast(); - } - - UpdateRecentFiles(); -} - -void GMainWindow::UpdateRecentFiles() { - const int num_recent_files = - 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( - QFileInfo(UISettings::values.recent_files[i]).fileName()); - actions_recent_files[i]->setText(text); - actions_recent_files[i]->setData(UISettings::values.recent_files[i]); - actions_recent_files[i]->setToolTip(UISettings::values.recent_files[i]); - actions_recent_files[i]->setVisible(true); - } - - for (int j = num_recent_files; j < max_recent_files_item; ++j) { - actions_recent_files[j]->setVisible(false); - } - - // Enable the recent files menu if the list isn't empty - ui->menu_recent_files->setEnabled(num_recent_files != 0); -} - -void GMainWindow::OnGameListLoadFile(QString game_path, u64 program_id) { - auto params = ApplicationAppletParameters(); - params.program_id = program_id; - - BootGame(game_path, params); -} - -void GMainWindow::OnGameListOpenFolder(u64 program_id, GameListOpenTarget target, - const std::string& game_path) { - std::filesystem::path path; - QString open_target; - - const auto [user_save_size, device_save_size] = [this, &game_path, &program_id] { - const FileSys::PatchManager pm{program_id, system->GetFileSystemController(), - system->GetContentProvider()}; - const auto control = pm.GetControlMetadata().first; - if (control != nullptr) { - return std::make_pair(control->GetDefaultNormalSaveSize(), - control->GetDeviceSaveDataSize()); - } else { - const auto file = Core::GetGameFileFromPath(vfs, game_path); - const auto loader = Loader::GetLoader(*system, file); - - FileSys::NACP nacp{}; - loader->ReadControlData(nacp); - return std::make_pair(nacp.GetDefaultNormalSaveSize(), nacp.GetDeviceSaveDataSize()); - } - }(); - - const bool has_user_save{user_save_size > 0}; - const bool has_device_save{device_save_size > 0}; - - ASSERT_MSG(has_user_save != has_device_save, "Game uses both user and device savedata?"); - - switch (target) { - case GameListOpenTarget::SaveData: { - open_target = tr("Save Data"); - const auto nand_dir = Common::FS::GetYuzuPath(Common::FS::YuzuPath::NANDDir); - auto vfs_nand_dir = - vfs->OpenDirectory(Common::FS::PathToUTF8String(nand_dir), FileSys::OpenMode::Read); - - if (has_user_save) { - // User save data - const auto select_profile = [this] { - const Core::Frontend::ProfileSelectParameters parameters{ - .mode = Service::AM::Frontend::UiMode::UserSelector, - .invalid_uid_list = {}, - .display_options = {}, - .purpose = Service::AM::Frontend::UserSelectionPurpose::General, - }; - QtProfileSelectionDialog dialog(*system, this, parameters); - dialog.setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | - Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint); - dialog.setWindowModality(Qt::WindowModal); - - if (dialog.exec() == QDialog::Rejected) { - return -1; - } - - return dialog.GetIndex(); - }; - - const auto index = select_profile(); - if (index == -1) { - return; - } - - const auto user_id = - system->GetProfileManager().GetUser(static_cast<std::size_t>(index)); - ASSERT(user_id); - - const auto user_save_data_path = FileSys::SaveDataFactory::GetFullPath( - {}, vfs_nand_dir, FileSys::SaveDataSpaceId::User, FileSys::SaveDataType::Account, - program_id, user_id->AsU128(), 0); - - path = Common::FS::ConcatPathSafe(nand_dir, user_save_data_path); - } else { - // Device save data - const auto device_save_data_path = FileSys::SaveDataFactory::GetFullPath( - {}, vfs_nand_dir, FileSys::SaveDataSpaceId::User, FileSys::SaveDataType::Account, - program_id, {}, 0); - - path = Common::FS::ConcatPathSafe(nand_dir, device_save_data_path); - } - - if (!Common::FS::CreateDirs(path)) { - LOG_ERROR(Frontend, "Unable to create the directories for save data"); - } - - break; - } - case GameListOpenTarget::ModData: { - open_target = tr("Mod Data"); - path = Common::FS::GetYuzuPath(Common::FS::YuzuPath::LoadDir) / - fmt::format("{:016X}", program_id); - break; - } - default: - UNIMPLEMENTED(); - break; - } - - const QString qpath = QString::fromStdString(Common::FS::PathToUTF8String(path)); - const QDir dir(qpath); - if (!dir.exists()) { - QMessageBox::warning(this, tr("Error Opening %1 Folder").arg(open_target), - tr("Folder does not exist!")); - return; - } - LOG_INFO(Frontend, "Opening {} path for program_id={:016x}", open_target.toStdString(), - program_id); - QDesktopServices::openUrl(QUrl::fromLocalFile(qpath)); -} - -void GMainWindow::OnTransferableShaderCacheOpenFile(u64 program_id) { - const auto shader_cache_dir = Common::FS::GetYuzuPath(Common::FS::YuzuPath::ShaderDir); - const auto shader_cache_folder_path{shader_cache_dir / fmt::format("{:016x}", program_id)}; - if (!Common::FS::CreateDirs(shader_cache_folder_path)) { - QMessageBox::warning(this, tr("Error Opening Transferable Shader Cache"), - tr("Failed to create the shader cache directory for this title.")); - return; - } - const auto shader_path_string{Common::FS::PathToUTF8String(shader_cache_folder_path)}; - const auto qt_shader_cache_path = QString::fromStdString(shader_path_string); - QDesktopServices::openUrl(QUrl::fromLocalFile(qt_shader_cache_path)); -} - -static bool RomFSRawCopy(size_t total_size, size_t& read_size, QProgressDialog& dialog, - const FileSys::VirtualDir& src, const FileSys::VirtualDir& dest, - bool full) { - if (src == nullptr || dest == nullptr || !src->IsReadable() || !dest->IsWritable()) - return false; - if (dialog.wasCanceled()) - return false; - - std::vector<u8> buffer(CopyBufferSize); - auto last_timestamp = std::chrono::steady_clock::now(); - - const auto QtRawCopy = [&](const FileSys::VirtualFile& src_file, - const FileSys::VirtualFile& dest_file) { - if (src_file == nullptr || dest_file == nullptr) { - return false; - } - if (!dest_file->Resize(src_file->GetSize())) { - return false; - } - - for (std::size_t i = 0; i < src_file->GetSize(); i += buffer.size()) { - if (dialog.wasCanceled()) { - dest_file->Resize(0); - return false; - } - - using namespace std::literals::chrono_literals; - const auto new_timestamp = std::chrono::steady_clock::now(); - - if ((new_timestamp - last_timestamp) > 33ms) { - last_timestamp = new_timestamp; - dialog.setValue( - static_cast<int>(std::min(read_size, total_size) * 100 / total_size)); - QCoreApplication::processEvents(); - } - - const auto read = src_file->Read(buffer.data(), buffer.size(), i); - dest_file->Write(buffer.data(), read, i); - - read_size += read; - } - - return true; - }; - - if (full) { - for (const auto& file : src->GetFiles()) { - const auto out = VfsDirectoryCreateFileWrapper(dest, file->GetName()); - if (!QtRawCopy(file, out)) - return false; - } - } - - for (const auto& dir : src->GetSubdirectories()) { - const auto out = dest->CreateSubdirectory(dir->GetName()); - if (!RomFSRawCopy(total_size, read_size, dialog, dir, out, full)) - return false; - } - - return true; -} - -QString GMainWindow::GetGameListErrorRemoving(InstalledEntryType type) const { - switch (type) { - case InstalledEntryType::Game: - return tr("Error Removing Contents"); - case InstalledEntryType::Update: - return tr("Error Removing Update"); - case InstalledEntryType::AddOnContent: - return tr("Error Removing DLC"); - default: - return QStringLiteral("Error Removing <Invalid Type>"); - } -} -void GMainWindow::OnGameListRemoveInstalledEntry(u64 program_id, InstalledEntryType type) { - const QString entry_question = [type] { - switch (type) { - case InstalledEntryType::Game: - return tr("Remove Installed Game Contents?"); - case InstalledEntryType::Update: - return tr("Remove Installed Game Update?"); - case InstalledEntryType::AddOnContent: - return tr("Remove Installed Game DLC?"); - default: - return QStringLiteral("Remove Installed Game <Invalid Type>?"); - } - }(); - - if (!question(this, tr("Remove Entry"), entry_question, QMessageBox::Yes | QMessageBox::No, - QMessageBox::No)) { - return; - } - - switch (type) { - case InstalledEntryType::Game: - RemoveBaseContent(program_id, type); - [[fallthrough]]; - case InstalledEntryType::Update: - RemoveUpdateContent(program_id, type); - if (type != InstalledEntryType::Game) { - break; - } - [[fallthrough]]; - case InstalledEntryType::AddOnContent: - RemoveAddOnContent(program_id, type); - break; - } - Common::FS::RemoveDirRecursively(Common::FS::GetYuzuPath(Common::FS::YuzuPath::CacheDir) / - "game_list"); - game_list->PopulateAsync(UISettings::values.game_dirs); -} - -void GMainWindow::RemoveBaseContent(u64 program_id, InstalledEntryType type) { - const auto res = - ContentManager::RemoveBaseContent(system->GetFileSystemController(), program_id); - if (res) { - QMessageBox::information(this, tr("Successfully Removed"), - tr("Successfully removed the installed base game.")); - } else { - QMessageBox::warning( - this, GetGameListErrorRemoving(type), - tr("The base game is not installed in the NAND and cannot be removed.")); - } -} - -void GMainWindow::RemoveUpdateContent(u64 program_id, InstalledEntryType type) { - const auto res = ContentManager::RemoveUpdate(system->GetFileSystemController(), program_id); - if (res) { - QMessageBox::information(this, tr("Successfully Removed"), - tr("Successfully removed the installed update.")); - } else { - QMessageBox::warning(this, GetGameListErrorRemoving(type), - tr("There is no update installed for this title.")); - } -} - -void GMainWindow::RemoveAddOnContent(u64 program_id, InstalledEntryType type) { - const size_t count = ContentManager::RemoveAllDLC(*system, program_id); - if (count == 0) { - QMessageBox::warning(this, GetGameListErrorRemoving(type), - tr("There are no DLC installed for this title.")); - return; - } - - QMessageBox::information(this, tr("Successfully Removed"), - tr("Successfully removed %1 installed DLC.").arg(count)); -} - -void GMainWindow::OnGameListRemoveFile(u64 program_id, GameListRemoveTarget target, - const std::string& game_path) { - const QString question = [target] { - switch (target) { - case GameListRemoveTarget::GlShaderCache: - return tr("Delete OpenGL Transferable Shader Cache?"); - case GameListRemoveTarget::VkShaderCache: - return tr("Delete Vulkan Transferable Shader Cache?"); - case GameListRemoveTarget::AllShaderCache: - return tr("Delete All Transferable Shader Caches?"); - case GameListRemoveTarget::CustomConfiguration: - return tr("Remove Custom Game Configuration?"); - case GameListRemoveTarget::CacheStorage: - return tr("Remove Cache Storage?"); - default: - return QString{}; - } - }(); - - if (!GMainWindow::question(this, tr("Remove File"), question, - QMessageBox::Yes | QMessageBox::No, QMessageBox::No)) { - return; - } - - switch (target) { - case GameListRemoveTarget::VkShaderCache: - RemoveVulkanDriverPipelineCache(program_id); - [[fallthrough]]; - case GameListRemoveTarget::GlShaderCache: - RemoveTransferableShaderCache(program_id, target); - break; - case GameListRemoveTarget::AllShaderCache: - RemoveAllTransferableShaderCaches(program_id); - break; - case GameListRemoveTarget::CustomConfiguration: - RemoveCustomConfiguration(program_id, game_path); - break; - case GameListRemoveTarget::CacheStorage: - RemoveCacheStorage(program_id); - break; - } -} - -void GMainWindow::OnGameListRemovePlayTimeData(u64 program_id) { - if (QMessageBox::question(this, tr("Remove Play Time Data"), tr("Reset play time?"), - QMessageBox::Yes | QMessageBox::No, - QMessageBox::No) != QMessageBox::Yes) { - return; - } - - play_time_manager->ResetProgramPlayTime(program_id); - game_list->PopulateAsync(UISettings::values.game_dirs); -} - -void GMainWindow::RemoveTransferableShaderCache(u64 program_id, GameListRemoveTarget target) { - const auto target_file_name = [target] { - switch (target) { - case GameListRemoveTarget::GlShaderCache: - return "opengl.bin"; - case GameListRemoveTarget::VkShaderCache: - return "vulkan.bin"; - default: - return ""; - } - }(); - const auto shader_cache_dir = Common::FS::GetYuzuPath(Common::FS::YuzuPath::ShaderDir); - const auto shader_cache_folder_path = shader_cache_dir / fmt::format("{:016x}", program_id); - const auto target_file = shader_cache_folder_path / target_file_name; - - if (!Common::FS::Exists(target_file)) { - QMessageBox::warning(this, tr("Error Removing Transferable Shader Cache"), - tr("A shader cache for this title does not exist.")); - return; - } - if (Common::FS::RemoveFile(target_file)) { - QMessageBox::information(this, tr("Successfully Removed"), - tr("Successfully removed the transferable shader cache.")); - } else { - QMessageBox::warning(this, tr("Error Removing Transferable Shader Cache"), - tr("Failed to remove the transferable shader cache.")); - } -} - -void GMainWindow::RemoveVulkanDriverPipelineCache(u64 program_id) { - static constexpr std::string_view target_file_name = "vulkan_pipelines.bin"; - - const auto shader_cache_dir = Common::FS::GetYuzuPath(Common::FS::YuzuPath::ShaderDir); - const auto shader_cache_folder_path = shader_cache_dir / fmt::format("{:016x}", program_id); - const auto target_file = shader_cache_folder_path / target_file_name; - - if (!Common::FS::Exists(target_file)) { - return; - } - if (!Common::FS::RemoveFile(target_file)) { - QMessageBox::warning(this, tr("Error Removing Vulkan Driver Pipeline Cache"), - tr("Failed to remove the driver pipeline cache.")); - } -} - -void GMainWindow::RemoveAllTransferableShaderCaches(u64 program_id) { - const auto shader_cache_dir = Common::FS::GetYuzuPath(Common::FS::YuzuPath::ShaderDir); - const auto program_shader_cache_dir = shader_cache_dir / fmt::format("{:016x}", program_id); - - if (!Common::FS::Exists(program_shader_cache_dir)) { - QMessageBox::warning(this, tr("Error Removing Transferable Shader Caches"), - tr("A shader cache for this title does not exist.")); - return; - } - if (Common::FS::RemoveDirRecursively(program_shader_cache_dir)) { - QMessageBox::information(this, tr("Successfully Removed"), - tr("Successfully removed the transferable shader caches.")); - } else { - QMessageBox::warning(this, tr("Error Removing Transferable Shader Caches"), - tr("Failed to remove the transferable shader cache directory.")); - } -} - -void GMainWindow::RemoveCustomConfiguration(u64 program_id, const std::string& game_path) { - const auto file_path = std::filesystem::path(Common::FS::ToU8String(game_path)); - const auto config_file_name = - program_id == 0 ? Common::FS::PathToUTF8String(file_path.filename()).append(".ini") - : fmt::format("{:016X}.ini", program_id); - const auto custom_config_file_path = - Common::FS::GetYuzuPath(Common::FS::YuzuPath::ConfigDir) / "custom" / config_file_name; - - if (!Common::FS::Exists(custom_config_file_path)) { - QMessageBox::warning(this, tr("Error Removing Custom Configuration"), - tr("A custom configuration for this title does not exist.")); - return; - } - - if (Common::FS::RemoveFile(custom_config_file_path)) { - QMessageBox::information(this, tr("Successfully Removed"), - tr("Successfully removed the custom game configuration.")); - } else { - QMessageBox::warning(this, tr("Error Removing Custom Configuration"), - tr("Failed to remove the custom game configuration.")); - } -} - -void GMainWindow::RemoveCacheStorage(u64 program_id) { - const auto nand_dir = Common::FS::GetYuzuPath(Common::FS::YuzuPath::NANDDir); - auto vfs_nand_dir = - vfs->OpenDirectory(Common::FS::PathToUTF8String(nand_dir), FileSys::OpenMode::Read); - - const auto cache_storage_path = FileSys::SaveDataFactory::GetFullPath( - {}, vfs_nand_dir, FileSys::SaveDataSpaceId::User, FileSys::SaveDataType::Cache, - 0 /* program_id */, {}, 0); - - const auto path = Common::FS::ConcatPathSafe(nand_dir, cache_storage_path); - - // Not an error if it wasn't cleared. - Common::FS::RemoveDirRecursively(path); -} - -void GMainWindow::OnGameListDumpRomFS(u64 program_id, const std::string& game_path, - DumpRomFSTarget target) { - const auto failed = [this] { - QMessageBox::warning(this, tr("RomFS Extraction Failed!"), - tr("There was an error copying the RomFS files or the user " - "cancelled the operation.")); - }; - - const auto loader = - Loader::GetLoader(*system, vfs->OpenFile(game_path, FileSys::OpenMode::Read)); - if (loader == nullptr) { - failed(); - return; - } - - FileSys::VirtualFile packed_update_raw{}; - loader->ReadUpdateRaw(packed_update_raw); - - const auto& installed = system->GetContentProvider(); - - u64 title_id{}; - u8 raw_type{}; - if (!SelectRomFSDumpTarget(installed, program_id, &title_id, &raw_type)) { - failed(); - return; - } - - const auto type = static_cast<FileSys::ContentRecordType>(raw_type); - const auto base_nca = installed.GetEntry(title_id, type); - if (!base_nca) { - failed(); - return; - } - - const FileSys::NCA update_nca{packed_update_raw, nullptr}; - if (type != FileSys::ContentRecordType::Program || - update_nca.GetStatus() != Loader::ResultStatus::ErrorMissingBKTRBaseRomFS || - update_nca.GetTitleId() != FileSys::GetUpdateTitleID(title_id)) { - packed_update_raw = {}; - } - - const auto base_romfs = base_nca->GetRomFS(); - const auto dump_dir = - target == DumpRomFSTarget::Normal - ? Common::FS::GetYuzuPath(Common::FS::YuzuPath::DumpDir) - : Common::FS::GetYuzuPath(Common::FS::YuzuPath::SDMCDir) / "atmosphere" / "contents"; - const auto romfs_dir = fmt::format("{:016X}/romfs", title_id); - - const auto path = Common::FS::PathToUTF8String(dump_dir / romfs_dir); - - const FileSys::PatchManager pm{title_id, system->GetFileSystemController(), installed}; - auto romfs = pm.PatchRomFS(base_nca.get(), base_romfs, type, packed_update_raw, false); - - const auto out = VfsFilesystemCreateDirectoryWrapper(vfs, path, FileSys::OpenMode::ReadWrite); - - if (out == nullptr) { - failed(); - vfs->DeleteDirectory(path); - return; - } - - bool ok = false; - const QStringList selections{tr("Full"), tr("Skeleton")}; - const auto res = QInputDialog::getItem( - this, tr("Select RomFS Dump Mode"), - tr("Please select the how you would like the RomFS dumped.<br>Full will copy all of the " - "files into the new directory while <br>skeleton will only create the directory " - "structure."), - selections, 0, false, &ok); - if (!ok) { - failed(); - vfs->DeleteDirectory(path); - return; - } - - const auto extracted = FileSys::ExtractRomFS(romfs); - if (extracted == nullptr) { - failed(); - return; - } - - const auto full = res == selections.constFirst(); - - // The expected required space is the size of the RomFS + 1 GiB - const auto minimum_free_space = romfs->GetSize() + 0x40000000; - - if (full && Common::FS::GetFreeSpaceSize(path) < minimum_free_space) { - QMessageBox::warning(this, tr("RomFS Extraction Failed!"), - tr("There is not enough free space at %1 to extract the RomFS. Please " - "free up space or select a different dump directory at " - "Emulation > Configure > System > Filesystem > Dump Root") - .arg(QString::fromStdString(path))); - return; - } - - QProgressDialog progress(tr("Extracting RomFS..."), tr("Cancel"), 0, 100, this); - progress.setWindowModality(Qt::WindowModal); - progress.setMinimumDuration(100); - progress.setAutoClose(false); - progress.setAutoReset(false); - - size_t read_size = 0; - - if (RomFSRawCopy(romfs->GetSize(), read_size, progress, extracted, out, full)) { - progress.close(); - QMessageBox::information(this, tr("RomFS Extraction Succeeded!"), - tr("The operation completed successfully.")); - QDesktopServices::openUrl(QUrl::fromLocalFile(QString::fromStdString(path))); - } else { - progress.close(); - failed(); - vfs->DeleteDirectory(path); - } -} - -void GMainWindow::OnGameListVerifyIntegrity(const std::string& game_path) { - const auto NotImplemented = [this] { - QMessageBox::warning(this, tr("Integrity verification couldn't be performed!"), - tr("File contents were not checked for validity.")); - }; - - QProgressDialog progress(tr("Verifying integrity..."), tr("Cancel"), 0, 100, this); - progress.setWindowModality(Qt::WindowModal); - progress.setMinimumDuration(100); - progress.setAutoClose(false); - progress.setAutoReset(false); - - const auto QtProgressCallback = [&](size_t total_size, size_t processed_size) { - progress.setValue(static_cast<int>((processed_size * 100) / total_size)); - return progress.wasCanceled(); - }; - - const auto result = ContentManager::VerifyGameContents(*system, game_path, QtProgressCallback); - progress.close(); - switch (result) { - case ContentManager::GameVerificationResult::Success: - QMessageBox::information(this, tr("Integrity verification succeeded!"), - tr("The operation completed successfully.")); - break; - case ContentManager::GameVerificationResult::Failed: - QMessageBox::critical(this, tr("Integrity verification failed!"), - tr("File contents may be corrupt.")); - break; - case ContentManager::GameVerificationResult::NotImplemented: - NotImplemented(); - } -} - -void GMainWindow::OnGameListCopyTID(u64 program_id) { - QClipboard* clipboard = QGuiApplication::clipboard(); - clipboard->setText(QString::fromStdString(fmt::format("{:016X}", program_id))); -} - -void GMainWindow::OnGameListNavigateToGamedbEntry(u64 program_id, - const CompatibilityList& compatibility_list) { - const auto it = FindMatchingCompatibilityEntry(compatibility_list, program_id); - - QString directory; - if (it != compatibility_list.end()) { - directory = it->second.second; - } - - QDesktopServices::openUrl(QUrl(QStringLiteral("https://yuzu-emu.org/game/") + directory)); -} - -bool GMainWindow::CreateShortcutLink(const std::filesystem::path& shortcut_path, - const std::string& comment, - const std::filesystem::path& icon_path, - const std::filesystem::path& command, - const std::string& arguments, const std::string& categories, - const std::string& keywords, const std::string& name) try { -#if defined(__linux__) || defined(__FreeBSD__) // Linux and FreeBSD - std::filesystem::path shortcut_path_full = shortcut_path / (name + ".desktop"); - std::ofstream shortcut_stream(shortcut_path_full, std::ios::binary | std::ios::trunc); - if (!shortcut_stream.is_open()) { - LOG_ERROR(Frontend, "Failed to create shortcut"); - return false; - } - // TODO: Migrate fmt::print to std::print in futures STD C++ 23. - fmt::print(shortcut_stream, "[Desktop Entry]\n"); - fmt::print(shortcut_stream, "Type=Application\n"); - fmt::print(shortcut_stream, "Version=1.0\n"); - fmt::print(shortcut_stream, "Name={}\n", name); - if (!comment.empty()) { - fmt::print(shortcut_stream, "Comment={}\n", comment); - } - if (std::filesystem::is_regular_file(icon_path)) { - fmt::print(shortcut_stream, "Icon={}\n", icon_path.string()); - } - fmt::print(shortcut_stream, "TryExec={}\n", command.string()); - fmt::print(shortcut_stream, "Exec={} {}\n", command.string(), arguments); - if (!categories.empty()) { - fmt::print(shortcut_stream, "Categories={}\n", categories); - } - if (!keywords.empty()) { - fmt::print(shortcut_stream, "Keywords={}\n", keywords); - } - return true; -#elif defined(_WIN32) // Windows - HRESULT hr = CoInitialize(nullptr); - if (FAILED(hr)) { - LOG_ERROR(Frontend, "CoInitialize failed"); - return false; - } - SCOPE_EXIT { - CoUninitialize(); - }; - IShellLinkW* ps1 = nullptr; - IPersistFile* persist_file = nullptr; - SCOPE_EXIT { - if (persist_file != nullptr) { - persist_file->Release(); - } - if (ps1 != nullptr) { - ps1->Release(); - } - }; - HRESULT hres = CoCreateInstance(CLSID_ShellLink, nullptr, CLSCTX_INPROC_SERVER, IID_IShellLinkW, - reinterpret_cast<void**>(&ps1)); - if (FAILED(hres)) { - LOG_ERROR(Frontend, "Failed to create IShellLinkW instance"); - return false; - } - hres = ps1->SetPath(command.c_str()); - if (FAILED(hres)) { - LOG_ERROR(Frontend, "Failed to set path"); - return false; - } - if (!arguments.empty()) { - hres = ps1->SetArguments(Common::UTF8ToUTF16W(arguments).data()); - if (FAILED(hres)) { - LOG_ERROR(Frontend, "Failed to set arguments"); - return false; - } - } - if (!comment.empty()) { - hres = ps1->SetDescription(Common::UTF8ToUTF16W(comment).data()); - if (FAILED(hres)) { - LOG_ERROR(Frontend, "Failed to set description"); - return false; - } - } - if (std::filesystem::is_regular_file(icon_path)) { - hres = ps1->SetIconLocation(icon_path.c_str(), 0); - if (FAILED(hres)) { - LOG_ERROR(Frontend, "Failed to set icon location"); - return false; - } - } - hres = ps1->QueryInterface(IID_IPersistFile, reinterpret_cast<void**>(&persist_file)); - if (FAILED(hres)) { - LOG_ERROR(Frontend, "Failed to get IPersistFile interface"); - return false; - } - hres = persist_file->Save(std::filesystem::path{shortcut_path / (name + ".lnk")}.c_str(), TRUE); - if (FAILED(hres)) { - LOG_ERROR(Frontend, "Failed to save shortcut"); - return false; - } - return true; -#else // Unsupported platform - return false; -#endif -} catch (const std::exception& e) { - LOG_ERROR(Frontend, "Failed to create shortcut: {}", e.what()); - return false; -} -// Messages in pre-defined message boxes for less code spaghetti -bool GMainWindow::CreateShortcutMessagesGUI(QWidget* parent, int imsg, const QString& game_title) { - int result = 0; - QMessageBox::StandardButtons buttons; - switch (imsg) { - case GMainWindow::CREATE_SHORTCUT_MSGBOX_FULLSCREEN_YES: - buttons = QMessageBox::Yes | QMessageBox::No; - result = - QMessageBox::information(parent, tr("Create Shortcut"), - tr("Do you want to launch the game in fullscreen?"), buttons); - return result == QMessageBox::Yes; - case GMainWindow::CREATE_SHORTCUT_MSGBOX_SUCCESS: - QMessageBox::information(parent, tr("Create Shortcut"), - tr("Successfully created a shortcut to %1").arg(game_title)); - return false; - case GMainWindow::CREATE_SHORTCUT_MSGBOX_APPVOLATILE_WARNING: - buttons = QMessageBox::StandardButton::Ok | QMessageBox::StandardButton::Cancel; - result = - QMessageBox::warning(this, tr("Create Shortcut"), - tr("This will create a shortcut to the current AppImage. This may " - "not work well if you update. Continue?"), - buttons); - return result == QMessageBox::Ok; - default: - buttons = QMessageBox::Ok; - QMessageBox::critical(parent, tr("Create Shortcut"), - tr("Failed to create a shortcut to %1").arg(game_title), buttons); - return false; - } -} - -bool GMainWindow::MakeShortcutIcoPath(const u64 program_id, const std::string_view game_file_name, - std::filesystem::path& out_icon_path) { - // Get path to Yuzu icons directory & icon extension - std::string ico_extension = "png"; -#if defined(_WIN32) - out_icon_path = Common::FS::GetYuzuPath(Common::FS::YuzuPath::IconsDir); - ico_extension = "ico"; -#elif defined(__linux__) || defined(__FreeBSD__) - out_icon_path = Common::FS::GetDataDirectory("XDG_DATA_HOME") / "icons/hicolor/256x256"; -#endif - // Create icons directory if it doesn't exist - if (!Common::FS::CreateDirs(out_icon_path)) { - QMessageBox::critical( - this, tr("Create Icon"), - tr("Cannot create icon file. Path \"%1\" does not exist and cannot be created.") - .arg(QString::fromStdString(out_icon_path.string())), - QMessageBox::StandardButton::Ok); - out_icon_path.clear(); - return false; - } - - // Create icon file path - out_icon_path /= (program_id == 0 ? fmt::format("yuzu-{}.{}", game_file_name, ico_extension) - : fmt::format("yuzu-{:016X}.{}", program_id, ico_extension)); - return true; -} - -void GMainWindow::OnGameListCreateShortcut(u64 program_id, const std::string& game_path, - GameListShortcutTarget target) { - // Get path to yuzu executable - const QStringList args = QApplication::arguments(); - std::filesystem::path yuzu_command = args[0].toStdString(); - // If relative path, make it an absolute path - if (yuzu_command.c_str()[0] == '.') { - yuzu_command = Common::FS::GetCurrentDir() / yuzu_command; - } - // Shortcut path - std::filesystem::path shortcut_path{}; - if (target == GameListShortcutTarget::Desktop) { - shortcut_path = - QStandardPaths::writableLocation(QStandardPaths::DesktopLocation).toStdString(); - } else if (target == GameListShortcutTarget::Applications) { - shortcut_path = - QStandardPaths::writableLocation(QStandardPaths::ApplicationsLocation).toStdString(); - } - - if (!std::filesystem::exists(shortcut_path)) { - GMainWindow::CreateShortcutMessagesGUI( - this, GMainWindow::CREATE_SHORTCUT_MSGBOX_ERROR, - QString::fromStdString(shortcut_path.generic_string())); - LOG_ERROR(Frontend, "Invalid shortcut target {}", shortcut_path.generic_string()); - return; - } - - // Get title from game file - const FileSys::PatchManager pm{program_id, system->GetFileSystemController(), - system->GetContentProvider()}; - const auto control = pm.GetControlMetadata(); - const auto loader = - Loader::GetLoader(*system, vfs->OpenFile(game_path, FileSys::OpenMode::Read)); - std::string game_title = fmt::format("{:016X}", program_id); - if (control.first != nullptr) { - game_title = control.first->GetApplicationName(); - } else { - loader->ReadTitle(game_title); - } - // Delete illegal characters from title - const std::string illegal_chars = "<>:\"/\\|?*."; - for (auto it = game_title.rbegin(); it != game_title.rend(); ++it) { - if (illegal_chars.find(*it) != std::string::npos) { - game_title.erase(it.base() - 1); - } - } - const QString qt_game_title = QString::fromStdString(game_title); - // Get icon from game file - std::vector<u8> icon_image_file{}; - if (control.second != nullptr) { - icon_image_file = control.second->ReadAllBytes(); - } else if (loader->ReadIcon(icon_image_file) != Loader::ResultStatus::Success) { - LOG_WARNING(Frontend, "Could not read icon from {:s}", game_path); - } - QImage icon_data = - QImage::fromData(icon_image_file.data(), static_cast<int>(icon_image_file.size())); - std::filesystem::path out_icon_path; - if (GMainWindow::MakeShortcutIcoPath(program_id, game_title, out_icon_path)) { - if (!SaveIconToFile(out_icon_path, icon_data)) { - LOG_ERROR(Frontend, "Could not write icon to file"); - } - } - -#if defined(__linux__) - // Special case for AppImages - // Warn once if we are making a shortcut to a volatile AppImage - const std::string appimage_ending = - std::string(Common::g_scm_rev).substr(0, 9).append(".AppImage"); - if (yuzu_command.string().ends_with(appimage_ending) && - !UISettings::values.shortcut_already_warned) { - if (GMainWindow::CreateShortcutMessagesGUI( - this, GMainWindow::CREATE_SHORTCUT_MSGBOX_APPVOLATILE_WARNING, qt_game_title)) { - return; - } - UISettings::values.shortcut_already_warned = true; - } -#endif // __linux__ - // Create shortcut - std::string arguments = fmt::format("-g \"{:s}\"", game_path); - if (GMainWindow::CreateShortcutMessagesGUI( - this, GMainWindow::CREATE_SHORTCUT_MSGBOX_FULLSCREEN_YES, qt_game_title)) { - arguments = "-f " + arguments; - } - const std::string comment = fmt::format("Start {:s} with the yuzu Emulator", game_title); - const std::string categories = "Game;Emulator;Qt;"; - const std::string keywords = "Switch;Nintendo;"; - - if (GMainWindow::CreateShortcutLink(shortcut_path, comment, out_icon_path, yuzu_command, - arguments, categories, keywords, game_title)) { - GMainWindow::CreateShortcutMessagesGUI(this, GMainWindow::CREATE_SHORTCUT_MSGBOX_SUCCESS, - qt_game_title); - return; - } - GMainWindow::CreateShortcutMessagesGUI(this, GMainWindow::CREATE_SHORTCUT_MSGBOX_ERROR, - qt_game_title); -} - -void GMainWindow::OnGameListOpenDirectory(const QString& directory) { - std::filesystem::path fs_path; - if (directory == QStringLiteral("SDMC")) { - fs_path = - Common::FS::GetYuzuPath(Common::FS::YuzuPath::SDMCDir) / "Nintendo/Contents/registered"; - } else if (directory == QStringLiteral("UserNAND")) { - fs_path = - Common::FS::GetYuzuPath(Common::FS::YuzuPath::NANDDir) / "user/Contents/registered"; - } else if (directory == QStringLiteral("SysNAND")) { - fs_path = - Common::FS::GetYuzuPath(Common::FS::YuzuPath::NANDDir) / "system/Contents/registered"; - } else { - fs_path = directory.toStdString(); - } - - const auto qt_path = QString::fromStdString(Common::FS::PathToUTF8String(fs_path)); - - if (!Common::FS::IsDir(fs_path)) { - QMessageBox::critical(this, tr("Error Opening %1").arg(qt_path), - tr("Folder does not exist!")); - return; - } - - QDesktopServices::openUrl(QUrl::fromLocalFile(qt_path)); -} - -void GMainWindow::OnGameListAddDirectory() { - const QString dir_path = QFileDialog::getExistingDirectory(this, tr("Select Directory")); - if (dir_path.isEmpty()) { - return; - } - - UISettings::GameDir game_dir{dir_path.toStdString(), false, true}; - if (!UISettings::values.game_dirs.contains(game_dir)) { - UISettings::values.game_dirs.append(game_dir); - game_list->PopulateAsync(UISettings::values.game_dirs); - } else { - LOG_WARNING(Frontend, "Selected directory is already in the game list"); - } - - OnSaveConfig(); -} - -void GMainWindow::OnGameListShowList(bool show) { - if (emulation_running && ui->action_Single_Window_Mode->isChecked()) - return; - game_list->setVisible(show); - game_list_placeholder->setVisible(!show); -}; - -void GMainWindow::OnGameListOpenPerGameProperties(const std::string& file) { - u64 title_id{}; - const auto v_file = Core::GetGameFileFromPath(vfs, file); - const auto loader = Loader::GetLoader(*system, v_file); - - if (loader == nullptr || loader->ReadProgramId(title_id) != Loader::ResultStatus::Success) { - QMessageBox::information(this, tr("Properties"), - tr("The game properties could not be loaded.")); - return; - } - - OpenPerGameConfiguration(title_id, file); -} - -void GMainWindow::OnMenuLoadFile() { - if (is_load_file_select_active) { - return; - } - - is_load_file_select_active = true; - const QString extensions = - QStringLiteral("*.") - .append(GameList::supported_file_extensions.join(QStringLiteral(" *."))) - .append(QStringLiteral(" main")); - const QString file_filter = tr("Switch Executable (%1);;All Files (*.*)", - "%1 is an identifier for the Switch executable file extensions.") - .arg(extensions); - const QString filename = QFileDialog::getOpenFileName( - this, tr("Load File"), QString::fromStdString(UISettings::values.roms_path), file_filter); - is_load_file_select_active = false; - - if (filename.isEmpty()) { - return; - } - - UISettings::values.roms_path = QFileInfo(filename).path().toStdString(); - BootGame(filename, ApplicationAppletParameters()); -} - -void GMainWindow::OnMenuLoadFolder() { - const QString dir_path = - QFileDialog::getExistingDirectory(this, tr("Open Extracted ROM Directory")); - - if (dir_path.isNull()) { - return; - } - - const QDir dir{dir_path}; - const QStringList matching_main = dir.entryList({QStringLiteral("main")}, QDir::Files); - if (matching_main.size() == 1) { - BootGame(dir.path() + QDir::separator() + matching_main[0], ApplicationAppletParameters()); - } else { - QMessageBox::warning(this, tr("Invalid Directory Selected"), - tr("The directory you have selected does not contain a 'main' file.")); - } -} - -void GMainWindow::IncrementInstallProgress() { - install_progress->setValue(install_progress->value() + 1); -} - -void GMainWindow::OnMenuInstallToNAND() { - const QString file_filter = - tr("Installable Switch File (*.nca *.nsp *.xci);;Nintendo Content Archive " - "(*.nca);;Nintendo Submission Package (*.nsp);;NX Cartridge " - "Image (*.xci)"); - - QStringList filenames = QFileDialog::getOpenFileNames( - this, tr("Install Files"), QString::fromStdString(UISettings::values.roms_path), - file_filter); - - if (filenames.isEmpty()) { - return; - } - - InstallDialog installDialog(this, filenames); - if (installDialog.exec() == QDialog::Rejected) { - return; - } - - const QStringList files = installDialog.GetFiles(); - - if (files.isEmpty()) { - return; - } - - // Save folder location of the first selected file - UISettings::values.roms_path = QFileInfo(filenames[0]).path().toStdString(); - - int remaining = filenames.size(); - - // This would only overflow above 2^51 bytes (2.252 PB) - int total_size = 0; - for (const QString& file : files) { - total_size += static_cast<int>(QFile(file).size() / CopyBufferSize); - } - if (total_size < 0) { - LOG_CRITICAL(Frontend, "Attempting to install too many files, aborting."); - return; - } - - QStringList new_files{}; // Newly installed files that do not yet exist in the NAND - QStringList overwritten_files{}; // Files that overwrote those existing in the NAND - QStringList failed_files{}; // Files that failed to install due to errors - bool detected_base_install{}; // Whether a base game was attempted to be installed - - ui->action_Install_File_NAND->setEnabled(false); - - install_progress = new QProgressDialog(QString{}, tr("Cancel"), 0, total_size, this); - install_progress->setWindowFlags(windowFlags() & ~Qt::WindowMaximizeButtonHint); - install_progress->setAttribute(Qt::WA_DeleteOnClose, true); - install_progress->setFixedWidth(installDialog.GetMinimumWidth() + 40); - install_progress->show(); - - for (const QString& file : files) { - install_progress->setWindowTitle(tr("%n file(s) remaining", "", remaining)); - install_progress->setLabelText( - tr("Installing file \"%1\"...").arg(QFileInfo(file).fileName())); - - QFuture<ContentManager::InstallResult> future; - ContentManager::InstallResult result; - - if (file.endsWith(QStringLiteral("nsp"), Qt::CaseInsensitive)) { - const auto progress_callback = [this](size_t size, size_t progress) { - emit UpdateInstallProgress(); - if (install_progress->wasCanceled()) { - return true; - } - return false; - }; - future = QtConcurrent::run([this, &file, progress_callback] { - return ContentManager::InstallNSP(*system, *vfs, file.toStdString(), - progress_callback); - }); - - while (!future.isFinished()) { - QCoreApplication::processEvents(); - std::this_thread::sleep_for(std::chrono::milliseconds(1)); - } - - result = future.result(); - - } else { - result = InstallNCA(file); - } - - std::this_thread::sleep_for(std::chrono::milliseconds(10)); - - switch (result) { - case ContentManager::InstallResult::Success: - new_files.append(QFileInfo(file).fileName()); - break; - case ContentManager::InstallResult::Overwrite: - overwritten_files.append(QFileInfo(file).fileName()); - break; - case ContentManager::InstallResult::Failure: - failed_files.append(QFileInfo(file).fileName()); - break; - case ContentManager::InstallResult::BaseInstallAttempted: - failed_files.append(QFileInfo(file).fileName()); - detected_base_install = true; - break; - } - - --remaining; - } - - install_progress->close(); - - if (detected_base_install) { - QMessageBox::warning( - this, tr("Install Results"), - tr("To avoid possible conflicts, we discourage users from installing base games to the " - "NAND.\nPlease, only use this feature to install updates and DLC.")); - } - - const QString install_results = - (new_files.isEmpty() ? QString{} - : tr("%n file(s) were newly installed\n", "", new_files.size())) + - (overwritten_files.isEmpty() - ? QString{} - : tr("%n file(s) were overwritten\n", "", overwritten_files.size())) + - (failed_files.isEmpty() ? QString{} - : tr("%n file(s) failed to install\n", "", failed_files.size())); - - QMessageBox::information(this, tr("Install Results"), install_results); - Common::FS::RemoveDirRecursively(Common::FS::GetYuzuPath(Common::FS::YuzuPath::CacheDir) / - "game_list"); - game_list->PopulateAsync(UISettings::values.game_dirs); - ui->action_Install_File_NAND->setEnabled(true); -} - -ContentManager::InstallResult GMainWindow::InstallNCA(const QString& filename) { - const QStringList tt_options{tr("System Application"), - tr("System Archive"), - tr("System Application Update"), - tr("Firmware Package (Type A)"), - tr("Firmware Package (Type B)"), - tr("Game"), - tr("Game Update"), - tr("Game DLC"), - tr("Delta Title")}; - bool ok; - const auto item = QInputDialog::getItem( - this, tr("Select NCA Install Type..."), - tr("Please select the type of title you would like to install this NCA as:\n(In " - "most instances, the default 'Game' is fine.)"), - tt_options, 5, false, &ok); - - auto index = tt_options.indexOf(item); - if (!ok || index == -1) { - QMessageBox::warning(this, tr("Failed to Install"), - tr("The title type you selected for the NCA is invalid.")); - return ContentManager::InstallResult::Failure; - } - - // If index is equal to or past Game, add the jump in TitleType. - if (index >= 5) { - index += static_cast<size_t>(FileSys::TitleType::Application) - - static_cast<size_t>(FileSys::TitleType::FirmwarePackageB); - } - - const bool is_application = index >= static_cast<s32>(FileSys::TitleType::Application); - const auto& fs_controller = system->GetFileSystemController(); - auto* registered_cache = is_application ? fs_controller.GetUserNANDContents() - : fs_controller.GetSystemNANDContents(); - - const auto progress_callback = [this](size_t size, size_t progress) { - emit UpdateInstallProgress(); - if (install_progress->wasCanceled()) { - return true; - } - return false; - }; - return ContentManager::InstallNCA(*vfs, filename.toStdString(), *registered_cache, - static_cast<FileSys::TitleType>(index), progress_callback); -} - -void GMainWindow::OnMenuRecentFile() { - QAction* action = qobject_cast<QAction*>(sender()); - assert(action); - - const QString filename = action->data().toString(); - if (QFileInfo::exists(filename)) { - BootGame(filename, ApplicationAppletParameters()); - } else { - // Display an error message and remove the file from the list. - QMessageBox::information(this, tr("File not found"), - tr("File \"%1\" not found").arg(filename)); - - UISettings::values.recent_files.removeOne(filename); - UpdateRecentFiles(); - } -} - -void GMainWindow::OnStartGame() { - PreventOSSleep(); - - emu_thread->SetRunning(true); - - UpdateMenuState(); - OnTasStateChanged(); - - play_time_manager->SetProgramId(system->GetApplicationProcessProgramID()); - play_time_manager->Start(); - - discord_rpc->Update(); - -#ifdef __unix__ - Common::Linux::StartGamemode(); -#endif -} - -void GMainWindow::OnRestartGame() { - if (!system->IsPoweredOn()) { - return; - } - - if (ConfirmShutdownGame()) { - // Make a copy since ShutdownGame edits game_path - const auto current_game = QString(current_game_path); - ShutdownGame(); - BootGame(current_game, ApplicationAppletParameters()); - } -} - -void GMainWindow::OnPauseGame() { - emu_thread->SetRunning(false); - play_time_manager->Stop(); - UpdateMenuState(); - AllowOSSleep(); - -#ifdef __unix__ - Common::Linux::StopGamemode(); -#endif -} - -void GMainWindow::OnPauseContinueGame() { - if (emulation_running) { - if (emu_thread->IsRunning()) { - OnPauseGame(); - } else { - OnStartGame(); - } - } -} - -void GMainWindow::OnStopGame() { - if (ConfirmShutdownGame()) { - play_time_manager->Stop(); - // Update game list to show new play time - game_list->PopulateAsync(UISettings::values.game_dirs); - if (OnShutdownBegin()) { - OnShutdownBeginDialog(); - } else { - OnEmulationStopped(); - } - } -} - -bool GMainWindow::ConfirmShutdownGame() { - if (UISettings::values.confirm_before_stopping.GetValue() == ConfirmStop::Ask_Always) { - if (system->GetExitLocked()) { - if (!ConfirmForceLockedExit()) { - return false; - } - } else { - if (!ConfirmChangeGame()) { - return false; - } - } - } else { - if (UISettings::values.confirm_before_stopping.GetValue() == - ConfirmStop::Ask_Based_On_Game && - system->GetExitLocked()) { - if (!ConfirmForceLockedExit()) { - return false; - } - } - } - return true; -} - -void GMainWindow::OnLoadComplete() { - loading_screen->OnLoadComplete(); -} - -void GMainWindow::OnExecuteProgram(std::size_t program_index) { - ShutdownGame(); - - auto params = ApplicationAppletParameters(); - params.program_index = static_cast<s32>(program_index); - params.launch_type = Service::AM::LaunchType::ApplicationInitiated; - BootGame(last_filename_booted, params); -} - -void GMainWindow::OnExit() { - ShutdownGame(); -} - -void GMainWindow::OnSaveConfig() { - system->ApplySettings(); - config->SaveAllValues(); -} - -void GMainWindow::ErrorDisplayDisplayError(QString error_code, QString error_text) { - error_applet = new OverlayDialog(render_window, *system, error_code, error_text, QString{}, - tr("OK"), Qt::AlignLeft | Qt::AlignVCenter); - SCOPE_EXIT { - error_applet->deleteLater(); - error_applet = nullptr; - }; - error_applet->exec(); - - emit ErrorDisplayFinished(); -} - -void GMainWindow::ErrorDisplayRequestExit() { - if (error_applet) { - error_applet->reject(); - } -} - -void GMainWindow::OnMenuReportCompatibility() { -#if defined(ARCHITECTURE_x86_64) && !defined(__APPLE__) - const auto& caps = Common::GetCPUCaps(); - const bool has_fma = caps.fma || caps.fma4; - const auto processor_count = std::thread::hardware_concurrency(); - const bool has_4threads = processor_count == 0 || processor_count >= 4; - const bool has_8gb_ram = Common::GetMemInfo().TotalPhysicalMemory >= 8_GiB; - const bool has_broken_vulkan = UISettings::values.has_broken_vulkan; - - if (!has_fma || !has_4threads || !has_8gb_ram || has_broken_vulkan) { - QMessageBox::critical(this, tr("Hardware requirements not met"), - tr("Your system does not meet the recommended hardware requirements. " - "Compatibility reporting has been disabled.")); - return; - } - - if (!Settings::values.yuzu_token.GetValue().empty() && - !Settings::values.yuzu_username.GetValue().empty()) { - CompatDB compatdb{system->TelemetrySession(), this}; - compatdb.exec(); - } else { - QMessageBox::critical( - this, tr("Missing yuzu Account"), - tr("In order to submit a game compatibility test case, you must link your yuzu " - "account.<br><br/>To link your yuzu account, go to Emulation > Configuration " - "> " - "Web.")); - } -#else - QMessageBox::critical(this, tr("Hardware requirements not met"), - tr("Your system does not meet the recommended hardware requirements. " - "Compatibility reporting has been disabled.")); -#endif -} - -void GMainWindow::OpenURL(const QUrl& url) { - const bool open = QDesktopServices::openUrl(url); - if (!open) { - QMessageBox::warning(this, tr("Error opening URL"), - tr("Unable to open the URL \"%1\".").arg(url.toString())); - } -} - -void GMainWindow::OnOpenModsPage() { - OpenURL(QUrl(QStringLiteral("https://github.com/yuzu-emu/yuzu/wiki/Switch-Mods"))); -} - -void GMainWindow::OnOpenQuickstartGuide() { - OpenURL(QUrl(QStringLiteral("https://yuzu-emu.org/help/quickstart/"))); -} - -void GMainWindow::OnOpenFAQ() { - OpenURL(QUrl(QStringLiteral("https://yuzu-emu.org/wiki/faq/"))); -} - -void GMainWindow::ToggleFullscreen() { - if (!emulation_running) { - return; - } - if (ui->action_Fullscreen->isChecked()) { - ShowFullscreen(); - } else { - HideFullscreen(); - } -} - -// 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()); - }); -} - -bool GMainWindow::UsingExclusiveFullscreen() { - return Settings::values.fullscreen_mode.GetValue() == Settings::FullscreenMode::Exclusive || - QGuiApplication::platformName() == QStringLiteral("wayland") || - QGuiApplication::platformName() == QStringLiteral("wayland-egl"); -} - -void GMainWindow::ShowFullscreen() { - const auto show_fullscreen = [this](QWidget* window) { - if (UsingExclusiveFullscreen()) { - window->showFullScreen(); - return; - } - window->hide(); - window->setWindowFlags(window->windowFlags() | Qt::FramelessWindowHint); - const auto screen_geometry = GuessCurrentScreen(window)->geometry(); - window->setGeometry(screen_geometry.x(), screen_geometry.y(), screen_geometry.width(), - screen_geometry.height() + 1); - window->raise(); - window->showNormal(); - }; - - if (ui->action_Single_Window_Mode->isChecked()) { - UISettings::values.geometry = saveGeometry(); - - ui->menubar->hide(); - statusBar()->hide(); - - show_fullscreen(this); - } else { - UISettings::values.renderwindow_geometry = render_window->saveGeometry(); - show_fullscreen(render_window); - } -} - -void GMainWindow::HideFullscreen() { - if (ui->action_Single_Window_Mode->isChecked()) { - if (UsingExclusiveFullscreen()) { - showNormal(); - restoreGeometry(UISettings::values.geometry); - } else { - hide(); - setWindowFlags(windowFlags() & ~Qt::FramelessWindowHint); - restoreGeometry(UISettings::values.geometry); - raise(); - show(); - } - - statusBar()->setVisible(ui->action_Show_Status_Bar->isChecked()); - ui->menubar->show(); - } else { - if (UsingExclusiveFullscreen()) { - render_window->showNormal(); - render_window->restoreGeometry(UISettings::values.renderwindow_geometry); - } else { - render_window->hide(); - render_window->setWindowFlags(windowFlags() & ~Qt::FramelessWindowHint); - render_window->restoreGeometry(UISettings::values.renderwindow_geometry); - render_window->raise(); - render_window->show(); - } - } -} - -void GMainWindow::ToggleWindowMode() { - if (ui->action_Single_Window_Mode->isChecked()) { - // Render in the main window... - render_window->BackupGeometry(); - ui->horizontalLayout->addWidget(render_window); - render_window->setFocusPolicy(Qt::StrongFocus); - if (emulation_running) { - render_window->setVisible(true); - render_window->setFocus(); - game_list->hide(); - } - - } else { - // Render in a separate window... - ui->horizontalLayout->removeWidget(render_window); - render_window->setParent(nullptr); - render_window->setFocusPolicy(Qt::NoFocus); - if (emulation_running) { - render_window->setVisible(true); - render_window->RestoreGeometry(); - game_list->show(); - } - } -} - -void GMainWindow::ResetWindowSize(u32 width, u32 height) { - const auto aspect_ratio = Layout::EmulationAspectRatio( - static_cast<Layout::AspectRatio>(Settings::values.aspect_ratio.GetValue()), - static_cast<float>(height) / width); - if (!ui->action_Single_Window_Mode->isChecked()) { - render_window->resize(height / aspect_ratio, height); - } else { - const bool show_status_bar = ui->action_Show_Status_Bar->isChecked(); - const auto status_bar_height = show_status_bar ? statusBar()->height() : 0; - resize(height / aspect_ratio, height + menuBar()->height() + status_bar_height); - } -} - -void GMainWindow::ResetWindowSize720() { - ResetWindowSize(Layout::ScreenUndocked::Width, Layout::ScreenUndocked::Height); -} - -void GMainWindow::ResetWindowSize900() { - ResetWindowSize(1600U, 900U); -} - -void GMainWindow::ResetWindowSize1080() { - ResetWindowSize(Layout::ScreenDocked::Width, Layout::ScreenDocked::Height); -} - -void GMainWindow::OnConfigure() { - const auto old_theme = UISettings::values.theme; - const bool old_discord_presence = UISettings::values.enable_discord_presence.GetValue(); - const auto old_language_index = Settings::values.language_index.GetValue(); -#ifdef __unix__ - const bool old_gamemode = Settings::values.enable_gamemode.GetValue(); -#endif - - Settings::SetConfiguringGlobal(true); - ConfigureDialog configure_dialog(this, hotkey_registry, input_subsystem.get(), - vk_device_records, *system, - !multiplayer_state->IsHostingPublicRoom()); - connect(&configure_dialog, &ConfigureDialog::LanguageChanged, this, - &GMainWindow::OnLanguageChanged); - - const auto result = configure_dialog.exec(); - if (result != QDialog::Accepted && !UISettings::values.configuration_applied && - !UISettings::values.reset_to_defaults) { - // Runs if the user hit Cancel or closed the window, and did not ever press the Apply button - // or `Reset to Defaults` button - return; - } else if (result == QDialog::Accepted) { - // Only apply new changes if user hit Okay - // This is here to avoid applying changes if the user hit Apply, made some changes, then hit - // Cancel - configure_dialog.ApplyConfiguration(); - } else if (UISettings::values.reset_to_defaults) { - LOG_INFO(Frontend, "Resetting all settings to defaults"); - if (!Common::FS::RemoveFile(config->GetConfigFilePath())) { - LOG_WARNING(Frontend, "Failed to remove configuration file"); - } - if (!Common::FS::RemoveDirContentsRecursively( - Common::FS::GetYuzuPath(Common::FS::YuzuPath::ConfigDir) / "custom")) { - LOG_WARNING(Frontend, "Failed to remove custom configuration files"); - } - if (!Common::FS::RemoveDirRecursively( - Common::FS::GetYuzuPath(Common::FS::YuzuPath::CacheDir) / "game_list")) { - LOG_WARNING(Frontend, "Failed to remove game metadata cache files"); - } - - // Explicitly save the game directories, since reinitializing config does not explicitly do - // so. - QVector<UISettings::GameDir> old_game_dirs = std::move(UISettings::values.game_dirs); - QVector<u64> old_favorited_ids = std::move(UISettings::values.favorited_ids); - - Settings::values.disabled_addons.clear(); - - config = std::make_unique<QtConfig>(); - UISettings::values.reset_to_defaults = false; - - UISettings::values.game_dirs = std::move(old_game_dirs); - UISettings::values.favorited_ids = std::move(old_favorited_ids); - - InitializeRecentFileMenuActions(); - - SetDefaultUIGeometry(); - RestoreUIState(); - - ShowTelemetryCallout(); - } - InitializeHotkeys(); - - if (UISettings::values.theme != old_theme) { - UpdateUITheme(); - } - if (UISettings::values.enable_discord_presence.GetValue() != old_discord_presence) { - SetDiscordEnabled(UISettings::values.enable_discord_presence.GetValue()); - } -#ifdef __unix__ - if (Settings::values.enable_gamemode.GetValue() != old_gamemode) { - SetGamemodeEnabled(Settings::values.enable_gamemode.GetValue()); - } -#endif - - if (!multiplayer_state->IsHostingPublicRoom()) { - multiplayer_state->UpdateCredentials(); - } - - emit UpdateThemedIcons(); - - const auto reload = UISettings::values.is_game_list_reload_pending.exchange(false); - if (reload || Settings::values.language_index.GetValue() != old_language_index) { - game_list->PopulateAsync(UISettings::values.game_dirs); - } - - UISettings::values.configuration_applied = false; - - config->SaveAllValues(); - - if ((UISettings::values.hide_mouse || Settings::values.mouse_panning) && emulation_running) { - render_window->installEventFilter(render_window); - render_window->setAttribute(Qt::WA_Hover, true); - } else { - render_window->removeEventFilter(render_window); - render_window->setAttribute(Qt::WA_Hover, false); - } - - if (UISettings::values.hide_mouse) { - 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() { - ConfigureTasDialog dialog(this); - const auto result = dialog.exec(); - - if (result != QDialog::Accepted && !UISettings::values.configuration_applied) { - Settings::RestoreGlobalState(system->IsPoweredOn()); - return; - } else if (result == QDialog::Accepted) { - dialog.ApplyConfiguration(); - OnSaveConfig(); - } -} - -void GMainWindow::OnTasStartStop() { - if (!emulation_running) { - return; - } - - // Disable system buttons to prevent TAS from executing a hotkey - auto* controller = system->HIDCore().GetEmulatedController(Core::HID::NpadIdType::Player1); - controller->ResetSystemButtons(); - - input_subsystem->GetTas()->StartStop(); - OnTasStateChanged(); -} - -void GMainWindow::OnTasRecord() { - if (!emulation_running) { - return; - } - if (is_tas_recording_dialog_active) { - return; - } - - // Disable system buttons to prevent TAS from recording a hotkey - auto* controller = system->HIDCore().GetEmulatedController(Core::HID::NpadIdType::Player1); - controller->ResetSystemButtons(); - - const bool is_recording = input_subsystem->GetTas()->Record(); - if (!is_recording) { - is_tas_recording_dialog_active = true; - - bool answer = question(this, tr("TAS Recording"), tr("Overwrite file of player 1?"), - QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes); - - input_subsystem->GetTas()->SaveRecording(answer); - is_tas_recording_dialog_active = false; - } - OnTasStateChanged(); -} - -void GMainWindow::OnTasReset() { - input_subsystem->GetTas()->Reset(); -} - -void GMainWindow::OnToggleDockedMode() { - const bool is_docked = Settings::IsDockedMode(); - auto* player_1 = system->HIDCore().GetEmulatedController(Core::HID::NpadIdType::Player1); - auto* handheld = system->HIDCore().GetEmulatedController(Core::HID::NpadIdType::Handheld); - - if (!is_docked && handheld->IsConnected()) { - QMessageBox::warning(this, tr("Invalid config detected"), - tr("Handheld controller can't be used on docked mode. Pro " - "controller will be selected.")); - handheld->Disconnect(); - player_1->SetNpadStyleIndex(Core::HID::NpadStyleIndex::Fullkey); - player_1->Connect(); - controller_dialog->refreshConfiguration(); - } - - Settings::values.use_docked_mode.SetValue(is_docked ? Settings::ConsoleMode::Handheld - : Settings::ConsoleMode::Docked); - UpdateDockedButton(); - OnDockedModeChanged(is_docked, !is_docked, *system); -} - -void GMainWindow::OnToggleGpuAccuracy() { - switch (Settings::values.gpu_accuracy.GetValue()) { - case Settings::GpuAccuracy::High: { - Settings::values.gpu_accuracy.SetValue(Settings::GpuAccuracy::Normal); - break; - } - case Settings::GpuAccuracy::Normal: - case Settings::GpuAccuracy::Extreme: - default: { - Settings::values.gpu_accuracy.SetValue(Settings::GpuAccuracy::High); - break; - } - } - - system->ApplySettings(); - UpdateGPUAccuracyButton(); -} - -void GMainWindow::OnMute() { - Settings::values.audio_muted = !Settings::values.audio_muted; - UpdateVolumeUI(); -} - -void GMainWindow::OnDecreaseVolume() { - Settings::values.audio_muted = false; - 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)); - UpdateVolumeUI(); -} - -void GMainWindow::OnIncreaseVolume() { - Settings::values.audio_muted = false; - 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); - UpdateVolumeUI(); -} - -void GMainWindow::OnToggleAdaptingFilter() { - auto filter = Settings::values.scaling_filter.GetValue(); - filter = static_cast<Settings::ScalingFilter>(static_cast<u32>(filter) + 1); - if (filter == Settings::ScalingFilter::MaxEnum) { - filter = Settings::ScalingFilter::NearestNeighbor; - } - Settings::values.scaling_filter.SetValue(filter); - filter_status_button->setChecked(true); - UpdateFilterText(); -} - -void GMainWindow::OnToggleGraphicsAPI() { - auto api = Settings::values.renderer_backend.GetValue(); - if (api != Settings::RendererBackend::Vulkan) { - api = Settings::RendererBackend::Vulkan; - } else { -#ifdef HAS_OPENGL - api = Settings::RendererBackend::OpenGL; -#else - api = Settings::RendererBackend::Null; -#endif - } - Settings::values.renderer_backend.SetValue(api); - renderer_status_button->setChecked(api == Settings::RendererBackend::Vulkan); - UpdateAPIText(); -} - -void GMainWindow::OnConfigurePerGame() { - const u64 title_id = system->GetApplicationProcessProgramID(); - OpenPerGameConfiguration(title_id, current_game_path.toStdString()); -} - -void GMainWindow::OpenPerGameConfiguration(u64 title_id, const std::string& file_name) { - const auto v_file = Core::GetGameFileFromPath(vfs, file_name); - - Settings::SetConfiguringGlobal(false); - ConfigurePerGame dialog(this, title_id, file_name, vk_device_records, *system); - dialog.LoadFromFile(v_file); - const auto result = dialog.exec(); - - if (result != QDialog::Accepted && !UISettings::values.configuration_applied) { - Settings::RestoreGlobalState(system->IsPoweredOn()); - return; - } else if (result == QDialog::Accepted) { - dialog.ApplyConfiguration(); - } - - const auto reload = UISettings::values.is_game_list_reload_pending.exchange(false); - if (reload) { - game_list->PopulateAsync(UISettings::values.game_dirs); - } - - // Do not cause the global config to write local settings into the config file - const bool is_powered_on = system->IsPoweredOn(); - Settings::RestoreGlobalState(is_powered_on); - system->HIDCore().ReloadInputDevices(); - - UISettings::values.configuration_applied = false; - - if (!is_powered_on) { - config->SaveAllValues(); - } -} - -void GMainWindow::OnLoadAmiibo() { - if (emu_thread == nullptr || !emu_thread->IsRunning()) { - return; - } - if (is_amiibo_file_select_active) { - return; - } - - auto* virtual_amiibo = input_subsystem->GetVirtualAmiibo(); - - // Remove amiibo if one is connected - if (virtual_amiibo->GetCurrentState() == InputCommon::VirtualAmiibo::State::TagNearby) { - 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); - const QString filename = QFileDialog::getOpenFileName(this, tr("Load Amiibo"), {}, file_filter); - is_amiibo_file_select_active = false; - - if (filename.isEmpty()) { - return; - } - - LoadAmiibo(filename); -} - -bool GMainWindow::question(QWidget* parent, const QString& title, const QString& text, - QMessageBox::StandardButtons buttons, - QMessageBox::StandardButton defaultButton) { - QMessageBox* box_dialog = new QMessageBox(parent); - box_dialog->setWindowTitle(title); - box_dialog->setText(text); - box_dialog->setStandardButtons(buttons); - box_dialog->setDefaultButton(defaultButton); - - ControllerNavigation* controller_navigation = - new ControllerNavigation(system->HIDCore(), box_dialog); - connect(controller_navigation, &ControllerNavigation::TriggerKeyboardEvent, - [box_dialog](Qt::Key key) { - QKeyEvent* event = new QKeyEvent(QEvent::KeyPress, key, Qt::NoModifier); - QCoreApplication::postEvent(box_dialog, event); - }); - int res = box_dialog->exec(); - - controller_navigation->UnloadController(); - return res == QMessageBox::Yes; -} - -void GMainWindow::LoadAmiibo(const QString& filename) { - 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::TagNearby) { - virtual_amiibo->CloseAmiibo(); - QMessageBox::warning(this, tr("Amiibo"), tr("The current amiibo has been removed")); - return; - } - - 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 unknown error occurred")); - break; - default: - break; - } -} - -void GMainWindow::OnOpenYuzuFolder() { - QDesktopServices::openUrl(QUrl::fromLocalFile( - QString::fromStdString(Common::FS::GetYuzuPathString(Common::FS::YuzuPath::YuzuDir)))); -} - -void GMainWindow::OnVerifyInstalledContents() { - // Initialize a progress dialog. - QProgressDialog progress(tr("Verifying integrity..."), tr("Cancel"), 0, 100, this); - progress.setWindowModality(Qt::WindowModal); - progress.setMinimumDuration(100); - progress.setAutoClose(false); - progress.setAutoReset(false); - - // Declare progress callback. - auto QtProgressCallback = [&](size_t total_size, size_t processed_size) { - progress.setValue(static_cast<int>((processed_size * 100) / total_size)); - return progress.wasCanceled(); - }; - - const std::vector<std::string> result = - ContentManager::VerifyInstalledContents(*system, *provider, QtProgressCallback); - progress.close(); - - if (result.empty()) { - QMessageBox::information(this, tr("Integrity verification succeeded!"), - tr("The operation completed successfully.")); - } else { - const auto failed_names = - QString::fromStdString(fmt::format("{}", fmt::join(result, "\n"))); - QMessageBox::critical( - this, tr("Integrity verification failed!"), - tr("Verification failed for the following files:\n\n%1").arg(failed_names)); - } -} - -void GMainWindow::OnInstallFirmware() { - // Don't do this while emulation is running, that'd probably be a bad idea. - if (emu_thread != nullptr && emu_thread->IsRunning()) { - return; - } - - // Check for installed keys, error out, suggest restart? - if (!ContentManager::AreKeysPresent()) { - QMessageBox::information( - this, tr("Keys not installed"), - tr("Install decryption keys and restart yuzu before attempting to install firmware.")); - return; - } - - const QString firmware_source_location = QFileDialog::getExistingDirectory( - this, tr("Select Dumped Firmware Source Location"), {}, QFileDialog::ShowDirsOnly); - if (firmware_source_location.isEmpty()) { - return; - } - - QProgressDialog progress(tr("Installing Firmware..."), tr("Cancel"), 0, 100, this); - progress.setWindowModality(Qt::WindowModal); - progress.setMinimumDuration(100); - progress.setAutoClose(false); - progress.setAutoReset(false); - progress.show(); - - // Declare progress callback. - auto QtProgressCallback = [&](size_t total_size, size_t processed_size) { - progress.setValue(static_cast<int>((processed_size * 100) / total_size)); - return progress.wasCanceled(); - }; - - LOG_INFO(Frontend, "Installing firmware from {}", firmware_source_location.toStdString()); - - // Check for a reasonable number of .nca files (don't hardcode them, just see if there's some in - // there.) - std::filesystem::path firmware_source_path = firmware_source_location.toStdString(); - if (!Common::FS::IsDir(firmware_source_path)) { - progress.close(); - return; - } - - std::vector<std::filesystem::path> out; - const Common::FS::DirEntryCallable callback = - [&out](const std::filesystem::directory_entry& entry) { - if (entry.path().has_extension() && entry.path().extension() == ".nca") { - out.emplace_back(entry.path()); - } - - return true; - }; - - QtProgressCallback(100, 10); - - Common::FS::IterateDirEntries(firmware_source_path, callback, Common::FS::DirEntryFilter::File); - if (out.size() <= 0) { - progress.close(); - QMessageBox::warning(this, tr("Firmware install failed"), - tr("Unable to locate potential firmware NCA files")); - return; - } - - // Locate and erase the content of nand/system/Content/registered/*.nca, if any. - auto sysnand_content_vdir = system->GetFileSystemController().GetSystemNANDContentDirectory(); - if (!sysnand_content_vdir->CleanSubdirectoryRecursive("registered")) { - progress.close(); - QMessageBox::critical(this, tr("Firmware install failed"), - tr("Failed to delete one or more firmware file.")); - return; - } - - LOG_INFO(Frontend, - "Cleaned nand/system/Content/registered folder in preparation for new firmware."); - - QtProgressCallback(100, 20); - - auto firmware_vdir = sysnand_content_vdir->GetDirectoryRelative("registered"); - - bool success = true; - int i = 0; - for (const auto& firmware_src_path : out) { - i++; - auto firmware_src_vfile = - vfs->OpenFile(firmware_src_path.generic_string(), FileSys::OpenMode::Read); - auto firmware_dst_vfile = - firmware_vdir->CreateFileRelative(firmware_src_path.filename().string()); - - if (!VfsRawCopy(firmware_src_vfile, firmware_dst_vfile)) { - LOG_ERROR(Frontend, "Failed to copy firmware file {} to {} in registered folder!", - firmware_src_path.generic_string(), firmware_src_path.filename().string()); - success = false; - } - - if (QtProgressCallback( - 100, 20 + static_cast<int>(((i) / static_cast<float>(out.size())) * 70.0))) { - progress.close(); - QMessageBox::warning( - this, tr("Firmware install failed"), - tr("Firmware installation cancelled, firmware may be in bad state, " - "restart yuzu or re-install firmware.")); - return; - } - } - - if (!success) { - progress.close(); - QMessageBox::critical(this, tr("Firmware install failed"), - tr("One or more firmware files failed to copy into NAND.")); - return; - } - - // Re-scan VFS for the newly placed firmware files. - system->GetFileSystemController().CreateFactories(*vfs); - - auto VerifyFirmwareCallback = [&](size_t total_size, size_t processed_size) { - progress.setValue(90 + static_cast<int>((processed_size * 10) / total_size)); - return progress.wasCanceled(); - }; - - auto result = - ContentManager::VerifyInstalledContents(*system, *provider, VerifyFirmwareCallback, true); - - if (result.size() > 0) { - const auto failed_names = - QString::fromStdString(fmt::format("{}", fmt::join(result, "\n"))); - progress.close(); - QMessageBox::critical( - this, tr("Firmware integrity verification failed!"), - tr("Verification failed for the following files:\n\n%1").arg(failed_names)); - return; - } - - progress.close(); - OnCheckFirmwareDecryption(); -} - -void GMainWindow::OnInstallDecryptionKeys() { - // Don't do this while emulation is running. - if (emu_thread != nullptr && emu_thread->IsRunning()) { - return; - } - - const QString key_source_location = QFileDialog::getOpenFileName( - this, tr("Select Dumped Keys Location"), {}, QStringLiteral("prod.keys (prod.keys)"), {}, - QFileDialog::ReadOnly); - if (key_source_location.isEmpty()) { - return; - } - - // Verify that it contains prod.keys, title.keys and optionally, key_retail.bin - LOG_INFO(Frontend, "Installing key files from {}", key_source_location.toStdString()); - - const std::filesystem::path prod_key_path = key_source_location.toStdString(); - const std::filesystem::path key_source_path = prod_key_path.parent_path(); - if (!Common::FS::IsDir(key_source_path)) { - return; - } - - bool prod_keys_found = false; - std::vector<std::filesystem::path> source_key_files; - - if (Common::FS::Exists(prod_key_path)) { - prod_keys_found = true; - source_key_files.emplace_back(prod_key_path); - } - - if (Common::FS::Exists(key_source_path / "title.keys")) { - source_key_files.emplace_back(key_source_path / "title.keys"); - } - - if (Common::FS::Exists(key_source_path / "key_retail.bin")) { - source_key_files.emplace_back(key_source_path / "key_retail.bin"); - } - - // There should be at least prod.keys. - if (source_key_files.empty() || !prod_keys_found) { - QMessageBox::warning(this, tr("Decryption Keys install failed"), - tr("prod.keys is a required decryption key file.")); - return; - } - - const auto yuzu_keys_dir = Common::FS::GetYuzuPath(Common::FS::YuzuPath::KeysDir); - for (auto key_file : source_key_files) { - std::filesystem::path destination_key_file = yuzu_keys_dir / key_file.filename(); - if (!std::filesystem::copy_file(key_file, destination_key_file, - std::filesystem::copy_options::overwrite_existing)) { - LOG_ERROR(Frontend, "Failed to copy file {} to {}", key_file.string(), - destination_key_file.string()); - QMessageBox::critical(this, tr("Decryption Keys install failed"), - tr("One or more keys failed to copy.")); - return; - } - } - - // Reinitialize the key manager, re-read the vfs (for update/dlc files), - // and re-populate the game list in the UI if the user has already added - // game folders. - Core::Crypto::KeyManager::Instance().ReloadKeys(); - system->GetFileSystemController().CreateFactories(*vfs); - game_list->PopulateAsync(UISettings::values.game_dirs); - - if (ContentManager::AreKeysPresent()) { - QMessageBox::information(this, tr("Decryption Keys install succeeded"), - tr("Decryption Keys were successfully installed")); - } else { - QMessageBox::critical( - this, tr("Decryption Keys install failed"), - tr("Decryption Keys failed to initialize. Check that your dumping tools are " - "up to date and re-dump keys.")); - } - - OnCheckFirmwareDecryption(); -} - -void GMainWindow::OnAbout() { - AboutDialog aboutDialog(this); - aboutDialog.exec(); -} - -void GMainWindow::OnToggleFilterBar() { - game_list->SetFilterVisible(ui->action_Show_Filter_Bar->isChecked()); - if (ui->action_Show_Filter_Bar->isChecked()) { - game_list->SetFilterFocus(); - } else { - game_list->ClearFilter(); - } -} - -void GMainWindow::OnToggleStatusBar() { - statusBar()->setVisible(ui->action_Show_Status_Bar->isChecked()); -} - -void GMainWindow::OnAlbum() { - constexpr u64 AlbumId = static_cast<u64>(Service::AM::AppletProgramId::PhotoViewer); - auto bis_system = system->GetFileSystemController().GetSystemNANDContents(); - if (!bis_system) { - QMessageBox::warning(this, tr("No firmware available"), - tr("Please install the firmware to use the Album applet.")); - return; - } - - auto album_nca = bis_system->GetEntry(AlbumId, FileSys::ContentRecordType::Program); - if (!album_nca) { - QMessageBox::warning(this, tr("Album Applet"), - tr("Album applet is not available. Please reinstall firmware.")); - return; - } - - system->GetFrontendAppletHolder().SetCurrentAppletId(Service::AM::AppletId::PhotoViewer); - - const auto filename = QString::fromStdString(album_nca->GetFullPath()); - UISettings::values.roms_path = QFileInfo(filename).path().toStdString(); - BootGame(filename, LibraryAppletParameters(AlbumId, Service::AM::AppletId::PhotoViewer)); -} - -void GMainWindow::OnCabinet(Service::NFP::CabinetMode mode) { - constexpr u64 CabinetId = static_cast<u64>(Service::AM::AppletProgramId::Cabinet); - auto bis_system = system->GetFileSystemController().GetSystemNANDContents(); - if (!bis_system) { - QMessageBox::warning(this, tr("No firmware available"), - tr("Please install the firmware to use the Cabinet applet.")); - return; - } - - auto cabinet_nca = bis_system->GetEntry(CabinetId, FileSys::ContentRecordType::Program); - if (!cabinet_nca) { - QMessageBox::warning(this, tr("Cabinet Applet"), - tr("Cabinet applet is not available. Please reinstall firmware.")); - return; - } - - system->GetFrontendAppletHolder().SetCurrentAppletId(Service::AM::AppletId::Cabinet); - system->GetFrontendAppletHolder().SetCabinetMode(mode); - - const auto filename = QString::fromStdString(cabinet_nca->GetFullPath()); - UISettings::values.roms_path = QFileInfo(filename).path().toStdString(); - BootGame(filename, LibraryAppletParameters(CabinetId, Service::AM::AppletId::Cabinet)); -} - -void GMainWindow::OnMiiEdit() { - constexpr u64 MiiEditId = static_cast<u64>(Service::AM::AppletProgramId::MiiEdit); - auto bis_system = system->GetFileSystemController().GetSystemNANDContents(); - if (!bis_system) { - QMessageBox::warning(this, tr("No firmware available"), - tr("Please install the firmware to use the Mii editor.")); - return; - } - - auto mii_applet_nca = bis_system->GetEntry(MiiEditId, FileSys::ContentRecordType::Program); - if (!mii_applet_nca) { - QMessageBox::warning(this, tr("Mii Edit Applet"), - tr("Mii editor is not available. Please reinstall firmware.")); - return; - } - - system->GetFrontendAppletHolder().SetCurrentAppletId(Service::AM::AppletId::MiiEdit); - - const auto filename = QString::fromStdString((mii_applet_nca->GetFullPath())); - UISettings::values.roms_path = QFileInfo(filename).path().toStdString(); - BootGame(filename, LibraryAppletParameters(MiiEditId, Service::AM::AppletId::MiiEdit)); -} - -void GMainWindow::OnOpenControllerMenu() { - constexpr u64 ControllerAppletId = static_cast<u64>(Service::AM::AppletProgramId::Controller); - auto bis_system = system->GetFileSystemController().GetSystemNANDContents(); - if (!bis_system) { - QMessageBox::warning(this, tr("No firmware available"), - tr("Please install the firmware to use the Controller Menu.")); - return; - } - - auto controller_applet_nca = - bis_system->GetEntry(ControllerAppletId, FileSys::ContentRecordType::Program); - if (!controller_applet_nca) { - QMessageBox::warning(this, tr("Controller Applet"), - tr("Controller Menu is not available. Please reinstall firmware.")); - return; - } - - system->GetFrontendAppletHolder().SetCurrentAppletId(Service::AM::AppletId::Controller); - - const auto filename = QString::fromStdString((controller_applet_nca->GetFullPath())); - UISettings::values.roms_path = QFileInfo(filename).path().toStdString(); - BootGame(filename, - LibraryAppletParameters(ControllerAppletId, Service::AM::AppletId::Controller)); -} - -void GMainWindow::OnCaptureScreenshot() { - if (emu_thread == nullptr || !emu_thread->IsRunning()) { - return; - } - - const u64 title_id = system->GetApplicationProcessProgramID(); - const auto screenshot_path = - QString::fromStdString(Common::FS::GetYuzuPathString(Common::FS::YuzuPath::ScreenshotsDir)); - const auto date = - QDateTime::currentDateTime().toString(QStringLiteral("yyyy-MM-dd_hh-mm-ss-zzz")); - QString filename = QStringLiteral("%1/%2_%3.png") - .arg(screenshot_path) - .arg(title_id, 16, 16, QLatin1Char{'0'}) - .arg(date); - - if (!Common::FS::CreateDir(screenshot_path.toStdString())) { - return; - } - -#ifdef _WIN32 - if (UISettings::values.enable_screenshot_save_as) { - OnPauseGame(); - filename = QFileDialog::getSaveFileName(this, tr("Capture Screenshot"), filename, - tr("PNG Image (*.png)")); - OnStartGame(); - if (filename.isEmpty()) { - return; - } - } -#endif - render_window->CaptureScreenshot(filename); -} - -// TODO: Written 2020-10-01: Remove per-game config migration code when it is irrelevant -void GMainWindow::MigrateConfigFiles() { - const auto config_dir_fs_path = Common::FS::GetYuzuPath(Common::FS::YuzuPath::ConfigDir); - const QDir config_dir = - QDir(QString::fromStdString(Common::FS::PathToUTF8String(config_dir_fs_path))); - const QStringList config_dir_list = config_dir.entryList(QStringList(QStringLiteral("*.ini"))); - - if (!Common::FS::CreateDirs(config_dir_fs_path / "custom")) { - LOG_ERROR(Frontend, "Failed to create new config file directory"); - } - - for (auto it = config_dir_list.constBegin(); it != config_dir_list.constEnd(); ++it) { - const auto filename = it->toStdString(); - if (filename.find_first_not_of("0123456789abcdefACBDEF", 0) < 16) { - continue; - } - 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.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); - } - } -} - -void GMainWindow::UpdateWindowTitle(std::string_view title_name, std::string_view title_version, - std::string_view gpu_vendor) { - const auto branch_name = std::string(Common::g_scm_branch); - const auto description = std::string(Common::g_scm_desc); - const auto build_id = std::string(Common::g_build_id); - - const auto yuzu_title = fmt::format("yuzu | {}-{}", branch_name, description); - const auto override_title = - fmt::format(fmt::runtime(std::string(Common::g_title_bar_format_idle)), build_id); - const auto window_title = override_title.empty() ? yuzu_title : override_title; - - if (title_name.empty()) { - setWindowTitle(QString::fromStdString(window_title)); - } else { - const auto run_title = [window_title, title_name, title_version, gpu_vendor]() { - if (title_version.empty()) { - return fmt::format("{} | {} | {}", window_title, title_name, gpu_vendor); - } - return fmt::format("{} | {} | {} | {}", window_title, title_name, title_version, - gpu_vendor); - }(); - setWindowTitle(QString::fromStdString(run_title)); - } -} - -std::string GMainWindow::CreateTASFramesString( - std::array<size_t, InputCommon::TasInput::PLAYER_NUMBER> frames) const { - std::string string = ""; - size_t maxPlayerIndex = 0; - for (size_t i = 0; i < frames.size(); i++) { - if (frames[i] != 0) { - if (maxPlayerIndex != 0) - string += ", "; - while (maxPlayerIndex++ != i) - string += "0, "; - string += std::to_string(frames[i]); - } - } - return string; -} - -QString GMainWindow::GetTasStateDescription() const { - auto [tas_status, current_tas_frame, total_tas_frames] = input_subsystem->GetTas()->GetStatus(); - std::string tas_frames_string = CreateTASFramesString(total_tas_frames); - switch (tas_status) { - case InputCommon::TasInput::TasState::Running: - return tr("TAS state: Running %1/%2") - .arg(current_tas_frame) - .arg(QString::fromStdString(tas_frames_string)); - case InputCommon::TasInput::TasState::Recording: - return tr("TAS state: Recording %1").arg(total_tas_frames[0]); - case InputCommon::TasInput::TasState::Stopped: - return tr("TAS state: Idle %1/%2") - .arg(current_tas_frame) - .arg(QString::fromStdString(tas_frames_string)); - default: - return tr("TAS State: Invalid"); - } -} - -void GMainWindow::OnTasStateChanged() { - bool is_running = false; - bool is_recording = false; - if (emulation_running) { - const InputCommon::TasInput::TasState tas_status = - std::get<0>(input_subsystem->GetTas()->GetStatus()); - is_running = tas_status == InputCommon::TasInput::TasState::Running; - is_recording = tas_status == InputCommon::TasInput::TasState::Recording; - } - - ui->action_TAS_Start->setText(is_running ? tr("&Stop Running") : tr("&Start")); - ui->action_TAS_Record->setText(is_recording ? tr("Stop R&ecording") : tr("R&ecord")); - - ui->action_TAS_Start->setEnabled(emulation_running); - ui->action_TAS_Record->setEnabled(emulation_running); - ui->action_TAS_Reset->setEnabled(emulation_running); -} - -void GMainWindow::UpdateStatusBar() { - if (emu_thread == nullptr || !system->IsPoweredOn()) { - status_bar_update_timer.stop(); - return; - } - - if (Settings::values.tas_enable) { - tas_label->setText(GetTasStateDescription()); - } else { - tas_label->clear(); - } - - auto results = system->GetAndResetPerfStats(); - auto& shader_notify = system->GPU().ShaderNotify(); - const int shaders_building = shader_notify.ShadersBuilding(); - - if (shaders_building > 0) { - shader_building_label->setText(tr("Building: %n shader(s)", "", shaders_building)); - shader_building_label->setVisible(true); - } else { - shader_building_label->setVisible(false); - } - - const auto res_info = Settings::values.resolution_info; - const auto res_scale = res_info.up_factor; - res_scale_label->setText( - tr("Scale: %1x", "%1 is the resolution scaling factor").arg(res_scale)); - - if (Settings::values.use_speed_limit.GetValue()) { - emu_speed_label->setText(tr("Speed: %1% / %2%") - .arg(results.emulation_speed * 100.0, 0, 'f', 0) - .arg(Settings::values.speed_limit.GetValue())); - } else { - emu_speed_label->setText(tr("Speed: %1%").arg(results.emulation_speed * 100.0, 0, 'f', 0)); - } - if (!Settings::values.use_speed_limit) { - game_fps_label->setText( - 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(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)); - - res_scale_label->setVisible(true); - emu_speed_label->setVisible(!Settings::values.use_multi_core.GetValue()); - game_fps_label->setVisible(true); - emu_frametime_label->setVisible(true); - firmware_label->setVisible(false); -} - -void GMainWindow::UpdateGPUAccuracyButton() { - const auto gpu_accuracy = Settings::values.gpu_accuracy.GetValue(); - const auto gpu_accuracy_text = - ConfigurationShared::gpu_accuracy_texts_map.find(gpu_accuracy)->second; - gpu_accuracy_button->setText(gpu_accuracy_text.toUpper()); - gpu_accuracy_button->setChecked(gpu_accuracy != Settings::GpuAccuracy::Normal); -} - -void GMainWindow::UpdateDockedButton() { - const auto console_mode = Settings::values.use_docked_mode.GetValue(); - dock_status_button->setChecked(Settings::IsDockedMode()); - dock_status_button->setText( - ConfigurationShared::use_docked_mode_texts_map.find(console_mode)->second.toUpper()); -} - -void GMainWindow::UpdateAPIText() { - const auto api = Settings::values.renderer_backend.GetValue(); - const auto renderer_status_text = - ConfigurationShared::renderer_backend_texts_map.find(api)->second; - renderer_status_button->setText( - api == Settings::RendererBackend::OpenGL - ? tr("%1 %2").arg(renderer_status_text.toUpper(), - ConfigurationShared::shader_backend_texts_map - .find(Settings::values.shader_backend.GetValue()) - ->second) - : renderer_status_text.toUpper()); -} - -void GMainWindow::UpdateFilterText() { - const auto filter = Settings::values.scaling_filter.GetValue(); - const auto filter_text = ConfigurationShared::scaling_filter_texts_map.find(filter)->second; - filter_status_button->setText(filter == Settings::ScalingFilter::Fsr ? tr("FSR") - : filter_text.toUpper()); -} - -void GMainWindow::UpdateAAText() { - const auto aa_mode = Settings::values.anti_aliasing.GetValue(); - const auto aa_text = ConfigurationShared::anti_aliasing_texts_map.find(aa_mode)->second; - aa_status_button->setText(aa_mode == Settings::AntiAliasing::None - ? QStringLiteral(QT_TRANSLATE_NOOP("GMainWindow", "NO AA")) - : aa_text.toUpper()); -} - -void GMainWindow::UpdateVolumeUI() { - const auto volume_value = static_cast<int>(Settings::values.volume.GetValue()); - volume_slider->setValue(volume_value); - if (Settings::values.audio_muted) { - volume_button->setChecked(false); - volume_button->setText(tr("VOLUME: MUTE")); - } else { - volume_button->setChecked(true); - volume_button->setText(tr("VOLUME: %1%", "Volume percentage (e.g. 50%)").arg(volume_value)); - } -} - -void GMainWindow::UpdateStatusButtons() { - renderer_status_button->setChecked(Settings::values.renderer_backend.GetValue() == - Settings::RendererBackend::Vulkan); - UpdateAPIText(); - UpdateGPUAccuracyButton(); - UpdateDockedButton(); - UpdateFilterText(); - UpdateAAText(); - UpdateVolumeUI(); -} - -void GMainWindow::UpdateUISettings() { - if (!ui->action_Fullscreen->isChecked()) { - UISettings::values.geometry = saveGeometry(); - UISettings::values.renderwindow_geometry = render_window->saveGeometry(); - } - UISettings::values.state = saveState(); -#if MICROPROFILE_ENABLED - UISettings::values.microprofile_geometry = microProfileDialog->saveGeometry(); - UISettings::values.microprofile_visible = microProfileDialog->isVisible(); -#endif - UISettings::values.single_window_mode = ui->action_Single_Window_Mode->isChecked(); - UISettings::values.fullscreen = ui->action_Fullscreen->isChecked(); - UISettings::values.display_titlebar = ui->action_Display_Dock_Widget_Headers->isChecked(); - UISettings::values.show_filter_bar = ui->action_Show_Filter_Bar->isChecked(); - UISettings::values.show_status_bar = ui->action_Show_Status_Bar->isChecked(); - UISettings::values.first_start = false; -} - -void GMainWindow::UpdateInputDrivers() { - if (!input_subsystem) { - return; - } - input_subsystem->PumpEvents(); -} - -void GMainWindow::HideMouseCursor() { - if (emu_thread == nullptr && UISettings::values.hide_mouse) { - mouse_hide_timer.stop(); - ShowMouseCursor(); - return; - } - render_window->setCursor(QCursor(Qt::BlankCursor)); -} - -void GMainWindow::ShowMouseCursor() { - render_window->unsetCursor(); - if (emu_thread != nullptr && UISettings::values.hide_mouse) { - mouse_hide_timer.start(); - } -} - -void GMainWindow::OnMouseActivity() { - if (!Settings::values.mouse_panning) { - ShowMouseCursor(); - } -} - -void GMainWindow::OnCheckFirmwareDecryption() { - system->GetFileSystemController().CreateFactories(*vfs); - if (!ContentManager::AreKeysPresent()) { - QMessageBox::warning( - this, tr("Derivation Components Missing"), - tr("Encryption keys are missing. " - "<br>Please follow <a href='https://yuzu-emu.org/help/quickstart/'>the yuzu " - "quickstart guide</a> to get all your keys, firmware and " - "games.")); - } - SetFirmwareVersion(); - UpdateMenuState(); -} - -bool GMainWindow::CheckFirmwarePresence() { - constexpr u64 MiiEditId = static_cast<u64>(Service::AM::AppletProgramId::MiiEdit); - - auto bis_system = system->GetFileSystemController().GetSystemNANDContents(); - if (!bis_system) { - return false; - } - - auto mii_applet_nca = bis_system->GetEntry(MiiEditId, FileSys::ContentRecordType::Program); - if (!mii_applet_nca) { - return false; - } - - return true; -} - -void GMainWindow::SetFirmwareVersion() { - Service::Set::FirmwareVersionFormat firmware_data{}; - const auto result = Service::Set::GetFirmwareVersionImpl( - firmware_data, *system, Service::Set::GetFirmwareVersionType::Version2); - - if (result.IsError() || !CheckFirmwarePresence()) { - LOG_INFO(Frontend, "Installed firmware: No firmware available"); - firmware_label->setVisible(false); - return; - } - - firmware_label->setVisible(true); - - const std::string display_version(firmware_data.display_version.data()); - const std::string display_title(firmware_data.display_title.data()); - - LOG_INFO(Frontend, "Installed firmware: {}", display_title); - - firmware_label->setText(QString::fromStdString(display_version)); - firmware_label->setToolTip(QString::fromStdString(display_title)); -} - -bool GMainWindow::SelectRomFSDumpTarget(const FileSys::ContentProvider& installed, u64 program_id, - u64* selected_title_id, u8* selected_content_record_type) { - using ContentInfo = std::tuple<u64, FileSys::TitleType, FileSys::ContentRecordType>; - boost::container::flat_set<ContentInfo> available_title_ids; - - const auto RetrieveEntries = [&](FileSys::TitleType title_type, - FileSys::ContentRecordType record_type) { - const auto entries = installed.ListEntriesFilter(title_type, record_type); - for (const auto& entry : entries) { - if (FileSys::GetBaseTitleID(entry.title_id) == program_id && - installed.GetEntry(entry)->GetStatus() == Loader::ResultStatus::Success) { - available_title_ids.insert({entry.title_id, title_type, record_type}); - } - } - }; - - RetrieveEntries(FileSys::TitleType::Application, FileSys::ContentRecordType::Program); - RetrieveEntries(FileSys::TitleType::Application, FileSys::ContentRecordType::HtmlDocument); - RetrieveEntries(FileSys::TitleType::Application, FileSys::ContentRecordType::LegalInformation); - RetrieveEntries(FileSys::TitleType::AOC, FileSys::ContentRecordType::Data); - - if (available_title_ids.empty()) { - return false; - } - - size_t title_index = 0; - - if (available_title_ids.size() > 1) { - QStringList list; - for (auto& [title_id, title_type, record_type] : available_title_ids) { - const auto hex_title_id = QString::fromStdString(fmt::format("{:X}", title_id)); - if (record_type == FileSys::ContentRecordType::Program) { - list.push_back(QStringLiteral("Program [%1]").arg(hex_title_id)); - } else if (record_type == FileSys::ContentRecordType::HtmlDocument) { - list.push_back(QStringLiteral("HTML document [%1]").arg(hex_title_id)); - } else if (record_type == FileSys::ContentRecordType::LegalInformation) { - list.push_back(QStringLiteral("Legal information [%1]").arg(hex_title_id)); - } else { - list.push_back( - QStringLiteral("DLC %1 [%2]").arg(title_id & 0x7FF).arg(hex_title_id)); - } - } - - bool ok; - const auto res = QInputDialog::getItem( - this, tr("Select RomFS Dump Target"), - tr("Please select which RomFS you would like to dump."), list, 0, false, &ok); - if (!ok) { - return false; - } - - title_index = list.indexOf(res); - } - - const auto& [title_id, title_type, record_type] = *available_title_ids.nth(title_index); - *selected_title_id = title_id; - *selected_content_record_type = static_cast<u8>(record_type); - return true; -} - -bool GMainWindow::ConfirmClose() { - if (emu_thread == nullptr || - UISettings::values.confirm_before_stopping.GetValue() == ConfirmStop::Ask_Never) { - return true; - } - if (!system->GetExitLocked() && - UISettings::values.confirm_before_stopping.GetValue() == ConfirmStop::Ask_Based_On_Game) { - return true; - } - const auto text = tr("Are you sure you want to close yuzu?"); - return question(this, tr("yuzu"), text); -} - -void GMainWindow::closeEvent(QCloseEvent* event) { - if (!ConfirmClose()) { - event->ignore(); - return; - } - - UpdateUISettings(); - game_list->SaveInterfaceLayout(); - UISettings::SaveWindowState(); - hotkey_registry.SaveHotkeys(); - - // Unload controllers early - controller_dialog->UnloadController(); - game_list->UnloadController(); - - // Shutdown session if the emu thread is active... - if (emu_thread != nullptr) { - ShutdownGame(); - } - - render_window->close(); - multiplayer_state->Close(); - system->HIDCore().UnloadInputDevices(); - system->GetRoomNetwork().Shutdown(); - - QWidget::closeEvent(event); -} - -static bool IsSingleFileDropEvent(const QMimeData* mime) { - return mime->hasUrls() && mime->urls().length() == 1; -} - -void GMainWindow::AcceptDropEvent(QDropEvent* event) { - if (IsSingleFileDropEvent(event->mimeData())) { - event->setDropAction(Qt::DropAction::LinkAction); - event->accept(); - } -} - -bool GMainWindow::DropAction(QDropEvent* event) { - if (!IsSingleFileDropEvent(event->mimeData())) { - return false; - } - - const QMimeData* mime_data = event->mimeData(); - const QString& filename = mime_data->urls().at(0).toLocalFile(); - - if (emulation_running && QFileInfo(filename).suffix() == QStringLiteral("bin")) { - // Amiibo - LoadAmiibo(filename); - } else { - // Game - if (ConfirmChangeGame()) { - BootGame(filename, ApplicationAppletParameters()); - } - } - return true; -} - -void GMainWindow::dropEvent(QDropEvent* event) { - DropAction(event); -} - -void GMainWindow::dragEnterEvent(QDragEnterEvent* event) { - AcceptDropEvent(event); -} - -void GMainWindow::dragMoveEvent(QDragMoveEvent* event) { - AcceptDropEvent(event); -} - -bool GMainWindow::ConfirmChangeGame() { - if (emu_thread == nullptr) - return true; - - // Use custom question to link controller navigation - return question( - this, tr("yuzu"), - tr("Are you sure you want to stop the emulation? Any unsaved progress will be lost."), - QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes); -} - -bool GMainWindow::ConfirmForceLockedExit() { - if (emu_thread == nullptr) { - return true; - } - const auto text = tr("The currently running application has requested yuzu to not exit.\n\n" - "Would you like to bypass this and exit anyway?"); - - return question(this, tr("yuzu"), text); -} - -void GMainWindow::RequestGameExit() { - if (!system->IsPoweredOn()) { - return; - } - - system->SetExitRequested(true); - system->GetAppletManager().RequestExit(); -} - -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 = QString::fromUtf8( - UISettings::themes[static_cast<size_t>(UISettings::default_theme)].second); - QString current_theme = QString::fromStdString(UISettings::values.theme); - - if (current_theme.isEmpty()) { - 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(QStringList(default_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); - if (!f.open(QFile::ReadOnly | QFile::Text)) { - LOG_ERROR(Frontend, "Unable to open style \"{}\", fallback to the default theme", - UISettings::values.theme); - current_theme = default_theme; - } - } - - QString theme_uri{QStringLiteral(":%1/style.qss").arg(current_theme)}; - QFile f(theme_uri); - if (f.open(QFile::ReadOnly | QFile::Text)) { - QTextStream ts(&f); - qApp->setStyleSheet(ts.readAll()); - setStyleSheet(ts.readAll()); - } else { - LOG_ERROR(Frontend, "Unable to set style \"{}\", stylesheet file not found", - UISettings::values.theme); - qApp->setStyleSheet({}); - setStyleSheet({}); - } -} - -void GMainWindow::LoadTranslation() { - bool loaded; - - if (UISettings::values.language.GetValue().empty()) { - // If the selected language is empty, use system locale - loaded = translator.load(QLocale(), {}, {}, QStringLiteral(":/languages/")); - } else { - // Otherwise load from the specified file - loaded = translator.load(QString::fromStdString(UISettings::values.language.GetValue()), - QStringLiteral(":/languages/")); - } - - if (loaded) { - qApp->installTranslator(&translator); - } else { - UISettings::values.language = std::string("en"); - } -} - -void GMainWindow::OnLanguageChanged(const QString& locale) { - if (UISettings::values.language.GetValue() != std::string("en")) { - qApp->removeTranslator(&translator); - } - - UISettings::values.language = locale.toStdString(); - LoadTranslation(); - ui->retranslateUi(this); - multiplayer_state->retranslateUi(); - UpdateWindowTitle(); -} - -void GMainWindow::SetDiscordEnabled([[maybe_unused]] bool state) { -#ifdef USE_DISCORD_PRESENCE - if (state) { - discord_rpc = std::make_unique<DiscordRPC::DiscordImpl>(*system); - } else { - discord_rpc = std::make_unique<DiscordRPC::NullImpl>(); - } -#else - discord_rpc = std::make_unique<DiscordRPC::NullImpl>(); -#endif - discord_rpc->Update(); -} - -#ifdef __unix__ -void GMainWindow::SetGamemodeEnabled(bool state) { - if (emulation_running) { - Common::Linux::SetGamemodeState(state); - } -} -#endif - -void GMainWindow::changeEvent(QEvent* event) { -#ifdef __unix__ - // 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 = QString::fromStdString(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 // __unix__ - QWidget::changeEvent(event); -} - -Service::AM::FrontendAppletParameters GMainWindow::ApplicationAppletParameters() { - return Service::AM::FrontendAppletParameters{ - .applet_id = Service::AM::AppletId::Application, - .applet_type = Service::AM::AppletType::Application, - }; -} - -Service::AM::FrontendAppletParameters GMainWindow::LibraryAppletParameters( - u64 program_id, Service::AM::AppletId applet_id) { - return Service::AM::FrontendAppletParameters{ - .program_id = program_id, - .applet_id = applet_id, - .applet_type = Service::AM::AppletType::LibraryApplet, - }; -} - -void VolumeButton::wheelEvent(QWheelEvent* event) { - - int num_degrees = event->angleDelta().y() / 8; - int num_steps = (num_degrees / 15) * scroll_multiplier; - // Stated in QT docs: Most mouse types work in steps of 15 degrees, in which case the delta - // value is a multiple of 120; i.e., 120 units * 1/8 = 15 degrees. - - if (num_steps > 0) { - Settings::values.volume.SetValue( - std::min(200, Settings::values.volume.GetValue() + num_steps)); - } else { - Settings::values.volume.SetValue( - std::max(0, Settings::values.volume.GetValue() + num_steps)); - } - - scroll_multiplier = std::min(MaxMultiplier, scroll_multiplier * 2); - scroll_timer.start(100); // reset the multiplier if no scroll event occurs within 100 ms - - emit VolumeChanged(); - event->accept(); -} - -void VolumeButton::ResetMultiplier() { - scroll_multiplier = 1; -} - -#ifdef main -#undef main -#endif - -static void SetHighDPIAttributes() { -#ifdef _WIN32 - // For Windows, we want to avoid scaling artifacts on fractional scaling ratios. - // This is done by setting the optimal scaling policy for the primary screen. - - // Create a temporary QApplication. - int temp_argc = 0; - char** temp_argv = nullptr; - QApplication temp{temp_argc, temp_argv}; - - // Get the current screen geometry. - const QScreen* primary_screen = QGuiApplication::primaryScreen(); - if (primary_screen == nullptr) { - return; - } - - const QRect screen_rect = primary_screen->geometry(); - const int real_width = screen_rect.width(); - const int real_height = screen_rect.height(); - const float real_ratio = primary_screen->logicalDotsPerInch() / 96.0f; - - // Recommended minimum width and height for proper window fit. - // Any screen with a lower resolution than this will still have a scale of 1. - constexpr float minimum_width = 1350.0f; - constexpr float minimum_height = 900.0f; - - const float width_ratio = std::max(1.0f, real_width / minimum_width); - const float height_ratio = std::max(1.0f, real_height / minimum_height); - - // Get the lower of the 2 ratios and truncate, this is the maximum integer scale. - const float max_ratio = std::trunc(std::min(width_ratio, height_ratio)); - - if (max_ratio > real_ratio) { - QApplication::setHighDpiScaleFactorRoundingPolicy( - Qt::HighDpiScaleFactorRoundingPolicy::Round); - } else { - QApplication::setHighDpiScaleFactorRoundingPolicy( - Qt::HighDpiScaleFactorRoundingPolicy::Floor); - } -#else - // Other OSes should be better than Windows at fractional scaling. - QApplication::setHighDpiScaleFactorRoundingPolicy( - Qt::HighDpiScaleFactorRoundingPolicy::PassThrough); -#endif - - QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); - QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); -} - -int main(int argc, char* argv[]) { - std::unique_ptr<QtConfig> config = std::make_unique<QtConfig>(); - UISettings::RestoreWindowState(config); - bool has_broken_vulkan = false; - bool is_child = false; - if (CheckEnvVars(&is_child)) { - return 0; - } - - if (StartupChecks(argv[0], &has_broken_vulkan, - Settings::values.perform_vulkan_check.GetValue())) { - return 0; - } - -#ifdef YUZU_CRASH_DUMPS - Breakpad::InstallCrashHandler(); -#endif - - Common::DetachedTasks detached_tasks; - MicroProfileOnThreadCreate("Frontend"); - SCOPE_EXIT { - MicroProfileShutdown(); - }; - - Common::ConfigureNvidiaEnvironmentFlags(); - - // Init settings params - QCoreApplication::setOrganizationName(QStringLiteral("yuzu team")); - QCoreApplication::setApplicationName(QStringLiteral("yuzu")); - -#ifdef _WIN32 - // Increases the maximum open file limit to 8192 - _setmaxstdio(8192); -#endif - -#ifdef __APPLE__ - // If you start a bundle (binary) on OSX without the Terminal, the working directory is "/". - // But since we require the working directory to be the executable path for the location of - // the user folder in the Qt Frontend, we need to cd into that working directory - const auto bin_path = Common::FS::GetBundleDirectory() / ".."; - chdir(Common::FS::PathToUTF8String(bin_path).c_str()); -#endif - -#ifdef __linux__ - // Set the DISPLAY variable in order to open web browsers - // TODO (lat9nq): Find a better solution for AppImages to start external applications - if (QString::fromLocal8Bit(qgetenv("DISPLAY")).isEmpty()) { - qputenv("DISPLAY", ":0"); - } - - // Fix the Wayland appId. This needs to match the name of the .desktop file without the .desktop - // suffix. - QGuiApplication::setDesktopFileName(QStringLiteral("org.yuzu_emu.yuzu")); -#endif - - SetHighDPIAttributes(); - -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - // Disables the "?" button on all dialogs. Disabled by default on Qt6. - QCoreApplication::setAttribute(Qt::AA_DisableWindowContextHelpButton); -#endif - - // Enables the core to make the qt created contexts current on std::threads - QCoreApplication::setAttribute(Qt::AA_DontCheckOpenGLContextThreadAffinity); - - QApplication app(argc, argv); - -#ifdef _WIN32 - OverrideWindowsFont(); -#endif - - // 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 -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - const QLocale locale = QLocale::system(); - if (QStringLiteral("\u3008") == locale.toString(1)) { - QLocale::setDefault(QLocale::system().name()); - } -#endif - - // Qt changes the locale and causes issues in float conversion using std::to_string() when - // generating shaders - setlocale(LC_ALL, "C"); - - GMainWindow main_window{std::move(config), has_broken_vulkan}; - // After settings have been loaded by GMainWindow, apply the filter - main_window.show(); - - QObject::connect(&app, &QGuiApplication::applicationStateChanged, &main_window, - &GMainWindow::OnAppFocusStateChanged); - - int result = app.exec(); - detached_tasks.WaitForAllTasks(); - return result; -} diff --git a/src/yuzu/main.h b/src/yuzu/main.h deleted file mode 100644 index cb68f5a75..000000000 --- a/src/yuzu/main.h +++ /dev/null @@ -1,580 +0,0 @@ -// SPDX-FileCopyrightText: 2014 Citra Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include <memory> -#include <optional> - -#include <filesystem> -#include <QMainWindow> -#include <QMessageBox> -#include <QPushButton> -#include <QTimer> -#include <QTranslator> - -#include "common/announce_multiplayer_room.h" -#include "common/common_types.h" -#include "configuration/qt_config.h" -#include "frontend_common/content_manager.h" -#include "input_common/drivers/tas_input.h" -#include "yuzu/compatibility_list.h" -#include "yuzu/hotkeys.h" -#include "yuzu/util/controller_navigation.h" - -#ifdef __unix__ -#include <QVariant> -#include <QtDBus/QDBusInterface> -#include <QtDBus/QtDBus> -#endif - -class QtConfig; -class ClickableLabel; -class EmuThread; -class GameList; -class GImageInfo; -class GRenderWindow; -class LoadingScreen; -class MicroProfileDialog; -class OverlayDialog; -class ProfilerWidget; -class ControllerDialog; -class QLabel; -class MultiplayerState; -class QPushButton; -class QProgressDialog; -class QSlider; -class QHBoxLayout; -class WaitTreeWidget; -enum class GameListOpenTarget; -enum class GameListRemoveTarget; -enum class GameListShortcutTarget; -enum class DumpRomFSTarget; -enum class InstalledEntryType; -class GameListPlaceholder; - -class QtAmiiboSettingsDialog; -class QtControllerSelectorDialog; -class QtProfileSelectionDialog; -class QtSoftwareKeyboardDialog; -class QtNXWebEngineView; - -enum class StartGameType { - Normal, // Can use custom configuration - Global, // Only uses global configuration -}; - -namespace Core { -enum class SystemResultStatus : u32; -class System; -} // namespace Core - -namespace Core::Frontend { -struct CabinetParameters; -struct ControllerParameters; -struct InlineAppearParameters; -struct InlineTextParameters; -struct KeyboardInitializeParameters; -struct ProfileSelectParameters; -} // namespace Core::Frontend - -namespace DiscordRPC { -class DiscordInterface; -} - -namespace PlayTime { -class PlayTimeManager; -} - -namespace FileSys { -class ContentProvider; -class ManualContentProvider; -class VfsFilesystem; -} // namespace FileSys - -namespace InputCommon { -class InputSubsystem; -} - -namespace Service::AM { -struct FrontendAppletParameters; -enum class AppletId : u32; -} // namespace Service::AM - -namespace Service::AM::Frontend { -enum class SwkbdResult : u32; -enum class SwkbdTextCheckResult : u32; -enum class SwkbdReplyType : u32; -enum class WebExitReason : u32; -} // namespace Service::AM::Frontend - -namespace Service::NFC { -class NfcDevice; -} // namespace Service::NFC - -namespace Service::NFP { -enum class CabinetMode : u8; -} // namespace Service::NFP - -namespace Ui { -class MainWindow; -} - -enum class EmulatedDirectoryTarget { - NAND, - SDMC, -}; - -namespace VkDeviceInfo { -class Record; -} - -class VolumeButton : public QPushButton { - Q_OBJECT -public: - explicit VolumeButton(QWidget* parent = nullptr) : QPushButton(parent), scroll_multiplier(1) { - connect(&scroll_timer, &QTimer::timeout, this, &VolumeButton::ResetMultiplier); - } - -signals: - void VolumeChanged(); - -protected: - void wheelEvent(QWheelEvent* event) override; - -private slots: - void ResetMultiplier(); - -private: - int scroll_multiplier; - QTimer scroll_timer; - constexpr static int MaxMultiplier = 8; -}; - -class GMainWindow : public QMainWindow { - Q_OBJECT - - /// Max number of recently loaded items to keep track of - static const int max_recent_files_item = 10; - - enum { - CREATE_SHORTCUT_MSGBOX_FULLSCREEN_YES, - CREATE_SHORTCUT_MSGBOX_SUCCESS, - CREATE_SHORTCUT_MSGBOX_ERROR, - CREATE_SHORTCUT_MSGBOX_APPVOLATILE_WARNING, - }; - -public: - void filterBarSetChecked(bool state); - void UpdateUITheme(); - explicit GMainWindow(std::unique_ptr<QtConfig> config_, bool has_broken_vulkan); - ~GMainWindow() override; - - bool DropAction(QDropEvent* event); - void AcceptDropEvent(QDropEvent* event); - -signals: - - /** - * Signal that is emitted when a new EmuThread has been created and an emulation session is - * about to start. At this time, the core system emulation has been initialized, and all - * emulation handles and memory should be valid. - * - * @param emu_thread Pointer to the newly created EmuThread (to be used by widgets that need to - * access/change emulation state). - */ - void EmulationStarting(EmuThread* emu_thread); - - /** - * Signal that is emitted when emulation is about to stop. At this time, the EmuThread and core - * system emulation handles and memory are still valid, but are about become invalid. - */ - void EmulationStopping(); - - // Signal that tells widgets to update icons to use the current theme - void UpdateThemedIcons(); - - void UpdateInstallProgress(); - - void AmiiboSettingsFinished(bool is_success, const std::string& name); - - void ControllerSelectorReconfigureFinished(bool is_success); - - void ErrorDisplayFinished(); - - void ProfileSelectorFinishedSelection(std::optional<Common::UUID> uuid); - - void SoftwareKeyboardSubmitNormalText(Service::AM::Frontend::SwkbdResult result, - std::u16string submitted_text, bool confirmed); - void SoftwareKeyboardSubmitInlineText(Service::AM::Frontend::SwkbdReplyType reply_type, - std::u16string submitted_text, s32 cursor_position); - - void WebBrowserExtractOfflineRomFS(); - void WebBrowserClosed(Service::AM::Frontend::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 AmiiboSettingsShowDialog(const Core::Frontend::CabinetParameters& parameters, - std::shared_ptr<Service::NFC::NfcDevice> nfp_device); - void AmiiboSettingsRequestExit(); - void ControllerSelectorReconfigureControllers( - const Core::Frontend::ControllerParameters& parameters); - void ControllerSelectorRequestExit(); - void SoftwareKeyboardInitialize( - bool is_inline, Core::Frontend::KeyboardInitializeParameters initialize_parameters); - void SoftwareKeyboardShowNormal(); - void SoftwareKeyboardShowTextCheck( - Service::AM::Frontend::SwkbdTextCheckResult text_check_result, - std::u16string text_check_message); - void SoftwareKeyboardShowInline(Core::Frontend::InlineAppearParameters appear_parameters); - void SoftwareKeyboardHideInline(); - void SoftwareKeyboardInlineTextChanged(Core::Frontend::InlineTextParameters text_parameters); - void SoftwareKeyboardExit(); - void ErrorDisplayDisplayError(QString error_code, QString error_text); - void ErrorDisplayRequestExit(); - void ProfileSelectorSelectProfile(const Core::Frontend::ProfileSelectParameters& parameters); - void ProfileSelectorRequestExit(); - void WebBrowserOpenWebPage(const std::string& main_url, const std::string& additional_args, - bool is_local); - void WebBrowserRequestExit(); - void OnAppFocusStateChanged(Qt::ApplicationState state); - void OnTasStateChanged(); - -private: - /// Updates an action's shortcut and text to reflect an updated hotkey from the hotkey registry. - void LinkActionShortcut(QAction* action, const QString& action_name, - const bool tas_allowed = false); - - void RegisterMetaTypes(); - - void InitializeWidgets(); - void InitializeDebugWidgets(); - void InitializeRecentFileMenuActions(); - - void SetDefaultUIGeometry(); - void RestoreUIState(); - - void ConnectWidgetEvents(); - void ConnectMenuEvents(); - void UpdateMenuState(); - - void SetupPrepareForSleep(); - - void PreventOSSleep(); - void AllowOSSleep(); - - bool LoadROM(const QString& filename, Service::AM::FrontendAppletParameters params); - void BootGame(const QString& filename, Service::AM::FrontendAppletParameters params, - StartGameType with_config = StartGameType::Normal); - void BootGameFromList(const QString& filename, StartGameType with_config); - void ShutdownGame(); - - void ShowTelemetryCallout(); - void SetDiscordEnabled(bool state); - void LoadAmiibo(const QString& filename); - - bool SelectAndSetCurrentUser(const Core::Frontend::ProfileSelectParameters& parameters); - - /** - * Stores the filename in the recently loaded files list. - * The new filename is stored at the beginning of the recently loaded files list. - * After inserting the new entry, duplicates are removed meaning that if - * this was inserted from \a OnMenuRecentFile(), the entry will be put on top - * and remove from its previous position. - * - * Finally, this function calls \a UpdateRecentFiles() to update the UI. - * - * @param filename the filename to store - */ - void StoreRecentFile(const QString& filename); - - /** - * Updates the recent files menu. - * Menu entries are rebuilt from the configuration file. - * If there is no entry in the menu, the menu is greyed out. - */ - void UpdateRecentFiles(); - - /** - * If the emulation is running, - * asks the user if he really want to close the emulator - * - * @return true if the user confirmed - */ - bool ConfirmClose(); - bool ConfirmChangeGame(); - bool ConfirmForceLockedExit(); - void RequestGameExit(); - void changeEvent(QEvent* event) override; - void closeEvent(QCloseEvent* event) override; - - std::string CreateTASFramesString( - std::array<size_t, InputCommon::TasInput::PLAYER_NUMBER> frames) const; - -#ifdef __unix__ - void SetupSigInterrupts(); - static void HandleSigInterrupt(int); - void OnSigInterruptNotifierActivated(); - void SetGamemodeEnabled(bool state); -#endif - - Service::AM::FrontendAppletParameters ApplicationAppletParameters(); - Service::AM::FrontendAppletParameters LibraryAppletParameters(u64 program_id, - Service::AM::AppletId applet_id); - -private slots: - void OnStartGame(); - void OnRestartGame(); - void OnPauseGame(); - void OnPauseContinueGame(); - void OnStopGame(); - void OnPrepareForSleep(bool prepare_sleep); - void OnMenuReportCompatibility(); - void OnOpenModsPage(); - void OnOpenQuickstartGuide(); - void OnOpenFAQ(); - /// Called whenever a user selects a game in the game list widget. - void OnGameListLoadFile(QString game_path, u64 program_id); - void OnGameListOpenFolder(u64 program_id, GameListOpenTarget target, - const std::string& game_path); - void OnTransferableShaderCacheOpenFile(u64 program_id); - void OnGameListRemoveInstalledEntry(u64 program_id, InstalledEntryType type); - void OnGameListRemoveFile(u64 program_id, GameListRemoveTarget target, - const std::string& game_path); - void OnGameListRemovePlayTimeData(u64 program_id); - void OnGameListDumpRomFS(u64 program_id, const std::string& game_path, DumpRomFSTarget target); - void OnGameListVerifyIntegrity(const std::string& game_path); - void OnGameListCopyTID(u64 program_id); - void OnGameListNavigateToGamedbEntry(u64 program_id, - const CompatibilityList& compatibility_list); - void OnGameListCreateShortcut(u64 program_id, const std::string& game_path, - GameListShortcutTarget target); - void OnGameListOpenDirectory(const QString& directory); - void OnGameListAddDirectory(); - void OnGameListShowList(bool show); - void OnGameListOpenPerGameProperties(const std::string& file); - void OnMenuLoadFile(); - void OnMenuLoadFolder(); - void IncrementInstallProgress(); - void OnMenuInstallToNAND(); - void OnMenuRecentFile(); - void OnConfigure(); - void OnConfigureTas(); - void OnDecreaseVolume(); - void OnIncreaseVolume(); - void OnMute(); - void OnTasStartStop(); - void OnTasRecord(); - void OnTasReset(); - void OnToggleGraphicsAPI(); - void OnToggleDockedMode(); - void OnToggleGpuAccuracy(); - void OnToggleAdaptingFilter(); - void OnConfigurePerGame(); - void OnLoadAmiibo(); - void OnOpenYuzuFolder(); - void OnVerifyInstalledContents(); - void OnInstallFirmware(); - void OnInstallDecryptionKeys(); - void OnAbout(); - void OnToggleFilterBar(); - void OnToggleStatusBar(); - void OnDisplayTitleBars(bool); - void InitializeHotkeys(); - void ToggleFullscreen(); - bool UsingExclusiveFullscreen(); - void ShowFullscreen(); - void HideFullscreen(); - void ToggleWindowMode(); - void ResetWindowSize(u32 width, u32 height); - void ResetWindowSize720(); - void ResetWindowSize900(); - void ResetWindowSize1080(); - void OnAlbum(); - void OnCabinet(Service::NFP::CabinetMode mode); - void OnMiiEdit(); - void OnOpenControllerMenu(); - void OnCaptureScreenshot(); - void OnCheckFirmwareDecryption(); - void OnLanguageChanged(const QString& locale); - void OnMouseActivity(); - bool OnShutdownBegin(); - void OnShutdownBeginDialog(); - void OnEmulationStopped(); - void OnEmulationStopTimeExpired(); - -private: - QString GetGameListErrorRemoving(InstalledEntryType type) const; - void RemoveBaseContent(u64 program_id, InstalledEntryType type); - void RemoveUpdateContent(u64 program_id, InstalledEntryType type); - void RemoveAddOnContent(u64 program_id, InstalledEntryType type); - void RemoveTransferableShaderCache(u64 program_id, GameListRemoveTarget target); - void RemoveVulkanDriverPipelineCache(u64 program_id); - void RemoveAllTransferableShaderCaches(u64 program_id); - void RemoveCustomConfiguration(u64 program_id, const std::string& game_path); - void RemovePlayTimeData(u64 program_id); - void RemoveCacheStorage(u64 program_id); - bool SelectRomFSDumpTarget(const FileSys::ContentProvider&, u64 program_id, - u64* selected_title_id, u8* selected_content_record_type); - ContentManager::InstallResult InstallNCA(const QString& filename); - void MigrateConfigFiles(); - void UpdateWindowTitle(std::string_view title_name = {}, std::string_view title_version = {}, - std::string_view gpu_vendor = {}); - void UpdateDockedButton(); - void UpdateAPIText(); - void UpdateFilterText(); - void UpdateAAText(); - void UpdateVolumeUI(); - void UpdateStatusBar(); - void UpdateGPUAccuracyButton(); - void UpdateStatusButtons(); - void UpdateUISettings(); - void UpdateInputDrivers(); - void HideMouseCursor(); - void ShowMouseCursor(); - void OpenURL(const QUrl& url); - void LoadTranslation(); - void OpenPerGameConfiguration(u64 title_id, const std::string& file_name); - bool CheckDarkMode(); - bool CheckFirmwarePresence(); - void SetFirmwareVersion(); - void ConfigureFilesystemProvider(const std::string& filepath); - /** - * Open (or not) the right confirm dialog based on current setting and game exit lock - * @returns true if the player confirmed or the settings do no require it - */ - bool ConfirmShutdownGame(); - - QString GetTasStateDescription() const; - bool CreateShortcutMessagesGUI(QWidget* parent, int imsg, const QString& game_title); - bool MakeShortcutIcoPath(const u64 program_id, const std::string_view game_file_name, - std::filesystem::path& out_icon_path); - bool CreateShortcutLink(const std::filesystem::path& shortcut_path, const std::string& comment, - const std::filesystem::path& icon_path, - const std::filesystem::path& command, const std::string& arguments, - const std::string& categories, const std::string& keywords, - const std::string& name); - /** - * Mimic the behavior of QMessageBox::question but link controller navigation to the dialog - * The only difference is that it returns a boolean. - * - * @returns true if buttons contains QMessageBox::Yes and the user clicks on the "Yes" button. - */ - bool question(QWidget* parent, const QString& title, const QString& text, - QMessageBox::StandardButtons buttons = - QMessageBox::StandardButtons(QMessageBox::Yes | QMessageBox::No), - QMessageBox::StandardButton defaultButton = QMessageBox::NoButton); - - std::unique_ptr<Ui::MainWindow> ui; - - std::unique_ptr<Core::System> system; - std::unique_ptr<DiscordRPC::DiscordInterface> discord_rpc; - std::unique_ptr<PlayTime::PlayTimeManager> play_time_manager; - std::shared_ptr<InputCommon::InputSubsystem> input_subsystem; - - MultiplayerState* multiplayer_state = nullptr; - - GRenderWindow* render_window; - GameList* game_list; - LoadingScreen* loading_screen; - QTimer shutdown_timer; - OverlayDialog* shutdown_dialog{}; - - GameListPlaceholder* game_list_placeholder; - - std::vector<VkDeviceInfo::Record> vk_device_records; - - // Status bar elements - QLabel* message_label = nullptr; - QLabel* shader_building_label = nullptr; - QLabel* res_scale_label = nullptr; - QLabel* emu_speed_label = nullptr; - QLabel* game_fps_label = nullptr; - QLabel* emu_frametime_label = nullptr; - QLabel* tas_label = nullptr; - QLabel* firmware_label = nullptr; - QPushButton* gpu_accuracy_button = nullptr; - QPushButton* renderer_status_button = nullptr; - QPushButton* dock_status_button = nullptr; - QPushButton* filter_status_button = nullptr; - QPushButton* aa_status_button = nullptr; - VolumeButton* volume_button = nullptr; - QWidget* volume_popup = nullptr; - QSlider* volume_slider = nullptr; - QTimer status_bar_update_timer; - - std::unique_ptr<QtConfig> config; - - // Whether emulation is currently running in yuzu. - bool emulation_running = false; - std::unique_ptr<EmuThread> emu_thread; - // The path to the game currently running - QString current_game_path; - // Whether a user was set on the command line (skips UserSelector if it's forced to show up) - bool user_flag_cmd_line = false; - - bool auto_paused = false; - bool auto_muted = false; - QTimer mouse_hide_timer; - QTimer update_input_timer; - - QString startup_icon_theme; - bool os_dark_mode = false; - - // FS - std::shared_ptr<FileSys::VfsFilesystem> vfs; - std::unique_ptr<FileSys::ManualContentProvider> provider; - - // Debugger panes - ProfilerWidget* profilerWidget; - MicroProfileDialog* microProfileDialog; - WaitTreeWidget* waitTreeWidget; - ControllerDialog* controller_dialog; - - QAction* actions_recent_files[max_recent_files_item]; - - // stores default icon theme search paths for the platform - QStringList default_theme_paths; - - HotkeyRegistry hotkey_registry; - - QTranslator translator; - - // Install progress dialog - QProgressDialog* install_progress; - - // Last game booted, used for multi-process apps - QString last_filename_booted; - - // Applets - QtAmiiboSettingsDialog* cabinet_applet = nullptr; - QtControllerSelectorDialog* controller_applet = nullptr; - QtProfileSelectionDialog* profile_select_applet = nullptr; - QDialog* error_applet = nullptr; - QtSoftwareKeyboardDialog* software_keyboard = nullptr; - QtNXWebEngineView* web_applet = nullptr; - - // True if amiibo file select is visible - bool is_amiibo_file_select_active{}; - - // True if load file select is visible - bool is_load_file_select_active{}; - - // True if TAS recording dialog is visible - bool is_tas_recording_dialog_active{}; - -#ifdef __unix__ - QSocketNotifier* sig_interrupt_notifier; - static std::array<int, 3> sig_interrupt_fds; -#endif - -protected: - void dropEvent(QDropEvent* event) override; - void dragEnterEvent(QDragEnterEvent* event) override; - void dragMoveEvent(QDragMoveEvent* event) override; -}; diff --git a/src/yuzu/main.ui b/src/yuzu/main.ui deleted file mode 100644 index 85dc1f2f6..000000000 --- a/src/yuzu/main.ui +++ /dev/null @@ -1,483 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>MainWindow</class> - <widget class="QMainWindow" name="MainWindow"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>1280</width> - <height>720</height> - </rect> - </property> - <property name="windowTitle"> - <string>yuzu</string> - </property> - <property name="windowIcon"> - <iconset resource="yuzu.qrc"> - <normaloff>:/img/yuzu.ico</normaloff>:/img/yuzu.ico</iconset> - </property> - <property name="tabShape"> - <enum>QTabWidget::Rounded</enum> - </property> - <property name="dockNestingEnabled"> - <bool>true</bool> - </property> - <widget class="QWidget" name="centralwidget"> - <layout class="QHBoxLayout" name="horizontalLayout"> - <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> - </layout> - </widget> - <widget class="QMenuBar" name="menubar"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>1280</width> - <height>21</height> - </rect> - </property> - <widget class="QMenu" name="menu_File"> - <property name="title"> - <string>&File</string> - </property> - <widget class="QMenu" name="menu_recent_files"> - <property name="title"> - <string>&Recent Files</string> - </property> - </widget> - <addaction name="action_Install_File_NAND"/> - <addaction name="separator"/> - <addaction name="action_Load_File"/> - <addaction name="action_Load_Folder"/> - <addaction name="separator"/> - <addaction name="menu_recent_files"/> - <addaction name="separator"/> - <addaction name="action_Load_Amiibo"/> - <addaction name="separator"/> - <addaction name="action_Open_yuzu_Folder"/> - <addaction name="separator"/> - <addaction name="action_Exit"/> - </widget> - <widget class="QMenu" name="menu_Emulation"> - <property name="title"> - <string>&Emulation</string> - </property> - <addaction name="action_Pause"/> - <addaction name="action_Stop"/> - <addaction name="action_Restart"/> - <addaction name="separator"/> - <addaction name="action_Configure"/> - <addaction name="action_Configure_Current_Game"/> - </widget> - <widget class="QMenu" name="menu_View"> - <property name="title"> - <string>&View</string> - </property> - <widget class="QMenu" name="menu_Reset_Window_Size"> - <property name="title"> - <string>&Reset Window Size</string> - </property> - </widget> - <widget class="QMenu" name="menu_View_Debugging"> - <property name="title"> - <string>&Debugging</string> - </property> - </widget> - <action name="action_Reset_Window_Size_720"> - <property name="text"> - <string>Reset Window Size to &720p</string> - </property> - <property name="iconText"> - <string>Reset Window Size to 720p</string> - </property> - </action> - <action name="action_Reset_Window_Size_900"> - <property name="text"> - <string>Reset Window Size to &900p</string> - </property> - <property name="iconText"> - <string>Reset Window Size to 900p</string> - </property> - </action> - <action name="action_Reset_Window_Size_1080"> - <property name="text"> - <string>Reset Window Size to &1080p</string> - </property> - <property name="iconText"> - <string>Reset Window Size to 1080p</string> - </property> - </action> - <addaction name="action_Fullscreen"/> - <addaction name="action_Single_Window_Mode"/> - <addaction name="action_Display_Dock_Widget_Headers"/> - <addaction name="action_Show_Filter_Bar"/> - <addaction name="action_Show_Status_Bar"/> - <addaction name="separator"/> - <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>&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>&Tools</string> - </property> - <widget class="QMenu" name="menu_cabinet_applet"> - <property name="title"> - <string>&Amiibo</string> - </property> - <addaction name="action_Load_Cabinet_Nickname_Owner"/> - <addaction name="action_Load_Cabinet_Eraser"/> - <addaction name="action_Load_Cabinet_Restorer"/> - <addaction name="action_Load_Cabinet_Formatter"/> - </widget> - <widget class="QMenu" name="menuTAS"> - <property name="title"> - <string>&TAS</string> - </property> - <addaction name="action_TAS_Start"/> - <addaction name="action_TAS_Record"/> - <addaction name="action_TAS_Reset"/> - <addaction name="separator"/> - <addaction name="action_Configure_Tas"/> - </widget> - <addaction name="action_Install_Keys"/> - <addaction name="action_Install_Firmware"/> - <addaction name="action_Verify_installed_contents"/> - <addaction name="separator"/> - <addaction name="menu_cabinet_applet"/> - <addaction name="action_Load_Album"/> - <addaction name="action_Load_Mii_Edit"/> - <addaction name="action_Open_Controller_Menu"/> - <addaction name="separator"/> - <addaction name="action_Capture_Screenshot"/> - <addaction name="menuTAS"/> - </widget> - <widget class="QMenu" name="menu_Help"> - <property name="title"> - <string>&Help</string> - </property> - <addaction name="action_Report_Compatibility"/> - <addaction name="action_Open_Mods_Page"/> - <addaction name="action_Open_Quickstart_Guide"/> - <addaction name="action_Open_FAQ"/> - <addaction name="separator"/> - <addaction name="action_About"/> - </widget> - <addaction name="menu_File"/> - <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"> - <property name="enabled"> - <bool>true</bool> - </property> - <property name="text"> - <string>&Install Files to NAND...</string> - </property> - </action> - <action name="action_Load_File"> - <property name="text"> - <string>L&oad File...</string> - </property> - </action> - <action name="action_Load_Folder"> - <property name="text"> - <string>Load &Folder...</string> - </property> - </action> - <action name="action_Exit"> - <property name="text"> - <string>E&xit</string> - </property> - </action> - <action name="action_Pause"> - <property name="enabled"> - <bool>false</bool> - </property> - <property name="text"> - <string>&Pause</string> - </property> - </action> - <action name="action_Stop"> - <property name="enabled"> - <bool>false</bool> - </property> - <property name="text"> - <string>&Stop</string> - </property> - </action> - <action name="action_Verify_installed_contents"> - <property name="text"> - <string>&Verify Installed Contents</string> - </property> - </action> - <action name="action_About"> - <property name="text"> - <string>&About yuzu</string> - </property> - </action> - <action name="action_Single_Window_Mode"> - <property name="checkable"> - <bool>true</bool> - </property> - <property name="text"> - <string>Single &Window Mode</string> - </property> - </action> - <action name="action_Configure"> - <property name="text"> - <string>Con&figure...</string> - </property> - <property name="menuRole"> - <enum>QAction::PreferencesRole</enum> - </property> - </action> - <action name="action_Display_Dock_Widget_Headers"> - <property name="checkable"> - <bool>true</bool> - </property> - <property name="text"> - <string>Display D&ock Widget Headers</string> - </property> - </action> - <action name="action_Show_Filter_Bar"> - <property name="checkable"> - <bool>true</bool> - </property> - <property name="text"> - <string>Show &Filter Bar</string> - </property> - </action> - <action name="action_Show_Status_Bar"> - <property name="checkable"> - <bool>true</bool> - </property> - <property name="text"> - <string>Show &Status Bar</string> - </property> - <property name="iconText"> - <string>Show Status Bar</string> - </property> - </action> - <action name="action_View_Lobby"> - <property name="enabled"> - <bool>true</bool> - </property> - <property name="text"> - <string>&Browse Public Game Lobby</string> - </property> - </action> - <action name="action_Start_Room"> - <property name="enabled"> - <bool>true</bool> - </property> - <property name="text"> - <string>&Create Room</string> - </property> - </action> - <action name="action_Leave_Room"> - <property name="enabled"> - <bool>false</bool> - </property> - <property name="text"> - <string>&Leave Room</string> - </property> - </action> - <action name="action_Connect_To_Room"> - <property name="text"> - <string>&Direct Connect to Room</string> - </property> - </action> - <action name="action_Show_Room"> - <property name="enabled"> - <bool>false</bool> - </property> - <property name="text"> - <string>&Show Current Room</string> - </property> - </action> - <action name="action_Fullscreen"> - <property name="checkable"> - <bool>true</bool> - </property> - <property name="text"> - <string>F&ullscreen</string> - </property> - </action> - <action name="action_Restart"> - <property name="enabled"> - <bool>false</bool> - </property> - <property name="text"> - <string>&Restart</string> - </property> - </action> - <action name="action_Load_Amiibo"> - <property name="enabled"> - <bool>false</bool> - </property> - <property name="text"> - <string>Load/Remove &Amiibo...</string> - </property> - </action> - <action name="action_Report_Compatibility"> - <property name="enabled"> - <bool>false</bool> - </property> - <property name="text"> - <string>&Report Compatibility</string> - </property> - <property name="visible"> - <bool>false</bool> - </property> - </action> - <action name="action_Open_Mods_Page"> - <property name="text"> - <string>Open &Mods Page</string> - </property> - </action> - <action name="action_Open_Quickstart_Guide"> - <property name="text"> - <string>Open &Quickstart Guide</string> - </property> - </action> - <action name="action_Open_FAQ"> - <property name="text"> - <string>&FAQ</string> - </property> - </action> - <action name="action_Open_yuzu_Folder"> - <property name="text"> - <string>Open &yuzu Folder</string> - </property> - </action> - <action name="action_Capture_Screenshot"> - <property name="enabled"> - <bool>false</bool> - </property> - <property name="text"> - <string>&Capture Screenshot</string> - </property> - </action> - <action name="action_Load_Album"> - <property name="text"> - <string>Open &Album</string> - </property> - </action> - <action name="action_Load_Cabinet_Nickname_Owner"> - <property name="text"> - <string>&Set Nickname and Owner</string> - </property> - </action> - <action name="action_Load_Cabinet_Eraser"> - <property name="text"> - <string>&Delete Game Data</string> - </property> - </action> - <action name="action_Load_Cabinet_Restorer"> - <property name="text"> - <string>&Restore Amiibo</string> - </property> - </action> - <action name="action_Load_Cabinet_Formatter"> - <property name="text"> - <string>&Format Amiibo</string> - </property> - </action> - <action name="action_Load_Mii_Edit"> - <property name="text"> - <string>Open &Mii Editor</string> - </property> - </action> - <action name="action_Configure_Tas"> - <property name="text"> - <string>&Configure TAS...</string> - </property> - <property name="menuRole"> - <enum>QAction::NoRole</enum> - </property> - </action> - <action name="action_Configure_Current_Game"> - <property name="enabled"> - <bool>false</bool> - </property> - <property name="text"> - <string>Configure C&urrent Game...</string> - </property> - <property name="menuRole"> - <enum>QAction::NoRole</enum> - </property> - </action> - <action name="action_TAS_Start"> - <property name="enabled"> - <bool>false</bool> - </property> - <property name="text"> - <string>&Start</string> - </property> - </action> - <action name="action_TAS_Reset"> - <property name="enabled"> - <bool>false</bool> - </property> - <property name="text"> - <string>&Reset</string> - </property> - </action> - <action name="action_TAS_Record"> - <property name="enabled"> - <bool>false</bool> - </property> - <property name="text"> - <string>R&ecord</string> - </property> - </action> - <action name="action_Open_Controller_Menu"> - <property name="text"> - <string>Open &Controller Menu</string> - </property> - </action> - <action name="action_Install_Firmware"> - <property name="text"> - <string>Install Firmware</string> - </property> - </action> - <action name="action_Install_Keys"> - <property name="text"> - <string>Install Decryption Keys</string> - </property> - </action> - </widget> - <resources> - <include location="yuzu.qrc"/> - </resources> - <connections/> -</ui> diff --git a/src/yuzu/multiplayer/chat_room.cpp b/src/yuzu/multiplayer/chat_room.cpp deleted file mode 100644 index 4463616b4..000000000 --- a/src/yuzu/multiplayer/chat_room.cpp +++ /dev/null @@ -1,508 +0,0 @@ -// 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'><%3></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->BindOnChatMessageReceived( - [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 deleted file mode 100644 index dd71ea4cd..000000000 --- a/src/yuzu/multiplayer/chat_room.h +++ /dev/null @@ -1,76 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2017 Citra Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include <memory> -#include <unordered_map> -#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 deleted file mode 100644 index f2b31b5da..000000000 --- a/src/yuzu/multiplayer/chat_room.ui +++ /dev/null @@ -1,59 +0,0 @@ -<?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 deleted file mode 100644 index caf34a414..000000000 --- a/src/yuzu/multiplayer/client_room.cpp +++ /dev/null @@ -1,115 +0,0 @@ -// 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 deleted file mode 100644 index f338e3c59..000000000 --- a/src/yuzu/multiplayer/client_room.h +++ /dev/null @@ -1,39 +0,0 @@ -// 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 deleted file mode 100644 index 97e88b502..000000000 --- a/src/yuzu/multiplayer/client_room.ui +++ /dev/null @@ -1,80 +0,0 @@ -<?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 deleted file mode 100644 index 74da97e21..000000000 --- a/src/yuzu/multiplayer/direct_connect.cpp +++ /dev/null @@ -1,137 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2017 Citra Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include <QComboBox> -#include <QFuture> -#include <QIntValidator> -#include <QRegularExpressionValidator> -#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( - QString::fromStdString(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(QString::fromStdString(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; - } - } - } - 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; - } - - // Store settings - UISettings::values.multiplayer_nickname = ui->nickname->text().toStdString(); - UISettings::values.multiplayer_ip = ui->ip->text().toStdString(); - if (!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 deleted file mode 100644 index b8f66cfb2..000000000 --- a/src/yuzu/multiplayer/direct_connect.h +++ /dev/null @@ -1,49 +0,0 @@ -// 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 deleted file mode 100644 index 0dd4e6829..000000000 --- a/src/yuzu/multiplayer/direct_connect.ui +++ /dev/null @@ -1,165 +0,0 @@ -<?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="QWidget" name="ip_container" native="true"> - <layout class="QHBoxLayout" name="ip_layout"> - <property name="leftMargin"> - <number>0</number> - </property> - <property name="topMargin"> - <number>0</number> - </property> - <property name="rightMargin"> - <number>0</number> - </property> - <property name="bottomMargin"> - <number>0</number> - </property> - <item> - <widget class="QLabel" name="label_2"> - <property name="text"> - <string>Server Address</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="ip"> - <property name="toolTip"> - <string><html><head/><body><p>Server address of the host</p></body></html></string> - </property> - <property name="maxLength"> - <number>253</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><html><head/><body><p>Port number the host is listening on</p></body></html></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> - <property name="maximumSize"> - <size> - <width>65</width> - <height>50</height> - </size> - </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 deleted file mode 100644 index ef364ee43..000000000 --- a/src/yuzu/multiplayer/host_room.cpp +++ /dev/null @@ -1,264 +0,0 @@ -// 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( - QString::fromStdString(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( - QString::fromStdString(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( - QString::fromStdString(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().toStdString(); - UISettings::values.multiplayer_room_name = ui->room_name->text().toStdString(); - 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().toStdString(); - 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 deleted file mode 100644 index ae816e2e0..000000000 --- a/src/yuzu/multiplayer/host_room.h +++ /dev/null @@ -1,80 +0,0 @@ -// 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 deleted file mode 100644 index d54cf49c6..000000000 --- a/src/yuzu/multiplayer/host_room.ui +++ /dev/null @@ -1,207 +0,0 @@ -<?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 deleted file mode 100644 index 77ac84295..000000000 --- a/src/yuzu/multiplayer/lobby.cpp +++ /dev/null @@ -1,439 +0,0 @@ -// 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), 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( - QString::fromStdString(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->search, &QLineEdit::textChanged, proxy, &LobbyFilterProxyModel::SetFilterSearch); - connect(ui->games_owned, &QCheckBox::toggled, proxy, &LobbyFilterProxyModel::SetFilterOwned); - connect(ui->hide_empty, &QCheckBox::toggled, proxy, &LobbyFilterProxyModel::SetFilterEmpty); - connect(ui->hide_full, &QCheckBox::toggled, proxy, &LobbyFilterProxyModel::SetFilterFull); - 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); - - // Load persistent filters after events are connected to make sure they apply - ui->search->setText( - QString::fromStdString(UISettings::values.multiplayer_filter_text.GetValue())); - ui->games_owned->setChecked(UISettings::values.multiplayer_filter_games_owned.GetValue()); - ui->hide_empty->setChecked(UISettings::values.multiplayer_filter_hide_empty.GetValue()); - ui->hide_full->setChecked(UISettings::values.multiplayer_filter_hide_full.GetValue()); -} - -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().toStdString(); - UISettings::values.multiplayer_filter_text = ui->search->text().toStdString(); - UISettings::values.multiplayer_filter_games_owned = ui->games_owned->isChecked(); - UISettings::values.multiplayer_filter_hide_empty = ui->hide_empty->isChecked(); - UISettings::values.multiplayer_filter_hide_full = ui->hide_full->isChecked(); - UISettings::values.multiplayer_ip = - proxy->data(connection_index, LobbyItemHost::HostIPRole).value<QString>().toStdString(); - 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)); - } - } - - // Re-enable 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 = - system.GetProfileManager().GetUser(Settings::values.current_user.GetValue()); - Service::Account::ProfileBase profile{}; - - if (!current_user.has_value()) { - return ""; - } - - if (!system.GetProfileManager().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 empty rooms - if (filter_empty) { - QModelIndex member_list = sourceModel()->index(sourceRow, Column::MEMBER, sourceParent); - int player_count = - sourceModel()->data(member_list, LobbyItemMemberList::MemberListRole).toList().size(); - if (player_count == 0) { - return false; - } - } - - // 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::SetFilterEmpty(bool filter) { - filter_empty = 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 deleted file mode 100644 index e78c9cae3..000000000 --- a/src/yuzu/multiplayer/lobby.h +++ /dev/null @@ -1,138 +0,0 @@ -// 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; -} - -/** - * 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; - 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 SetFilterEmpty(bool); - void SetFilterFull(bool); - void SetFilterSearch(const QString&); - -private: - QStandardItemModel* game_list; - bool filter_owned = false; - bool filter_empty = false; - bool filter_full = false; - QString filter_search; -}; diff --git a/src/yuzu/multiplayer/lobby.ui b/src/yuzu/multiplayer/lobby.ui deleted file mode 100644 index 0ef0ef762..000000000 --- a/src/yuzu/multiplayer/lobby.ui +++ /dev/null @@ -1,130 +0,0 @@ -<?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_empty"> - <property name="text"> - <string>Hide Empty Rooms</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 deleted file mode 100644 index 77ec1fcde..000000000 --- a/src/yuzu/multiplayer/lobby_p.h +++ /dev/null @@ -1,268 +0,0 @@ -// 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 { - switch (role) { - case Qt::DisplayRole: { - auto members = data(MemberListRole).toList(); - return QStringLiteral("%1 / %2 ") - .arg(QString::number(members.size()), data(MaxPlayerRole).toString()); - } - case Qt::ForegroundRole: { - auto members = data(MemberListRole).toList(); - auto max_players = data(MaxPlayerRole).toInt(); - const QColor room_full_color(255, 48, 32); - const QColor room_almost_full_color(255, 140, 32); - const QColor room_has_players_color(32, 160, 32); - const QColor room_empty_color(128, 128, 128); - - if (members.size() >= max_players) { - return QBrush(room_full_color); - } else if (members.size() == (max_players - 1)) { - return QBrush(room_almost_full_color); - } else if (members.size() == 0) { - return QBrush(room_empty_color); - } else if (members.size() > 0 && members.size() < (max_players - 1)) { - return QBrush(room_has_players_color); - } - // FIXME: How to return a value that tells Qt not to modify the - // text color from the default (as if Qt::ForegroundRole wasn't overridden)? - return QBrush(nullptr); - } - default: - return LobbyItem::data(role); - } - } - - 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 deleted file mode 100644 index 6d8f18274..000000000 --- a/src/yuzu/multiplayer/message.cpp +++ /dev/null @@ -1,85 +0,0 @@ -// 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 deleted file mode 100644 index f038b9a1f..000000000 --- a/src/yuzu/multiplayer/message.h +++ /dev/null @@ -1,72 +0,0 @@ -// 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 deleted file mode 100644 index c9b8ed397..000000000 --- a/src/yuzu/multiplayer/moderation_dialog.cpp +++ /dev/null @@ -1,112 +0,0 @@ -// 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 deleted file mode 100644 index e9e5daff7..000000000 --- a/src/yuzu/multiplayer/moderation_dialog.h +++ /dev/null @@ -1,43 +0,0 @@ -// 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 deleted file mode 100644 index 808d99414..000000000 --- a/src/yuzu/multiplayer/moderation_dialog.ui +++ /dev/null @@ -1,84 +0,0 @@ -<?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 deleted file mode 100644 index d82ca9aee..000000000 --- a/src/yuzu/multiplayer/state.cpp +++ /dev/null @@ -1,336 +0,0 @@ -// 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::Uninitialized: - 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 = 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 deleted file mode 100644 index d6149838f..000000000 --- a/src/yuzu/multiplayer/state.h +++ /dev/null @@ -1,111 +0,0 @@ -// 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 { - Uninitialized, - 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::Uninitialized; - 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 deleted file mode 100644 index cbbe6757b..000000000 --- a/src/yuzu/multiplayer/validation.h +++ /dev/null @@ -1,67 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2017 Citra Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include <QRegularExpression> -#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 - QRegularExpression room_name_regex = - QRegularExpression(QStringLiteral("^[a-zA-Z0-9._ -]{4,20}")); - QRegularExpressionValidator room_name; - - /// nickname can be alphanumeric and " " "_" "." and "-" and must have a size of 4-20 - const QRegularExpression nickname_regex = - QRegularExpression(QStringLiteral("^[a-zA-Z0-9._ -]{4,20}")); - QRegularExpressionValidator nickname; - - /// ipv4 / ipv6 / hostnames - QRegularExpression ip_regex = QRegularExpression(QStringLiteral( - // IPv4 regex - "^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$|" - // IPv6 regex - "^((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|" - "(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-" - "5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3})|:))|" - "(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)" - "(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3})|:))|" - "(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]" - "\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|" - "(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[" - "0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|" - "(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[" - "0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|" - "(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[" - "0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|" - "(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?" - "\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:)))(%.+)?$|" - // Hostname regex - "^([a-zA-Z0-9]+(-[a-zA-Z0-9]+)*\\.)+[a-zA-Z]{2,}$")); - QRegularExpressionValidator ip; - - /// port must be between 0 and 65535 - QIntValidator port; -}; diff --git a/src/yuzu/play_time_manager.cpp b/src/yuzu/play_time_manager.cpp deleted file mode 100644 index 94c99274d..000000000 --- a/src/yuzu/play_time_manager.cpp +++ /dev/null @@ -1,182 +0,0 @@ -// SPDX-FileCopyrightText: 2023 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include "common/alignment.h" -#include "common/fs/file.h" -#include "common/fs/fs.h" -#include "common/fs/path_util.h" -#include "common/logging/log.h" -#include "common/settings.h" -#include "common/thread.h" -#include "core/hle/service/acc/profile_manager.h" -#include "yuzu/play_time_manager.h" - -namespace PlayTime { - -namespace { - -struct PlayTimeElement { - ProgramId program_id; - PlayTime play_time; -}; - -std::optional<std::filesystem::path> GetCurrentUserPlayTimePath( - const Service::Account::ProfileManager& manager) { - const auto uuid = manager.GetUser(static_cast<s32>(Settings::values.current_user)); - if (!uuid.has_value()) { - return std::nullopt; - } - return Common::FS::GetYuzuPath(Common::FS::YuzuPath::PlayTimeDir) / - uuid->RawString().append(".bin"); -} - -[[nodiscard]] bool ReadPlayTimeFile(PlayTimeDatabase& out_play_time_db, - const Service::Account::ProfileManager& manager) { - const auto filename = GetCurrentUserPlayTimePath(manager); - - if (!filename.has_value()) { - LOG_ERROR(Frontend, "Failed to get current user path"); - return false; - } - - out_play_time_db.clear(); - - if (Common::FS::Exists(filename.value())) { - Common::FS::IOFile file{filename.value(), Common::FS::FileAccessMode::Read, - Common::FS::FileType::BinaryFile}; - if (!file.IsOpen()) { - LOG_ERROR(Frontend, "Failed to open play time file: {}", - Common::FS::PathToUTF8String(filename.value())); - return false; - } - - const size_t num_elements = file.GetSize() / sizeof(PlayTimeElement); - std::vector<PlayTimeElement> elements(num_elements); - - if (file.ReadSpan<PlayTimeElement>(elements) != num_elements) { - return false; - } - - for (const auto& [program_id, play_time] : elements) { - if (program_id != 0) { - out_play_time_db[program_id] = play_time; - } - } - } - - return true; -} - -[[nodiscard]] bool WritePlayTimeFile(const PlayTimeDatabase& play_time_db, - const Service::Account::ProfileManager& manager) { - const auto filename = GetCurrentUserPlayTimePath(manager); - - if (!filename.has_value()) { - LOG_ERROR(Frontend, "Failed to get current user path"); - return false; - } - - Common::FS::IOFile file{filename.value(), Common::FS::FileAccessMode::Write, - Common::FS::FileType::BinaryFile}; - if (!file.IsOpen()) { - LOG_ERROR(Frontend, "Failed to open play time file: {}", - Common::FS::PathToUTF8String(filename.value())); - return false; - } - - std::vector<PlayTimeElement> elements; - elements.reserve(play_time_db.size()); - - for (auto& [program_id, play_time] : play_time_db) { - if (program_id != 0) { - elements.push_back(PlayTimeElement{program_id, play_time}); - } - } - - return file.WriteSpan<PlayTimeElement>(elements) == elements.size(); -} - -} // namespace - -PlayTimeManager::PlayTimeManager(Service::Account::ProfileManager& profile_manager) - : manager{profile_manager} { - if (!ReadPlayTimeFile(database, manager)) { - LOG_ERROR(Frontend, "Failed to read play time database! Resetting to default."); - } -} - -PlayTimeManager::~PlayTimeManager() { - Save(); -} - -void PlayTimeManager::SetProgramId(u64 program_id) { - running_program_id = program_id; -} - -void PlayTimeManager::Start() { - play_time_thread = std::jthread([&](std::stop_token stop_token) { AutoTimestamp(stop_token); }); -} - -void PlayTimeManager::Stop() { - play_time_thread = {}; -} - -void PlayTimeManager::AutoTimestamp(std::stop_token stop_token) { - Common::SetCurrentThreadName("PlayTimeReport"); - - using namespace std::literals::chrono_literals; - using std::chrono::seconds; - using std::chrono::steady_clock; - - auto timestamp = steady_clock::now(); - - const auto GetDuration = [&]() -> u64 { - const auto last_timestamp = std::exchange(timestamp, steady_clock::now()); - const auto duration = std::chrono::duration_cast<seconds>(timestamp - last_timestamp); - return static_cast<u64>(duration.count()); - }; - - while (!stop_token.stop_requested()) { - Common::StoppableTimedWait(stop_token, 30s); - - database[running_program_id] += GetDuration(); - Save(); - } -} - -void PlayTimeManager::Save() { - if (!WritePlayTimeFile(database, manager)) { - LOG_ERROR(Frontend, "Failed to update play time database!"); - } -} - -u64 PlayTimeManager::GetPlayTime(u64 program_id) const { - auto it = database.find(program_id); - if (it != database.end()) { - return it->second; - } else { - return 0; - } -} - -void PlayTimeManager::ResetProgramPlayTime(u64 program_id) { - database.erase(program_id); - Save(); -} - -QString ReadablePlayTime(qulonglong time_seconds) { - if (time_seconds == 0) { - return {}; - } - const auto time_minutes = std::max(static_cast<double>(time_seconds) / 60, 1.0); - const auto time_hours = static_cast<double>(time_seconds) / 3600; - const bool is_minutes = time_minutes < 60; - const char* unit = is_minutes ? "m" : "h"; - const auto value = is_minutes ? time_minutes : time_hours; - - return QStringLiteral("%L1 %2") - .arg(value, 0, 'f', !is_minutes && time_seconds % 60 != 0) - .arg(QString::fromUtf8(unit)); -} - -} // namespace PlayTime diff --git a/src/yuzu/play_time_manager.h b/src/yuzu/play_time_manager.h deleted file mode 100644 index 1714b9131..000000000 --- a/src/yuzu/play_time_manager.h +++ /dev/null @@ -1,50 +0,0 @@ -// SPDX-FileCopyrightText: 2023 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include <QString> - -#include <map> - -#include "common/common_funcs.h" -#include "common/common_types.h" -#include "common/polyfill_thread.h" - -namespace Service::Account { -class ProfileManager; -} - -namespace PlayTime { - -using ProgramId = u64; -using PlayTime = u64; -using PlayTimeDatabase = std::map<ProgramId, PlayTime>; - -class PlayTimeManager { -public: - explicit PlayTimeManager(Service::Account::ProfileManager& profile_manager); - ~PlayTimeManager(); - - YUZU_NON_COPYABLE(PlayTimeManager); - YUZU_NON_MOVEABLE(PlayTimeManager); - - u64 GetPlayTime(u64 program_id) const; - void ResetProgramPlayTime(u64 program_id); - void SetProgramId(u64 program_id); - void Start(); - void Stop(); - -private: - void AutoTimestamp(std::stop_token stop_token); - void Save(); - - PlayTimeDatabase database; - u64 running_program_id; - std::jthread play_time_thread; - Service::Account::ProfileManager& manager; -}; - -QString ReadablePlayTime(qulonglong time_seconds); - -} // namespace PlayTime diff --git a/src/yuzu/precompiled_headers.h b/src/yuzu/precompiled_headers.h deleted file mode 100644 index aabae730b..000000000 --- a/src/yuzu/precompiled_headers.h +++ /dev/null @@ -1,6 +0,0 @@ -// SPDX-FileCopyrightText: 2022 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include "common/common_precompiled_headers.h" diff --git a/src/yuzu/qt_common.cpp b/src/yuzu/qt_common.cpp deleted file mode 100644 index 413402165..000000000 --- a/src/yuzu/qt_common.cpp +++ /dev/null @@ -1,60 +0,0 @@ -// SPDX-FileCopyrightText: 2023 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include <QGuiApplication> -#include <QStringLiteral> -#include <QWindow> -#include "common/logging/log.h" -#include "core/frontend/emu_window.h" -#include "yuzu/qt_common.h" - -#if !defined(WIN32) && !defined(__APPLE__) -#include <qpa/qplatformnativeinterface.h> -#elif defined(__APPLE__) -#include <objc/message.h> -#endif - -namespace QtCommon { -Core::Frontend::WindowSystemType GetWindowSystemType() { - // Determine WSI type based on Qt platform. - QString platform_name = QGuiApplication::platformName(); - if (platform_name == QStringLiteral("windows")) - return Core::Frontend::WindowSystemType::Windows; - else if (platform_name == QStringLiteral("xcb")) - return Core::Frontend::WindowSystemType::X11; - else if (platform_name == QStringLiteral("wayland")) - return Core::Frontend::WindowSystemType::Wayland; - else if (platform_name == QStringLiteral("wayland-egl")) - return Core::Frontend::WindowSystemType::Wayland; - else if (platform_name == QStringLiteral("cocoa")) - return Core::Frontend::WindowSystemType::Cocoa; - else if (platform_name == QStringLiteral("android")) - return Core::Frontend::WindowSystemType::Android; - - LOG_CRITICAL(Frontend, "Unknown Qt platform {}!", platform_name.toStdString()); - return Core::Frontend::WindowSystemType::Windows; -} // namespace Core::Frontend::WindowSystemType - -Core::Frontend::EmuWindow::WindowSystemInfo GetWindowSystemInfo(QWindow* window) { - Core::Frontend::EmuWindow::WindowSystemInfo wsi; - wsi.type = GetWindowSystemType(); - -#if defined(WIN32) - // Our Win32 Qt external doesn't have the private API. - wsi.render_surface = reinterpret_cast<void*>(window->winId()); -#elif defined(__APPLE__) - wsi.render_surface = reinterpret_cast<void* (*)(id, SEL)>(objc_msgSend)( - reinterpret_cast<id>(window->winId()), sel_registerName("layer")); -#else - QPlatformNativeInterface* pni = QGuiApplication::platformNativeInterface(); - wsi.display_connection = pni->nativeResourceForWindow("display", window); - if (wsi.type == Core::Frontend::WindowSystemType::Wayland) - wsi.render_surface = window ? pni->nativeResourceForWindow("surface", window) : nullptr; - else - wsi.render_surface = window ? reinterpret_cast<void*>(window->winId()) : nullptr; -#endif - wsi.render_surface_scale = window ? static_cast<float>(window->devicePixelRatio()) : 1.0f; - - return wsi; -} -} // namespace QtCommon diff --git a/src/yuzu/qt_common.h b/src/yuzu/qt_common.h deleted file mode 100644 index 9c63f08f3..000000000 --- a/src/yuzu/qt_common.h +++ /dev/null @@ -1,15 +0,0 @@ -// SPDX-FileCopyrightText: 2023 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include <QWindow> -#include "core/frontend/emu_window.h" - -namespace QtCommon { - -Core::Frontend::WindowSystemType GetWindowSystemType(); - -Core::Frontend::EmuWindow::WindowSystemInfo GetWindowSystemInfo(QWindow* window); - -} // namespace QtCommon diff --git a/src/yuzu/startup_checks.cpp b/src/yuzu/startup_checks.cpp deleted file mode 100644 index 6eefc94ed..000000000 --- a/src/yuzu/startup_checks.cpp +++ /dev/null @@ -1,197 +0,0 @@ -// 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> -#include <processthreadsapi.h> -#include <windows.h> -#elif defined(YUZU_UNIX) -#include <cstring> -#include <errno.h> -#include <spawn.h> -#include <sys/types.h> -#include <sys/wait.h> -#include <unistd.h> -#endif - -#include <fmt/core.h> -#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 auto library = Vulkan::OpenLibrary(); - const Vulkan::vk::Instance instance = - Vulkan::CreateInstance(*library, dld, VK_API_VERSION_1_1); - - } catch (const Vulkan::vk::Exception& exception) { - fmt::print(stderr, "Failed to initialize Vulkan: {}\n", exception.what()); - } -} - -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)) { - fmt::print(stderr, "SetEnvironmentVariableA failed to set {} with error {}\n", - IS_CHILD_ENV_VAR, GetLastError()); - return true; - } -#elif defined(YUZU_UNIX) - const char* startup_check_var = getenv(STARTUP_CHECK_ENV_VAR); - if (startup_check_var != nullptr && - std::strncmp(startup_check_var, ENV_VAR_ENABLED_TEXT, 8) == 0) { - CheckVulkan(); - 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) { - fmt::print(stderr, "SetEnvironmentVariableA failed to set {} with error {}\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 process 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) { - fmt::print(stderr, "GetExitCodeProcess failed with error {}\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) { - fmt::print(stderr, "CloseHandle failed with error {}\n", GetLastError()); - } - if (CloseHandle(process_info.hThread) == 0) { - fmt::print(stderr, "CloseHandle failed with error {}\n", GetLastError()); - } - } - - if (!SetEnvironmentVariableA(STARTUP_CHECK_ENV_VAR, nullptr)) { - fmt::print(stderr, "SetEnvironmentVariableA failed to clear {} with error {}\n", - STARTUP_CHECK_ENV_VAR, GetLastError()); - } - -#elif defined(YUZU_UNIX) - const int env_var_set = setenv(STARTUP_CHECK_ENV_VAR, ENV_VAR_ENABLED_TEXT, 1); - if (env_var_set == -1) { - const int err = errno; - fmt::print(stderr, "setenv failed to set {} with error {}\n", STARTUP_CHECK_ENV_VAR, err); - return false; - } - - if (perform_vulkan_check) { - const pid_t pid = SpawnChild(arg0); - if (pid == -1) { - return false; - } - - // Get exit code from child process - int status; - const int r_val = waitpid(pid, &status, 0); - if (r_val == -1) { - const int err = errno; - fmt::print(stderr, "wait failed with error {}\n", err); - return false; - } - // Vulkan is broken if the child crashed (return value is not zero) - *has_broken_vulkan = (status != 0); - } - - const int env_var_cleared = unsetenv(STARTUP_CHECK_ENV_VAR); - if (env_var_cleared == -1) { - const int err = errno; - fmt::print(stderr, "unsetenv failed to clear {} with error {}\n", STARTUP_CHECK_ENV_VAR, - err); - } -#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, 254); - p_name[254] = '\0'; - - 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) { - fmt::print(stderr, "CreateProcessA failed with error {}\n", GetLastError()); - return false; - } - - return true; -} -#elif defined(YUZU_UNIX) -pid_t SpawnChild(const char* arg0) { - const pid_t pid = fork(); - - if (pid == -1) { - // error - const int err = errno; - fmt::print(stderr, "fork failed with error {}\n", err); - return pid; - } else if (pid == 0) { - // child - execlp(arg0, arg0, nullptr); - const int err = errno; - fmt::print(stderr, "execl failed with error {}\n", err); - _exit(0); - } - - return pid; -} -#endif diff --git a/src/yuzu/startup_checks.h b/src/yuzu/startup_checks.h deleted file mode 100644 index 2f86fb843..000000000 --- a/src/yuzu/startup_checks.h +++ /dev/null @@ -1,24 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#ifdef _WIN32 -#include <windows.h> -#elif defined(YUZU_UNIX) -#include <sys/types.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); -#elif defined(YUZU_UNIX) -pid_t SpawnChild(const char* arg0); -#endif diff --git a/src/yuzu/uisettings.cpp b/src/yuzu/uisettings.cpp deleted file mode 100644 index 7bb7e95af..000000000 --- a/src/yuzu/uisettings.cpp +++ /dev/null @@ -1,112 +0,0 @@ -// SPDX-FileCopyrightText: 2016 Citra Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include <QSettings> -#include "common/fs/fs.h" -#include "common/fs/path_util.h" -#include "yuzu/uisettings.h" - -#ifndef CANNOT_EXPLICITLY_INSTANTIATE -namespace Settings { -template class Setting<bool>; -template class Setting<std::string>; -template class Setting<u16, true>; -template class Setting<u32>; -template class Setting<u8, true>; -template class Setting<u8>; -template class Setting<unsigned long long>; -} // namespace Settings -#endif - -namespace FS = Common::FS; - -namespace UISettings { - -const Themes themes{{ - {"Default", "default"}, - {"Default Colorful", "colorful"}, - {"Dark", "qdarkstyle"}, - {"Dark Colorful", "colorful_dark"}, - {"Midnight Blue", "qdarkstyle_midnight_blue"}, - {"Midnight Blue Colorful", "colorful_midnight_blue"}, -}}; - -bool IsDarkTheme() { - const auto& theme = UISettings::values.theme; - return theme == std::string("qdarkstyle") || theme == std::string("qdarkstyle_midnight_blue") || - theme == std::string("colorful_dark") || theme == std::string("colorful_midnight_blue"); -} - -Values values = {}; - -u32 CalculateWidth(u32 height, Settings::AspectRatio ratio) { - switch (ratio) { - case Settings::AspectRatio::R4_3: - return height * 4 / 3; - case Settings::AspectRatio::R21_9: - return height * 21 / 9; - case Settings::AspectRatio::R16_10: - return height * 16 / 10; - case Settings::AspectRatio::R16_9: - case Settings::AspectRatio::Stretch: - // TODO: Move this function wherever appropriate to implement Stretched aspect - break; - } - return height * 16 / 9; -} - -void SaveWindowState() { - const auto window_state_config_loc = - FS::PathToUTF8String(FS::GetYuzuPath(FS::YuzuPath::ConfigDir) / "window_state.ini"); - - void(FS::CreateParentDir(window_state_config_loc)); - QSettings config(QString::fromStdString(window_state_config_loc), QSettings::IniFormat); - - config.setValue(QStringLiteral("geometry"), values.geometry); - config.setValue(QStringLiteral("state"), values.state); - config.setValue(QStringLiteral("geometryRenderWindow"), values.renderwindow_geometry); - config.setValue(QStringLiteral("gameListHeaderState"), values.gamelist_header_state); - config.setValue(QStringLiteral("microProfileDialogGeometry"), values.microprofile_geometry); - - config.sync(); -} - -void RestoreWindowState(std::unique_ptr<QtConfig>& qtConfig) { - const auto window_state_config_loc = - FS::PathToUTF8String(FS::GetYuzuPath(FS::YuzuPath::ConfigDir) / "window_state.ini"); - - // Migrate window state from old location - if (!FS::Exists(window_state_config_loc) && qtConfig->Exists("UI", "UILayout\\geometry")) { - const auto config_loc = - FS::PathToUTF8String(FS::GetYuzuPath(FS::YuzuPath::ConfigDir) / "qt-config.ini"); - QSettings config(QString::fromStdString(config_loc), QSettings::IniFormat); - - config.beginGroup(QStringLiteral("UI")); - config.beginGroup(QStringLiteral("UILayout")); - values.geometry = config.value(QStringLiteral("geometry")).toByteArray(); - values.state = config.value(QStringLiteral("state")).toByteArray(); - values.renderwindow_geometry = - config.value(QStringLiteral("geometryRenderWindow")).toByteArray(); - values.gamelist_header_state = - config.value(QStringLiteral("gameListHeaderState")).toByteArray(); - values.microprofile_geometry = - config.value(QStringLiteral("microProfileDialogGeometry")).toByteArray(); - config.endGroup(); - config.endGroup(); - return; - } - - void(FS::CreateParentDir(window_state_config_loc)); - const QSettings config(QString::fromStdString(window_state_config_loc), QSettings::IniFormat); - - values.geometry = config.value(QStringLiteral("geometry")).toByteArray(); - values.state = config.value(QStringLiteral("state")).toByteArray(); - values.renderwindow_geometry = - config.value(QStringLiteral("geometryRenderWindow")).toByteArray(); - values.gamelist_header_state = - config.value(QStringLiteral("gameListHeaderState")).toByteArray(); - values.microprofile_geometry = - config.value(QStringLiteral("microProfileDialogGeometry")).toByteArray(); -} - -} // namespace UISettings diff --git a/src/yuzu/uisettings.h b/src/yuzu/uisettings.h deleted file mode 100644 index 03e42b930..000000000 --- a/src/yuzu/uisettings.h +++ /dev/null @@ -1,279 +0,0 @@ -// SPDX-FileCopyrightText: 2016 Citra Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include <array> -#include <atomic> -#include <vector> -#include <QByteArray> -#include <QMetaType> -#include <QString> -#include <QStringList> -#include <QVector> -#include "common/common_types.h" -#include "common/settings.h" -#include "common/settings_enums.h" -#include "configuration/qt_config.h" - -using Settings::Category; -using Settings::ConfirmStop; -using Settings::Setting; -using Settings::SwitchableSetting; - -#ifndef CANNOT_EXPLICITLY_INSTANTIATE -namespace Settings { -extern template class Setting<bool>; -extern template class Setting<std::string>; -extern template class Setting<u16, true>; -extern template class Setting<u32>; -extern template class Setting<u8, true>; -extern template class Setting<u8>; -extern template class Setting<unsigned long long>; -} // namespace Settings -#endif - -namespace UISettings { - -bool IsDarkTheme(); - -struct ContextualShortcut { - std::string keyseq; - std::string controller_keyseq; - int context; - bool repeat; -}; - -struct Shortcut { - std::string name; - std::string group; - ContextualShortcut shortcut; -}; - -enum class Theme { - Default, - DefaultColorful, - Dark, - DarkColorful, - MidnightBlue, - MidnightBlueColorful, -}; - -static constexpr Theme default_theme{ -#ifdef _WIN32 - Theme::DarkColorful -#else - Theme::DefaultColorful -#endif -}; - -using Themes = std::array<std::pair<const char*, const char*>, 6>; -extern const Themes themes; - -struct GameDir { - std::string path; - bool deep_scan = false; - bool expanded = false; - bool operator==(const GameDir& rhs) const { - return path == rhs.path; - } - bool operator!=(const GameDir& rhs) const { - return !operator==(rhs); - } -}; - -struct Values { - Settings::Linkage linkage{1000}; - - QByteArray geometry; - QByteArray state; - - QByteArray renderwindow_geometry; - - QByteArray gamelist_header_state; - - QByteArray microprofile_geometry; - Setting<bool> microprofile_visible{linkage, false, "microProfileDialogVisible", - Category::UiLayout}; - - Setting<bool> single_window_mode{linkage, true, "singleWindowMode", Category::Ui}; - Setting<bool> fullscreen{linkage, false, "fullscreen", Category::Ui}; - Setting<bool> display_titlebar{linkage, true, "displayTitleBars", Category::Ui}; - Setting<bool> show_filter_bar{linkage, true, "showFilterBar", Category::Ui}; - Setting<bool> show_status_bar{linkage, true, "showStatusBar", Category::Ui}; - - SwitchableSetting<ConfirmStop> confirm_before_stopping{linkage, - ConfirmStop::Ask_Always, - "confirmStop", - Category::UiGeneral, - Settings::Specialization::Default, - true, - true}; - - Setting<bool> first_start{linkage, true, "firstStart", Category::Ui}; - Setting<bool> pause_when_in_background{linkage, - false, - "pauseWhenInBackground", - Category::UiGeneral, - Settings::Specialization::Default, - true, - true}; - Setting<bool> mute_when_in_background{linkage, - false, - "muteWhenInBackground", - Category::UiAudio, - Settings::Specialization::Default, - true, - true}; - Setting<bool> hide_mouse{ - linkage, true, "hideInactiveMouse", Category::UiGeneral, Settings::Specialization::Default, - true, true}; - Setting<bool> controller_applet_disabled{linkage, false, "disableControllerApplet", - Category::UiGeneral}; - // Set when Vulkan is known to crash the application - bool has_broken_vulkan = false; - - Setting<bool> select_user_on_boot{linkage, - false, - "select_user_on_boot", - Category::UiGeneral, - Settings::Specialization::Default, - true, - true}; - Setting<bool> disable_web_applet{linkage, true, "disable_web_applet", Category::Ui}; - - // Discord RPC - Setting<bool> enable_discord_presence{linkage, true, "enable_discord_presence", Category::Ui}; - - // logging - Setting<bool> show_console{linkage, false, "showConsole", Category::Ui}; - - // Screenshots - Setting<bool> enable_screenshot_save_as{linkage, true, "enable_screenshot_save_as", - Category::Screenshots}; - Setting<u32> screenshot_height{linkage, 0, "screenshot_height", Category::Screenshots}; - - std::string roms_path; - std::string game_dir_deprecated; - bool game_dir_deprecated_deepscan; - QVector<GameDir> game_dirs; - QStringList recent_files; - Setting<std::string> language{linkage, {}, "language", Category::Paths}; - - std::string theme; - - // Shortcut name <Shortcut, context> - std::vector<Shortcut> shortcuts; - - Setting<u32> callout_flags{linkage, 0, "calloutFlags", Category::Ui}; - - // multiplayer settings - Setting<std::string> multiplayer_nickname{linkage, {}, "nickname", Category::Multiplayer}; - Setting<std::string> multiplayer_filter_text{linkage, {}, "filter_text", Category::Multiplayer}; - Setting<bool> multiplayer_filter_games_owned{linkage, false, "filter_games_owned", - Category::Multiplayer}; - Setting<bool> multiplayer_filter_hide_empty{linkage, false, "filter_games_hide_empty", - Category::Multiplayer}; - Setting<bool> multiplayer_filter_hide_full{linkage, false, "filter_games_hide_full", - Category::Multiplayer}; - Setting<std::string> multiplayer_ip{linkage, {}, "ip", Category::Multiplayer}; - Setting<u16, true> multiplayer_port{linkage, 24872, 0, - UINT16_MAX, "port", Category::Multiplayer}; - Setting<std::string> multiplayer_room_nickname{ - linkage, {}, "room_nickname", Category::Multiplayer}; - Setting<std::string> multiplayer_room_name{linkage, {}, "room_name", Category::Multiplayer}; - Setting<u8, true> multiplayer_max_player{linkage, 8, 0, 8, "max_player", Category::Multiplayer}; - Setting<u16, true> multiplayer_room_port{linkage, 24872, 0, - UINT16_MAX, "room_port", Category::Multiplayer}; - Setting<u8, true> multiplayer_host_type{linkage, 0, 0, 1, "host_type", Category::Multiplayer}; - Setting<unsigned long long> multiplayer_game_id{linkage, {}, "game_id", Category::Multiplayer}; - Setting<std::string> multiplayer_room_description{ - linkage, {}, "room_description", Category::Multiplayer}; - std::pair<std::vector<std::string>, std::vector<std::string>> multiplayer_ban_list; - - // Game List - Setting<bool> show_add_ons{linkage, true, "show_add_ons", Category::UiGameList}; - Setting<u32> game_icon_size{linkage, 64, "game_icon_size", Category::UiGameList}; - Setting<u32> folder_icon_size{linkage, 48, "folder_icon_size", Category::UiGameList}; - Setting<u8> row_1_text_id{linkage, 3, "row_1_text_id", Category::UiGameList}; - Setting<u8> row_2_text_id{linkage, 2, "row_2_text_id", Category::UiGameList}; - std::atomic_bool is_game_list_reload_pending{false}; - Setting<bool> cache_game_list{linkage, true, "cache_game_list", Category::UiGameList}; - Setting<bool> favorites_expanded{linkage, true, "favorites_expanded", Category::UiGameList}; - QVector<u64> favorited_ids; - - // Compatibility List - Setting<bool> show_compat{linkage, false, "show_compat", Category::UiGameList}; - - // Size & File Types Column - Setting<bool> show_size{linkage, true, "show_size", Category::UiGameList}; - Setting<bool> show_types{linkage, true, "show_types", Category::UiGameList}; - - // Play time - Setting<bool> show_play_time{linkage, true, "show_play_time", Category::UiGameList}; - - bool configuration_applied; - bool reset_to_defaults; - bool shortcut_already_warned{false}; -}; - -extern Values values; - -u32 CalculateWidth(u32 height, Settings::AspectRatio ratio); - -void SaveWindowState(); -void RestoreWindowState(std::unique_ptr<QtConfig>& qtConfig); - -// 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<Shortcut, 28> default_hotkeys{{ - {QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Audio Mute/Unmute")).toStdString(), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")).toStdString(), {std::string("Ctrl+M"), std::string("Home+Dpad_Right"), Qt::WindowShortcut, false}}, - {QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Audio Volume Down")).toStdString(), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")).toStdString(), {std::string("-"), std::string("Home+Dpad_Down"), Qt::ApplicationShortcut, true}}, - {QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Audio Volume Up")).toStdString(), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")).toStdString(), {std::string("="), std::string("Home+Dpad_Up"), Qt::ApplicationShortcut, true}}, - {QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Capture Screenshot")).toStdString(), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")).toStdString(), {std::string("Ctrl+P"), std::string("Screenshot"), Qt::WidgetWithChildrenShortcut, false}}, - {QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Change Adapting Filter")).toStdString(), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")).toStdString(), {std::string("F8"), std::string("Home+L"), Qt::ApplicationShortcut, false}}, - {QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Change Docked Mode")).toStdString(), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")).toStdString(), {std::string("F10"), std::string("Home+X"), Qt::ApplicationShortcut, false}}, - {QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Change GPU Accuracy")).toStdString(), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")).toStdString(), {std::string("F9"), std::string("Home+R"), Qt::ApplicationShortcut, false}}, - {QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Continue/Pause Emulation")).toStdString(), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")).toStdString(), {std::string("F4"), std::string("Home+Plus"), Qt::WindowShortcut, false}}, - {QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Exit Fullscreen")).toStdString(), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")).toStdString(), {std::string("Esc"), std::string(""), Qt::WindowShortcut, false}}, - {QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Exit yuzu")).toStdString(), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")).toStdString(), {std::string("Ctrl+Q"), std::string("Home+Minus"), Qt::WindowShortcut, false}}, - {QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Fullscreen")).toStdString(), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")).toStdString(), {std::string("F11"), std::string("Home+B"), Qt::WindowShortcut, false}}, - {QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Load File")).toStdString(), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")).toStdString(), {std::string("Ctrl+O"), std::string(""), Qt::WidgetWithChildrenShortcut, false}}, - {QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Load/Remove Amiibo")).toStdString(), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")).toStdString(), {std::string("F2"), std::string("Home+A"), Qt::WidgetWithChildrenShortcut, false}}, - {QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Multiplayer Browse Public Game Lobby")).toStdString(), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")).toStdString(), {std::string("Ctrl+B"), std::string(""), Qt::ApplicationShortcut, false}}, - {QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Multiplayer Create Room")).toStdString(), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")).toStdString(), {std::string("Ctrl+N"), std::string(""), Qt::ApplicationShortcut, false}}, - {QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Multiplayer Direct Connect to Room")).toStdString(), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")).toStdString(), {std::string("Ctrl+C"), std::string(""), Qt::ApplicationShortcut, false}}, - {QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Multiplayer Leave Room")).toStdString(), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")).toStdString(), {std::string("Ctrl+L"), std::string(""), Qt::ApplicationShortcut, false}}, - {QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Multiplayer Show Current Room")).toStdString(), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")).toStdString(), {std::string("Ctrl+R"), std::string(""), Qt::ApplicationShortcut, false}}, - {QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Restart Emulation")).toStdString(), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")).toStdString(), {std::string("F6"), std::string("R+Plus+Minus"), Qt::WindowShortcut, false}}, - {QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Stop Emulation")).toStdString(), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")).toStdString(), {std::string("F5"), std::string("L+Plus+Minus"), Qt::WindowShortcut, false}}, - {QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "TAS Record")).toStdString(), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")).toStdString(), {std::string("Ctrl+F7"), std::string(""), Qt::ApplicationShortcut, false}}, - {QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "TAS Reset")).toStdString(), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")).toStdString(), {std::string("Ctrl+F6"), std::string(""), Qt::ApplicationShortcut, false}}, - {QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "TAS Start/Stop")).toStdString(), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")).toStdString(), {std::string("Ctrl+F5"), std::string(""), Qt::ApplicationShortcut, false}}, - {QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Toggle Filter Bar")).toStdString(), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")).toStdString(), {std::string("Ctrl+F"), std::string(""), Qt::WindowShortcut, false}}, - {QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Toggle Framerate Limit")).toStdString(), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")).toStdString(), {std::string("Ctrl+U"), std::string("Home+Y"), Qt::ApplicationShortcut, false}}, - {QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Toggle Mouse Panning")).toStdString(), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")).toStdString(), {std::string("Ctrl+F9"), std::string(""), Qt::ApplicationShortcut, false}}, - {QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Toggle Renderdoc Capture")).toStdString(), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")).toStdString(), {std::string(""), std::string(""), Qt::ApplicationShortcut, false}}, - {QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Toggle Status Bar")).toStdString(), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")).toStdString(), {std::string("Ctrl+S"), std::string(""), Qt::WindowShortcut, false}}, -}}; -// clang-format on - -} // namespace UISettings - -Q_DECLARE_METATYPE(UISettings::GameDir*); - -// These metatype declarations cannot be in common/settings.h because core is devoid of QT -Q_DECLARE_METATYPE(Settings::CpuAccuracy); -Q_DECLARE_METATYPE(Settings::GpuAccuracy); -Q_DECLARE_METATYPE(Settings::FullscreenMode); -Q_DECLARE_METATYPE(Settings::NvdecEmulation); -Q_DECLARE_METATYPE(Settings::ResolutionSetup); -Q_DECLARE_METATYPE(Settings::ScalingFilter); -Q_DECLARE_METATYPE(Settings::AntiAliasing); -Q_DECLARE_METATYPE(Settings::RendererBackend); -Q_DECLARE_METATYPE(Settings::ShaderBackend); -Q_DECLARE_METATYPE(Settings::AstcRecompression); -Q_DECLARE_METATYPE(Settings::AstcDecodeMode); diff --git a/src/yuzu/util/clickable_label.cpp b/src/yuzu/util/clickable_label.cpp deleted file mode 100644 index 89d14190a..000000000 --- a/src/yuzu/util/clickable_label.cpp +++ /dev/null @@ -1,11 +0,0 @@ -// 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 deleted file mode 100644 index 4fe744150..000000000 --- a/src/yuzu/util/clickable_label.h +++ /dev/null @@ -1,21 +0,0 @@ -// 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 deleted file mode 100644 index 0dbfca243..000000000 --- a/src/yuzu/util/controller_navigation.cpp +++ /dev/null @@ -1,179 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include "common/settings_input.h" -#include "hid_core/frontend/emulated_controller.h" -#include "hid_core/hid_core.h" -#include "yuzu/util/controller_navigation.h" - -ControllerNavigation::ControllerNavigation(Core::HID::HIDCore& hid_core, QWidget* parent) { - player1_controller = hid_core.GetEmulatedController(Core::HID::NpadIdType::Player1); - handheld_controller = hid_core.GetEmulatedController(Core::HID::NpadIdType::Handheld); - Core::HID::ControllerUpdateCallback engine_callback{ - .on_change = [this](Core::HID::ControllerTriggerType type) { ControllerUpdateEvent(type); }, - .is_npad_service = false, - }; - player1_callback_key = player1_controller->SetCallback(engine_callback); - handheld_callback_key = handheld_controller->SetCallback(engine_callback); - is_controller_set = true; -} - -ControllerNavigation::~ControllerNavigation() { - UnloadController(); -} - -void ControllerNavigation::UnloadController() { - if (is_controller_set) { - player1_controller->DeleteCallback(player1_callback_key); - handheld_controller->DeleteCallback(handheld_callback_key); - is_controller_set = false; - } -} - -void ControllerNavigation::TriggerButton(Settings::NativeButton::Values native_button, - Qt::Key key) { - if (button_values[native_button].value && !button_values[native_button].locked) { - emit TriggerKeyboardEvent(key); - } -} - -void ControllerNavigation::ControllerUpdateEvent(Core::HID::ControllerTriggerType type) { - std::scoped_lock lock{mutex}; - if (!Settings::values.controller_navigation) { - return; - } - if (type == Core::HID::ControllerTriggerType::Button) { - ControllerUpdateButton(); - return; - } - - if (type == Core::HID::ControllerTriggerType::Stick) { - ControllerUpdateStick(); - return; - } -} - -void ControllerNavigation::ControllerUpdateButton() { - const auto controller_type = player1_controller->GetNpadStyleIndex(); - const auto& player1_buttons = player1_controller->GetButtonsValues(); - const auto& handheld_buttons = handheld_controller->GetButtonsValues(); - - for (std::size_t i = 0; i < player1_buttons.size(); ++i) { - const bool button = player1_buttons[i].value || handheld_buttons[i].value; - // Trigger only once - button_values[i].locked = button == button_values[i].value; - button_values[i].value = button; - } - - switch (controller_type) { - case Core::HID::NpadStyleIndex::Fullkey: - case Core::HID::NpadStyleIndex::JoyconDual: - case Core::HID::NpadStyleIndex::Handheld: - case Core::HID::NpadStyleIndex::GameCube: - TriggerButton(Settings::NativeButton::A, Qt::Key_Enter); - TriggerButton(Settings::NativeButton::B, Qt::Key_Escape); - TriggerButton(Settings::NativeButton::DDown, Qt::Key_Down); - TriggerButton(Settings::NativeButton::DLeft, Qt::Key_Left); - TriggerButton(Settings::NativeButton::DRight, Qt::Key_Right); - TriggerButton(Settings::NativeButton::DUp, Qt::Key_Up); - break; - case Core::HID::NpadStyleIndex::JoyconLeft: - TriggerButton(Settings::NativeButton::DDown, Qt::Key_Enter); - TriggerButton(Settings::NativeButton::DLeft, Qt::Key_Escape); - break; - case Core::HID::NpadStyleIndex::JoyconRight: - TriggerButton(Settings::NativeButton::X, Qt::Key_Enter); - TriggerButton(Settings::NativeButton::A, Qt::Key_Escape); - break; - default: - break; - } -} - -void ControllerNavigation::ControllerUpdateStick() { - const auto controller_type = player1_controller->GetNpadStyleIndex(); - const auto& player1_sticks = player1_controller->GetSticksValues(); - const auto& handheld_sticks = player1_controller->GetSticksValues(); - bool update = false; - - for (std::size_t i = 0; i < player1_sticks.size(); ++i) { - const Common::Input::StickStatus stick{ - .left = player1_sticks[i].left || handheld_sticks[i].left, - .right = player1_sticks[i].right || handheld_sticks[i].right, - .up = player1_sticks[i].up || handheld_sticks[i].up, - .down = player1_sticks[i].down || handheld_sticks[i].down, - }; - // Trigger only once - if (stick.down != stick_values[i].down || stick.left != stick_values[i].left || - stick.right != stick_values[i].right || stick.up != stick_values[i].up) { - update = true; - } - stick_values[i] = stick; - } - - if (!update) { - return; - } - - switch (controller_type) { - case Core::HID::NpadStyleIndex::Fullkey: - case Core::HID::NpadStyleIndex::JoyconDual: - case Core::HID::NpadStyleIndex::Handheld: - case Core::HID::NpadStyleIndex::GameCube: - if (stick_values[Settings::NativeAnalog::LStick].down) { - emit TriggerKeyboardEvent(Qt::Key_Down); - return; - } - if (stick_values[Settings::NativeAnalog::LStick].left) { - emit TriggerKeyboardEvent(Qt::Key_Left); - return; - } - if (stick_values[Settings::NativeAnalog::LStick].right) { - emit TriggerKeyboardEvent(Qt::Key_Right); - return; - } - if (stick_values[Settings::NativeAnalog::LStick].up) { - emit TriggerKeyboardEvent(Qt::Key_Up); - return; - } - break; - case Core::HID::NpadStyleIndex::JoyconLeft: - if (stick_values[Settings::NativeAnalog::LStick].left) { - emit TriggerKeyboardEvent(Qt::Key_Down); - return; - } - if (stick_values[Settings::NativeAnalog::LStick].up) { - emit TriggerKeyboardEvent(Qt::Key_Left); - return; - } - if (stick_values[Settings::NativeAnalog::LStick].down) { - emit TriggerKeyboardEvent(Qt::Key_Right); - return; - } - if (stick_values[Settings::NativeAnalog::LStick].right) { - emit TriggerKeyboardEvent(Qt::Key_Up); - return; - } - break; - case Core::HID::NpadStyleIndex::JoyconRight: - if (stick_values[Settings::NativeAnalog::RStick].right) { - emit TriggerKeyboardEvent(Qt::Key_Down); - return; - } - if (stick_values[Settings::NativeAnalog::RStick].down) { - emit TriggerKeyboardEvent(Qt::Key_Left); - return; - } - if (stick_values[Settings::NativeAnalog::RStick].up) { - emit TriggerKeyboardEvent(Qt::Key_Right); - return; - } - if (stick_values[Settings::NativeAnalog::RStick].left) { - emit TriggerKeyboardEvent(Qt::Key_Up); - return; - } - break; - default: - break; - } -} diff --git a/src/yuzu/util/controller_navigation.h b/src/yuzu/util/controller_navigation.h deleted file mode 100644 index 86e210368..000000000 --- a/src/yuzu/util/controller_navigation.h +++ /dev/null @@ -1,50 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include <QKeyEvent> -#include <QObject> - -#include "common/input.h" -#include "common/settings_input.h" - -namespace Core::HID { -using ButtonValues = std::array<Common::Input::ButtonStatus, Settings::NativeButton::NumButtons>; -using SticksValues = std::array<Common::Input::StickStatus, Settings::NativeAnalog::NumAnalogs>; -enum class ControllerTriggerType; -class EmulatedController; -class HIDCore; -} // namespace Core::HID - -class ControllerNavigation : public QObject { - Q_OBJECT - -public: - explicit ControllerNavigation(Core::HID::HIDCore& hid_core, QWidget* parent = nullptr); - ~ControllerNavigation(); - - /// Disables events from the emulated controller - void UnloadController(); - -signals: - void TriggerKeyboardEvent(Qt::Key key); - -private: - void TriggerButton(Settings::NativeButton::Values native_button, Qt::Key key); - void ControllerUpdateEvent(Core::HID::ControllerTriggerType type); - - void ControllerUpdateButton(); - - void ControllerUpdateStick(); - - Core::HID::ButtonValues button_values{}; - Core::HID::SticksValues stick_values{}; - - int player1_callback_key{}; - int handheld_callback_key{}; - bool is_controller_set{}; - mutable std::mutex mutex; - Core::HID::EmulatedController* player1_controller; - Core::HID::EmulatedController* handheld_controller; -}; diff --git a/src/yuzu/util/limitable_input_dialog.cpp b/src/yuzu/util/limitable_input_dialog.cpp deleted file mode 100644 index 5f6a9c193..000000000 --- a/src/yuzu/util/limitable_input_dialog.cpp +++ /dev/null @@ -1,88 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include <QDialogButtonBox> -#include <QLabel> -#include <QLineEdit> -#include <QPushButton> -#include <QVBoxLayout> -#include "yuzu/util/limitable_input_dialog.h" - -LimitableInputDialog::LimitableInputDialog(QWidget* parent) : QDialog{parent} { - CreateUI(); - ConnectEvents(); -} - -LimitableInputDialog::~LimitableInputDialog() = default; - -void LimitableInputDialog::CreateUI() { - text_label = new QLabel(this); - text_entry = new QLineEdit(this); - text_label_invalid = new QLabel(this); - buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this); - - auto* const layout = new QVBoxLayout; - layout->addWidget(text_label); - layout->addWidget(text_entry); - layout->addWidget(text_label_invalid); - layout->addWidget(buttons); - - setLayout(layout); -} - -void LimitableInputDialog::ConnectEvents() { - connect(buttons, &QDialogButtonBox::accepted, this, &QDialog::accept); - connect(buttons, &QDialogButtonBox::rejected, this, &QDialog::reject); -} - -QString LimitableInputDialog::GetText(QWidget* parent, const QString& title, const QString& text, - int min_character_limit, int max_character_limit, - InputLimiter limit_type) { - Q_ASSERT(min_character_limit <= max_character_limit); - - LimitableInputDialog dialog{parent}; - dialog.setWindowTitle(title); - dialog.text_label->setText(text); - dialog.text_entry->setMaxLength(max_character_limit); - dialog.text_label_invalid->show(); - - switch (limit_type) { - case InputLimiter::Filesystem: - dialog.invalid_characters = QStringLiteral("<>:;\"/\\|,.!?*"); - break; - default: - dialog.invalid_characters.clear(); - dialog.text_label_invalid->hide(); - break; - } - dialog.text_label_invalid->setText( - tr("The text can't contain any of the following characters:\n%1") - .arg(dialog.invalid_characters)); - - auto* const ok_button = dialog.buttons->button(QDialogButtonBox::Ok); - ok_button->setEnabled(false); - connect(dialog.text_entry, &QLineEdit::textEdited, [&] { - if (!dialog.invalid_characters.isEmpty()) { - dialog.RemoveInvalidCharacters(); - } - ok_button->setEnabled(dialog.text_entry->text().length() >= min_character_limit); - }); - - if (dialog.exec() != QDialog::Accepted) { - return {}; - } - - return dialog.text_entry->text(); -} - -void LimitableInputDialog::RemoveInvalidCharacters() { - auto cpos = text_entry->cursorPosition(); - for (int i = 0; i < text_entry->text().length(); i++) { - if (invalid_characters.contains(text_entry->text().at(i))) { - text_entry->setText(text_entry->text().remove(i, 1)); - i--; - cpos--; - } - } - text_entry->setCursorPosition(cpos); -} diff --git a/src/yuzu/util/limitable_input_dialog.h b/src/yuzu/util/limitable_input_dialog.h deleted file mode 100644 index f261f1a0f..000000000 --- a/src/yuzu/util/limitable_input_dialog.h +++ /dev/null @@ -1,40 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include <QDialog> - -class QDialogButtonBox; -class QLabel; -class QLineEdit; - -/// A QDialog that functions similarly to QInputDialog, however, it allows -/// restricting the minimum and total number of characters that can be entered. -class LimitableInputDialog final : public QDialog { - Q_OBJECT -public: - explicit LimitableInputDialog(QWidget* parent = nullptr); - ~LimitableInputDialog() override; - - enum class InputLimiter { - None, - Filesystem, - }; - - static QString GetText(QWidget* parent, const QString& title, const QString& text, - int min_character_limit, int max_character_limit, - InputLimiter limit_type = InputLimiter::None); - -private: - void CreateUI(); - void ConnectEvents(); - - void RemoveInvalidCharacters(); - QString invalid_characters; - - QLabel* text_label; - QLineEdit* text_entry; - QLabel* text_label_invalid; - QDialogButtonBox* buttons; -}; diff --git a/src/yuzu/util/overlay_dialog.cpp b/src/yuzu/util/overlay_dialog.cpp deleted file mode 100644 index 466bbe7b2..000000000 --- a/src/yuzu/util/overlay_dialog.cpp +++ /dev/null @@ -1,268 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include <QKeyEvent> -#include <QScreen> -#include <QWindow> - -#include "core/core.h" -#include "hid_core/frontend/input_interpreter.h" -#include "hid_core/hid_types.h" -#include "ui_overlay_dialog.h" -#include "yuzu/util/overlay_dialog.h" - -namespace { - -constexpr float BASE_TITLE_FONT_SIZE = 14.0f; -constexpr float BASE_FONT_SIZE = 18.0f; -constexpr float BASE_WIDTH = 1280.0f; -constexpr float BASE_HEIGHT = 720.0f; - -} // Anonymous namespace - -OverlayDialog::OverlayDialog(QWidget* parent, Core::System& system, const QString& title_text, - const QString& body_text, const QString& left_button_text, - const QString& right_button_text, Qt::Alignment alignment, - bool use_rich_text_) - : QDialog(parent), ui{std::make_unique<Ui::OverlayDialog>()}, use_rich_text{use_rich_text_} { - ui->setupUi(this); - - setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint | Qt::WindowTitleHint | - Qt::WindowSystemMenuHint | Qt::CustomizeWindowHint); - setWindowModality(Qt::WindowModal); - setAttribute(Qt::WA_TranslucentBackground); - - if (use_rich_text) { - InitializeRichTextDialog(title_text, body_text, left_button_text, right_button_text, - alignment); - } else { - InitializeRegularTextDialog(title_text, body_text, left_button_text, right_button_text, - alignment); - } - - MoveAndResizeWindow(); - - // TODO (Morph): Remove this when InputInterpreter no longer relies on the HID backend - if (system.IsPoweredOn() && !ui->buttonsDialog->isHidden()) { - input_interpreter = std::make_unique<InputInterpreter>(system); - - StartInputThread(); - } -} - -OverlayDialog::~OverlayDialog() { - StopInputThread(); -} - -void OverlayDialog::InitializeRegularTextDialog(const QString& title_text, const QString& body_text, - const QString& left_button_text, - const QString& right_button_text, - Qt::Alignment alignment) { - ui->stackedDialog->setCurrentIndex(0); - - ui->label_title->setText(title_text); - ui->label_dialog->setText(body_text); - ui->button_cancel->setText(left_button_text); - ui->button_ok_label->setText(right_button_text); - - ui->label_dialog->setAlignment(alignment); - - if (title_text.isEmpty()) { - ui->label_title->hide(); - ui->verticalLayout_2->setStretch(0, 0); - ui->verticalLayout_2->setStretch(1, 219); - ui->verticalLayout_2->setStretch(2, 82); - } - - if (left_button_text.isEmpty()) { - ui->button_cancel->hide(); - ui->button_cancel->setEnabled(false); - } - - if (right_button_text.isEmpty()) { - ui->button_ok_label->hide(); - ui->button_ok_label->setEnabled(false); - } - - if (ui->button_cancel->isHidden() && ui->button_ok_label->isHidden()) { - ui->buttonsDialog->hide(); - return; - } - - connect( - ui->button_cancel, &QPushButton::clicked, this, - [this](bool) { - StopInputThread(); - QDialog::reject(); - }, - Qt::QueuedConnection); - connect( - ui->button_ok_label, &QPushButton::clicked, this, - [this](bool) { - StopInputThread(); - QDialog::accept(); - }, - Qt::QueuedConnection); -} - -void OverlayDialog::InitializeRichTextDialog(const QString& title_text, const QString& body_text, - const QString& left_button_text, - const QString& right_button_text, - Qt::Alignment alignment) { - ui->stackedDialog->setCurrentIndex(1); - - ui->label_title_rich->setText(title_text); - ui->text_browser_dialog->setText(body_text); - ui->button_cancel_rich->setText(left_button_text); - ui->button_ok_rich->setText(right_button_text); - - // TODO (Morph/Rei): Replace this with something that works better - ui->text_browser_dialog->setAlignment(alignment); - - if (title_text.isEmpty()) { - ui->label_title_rich->hide(); - ui->verticalLayout_3->setStretch(0, 0); - ui->verticalLayout_3->setStretch(1, 438); - ui->verticalLayout_3->setStretch(2, 82); - } - - if (left_button_text.isEmpty()) { - ui->button_cancel_rich->hide(); - ui->button_cancel_rich->setEnabled(false); - } - - if (right_button_text.isEmpty()) { - ui->button_ok_rich->hide(); - ui->button_ok_rich->setEnabled(false); - } - - if (ui->button_cancel_rich->isHidden() && ui->button_ok_rich->isHidden()) { - ui->buttonsRichDialog->hide(); - return; - } - - connect( - ui->button_cancel_rich, &QPushButton::clicked, this, - [this](bool) { - StopInputThread(); - QDialog::reject(); - }, - Qt::QueuedConnection); - connect( - ui->button_ok_rich, &QPushButton::clicked, this, - [this](bool) { - StopInputThread(); - QDialog::accept(); - }, - Qt::QueuedConnection); -} - -void OverlayDialog::MoveAndResizeWindow() { - const auto pos = parentWidget()->mapToGlobal(parentWidget()->rect().topLeft()); - const auto width = static_cast<float>(parentWidget()->width()); - const auto height = static_cast<float>(parentWidget()->height()); - - // High DPI - const float dpi_scale = screen()->logicalDotsPerInch() / 96.0f; - - const auto title_text_font_size = BASE_TITLE_FONT_SIZE * (height / BASE_HEIGHT) / dpi_scale; - const auto body_text_font_size = - BASE_FONT_SIZE * (((width / BASE_WIDTH) + (height / BASE_HEIGHT)) / 2.0f) / dpi_scale; - const auto button_text_font_size = BASE_FONT_SIZE * (height / BASE_HEIGHT) / dpi_scale; - - QFont title_text_font(QStringLiteral("MS Shell Dlg 2"), title_text_font_size, QFont::Normal); - QFont body_text_font(QStringLiteral("MS Shell Dlg 2"), body_text_font_size, QFont::Normal); - QFont button_text_font(QStringLiteral("MS Shell Dlg 2"), button_text_font_size, QFont::Normal); - - if (use_rich_text) { - ui->label_title_rich->setFont(title_text_font); - ui->text_browser_dialog->setFont(body_text_font); - ui->button_cancel_rich->setFont(button_text_font); - ui->button_ok_rich->setFont(button_text_font); - } else { - ui->label_title->setFont(title_text_font); - ui->label_dialog->setFont(body_text_font); - ui->button_cancel->setFont(button_text_font); - ui->button_ok_label->setFont(button_text_font); - } - - QDialog::move(pos); - QDialog::resize(width, height); -} - -template <Core::HID::NpadButton... T> -void OverlayDialog::HandleButtonPressedOnce() { - const auto f = [this](Core::HID::NpadButton button) { - if (input_interpreter->IsButtonPressedOnce(button)) { - TranslateButtonPress(button); - } - }; - - (f(T), ...); -} - -void OverlayDialog::TranslateButtonPress(Core::HID::NpadButton button) { - QPushButton* left_button = use_rich_text ? ui->button_cancel_rich : ui->button_cancel; - QPushButton* right_button = use_rich_text ? ui->button_ok_rich : ui->button_ok_label; - - // TODO (Morph): Handle QTextBrowser text scrolling - // TODO (Morph): focusPrevious/NextChild() doesn't work well with the rich text dialog, fix it - - switch (button) { - case Core::HID::NpadButton::A: - case Core::HID::NpadButton::B: - if (left_button->hasFocus()) { - left_button->click(); - } else if (right_button->hasFocus()) { - right_button->click(); - } - break; - case Core::HID::NpadButton::Left: - case Core::HID::NpadButton::StickLLeft: - focusPreviousChild(); - break; - case Core::HID::NpadButton::Right: - case Core::HID::NpadButton::StickLRight: - focusNextChild(); - break; - default: - break; - } -} - -void OverlayDialog::StartInputThread() { - if (input_thread_running) { - return; - } - - input_thread_running = true; - - input_thread = std::thread(&OverlayDialog::InputThread, this); -} - -void OverlayDialog::StopInputThread() { - input_thread_running = false; - - if (input_thread.joinable()) { - input_thread.join(); - } -} - -void OverlayDialog::InputThread() { - while (input_thread_running) { - input_interpreter->PollInput(); - - HandleButtonPressedOnce<Core::HID::NpadButton::A, Core::HID::NpadButton::B, - Core::HID::NpadButton::Left, Core::HID::NpadButton::Right, - Core::HID::NpadButton::StickLLeft, - Core::HID::NpadButton::StickLRight>(); - - std::this_thread::sleep_for(std::chrono::milliseconds(50)); - } -} - -void OverlayDialog::keyPressEvent(QKeyEvent* e) { - if (!ui->buttonsDialog->isHidden() || e->key() != Qt::Key_Escape) { - QDialog::keyPressEvent(e); - } -} diff --git a/src/yuzu/util/overlay_dialog.h b/src/yuzu/util/overlay_dialog.h deleted file mode 100644 index 62f9da311..000000000 --- a/src/yuzu/util/overlay_dialog.h +++ /dev/null @@ -1,108 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include <atomic> -#include <memory> -#include <thread> - -#include <QDialog> - -#include "common/common_types.h" - -class InputInterpreter; - -namespace Core { -class System; -} - -namespace Core::HID { -enum class NpadButton : u64; -} - -namespace Ui { -class OverlayDialog; -} - -/** - * An OverlayDialog is an interactive dialog that accepts controller input (while a game is running) - * This dialog attempts to replicate the look and feel of the Nintendo Switch's overlay dialogs and - * provide some extra features such as embedding HTML/Rich Text content in a QTextBrowser. - * The OverlayDialog provides 2 modes: one to embed regular text into a QLabel and another to embed - * HTML/Rich Text content into a QTextBrowser. - */ -class OverlayDialog final : public QDialog { - Q_OBJECT - -public: - explicit OverlayDialog(QWidget* parent, Core::System& system, const QString& title_text, - const QString& body_text, const QString& left_button_text, - const QString& right_button_text, - Qt::Alignment alignment = Qt::AlignCenter, bool use_rich_text_ = false); - ~OverlayDialog() override; - -private: - /** - * Initializes a text dialog with a QLabel storing text. - * Only use this for short text as the dialog buttons would be squashed with longer text. - * - * @param title_text Title text to be displayed - * @param body_text Main text to be displayed - * @param left_button_text Left button text. If empty, the button is hidden and disabled - * @param right_button_text Right button text. If empty, the button is hidden and disabled - * @param alignment Main text alignment - */ - void InitializeRegularTextDialog(const QString& title_text, const QString& body_text, - const QString& left_button_text, - const QString& right_button_text, Qt::Alignment alignment); - - /** - * Initializes a text dialog with a QTextBrowser storing text. - * This is ideal for longer text or rich text content. A scrollbar is shown for longer text. - * - * @param title_text Title text to be displayed - * @param body_text Main text to be displayed - * @param left_button_text Left button text. If empty, the button is hidden and disabled - * @param right_button_text Right button text. If empty, the button is hidden and disabled - * @param alignment Main text alignment - */ - void InitializeRichTextDialog(const QString& title_text, const QString& body_text, - const QString& left_button_text, const QString& right_button_text, - Qt::Alignment alignment); - - /// Moves and resizes the dialog to be fully overlaid on top of the parent window. - void MoveAndResizeWindow(); - - /** - * Handles button presses and converts them into keyboard input. - * - * @tparam HIDButton The list of buttons that can be converted into keyboard input. - */ - template <Core::HID::NpadButton... T> - void HandleButtonPressedOnce(); - - /** - * Translates a button press to focus or click either the left or right buttons. - * - * @param button The button press to process. - */ - void TranslateButtonPress(Core::HID::NpadButton button); - - void StartInputThread(); - void StopInputThread(); - - /// The thread where input is being polled and processed. - void InputThread(); - void keyPressEvent(QKeyEvent* e) override; - - std::unique_ptr<Ui::OverlayDialog> ui; - - bool use_rich_text; - - std::unique_ptr<InputInterpreter> input_interpreter; - - std::thread input_thread; - - std::atomic<bool> input_thread_running{}; -}; diff --git a/src/yuzu/util/overlay_dialog.ui b/src/yuzu/util/overlay_dialog.ui deleted file mode 100644 index 278e2f219..000000000 --- a/src/yuzu/util/overlay_dialog.ui +++ /dev/null @@ -1,404 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>OverlayDialog</class> - <widget class="QDialog" name="OverlayDialog"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>1280</width> - <height>720</height> - </rect> - </property> - <property name="windowTitle"> - <string>Dialog</string> - </property> - <property name="styleSheet"> - <string notr="true"/> - </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <property name="spacing"> - <number>0</number> - </property> - <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="QStackedWidget" name="stackedDialog"> - <property name="currentIndex"> - <number>0</number> - </property> - <widget class="QWidget" name="lineDialog"> - <layout class="QGridLayout" name="lineDialogGridLayout" rowstretch="210,300,210" columnstretch="250,780,250"> - <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> - <property name="spacing"> - <number>0</number> - </property> - <item row="1" column="1"> - <widget class="QWidget" name="contentDialog" native="true"> - <layout class="QVBoxLayout" name="verticalLayout_2" stretch="70,149,82"> - <property name="spacing"> - <number>0</number> - </property> - <property name="leftMargin"> - <number>0</number> - </property> - <property name="topMargin"> - <number>0</number> - </property> - <property name="rightMargin"> - <number>0</number> - </property> - <property name="bottomMargin"> - <number>0</number> - </property> - <item> - <widget class="QLabel" name="label_title"> - <property name="font"> - <font> - <pointsize>14</pointsize> - </font> - </property> - <property name="alignment"> - <set>Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set> - </property> - </widget> - </item> - <item> - <widget class="QLabel" name="label_dialog"> - <property name="font"> - <font> - <pointsize>18</pointsize> - </font> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - <property name="wordWrap"> - <bool>true</bool> - </property> - </widget> - </item> - <item> - <widget class="QWidget" name="buttonsDialog" native="true"> - <layout class="QHBoxLayout" name="horizontalLayout"> - <property name="spacing"> - <number>0</number> - </property> - <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="QPushButton" name="button_cancel"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Expanding"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="font"> - <font> - <pointsize>18</pointsize> - </font> - </property> - <property name="text"> - <string>Cancel</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="button_ok_label"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Expanding"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="font"> - <font> - <pointsize>18</pointsize> - </font> - </property> - <property name="text"> - <string>OK</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - </item> - <item row="0" column="1"> - <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 row="1" 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="2" column="1"> - <spacer name="verticalSpacer_2"> - <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 row="1" column="2"> - <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> - <widget class="QWidget" name="richDialog"> - <layout class="QGridLayout" name="richDialogGridLayout" rowstretch="100,520,100" columnstretch="165,950,165"> - <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> - <property name="spacing"> - <number>0</number> - </property> - <item row="1" column="0"> - <spacer name="horizontalSpacer_3"> - <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="2" column="1"> - <spacer name="verticalSpacer_4"> - <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 row="0" column="1"> - <spacer name="verticalSpacer_3"> - <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 row="1" column="1"> - <widget class="QWidget" name="contentRichDialog" native="true"> - <layout class="QVBoxLayout" name="verticalLayout_3" stretch="70,368,82"> - <property name="spacing"> - <number>0</number> - </property> - <property name="leftMargin"> - <number>0</number> - </property> - <property name="topMargin"> - <number>0</number> - </property> - <property name="rightMargin"> - <number>0</number> - </property> - <property name="bottomMargin"> - <number>0</number> - </property> - <item> - <widget class="QLabel" name="label_title_rich"> - <property name="font"> - <font> - <pointsize>14</pointsize> - </font> - </property> - <property name="text"> - <string/> - </property> - <property name="alignment"> - <set>Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set> - </property> - </widget> - </item> - <item> - <widget class="QTextBrowser" name="text_browser_dialog"> - <property name="font"> - <font> - <pointsize>18</pointsize> - </font> - </property> - <property name="html"> - <string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:18pt; font-weight:400; font-style:normal;"> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p></body></html></string> - </property> - </widget> - </item> - <item> - <widget class="QWidget" name="buttonsRichDialog" native="true"> - <layout class="QHBoxLayout" name="horizontalLayout_2"> - <property name="spacing"> - <number>0</number> - </property> - <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="QPushButton" name="button_cancel_rich"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Expanding"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="font"> - <font> - <pointsize>18</pointsize> - </font> - </property> - <property name="text"> - <string>Cancel</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="button_ok_rich"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Expanding"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="font"> - <font> - <pointsize>18</pointsize> - </font> - </property> - <property name="text"> - <string>OK</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - </item> - <item row="1" column="2"> - <spacer name="horizontalSpacer_4"> - <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> - </widget> - </item> - </layout> - </widget> - <resources> - <include location="../../../dist/icons/overlay/overlay.qrc"/> - </resources> - <connections/> -</ui> diff --git a/src/yuzu/util/sequence_dialog/sequence_dialog.cpp b/src/yuzu/util/sequence_dialog/sequence_dialog.cpp deleted file mode 100644 index 1670aa596..000000000 --- a/src/yuzu/util/sequence_dialog/sequence_dialog.cpp +++ /dev/null @@ -1,38 +0,0 @@ -// SPDX-FileCopyrightText: 2018 Citra Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include <QDialogButtonBox> -#include <QKeySequenceEdit> -#include <QVBoxLayout> -#include "yuzu/util/sequence_dialog/sequence_dialog.h" - -SequenceDialog::SequenceDialog(QWidget* parent) : QDialog(parent) { - setWindowTitle(tr("Enter a hotkey")); - - key_sequence = new QKeySequenceEdit; - - auto* const buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); - buttons->setCenterButtons(true); - - auto* const layout = new QVBoxLayout(this); - layout->addWidget(key_sequence); - layout->addWidget(buttons); - - connect(buttons, &QDialogButtonBox::accepted, this, &QDialog::accept); - connect(buttons, &QDialogButtonBox::rejected, this, &QDialog::reject); -} - -SequenceDialog::~SequenceDialog() = default; - -QKeySequence SequenceDialog::GetSequence() const { - // Only the first key is returned. The other 3, if present, are ignored. - return QKeySequence(key_sequence->keySequence()[0]); -} - -bool SequenceDialog::focusNextPrevChild(bool next) { - return false; -} - -void SequenceDialog::closeEvent(QCloseEvent*) { - reject(); -} diff --git a/src/yuzu/util/sequence_dialog/sequence_dialog.h b/src/yuzu/util/sequence_dialog/sequence_dialog.h deleted file mode 100644 index 85e146d40..000000000 --- a/src/yuzu/util/sequence_dialog/sequence_dialog.h +++ /dev/null @@ -1,23 +0,0 @@ -// SPDX-FileCopyrightText: 2018 Citra Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include <QDialog> - -class QKeySequenceEdit; - -class SequenceDialog : public QDialog { - Q_OBJECT - -public: - explicit SequenceDialog(QWidget* parent = nullptr); - ~SequenceDialog() override; - - QKeySequence GetSequence() const; - void closeEvent(QCloseEvent*) override; - -private: - QKeySequenceEdit* key_sequence; - bool focusNextPrevChild(bool next) override; -}; diff --git a/src/yuzu/util/url_request_interceptor.cpp b/src/yuzu/util/url_request_interceptor.cpp deleted file mode 100644 index 996097e35..000000000 --- a/src/yuzu/util/url_request_interceptor.cpp +++ /dev/null @@ -1,33 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#ifdef YUZU_USE_QT_WEB_ENGINE - -#include "yuzu/util/url_request_interceptor.h" - -UrlRequestInterceptor::UrlRequestInterceptor(QObject* p) : QWebEngineUrlRequestInterceptor(p) {} - -UrlRequestInterceptor::~UrlRequestInterceptor() = default; - -void UrlRequestInterceptor::interceptRequest(QWebEngineUrlRequestInfo& info) { - const auto resource_type = info.resourceType(); - - switch (resource_type) { - case QWebEngineUrlRequestInfo::ResourceTypeMainFrame: - requested_url = info.requestUrl(); - emit FrameChanged(); - break; - case QWebEngineUrlRequestInfo::ResourceTypeSubFrame: - case QWebEngineUrlRequestInfo::ResourceTypeXhr: - emit FrameChanged(); - break; - default: - break; - } -} - -QUrl UrlRequestInterceptor::GetRequestedURL() const { - return requested_url; -} - -#endif diff --git a/src/yuzu/util/url_request_interceptor.h b/src/yuzu/util/url_request_interceptor.h deleted file mode 100644 index 9831e1523..000000000 --- a/src/yuzu/util/url_request_interceptor.h +++ /dev/null @@ -1,29 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#ifdef YUZU_USE_QT_WEB_ENGINE - -#include <QObject> -#include <QWebEngineUrlRequestInterceptor> - -class UrlRequestInterceptor : public QWebEngineUrlRequestInterceptor { - Q_OBJECT - -public: - explicit UrlRequestInterceptor(QObject* p = nullptr); - ~UrlRequestInterceptor() override; - - void interceptRequest(QWebEngineUrlRequestInfo& info) override; - - QUrl GetRequestedURL() const; - -signals: - void FrameChanged(); - -private: - QUrl requested_url; -}; - -#endif diff --git a/src/yuzu/util/util.cpp b/src/yuzu/util/util.cpp deleted file mode 100644 index e22cf84bf..000000000 --- a/src/yuzu/util/util.cpp +++ /dev/null @@ -1,152 +0,0 @@ -// SPDX-FileCopyrightText: 2015 Citra Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include <array> -#include <cmath> -#include <QPainter> - -#include "common/logging/log.h" -#include "yuzu/util/util.h" - -#ifdef _WIN32 -#include <windows.h> -#include "common/fs/file.h" -#endif - -QFont GetMonospaceFont() { - QFont font(QStringLiteral("monospace")); - // Automatic fallback to a monospace font on on platforms without a font called "monospace" - font.setStyleHint(QFont::Monospace); - font.setFixedPitch(true); - return font; -} - -QString ReadableByteSize(qulonglong size) { - static constexpr std::array units{"B", "KiB", "MiB", "GiB", "TiB", "PiB"}; - if (size == 0) { - return QStringLiteral("0"); - } - - const int digit_groups = std::min(static_cast<int>(std::log10(size) / std::log10(1024)), - static_cast<int>(units.size())); - return QStringLiteral("%L1 %2") - .arg(size / std::pow(1024, digit_groups), 0, 'f', 1) - .arg(QString::fromUtf8(units[digit_groups])); -} - -QPixmap CreateCirclePixmapFromColor(const QColor& color) { - QPixmap circle_pixmap(16, 16); - circle_pixmap.fill(Qt::transparent); - QPainter painter(&circle_pixmap); - painter.setRenderHint(QPainter::Antialiasing); - painter.setPen(color); - painter.setBrush(color); - painter.drawEllipse({circle_pixmap.width() / 2.0, circle_pixmap.height() / 2.0}, 7.0, 7.0); - return circle_pixmap; -} - -bool SaveIconToFile(const std::filesystem::path& icon_path, const QImage& image) { -#if defined(WIN32) -#pragma pack(push, 2) - struct IconDir { - WORD id_reserved; - WORD id_type; - WORD id_count; - }; - - struct IconDirEntry { - BYTE width; - BYTE height; - BYTE color_count; - BYTE reserved; - WORD planes; - WORD bit_count; - DWORD bytes_in_res; - DWORD image_offset; - }; -#pragma pack(pop) - - const QImage source_image = image.convertToFormat(QImage::Format_RGB32); - constexpr std::array<int, 7> scale_sizes{256, 128, 64, 48, 32, 24, 16}; - constexpr int bytes_per_pixel = 4; - - const IconDir icon_dir{ - .id_reserved = 0, - .id_type = 1, - .id_count = static_cast<WORD>(scale_sizes.size()), - }; - - Common::FS::IOFile icon_file(icon_path.string(), Common::FS::FileAccessMode::Write, - Common::FS::FileType::BinaryFile); - if (!icon_file.IsOpen()) { - return false; - } - - if (!icon_file.Write(icon_dir)) { - return false; - } - - std::size_t image_offset = sizeof(IconDir) + (sizeof(IconDirEntry) * scale_sizes.size()); - for (std::size_t i = 0; i < scale_sizes.size(); i++) { - const int image_size = scale_sizes[i] * scale_sizes[i] * bytes_per_pixel; - const IconDirEntry icon_entry{ - .width = static_cast<BYTE>(scale_sizes[i]), - .height = static_cast<BYTE>(scale_sizes[i]), - .color_count = 0, - .reserved = 0, - .planes = 1, - .bit_count = bytes_per_pixel * 8, - .bytes_in_res = static_cast<DWORD>(sizeof(BITMAPINFOHEADER) + image_size), - .image_offset = static_cast<DWORD>(image_offset), - }; - image_offset += icon_entry.bytes_in_res; - if (!icon_file.Write(icon_entry)) { - return false; - } - } - - for (std::size_t i = 0; i < scale_sizes.size(); i++) { - const QImage scaled_image = source_image.scaled( - scale_sizes[i], scale_sizes[i], Qt::IgnoreAspectRatio, Qt::SmoothTransformation); - const BITMAPINFOHEADER info_header{ - .biSize = sizeof(BITMAPINFOHEADER), - .biWidth = scaled_image.width(), - .biHeight = scaled_image.height() * 2, - .biPlanes = 1, - .biBitCount = bytes_per_pixel * 8, - .biCompression = BI_RGB, - .biSizeImage{}, - .biXPelsPerMeter{}, - .biYPelsPerMeter{}, - .biClrUsed{}, - .biClrImportant{}, - }; - - if (!icon_file.Write(info_header)) { - return false; - } - - for (int y = 0; y < scaled_image.height(); y++) { - const auto* line = scaled_image.scanLine(scaled_image.height() - 1 - y); - std::vector<u8> line_data(scaled_image.width() * bytes_per_pixel); - std::memcpy(line_data.data(), line, line_data.size()); - if (!icon_file.Write(line_data)) { - return false; - } - } - } - icon_file.Close(); - - return true; -#elif defined(__linux__) || defined(__FreeBSD__) - // Convert and write the icon as a PNG - if (!image.save(QString::fromStdString(icon_path.string()))) { - LOG_ERROR(Frontend, "Could not write icon as PNG to file"); - } else { - LOG_INFO(Frontend, "Wrote an icon to {}", icon_path.string()); - } - return true; -#else - return false; -#endif -} diff --git a/src/yuzu/util/util.h b/src/yuzu/util/util.h deleted file mode 100644 index 4094cf6c2..000000000 --- a/src/yuzu/util/util.h +++ /dev/null @@ -1,29 +0,0 @@ -// SPDX-FileCopyrightText: 2015 Citra Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include <filesystem> -#include <QFont> -#include <QString> - -/// Returns a QFont object appropriate to use as a monospace font for debugging widgets, etc. -[[nodiscard]] QFont GetMonospaceFont(); - -/// Convert a size in bytes into a readable format (KiB, MiB, etc.) -[[nodiscard]] QString ReadableByteSize(qulonglong size); - -/** - * Creates a circle pixmap from a specified color - * @param color The color the pixmap shall have - * @return QPixmap circle pixmap - */ -[[nodiscard]] QPixmap CreateCirclePixmapFromColor(const QColor& color); - -/** - * Saves a windows icon to a file - * @param path The icons path - * @param image The image to save - * @return bool If the operation succeeded - */ -[[nodiscard]] bool SaveIconToFile(const std::filesystem::path& icon_path, const QImage& image); diff --git a/src/yuzu/vk_device_info.cpp b/src/yuzu/vk_device_info.cpp deleted file mode 100644 index ab0d39c25..000000000 --- a/src/yuzu/vk_device_info.cpp +++ /dev/null @@ -1,67 +0,0 @@ -// SPDX-FileCopyrightText: 2023 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include <utility> -#include <vector> - -#include "yuzu/qt_common.h" - -#include "common/dynamic_library.h" -#include "common/logging/log.h" -#include "video_core/vulkan_common/vulkan_device.h" -#include "video_core/vulkan_common/vulkan_instance.h" -#include "video_core/vulkan_common/vulkan_library.h" -#include "video_core/vulkan_common/vulkan_surface.h" -#include "video_core/vulkan_common/vulkan_wrapper.h" -#include "vulkan/vulkan_core.h" -#include "yuzu/vk_device_info.h" - -class QWindow; - -namespace VkDeviceInfo { -Record::Record(std::string_view name_, const std::vector<VkPresentModeKHR>& vsync_modes_, - bool has_broken_compute_) - : name{name_}, vsync_support{vsync_modes_}, has_broken_compute{has_broken_compute_} {} - -Record::~Record() = default; - -void PopulateRecords(std::vector<Record>& records, QWindow* window) try { - using namespace Vulkan; - - // Create a test window with a Vulkan surface type for checking present modes. - QWindow test_window(window); - test_window.setSurfaceType(QWindow::VulkanSurface); - test_window.create(); - auto wsi = QtCommon::GetWindowSystemInfo(&test_window); - - vk::InstanceDispatch dld; - const auto library = OpenLibrary(); - const vk::Instance instance = CreateInstance(*library, dld, VK_API_VERSION_1_1, wsi.type); - const std::vector<VkPhysicalDevice> physical_devices = instance.EnumeratePhysicalDevices(); - vk::SurfaceKHR surface = CreateSurface(instance, wsi); - - records.clear(); - records.reserve(physical_devices.size()); - for (const VkPhysicalDevice device : physical_devices) { - const auto physical_device = vk::PhysicalDevice(device, dld); - const std::string name = physical_device.GetProperties().deviceName; - const std::vector<VkPresentModeKHR> present_modes = - physical_device.GetSurfacePresentModesKHR(*surface); - - VkPhysicalDeviceDriverProperties driver_properties{}; - driver_properties.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DRIVER_PROPERTIES; - driver_properties.pNext = nullptr; - VkPhysicalDeviceProperties2 properties{}; - properties.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2_KHR; - properties.pNext = &driver_properties; - dld.vkGetPhysicalDeviceProperties2(physical_device, &properties); - - bool has_broken_compute{Vulkan::Device::CheckBrokenCompute( - driver_properties.driverID, properties.properties.driverVersion)}; - - records.push_back(VkDeviceInfo::Record(name, present_modes, has_broken_compute)); - } -} catch (const Vulkan::vk::Exception& exception) { - LOG_ERROR(Frontend, "Failed to enumerate devices with error: {}", exception.what()); -} -} // namespace VkDeviceInfo diff --git a/src/yuzu/vk_device_info.h b/src/yuzu/vk_device_info.h deleted file mode 100644 index bda8262f4..000000000 --- a/src/yuzu/vk_device_info.h +++ /dev/null @@ -1,36 +0,0 @@ -// SPDX-FileCopyrightText: 2023 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include <algorithm> -#include <iterator> -#include <memory> -#include <string> -#include <string_view> -#include <vector> -#include "common/common_types.h" -#include "vulkan/vulkan_core.h" - -class QWindow; - -namespace Settings { -enum class VSyncMode : u32; -} -// #include "common/settings.h" - -namespace VkDeviceInfo { -// Short class to record Vulkan driver information for configuration purposes -class Record { -public: - explicit Record(std::string_view name, const std::vector<VkPresentModeKHR>& vsync_modes, - bool has_broken_compute); - ~Record(); - - const std::string name; - const std::vector<VkPresentModeKHR> vsync_support; - const bool has_broken_compute; -}; - -void PopulateRecords(std::vector<Record>& records, QWindow* window); -} // namespace VkDeviceInfo diff --git a/src/yuzu/yuzu.qrc b/src/yuzu/yuzu.qrc deleted file mode 100644 index 855df05fd..000000000 --- a/src/yuzu/yuzu.qrc +++ /dev/null @@ -1,10 +0,0 @@ -<!-- -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> - </qresource> -</RCC> diff --git a/src/yuzu/yuzu.rc b/src/yuzu/yuzu.rc deleted file mode 100644 index 1fc74d065..000000000 --- a/src/yuzu/yuzu.rc +++ /dev/null @@ -1,22 +0,0 @@ -// SPDX-FileCopyrightText: 2018 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include "winresrc.h" -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -// QT requires that the default application icon is named IDI_ICON1 - -IDI_ICON1 ICON "../../dist/yuzu.ico" - - -///////////////////////////////////////////////////////////////////////////// -// -// RT_MANIFEST -// - -0 RT_MANIFEST "../../dist/yuzu.manifest" |