qt: Add support for building for iOS. (#6594)

This commit is contained in:
Steveice10 2023-06-07 20:40:53 -07:00 committed by GitHub
parent d9bf4fd8a2
commit 238a574645
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 277 additions and 122 deletions

View file

@ -143,9 +143,12 @@ add_subdirectory(video_core)
add_subdirectory(audio_core)
add_subdirectory(network)
add_subdirectory(input_common)
add_subdirectory(tests)
if (ENABLE_SDL2)
if (ENABLE_TESTS)
add_subdirectory(tests)
endif()
if (ENABLE_SDL2 AND ENABLE_SDL2_FRONTEND)
add_subdirectory(citra)
endif()
@ -153,11 +156,13 @@ if (ENABLE_QT)
add_subdirectory(citra_qt)
endif()
if (ENABLE_DEDICATED_ROOM)
add_subdirectory(dedicated_room)
endif()
if (ANDROID)
add_subdirectory(android/app/src/main/jni)
target_include_directories(citra-android PRIVATE android/app/src/main)
else()
add_subdirectory(dedicated_room)
endif()
if (ENABLE_WEB_SERVICE)

View file

@ -8,7 +8,6 @@ if (POLICY CMP0071)
endif()
add_executable(citra-qt
Info.plist
aboutdialog.cpp
aboutdialog.h
aboutdialog.ui
@ -169,9 +168,6 @@ add_executable(citra-qt
uisettings.h
qt_image_interface.cpp
qt_image_interface.h
updater/updater.cpp
updater/updater.h
updater/updater_p.h
util/clickable_label.cpp
util/clickable_label.h
util/sequence_dialog/sequence_dialog.cpp
@ -202,6 +198,15 @@ file(GLOB COMPAT_LIST
file(GLOB_RECURSE ICONS ${PROJECT_SOURCE_DIR}/dist/icons/*)
file(GLOB_RECURSE THEMES ${PROJECT_SOURCE_DIR}/dist/qt_themes/*)
if (ENABLE_QT_UPDATER)
target_sources(citra-qt PRIVATE
updater/updater.cpp
updater/updater.h
updater/updater_p.h
)
target_compile_definitions(citra-qt PUBLIC ENABLE_QT_UPDATER)
endif()
if (ENABLE_QT_TRANSLATION)
set(CITRA_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)
@ -248,17 +253,43 @@ target_sources(citra-qt
)
if (APPLE)
set(MACOSX_ICON "../../dist/citra.icns")
set_source_files_properties(${MACOSX_ICON} PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
set(DIST_DIR "../../dist/apple")
set(APPLE_RESOURCES
"${DIST_DIR}/citra.icns"
"${DIST_DIR}/LaunchScreen.storyboard"
"${DIST_DIR}/launch_logo.png"
)
target_sources(citra-qt PRIVATE
${MACOSX_ICON}
${APPLE_RESOURCES}
macos_authorization.h
macos_authorization.mm
)
# Define app bundle metadata.
include(GenerateBuildInfo)
set_target_properties(citra-qt PROPERTIES
MACOSX_BUNDLE TRUE
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist
MACOSX_BUNDLE_INFO_PLIST "${DIST_DIR}/Info.plist.in"
MACOSX_BUNDLE_BUNDLE_NAME "Citra"
MACOSX_BUNDLE_GUI_IDENTIFIER "com.citra-emu.citra"
MACOSX_BUNDLE_BUNDLE_VERSION "${BUILD_VERSION}"
MACOSX_BUNDLE_SHORT_VERSION_STRING "${BUILD_FULLNAME}"
MACOSX_BUNDLE_LONG_VERSION_STRING "${BUILD_FULLNAME}"
MACOSX_BUNDLE_ICON_FILE "citra.icns"
RESOURCE "${APPLE_RESOURCES}"
)
if (IOS)
set_target_properties(citra-qt PROPERTIES
# Have Xcode copy and sign MoltenVK into app bundle.
XCODE_EMBED_FRAMEWORKS "${MOLTENVK_LIBRARY}"
XCODE_EMBED_FRAMEWORKS_CODE_SIGN_ON_COPY YES
XCODE_ATTRIBUTE_LD_RUNPATH_SEARCH_PATHS "@executable_path/Frameworks"
# Support iPhone and iPad.
XCODE_ATTRIBUTE_TARGETED_DEVICE_FAMILY "1,2"
)
endif()
elseif(WIN32)
# compile as a win32 gui application instead of a console application
target_link_libraries(citra-qt PRIVATE Qt6::EntryPointImplementation)

View file

@ -1,46 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!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>citra.icns</string>
<key>CFBundleIdentifier</key>
<string>com.citra-emu.citra</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleLongVersionString</key>
<string></string>
<key>CFBundleName</key>
<string>Citra</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>LSRequiresCarbon</key>
<true/>
<key>NSHumanReadableCopyright</key>
<string></string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
<key>NSHighResolutionCapable</key>
<string>True</string>
<key>NSCameraUsageDescription</key>
<string>This app requires camera access to emulate the 3DS&apos;s cameras.</string>
<key>NSMicrophoneUsageDescription</key>
<string>This app requires microphone access to emulate the 3DS&apos;s microphone.</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.games</string>
</dict>
</plist>

View file

@ -364,7 +364,7 @@ static Frontend::WindowSystemType GetWindowSystemType() {
return Frontend::WindowSystemType::X11;
else if (platform_name == QStringLiteral("wayland"))
return Frontend::WindowSystemType::Wayland;
else if (platform_name == QStringLiteral("cocoa"))
else if (platform_name == QStringLiteral("cocoa") || platform_name == QStringLiteral("ios"))
return Frontend::WindowSystemType::MacOS;
LOG_CRITICAL(Frontend, "Unknown Qt platform!");

View file

@ -223,7 +223,12 @@ GMainWindow::GMainWindow(Core::System& system_)
InitializeRecentFileMenuActions();
InitializeSaveStateMenuActions();
InitializeHotkeys();
#if ENABLE_QT_UPDATER
ShowUpdaterWidgets();
#else
ui->action_Check_For_Updates->setVisible(false);
ui->action_Open_Maintenance_Tool->setVisible(false);
#endif
SetDefaultUIGeometry();
RestoreUIState();
@ -268,9 +273,11 @@ GMainWindow::GMainWindow(Core::System& system_)
connect(&mouse_hide_timer, &QTimer::timeout, this, &GMainWindow::HideMouseCursor);
connect(ui->menubar, &QMenuBar::hovered, this, &GMainWindow::OnMouseActivity);
#if ENABLE_QT_UPDATER
if (UISettings::values.check_for_update_on_start) {
CheckForUpdates();
}
#endif
QStringList args = QApplication::arguments();
if (args.length() >= 2) {
@ -322,9 +329,11 @@ void GMainWindow::InitializeWidgets() {
ui->action_Show_Room);
multiplayer_state->setVisible(false);
#if ENABLE_QT_UPDATER
// Setup updater
updater = new Updater(this);
UISettings::values.updater_found = updater->HasUpdater();
#endif
UpdateBootHomeMenuState();
@ -655,13 +664,6 @@ void GMainWindow::InitializeHotkeys() {
});
}
void GMainWindow::ShowUpdaterWidgets() {
ui->action_Check_For_Updates->setVisible(UISettings::values.updater_found);
ui->action_Open_Maintenance_Tool->setVisible(UISettings::values.updater_found);
connect(updater, &Updater::CheckUpdatesDone, this, &GMainWindow::OnUpdateFound);
}
void GMainWindow::SetDefaultUIGeometry() {
// geometry: 55% of the window contents are in the upper screen half, 45% in the lower half
const QRect screenRect = screen()->geometry();
@ -851,8 +853,11 @@ void GMainWindow::ConnectMenuEvents() {
QDesktopServices::openUrl(QUrl(QStringLiteral("https://citra-emu.org/wiki/faq/")));
});
connect_menu(ui->action_About, &GMainWindow::OnMenuAboutCitra);
#if ENABLE_QT_UPDATER
connect_menu(ui->action_Check_For_Updates, &GMainWindow::OnCheckForUpdates);
connect_menu(ui->action_Open_Maintenance_Tool, &GMainWindow::OnOpenUpdater);
#endif
}
void GMainWindow::UpdateMenuState() {
@ -904,6 +909,7 @@ void GMainWindow::OnDisplayTitleBars(bool show) {
}
}
#if ENABLE_QT_UPDATER
void GMainWindow::OnCheckForUpdates() {
explicit_update_check = true;
CheckForUpdates();
@ -970,6 +976,14 @@ void GMainWindow::OnOpenUpdater() {
updater->LaunchUI();
}
void GMainWindow::ShowUpdaterWidgets() {
ui->action_Check_For_Updates->setVisible(UISettings::values.updater_found);
ui->action_Open_Maintenance_Tool->setVisible(UISettings::values.updater_found);
connect(updater, &Updater::CheckUpdatesDone, this, &GMainWindow::OnUpdateFound);
}
#endif
#if defined(__unix__) && !defined(__APPLE__)
static std::optional<QDBusObjectPath> HoldWakeLockLinux(u32 window_id = 0) {
if (!QDBusConnection::sessionBus().isConnected()) {
@ -1327,9 +1341,11 @@ void GMainWindow::ShutdownGame() {
emulation_running = false;
#if ENABLE_QT_UDPATER
if (defer_update_prompt) {
ShowUpdatePrompt();
}
#endif
game_title.clear();
UpdateWindowTitle();

View file

@ -46,7 +46,9 @@ class QProgressBar;
class QPushButton;
class QSlider;
class RegistersWidget;
#if ENABLE_QT_UPDATER
class Updater;
#endif
class WaitTreeWidget;
namespace Camera {
@ -146,12 +148,15 @@ private:
void ShutdownGame();
void ShowTelemetryCallout();
void SetDiscordEnabled(bool state);
void LoadAmiibo(const QString& filename);
#if ENABLE_QT_UPDATER
void ShowUpdaterWidgets();
void ShowUpdatePrompt();
void ShowNoUpdatePrompt();
void CheckForUpdates();
void SetDiscordEnabled(bool state);
void LoadAmiibo(const QString& filename);
#endif
/**
* Stores the filename in the recently loaded files list.
@ -244,9 +249,13 @@ private slots:
void OnCoreError(Core::System::ResultStatus, std::string);
/// Called whenever a user selects Help->About Citra
void OnMenuAboutCitra();
#if ENABLE_QT_UPDATER
void OnUpdateFound(bool found, bool error);
void OnCheckForUpdates();
void OnOpenUpdater();
#endif
void OnLanguageChanged(const QString& locale);
void OnMouseActivity();
@ -326,7 +335,9 @@ private:
IPCRecorderWidget* ipcRecorderWidget;
LLEServiceModulesWidget* lleServiceModulesWidget;
WaitTreeWidget* waitTreeWidget;
#if ENABLE_QT_UPDATER
Updater* updater;
#endif
bool explicit_update_check = false;
bool defer_update_prompt = false;

View file

@ -21,7 +21,12 @@
#ifdef _WIN32
#define EMU_DATA_DIR "Citra"
#elif defined(__APPLE__)
#define MACOS_EMU_DATA_DIR "Library" DIR_SEP "Application Support" DIR_SEP "Citra"
#include <TargetConditionals.h>
#if TARGET_OS_IPHONE
#define APPLE_EMU_DATA_DIR "Documents" DIR_SEP "Citra"
#else
#define APPLE_EMU_DATA_DIR "Library" DIR_SEP "Application Support" DIR_SEP "Citra"
#endif
// For compatibility with XDG paths.
#define EMU_DATA_DIR "citra-emu"
#else

View file

@ -786,7 +786,7 @@ void SetUserPath(const std::string& path) {
// paths.
if (!FileUtil::Exists(data_dir) && !FileUtil::Exists(config_dir) &&
!FileUtil::Exists(cache_dir)) {
data_dir = GetHomeDirectory() + DIR_SEP MACOS_EMU_DATA_DIR DIR_SEP;
data_dir = GetHomeDirectory() + DIR_SEP APPLE_EMU_DATA_DIR DIR_SEP;
config_dir = data_dir + CONFIG_DIR DIR_SEP;
cache_dir = data_dir + CACHE_DIR DIR_SEP;
}