mirror of
https://git.suyu.dev/suyu/suyu
synced 2025-11-04 17:09:02 -06:00
Revert "Merge branch 'master' into 'dev'"
This reverts merge request !17
This commit is contained in:
480
src/yuzu/CMakeLists.txt
Normal file
480
src/yuzu/CMakeLists.txt
Normal file
@@ -0,0 +1,480 @@
|
||||
# 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)
|
||||
48
src/yuzu/Info.plist
Normal file
48
src/yuzu/Info.plist
Normal file
@@ -0,0 +1,48 @@
|
||||
<?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>
|
||||
32
src/yuzu/about_dialog.cpp
Normal file
32
src/yuzu/about_dialog.cpp
Normal file
@@ -0,0 +1,32 @@
|
||||
// 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;
|
||||
22
src/yuzu/about_dialog.h
Normal file
22
src/yuzu/about_dialog.h
Normal file
@@ -0,0 +1,22 @@
|
||||
// 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;
|
||||
};
|
||||
184
src/yuzu/aboutdialog.ui
Normal file
184
src/yuzu/aboutdialog.ui
Normal file
@@ -0,0 +1,184 @@
|
||||
<?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>
|
||||
274
src/yuzu/applets/qt_amiibo_settings.cpp
Normal file
274
src/yuzu/applets/qt_amiibo_settings.cpp
Normal file
@@ -0,0 +1,274 @@
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
85
src/yuzu/applets/qt_amiibo_settings.h
Normal file
85
src/yuzu/applets/qt_amiibo_settings.h
Normal file
@@ -0,0 +1,85 @@
|
||||
// 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;
|
||||
};
|
||||
494
src/yuzu/applets/qt_amiibo_settings.ui
Normal file
494
src/yuzu/applets/qt_amiibo_settings.ui
Normal file
@@ -0,0 +1,494 @@
|
||||
<?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>
|
||||
778
src/yuzu/applets/qt_controller.cpp
Normal file
778
src/yuzu/applets/qt_controller.cpp
Normal file
@@ -0,0 +1,778 @@
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
183
src/yuzu/applets/qt_controller.h
Normal file
183
src/yuzu/applets/qt_controller.h
Normal file
@@ -0,0 +1,183 @@
|
||||
// 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;
|
||||
};
|
||||
2699
src/yuzu/applets/qt_controller.ui
Normal file
2699
src/yuzu/applets/qt_controller.ui
Normal file
File diff suppressed because it is too large
Load Diff
68
src/yuzu/applets/qt_error.cpp
Normal file
68
src/yuzu/applets/qt_error.cpp
Normal file
@@ -0,0 +1,68 @@
|
||||
// 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();
|
||||
}
|
||||
}
|
||||
34
src/yuzu/applets/qt_error.h
Normal file
34
src/yuzu/applets/qt_error.h
Normal file
@@ -0,0 +1,34 @@
|
||||
// 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;
|
||||
};
|
||||
260
src/yuzu/applets/qt_profile_select.cpp
Normal file
260
src/yuzu/applets/qt_profile_select.cpp
Normal file
@@ -0,0 +1,260 @@
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
87
src/yuzu/applets/qt_profile_select.h
Normal file
87
src/yuzu/applets/qt_profile_select.h
Normal file
@@ -0,0 +1,87 @@
|
||||
// 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;
|
||||
};
|
||||
1674
src/yuzu/applets/qt_software_keyboard.cpp
Normal file
1674
src/yuzu/applets/qt_software_keyboard.cpp
Normal file
File diff suppressed because it is too large
Load Diff
287
src/yuzu/applets/qt_software_keyboard.h
Normal file
287
src/yuzu/applets/qt_software_keyboard.h
Normal file
@@ -0,0 +1,287 @@
|
||||
// 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;
|
||||
};
|
||||
3541
src/yuzu/applets/qt_software_keyboard.ui
Normal file
3541
src/yuzu/applets/qt_software_keyboard.ui
Normal file
File diff suppressed because it is too large
Load Diff
449
src/yuzu/applets/qt_web_browser.cpp
Normal file
449
src/yuzu/applets/qt_web_browser.cpp
Normal file
@@ -0,0 +1,449 @@
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
220
src/yuzu/applets/qt_web_browser.h
Normal file
220
src/yuzu/applets/qt_web_browser.h
Normal file
@@ -0,0 +1,220 @@
|
||||
// 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;
|
||||
};
|
||||
198
src/yuzu/applets/qt_web_browser_scripts.h
Normal file
198
src/yuzu/applets/qt_web_browser_scripts.h
Normal file
@@ -0,0 +1,198 @@
|
||||
// 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();
|
||||
})();
|
||||
)";
|
||||
1140
src/yuzu/bootmanager.cpp
Normal file
1140
src/yuzu/bootmanager.cpp
Normal file
File diff suppressed because it is too large
Load Diff
280
src/yuzu/bootmanager.h
Normal file
280
src/yuzu/bootmanager.h
Normal file
@@ -0,0 +1,280 @@
|
||||
// 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;
|
||||
};
|
||||
77
src/yuzu/breakpad.cpp
Normal file
77
src/yuzu/breakpad.cpp
Normal file
@@ -0,0 +1,77 @@
|
||||
// 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
|
||||
10
src/yuzu/breakpad.h
Normal file
10
src/yuzu/breakpad.h
Normal file
@@ -0,0 +1,10 @@
|
||||
// SPDX-FileCopyrightText: 2023 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace Breakpad {
|
||||
|
||||
void InstallCrashHandler();
|
||||
|
||||
}
|
||||
210
src/yuzu/compatdb.cpp
Normal file
210
src/yuzu/compatdb.cpp
Normal file
@@ -0,0 +1,210 @@
|
||||
// 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);
|
||||
}
|
||||
43
src/yuzu/compatdb.h
Normal file
43
src/yuzu/compatdb.h
Normal file
@@ -0,0 +1,43 @@
|
||||
// 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;
|
||||
};
|
||||
398
src/yuzu/compatdb.ui
Normal file
398
src/yuzu/compatdb.ui
Normal file
@@ -0,0 +1,398 @@
|
||||
<?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>
|
||||
17
src/yuzu/compatibility_list.cpp
Normal file
17
src/yuzu/compatibility_list.cpp
Normal file
@@ -0,0 +1,17 @@
|
||||
// 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;
|
||||
});
|
||||
}
|
||||
16
src/yuzu/compatibility_list.h
Normal file
16
src/yuzu/compatibility_list.h
Normal file
@@ -0,0 +1,16 @@
|
||||
// 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);
|
||||
19
src/yuzu/configuration/configuration_shared.cpp
Normal file
19
src/yuzu/configuration/configuration_shared.cpp
Normal file
@@ -0,0 +1,19 @@
|
||||
// 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
|
||||
27
src/yuzu/configuration/configuration_shared.h
Normal file
27
src/yuzu/configuration/configuration_shared.h
Normal file
@@ -0,0 +1,27 @@
|
||||
// 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
|
||||
117
src/yuzu/configuration/configure.ui
Normal file
117
src/yuzu/configuration/configure.ui
Normal file
@@ -0,0 +1,117 @@
|
||||
<?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>
|
||||
84
src/yuzu/configuration/configure_applets.cpp
Normal file
84
src/yuzu/configuration/configure_applets.cpp
Normal file
@@ -0,0 +1,84 @@
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
48
src/yuzu/configuration/configure_applets.h
Normal file
48
src/yuzu/configuration/configure_applets.h
Normal file
@@ -0,0 +1,48 @@
|
||||
// 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;
|
||||
};
|
||||
65
src/yuzu/configuration/configure_applets.ui
Normal file
65
src/yuzu/configuration/configure_applets.ui
Normal file
@@ -0,0 +1,65 @@
|
||||
<?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>
|
||||
278
src/yuzu/configuration/configure_audio.cpp
Normal file
278
src/yuzu/configuration/configure_audio.cpp
Normal file
@@ -0,0 +1,278 @@
|
||||
// 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);
|
||||
}
|
||||
66
src/yuzu/configuration/configure_audio.h
Normal file
66
src/yuzu/configuration/configure_audio.h
Normal file
@@ -0,0 +1,66 @@
|
||||
// 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;
|
||||
};
|
||||
67
src/yuzu/configuration/configure_audio.ui
Normal file
67
src/yuzu/configuration/configure_audio.ui
Normal file
@@ -0,0 +1,67 @@
|
||||
<?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>
|
||||
163
src/yuzu/configuration/configure_camera.cpp
Normal file
163
src/yuzu/configuration/configure_camera.cpp
Normal file
@@ -0,0 +1,163 @@
|
||||
// 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);
|
||||
}
|
||||
56
src/yuzu/configuration/configure_camera.h
Normal file
56
src/yuzu/configuration/configure_camera.h
Normal file
@@ -0,0 +1,56 @@
|
||||
// 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;
|
||||
};
|
||||
170
src/yuzu/configuration/configure_camera.ui
Normal file
170
src/yuzu/configuration/configure_camera.ui
Normal file
@@ -0,0 +1,170 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ConfigureCamera</class>
|
||||
<widget class="QDialog" name="ConfigureCamera">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>298</width>
|
||||
<height>339</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Configure Infrared Camera</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>280</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Select where the image of the emulated camera comes from. It may be a virtual camera or a real camera.</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="gridGroupBox">
|
||||
<property name="title">
|
||||
<string>Camera Image Source:</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Input device:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QComboBox" name="ir_sensor_combo_box"/>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item><item>
|
||||
<widget class="QGroupBox" name="previewBox">
|
||||
<property name="title">
|
||||
<string>Preview</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QLabel" name="preview_box">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>320</width>
|
||||
<height>240</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Resolution: 320*240</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="preview_button">
|
||||
<property name="text">
|
||||
<string>Click to preview</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QPushButton" name="restore_defaults_button">
|
||||
<property name="text">
|
||||
<string>Restore Defaults</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>ConfigureCamera</receiver>
|
||||
<slot>accept()</slot>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>ConfigureCamera</receiver>
|
||||
<slot>reject()</slot>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
114
src/yuzu/configuration/configure_cpu.cpp
Normal file
114
src/yuzu/configuration/configure_cpu.cpp
Normal file
@@ -0,0 +1,114 @@
|
||||
// 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);
|
||||
}
|
||||
55
src/yuzu/configuration/configure_cpu.h
Normal file
55
src/yuzu/configuration/configure_cpu.h
Normal file
@@ -0,0 +1,55 @@
|
||||
// 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;
|
||||
};
|
||||
151
src/yuzu/configuration/configure_cpu.ui
Normal file
151
src/yuzu/configuration/configure_cpu.ui
Normal file
@@ -0,0 +1,151 @@
|
||||
<?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>
|
||||
78
src/yuzu/configuration/configure_cpu_debug.cpp
Normal file
78
src/yuzu/configuration/configure_cpu_debug.cpp
Normal file
@@ -0,0 +1,78 @@
|
||||
// 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);
|
||||
}
|
||||
35
src/yuzu/configuration/configure_cpu_debug.h
Normal file
35
src/yuzu/configuration/configure_cpu_debug.h
Normal file
@@ -0,0 +1,35 @@
|
||||
// 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;
|
||||
};
|
||||
223
src/yuzu/configuration/configure_cpu_debug.ui
Normal file
223
src/yuzu/configuration/configure_cpu_debug.ui
Normal file
@@ -0,0 +1,223 @@
|
||||
<?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>
|
||||
130
src/yuzu/configuration/configure_debug.cpp
Normal file
130
src/yuzu/configuration/configure_debug.cpp
Normal file
@@ -0,0 +1,130 @@
|
||||
// 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);
|
||||
}
|
||||
37
src/yuzu/configuration/configure_debug.h
Normal file
37
src/yuzu/configuration/configure_debug.h
Normal file
@@ -0,0 +1,37 @@
|
||||
// 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};
|
||||
};
|
||||
576
src/yuzu/configuration/configure_debug.ui
Normal file
576
src/yuzu/configuration/configure_debug.ui
Normal file
@@ -0,0 +1,576 @@
|
||||
<?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>
|
||||
44
src/yuzu/configuration/configure_debug_controller.cpp
Normal file
44
src/yuzu/configuration/configure_debug_controller.cpp
Normal file
@@ -0,0 +1,44 @@
|
||||
// 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);
|
||||
}
|
||||
45
src/yuzu/configuration/configure_debug_controller.h
Normal file
45
src/yuzu/configuration/configure_debug_controller.h
Normal file
@@ -0,0 +1,45 @@
|
||||
// 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;
|
||||
};
|
||||
77
src/yuzu/configuration/configure_debug_controller.ui
Normal file
77
src/yuzu/configuration/configure_debug_controller.ui
Normal file
@@ -0,0 +1,77 @@
|
||||
<?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>
|
||||
45
src/yuzu/configuration/configure_debug_tab.cpp
Normal file
45
src/yuzu/configuration/configure_debug_tab.cpp
Normal file
@@ -0,0 +1,45 @@
|
||||
// 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() {}
|
||||
41
src/yuzu/configuration/configure_debug_tab.h
Normal file
41
src/yuzu/configuration/configure_debug_tab.h
Normal file
@@ -0,0 +1,41 @@
|
||||
// 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;
|
||||
};
|
||||
31
src/yuzu/configuration/configure_debug_tab.ui
Normal file
31
src/yuzu/configuration/configure_debug_tab.ui
Normal file
@@ -0,0 +1,31 @@
|
||||
<?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>
|
||||
213
src/yuzu/configuration/configure_dialog.cpp
Normal file
213
src/yuzu/configuration/configure_dialog.cpp
Normal file
@@ -0,0 +1,213 @@
|
||||
// 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());
|
||||
}
|
||||
}
|
||||
94
src/yuzu/configuration/configure_dialog.h
Normal file
94
src/yuzu/configuration/configure_dialog.h
Normal file
@@ -0,0 +1,94 @@
|
||||
// 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;
|
||||
};
|
||||
155
src/yuzu/configuration/configure_filesystem.cpp
Normal file
155
src/yuzu/configuration/configure_filesystem.cpp
Normal file
@@ -0,0 +1,155 @@
|
||||
// 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);
|
||||
}
|
||||
43
src/yuzu/configuration/configure_filesystem.h
Normal file
43
src/yuzu/configuration/configure_filesystem.h
Normal file
@@ -0,0 +1,43 @@
|
||||
// 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;
|
||||
};
|
||||
244
src/yuzu/configuration/configure_filesystem.ui
Normal file
244
src/yuzu/configuration/configure_filesystem.ui
Normal file
@@ -0,0 +1,244 @@
|
||||
<?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>
|
||||
128
src/yuzu/configuration/configure_general.cpp
Normal file
128
src/yuzu/configuration/configure_general.cpp
Normal file
@@ -0,0 +1,128 @@
|
||||
// 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);
|
||||
}
|
||||
55
src/yuzu/configuration/configure_general.h
Normal file
55
src/yuzu/configuration/configure_general.h
Normal file
@@ -0,0 +1,55 @@
|
||||
// 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;
|
||||
};
|
||||
134
src/yuzu/configuration/configure_general.ui
Normal file
134
src/yuzu/configuration/configure_general.ui
Normal file
@@ -0,0 +1,134 @@
|
||||
<?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>
|
||||
552
src/yuzu/configuration/configure_graphics.cpp
Normal file
552
src/yuzu/configuration/configure_graphics.cpp
Normal file
@@ -0,0 +1,552 @@
|
||||
// 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;
|
||||
}
|
||||
116
src/yuzu/configuration/configure_graphics.h
Normal file
116
src/yuzu/configuration/configure_graphics.h
Normal file
@@ -0,0 +1,116 @@
|
||||
// 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;
|
||||
};
|
||||
151
src/yuzu/configuration/configure_graphics.ui
Normal file
151
src/yuzu/configuration/configure_graphics.ui
Normal file
@@ -0,0 +1,151 @@
|
||||
<?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>
|
||||
82
src/yuzu/configuration/configure_graphics_advanced.cpp
Normal file
82
src/yuzu/configuration/configure_graphics_advanced.cpp
Normal file
@@ -0,0 +1,82 @@
|
||||
// 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);
|
||||
}
|
||||
49
src/yuzu/configuration/configure_graphics_advanced.h
Normal file
49
src/yuzu/configuration/configure_graphics_advanced.h
Normal file
@@ -0,0 +1,49 @@
|
||||
// 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{};
|
||||
};
|
||||
68
src/yuzu/configuration/configure_graphics_advanced.ui
Normal file
68
src/yuzu/configuration/configure_graphics_advanced.ui
Normal file
@@ -0,0 +1,68 @@
|
||||
<?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>
|
||||
423
src/yuzu/configuration/configure_hotkeys.cpp
Normal file
423
src/yuzu/configuration/configure_hotkeys.cpp
Normal file
@@ -0,0 +1,423 @@
|
||||
// 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));
|
||||
}
|
||||
}
|
||||
74
src/yuzu/configuration/configure_hotkeys.h
Normal file
74
src/yuzu/configuration/configure_hotkeys.h
Normal file
@@ -0,0 +1,74 @@
|
||||
// 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;
|
||||
};
|
||||
76
src/yuzu/configuration/configure_hotkeys.ui
Normal file
76
src/yuzu/configuration/configure_hotkeys.ui
Normal file
@@ -0,0 +1,76 @@
|
||||
<?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>
|
||||
309
src/yuzu/configuration/configure_input.cpp
Normal file
309
src/yuzu/configuration/configure_input.cpp
Normal file
@@ -0,0 +1,309 @@
|
||||
// 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();
|
||||
}
|
||||
}
|
||||
81
src/yuzu/configuration/configure_input.h
Normal file
81
src/yuzu/configuration/configure_input.h
Normal file
@@ -0,0 +1,81 @@
|
||||
// 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;
|
||||
};
|
||||
548
src/yuzu/configuration/configure_input.ui
Normal file
548
src/yuzu/configuration/configure_input.ui
Normal file
@@ -0,0 +1,548 @@
|
||||
<?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>
|
||||
204
src/yuzu/configuration/configure_input_advanced.cpp
Normal file
204
src/yuzu/configuration/configure_input_advanced.cpp
Normal file
@@ -0,0 +1,204 @@
|
||||
// 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
|
||||
}
|
||||
53
src/yuzu/configuration/configure_input_advanced.h
Normal file
53
src/yuzu/configuration/configure_input_advanced.h
Normal file
@@ -0,0 +1,53 @@
|
||||
// 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;
|
||||
};
|
||||
2821
src/yuzu/configuration/configure_input_advanced.ui
Normal file
2821
src/yuzu/configuration/configure_input_advanced.ui
Normal file
File diff suppressed because it is too large
Load Diff
115
src/yuzu/configuration/configure_input_per_game.cpp
Normal file
115
src/yuzu/configuration/configure_input_per_game.cpp
Normal file
@@ -0,0 +1,115 @@
|
||||
// SPDX-FileCopyrightText: 2022 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include "common/settings.h"
|
||||
#include "core/core.h"
|
||||
#include "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);
|
||||
}
|
||||
}
|
||||
46
src/yuzu/configuration/configure_input_per_game.h
Normal file
46
src/yuzu/configuration/configure_input_per_game.h
Normal file
@@ -0,0 +1,46 @@
|
||||
// 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;
|
||||
};
|
||||
333
src/yuzu/configuration/configure_input_per_game.ui
Normal file
333
src/yuzu/configuration/configure_input_per_game.ui
Normal file
@@ -0,0 +1,333 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ConfigureInputPerGame</class>
|
||||
<widget class="QWidget" name="PerGameInput">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>541</width>
|
||||
<height>759</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<property name="accessibleName">
|
||||
<string>Graphics</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_1">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Input Profiles</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<item>
|
||||
<widget class="QWidget" name="player_1" native="true">
|
||||
<layout class="QHBoxLayout" name="input_profile_layout_1">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_player_1">
|
||||
<property name="text">
|
||||
<string>Player 1 Profile</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="profile_player_1">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="player_2" native="true">
|
||||
<layout class="QHBoxLayout" name="input_profile_layout_2">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_player_2">
|
||||
<property name="text">
|
||||
<string>Player 2 Profile</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="profile_player_2">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="player_3" native="true">
|
||||
<layout class="QHBoxLayout" name="input_profile_layout_3">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_player_3">
|
||||
<property name="text">
|
||||
<string>Player 3 Profile</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="profile_player_3">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="player_4" native="true">
|
||||
<layout class="QHBoxLayout" name="input_profile_layout_4">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_player_4">
|
||||
<property name="text">
|
||||
<string>Player 4 Profile</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="profile_player_4">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="player_5" native="true">
|
||||
<layout class="QHBoxLayout" name="input_profile_layout_5">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_player_5">
|
||||
<property name="text">
|
||||
<string>Player 5 Profile</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="profile_player_5">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="player_6" native="true">
|
||||
<layout class="QHBoxLayout" name="input_profile_layout_6">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_player_6">
|
||||
<property name="text">
|
||||
<string>Player 6 Profile</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="profile_player_6">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="player_7" native="true">
|
||||
<layout class="QHBoxLayout" name="input_profile_layout_7">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_player_7">
|
||||
<property name="text">
|
||||
<string>Player 7 Profile</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="profile_player_7">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="player_8" native="true">
|
||||
<layout class="QHBoxLayout" name="input_profile_layout_8">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_player_8">
|
||||
<property name="text">
|
||||
<string>Player 8 Profile</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="profile_player_8">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
1670
src/yuzu/configuration/configure_input_player.cpp
Normal file
1670
src/yuzu/configuration/configure_input_player.cpp
Normal file
File diff suppressed because it is too large
Load Diff
228
src/yuzu/configuration/configure_input_player.h
Normal file
228
src/yuzu/configuration/configure_input_player.h
Normal file
@@ -0,0 +1,228 @@
|
||||
// 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;
|
||||
};
|
||||
3323
src/yuzu/configuration/configure_input_player.ui
Normal file
3323
src/yuzu/configuration/configure_input_player.ui
Normal file
File diff suppressed because it is too large
Load Diff
3007
src/yuzu/configuration/configure_input_player_widget.cpp
Normal file
3007
src/yuzu/configuration/configure_input_player_widget.cpp
Normal file
File diff suppressed because it is too large
Load Diff
230
src/yuzu/configuration/configure_input_player_widget.h
Normal file
230
src/yuzu/configuration/configure_input_player_widget.h
Normal file
@@ -0,0 +1,230 @@
|
||||
// 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{};
|
||||
};
|
||||
39
src/yuzu/configuration/configure_input_profile_dialog.cpp
Normal file
39
src/yuzu/configuration/configure_input_profile_dialog.cpp
Normal file
@@ -0,0 +1,39 @@
|
||||
// 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);
|
||||
}
|
||||
43
src/yuzu/configuration/configure_input_profile_dialog.h
Normal file
43
src/yuzu/configuration/configure_input_profile_dialog.h
Normal file
@@ -0,0 +1,43 @@
|
||||
// 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;
|
||||
};
|
||||
71
src/yuzu/configuration/configure_input_profile_dialog.ui
Normal file
71
src/yuzu/configuration/configure_input_profile_dialog.ui
Normal file
@@ -0,0 +1,71 @@
|
||||
<?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>
|
||||
75
src/yuzu/configuration/configure_linux_tab.cpp
Normal file
75
src/yuzu/configuration/configure_linux_tab.cpp
Normal file
@@ -0,0 +1,75 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include "common/settings.h"
|
||||
#include "core/core.h"
|
||||
#include "ui_configure_linux_tab.h"
|
||||
#include "yuzu/configuration/configuration_shared.h"
|
||||
#include "yuzu/configuration/configure_linux_tab.h"
|
||||
#include "yuzu/configuration/shared_widget.h"
|
||||
|
||||
ConfigureLinuxTab::ConfigureLinuxTab(const Core::System& system_,
|
||||
std::shared_ptr<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);
|
||||
}
|
||||
44
src/yuzu/configuration/configure_linux_tab.h
Normal file
44
src/yuzu/configuration/configure_linux_tab.h
Normal file
@@ -0,0 +1,44 @@
|
||||
// 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{};
|
||||
};
|
||||
53
src/yuzu/configuration/configure_linux_tab.ui
Normal file
53
src/yuzu/configuration/configure_linux_tab.ui
Normal file
@@ -0,0 +1,53 @@
|
||||
<?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>
|
||||
326
src/yuzu/configuration/configure_motion_touch.cpp
Normal file
326
src/yuzu/configuration/configure_motion_touch.cpp
Normal file
@@ -0,0 +1,326 @@
|
||||
// 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();
|
||||
}
|
||||
93
src/yuzu/configuration/configure_motion_touch.h
Normal file
93
src/yuzu/configuration/configure_motion_touch.h
Normal file
@@ -0,0 +1,93 @@
|
||||
// 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;
|
||||
};
|
||||
297
src/yuzu/configuration/configure_motion_touch.ui
Normal file
297
src/yuzu/configuration/configure_motion_touch.ui
Normal file
@@ -0,0 +1,297 @@
|
||||
<?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>
|
||||
90
src/yuzu/configuration/configure_mouse_panning.cpp
Normal file
90
src/yuzu/configuration/configure_mouse_panning.cpp
Normal file
@@ -0,0 +1,90 @@
|
||||
// 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();
|
||||
}
|
||||
36
src/yuzu/configuration/configure_mouse_panning.h
Normal file
36
src/yuzu/configuration/configure_mouse_panning.h
Normal file
@@ -0,0 +1,36 @@
|
||||
// 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;
|
||||
};
|
||||
212
src/yuzu/configuration/configure_mouse_panning.ui
Normal file
212
src/yuzu/configuration/configure_mouse_panning.ui
Normal file
@@ -0,0 +1,212 @@
|
||||
<?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>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user