summaryrefslogtreecommitdiff
path: root/src/yuzu
diff options
context:
space:
mode:
Diffstat (limited to 'src/yuzu')
-rw-r--r--src/yuzu/CMakeLists.txt11
-rw-r--r--src/yuzu/bootmanager.cpp6
-rw-r--r--src/yuzu/bootmanager.h1
-rw-r--r--src/yuzu/configuration/configure_graphics.cpp2
-rw-r--r--src/yuzu/main.cpp21
-rw-r--r--src/yuzu/main.h2
-rw-r--r--src/yuzu/multiplayer/chat_room.h1
-rw-r--r--src/yuzu/precompiled_headers.h6
-rw-r--r--src/yuzu/startup_checks.cpp84
-rw-r--r--src/yuzu/startup_checks.h4
10 files changed, 110 insertions, 28 deletions
diff --git a/src/yuzu/CMakeLists.txt b/src/yuzu/CMakeLists.txt
index 0aa109dd3..656dd79a9 100644
--- a/src/yuzu/CMakeLists.txt
+++ b/src/yuzu/CMakeLists.txt
@@ -186,6 +186,7 @@ add_executable(yuzu
multiplayer/state.cpp
multiplayer/state.h
multiplayer/validation.h
+ precompiled_headers.h
startup_checks.cpp
startup_checks.h
uisettings.cpp
@@ -387,7 +388,11 @@ if (YUZU_USE_BUNDLED_QT AND QT_VERSION VERSION_LESS 6)
endif()
if (ENABLE_SDL2)
- target_link_libraries(yuzu PRIVATE SDL2)
+ if (YUZU_USE_EXTERNAL_SDL2)
+ target_link_libraries(yuzu PRIVATE SDL2-static)
+ else()
+ target_link_libraries(yuzu PRIVATE SDL2)
+ endif()
target_compile_definitions(yuzu PRIVATE HAVE_SDL2)
endif()
@@ -405,3 +410,7 @@ endif()
if (ARCHITECTURE_x86_64 OR ARCHITECTURE_arm64)
target_link_libraries(yuzu PRIVATE dynarmic)
endif()
+
+if (YUZU_USE_PRECOMPILED_HEADERS)
+ target_precompile_headers(yuzu PRIVATE precompiled_headers.h)
+endif()
diff --git a/src/yuzu/bootmanager.cpp b/src/yuzu/bootmanager.cpp
index f140e951f..5b5b6fed8 100644
--- a/src/yuzu/bootmanager.cpp
+++ b/src/yuzu/bootmanager.cpp
@@ -118,7 +118,7 @@ void EmuThread::run() {
}
} else {
std::unique_lock lock{running_mutex};
- running_cv.wait(lock, stop_token, [this] { return IsRunning(); });
+ Common::CondvarWait(running_cv, lock, stop_token, [&] { return IsRunning(); });
}
}
@@ -269,6 +269,10 @@ static Core::Frontend::WindowSystemType GetWindowSystemType() {
return Core::Frontend::WindowSystemType::X11;
else if (platform_name == QStringLiteral("wayland"))
return Core::Frontend::WindowSystemType::Wayland;
+ else if (platform_name == QStringLiteral("cocoa"))
+ return Core::Frontend::WindowSystemType::Cocoa;
+ else if (platform_name == QStringLiteral("android"))
+ return Core::Frontend::WindowSystemType::Android;
LOG_CRITICAL(Frontend, "Unknown Qt platform!");
return Core::Frontend::WindowSystemType::Windows;
diff --git a/src/yuzu/bootmanager.h b/src/yuzu/bootmanager.h
index 2e19a879e..f4deae4ee 100644
--- a/src/yuzu/bootmanager.h
+++ b/src/yuzu/bootmanager.h
@@ -14,6 +14,7 @@
#include <QTouchEvent>
#include <QWidget>
+#include "common/polyfill_thread.h"
#include "common/thread.h"
#include "core/frontend/emu_window.h"
diff --git a/src/yuzu/configuration/configure_graphics.cpp b/src/yuzu/configuration/configure_graphics.cpp
index 4a875f86a..8ca683966 100644
--- a/src/yuzu/configuration/configure_graphics.cpp
+++ b/src/yuzu/configuration/configure_graphics.cpp
@@ -365,7 +365,7 @@ void ConfigureGraphics::RetrieveVulkanDevices() try {
vk::InstanceDispatch dld;
const Common::DynamicLibrary library = OpenLibrary();
- const vk::Instance instance = CreateInstance(library, dld, VK_API_VERSION_1_0);
+ const vk::Instance instance = CreateInstance(library, dld, VK_API_VERSION_1_1);
const std::vector<VkPhysicalDevice> physical_devices = instance.EnumeratePhysicalDevices();
vulkan_devices.clear();
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp
index be13024c6..e06ee7570 100644
--- a/src/yuzu/main.cpp
+++ b/src/yuzu/main.cpp
@@ -167,6 +167,7 @@ __declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;
constexpr int default_mouse_hide_timeout = 2500;
constexpr int default_mouse_center_timeout = 10;
+constexpr int default_input_update_timeout = 1;
/**
* "Callouts" are one-time instructional messages shown to the user. In the config settings, there
@@ -405,6 +406,10 @@ GMainWindow::GMainWindow(std::unique_ptr<Config> config_, bool has_broken_vulkan
mouse_center_timer.setInterval(default_mouse_center_timeout);
connect(&mouse_center_timer, &QTimer::timeout, this, &GMainWindow::CenterMouseCursor);
+ update_input_timer.setInterval(default_input_update_timeout);
+ connect(&update_input_timer, &QTimer::timeout, this, &GMainWindow::UpdateInputDrivers);
+ update_input_timer.start();
+
MigrateConfigFiles();
if (has_broken_vulkan) {
@@ -2827,6 +2832,7 @@ void GMainWindow::ErrorDisplayDisplayError(QString error_code, QString error_tex
}
void GMainWindow::OnMenuReportCompatibility() {
+#if defined(ARCHITECTURE_x86_64) && !defined(__APPLE__)
const auto& caps = Common::GetCPUCaps();
const bool has_fma = caps.fma || caps.fma4;
const auto processor_count = std::thread::hardware_concurrency();
@@ -2853,6 +2859,11 @@ void GMainWindow::OnMenuReportCompatibility() {
"&gt; "
"Web."));
}
+#else
+ QMessageBox::critical(this, tr("Hardware requirements not met"),
+ tr("Your system does not meet the recommended hardware requirements. "
+ "Compatibility reporting has been disabled."));
+#endif
}
void GMainWindow::OpenURL(const QUrl& url) {
@@ -3647,6 +3658,13 @@ void GMainWindow::UpdateUISettings() {
UISettings::values.first_start = false;
}
+void GMainWindow::UpdateInputDrivers() {
+ if (!input_subsystem) {
+ return;
+ }
+ input_subsystem->PumpEvents();
+}
+
void GMainWindow::HideMouseCursor() {
if (emu_thread == nullptr && UISettings::values.hide_mouse) {
mouse_hide_timer.stop();
@@ -4047,7 +4065,6 @@ void GMainWindow::UpdateUITheme() {
const QString default_theme =
QString::fromUtf8(UISettings::themes[static_cast<size_t>(Config::default_theme)].second);
QString current_theme = UISettings::values.theme;
- QStringList theme_paths(default_theme_paths);
if (current_theme.isEmpty()) {
current_theme = default_theme;
@@ -4060,7 +4077,7 @@ void GMainWindow::UpdateUITheme() {
if (current_theme == QStringLiteral("default") || current_theme == QStringLiteral("colorful")) {
QIcon::setThemeName(current_theme == QStringLiteral("colorful") ? current_theme
: startup_icon_theme);
- QIcon::setThemeSearchPaths(theme_paths);
+ QIcon::setThemeSearchPaths(QStringList(default_theme_paths));
if (CheckDarkMode()) {
current_theme = QStringLiteral("default_dark");
}
diff --git a/src/yuzu/main.h b/src/yuzu/main.h
index af6fcec3c..62d629973 100644
--- a/src/yuzu/main.h
+++ b/src/yuzu/main.h
@@ -355,6 +355,7 @@ private:
void UpdateGPUAccuracyButton();
void UpdateStatusButtons();
void UpdateUISettings();
+ void UpdateInputDrivers();
void HideMouseCursor();
void ShowMouseCursor();
void CenterMouseCursor();
@@ -406,6 +407,7 @@ private:
bool auto_muted = false;
QTimer mouse_hide_timer;
QTimer mouse_center_timer;
+ QTimer update_input_timer;
QString startup_icon_theme;
bool os_dark_mode = false;
diff --git a/src/yuzu/multiplayer/chat_room.h b/src/yuzu/multiplayer/chat_room.h
index 01c70fad0..dd71ea4cd 100644
--- a/src/yuzu/multiplayer/chat_room.h
+++ b/src/yuzu/multiplayer/chat_room.h
@@ -4,6 +4,7 @@
#pragma once
#include <memory>
+#include <unordered_map>
#include <unordered_set>
#include <QDialog>
#include <QSortFilterProxyModel>
diff --git a/src/yuzu/precompiled_headers.h b/src/yuzu/precompiled_headers.h
new file mode 100644
index 000000000..aabae730b
--- /dev/null
+++ b/src/yuzu/precompiled_headers.h
@@ -0,0 +1,6 @@
+// SPDX-FileCopyrightText: 2022 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+#include "common/common_precompiled_headers.h"
diff --git a/src/yuzu/startup_checks.cpp b/src/yuzu/startup_checks.cpp
index 6a91212e2..563818362 100644
--- a/src/yuzu/startup_checks.cpp
+++ b/src/yuzu/startup_checks.cpp
@@ -4,16 +4,19 @@
#include "video_core/vulkan_common/vulkan_wrapper.h"
#ifdef _WIN32
-#include <cstring> // for memset, strncpy
+#include <cstring>
#include <processthreadsapi.h>
#include <windows.h>
#elif defined(YUZU_UNIX)
+#include <cstring>
#include <errno.h>
+#include <spawn.h>
+#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#endif
-#include <cstdio>
+#include <fmt/core.h>
#include "video_core/vulkan_common/vulkan_instance.h"
#include "video_core/vulkan_common/vulkan_library.h"
#include "yuzu/startup_checks.h"
@@ -24,10 +27,10 @@ void CheckVulkan() {
Vulkan::vk::InstanceDispatch dld;
const Common::DynamicLibrary library = Vulkan::OpenLibrary();
const Vulkan::vk::Instance instance =
- Vulkan::CreateInstance(library, dld, VK_API_VERSION_1_0);
+ Vulkan::CreateInstance(library, dld, VK_API_VERSION_1_1);
} catch (const Vulkan::vk::Exception& exception) {
- std::fprintf(stderr, "Failed to initialize Vulkan: %s\n", exception.what());
+ fmt::print(stderr, "Failed to initialize Vulkan: {}\n", exception.what());
}
}
@@ -49,8 +52,15 @@ bool CheckEnvVars(bool* is_child) {
*is_child = true;
return false;
} else if (!SetEnvironmentVariableA(IS_CHILD_ENV_VAR, ENV_VAR_ENABLED_TEXT)) {
- std::fprintf(stderr, "SetEnvironmentVariableA failed to set %s with error %lu\n",
- IS_CHILD_ENV_VAR, GetLastError());
+ fmt::print(stderr, "SetEnvironmentVariableA failed to set {} with error {}\n",
+ IS_CHILD_ENV_VAR, GetLastError());
+ return true;
+ }
+#elif defined(YUZU_UNIX)
+ const char* startup_check_var = getenv(STARTUP_CHECK_ENV_VAR);
+ if (startup_check_var != nullptr &&
+ std::strncmp(startup_check_var, ENV_VAR_ENABLED_TEXT, 8) == 0) {
+ CheckVulkan();
return true;
}
#endif
@@ -62,8 +72,8 @@ bool StartupChecks(const char* arg0, bool* has_broken_vulkan, bool perform_vulka
// Set the startup variable for child processes
const bool env_var_set = SetEnvironmentVariableA(STARTUP_CHECK_ENV_VAR, ENV_VAR_ENABLED_TEXT);
if (!env_var_set) {
- std::fprintf(stderr, "SetEnvironmentVariableA failed to set %s with error %lu\n",
- STARTUP_CHECK_ENV_VAR, GetLastError());
+ fmt::print(stderr, "SetEnvironmentVariableA failed to set {} with error {}\n",
+ STARTUP_CHECK_ENV_VAR, GetLastError());
return false;
}
@@ -81,48 +91,57 @@ bool StartupChecks(const char* arg0, bool* has_broken_vulkan, bool perform_vulka
DWORD exit_code = STILL_ACTIVE;
const int err = GetExitCodeProcess(process_info.hProcess, &exit_code);
if (err == 0) {
- std::fprintf(stderr, "GetExitCodeProcess failed with error %lu\n", GetLastError());
+ fmt::print(stderr, "GetExitCodeProcess failed with error {}\n", GetLastError());
}
// Vulkan is broken if the child crashed (return value is not zero)
*has_broken_vulkan = (exit_code != 0);
if (CloseHandle(process_info.hProcess) == 0) {
- std::fprintf(stderr, "CloseHandle failed with error %lu\n", GetLastError());
+ fmt::print(stderr, "CloseHandle failed with error {}\n", GetLastError());
}
if (CloseHandle(process_info.hThread) == 0) {
- std::fprintf(stderr, "CloseHandle failed with error %lu\n", GetLastError());
+ fmt::print(stderr, "CloseHandle failed with error {}\n", GetLastError());
}
}
if (!SetEnvironmentVariableA(STARTUP_CHECK_ENV_VAR, nullptr)) {
- std::fprintf(stderr, "SetEnvironmentVariableA failed to clear %s with error %lu\n",
- STARTUP_CHECK_ENV_VAR, GetLastError());
+ fmt::print(stderr, "SetEnvironmentVariableA failed to clear {} with error {}\n",
+ STARTUP_CHECK_ENV_VAR, GetLastError());
}
#elif defined(YUZU_UNIX)
+ const int env_var_set = setenv(STARTUP_CHECK_ENV_VAR, ENV_VAR_ENABLED_TEXT, 1);
+ if (env_var_set == -1) {
+ const int err = errno;
+ fmt::print(stderr, "setenv failed to set {} with error {}\n", STARTUP_CHECK_ENV_VAR, err);
+ return false;
+ }
+
if (perform_vulkan_check) {
- const pid_t pid = fork();
- if (pid == 0) {
- CheckVulkan();
- return true;
- } else if (pid == -1) {
- const int err = errno;
- std::fprintf(stderr, "fork failed with error %d\n", err);
+ const pid_t pid = SpawnChild(arg0);
+ if (pid == -1) {
return false;
}
// Get exit code from child process
int status;
- const int r_val = wait(&status);
+ const int r_val = waitpid(pid, &status, 0);
if (r_val == -1) {
const int err = errno;
- std::fprintf(stderr, "wait failed with error %d\n", err);
+ fmt::print(stderr, "wait failed with error {}\n", err);
return false;
}
// Vulkan is broken if the child crashed (return value is not zero)
*has_broken_vulkan = (status != 0);
}
+
+ const int env_var_cleared = unsetenv(STARTUP_CHECK_ENV_VAR);
+ if (env_var_cleared == -1) {
+ const int err = errno;
+ fmt::print(stderr, "unsetenv failed to clear {} with error {}\n", STARTUP_CHECK_ENV_VAR,
+ err);
+ }
#endif
return false;
}
@@ -150,10 +169,29 @@ bool SpawnChild(const char* arg0, PROCESS_INFORMATION* pi, int flags) {
pi // lpProcessInformation
);
if (!process_created) {
- std::fprintf(stderr, "CreateProcessA failed with error %lu\n", GetLastError());
+ fmt::print(stderr, "CreateProcessA failed with error {}\n", GetLastError());
return false;
}
return true;
}
+#elif defined(YUZU_UNIX)
+pid_t SpawnChild(const char* arg0) {
+ const pid_t pid = fork();
+
+ if (pid == -1) {
+ // error
+ const int err = errno;
+ fmt::print(stderr, "fork failed with error {}\n", err);
+ return pid;
+ } else if (pid == 0) {
+ // child
+ execl(arg0, arg0, nullptr);
+ const int err = errno;
+ fmt::print(stderr, "execl failed with error {}\n", err);
+ _exit(0);
+ }
+
+ return pid;
+}
#endif
diff --git a/src/yuzu/startup_checks.h b/src/yuzu/startup_checks.h
index d8e563be6..2f86fb843 100644
--- a/src/yuzu/startup_checks.h
+++ b/src/yuzu/startup_checks.h
@@ -5,6 +5,8 @@
#ifdef _WIN32
#include <windows.h>
+#elif defined(YUZU_UNIX)
+#include <sys/types.h>
#endif
constexpr char IS_CHILD_ENV_VAR[] = "YUZU_IS_CHILD";
@@ -17,4 +19,6 @@ bool StartupChecks(const char* arg0, bool* has_broken_vulkan, bool perform_vulka
#ifdef _WIN32
bool SpawnChild(const char* arg0, PROCESS_INFORMATION* pi, int flags);
+#elif defined(YUZU_UNIX)
+pid_t SpawnChild(const char* arg0);
#endif