From e4ca7c1f0b0388d90c20b43734c79420c296d5e7 Mon Sep 17 00:00:00 2001 From: Lorenzooone Date: Tue, 28 May 2024 22:39:41 +0200 Subject: [PATCH] Fix x86_64 macos build (#2) --- CMakeLists.txt | 20 ++++++++++++++++++++ README.md | 7 ++++--- macos_bundle_setup.sh | 12 ++++++++++++ macos_setup_ftd3xx.sh | 2 +- source/WindowScreen.cpp | 20 +++++++++++++++++++- 5 files changed, 56 insertions(+), 5 deletions(-) create mode 100755 macos_bundle_setup.sh diff --git a/CMakeLists.txt b/CMakeLists.txt index c6b0b06..f9162f4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -172,6 +172,26 @@ install(FILES openal32.dll DESTINATION .) endif() if(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") +set(FW_APP ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${OUTPUT_NAME}.app) +set(FW_DIRS ${sfml_SOURCE_DIR}/extlibs/libs-osx/Frameworks) +set_target_properties(${OUTPUT_NAME} PROPERTIES + MACOSX_BUNDLE TRUE) +set(CMAKE_MACOSX_RPATH TRUE) + +add_custom_command( + TARGET ${OUTPUT_NAME} + COMMENT "Copy Frameworks in bundle" + POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory ${FW_DIRS} ${FW_APP}/Contents/Frameworks + VERBATIM +) + +add_custom_command( + TARGET ${OUTPUT_NAME} + COMMENT "Set bundle path for Frameworks" + POST_BUILD COMMAND ${CMAKE_SOURCE_DIR}/macos_bundle_setup.sh ${FW_APP}/Contents/MacOS/${OUTPUT_NAME} + VERBATIM +) + elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") else() install(FILES 51-ftd3xx.rules DESTINATION .) diff --git a/README.md b/README.md index 77b0194..8954b5f 100644 --- a/README.md +++ b/README.md @@ -63,16 +63,16 @@ The software has a GUI which exposes all of the available settings. There are al Most of the settings are explained in [Keyboard shortcuts](#Keyboard-shortcuts). ### Keyboard controls -- __Enter key__: Used to open the GUI when it is not shown, as well as to confirm the selection of an option. +- __Enter key__: Used to open the GUI when it is not shown, as well as to confirm the selection of an option. Holding it for 30 seconds will reset the application to its defaults. - __Arrow keys__: Used to change the selected option in the GUI. ### Mouse controls -- __Right click__: Used to open the GUI when it is not shown. +- __Right click__: Used to open the GUI when it is not shown. Holding it for 30 seconds will reset the application to its defaults. - __Left click__: Used to confirm the selection of an option. ### Joystick controls - __Option/Share buttons__: Used to open the GUI when it is not shown. -- __A/B/X/Y buttons__: Used to confirm the selection of an option. +- __A/B/X/Y buttons__: Used to confirm the selection of an option. Holding B (X on a PS5 controller) for 30 seconds will reset the application to its defaults. - __Dpad/Sitcks__: Used to change the selected option in the GUI. _Note: Currently only tested using a PS5 controller._ @@ -120,5 +120,6 @@ The name of profiles can be changed by altering the __name__ field in its file. - At startup, the audio may be unstable. It should fix itself, if you give it enough time. - If, at first, the connection to the 3DS fails, reconnect the 3DS and then try again. If that also doesn't work, try restarting the program. If that also doesn't work, try restarting the computer. - USB Hubs can be the cause of connection issues. If you're having problems, try checking whether the 3DS connects fine or not without any other devices connected. +- Fullscreen mode on MacOS may mistake the screen for being bigger than what it really is. Changing the resolution to the proper one of the screen in the _Resolution Settings_ under Video Settings will fix the issue. - Current font in use: OFL Sorts Mill Goudy TT diff --git a/macos_bundle_setup.sh b/macos_bundle_setup.sh new file mode 100755 index 0000000..091adba --- /dev/null +++ b/macos_bundle_setup.sh @@ -0,0 +1,12 @@ +framework_change_pos() { + install_name_tool -change @rpath/../Frameworks/${2}.framework/Versions/A/${2} @executable_path/../Frameworks/${2}.framework/Versions/A/${2} ${1} +} + +framework_change_pos ${1} 'freetype' +framework_change_pos ${1} 'OpenAL' +framework_change_pos ${1} 'vorbisenc' +framework_change_pos ${1} 'vorbisfile' +framework_change_pos ${1} 'FLAC' +framework_change_pos ${1} 'vorbis' +framework_change_pos ${1} 'ogg' + diff --git a/macos_setup_ftd3xx.sh b/macos_setup_ftd3xx.sh index bc342b3..201553b 100755 --- a/macos_setup_ftd3xx.sh +++ b/macos_setup_ftd3xx.sh @@ -1,4 +1,4 @@ hdiutil attach ${1} cp ${2}/${4} ${3} cp ${2}/*.h ${3} -hdiutil detach ${3} || true +hdiutil detach ${2} || true diff --git a/source/WindowScreen.cpp b/source/WindowScreen.cpp index ef40bf7..73b31d3 100755 --- a/source/WindowScreen.cpp +++ b/source/WindowScreen.cpp @@ -3,6 +3,9 @@ #include #include "font_ttf.h" +#define DEFAULT_FS_WIDTH 1920 +#define DEFAULT_FS_HEIGHT 1080 + #define FPS_WINDOW_SIZE 64 #define LEFT_ROUNDED_PADDING 5 @@ -174,7 +177,6 @@ void WindowScreen::fullscreen_change() { if(this->curr_menu != CONNECT_MENU_TYPE) this->curr_menu = DEFAULT_MENU_TYPE; this->m_info.is_fullscreen = !this->m_info.is_fullscreen; - reset_fullscreen_info(this->m_info); this->create_window(true); } @@ -2228,6 +2230,22 @@ void WindowScreen::create_window(bool re_prepare_size) { success = true; } } + #ifdef __APPLE__ + if(!success) { + sf::VideoMode mode_created = sf::VideoMode(DEFAULT_FS_WIDTH, DEFAULT_FS_HEIGHT, 32); + if(mode_created.isValid()) { + this->curr_desk_mode = mode_created; + success = true; + } + else { + mode_created = sf::VideoMode(DEFAULT_FS_WIDTH, DEFAULT_FS_HEIGHT, 24); + if(mode_created.isValid()) { + this->curr_desk_mode = mode_created; + success = true; + } + } + } + #endif if(!success) { this->curr_desk_mode = sf::VideoMode::getDesktopMode(); }