diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a8455c57..8a8dddf6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,7 +1,7 @@ name: Build Cemu on: - pull_request_target: + pull_request: paths-ignore: - "*.md" types: @@ -26,9 +26,6 @@ env: jobs: build-ubuntu: runs-on: ubuntu-20.04 - env: - install_vulkan_folder: "$GITHUB_WORKSPACE/vulkan_sdk" - install_vulkan_version: "1.3.216.0" steps: - name: "Checkout repo" uses: actions/checkout@v3 @@ -53,13 +50,9 @@ jobs: run: | sudo apt update -qq sudo apt install -y ninja-build cmake libgtk-3-dev libsecret-1-dev libgcrypt20-dev libsystemd-dev freeglut3-dev clang-12 nasm - wget https://sdk.lunarg.com/sdk/download/${{ env.install_vulkan_version }}/linux/vulkansdk-linux-x86_64-${{ env.install_vulkan_version }}.tar.gz -q -O vulkansdk.tar.gz - mkdir -p "${{ env.install_vulkan_folder }}" - tar -xf vulkansdk.tar.gz --directory ${{ env.install_vulkan_folder }} - name: "Bootstrap vcpkg" run: | - export VULKAN_SDK="${{ env.install_vulkan_folder }}/${{ env.install_vulkan_version }}/x86_64" bash ./dependencies/vcpkg/bootstrap-vcpkg.sh - name: 'Setup NuGet Credentials for vcpkg' @@ -78,7 +71,6 @@ jobs: - name: "cmake" run: | - export VULKAN_SDK="${{ env.install_vulkan_folder }}/${{ env.install_vulkan_version }}/x86_64" mkdir -p build cd build cmake .. ${{ env.BUILD_FLAGS }} -DCMAKE_BUILD_TYPE=${{ env.BUILD_MODE }} -DCMAKE_C_COMPILER=/usr/bin/clang-12 -DCMAKE_CXX_COMPILER=/usr/bin/clang++-12 -G Ninja -DCMAKE_MAKE_PROGRAM=/usr/bin/ninja @@ -98,9 +90,6 @@ jobs: build-windows: runs-on: windows-2022 - env: - install_vulkan_folder: "$GITHUB_WORKSPACE/vulkan_sdk" - install_vulkan_version: "1.3.216.0" steps: - name: "Checkout repo" uses: actions/checkout@v3 @@ -121,12 +110,6 @@ jobs: echo "BUILD_FLAGS=" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append echo "Build mode is debug" - - name: Prepare Vulkan SDK - uses: humbletim/setup-vulkan-sdk@v1.2.0 - with: - vulkan-query-version: 1.3.216.0 - vulkan-components: Vulkan-Headers, Vulkan-Loader - vulkan-use-cache: false - name: Workaround run: | diff --git a/.gitignore b/.gitignore index fe0c7726..93d2b94e 100644 --- a/.gitignore +++ b/.gitignore @@ -16,7 +16,20 @@ build/ out/ +.cache/ # Cemu bin files -otp.bin -seeprom.bin +bin/otp.bin +bin/seeprom.bin +bin/Cemu.pdb +bin/mlc01/* +bin/settings.xml +bin/title_list_cache.xml + +!bin/shaderCache/info.txt +bin/shaderCache/* + +bin/controllerProfiles/* + +!bin/gameProfiles/default/* +bin/gameProfiles/* \ No newline at end of file diff --git a/.gitmodules b/.gitmodules index 04f01186..dd32088b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -10,3 +10,6 @@ path = dependencies/vcpkg url = https://github.com/microsoft/vcpkg shallow = true +[submodule "dependencies/Vulkan-Headers"] + path = dependencies/Vulkan-Headers + url = https://github.com/KhronosGroup/Vulkan-Headers diff --git a/BUILD.md b/BUILD.md index e9eac5a8..ab0dd10d 100644 --- a/BUILD.md +++ b/BUILD.md @@ -5,7 +5,6 @@ Prerequisites: - A recent version of Visual Studio 2022 with CMake tools component - git -- Vulkan SDK ([https://vulkan.lunarg.com/](https://vulkan.lunarg.com/)). Don't forget to restart after installing. Instructions: @@ -23,12 +22,11 @@ To compile Cemu, a recent enough compiler and STL with C++20 support is required For ubuntu and most derivatives: -1) Make sure vulkansdk is installed and the VULKAN_SDK environment variable is set correctly. -2) `sudo apt install -y libgtk-3-dev libsecret-1-dev libgcrypt20-dev libsystemd-dev freeglut3-dev clang-12 nasm` -3) Run `git clone --recursive https://github.com/cemu-project/Cemu` -4) `cd Cemu` -5) `mkdir build && cd build` -6) `cmake .. -DCMAKE_BUILD_TYPE=release -DCMAKE_C_COMPILER=/usr/bin/clang-12 -DCMAKE_CXX_COMPILER=/usr/bin/clang++-12 -G Ninja -DCMAKE_MAKE_PROGRAM=/usr/bin/ninja` -8) `ninja` +1) `sudo apt install -y libgtk-3-dev libsecret-1-dev libgcrypt20-dev libsystemd-dev freeglut3-dev clang-12 nasm ninja-build` +2) Run `git clone --recursive https://github.com/cemu-project/Cemu` +3) `cd Cemu` +4) `mkdir build && cd build` +5) `cmake .. -DCMAKE_BUILD_TYPE=release -DCMAKE_C_COMPILER=/usr/bin/clang-12 -DCMAKE_CXX_COMPILER=/usr/bin/clang++-12 -G Ninja` +6) `ninja` Build instructions for other distributions will be added in the future! diff --git a/CMakeLists.txt b/CMakeLists.txt index fb516da3..9666005d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,6 +23,10 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON) set_property(GLOBAL PROPERTY USE_FOLDERS ON) +if (MSVC) + set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT CemuBin) +endif() + if (MSVC) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /fp:precise") # floating point model: precise @@ -37,10 +41,6 @@ option(ENABLE_OPENGL "Enables the OpenGL backend" ON) option(ENABLE_VULKAN "Enables the Vulkan backend" ON) option(ENABLE_DISCORD_RPC "Enables the Discord Rich Presence feature" ON) -if (WIN32) - option(ENABLE_CEMUHOOK "Enables Cemuhook compatibility" ON) -endif() - # input backends if (WIN32) option(ENABLE_XINPUT "Enables the usage of XInput" ON) @@ -70,8 +70,7 @@ find_package(ZLIB REQUIRED) find_package(zstd CONFIG REQUIRED) if (ENABLE_VULKAN) - find_package(Vulkan REQUIRED) - include_directories("${Vulkan_INCLUDE_DIRS}") + include_directories("dependencies/Vulkan-Headers/include") endif() if (ENABLE_OPENGL) @@ -113,5 +112,4 @@ endif() add_subdirectory(dependencies/ih264d) add_subdirectory(dependencies/ZArchive) -add_subdirectory(src) - +add_subdirectory(src) \ No newline at end of file diff --git a/README.md b/README.md index 318c8d6e..232e4325 100644 --- a/README.md +++ b/README.md @@ -22,13 +22,13 @@ Cemu is currently only available for 64-bit Windows and Linux devices. ## Download -You can download the latest Cemu releases from the [Github Releases](https://github.com/cemu-project/Cemu/releases/) or from [Cemu's website](http://cemu.info). +You can download the latest Cemu releases from the [Github Releases](https://github.com/cemu-project/Cemu/releases/) or from [Cemu's website](https://cemu.info). Cemu is currently only available in a portable format so no installation is required besides extracting it in a safe place. See [Current State Of Linux builds](https://github.com/cemu-project/Cemu/issues/1) for information on using Cemu natively on Linux. -Pre-2.0 releases can be found on Cemu's [changelog page](http://cemu.info/changelog.html). +Pre-2.0 releases can be found on Cemu's [changelog page](https://cemu.info/changelog.html). ## Build Instructions diff --git a/bin/gameProfiles/example.ini b/bin/gameProfiles/example.ini deleted file mode 100644 index cca6dd87..00000000 --- a/bin/gameProfiles/example.ini +++ /dev/null @@ -1,27 +0,0 @@ -# This is an example configuration file. You can use this file as a guideline on how to create your own game profiles. - -# Overview: -# The filename of the game profile can be found by looking at log.txt after a game was launched in Cemu. -# A '#' character starts a one-line comment. Any text afterwards will be ignored. -# If an option is not given in the .ini file, Cemu will use the value from the global settings instead. - -[General] -loadSharedLibraries = true # If set to true, system rpl files will be loaded from /cafeLibs/ if present. Default value is true -useRDTSC = true # Use RDTSC instruction as timer source for emulated CPU, OS and audio - -[Graphics] -accurateShaderMul = true # If set to true, Cemu will correctly emulate the non-IEEE behavior of the shader MUL instruction. Can fix graphic issues but also decreases shader performance and increases shader compile time. Default value is true. -# Since Cemu 1.7.5 the option accurateShaderMul also supports a third mode, enabled by using the value 'min' (e.g. accurateShaderMul = min). In this mode, Cemu will emulate non-ieee MUL instructions in a more GPU-friendly way which generates less complex shaders. However, this mode might not be 100% accurate - -disableGPUFence = false # If set to true, GPU fence operations will be skipped. Default value is false. Enabling this option can lead to instability and crashes - -GPUBufferCacheAccuracy = 0 # Controls the accuracy of vertex and uniform data caching. A higher accuracy means more expensive checks which can slow down rendering. Possible values: 0 = high, 1 = medium, 2 = low - -streamoutBufferCacheSize = 24 # buffer cache size of the streamout buffer in MB. - -extendedTextureReadback = false # If set to true, Cemu will try to mirror data written by GPU operations to CPU RAM (but only if access by CPU is assumed to be likely) Default value is false - -[CPU] -cpuTimer = cycleCounter # Timer source for OS and CPU time. Supported values are 'hostBased' (timers are based on actual OS time) and 'cycleCounter' (timers are based on speed of emulated CPU). -emulateSinglePrecision = true # If set to false, the recompiler won't correctly round the result of single-precision instructions in certain situations. This can introduce gameplay bugs, but might also improve performance. -cpuMode = Singlecore-Recompiler # CPU mode. Possible values: Singlecore-Interpreter, Singlecore-Recompiler, Dualcore-Recompiler, Triplecore-Recompiler \ No newline at end of file diff --git a/dependencies/Vulkan-Headers b/dependencies/Vulkan-Headers new file mode 160000 index 00000000..71567370 --- /dev/null +++ b/dependencies/Vulkan-Headers @@ -0,0 +1 @@ +Subproject commit 715673702f5b18ffb8e5832e67cf731468d32ac6 diff --git a/dist/linux/info.cemu.Cemu.desktop b/dist/linux/info.cemu.Cemu.desktop new file mode 100644 index 00000000..e23102d8 --- /dev/null +++ b/dist/linux/info.cemu.Cemu.desktop @@ -0,0 +1,12 @@ +[Desktop Entry] +Name=Cemu +Type=Application +Terminal=false +Icon=info.cemu.Cemu +Exec=cemu +Comment=Software to emulate Wii U games and applications on PC +Comment[de]=Software zum emulieren von Wii U Spielen und Anwendungen auf dem PC +Comment[ru]=Программа для эмуляции игр и приложений Wii U на PC +Categories=Game;Emulator; +Keywords=Nintendo; +MimeType=application/x-wii-u-rom; diff --git a/dist/linux/info.cemu.Cemu.metainfo.xml b/dist/linux/info.cemu.Cemu.metainfo.xml new file mode 100644 index 00000000..2535cbf8 --- /dev/null +++ b/dist/linux/info.cemu.Cemu.metainfo.xml @@ -0,0 +1,58 @@ + + + + info.cemu.Cemu + Cemu + Software to emulate Wii U games and applications on PC + Software zum emulieren von Wii U Spielen und Anwendungen auf dem PC + Cemu Project + info.cemu.Cemu.desktop + CC0-1.0 + MPL-2.0 + +

Cemu is a Nintendo Wii U emulator that is able to run most Wii U games and homebrew in a playable state. Created by Exzap, and written in C/C++.

+

Cemu ist ein Nintendo Wii U-Emulator, der die meisten Wii U Spiele und Homebrew in einem spielbaren Zustand ausführen kann. Erstellt von Exzap, und geschrieben in C/C++.

+

This emulator aims at providing both high-accuracy and performance, and is actively being developed with new features and fixes to increase compatibility, convenience and usability.

+

Dieser Emulator zielt darauf ab, sowohl hohe Genauigkeit als auch Leistung zu bieten, und wird aktiv mit neuen Funktionen und Korrekturen weiterentwickelt, um Kompatibilität, Komfort und Benutzerfreundlichkeit zu verbessern.

+

It was written from scratch and development on the project began roughly early 2015.

+

Er wird seit Anfang 2015 entwickelt.

+
+ + + https://upload.wikimedia.org/wikipedia/commons/5/58/Cemu_Screenshot.png + + + + + https://github.com/cemu-project/Cemu/releases/tag/v2.0 + + + https://cemu.info + https://github.com/cemu-project/Cemu/issues + https://cemu.info/faq.html + https://wiki.cemu.info + https://github.com/cemu-project/Cemu + + Game + Emulator + + + 4096 + + + 8192 + + + pointing + keyboard + gamepad + + + + cemu + application/x-wii-u-rom + + + nintendo + +
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3505d6e0..49f79e21 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -20,12 +20,12 @@ if(MSVC) # _SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING # _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS elseif(UNIX) + if(NOT APPLE) + add_definitions(-DVK_USE_PLATFORM_XLIB_KHR) # legacy. Do we need to support XLIB surfaces? + add_definitions(-DVK_USE_PLATFORM_XCB_KHR) + endif() add_definitions(-fms-extensions) - # add_definitions(-fms-compatibility-version=19.14) - # add_definitions(-fdelayed-template-parsing) add_definitions(-fpermissive) - add_definitions(-DVK_USE_PLATFORM_XLIB_KHR) # legacy. Do we need to support XLIB surfaces? - add_definitions(-DVK_USE_PLATFORM_XCB_KHR) add_definitions(-maes) # warnings add_compile_options(-Wno-switch -Wno-ignored-attributes -Wno-deprecated-enum-enum-conversion -Wno-ambiguous-reversed-operator) @@ -47,11 +47,6 @@ add_subdirectory(imgui) add_subdirectory(resource) add_subdirectory(asm) -if(ENABLE_CEMUHOOK) - add_definitions(-DUSE_CEMUHOOK) - add_subdirectory(cemuhook) -endif() - if(PUBLIC_RELEASE) add_executable(CemuBin WIN32 main.cpp @@ -69,7 +64,6 @@ target_precompile_headers(CemuBin PRIVATE Common/precompiled.h) if(WIN32) target_sources(CemuBin PRIVATE resource/cemu.rc - exports.def # for Cemuhook ) endif() @@ -90,10 +84,6 @@ target_link_libraries(CemuBin PRIVATE CURL::libcurl) target_link_libraries(CemuBin PRIVATE imgui::imgui) target_link_libraries(CemuBin PRIVATE pugixml pugixml::static pugixml::pugixml) -if(ENABLE_CEMUHOOK) -target_link_libraries(CemuBin PRIVATE CemuCemuhook) -endif() - target_link_libraries(CemuBin PUBLIC CemuCommon CemuAudio CemuInput CemuComponents CemuCafe CemuConfig CemuGui imguiImpl) diff --git a/src/Cafe/Account/Account.cpp b/src/Cafe/Account/Account.cpp index bb17f3ff..a524220f 100644 --- a/src/Cafe/Account/Account.cpp +++ b/src/Cafe/Account/Account.cpp @@ -3,12 +3,13 @@ #include "gui/CemuApp.h" #include "util/helpers/SystemException.h" -#include - #include "config/ActiveSettings.h" #include "Cafe/IOSU/legacy/iosu_crypto.h" #include "Common/filestream.h" +#include +#include + std::vector Account::s_account_list; Account::Account(uint32 persistent_id) @@ -65,8 +66,11 @@ Account::Account(uint32 persistent_id, std::wstring_view mii_name) static std::random_device s_random_device; static std::mt19937 s_mte(s_random_device()); - std::uniform_int_distribution dist(std::numeric_limits::min(), std::numeric_limits::max()); - std::generate(m_uuid.begin(), m_uuid.end(), [&]() { return (uint8)dist(s_mte); }); + + // use boost library to escape static asserts in linux builds + boost::random::uniform_int_distribution dist(std::numeric_limits::min(), std::numeric_limits::max()); + + std::generate(m_uuid.begin(), m_uuid.end(), [&]() { return (uint8)dist(s_mte); }); // 1000004 or 2000004 | lower uint32 from uuid from uuid m_transferable_id_base = (0x2000004ULL << 32); @@ -575,4 +579,4 @@ void actPwTest() makePWHash(pwHash, 32, pid, pwHash); // calculates AccountPasswordHash assert_dbg(); -} \ No newline at end of file +} diff --git a/src/Cafe/CafeSystem.cpp b/src/Cafe/CafeSystem.cpp index a07942d2..2e79d210 100644 --- a/src/Cafe/CafeSystem.cpp +++ b/src/Cafe/CafeSystem.cpp @@ -282,7 +282,7 @@ struct static_assert(sizeof(SharedDataEntry) == 0x1C); -DLLEXPORT uint32 loadSharedData() +uint32 loadSharedData() { // check if font files are dumped bool hasAllShareddataFiles = true; @@ -364,7 +364,7 @@ void cemu_initForGame() time_t theTime = (time(NULL) - 946684800); { tm* lt = localtime(&theTime); -#if BOOST_OS_WINDOWS > 0 +#if BOOST_OS_WINDOWS theTime = _mkgmtime(lt); #else theTime = timegm(lt); @@ -856,4 +856,4 @@ namespace CafeSystem return currentUpdatedApplicationHash; } -} \ No newline at end of file +} diff --git a/src/Cafe/Filesystem/FST/FST.cpp b/src/Cafe/Filesystem/FST/FST.cpp index b9b511f1..a230a3a6 100644 --- a/src/Cafe/Filesystem/FST/FST.cpp +++ b/src/Cafe/Filesystem/FST/FST.cpp @@ -1029,7 +1029,7 @@ bool FSTVerifier::VerifyContentFile(FileStream* fileContent, const NCrypto::AesK SHA256_Init(&sha256Ctx); while (remainingBytes > 0) { - uint32 bytesToRead = (uint32)std::min(remainingBytes, buffer.size()); + uint32 bytesToRead = (uint32)std::min(remainingBytes, (uint64)buffer.size()); uint32 bytesToReadPadded = ((bytesToRead + 0xF) & ~0xF); uint32 bytesRead = fileContent->readData(buffer.data(), bytesToReadPadded); if (bytesRead != bytesToReadPadded) diff --git a/src/Cafe/GameProfile/GameProfile.cpp b/src/Cafe/GameProfile/GameProfile.cpp index 8d3f739e..11f8f758 100644 --- a/src/Cafe/GameProfile/GameProfile.cpp +++ b/src/Cafe/GameProfile/GameProfile.cpp @@ -22,7 +22,7 @@ struct gameProfileBooleanOption_t * If the option exists, true is returned. * The boolean is stored in *optionValue */ -DLLEXPORT bool gameProfile_loadBooleanOption(IniParser* iniParser, char* optionName, gameProfileBooleanOption_t* option) +bool gameProfile_loadBooleanOption(IniParser* iniParser, char* optionName, gameProfileBooleanOption_t* option) { auto option_value = iniParser->FindOption(optionName); option->isPresent = false; @@ -81,7 +81,7 @@ bool gameProfile_loadBooleanOption2(IniParser& iniParser, const char* optionName * Attempts to load a integer option * Allows to specify min and max value (error is logged if out of range and default value is picked) */ -DLLEXPORT bool gameProfile_loadIntegerOption(IniParser* iniParser, const char* optionName, gameProfileIntegerOption_t* option, sint32 defaultValue, sint32 minVal, sint32 maxVal) +bool gameProfile_loadIntegerOption(IniParser* iniParser, const char* optionName, gameProfileIntegerOption_t* option, sint32 defaultValue, sint32 minVal, sint32 maxVal) { auto option_value = iniParser->FindOption(optionName); option->isPresent = false; @@ -166,17 +166,10 @@ bool gameProfile_loadEnumOption(IniParser& iniParser, const char* optionName, st return result; } -#pragma optimize( "", off ) -DLLEXPORT NOINLINE void gameProfile_categoryBegin(IniParser* iniParser) -{ - // do nothing -} -#pragma optimize( "", on ) - void gameProfile_load() { g_current_game_profile->ResetOptional(); // reset with global values as optional - g_current_game_profile->Load(CafeSystem::GetForegroundTitleId(), true); + g_current_game_profile->Load(CafeSystem::GetForegroundTitleId()); // apply some settings immediately ppcThreadQuantum = g_current_game_profile->GetThreadQuantum(); @@ -185,7 +178,7 @@ void gameProfile_load() cemuLog_force("Thread quantum set to {}", ppcThreadQuantum); } -bool GameProfile::Load(uint64_t title_id, bool notifyCemuhook) +bool GameProfile::Load(uint64_t title_id) { auto gameProfilePath = ActiveSettings::GetPath("gameProfiles/{:016x}.ini", title_id); @@ -220,9 +213,6 @@ bool GameProfile::Load(uint64_t title_id, bool notifyCemuhook) // parse ini while (iniParser.NextSection()) { - //if (notifyCemuhook) - // gameProfile_categoryBegin(gameProfile); // hookable export for Cemuhook - if (boost::iequals(iniParser.GetCurrentSectionName(), "General")) { gameProfile_loadBooleanOption2(iniParser, "loadSharedLibraries", m_loadSharedLibraries); @@ -379,24 +369,3 @@ void GameProfile::Reset() for (auto& profile : m_controllerProfile) profile.reset(); } - -// legacy code for Cemuhook -DLLEXPORT char* gameProfile_loadStringOption(IniParser* iniParser, char* optionName) -{ - return nullptr; -} -DLLEXPORT char* gameProfile_getCurrentCategoryName(IniParser* iniParser) -{ - return nullptr; -} - -struct gpNamedOptionEntry_t -{ - char* name; - sint32 value; -}; - -DLLEXPORT bool gameProfile_loadIntegerNamedOption(IniParser* iniParser, char* optionName, gameProfileIntegerOption_t* option, sint32 defaultValue, const gpNamedOptionEntry_t* nameValues, sint32 numNameValues) -{ - return false; -} \ No newline at end of file diff --git a/src/Cafe/GameProfile/GameProfile.h b/src/Cafe/GameProfile/GameProfile.h index 10e90fea..6a1f2ebd 100644 --- a/src/Cafe/GameProfile/GameProfile.h +++ b/src/Cafe/GameProfile/GameProfile.h @@ -16,7 +16,7 @@ class GameProfile public: static const uint32 kThreadQuantumDefault = 45000; - bool Load(uint64_t title_id, bool notifyCemuhook); + bool Load(uint64_t title_id); void Save(uint64_t title_id); void ResetOptional(); void Reset(); @@ -65,4 +65,4 @@ private: }; extern std::unique_ptr g_current_game_profile; -DLLEXPORT void gameProfile_load(); +void gameProfile_load(); diff --git a/src/Cafe/GraphicPack/GraphicPack.cpp b/src/Cafe/GraphicPack/GraphicPack.cpp index bdf21e4b..d8b21c36 100644 --- a/src/Cafe/GraphicPack/GraphicPack.cpp +++ b/src/Cafe/GraphicPack/GraphicPack.cpp @@ -4,31 +4,6 @@ #include "config/ActiveSettings.h" #include "Cafe/GraphicPack/GraphicPack2.h" -typedef struct -{ - int placeholder; -}graphicPack_t; - -// scans the graphic pack directory for shaders -DLLEXPORT void graphicPack_loadGraphicPackShaders(graphicPack_t* gp, wchar_t* graphicPackPath) -{ - // this function is part of the deprecated/removed v1 graphic pack code - // as of Cemuhook 0.5.7.3 this function must exist with a minimum length for detour - // otherwise Cemuhook graphic pack stuff will error out, so we just create some pointless instructions which wont be optimized away - forceLog_printf("STUB1"); - forceLog_printf("STUB2"); - forceLog_printf("STUB3"); -} - -// for cemuhook compatibility only -DLLEXPORT bool config_isGraphicPackEnabled(uint64 id) -{ - forceLog_printf("STUB4"); - forceLog_printf("STUB5"); - forceLog_printf("STUB6"); - return false; -} - /* * Loads the graphic pack if the titleId is referenced in rules.ini */ @@ -149,4 +124,4 @@ void graphicPack_activateForCurrentTitle(uint64 titleId) } } } -} \ No newline at end of file +} diff --git a/src/Cafe/GraphicPack/GraphicPack2.cpp b/src/Cafe/GraphicPack/GraphicPack2.cpp index 0a04b154..4f5b635f 100644 --- a/src/Cafe/GraphicPack/GraphicPack2.cpp +++ b/src/Cafe/GraphicPack/GraphicPack2.cpp @@ -599,23 +599,6 @@ void GraphicPack2::LoadShaders() } } -#pragma optimize( "", off ) - -DLLEXPORT NOINLINE void GraphicPack2_notifyActivate(GraphicPack2* gp, ExpressionParser* ep) -{ - // for Cemuhook - int placeholder = 0xDEADDEAD; -} - -DLLEXPORT NOINLINE void GraphicPack2_notifyDeactivate(GraphicPack2* gp) -{ - // for Cemuhook - int placeholder = 0xDEADDEAD; -} - -#pragma optimize( "", on ) - - bool GraphicPack2::SetActivePreset(std::string_view name) { return SetActivePreset("", name); @@ -862,7 +845,6 @@ bool GraphicPack2::Activate() m_output_settings.downscale_filter = LatteTextureView::MagFilter::kNearestNeighbor; } } - GraphicPack2_notifyActivate(this, &parser); } catch(const std::exception& ex) { @@ -932,7 +914,6 @@ bool GraphicPack2::Deactivate() LatteTiming_disableCustomVsyncFrequency(); } - GraphicPack2_notifyDeactivate(this); return true; } @@ -1149,45 +1130,3 @@ std::vector> GraphicPack2::GetActiveRAMMappings() }); return v; } - -// C-style exports for Cemuhook - -DLLEXPORT const wchar_t* GraphicPack2_GetFilename(GraphicPack2* gp) -{ - return gp->GetFilename().c_str(); -} - -DLLEXPORT const char* GraphicPack2_GetName(GraphicPack2* gp) -{ - if (!gp->HasName()) - return ""; - - return gp->GetName().c_str(); -} - -DLLEXPORT const char* GraphicPack2_GetPath(GraphicPack2* gp) -{ - return gp->GetPath().c_str(); -} - -DLLEXPORT const char* GraphicPack2_GetDescription(GraphicPack2* gp) -{ - return gp->GetDescription().c_str(); -} - -DLLEXPORT const sint32 GraphicPack2_GetTitleIdCount(GraphicPack2* gp) -{ - return gp->GetTitleIds().size(); -} - -DLLEXPORT const uint64* GraphicPack2_GetTitleIdList(GraphicPack2* gp) -{ - return &gp->GetTitleIds()[0]; -} - -DLLEXPORT ExpressionParser* GraphicPack2_CreateExpressionParser(GraphicPack2* gp) -{ - auto ep = new ExpressionParser(); - gp->AddConstantsForCurrentPreset((ExpressionParser&)*ep); - return ep; -} diff --git a/src/Cafe/GraphicPack/GraphicPack2.h b/src/Cafe/GraphicPack/GraphicPack2.h index f038fb64..8eb18766 100644 --- a/src/Cafe/GraphicPack/GraphicPack2.h +++ b/src/Cafe/GraphicPack/GraphicPack2.h @@ -166,8 +166,8 @@ public: static bool DeactivateGraphicPack(const std::shared_ptr& graphic_pack); static void ClearGraphicPacks(); private: - DLLEXPORT bool Activate(); - DLLEXPORT bool Deactivate(); + bool Activate(); + bool Deactivate(); static std::vector> s_graphic_packs; static std::vector> s_active_graphic_packs; @@ -320,4 +320,4 @@ std::vector GraphicPack2::ParseList(const ExpressionParser& parser, IniParser } return result; -} \ No newline at end of file +} diff --git a/src/Cafe/HW/Espresso/Debugger/Debugger.cpp b/src/Cafe/HW/Espresso/Debugger/Debugger.cpp index 51417633..fc015285 100644 --- a/src/Cafe/HW/Espresso/Debugger/Debugger.cpp +++ b/src/Cafe/HW/Espresso/Debugger/Debugger.cpp @@ -8,7 +8,7 @@ #include "Cafe/OS/libs/coreinit/coreinit.h" -#if BOOST_OS_WINDOWS > 0 +#if BOOST_OS_WINDOWS #include #endif @@ -158,7 +158,7 @@ void debugger_updateMemoryBreakpoint(DebuggerBreakpoint* bp) { std::vector schedulerThreadHandles = coreinit::OSGetSchedulerThreads(); -#if BOOST_OS_WINDOWS > 0 +#if BOOST_OS_WINDOWS debuggerState.activeMemoryBreakpoint = bp; for (auto& hThreadNH : schedulerThreadHandles) { diff --git a/src/Cafe/HW/Espresso/PPCScheduler.cpp b/src/Cafe/HW/Espresso/PPCScheduler.cpp index e64b61a2..ab662150 100644 --- a/src/Cafe/HW/Espresso/PPCScheduler.cpp +++ b/src/Cafe/HW/Espresso/PPCScheduler.cpp @@ -100,11 +100,6 @@ PPCInterpreter_t* PPCCore_executeCallbackInternal(uint32 functionMPTR) return hCPU; } -DLLEXPORT void PPCCore_executeCallback(uint32 functionMPTR) -{ - PPCCore_executeCallbackInternal(functionMPTR); -} - void PPCCore_deleteAllThreads() { assert_dbg(); diff --git a/src/Cafe/HW/Espresso/PPCTimer.cpp b/src/Cafe/HW/Espresso/PPCTimer.cpp index 24339b32..281ecd62 100644 --- a/src/Cafe/HW/Espresso/PPCTimer.cpp +++ b/src/Cafe/HW/Espresso/PPCTimer.cpp @@ -5,7 +5,7 @@ #include "util/helpers/fspinlock.h" #include "util/highresolutiontimer/HighResolutionTimer.h" -#if BOOST_OS_LINUX > 0 +#if BOOST_OS_LINUX || BOOST_OS_MACOS static __inline__ uint64 _umul128(uint64 multiplier, uint64 multiplicand, uint64 *highProduct) { unsigned __int128 x = (unsigned __int128)multiplier * (unsigned __int128)multiplicand; @@ -115,7 +115,7 @@ uint64 PPCTimer_microsecondsToTsc(uint64 us) uint64 PPCTimer_tscToMicroseconds(uint64 us) { uint128_t r{}; - #if BOOST_OS_WINDOWS > 0 + #if BOOST_OS_WINDOWS r.low = _umul128(us, 1000000ULL, &r.high); #else r.low = _umul128(us, 1000000ULL, (unsigned long long*)&r.high); @@ -155,7 +155,7 @@ uint64 PPCTimer_getFromRDTSC() rdtscDif = rdtscDif & ~(uint64)((sint64)rdtscDif >> 63); uint128_t diff{}; -#if BOOST_OS_WINDOWS > 0 +#if BOOST_OS_WINDOWS diff.low = _umul128(rdtscDif, Espresso::CORE_CLOCK, &diff.high); #else diff.low = _umul128(rdtscDif, Espresso::CORE_CLOCK, (unsigned long long*)&diff.high); @@ -165,7 +165,7 @@ uint64 PPCTimer_getFromRDTSC() _rdtscLastMeasure = rdtscCurrentMeasure; // only travel forward in time uint8 c = 0; - #if BOOST_OS_WINDOWS > 0 + #if BOOST_OS_WINDOWS c = _addcarry_u64(c, _rdtscAcc.low, diff.low, &_rdtscAcc.low); _addcarry_u64(c, _rdtscAcc.high, diff.high, &_rdtscAcc.high); #else diff --git a/src/Cafe/HW/Espresso/Recompiler/PPCRecompiler.cpp b/src/Cafe/HW/Espresso/Recompiler/PPCRecompiler.cpp index 6b9bb542..83271e8c 100644 --- a/src/Cafe/HW/Espresso/Recompiler/PPCRecompiler.cpp +++ b/src/Cafe/HW/Espresso/Recompiler/PPCRecompiler.cpp @@ -72,7 +72,7 @@ void PPCRecompiler_recompileIfUnvisited(uint32 enterAddress) void PPCRecompiler_enter(PPCInterpreter_t* hCPU, PPCREC_JUMP_ENTRY funcPtr) { -#if BOOST_OS_WINDOWS > 0 +#if BOOST_OS_WINDOWS uint32 prevState = _controlfp(0, 0); _controlfp(_RC_NEAR, _MCW_RC); PPCRecompiler_enterRecompilerCode((uint64)funcPtr, (uint64)hCPU); @@ -374,7 +374,7 @@ struct ppcRecompilerFuncRange_t size_t x86Size; }; -DLLEXPORT bool PPCRecompiler_findFuncRanges(uint32 addr, ppcRecompilerFuncRange_t* rangesOut, size_t* countInOut) +bool PPCRecompiler_findFuncRanges(uint32 addr, ppcRecompilerFuncRange_t* rangesOut, size_t* countInOut) { PPCRecompilerState.recompilerSpinlock.acquire(); size_t countIn = *countInOut; @@ -399,7 +399,7 @@ DLLEXPORT bool PPCRecompiler_findFuncRanges(uint32 addr, ppcRecompilerFuncRange_ return true; } -DLLEXPORT uintptr_t* PPCRecompiler_getJumpTableBase() +extern "C" DLLEXPORT uintptr_t * PPCRecompiler_getJumpTableBase() { if (ppcRecompilerInstanceData == nullptr) return nullptr; @@ -431,7 +431,7 @@ void PPCRecompiler_deleteFunction(PPCRecFunction_t* func) // todo - free x86 code } -DLLEXPORT void PPCRecompiler_invalidateRange(uint32 startAddr, uint32 endAddr) +void PPCRecompiler_invalidateRange(uint32 startAddr, uint32 endAddr) { if (ppcRecompilerEnabled == false) return; diff --git a/src/Cafe/HW/Espresso/Recompiler/PPCRecompiler.h b/src/Cafe/HW/Espresso/Recompiler/PPCRecompiler.h index a87d53a4..7a74749d 100644 --- a/src/Cafe/HW/Espresso/Recompiler/PPCRecompiler.h +++ b/src/Cafe/HW/Espresso/Recompiler/PPCRecompiler.h @@ -369,14 +369,14 @@ typedef struct uint32 _x64XMM_mxCsr_ftzOff; }PPCRecompilerInstanceData_t; -extern DLLEXPORT PPCRecompilerInstanceData_t* ppcRecompilerInstanceData; +extern PPCRecompilerInstanceData_t* ppcRecompilerInstanceData; extern bool ppcRecompilerEnabled; -DLLEXPORT void PPCRecompiler_init(); +void PPCRecompiler_init(); void PPCRecompiler_allocateRange(uint32 startAddress, uint32 size); -DLLEXPORT void PPCRecompiler_invalidateRange(uint32 startAddr, uint32 endAddr); +void PPCRecompiler_invalidateRange(uint32 startAddr, uint32 endAddr); extern void ATTR_MS_ABI (*PPCRecompiler_enterRecompilerCode)(uint64 codeMem, uint64 ppcInterpreterInstance); extern void ATTR_MS_ABI (*PPCRecompiler_leaveRecompilerCode_visited)(); @@ -385,10 +385,10 @@ extern void ATTR_MS_ABI (*PPCRecompiler_leaveRecompilerCode_unvisited)(); #define PPC_REC_INVALID_FUNCTION ((PPCRecFunction_t*)-1) // CPUID -extern DLLEXPORT bool hasLZCNTSupport; -extern DLLEXPORT bool hasMOVBESupport; -extern DLLEXPORT bool hasBMI2Support; -extern DLLEXPORT bool hasAVXSupport; +extern bool hasLZCNTSupport; +extern bool hasMOVBESupport; +extern bool hasBMI2Support; +extern bool hasAVXSupport; // todo - move some of the stuff above into PPCRecompilerInternal.h @@ -396,4 +396,4 @@ extern DLLEXPORT bool hasAVXSupport; void PPCRecompiler_recompileIfUnvisited(uint32 enterAddress); void PPCRecompiler_attemptEnter(struct PPCInterpreter_t* hCPU, uint32 enterAddress); -void PPCRecompiler_attemptEnterWithoutRecompile(struct PPCInterpreter_t* hCPU, uint32 enterAddress); \ No newline at end of file +void PPCRecompiler_attemptEnterWithoutRecompile(struct PPCInterpreter_t* hCPU, uint32 enterAddress); diff --git a/src/Cafe/HW/Latte/Core/LatteIndices.cpp b/src/Cafe/HW/Latte/Core/LatteIndices.cpp index 2ffd1d0a..7edaad00 100644 --- a/src/Cafe/HW/Latte/Core/LatteIndices.cpp +++ b/src/Cafe/HW/Latte/Core/LatteIndices.cpp @@ -284,7 +284,7 @@ void LatteIndices_generateAutoLineLoopIndices(void* indexDataOutput, uint32 coun indexMax = std::max(count, 1u) - 1; } -#if BOOST_OS_LINUX +#if BOOST_OS_LINUX || BOOST_OS_MACOS #pragma clang attribute push (__attribute__((target("avx2"))), apply_to=function) #endif @@ -352,11 +352,11 @@ void LatteIndices_fastConvertU16_AVX2(const void* indexDataInput, void* indexDat indexMin = std::min(indexMin, _minIndex); } -#if BOOST_OS_LINUX +#if BOOST_OS_LINUX || BOOST_OS_MACOS #pragma clang attribute pop #endif -#if BOOST_OS_LINUX +#if BOOST_OS_LINUX || BOOST_OS_MACOS #pragma clang attribute push (__attribute__((target("avx2"))), apply_to=function) #endif @@ -423,11 +423,11 @@ void LatteIndices_fastConvertU16_SSE41(const void* indexDataInput, void* indexDa indexMin = std::min(indexMin, _minIndex); } -#if BOOST_OS_LINUX +#if BOOST_OS_LINUX || BOOST_OS_MACOS #pragma clang attribute pop #endif -#if BOOST_OS_LINUX +#if BOOST_OS_LINUX || BOOST_OS_MACOS #pragma clang attribute push (__attribute__((target("avx2"))), apply_to=function) #endif @@ -497,7 +497,7 @@ void LatteIndices_fastConvertU32_AVX2(const void* indexDataInput, void* indexDat indexMin = std::min(indexMin, _minIndex); } -#if BOOST_OS_LINUX +#if BOOST_OS_LINUX || BOOST_OS_MACOS #pragma clang attribute pop #endif diff --git a/src/Cafe/HW/Latte/Core/LatteRenderTarget.cpp b/src/Cafe/HW/Latte/Core/LatteRenderTarget.cpp index 52a6f040..84183cbc 100644 --- a/src/Cafe/HW/Latte/Core/LatteRenderTarget.cpp +++ b/src/Cafe/HW/Latte/Core/LatteRenderTarget.cpp @@ -1003,7 +1003,7 @@ void LatteRenderTarget_copyToBackbuffer(LatteTextureView* textureView, bool isPa g_renderer->ImguiEnd(); } -bool DLLEXPORT alwaysDisplayDRC = false; +bool alwaysDisplayDRC = false; bool ctrlTabHotkeyPressed = false; void LatteRenderTarget_itHLECopyColorBufferToScanBuffer(MPTR colorBufferPtr, uint32 colorBufferWidth, uint32 colorBufferHeight, uint32 colorBufferSliceIndex, uint32 colorBufferFormat, uint32 colorBufferPitch, Latte::E_HWTILEMODE colorBufferTilemode, uint32 colorBufferSwizzle, uint32 renderTarget) diff --git a/src/Cafe/HW/Latte/Core/LatteShaderCache.cpp b/src/Cafe/HW/Latte/Core/LatteShaderCache.cpp index 3bc6699b..fe1388f0 100644 --- a/src/Cafe/HW/Latte/Core/LatteShaderCache.cpp +++ b/src/Cafe/HW/Latte/Core/LatteShaderCache.cpp @@ -27,7 +27,7 @@ #include -#if BOOST_OS_WINDOWS > 0 +#if BOOST_OS_WINDOWS #include #endif @@ -189,7 +189,7 @@ void LatteShaderCache_load() const auto timeLoadStart = now_cached(); // remember current amount of committed memory -#if BOOST_OS_WINDOWS > 0 +#if BOOST_OS_WINDOWS PROCESS_MEMORY_COUNTERS pmc1; GetProcessMemoryInfo(GetCurrentProcess(), &pmc1, sizeof(PROCESS_MEMORY_COUNTERS)); LONGLONG totalMem1 = pmc1.PagefileUsage; @@ -285,7 +285,7 @@ void LatteShaderCache_load() LatteShaderCache_updateCompileQueue(0); // write load time and RAM usage to log file (in dev build) -#if BOOST_OS_WINDOWS > 0 +#if BOOST_OS_WINDOWS const auto timeLoadEnd = now_cached(); const auto timeLoad = std::chrono::duration_cast(timeLoadEnd - timeLoadStart).count(); PROCESS_MEMORY_COUNTERS pmc2; @@ -432,7 +432,7 @@ void LatteShaderCache_ShowProgress(const std::function & loadUpdateF } ImGui::SetCursorPosX(width - ImGui::CalcTextSize(text.c_str()).x / 2); - ImGui::Text(text.c_str()); + ImGui::Text("%s", text.c_str()); float percentLoaded; if(isPipelines) @@ -446,7 +446,7 @@ void LatteShaderCache_ShowProgress(const std::function & loadUpdateF else text = fmt::format("{}/{} ({}%%)", g_shaderCacheLoaderState.loadedShaderFiles, g_shaderCacheLoaderState.shaderFileCount, (int)(percentLoaded * 100)); ImGui::SetCursorPosX(width - ImGui::CalcTextSize(text.c_str()).x / 2); - ImGui::Text(text.c_str()); + ImGui::Text("%s", text.c_str()); ImGui::End(); } ImGui::PopFont(); @@ -775,4 +775,4 @@ void LatteShaderCache_handleDeprecatedCacheFiles(fs::path pathGeneric, fs::path fs::remove(pathGenericPre1_25_0, ec); } } -} \ No newline at end of file +} diff --git a/src/Cafe/HW/Latte/Core/LatteTextureCache.cpp b/src/Cafe/HW/Latte/Core/LatteTextureCache.cpp index 8ec54c05..9016a9ae 100644 --- a/src/Cafe/HW/Latte/Core/LatteTextureCache.cpp +++ b/src/Cafe/HW/Latte/Core/LatteTextureCache.cpp @@ -145,7 +145,7 @@ uint32 LatteTexture_CalculateTextureDataHash(LatteTexture* hostTexture) bool isCompressedFormat = hostTexture->IsCompressedFormat(); if( isCompressedFormat == false ) { - #if BOOST_OS_WINDOWS > 0 + #if BOOST_OS_WINDOWS if (_cpuExtension_AVX2) { __m256i h256 = { 0 }; @@ -426,11 +426,3 @@ void LatteTC_UnloadAllTextures() } LatteRenderTarget_unloadAll(); } - -/* - * Asynchronous way to invalidate textures - */ -DLLEXPORT void gpu7Texture_forceInvalidateByImagePtr(MPTR imagePtr) -{ - // deprecated. Texture cache heuristics are now good enough to detect moving frames -} diff --git a/src/Cafe/HW/Latte/LatteAddrLib/LatteAddrLib_Coord.cpp b/src/Cafe/HW/Latte/LatteAddrLib/LatteAddrLib_Coord.cpp index 8dc69b57..bc43202a 100644 --- a/src/Cafe/HW/Latte/LatteAddrLib/LatteAddrLib_Coord.cpp +++ b/src/Cafe/HW/Latte/LatteAddrLib/LatteAddrLib_Coord.cpp @@ -7,7 +7,7 @@ using namespace Latte; namespace LatteAddrLib { -#if BOOST_OS_LINUX +#if BOOST_OS_LINUX || BOOST_OS_MACOS unsigned char _BitScanReverse(uint32* _Index, uint32 _Mask) { if (!_Mask) diff --git a/src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLRenderer.cpp b/src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLRenderer.cpp index 548e4923..7f7d1b84 100644 --- a/src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLRenderer.cpp +++ b/src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLRenderer.cpp @@ -95,7 +95,7 @@ OpenGLRenderer::OpenGLRenderer() glRendererState.uploadIndex = 0; } -#if BOOST_OS_WINDOWS > 0 +#if BOOST_OS_WINDOWS try { m_dxgi_wrapper = std::make_unique(); @@ -191,7 +191,7 @@ void OpenGLRenderer::DeleteFontTextures() typedef void(*GL_IMPORT)(); -#if BOOST_OS_WINDOWS > 0 +#if BOOST_OS_WINDOWS GL_IMPORT _GetOpenGLFunction(HMODULE hLib, const char* name) { GL_IMPORT r = (GL_IMPORT)wglGetProcAddress(name); @@ -207,7 +207,7 @@ void LoadOpenGLImports() #include "Common/GLInclude/glFunctions.h" #undef GLFUNC } -#else +#elif BOOST_OS_LINUX GL_IMPORT _GetOpenGLFunction(void* hLib, PFNGLXGETPROCADDRESSPROC func, const char* name) { GL_IMPORT r = (GL_IMPORT)func((const GLubyte*)name); @@ -233,6 +233,11 @@ void LoadOpenGLImports() #include "Common/GLInclude/glFunctions.h" #undef GLFUNC } +#elif BOOST_OS_MACOS +void LoadOpenGLImports() +{ + cemu_assert_unimplemented(); +} #endif void OpenGLRenderer::Initialize() @@ -244,7 +249,7 @@ void OpenGLRenderer::Initialize() LoadOpenGLImports(); GetVendorInformation(); -#if BOOST_OS_WINDOWS > 0 +#if BOOST_OS_WINDOWS if (wglSwapIntervalEXT) wglSwapIntervalEXT(0); // disable V-Sync per default #endif @@ -349,7 +354,7 @@ void OpenGLRenderer::NotifyLatteCommandProcessorIdle() void OpenGLRenderer::EnableVSync(int state) { -#if BOOST_OS_WINDOWS > 0 +#if BOOST_OS_WINDOWS if(wglSwapIntervalEXT) wglSwapIntervalEXT(state); // 1 = enabled, 0 = disabled #else diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VKRMemoryManager.cpp b/src/Cafe/HW/Latte/Renderer/Vulkan/VKRMemoryManager.cpp index 93021fd8..95a04315 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VKRMemoryManager.cpp +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VKRMemoryManager.cpp @@ -531,6 +531,6 @@ void VKRMemoryManager::appendOverlayHeapDebugInfo() uint32 heapSizeMB = (heapSize / 1024 / 1024); uint32 allocatedBytesMB = (allocatedBytes / 1024 / 1024); - ImGui::Text(fmt::format("{0:#08x} Size: {1}MB/{2}MB", itr.first, allocatedBytesMB, heapSizeMB).c_str()); + ImGui::Text("%s", fmt::format("{0:#08x} Size: {1}MB/{2}MB", itr.first, allocatedBytesMB, heapSizeMB).c_str()); } -} \ No newline at end of file +} diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanAPI.cpp b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanAPI.cpp index c657cba7..a60720d1 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanAPI.cpp +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanAPI.cpp @@ -2,7 +2,7 @@ #define VKFUNC_DEFINE #include "Cafe/HW/Latte/Renderer/Vulkan/VulkanAPI.h" -#if BOOST_OS_LINUX +#if BOOST_OS_LINUX || BOOST_OS_MACOS #include #endif diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp index 56e8888c..4e6632ab 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp @@ -104,7 +104,7 @@ std::vector VulkanRenderer::GetDevices() requiredExtensions.emplace_back(VK_KHR_SURFACE_EXTENSION_NAME); #if BOOST_OS_WINDOWS requiredExtensions.emplace_back(VK_KHR_WIN32_SURFACE_EXTENSION_NAME); - #else + #elif BOOST_OS_LINUX requiredExtensions.emplace_back(VK_KHR_XLIB_SURFACE_EXTENSION_NAME); #endif @@ -1143,7 +1143,7 @@ std::vector VulkanRenderer::CheckInstanceExtensionSupport(FeatureCo requiredInstanceExtensions.emplace_back(VK_KHR_SURFACE_EXTENSION_NAME); #if BOOST_OS_WINDOWS requiredInstanceExtensions.emplace_back(VK_KHR_WIN32_SURFACE_EXTENSION_NAME); - #else + #elif BOOST_OS_LINUX requiredInstanceExtensions.emplace_back(VK_KHR_XLIB_SURFACE_EXTENSION_NAME); #endif if (cafeLog_isLoggingFlagEnabled(LOG_TYPE_VULKAN_VALIDATION)) @@ -1319,8 +1319,11 @@ VkSurfaceKHR VulkanRenderer::CreateFramebufferSurface(VkInstance instance, struc { #if BOOST_OS_WINDOWS return CreateWinSurface(instance, windowInfo.hwnd); -#else +#elif BOOST_OS_LINUX return CreateXlibSurface(instance, windowInfo.xlib_display, windowInfo.xlib_window); +#elif BOOST_OS_MACOS + cemu_assert_unimplemented(); + return nullptr; #endif } diff --git a/src/Cafe/HW/MMU/MMU.cpp b/src/Cafe/HW/MMU/MMU.cpp index 1d746d68..cf86206d 100644 --- a/src/Cafe/HW/MMU/MMU.cpp +++ b/src/Cafe/HW/MMU/MMU.cpp @@ -389,7 +389,7 @@ uint8 memory_readU8(uint32 address) return *(uint8*)(memory_getPointerFromVirtualOffset(address)); } -DLLEXPORT void* memory_getBase() +extern "C" DLLEXPORT void* memory_getBase() { return memory_base; } @@ -533,4 +533,4 @@ namespace MMU } -} \ No newline at end of file +} diff --git a/src/Cafe/HW/MMU/MMU.h b/src/Cafe/HW/MMU/MMU.h index 5169ef7e..0e27d81a 100644 --- a/src/Cafe/HW/MMU/MMU.h +++ b/src/Cafe/HW/MMU/MMU.h @@ -1,6 +1,6 @@ #pragma once -DLLEXPORT void memory_init(); +void memory_init(); void memory_mapForCurrentTitle(); void memory_logModifiedMemoryRanges(); @@ -201,6 +201,9 @@ static uint16 CPU_swapEndianU16(uint16 v) #elif BOOST_OS_LINUX #define CPU_swapEndianU64(_v) bswap_64((uint64)(_v)) #define CPU_swapEndianU32(_v) bswap_32((uint32)(_v)) +#elif BOOST_OS_MACOS +#define CPU_swapEndianU64(_v) OSSwapInt64((uint64)(_v)) +#define CPU_swapEndianU32(_v) OSSwapInt32((uint32)(_v)) #endif // direct memory access (no hardware interface access) diff --git a/src/Cafe/IOSU/PDM/iosu_pdm.cpp b/src/Cafe/IOSU/PDM/iosu_pdm.cpp index 57e2c61d..626eba40 100644 --- a/src/Cafe/IOSU/PDM/iosu_pdm.cpp +++ b/src/Cafe/IOSU/PDM/iosu_pdm.cpp @@ -6,7 +6,7 @@ #if BOOST_OS_LINUX // using chrono::year_month_date and other features require a relatively recent stdlibc++ // to avoid upping the required version we use the STL reference implementation for now -#include "Common/linux/date.h" +#include "Common/unix/date.h" namespace chrono_d = date; #else namespace chrono_d = std::chrono; @@ -373,4 +373,4 @@ namespace iosu } }; -}; \ No newline at end of file +}; diff --git a/src/Cafe/OS/RPL/rpl.cpp b/src/Cafe/OS/RPL/rpl.cpp index cf17a42c..82edbb85 100644 --- a/src/Cafe/OS/RPL/rpl.cpp +++ b/src/Cafe/OS/RPL/rpl.cpp @@ -46,8 +46,8 @@ ChunkedFlatAllocator<64 * 1024> g_heapTrampolineArea; std::vector rplDependencyList = std::vector(); -DLLEXPORT RPLModule* rplModuleList[256]; -DLLEXPORT sint32 rplModuleCount = 0; +RPLModule* rplModuleList[256]; +sint32 rplModuleCount = 0; uint32 _currentTLSModuleIndex = 1; // value 0 is reserved diff --git a/src/Cafe/OS/RPL/rpl.h b/src/Cafe/OS/RPL/rpl.h index 8be6d9af..7933e5d3 100644 --- a/src/Cafe/OS/RPL/rpl.h +++ b/src/Cafe/OS/RPL/rpl.h @@ -14,7 +14,7 @@ MPTR RPLLoader_AllocateCodeSpace(uint32 size, uint32 alignment); uint32 RPLLoader_GetMaxCodeOffset(); uint32 RPLLoader_GetDataAllocatorAddr(); -DLLEXPORT RPLModule* rpl_loadFromMem(uint8* rplData, sint32 size, char* name); +RPLModule* rpl_loadFromMem(uint8* rplData, sint32 size, char* name); uint32 rpl_mapHLEImport(RPLModule* rplLoaderContext, const char* rplName, const char* funcName, bool functionMustExist); void RPLLoader_Link(); diff --git a/src/Cafe/OS/common/OSCommon.cpp b/src/Cafe/OS/common/OSCommon.cpp index 77f1fa6d..b41ab865 100644 --- a/src/Cafe/OS/common/OSCommon.cpp +++ b/src/Cafe/OS/common/OSCommon.cpp @@ -99,7 +99,7 @@ void osLib_addFunctionInternal(const char* libraryName, const char* functionName s_osFunctionTable->emplace_back(libHashA, libHashB, funcHashA, funcHashB, fmt::format("{}.{}", libraryName, functionName), PPCInterpreter_registerHLECall(osFunction)); } -DLLEXPORT void osLib_registerHLEFunction(const char* libraryName, const char* functionName, void(*osFunction)(PPCInterpreter_t* hCPU)) +extern "C" DLLEXPORT void osLib_registerHLEFunction(const char* libraryName, const char* functionName, void(*osFunction)(PPCInterpreter_t * hCPU)) { osLib_addFunctionInternal(libraryName, functionName, osFunction); } @@ -217,4 +217,4 @@ void osLib_load() swkbd::load(); camera::load(); procui_load(); -} \ No newline at end of file +} diff --git a/src/Cafe/OS/libs/coreinit/coreinit_Init.cpp b/src/Cafe/OS/libs/coreinit/coreinit_Init.cpp index 4cedc7fb..9bb49741 100644 --- a/src/Cafe/OS/libs/coreinit/coreinit_Init.cpp +++ b/src/Cafe/OS/libs/coreinit/coreinit_Init.cpp @@ -78,7 +78,7 @@ void CafeInit() rpxPathStart = 0; } - std::string_view rpxFileName = std::basic_string_view(_pathToExecutable.data() + rpxPathStart, _pathToExecutable.data() + _pathToExecutable.size()); + std::string_view rpxFileName(_pathToExecutable.data() + rpxPathStart, _pathToExecutable.size() - rpxPathStart); argStorageIndex = 0; _coreinitInfo->argc = 0; diff --git a/src/Cafe/OS/libs/coreinit/coreinit_MCP.cpp b/src/Cafe/OS/libs/coreinit/coreinit_MCP.cpp index fbc42683..f4080a23 100644 --- a/src/Cafe/OS/libs/coreinit/coreinit_MCP.cpp +++ b/src/Cafe/OS/libs/coreinit/coreinit_MCP.cpp @@ -424,7 +424,7 @@ typedef struct static_assert(sizeof(UCParamStruct_t) == 0x54); // unsure -#if BOOST_OS_LINUX +#if BOOST_OS_LINUX || BOOST_OS_MACOS #define _strcmpi strcasecmp #endif diff --git a/src/Cafe/OS/libs/coreinit/coreinit_MEM.cpp b/src/Cafe/OS/libs/coreinit/coreinit_MEM.cpp index e1904f72..a9f9f3a8 100644 --- a/src/Cafe/OS/libs/coreinit/coreinit_MEM.cpp +++ b/src/Cafe/OS/libs/coreinit/coreinit_MEM.cpp @@ -538,7 +538,6 @@ namespace coreinit void coreinitExport_MEMAllocFromAllocator(PPCInterpreter_t* hCPU) { - debug_printf("MEMAllocFromAllocator(0x%x, 0x%x)\n", hCPU->gpr[3], hCPU->gpr[4]); MEMAllocator* memAllocator = (MEMAllocator*)memory_getPointerFromVirtualOffset(hCPU->gpr[3]); // redirect execution to allocator alloc callback hCPU->instructionPointer = memAllocator->func->funcAlloc.GetMPTR(); @@ -546,7 +545,6 @@ namespace coreinit void coreinitExport_MEMFreeToAllocator(PPCInterpreter_t* hCPU) { - debug_printf("MEMFreeToAllocator(0x%x, 0x%08x)\n", hCPU->gpr[3], hCPU->gpr[4]); MEMAllocator* memAllocator = (MEMAllocator*)memory_getPointerFromVirtualOffset(hCPU->gpr[3]); // redirect execution to allocator free callback hCPU->instructionPointer = memAllocator->func->funcFree.GetMPTR(); @@ -568,11 +566,10 @@ namespace coreinit void coreinitExport_MEMInitAllocatorForDefaultHeap(PPCInterpreter_t* hCPU) { - debug_printf("MEMInitAllocatorForDefaultHeap(0x%08x)", hCPU->gpr[3]); ppcDefineParamStructPtr(memAllocator, MEMAllocator, 0); - gDefaultHeapAllocator->funcAlloc = _swapEndianU32(PPCInterpreter_makeCallableExportDepr(_DefaultHeapAllocator_Alloc)); - gDefaultHeapAllocator->funcFree = _swapEndianU32(PPCInterpreter_makeCallableExportDepr(_DefaultHeapAllocator_Free)); + gDefaultHeapAllocator->funcAlloc = PPCInterpreter_makeCallableExportDepr(_DefaultHeapAllocator_Alloc); + gDefaultHeapAllocator->funcFree = PPCInterpreter_makeCallableExportDepr(_DefaultHeapAllocator_Free); memAllocator->func = gDefaultHeapAllocator.GetPtr(); memAllocator->heap = MEMPTR(MEMGetBaseHeapHandle(1)); diff --git a/src/Cafe/OS/libs/coreinit/coreinit_MEM_ExpHeap.cpp b/src/Cafe/OS/libs/coreinit/coreinit_MEM_ExpHeap.cpp index fe221717..c587b879 100644 --- a/src/Cafe/OS/libs/coreinit/coreinit_MEM_ExpHeap.cpp +++ b/src/Cafe/OS/libs/coreinit/coreinit_MEM_ExpHeap.cpp @@ -831,8 +831,8 @@ SysAllocator gExpHeapDefaultAllocator; void MEMInitAllocatorForExpHeap(MEMAllocator* allocator, MEMHeapHandle heap, sint32 alignment) { allocator->func = gExpHeapDefaultAllocator.GetPtr(); - gExpHeapDefaultAllocator->funcAlloc = _swapEndianU32(PPCInterpreter_makeCallableExportDepr(_DefaultAllocatorForExpHeap_Alloc)); - gExpHeapDefaultAllocator->funcFree = _swapEndianU32(PPCInterpreter_makeCallableExportDepr(_DefaultAllocatorForExpHeap_Free)); + gExpHeapDefaultAllocator->funcAlloc = PPCInterpreter_makeCallableExportDepr(_DefaultAllocatorForExpHeap_Alloc); + gExpHeapDefaultAllocator->funcFree = PPCInterpreter_makeCallableExportDepr(_DefaultAllocatorForExpHeap_Free); allocator->heap = heap; allocator->param1 = alignment; diff --git a/src/Cafe/OS/libs/coreinit/coreinit_MEM_FrmHeap.cpp b/src/Cafe/OS/libs/coreinit/coreinit_MEM_FrmHeap.cpp index 88c52901..b33feb4b 100644 --- a/src/Cafe/OS/libs/coreinit/coreinit_MEM_FrmHeap.cpp +++ b/src/Cafe/OS/libs/coreinit/coreinit_MEM_FrmHeap.cpp @@ -63,7 +63,8 @@ namespace coreinit bool negativeAlignment = alignment < 0; if (negativeAlignment) alignment = -alignment; - if (!std::has_single_bit((uint32)alignment)) + uint32 bits = (uint32)alignment; + if (bits == 0 || (bits & (bits - 1)) != 0) { cemuLog_log(LogType::APIErrors, "MEMGetAllocatableSizeForFrmHeapEx(): Invalid alignment"); return 0; diff --git a/src/Cafe/OS/libs/coreinit/coreinit_Time.cpp b/src/Cafe/OS/libs/coreinit/coreinit_Time.cpp index fd51f81e..6176ccca 100644 --- a/src/Cafe/OS/libs/coreinit/coreinit_Time.cpp +++ b/src/Cafe/OS/libs/coreinit/coreinit_Time.cpp @@ -366,7 +366,7 @@ namespace coreinit void InitializeTimeAndCalendar() { osLib_addFunction("coreinit", "OSGetTime", export_OSGetTime); - osLib_addFunction("coreinit", "OSGetSystemTime", export_OSGetSystemTimeDummy); // register dummy HLE function to get Cemuhook to patch our dummy instead of the real function + osLib_addFunction("coreinit", "OSGetSystemTime", export_OSGetSystemTimeDummy); osLib_addFunction("coreinit", "OSGetTick", export_OSGetTick); cafeExportRegister("coreinit", OSTicksToCalendarTime, LogType::Placeholder); diff --git a/src/Cafe/OS/libs/nlibcurl/nlibcurl.cpp b/src/Cafe/OS/libs/nlibcurl/nlibcurl.cpp index 5e9f8b51..4923eae2 100644 --- a/src/Cafe/OS/libs/nlibcurl/nlibcurl.cpp +++ b/src/Cafe/OS/libs/nlibcurl/nlibcurl.cpp @@ -455,7 +455,7 @@ void export_curl_multi_fdset(PPCInterpreter_t* hCPU) ppcDefineParamMEMPTR(exceptionFd, wu_fd_set, 3); ppcDefineParamU32BEPtr(maxFd, 4); -#if BOOST_OS_LINUX > 0 +#if BOOST_OS_LINUX || BOOST_OS_MACOS cemuLog_log(LogType::Force, "curl_multi_fdset(...) - todo"); osLib_returnFromFunction(hCPU, 0); diff --git a/src/Cafe/OS/libs/nn_save/nn_save.cpp b/src/Cafe/OS/libs/nn_save/nn_save.cpp index 64bbdc2f..a0a8ff7b 100644 --- a/src/Cafe/OS/libs/nn_save/nn_save.cpp +++ b/src/Cafe/OS/libs/nn_save/nn_save.cpp @@ -242,7 +242,7 @@ namespace save } catch (const std::exception& ex) { -#if BOOST_OS_WINDOWS > 0 +#if BOOST_OS_WINDOWS std::wstringstream errorMsg; errorMsg << L"Couldn't move your save files!" << std::endl << std::endl; errorMsg << L"Error: " << ex.what() << std::endl << std::endl; diff --git a/src/Cafe/OS/libs/nsyshid/nsyshid.cpp b/src/Cafe/OS/libs/nsyshid/nsyshid.cpp index 4789d3e4..d43b486e 100644 --- a/src/Cafe/OS/libs/nsyshid/nsyshid.cpp +++ b/src/Cafe/OS/libs/nsyshid/nsyshid.cpp @@ -3,7 +3,7 @@ #include #include "nsyshid.h" -#if BOOST_OS_WINDOWS > 0 +#if BOOST_OS_WINDOWS #include #include diff --git a/src/Cafe/OS/libs/nsysnet/nsysnet.cpp b/src/Cafe/OS/libs/nsysnet/nsysnet.cpp index 0a01ca3e..b49d2e80 100644 --- a/src/Cafe/OS/libs/nsysnet/nsysnet.cpp +++ b/src/Cafe/OS/libs/nsysnet/nsysnet.cpp @@ -6,7 +6,7 @@ #include "Common/socket.h" -#if BOOST_OS_WINDOWS > 0 +#if BOOST_OS_WINDOWS #define WU_AF_INET 2 @@ -2085,7 +2085,7 @@ void nsysnet_load() osLib_addFunction("nsysnet", "NSSLExportInternalClientCertificate", nsysnet::export_NSSLExportInternalClientCertificate); } -#if BOOST_OS_LINUX +#if BOOST_OS_LINUX || BOOST_OS_MACOS void nsysnet_notifyCloseSharedSocket(SOCKET existingSocket) { diff --git a/src/Cafe/OS/libs/nsysnet/nsysnet.h b/src/Cafe/OS/libs/nsysnet/nsysnet.h index bb0ad2b0..fa2f2ca4 100644 --- a/src/Cafe/OS/libs/nsysnet/nsysnet.h +++ b/src/Cafe/OS/libs/nsysnet/nsysnet.h @@ -2,7 +2,7 @@ #include #include -#if BOOST_OS_WINDOWS > 0 +#if BOOST_OS_WINDOWS #include #else #include diff --git a/src/Cafe/OS/libs/swkbd/swkbd.cpp b/src/Cafe/OS/libs/swkbd/swkbd.cpp index 1a09ec58..b7ad80f4 100644 --- a/src/Cafe/OS/libs/swkbd/swkbd.cpp +++ b/src/Cafe/OS/libs/swkbd/swkbd.cpp @@ -390,7 +390,7 @@ void swkbd_render(bool mainWindow) ImGui::PushFont(font); if (ImGui::Begin("Keyboard Input", nullptr, kPopupFlags)) { - ImGui::Text(_utf8WrapperPtr(ICON_FA_KEYBOARD)); + ImGui::Text("%s", _utf8WrapperPtr(ICON_FA_KEYBOARD)); ImGui::SameLine(70); auto text = boost::nowide::narrow(fmt::format(L"{}", swkbdInternalState->formStringBuffer)); @@ -647,4 +647,4 @@ namespace swkbd osLib_addFunction("swkbd", "SwkbdIsNeedCalcSubThreadFont__3RplFv", swkbdExport_SwkbdIsNeedCalcSubThreadFont); osLib_addFunction("swkbd", "SwkbdIsNeedCalcSubThreadPredict__3RplFv", swkbdExport_SwkbdIsNeedCalcSubThreadPredict); } -} \ No newline at end of file +} diff --git a/src/Cemu/ExpressionParser/ExpressionParser.cpp b/src/Cemu/ExpressionParser/ExpressionParser.cpp index 74729339..90e3f4cd 100644 --- a/src/Cemu/ExpressionParser/ExpressionParser.cpp +++ b/src/Cemu/ExpressionParser/ExpressionParser.cpp @@ -43,49 +43,4 @@ void ExpressionParser_test() cemu_assert_debug(_testEvaluateToType("5 > 4 > 3 > 2") == 0.0f); // this should evaluate the operations from left to right, (5 > 4) -> 0.0, (0.0 > 4) -> 0.0, (0.0 > 3) -> 0.0, (0.0 > 2) -> 0.0 cemu_assert_debug(_testEvaluateToType("5 > 4 > 3 > -2") == 1.0f); // this should evaluate the operations from left to right, (5 > 4) -> 0.0, (0.0 > 4) -> 0.0, (0.0 > 3) -> 0.0, (0.0 > -2) -> 1.0 cemu_assert_debug(_testEvaluateToType("(5 == 5) > (5 == 6)") == 1.0f); -} - -// Cemuhook exports - -DLLEXPORT ExpressionParser* ExpressionParser_Create() -{ - return new ExpressionParser(); -} - -DLLEXPORT ExpressionParser* ExpressionParser_CreateCopy(ExpressionParser* ep) -{ - return new ExpressionParser((ExpressionParser&)*ep); -} - -DLLEXPORT void ExpressionParser_Delete(ExpressionParser* ep) -{ - delete ep; -} - -DLLEXPORT void ExpressionParser_AddConstantDouble(ExpressionParser* ep, const char* name, double value) -{ - ep->AddConstant(name, value); -} - -DLLEXPORT void ExpressionParser_AddConstantString(ExpressionParser* ep, const char* name, const char* value) -{ - ep->AddConstant(name, value); -} - -DLLEXPORT bool ExpressionParser_EvaluateToDouble(ExpressionParser* ep, const char* expression, double* result) -{ - try - { - const double temp = ep->Evaluate(std::string(expression)); - if (result) - *result = temp; - - return true; - } - catch (const std::exception& ex) - { - if( result ) - forceLog_printf("Unable to evaluate expression: %s", ex.what()); - return false; - } } \ No newline at end of file diff --git a/src/Cemu/ExpressionParser/ExpressionParser.h b/src/Cemu/ExpressionParser/ExpressionParser.h index 5f7bf406..ab14dc5d 100644 --- a/src/Cemu/ExpressionParser/ExpressionParser.h +++ b/src/Cemu/ExpressionParser/ExpressionParser.h @@ -12,7 +12,7 @@ #include #ifdef __clang__ -#include "Common/linux/fast_float.h" +#include "Common/unix/fast_float.h" #define _EP_FROM_CHARS_DBL(...) _convFastFloatResult(fast_float::from_chars(__VA_ARGS__)) inline std::from_chars_result _convFastFloatResult(fast_float::from_chars_result r) diff --git a/src/Cemu/Logging/CemuLogging.cpp b/src/Cemu/Logging/CemuLogging.cpp index fb9b8a57..f58e7984 100644 --- a/src/Cemu/Logging/CemuLogging.cpp +++ b/src/Cemu/Logging/CemuLogging.cpp @@ -200,7 +200,7 @@ void cafeLog_log(uint32 type, const char* format, ...) char logTempStr[2048]; va_list(args); va_start(args, format); -#if BOOST_OS_WINDOWS > 0 +#if BOOST_OS_WINDOWS vsprintf_s(logTempStr, format, args); #else vsprintf(logTempStr, format, args); @@ -226,7 +226,7 @@ void cafeLog_logW(uint32 type, const wchar_t* format, ...) wchar_t logTempStr[2048]; va_list(args); va_start(args, format); -#if BOOST_OS_WINDOWS > 0 +#if BOOST_OS_WINDOWS vswprintf_s(logTempStr, format, args); #else vswprintf(logTempStr, 2048, format, args); @@ -243,7 +243,7 @@ void cafeLog_logW(uint32 type, const wchar_t* format, ...) LoggingWindow::Log(it->second, logTempStr); } -DLLEXPORT void cemuLog_log() +void cemuLog_log() { typedef void(*VoidFunc)(); const VoidFunc func = (VoidFunc)cafeLog_log; diff --git a/src/Cemu/PPCAssembler/ppcAssembler.cpp b/src/Cemu/PPCAssembler/ppcAssembler.cpp index 647d683d..c8c28191 100644 --- a/src/Cemu/PPCAssembler/ppcAssembler.cpp +++ b/src/Cemu/PPCAssembler/ppcAssembler.cpp @@ -628,7 +628,7 @@ public: ppcAssembler_setError(assemblerCtx->ctx, fmt::format("\'{}\' does not end with valid memory register syntax. Memory operand must have the form offset(gpr). Example: 0x20(r3)", svOpText)); return false; } - std::string_view svExpressionPart(startPtr, endPtr); + std::string_view svExpressionPart(startPtr, endPtr - startPtr); std::string_view svRegPart(memoryRegBegin, memoryRegEnd - memoryRegBegin); sint32 memGpr = _parseRegIndex(svRegPart, "r"); //if (_ppcAssembler_parseRegister(svRegPart, "r", memGpr) == false || (memGpr < 0 || memGpr >= 32)) diff --git a/src/Cemu/napi/napi_helper.cpp b/src/Cemu/napi/napi_helper.cpp index 2f96567d..188c8840 100644 --- a/src/Cemu/napi/napi_helper.cpp +++ b/src/Cemu/napi/napi_helper.cpp @@ -73,6 +73,11 @@ CurlRequestHelper::CurlRequestHelper() curl_easy_setopt(m_curl, CURLOPT_FOLLOWLOCATION, 1); curl_easy_setopt(m_curl, CURLOPT_MAXREDIRS, 2); + + if(GetConfig().proxy_server.GetValue() != "") + { + curl_easy_setopt(m_curl, CURLOPT_PROXY, GetConfig().proxy_server.GetValue().c_str()); + } } CurlRequestHelper::~CurlRequestHelper() @@ -216,6 +221,11 @@ CurlSOAPHelper::CurlSOAPHelper() // SSL curl_easy_setopt(m_curl, CURLOPT_SSL_CTX_FUNCTION, _sslctx_function_SOAP); curl_easy_setopt(m_curl, CURLOPT_SSL_CTX_DATA, NULL); + + if(GetConfig().proxy_server.GetValue() != "") + { + curl_easy_setopt(m_curl, CURLOPT_PROXY, GetConfig().proxy_server.GetValue().c_str()); + } } CurlSOAPHelper::~CurlSOAPHelper() @@ -390,4 +400,4 @@ namespace NAPI result.apiError = NAPI_RESULT::SUCCESS; return true; } -}; \ No newline at end of file +}; diff --git a/src/Cemu/nex/nex.cpp b/src/Cemu/nex/nex.cpp index 8779043c..147d37da 100644 --- a/src/Cemu/nex/nex.cpp +++ b/src/Cemu/nex/nex.cpp @@ -5,7 +5,7 @@ #include "util/crypto/md5.h" // for inet_pton: -#if BOOST_OS_WINDOWS > 0 +#if BOOST_OS_WINDOWS #include #else #include diff --git a/src/Cemu/nex/prudp.cpp b/src/Cemu/nex/prudp.cpp index c60e4cc6..7700e5eb 100644 --- a/src/Cemu/nex/prudp.cpp +++ b/src/Cemu/nex/prudp.cpp @@ -4,6 +4,8 @@ #include #include +#include + void swap(unsigned char *a, unsigned char *b) { int tmp = *a; @@ -111,7 +113,8 @@ void releasePRUDPPort(uint16 port) } std::mt19937_64 prudpRG(GetTickCount()); -std::uniform_int_distribution prudpDis8(0, 0xFF); +// workaround for static asserts when using uniform_int_distribution +boost::random::uniform_int_distribution prudpDis8(0, 0xFF); uint8 prudp_generateRandomU8() { @@ -529,7 +532,7 @@ prudpClient::prudpClient(uint32 dstIp, uint16 dstPort, const char* key) : prudpC break; } // set socket to non-blocking mode -#if BOOST_OS_WINDOWS > 0 +#if BOOST_OS_WINDOWS u_long nonBlockingMode = 1; // 1 to enable non-blocking socket ioctlsocket(socketUdp, FIONBIO, &nonBlockingMode); #else diff --git a/src/Common/CMakeLists.txt b/src/Common/CMakeLists.txt index 5af5898e..bee159cd 100644 --- a/src/Common/CMakeLists.txt +++ b/src/Common/CMakeLists.txt @@ -17,8 +17,8 @@ PRIVATE else() target_sources(CemuCommon PRIVATE - linux/platform.cpp - linux/platform.h + unix/platform.cpp + unix/platform.h ) endif() diff --git a/src/Common/ExceptionHandler/ExceptionHandler.cpp b/src/Common/ExceptionHandler/ExceptionHandler.cpp index 6824a5a7..20074fbf 100644 --- a/src/Common/ExceptionHandler/ExceptionHandler.cpp +++ b/src/Common/ExceptionHandler/ExceptionHandler.cpp @@ -1,7 +1,7 @@ #include "Common/precompiled.h" #include "Cafe/CafeSystem.h" -#if BOOST_OS_LINUX +#if BOOST_OS_LINUX || BOOST_OS_MACOS #include #include #endif @@ -41,7 +41,6 @@ void crashlog_writeHeader(const char* header) } bool crashLogCreated = false; -bool IsCemuhookLoaded(); #include BOOL CALLBACK MyMiniDumpCallback(PVOID pParam, const PMINIDUMP_CALLBACK_INPUT pInput, PMINIDUMP_CALLBACK_OUTPUT pOutput) { @@ -375,10 +374,7 @@ void createCrashlog(EXCEPTION_POINTERS* e, PCONTEXT context) fs::copy_file(ActiveSettings::GetPath("log.txt"), p, ec); } - if (IsCemuhookLoaded()) - TerminateProcess(GetCurrentProcess(), 0); // abort(); - else - exit(0); + exit(0); return; } diff --git a/src/Common/platform.h b/src/Common/platform.h index d47bcf74..901bfda8 100644 --- a/src/Common/platform.h +++ b/src/Common/platform.h @@ -6,11 +6,12 @@ #if BOOST_OS_WINDOWS #include "Common/windows/platform.h" #elif BOOST_OS_LINUX -#include "byteswap.h" -//#include -// #include -#include "Common/linux/platform.h" - +#include +#include +#include +#include +#include "Common/unix/platform.h" #elif BOOST_OS_MACOS - -#endif \ No newline at end of file +#include +#include "Common/unix/platform.h" +#endif diff --git a/src/Common/precompiled.h b/src/Common/precompiled.h index e9b56bf6..8e7da689 100644 --- a/src/Common/precompiled.h +++ b/src/Common/precompiled.h @@ -138,22 +138,32 @@ inline sint16 _swapEndianS16(sint16 v) { return (sint16)(((uint16)v >> 8) | ((uint16)v << 8)); } -#endif - -#if BOOST_OS_LINUX +#else inline uint64 _swapEndianU64(uint64 v) { +#if BOOST_OS_MACOS + return OSSwapInt64(v); +#else return bswap_64(v); +#endif } inline uint32 _swapEndianU32(uint32 v) { +#if BOOST_OS_MACOS + return OSSwapInt32(v); +#else return bswap_32(v); +#endif } inline sint32 _swapEndianS32(sint32 v) { +#if BOOST_OS_MACOS + return (sint32)OSSwapInt32((uint32)v); +#else return (sint32)bswap_32((uint32)v); +#endif } inline uint16 _swapEndianU16(uint16 v) diff --git a/src/Common/socket.h b/src/Common/socket.h index 2a33d737..37d53c09 100644 --- a/src/Common/socket.h +++ b/src/Common/socket.h @@ -1,6 +1,6 @@ #pragma once -#if BOOST_OS_WINDOWS > 0 +#if BOOST_OS_WINDOWS #include typedef int socklen_t; diff --git a/src/Common/linux/date.h b/src/Common/unix/date.h similarity index 100% rename from src/Common/linux/date.h rename to src/Common/unix/date.h diff --git a/src/Common/linux/fast_float.h b/src/Common/unix/fast_float.h similarity index 100% rename from src/Common/linux/fast_float.h rename to src/Common/unix/fast_float.h diff --git a/src/Common/linux/platform.cpp b/src/Common/unix/platform.cpp similarity index 100% rename from src/Common/linux/platform.cpp rename to src/Common/unix/platform.cpp diff --git a/src/Common/linux/platform.h b/src/Common/unix/platform.h similarity index 94% rename from src/Common/linux/platform.h rename to src/Common/unix/platform.h index 735954a5..c3b1b011 100644 --- a/src/Common/linux/platform.h +++ b/src/Common/unix/platform.h @@ -32,9 +32,6 @@ inline uint32_t GetExceptionError() return errno; } -#include -#include -#include #undef False #undef True #undef None diff --git a/src/asm/CMakeLists.txt b/src/asm/CMakeLists.txt index ab9e701b..527fb1fe 100644 --- a/src/asm/CMakeLists.txt +++ b/src/asm/CMakeLists.txt @@ -12,7 +12,11 @@ set_source_files_properties(x64util_masm.asm PROPERTIES LANGUAGE ASM_MASM) ELSE() # NASM +IF (APPLE) +set(CMAKE_ASM_NASM_COMPILE_OBJECT " -g -Fdwarf -f macho64 --prefix _ -o ") +ELSE() set(CMAKE_ASM_NASM_COMPILE_OBJECT " -g -Fdwarf -f elf64 -o ") +ENDIF() set(CMAKE_ASM_NASM_LINK_EXECUTABLE "ld -fPIC -o ") enable_language(C ASM_NASM) @@ -22,7 +26,11 @@ x64util_nasm.asm ) set_source_files_properties(x64util_nasm.asm PROPERTIES LANGUAGE ASM_NASM) +IF (APPLE) +set_target_properties(CemuAsm PROPERTIES NASM_OBJ_FORMAT macho64) +ELSE() set_target_properties(CemuAsm PROPERTIES NASM_OBJ_FORMAT elf64) +ENDIF() set_target_properties(CemuAsm PROPERTIES LINKER_LANGUAGE C) ENDIF() diff --git a/src/audio/IAudioAPI.cpp b/src/audio/IAudioAPI.cpp index 1bbeac6d..29f74153 100644 --- a/src/audio/IAudioAPI.cpp +++ b/src/audio/IAudioAPI.cpp @@ -1,6 +1,6 @@ #include "IAudioAPI.h" -#if BOOST_OS_WINDOWS > 0 +#if BOOST_OS_WINDOWS #include "XAudio2API.h" #include "XAudio27API.h" #include "DirectSoundAPI.h" @@ -37,7 +37,7 @@ void IAudioAPI::PrintLogging() void IAudioAPI::InitWFX(sint32 samplerate, sint32 channels, sint32 bits_per_sample) { -#if BOOST_OS_WINDOWS > 0 +#if BOOST_OS_WINDOWS // move this to Windows-specific audio API implementations and use a cross-platform format here m_wfx.Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE; m_wfx.Format.nChannels = channels; diff --git a/src/audio/IAudioAPI.h b/src/audio/IAudioAPI.h index 25d416ba..935e3024 100644 --- a/src/audio/IAudioAPI.h +++ b/src/audio/IAudioAPI.h @@ -1,6 +1,6 @@ #pragma once -#if BOOST_OS_WINDOWS > 0 +#if BOOST_OS_WINDOWS #include #endif @@ -64,7 +64,7 @@ public: static std::vector GetDevices(AudioAPI api); protected: -#if BOOST_OS_WINDOWS > 0 +#if BOOST_OS_WINDOWS WAVEFORMATEXTENSIBLE m_wfx{}; #endif diff --git a/src/cemuhook/CMakeLists.txt b/src/cemuhook/CMakeLists.txt deleted file mode 100644 index b7f6b5a1..00000000 --- a/src/cemuhook/CMakeLists.txt +++ /dev/null @@ -1,12 +0,0 @@ -project(CemuCemuhook) - -add_library(CemuCemuhook -wxEvtHook.inl -wxCemuhookExports.cpp -) - -set_property(TARGET CemuCemuhook PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") - -target_precompile_headers(CemuCemuhook PRIVATE ../Common/precompiled.h) - -target_include_directories(CemuCemuhook PRIVATE ../) \ No newline at end of file diff --git a/src/cemuhook/wxCemuhookExports.cpp b/src/cemuhook/wxCemuhookExports.cpp index adcd8a0d..e69de29b 100644 --- a/src/cemuhook/wxCemuhookExports.cpp +++ b/src/cemuhook/wxCemuhookExports.cpp @@ -1,196 +0,0 @@ - -#ifdef USE_CEMUHOOK - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define CHECK_FOR_WX_EVT_STRING(strVar, strConst) if (strcmp(strVar, #strConst) == 0){ return static_cast(strConst); } - - -DLLEXPORT wxEvtHandler* wxEvtHandler_Initialize(uint8_t* allocMemory) -{ - wxEvtHandler* handler = new (allocMemory) wxEvtHandler(); - return handler; -} - -DLLEXPORT void wxEvtHandler_Connect(wxEvtHandler* eventSource, int id, int lastId, int eventType, wxObjectEventFunction func, wxObject* userData, wxEvtHandler* eventSink) -{ - eventSource->Connect(id, lastId, eventType, func, userData, eventSink); -} - -DLLEXPORT void wxEvtHandler_Disconnect(wxEvtHandler* eventSource, int id, int lastId, int eventType, wxObjectEventFunction func, wxObject* userData, wxEvtHandler* eventSink) -{ - eventSource->Disconnect(id, lastId, eventType, func, userData, eventSink); -} - -DLLEXPORT const wchar_t* GetTranslationWChar(const wchar_t* text) -{ - return wxGetTranslation(text).wc_str(); -} - -DLLEXPORT int wxGetEventByName(const char* eventName) -{ -#define PROCESS_OWN_WXEVT(EventVarName,EventHookId) if (!strcmp(eventName,#EventVarName)){ return static_cast(EventVarName); } -#include "wxEvtHook.inl" -#undef PROCESS_OWN_WXEVT - - return -1; -} - -#pragma optimize( "", off ) - -static bool FixupWxEvtId(const wxEventType& outObj, const int newId) -{ - const int oldVal = static_cast(outObj); - if (oldVal == newId) - return false; - - wxEventType* dstObj = const_cast(&outObj); - memcpy(dstObj, &newId, sizeof(newId)); - - // check value again - if (static_cast(outObj) != newId) - assert_dbg(); - - return true; -} - -void FixupWxEvtIdsToMatchCemuHook() -{ - // instantiate all the events -#define PROCESS_OWN_WXEVT(EventVarName,EventHookId) static_cast(EventVarName); -#include "cemuhook/wxEvtHook.inl" -#undef PROCESS_OWN_WXEVT - // fix them -#define PROCESS_OWN_WXEVT(EventVarName,EventHookId) FixupWxEvtId(EventVarName,EventHookId) -#include "cemuhook/wxEvtHook.inl" -#undef PROCESS_OWN_WXEVT -} - -#pragma optimize( "", on ) - -// these I added on my own since they might be useful - -DLLEXPORT void coreinitAPI_OSYieldThread() -{ - PPCCore_switchToScheduler(); -} - -#define xstr(a) str(a) -#define str(a) #a - -#define PRINT_EVENT(__evtName) printf(xstr(__evtName) " = %d\n", (int)(wxEventType)__evtName); - -void PrintEvents() -{ - PRINT_EVENT(wxEVT_IDLE) - PRINT_EVENT(wxEVT_THREAD) - PRINT_EVENT(wxEVT_ASYNC_METHOD_CALL) - - PRINT_EVENT(wxEVT_BUTTON) - PRINT_EVENT(wxEVT_CHECKBOX) - PRINT_EVENT(wxEVT_CHOICE) - PRINT_EVENT(wxEVT_LISTBOX) - PRINT_EVENT(wxEVT_LISTBOX_DCLICK) - PRINT_EVENT(wxEVT_CHECKLISTBOX) - PRINT_EVENT(wxEVT_MENU) - PRINT_EVENT(wxEVT_SLIDER) - PRINT_EVENT(wxEVT_RADIOBOX) - PRINT_EVENT(wxEVT_RADIOBUTTON) - PRINT_EVENT(wxEVT_SCROLLBAR) - - PRINT_EVENT(wxEVT_LEFT_DOWN) - PRINT_EVENT(wxEVT_LEFT_UP) - PRINT_EVENT(wxEVT_MIDDLE_DOWN) - PRINT_EVENT(wxEVT_MIDDLE_UP) - PRINT_EVENT(wxEVT_RIGHT_DOWN) - PRINT_EVENT(wxEVT_RIGHT_UP) - PRINT_EVENT(wxEVT_MOTION) - PRINT_EVENT(wxEVT_ENTER_WINDOW) - PRINT_EVENT(wxEVT_LEAVE_WINDOW) - - PRINT_EVENT(wxEVT_CHAR) - PRINT_EVENT(wxEVT_SET_CURSOR) - PRINT_EVENT(wxEVT_SCROLL_TOP) - PRINT_EVENT(wxEVT_SCROLL_BOTTOM) - - PRINT_EVENT(wxEVT_SIZE) - PRINT_EVENT(wxEVT_MOVE) - PRINT_EVENT(wxEVT_CLOSE_WINDOW) - PRINT_EVENT(wxEVT_END_SESSION) - PRINT_EVENT(wxEVT_ACTIVATE_APP) - PRINT_EVENT(wxEVT_ACTIVATE) - PRINT_EVENT(wxEVT_CREATE) - PRINT_EVENT(wxEVT_DESTROY) - PRINT_EVENT(wxEVT_SHOW) - PRINT_EVENT(wxEVT_ICONIZE) - PRINT_EVENT(wxEVT_MAXIMIZE) - - PRINT_EVENT(wxEVT_PAINT) - PRINT_EVENT(wxEVT_MENU_OPEN) - PRINT_EVENT(wxEVT_MENU_CLOSE) - PRINT_EVENT(wxEVT_MENU_HIGHLIGHT) - PRINT_EVENT(wxEVT_CONTEXT_MENU) - - PRINT_EVENT(wxEVT_UPDATE_UI) - PRINT_EVENT(wxEVT_SIZING) - PRINT_EVENT(wxEVT_MOVING) - - PRINT_EVENT(wxEVT_TEXT_COPY) - PRINT_EVENT(wxEVT_TEXT_CUT) - PRINT_EVENT(wxEVT_TEXT_PASTE) - -} - -void wxMatchCemuhookEventIds() -{ - - FixupWxEvtIdsToMatchCemuHook(); - - //PrintEvents(); - // check if key eventIds match with Cemuhook - cemu_assert((wxEventType)wxEVT_SIZE == 10078); - cemu_assert((wxEventType)wxEVT_HYPERLINK == 10156); - cemu_assert((wxEventType)wxEVT_IDLE == 10001); - cemu_assert((wxEventType)wxEVT_UPDATE_UI == 10116); -} - -/* This code reserves the first 300 wxWidgets event ids early, so that they cant be grabbed by wxWidgets constructors for the regular events. We then assign fixed IDs that match Cemuhook's later */ -#pragma init_seg(lib) - -int wxNewEventType(); - -bool wxReserveEventIds() -{ - for (int i = 0; i < 300; i++) - wxNewEventType(); - return true; -} - -bool s_placeholderResult = wxReserveEventIds(); - -#endif \ No newline at end of file diff --git a/src/cemuhook/wxEvtHook.inl b/src/cemuhook/wxEvtHook.inl deleted file mode 100644 index a8ae33c0..00000000 --- a/src/cemuhook/wxEvtHook.inl +++ /dev/null @@ -1,171 +0,0 @@ -PROCESS_OWN_WXEVT(wxEVT_NULL,10000); -PROCESS_OWN_WXEVT(wxEVT_IDLE,10001); -PROCESS_OWN_WXEVT(wxEVT_THREAD,10002); -PROCESS_OWN_WXEVT(wxEVT_ASYNC_METHOD_CALL,10003); -PROCESS_OWN_WXEVT(wxEVT_END_PROCESS,10004); -PROCESS_OWN_WXEVT(wxEVT_TIMER,10005); -PROCESS_OWN_WXEVT(wxEVT_BUTTON,10006); -PROCESS_OWN_WXEVT(wxEVT_CHECKBOX,10007); -PROCESS_OWN_WXEVT(wxEVT_CHOICE,10008); -PROCESS_OWN_WXEVT(wxEVT_LISTBOX,10009); -PROCESS_OWN_WXEVT(wxEVT_LISTBOX_DCLICK,10010); -PROCESS_OWN_WXEVT(wxEVT_CHECKLISTBOX,10011); -PROCESS_OWN_WXEVT(wxEVT_MENU,10012); -PROCESS_OWN_WXEVT(wxEVT_SLIDER,10013); -PROCESS_OWN_WXEVT(wxEVT_RADIOBOX,10014); -PROCESS_OWN_WXEVT(wxEVT_RADIOBUTTON,10015); -PROCESS_OWN_WXEVT(wxEVT_SCROLLBAR,10016); -PROCESS_OWN_WXEVT(wxEVT_VLBOX,10017); -PROCESS_OWN_WXEVT(wxEVT_COMBOBOX,10018); -PROCESS_OWN_WXEVT(wxEVT_TOOL_RCLICKED,10019); -PROCESS_OWN_WXEVT(wxEVT_TOOL_ENTER,10020); -PROCESS_OWN_WXEVT(wxEVT_TOOL_DROPDOWN,10021); -PROCESS_OWN_WXEVT(wxEVT_COMBOBOX_DROPDOWN,10022); -PROCESS_OWN_WXEVT(wxEVT_COMBOBOX_CLOSEUP,10023); -PROCESS_OWN_WXEVT(wxEVT_LEFT_DOWN,10024); -PROCESS_OWN_WXEVT(wxEVT_LEFT_UP,10025); -PROCESS_OWN_WXEVT(wxEVT_MIDDLE_DOWN,10026); -PROCESS_OWN_WXEVT(wxEVT_MIDDLE_UP,10027); -PROCESS_OWN_WXEVT(wxEVT_RIGHT_DOWN,10028); -PROCESS_OWN_WXEVT(wxEVT_RIGHT_UP,10029); -PROCESS_OWN_WXEVT(wxEVT_MOTION,10030); -PROCESS_OWN_WXEVT(wxEVT_ENTER_WINDOW,10031); -PROCESS_OWN_WXEVT(wxEVT_LEAVE_WINDOW,10032); -PROCESS_OWN_WXEVT(wxEVT_LEFT_DCLICK,10033); -PROCESS_OWN_WXEVT(wxEVT_MIDDLE_DCLICK,10034); -PROCESS_OWN_WXEVT(wxEVT_RIGHT_DCLICK,10035); -PROCESS_OWN_WXEVT(wxEVT_SET_FOCUS,10036); -PROCESS_OWN_WXEVT(wxEVT_KILL_FOCUS,10037); -PROCESS_OWN_WXEVT(wxEVT_CHILD_FOCUS,10038); -PROCESS_OWN_WXEVT(wxEVT_MOUSEWHEEL,10039); -PROCESS_OWN_WXEVT(wxEVT_AUX1_DOWN,10040); -PROCESS_OWN_WXEVT(wxEVT_AUX1_UP,10041); -PROCESS_OWN_WXEVT(wxEVT_AUX1_DCLICK,10042); -PROCESS_OWN_WXEVT(wxEVT_AUX2_DOWN,10043); -PROCESS_OWN_WXEVT(wxEVT_AUX2_UP,10044); -PROCESS_OWN_WXEVT(wxEVT_AUX2_DCLICK,10045); -PROCESS_OWN_WXEVT(wxEVT_MAGNIFY,10046); -PROCESS_OWN_WXEVT(wxEVT_CHAR,10047); -PROCESS_OWN_WXEVT(wxEVT_AFTER_CHAR,10048); -PROCESS_OWN_WXEVT(wxEVT_CHAR_HOOK,10049); -PROCESS_OWN_WXEVT(wxEVT_NAVIGATION_KEY,10050); -PROCESS_OWN_WXEVT(wxEVT_KEY_DOWN,10051); -PROCESS_OWN_WXEVT(wxEVT_KEY_UP,10052); -PROCESS_OWN_WXEVT(wxEVT_HOTKEY,10053); -PROCESS_OWN_WXEVT(wxEVT_SET_CURSOR,10054); -PROCESS_OWN_WXEVT(wxEVT_SCROLL_TOP,10055); -PROCESS_OWN_WXEVT(wxEVT_SCROLL_BOTTOM,10056); -PROCESS_OWN_WXEVT(wxEVT_SCROLL_LINEUP,10057); -PROCESS_OWN_WXEVT(wxEVT_SCROLL_LINEDOWN,10058); -PROCESS_OWN_WXEVT(wxEVT_SCROLL_PAGEUP,10059); -PROCESS_OWN_WXEVT(wxEVT_SCROLL_PAGEDOWN,10060); -PROCESS_OWN_WXEVT(wxEVT_SCROLL_THUMBTRACK,10061); -PROCESS_OWN_WXEVT(wxEVT_SCROLL_THUMBRELEASE,10062); -PROCESS_OWN_WXEVT(wxEVT_SCROLL_CHANGED,10063); -PROCESS_OWN_WXEVT(wxEVT_SPIN_UP,10057); -PROCESS_OWN_WXEVT(wxEVT_SPIN_DOWN,10058); -PROCESS_OWN_WXEVT(wxEVT_SPIN,10061); -PROCESS_OWN_WXEVT(wxEVT_SCROLLWIN_TOP,10064); -PROCESS_OWN_WXEVT(wxEVT_SCROLLWIN_BOTTOM,10065); -PROCESS_OWN_WXEVT(wxEVT_SCROLLWIN_LINEUP,10066); -PROCESS_OWN_WXEVT(wxEVT_SCROLLWIN_LINEDOWN,10067); -PROCESS_OWN_WXEVT(wxEVT_SCROLLWIN_PAGEUP,10068); -PROCESS_OWN_WXEVT(wxEVT_SCROLLWIN_PAGEDOWN,10069); -PROCESS_OWN_WXEVT(wxEVT_SCROLLWIN_THUMBTRACK,10070); -PROCESS_OWN_WXEVT(wxEVT_SCROLLWIN_THUMBRELEASE,10071); -PROCESS_OWN_WXEVT(wxEVT_GESTURE_PAN,10072); -PROCESS_OWN_WXEVT(wxEVT_GESTURE_ZOOM,10073); -PROCESS_OWN_WXEVT(wxEVT_GESTURE_ROTATE,10074); -PROCESS_OWN_WXEVT(wxEVT_TWO_FINGER_TAP,10075); -PROCESS_OWN_WXEVT(wxEVT_LONG_PRESS,10076); -PROCESS_OWN_WXEVT(wxEVT_PRESS_AND_TAP,10077); -PROCESS_OWN_WXEVT(wxEVT_SIZE,10078); -PROCESS_OWN_WXEVT(wxEVT_SIZING,10079); -PROCESS_OWN_WXEVT(wxEVT_MOVE,10080); -PROCESS_OWN_WXEVT(wxEVT_MOVING,10081); -PROCESS_OWN_WXEVT(wxEVT_MOVE_START,10082); -PROCESS_OWN_WXEVT(wxEVT_MOVE_END,10083); -PROCESS_OWN_WXEVT(wxEVT_CLOSE_WINDOW,10084); -PROCESS_OWN_WXEVT(wxEVT_END_SESSION,10085); -PROCESS_OWN_WXEVT(wxEVT_QUERY_END_SESSION,10086); -PROCESS_OWN_WXEVT(wxEVT_HIBERNATE,10087); -PROCESS_OWN_WXEVT(wxEVT_ACTIVATE_APP,10088); -PROCESS_OWN_WXEVT(wxEVT_ACTIVATE,10089); -PROCESS_OWN_WXEVT(wxEVT_CREATE,10090); -PROCESS_OWN_WXEVT(wxEVT_DESTROY,10091); -PROCESS_OWN_WXEVT(wxEVT_SHOW,10092); -PROCESS_OWN_WXEVT(wxEVT_ICONIZE,10093); -PROCESS_OWN_WXEVT(wxEVT_MAXIMIZE,10094); -PROCESS_OWN_WXEVT(wxEVT_FULLSCREEN,10095); -PROCESS_OWN_WXEVT(wxEVT_MOUSE_CAPTURE_CHANGED,10096); -PROCESS_OWN_WXEVT(wxEVT_MOUSE_CAPTURE_LOST,10097); -PROCESS_OWN_WXEVT(wxEVT_PAINT,10098); -PROCESS_OWN_WXEVT(wxEVT_ERASE_BACKGROUND,10099); -PROCESS_OWN_WXEVT(wxEVT_NC_PAINT,10100); -PROCESS_OWN_WXEVT(wxEVT_MENU_OPEN,10101); -PROCESS_OWN_WXEVT(wxEVT_MENU_CLOSE,10102); -PROCESS_OWN_WXEVT(wxEVT_MENU_HIGHLIGHT,10103); -PROCESS_OWN_WXEVT(wxEVT_CONTEXT_MENU,10104); -PROCESS_OWN_WXEVT(wxEVT_SYS_COLOUR_CHANGED,10105); -PROCESS_OWN_WXEVT(wxEVT_DISPLAY_CHANGED,10106); -PROCESS_OWN_WXEVT(wxEVT_DPI_CHANGED,10107); -PROCESS_OWN_WXEVT(wxEVT_QUERY_NEW_PALETTE,10108); -PROCESS_OWN_WXEVT(wxEVT_PALETTE_CHANGED,10109); -PROCESS_OWN_WXEVT(wxEVT_JOY_BUTTON_DOWN,10110); -PROCESS_OWN_WXEVT(wxEVT_JOY_BUTTON_UP,10111); -PROCESS_OWN_WXEVT(wxEVT_JOY_MOVE,10112); -PROCESS_OWN_WXEVT(wxEVT_JOY_ZMOVE,10113); -PROCESS_OWN_WXEVT(wxEVT_DROP_FILES,10114); -PROCESS_OWN_WXEVT(wxEVT_INIT_DIALOG,10115); -PROCESS_OWN_WXEVT(wxEVT_UPDATE_UI,10116); -PROCESS_OWN_WXEVT(wxEVT_TEXT_COPY,10117); -PROCESS_OWN_WXEVT(wxEVT_TEXT_CUT,10118); -PROCESS_OWN_WXEVT(wxEVT_TEXT_PASTE,10119); -PROCESS_OWN_WXEVT(wxEVT_COMMAND_LEFT_CLICK,10120); -PROCESS_OWN_WXEVT(wxEVT_COMMAND_LEFT_DCLICK,10121); -PROCESS_OWN_WXEVT(wxEVT_COMMAND_RIGHT_CLICK,10122); -PROCESS_OWN_WXEVT(wxEVT_COMMAND_RIGHT_DCLICK,10123); -PROCESS_OWN_WXEVT(wxEVT_COMMAND_SET_FOCUS,10124); -PROCESS_OWN_WXEVT(wxEVT_COMMAND_KILL_FOCUS,10125); -PROCESS_OWN_WXEVT(wxEVT_COMMAND_ENTER,10126); -PROCESS_OWN_WXEVT(wxEVT_HELP,10127); -PROCESS_OWN_WXEVT(wxEVT_DETAILED_HELP,10128); -PROCESS_OWN_WXEVT(wxEVT_LIST_BEGIN_DRAG,10129); -PROCESS_OWN_WXEVT(wxEVT_LIST_BEGIN_RDRAG,10130); -PROCESS_OWN_WXEVT(wxEVT_LIST_BEGIN_LABEL_EDIT,10131); -PROCESS_OWN_WXEVT(wxEVT_LIST_END_LABEL_EDIT,10132); -PROCESS_OWN_WXEVT(wxEVT_LIST_DELETE_ITEM,10133); -PROCESS_OWN_WXEVT(wxEVT_LIST_DELETE_ALL_ITEMS,10134); -PROCESS_OWN_WXEVT(wxEVT_LIST_ITEM_SELECTED,10135); -PROCESS_OWN_WXEVT(wxEVT_LIST_ITEM_DESELECTED,10136); -PROCESS_OWN_WXEVT(wxEVT_LIST_KEY_DOWN,10137); -PROCESS_OWN_WXEVT(wxEVT_LIST_INSERT_ITEM,10138); -PROCESS_OWN_WXEVT(wxEVT_LIST_COL_CLICK,10139); -PROCESS_OWN_WXEVT(wxEVT_LIST_COL_RIGHT_CLICK,10140); -PROCESS_OWN_WXEVT(wxEVT_LIST_COL_BEGIN_DRAG,10141); -PROCESS_OWN_WXEVT(wxEVT_LIST_COL_DRAGGING,10142); -PROCESS_OWN_WXEVT(wxEVT_LIST_COL_END_DRAG,10143); -PROCESS_OWN_WXEVT(wxEVT_LIST_ITEM_RIGHT_CLICK,10144); -PROCESS_OWN_WXEVT(wxEVT_LIST_ITEM_MIDDLE_CLICK,10145); -PROCESS_OWN_WXEVT(wxEVT_LIST_ITEM_ACTIVATED,10146); -PROCESS_OWN_WXEVT(wxEVT_LIST_ITEM_FOCUSED,10147); -PROCESS_OWN_WXEVT(wxEVT_LIST_ITEM_CHECKED,10148); -PROCESS_OWN_WXEVT(wxEVT_LIST_ITEM_UNCHECKED,10149); -PROCESS_OWN_WXEVT(wxEVT_LIST_CACHE_HINT,10150); -PROCESS_OWN_WXEVT(wxEVT_TEXT,10151); -PROCESS_OWN_WXEVT(wxEVT_TEXT_ENTER,10152); -PROCESS_OWN_WXEVT(wxEVT_TEXT_URL,10153); -PROCESS_OWN_WXEVT(wxEVT_TEXT_MAXLEN,10154); -PROCESS_OWN_WXEVT(wxEVT_WINDOW_MODAL_DIALOG_CLOSED,10155); -PROCESS_OWN_WXEVT(wxEVT_HYPERLINK,10156); -PROCESS_OWN_WXEVT(wxEVT_CLIPBOARD_CHANGED,10157); -PROCESS_OWN_WXEVT(wxEVT_NOTEBOOK_PAGE_CHANGED,10158); -PROCESS_OWN_WXEVT(wxEVT_NOTEBOOK_PAGE_CHANGING,10159); -PROCESS_OWN_WXEVT(wxEVT_SPINCTRL,10160); -PROCESS_OWN_WXEVT(wxEVT_SPINCTRLDOUBLE,10161); -PROCESS_OWN_WXEVT(wxEVT_COLLAPSIBLEPANE_CHANGED,10162); -PROCESS_OWN_WXEVT(wxEVT_COLLAPSIBLEHEADER_CHANGED,10163); -PROCESS_OWN_WXEVT(wxEVT_POWER_SUSPENDING,10164); -PROCESS_OWN_WXEVT(wxEVT_POWER_SUSPENDED,10165); -PROCESS_OWN_WXEVT(wxEVT_POWER_SUSPEND_CANCEL,10166); -PROCESS_OWN_WXEVT(wxEVT_POWER_RESUME,10167); \ No newline at end of file diff --git a/src/config/ActiveSettings.cpp b/src/config/ActiveSettings.cpp index 9e8a429e..c7ff4fe6 100644 --- a/src/config/ActiveSettings.cpp +++ b/src/config/ActiveSettings.cpp @@ -10,7 +10,7 @@ #include "Cafe/HW/Latte/Renderer/Vulkan/VulkanAPI.h" #include "Cafe/CafeSystem.h" -extern bool DLLEXPORT alwaysDisplayDRC; +extern bool alwaysDisplayDRC; void ActiveSettings::LoadOnce() { diff --git a/src/config/CemuConfig.cpp b/src/config/CemuConfig.cpp index c4280893..0cbd3c97 100644 --- a/src/config/CemuConfig.cpp +++ b/src/config/CemuConfig.cpp @@ -65,6 +65,7 @@ void CemuConfig::Load(XMLConfigParser& parser) did_show_vulkan_warning = parser.get("vk_warning", did_show_vulkan_warning); did_show_graphic_pack_download = parser.get("gp_download", did_show_graphic_pack_download); fullscreen = parser.get("fullscreen", fullscreen); + proxy_server = parser.get("proxy_server", ""); // cpu_mode = parser.get("cpu_mode", cpu_mode.GetInitValue()); //console_region = parser.get("console_region", console_region.GetInitValue()); @@ -340,6 +341,7 @@ void CemuConfig::Save(XMLConfigParser& parser) config.set("vk_warning", did_show_vulkan_warning); config.set("gp_download", did_show_graphic_pack_download); config.set("fullscreen", fullscreen); + config.set("proxy_server", proxy_server.GetValue().c_str()); // config.set("cpu_mode", cpu_mode.GetValue()); //config.set("console_region", console_region.GetValue()); @@ -576,4 +578,4 @@ void CemuConfig::AddRecentNfcFile(std::wstring_view file) // keep maximum of entries while (recent_nfc_files.size() > kMaxRecentEntries) recent_nfc_files.pop_back(); -} \ No newline at end of file +} diff --git a/src/config/CemuConfig.h b/src/config/CemuConfig.h index 247a0a83..8c43f0a5 100644 --- a/src/config/CemuConfig.h +++ b/src/config/CemuConfig.h @@ -331,6 +331,7 @@ struct CemuConfig ConfigValue mlc_path {}; ConfigValue fullscreen_menubar{ false }; ConfigValue fullscreen{ false }; + ConfigValue proxy_server{}; std::vector game_paths; std::mutex game_cache_entries_mutex; diff --git a/src/config/XMLConfig.h b/src/config/XMLConfig.h index fd2f04c7..04e3cfbf 100644 --- a/src/config/XMLConfig.h +++ b/src/config/XMLConfig.h @@ -396,7 +396,7 @@ public: } FILE* file = nullptr; -#if BOOST_OS_WINDOWS > 0 +#if BOOST_OS_WINDOWS file = _wfopen(tmp_name.c_str(), L"wb"); #else file = fopen(boost::nowide::narrow(tmp_name).c_str(), "wb"); diff --git a/src/exports.def b/src/exports.def deleted file mode 100644 index fd824c4c..00000000 --- a/src/exports.def +++ /dev/null @@ -1,57 +0,0 @@ -EXPORTS - cemuLog_log=?cemuLog_log@@YAXXZ - PPCCore_executeCallback=?PPCCore_executeCallback@@YAXI@Z - osLib_registerHLEFunction=?osLib_registerHLEFunction@@YAXPEBD0P6AXPEAUPPCInterpreter_t@@@Z@Z - gameProfile_load=?gameProfile_load@@YAXXZ - gameProfile_categoryBegin=?gameProfile_categoryBegin@@YAXPEAVIniParser@@@Z - gameProfile_getCurrentCategoryName=?gameProfile_getCurrentCategoryName@@YAPEADPEAVIniParser@@@Z - gameProfile_loadStringOption=?gameProfile_loadStringOption@@YAPEADPEAVIniParser@@PEAD@Z - gameProfile_loadBooleanOption=?gameProfile_loadBooleanOption@@YA_NPEAVIniParser@@PEADPEAUgameProfileBooleanOption_t@@@Z - gameProfile_loadIntegerNamedOption=?gameProfile_loadIntegerNamedOption@@YA_NPEAVIniParser@@PEADPEAUgameProfileIntegerOption_t@@HPEBUgpNamedOptionEntry_t@@H@Z - gameProfile_loadIntegerOption=?gameProfile_loadIntegerOption@@YA_NPEAVIniParser@@PEBDPEAUgameProfileIntegerOption_t@@HHH@Z - memory_init=?memory_init@@YAXXZ - memory_getBase=?memory_getBase@@YAPEAXXZ - wxMainWindowCreated=?wxMainWindowCreated@@YAPEAVwxTopLevelWindow@@PEAV1@IPEAVCemuApp@@@Z - wxEvtHandler_Initialize=?wxEvtHandler_Initialize@@YAPEAVwxEvtHandler@@PEAE@Z - wxEvtHandler_Connect=?wxEvtHandler_Connect@@YAXPEAVwxEvtHandler@@HHHP81@EAAXAEAVwxEvent@@@ZPEAVwxObject@@0@Z - wxEvtHandler_Disconnect=?wxEvtHandler_Disconnect@@YAXPEAVwxEvtHandler@@HHHP81@EAAXAEAVwxEvent@@@ZPEAVwxObject@@0@Z - wxGetEventByName=?wxGetEventByName@@YAHPEBD@Z - gameMeta_loadForCurrent=?gameMeta_loadForCurrent@@YAXXZ - gameMeta_getTitleId=?gameMeta_getTitleId@@YA_KXZ - PPCRecompiler_init=?PPCRecompiler_init@@YAXXZ - hasMOVBESupport=?hasMOVBESupport@@3_NA - hasLZCNTSupport=?hasLZCNTSupport@@3_NA - hasAVXSupport=?hasAVXSupport@@3_NA - ppcRecompilerInstanceData=?ppcRecompilerInstanceData@@3PEAUPPCRecompilerInstanceData_t@@EA - currentTLSModuleIndex=?_currentTLSModuleIndex@@3IA - rplModuleCount=?rplModuleCount@@3HA - rplModuleList=?rplModuleList@@3PAPEAURPLModule@@A - rpl_loadFromMem=?rpl_loadFromMem@@YAPEAURPLModule@@PEAEHPEAD@Z - loadSharedData=?loadSharedData@@YAIXZ - graphicPack_loadGraphicPackShaders=?graphicPack_loadGraphicPackShaders@@YAXPEAUgraphicPack_t@@PEA_W@Z - config_isGraphicPackEnabled=?config_isGraphicPackEnabled@@YA_N_K@Z - alwaysDisplayDRC=?alwaysDisplayDRC@@3_NA - ppcCyclesSince2000=?ppcCyclesSince2000@@3_KA - ppcMainThreadCycleCounter=?ppcMainThreadCycleCounter@@3_KC - GetTranslationWChar=?GetTranslationWChar@@YAPEB_WPEB_W@Z - ActivateGraphicPack=?Activate@GraphicPack2@@AEAA_NXZ - DeactivateGraphicPack=?Deactivate@GraphicPack2@@AEAA_NXZ - coreinitAPI_OSYieldThread=?coreinitAPI_OSYieldThread@@YAXXZ - GraphicPack2_GetFilename=?GraphicPack2_GetFilename@@YAPEB_WPEAVGraphicPack2@@@Z - GraphicPack2_GetName=?GraphicPack2_GetName@@YAPEBDPEAVGraphicPack2@@@Z - GraphicPack2_GetPath=?GraphicPack2_GetPath@@YAPEBDPEAVGraphicPack2@@@Z - GraphicPack2_GetDescription=?GraphicPack2_GetDescription@@YAPEBDPEAVGraphicPack2@@@Z - GraphicPack2_GetTitleIdCount=?GraphicPack2_GetTitleIdCount@@YA?BHPEAVGraphicPack2@@@Z - GraphicPack2_GetTitleIdList=?GraphicPack2_GetTitleIdList@@YAPEB_KPEAVGraphicPack2@@@Z - GraphicPack2_notifyActivate=?GraphicPack2_notifyActivate@@YAXPEAVGraphicPack2@@PEAVExpressionParser@@@Z - GraphicPack2_notifyDeactivate=?GraphicPack2_notifyDeactivate@@YAXPEAVGraphicPack2@@@Z - GraphicPack2_CreateExpressionParser=?GraphicPack2_CreateExpressionParser@@YAPEAVExpressionParser@@PEAVGraphicPack2@@@Z - ExpressionParser_Create=?ExpressionParser_Create@@YAPEAVExpressionParser@@XZ - ExpressionParser_CreateCopy=?ExpressionParser_CreateCopy@@YAPEAVExpressionParser@@PEAV1@@Z - ExpressionParser_Delete=?ExpressionParser_Delete@@YAXPEAVExpressionParser@@@Z - ExpressionParser_AddConstantDouble=?ExpressionParser_AddConstantDouble@@YAXPEAVExpressionParser@@PEBDN@Z - ExpressionParser_AddConstantString=?ExpressionParser_AddConstantString@@YAXPEAVExpressionParser@@PEBD1@Z - ExpressionParser_EvaluateToDouble=?ExpressionParser_EvaluateToDouble@@YA_NPEAVExpressionParser@@PEBDPEAN@Z - PPCRecompiler_findFuncRanges=?PPCRecompiler_findFuncRanges@@YA_NIPEAUppcRecompilerFuncRange_t@@PEA_K@Z - PPCRecompiler_getJumpTableBase=?PPCRecompiler_getJumpTableBase@@YAPEA_KXZ - PPCRecompiler_invalidateRange=?PPCRecompiler_invalidateRange@@YAXII@Z \ No newline at end of file diff --git a/src/gui/CemuApp.cpp b/src/gui/CemuApp.cpp index 1ce44d4e..37a40bab 100644 --- a/src/gui/CemuApp.cpp +++ b/src/gui/CemuApp.cpp @@ -68,14 +68,6 @@ void unused_translation_dummy() void(_("PrincipalId missing")); } - -#pragma optimize( "", off ) -DLLEXPORT NOINLINE wxTopLevelWindow* wxMainWindowCreated(wxTopLevelWindow* wndPtr, uint32 magicConstant, CemuApp* appPointer) -{ - return wndPtr; -} -#pragma optimize( "", on ) - bool CemuApp::OnInit() { wxInitAllImageHandlers(); @@ -140,9 +132,6 @@ bool CemuApp::OnInit() g_window_info.app_active = true; SetTopWindow(m_mainFrame); - - // Cemuhook callback - wxMainWindowCreated(m_mainFrame, 0xDABABE, this); m_mainFrame->Show(); return true; } @@ -150,7 +139,7 @@ bool CemuApp::OnInit() int CemuApp::OnExit() { wxApp::OnExit(); -#if BOOST_OS_WINDOWS > 0 +#if BOOST_OS_WINDOWS ExitProcess(0); #else exit(0); @@ -306,7 +295,7 @@ void CemuApp::CreateDefaultFiles(bool first_start) std::stringstream errorMsg; errorMsg << fmt::format(_("Couldn't create a required mlc01 subfolder or file!\n\nError: {0}\nTarget path:\n{1}").ToStdString(), ex.what(), boost::nowide::narrow(mlc)); -#if BOOST_OS_WINDOWS > 0 +#if BOOST_OS_WINDOWS const DWORD lastError = GetLastError(); if (lastError != ERROR_SUCCESS) errorMsg << fmt::format("\n\n{}", GetSystemErrorMessage(lastError)); @@ -332,7 +321,7 @@ void CemuApp::CreateDefaultFiles(bool first_start) std::stringstream errorMsg; errorMsg << fmt::format(_("Couldn't create a required cemu directory or file!\n\nError: {0}").ToStdString(), ex.what()); -#if BOOST_OS_WINDOWS > 0 +#if BOOST_OS_WINDOWS const DWORD lastError = GetLastError(); if (lastError != ERROR_SUCCESS) errorMsg << fmt::format("\n\n{}", GetSystemErrorMessage(lastError)); diff --git a/src/gui/CemuUpdateWindow.cpp b/src/gui/CemuUpdateWindow.cpp index f9aa3a88..6d79d13c 100644 --- a/src/gui/CemuUpdateWindow.cpp +++ b/src/gui/CemuUpdateWindow.cpp @@ -510,12 +510,11 @@ void CemuUpdateWindow::WorkerThread() } } -bool IsCemuhookLoaded(); void CemuUpdateWindow::OnClose(wxCloseEvent& event) { event.Skip(); -#if BOOST_OS_WINDOWS > 0 +#if BOOST_OS_WINDOWS if (m_restart_required && !m_restart_file.empty() && fs::exists(m_restart_file)) { PROCESS_INFORMATION pi{}; @@ -529,11 +528,8 @@ void CemuUpdateWindow::OnClose(wxCloseEvent& event) HANDLE lock = CreateMutex(nullptr, TRUE, L"Global\\cemu_update_lock"); CreateProcess(nullptr, (wchar_t*)cmdline.c_str(), nullptr, nullptr, FALSE, 0, nullptr, nullptr, &si, &pi); - - if (IsCemuhookLoaded()) - TerminateProcess(GetCurrentProcess(), 0); - else - exit(0); + + exit(0); } #else cemuLog_log(LogType::Force, "unimplemented - restart on update"); diff --git a/src/gui/GameProfileWindow.cpp b/src/gui/GameProfileWindow.cpp index a807e6cc..d3cd28d4 100644 --- a/src/gui/GameProfileWindow.cpp +++ b/src/gui/GameProfileWindow.cpp @@ -11,8 +11,8 @@ #include "gui/helpers/wxHelpers.h" #include "input/InputManager.h" -#if BOOST_OS_LINUX -#include "resource/linux/resources.h" +#if BOOST_OS_LINUX || BOOST_OS_MACOS +#include "resource/embedded/resources.h" #endif GameProfileWindow::GameProfileWindow(wxWindow* parent, uint64_t title_id) @@ -21,7 +21,7 @@ GameProfileWindow::GameProfileWindow(wxWindow* parent, uint64_t title_id) SetIcon(wxICON(X_GAME_PROFILE)); m_game_profile.Reset(); - m_game_profile.Load(title_id, false); + m_game_profile.Load(title_id); this->SetSizeHints(wxDefaultSize, wxDefaultSize); diff --git a/src/gui/GeneralSettings2.cpp b/src/gui/GeneralSettings2.cpp index 367fc902..012b8557 100644 --- a/src/gui/GeneralSettings2.cpp +++ b/src/gui/GeneralSettings2.cpp @@ -16,7 +16,7 @@ #include "config/CemuConfig.h" #include "audio/IAudioAPI.h" -#if BOOST_OS_WINDOWS > 0 +#if BOOST_OS_WINDOWS #include "audio/DirectSoundAPI.h" #include "audio/XAudio27API.h" #endif @@ -31,7 +31,7 @@ #include "gui/dialogs/CreateAccount/wxCreateAccountDialog.h" #include "config/PermanentStorage.h" -#if BOOST_OS_WINDOWS > 0 +#if BOOST_OS_WINDOWS #include #endif @@ -39,8 +39,8 @@ #include "config/ActiveSettings.h" #include "gui/helpers/wxHelpers.h" -#if BOOST_OS_LINUX > 0 -#include "resource/linux/resources.h" +#if BOOST_OS_LINUX || BOOST_OS_MACOS +#include "resource/embedded/resources.h" #endif #include "Cafe/CafeSystem.h" @@ -649,7 +649,7 @@ wxPanel* GeneralSettings2::AddAccountPage(wxNotebook* notebook) { m_account_information = new wxCollapsiblePane(online_panel, wxID_ANY, _("Account information")); - #if BOOST_OS_WINDOWS > 0 + #if BOOST_OS_WINDOWS m_account_information->GetControlWidget()->SetBackgroundColour(*wxWHITE); #endif auto win = m_account_information->GetPane(); @@ -1063,7 +1063,7 @@ void GeneralSettings2::ResetAccountInformation() // refresh pane size m_account_information->InvalidateBestSize(); - #if BOOST_OS_WINDOWS > 0 + #if BOOST_OS_WINDOWS m_account_information->OnStateChange(GetBestSize()); #endif } diff --git a/src/gui/GettingStartedDialog.cpp b/src/gui/GettingStartedDialog.cpp index 13fbfa94..30e5e557 100644 --- a/src/gui/GettingStartedDialog.cpp +++ b/src/gui/GettingStartedDialog.cpp @@ -15,8 +15,8 @@ #include "Cafe/TitleList/TitleList.h" -#if BOOST_OS_LINUX > 0 -#include "resource/linux/resources.h" +#if BOOST_OS_LINUX || BOOST_OS_MACOS +#include "resource/embedded/resources.h" #endif #include "wxHelper.h" diff --git a/src/gui/GraphicPacksWindow2.cpp b/src/gui/GraphicPacksWindow2.cpp index 53a65b69..f46d8abe 100644 --- a/src/gui/GraphicPacksWindow2.cpp +++ b/src/gui/GraphicPacksWindow2.cpp @@ -10,13 +10,11 @@ #include "Cafe/CafeSystem.h" #include "Cafe/TitleList/TitleList.h" -#if BOOST_OS_LINUX > 0 -#include "resource/linux/resources.h" +#if BOOST_OS_LINUX || BOOST_OS_MACOS +#include "resource/embedded/resources.h" #endif // main.cpp -bool IsCemuhookLoaded(); - class wxGraphicPackData : public wxTreeItemData { public: diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index d84a12e7..89895502 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -50,12 +50,12 @@ #include "gui/input/InputSettings2.h" #include "input/InputManager.h" -#if BOOST_OS_WINDOWS > 0 +#if BOOST_OS_WINDOWS #define exit(__c) ExitProcess(__c) #endif -#if BOOST_OS_LINUX > 0 -#include "resource/linux/resources.h" +#if BOOST_OS_LINUX || BOOST_OS_MACOS +#include "resource/embedded/resources.h" #endif #include "Cafe/TitleList/TitleInfo.h" @@ -65,8 +65,6 @@ extern WindowInfo g_window_info; extern std::shared_mutex g_mutex; -bool IsCemuhookLoaded(); - wxDEFINE_EVENT(wxEVT_SET_WINDOW_TITLE, wxCommandEvent); enum @@ -296,7 +294,7 @@ MainWindow::MainWindow() SetClientSize(1280, 720); SetIcon(wxICON(M_WND_ICON128)); -#if BOOST_OS_WINDOWS > 0 +#if BOOST_OS_WINDOWS HICON hWindowIcon = (HICON)LoadImageA(NULL, "M_WND_ICON16", IMAGE_ICON, 16, 16, LR_LOADFROMFILE); SendMessage(this->GetHWND(), WM_SETICON, ICON_SMALL, (LPARAM)hWindowIcon); #endif @@ -347,18 +345,6 @@ MainWindow::MainWindow() Bind(wxEVT_OPEN_GRAPHIC_PACK, &MainWindow::OnGraphicWindowOpen, this); Bind(wxEVT_LAUNCH_GAME, &MainWindow::OnLaunchFromFile, this); - if (fs::exists(ActiveSettings::GetPath("dbghelp.dll")) && !fs::exists(ActiveSettings::GetPath("cemuhook.dll"))) - { - m_statusBar = CreateStatusBar(1); - wxStaticText* statusBarText = new wxStaticText(m_statusBar, wxID_ANY, wxT("The installed version of Cemuhook is not compatible. To get the latest version visit: ")); - wxHyperlinkCtrl* cemuhookUrl = new wxHyperlinkCtrl(m_statusBar, wxID_ANY, "https://cemuhook.sshnuke.net/", "https://cemuhook.sshnuke.net/"); - // align elements - auto textSize = statusBarText->GetSize(); - statusBarText->SetPosition(wxPoint(6, (m_statusBar->GetSize().GetHeight() - textSize.GetHeight()) / 2)); - if(cemuhookUrl) - cemuhookUrl->SetPosition(wxPoint(textSize.GetWidth() + 12, (m_statusBar->GetSize().GetHeight() - textSize.GetHeight()) / 2)); - } - if (LaunchSettings::GetLoadFile().has_value()) { MainWindow::RequestLaunchGame(LaunchSettings::GetLoadFile().value(), wxLaunchGameEvent::INITIATED_BY::COMMAND_LINE); @@ -650,7 +636,7 @@ void MainWindow::OnInstallUpdate(wxCommandEvent& event) break; if (modalChoice == wxID_OK) { - #if BOOST_OS_LINUX + #if BOOST_OS_LINUX || BOOST_OS_MACOS fs::path dirPath((const char*)(openDirDialog.GetPath().fn_str())); #else fs::path dirPath(openDirDialog.GetPath().fn_str()); @@ -2086,12 +2072,6 @@ void MainWindow::RecreateMenu() #ifndef PUBLIC_RELEASE m_fileMenu->Append(MAINFRAME_MENU_ID_FILE_END_EMULATION, _("End emulation")); #endif - // destroy Cemuhook update indicator status bar - if (m_statusBar) - { - delete m_statusBar; - m_statusBar = nullptr; - } } m_exitMenuItem = m_fileMenu->Append(MAINFRAME_MENU_ID_FILE_EXIT, _("&Exit")); diff --git a/src/gui/MainWindow.h b/src/gui/MainWindow.h index 5b8458cb..bcf1212d 100644 --- a/src/gui/MainWindow.h +++ b/src/gui/MainWindow.h @@ -161,8 +161,6 @@ private: wxSize m_restored_size; wxPoint m_restored_position; - wxStatusBar* m_statusBar{}; - bool m_menu_visible = false; bool m_game_launched = false; diff --git a/src/gui/PadViewFrame.cpp b/src/gui/PadViewFrame.cpp index 8ac016ee..89a85297 100644 --- a/src/gui/PadViewFrame.cpp +++ b/src/gui/PadViewFrame.cpp @@ -13,8 +13,8 @@ #include "gui/helpers/wxHelpers.h" #include "input/InputManager.h" -#if BOOST_OS_LINUX -#include "resource/linux/resources.h" +#if BOOST_OS_LINUX || BOOST_OS_MACOS +#include "resource/embedded/resources.h" #endif #include "wxHelper.h" diff --git a/src/gui/TitleManager.cpp b/src/gui/TitleManager.cpp index ba3cfc19..7ae72131 100644 --- a/src/gui/TitleManager.cpp +++ b/src/gui/TitleManager.cpp @@ -42,8 +42,8 @@ #include "Cafe/TitleList/TitleList.h" -#if BOOST_OS_LINUX -#include "resource/linux/resources.h" +#if BOOST_OS_LINUX || BOOST_OS_MACOS +#include "resource/embedded/resources.h" #endif #include "Cafe/TitleList/SaveList.h" diff --git a/src/gui/debugger/DebuggerWindow2.cpp b/src/gui/debugger/DebuggerWindow2.cpp index a2dee9cf..7465c712 100644 --- a/src/gui/debugger/DebuggerWindow2.cpp +++ b/src/gui/debugger/DebuggerWindow2.cpp @@ -20,7 +20,7 @@ #include "util/helpers/helpers.h" #if BOOST_OS_LINUX -#include "resource/linux/resources.h" +#include "resource/embedded/resources.h" #endif enum diff --git a/src/gui/guiWrapper.cpp b/src/gui/guiWrapper.cpp index eed08425..c53a3bef 100644 --- a/src/gui/guiWrapper.cpp +++ b/src/gui/guiWrapper.cpp @@ -17,21 +17,17 @@ std::shared_mutex g_mutex; MainWindow* g_mainFrame = nullptr; #if BOOST_OS_WINDOWS -void wxMatchCemuhookEventIds(); - void _wxLaunch() { SetThreadName("MainThread_UI"); wxEntry(); } - #endif void gui_create() { SetThreadName("MainThread"); #if BOOST_OS_WINDOWS - wxMatchCemuhookEventIds(); // on Windows wxWidgets there is a bug where wxDirDialog->ShowModal will deadlock in Windows internals somehow // moving the UI thread off the main thread fixes this std::thread t = std::thread(_wxLaunch); @@ -159,9 +155,9 @@ typedef void GdkDisplay; void gui_initHandleContextFromWxWidgetsWindow(WindowHandleInfo& handleInfoOut, class wxWindow* wxw) { -#if BOOST_OS_WINDOWS > 0 +#if BOOST_OS_WINDOWS handleInfoOut.hwnd = wxw->GetHWND(); -#else +#elif BOOST_OS_LINUX /* dynamically retrieve GTK imports so we dont have to include and link the whole lib */ void (*dyn_gtk_widget_realize)(GtkWidget *widget); dyn_gtk_widget_realize = (void(*)(GtkWidget* widget))dlsym(RTLD_NEXT, "gtk_widget_realize"); diff --git a/src/gui/guiWrapper.h b/src/gui/guiWrapper.h index 1dfb611f..ecea2f6e 100644 --- a/src/gui/guiWrapper.h +++ b/src/gui/guiWrapper.h @@ -2,7 +2,7 @@ #include -#if BOOST_OS_LINUX > 0 +#if BOOST_OS_LINUX #include "xcb/xproto.h" #endif diff --git a/src/gui/input/InputSettings2.cpp b/src/gui/input/InputSettings2.cpp index 556028fa..62a7045a 100644 --- a/src/gui/input/InputSettings2.cpp +++ b/src/gui/input/InputSettings2.cpp @@ -30,7 +30,7 @@ #include "util/EventService.h" #if BOOST_OS_LINUX -#include "resource/linux/resources.h" +#include "resource/embedded/resources.h" #endif bool g_inputConfigWindowHasFocus = false; diff --git a/src/main.cpp b/src/main.cpp index 44704eb9..587d29e6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -28,24 +28,22 @@ #include "Cafe/OS/libs/vpad/vpad.h" #include "audio/IAudioAPI.h" -#if BOOST_OS_WINDOWS > 0 +#if BOOST_OS_WINDOWS #pragma comment(lib,"Dbghelp.lib") #endif #define SDL_MAIN_HANDLED #include -#if BOOST_OS_LINUX > 0 +#if BOOST_OS_LINUX || BOOST_OS_MACOS #define _putenv(__s) putenv((char*)(__s)) #endif -#if BOOST_OS_WINDOWS > 0 extern "C" { - DLLEXPORT int AmdPowerXpressRequestHighPerformance = 1; - DLLEXPORT DWORD NvOptimusEnablement = 0x00000001; + __declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1; + __declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001; } -#endif bool _cpuExtension_SSSE3 = false; bool _cpuExtension_SSE4_1 = false; @@ -53,51 +51,11 @@ bool _cpuExtension_AVX2 = false; std::atomic_bool g_isGPUInitFinished = false; -#if BOOST_OS_WINDOWS > 0 std::wstring executablePath; -#endif - -bool g_cemuhook_loaded = false; -bool IsCemuhookLoaded() -{ - return g_cemuhook_loaded; -} - -void checkForCemuhook() -{ - #if BOOST_OS_WINDOWS > 0 - // check if there is a dbghelp.dll in the current working directory - if (!fs::exists(ActiveSettings::GetPath("cemuhook.dll"))) - return; - // check if Cemuhook can be detected - DWORD verHandle; - DWORD verLen = GetFileVersionInfoSizeW(L"cemuhook.dll", &verHandle); - if (verLen == 0) - return; - uint8* verData = (uint8*)malloc(verLen); - GetFileVersionInfoW(L"cemuhook.dll", 0, verLen, verData); - // get version - LPVOID lpBuffer; - UINT size; - if (VerQueryValueW(verData, L"\\", (LPVOID*)&lpBuffer, (PUINT)&size)) - { - if (size) - { - VS_FIXEDFILEINFO *verInfo = (VS_FIXEDFILEINFO *)lpBuffer; - if (verInfo->dwSignature == 0xfeef04bd) - { - forceLog_printf("Cemuhook version: %d.%d.%d.%d", (verInfo->dwFileVersionMS >> 16) & 0xFFFF, (verInfo->dwFileVersionMS >> 0) & 0xFFFF, (verInfo->dwFileVersionLS >> 16) & 0xFFFF, (verInfo->dwFileVersionLS >> 0) & 0xFFFF); - g_cemuhook_loaded = true; - } - } - } - free(verData); - #endif -} void logCPUAndMemoryInfo() { - #if BOOST_OS_WINDOWS > 0 + #if BOOST_OS_WINDOWS int CPUInfo[4] = { -1 }; unsigned nExIds, i = 0; char CPUBrandString[0x40]; @@ -133,7 +91,7 @@ bool IsRunningInWine() void checkForWine() { - #if BOOST_OS_WINDOWS > 0 + #if BOOST_OS_WINDOWS const HMODULE hmodule = GetModuleHandleA("ntdll.dll"); if (!hmodule) return; @@ -154,8 +112,6 @@ void infoLog_cemuStartup() cemuLog_force("------- Init {} {}.{}{} -------", EMULATOR_NAME, EMULATOR_VERSION_LEAD, EMULATOR_VERSION_MAJOR, EMULATOR_VERSION_SUFFIX); cemuLog_force("Init Wii U memory space (base: 0x{:016x})", (size_t)memory_base); cemuLog_force(u8"mlc01 path: {}", ActiveSettings::GetMlcPath().generic_u8string()); - // check if Cemuhook is installed - checkForCemuhook(); // check for wine version checkForWine(); // CPU and RAM info @@ -210,7 +166,7 @@ void reconfigureGLDrivers() std::string nvCacheDirEnvOption("__GL_SHADER_DISK_CACHE_PATH="); nvCacheDirEnvOption.append(_utf8Wrapper(nvCacheDir)); -#if BOOST_OS_WINDOWS > 0 +#if BOOST_OS_WINDOWS std::wstring tmpW = boost::nowide::widen(nvCacheDirEnvOption); _wputenv(tmpW.c_str()); #else @@ -240,10 +196,10 @@ void mainEmulatorCommonInit() _cpuExtension_SSSE3 = ((cpuInfo[2] >> 9) & 1) != 0; _cpuExtension_SSE4_1 = ((cpuInfo[2] >> 19) & 1) != 0; - __cpuidex1(cpuInfo, 0x7, 0); + __cpuidex(cpuInfo, 0x7, 0); _cpuExtension_AVX2 = ((cpuInfo[1] >> 5) & 1) != 0; -#if BOOST_OS_WINDOWS > 0 +#if BOOST_OS_WINDOWS executablePath.resize(4096); int i = GetModuleFileName(NULL, executablePath.data(), executablePath.size()); if(i >= 0) @@ -328,7 +284,7 @@ int mainEmulatorHLE() bool isConsoleConnected = false; void requireConsole() { - #if BOOST_OS_WINDOWS > 0 + #if BOOST_OS_WINDOWS if (isConsoleConnected) return; @@ -349,7 +305,7 @@ void HandlePostUpdate() const auto filename = ActiveSettings::GetFullPath().replace_extension("exe.backup"); if (fs::exists(filename)) { -#if BOOST_OS_WINDOWS > 0 +#if BOOST_OS_WINDOWS HANDLE lock; do { @@ -378,7 +334,7 @@ void HandlePostUpdate() void ToolShaderCacheMerger(); -#if BOOST_OS_WINDOWS > 0 +#if BOOST_OS_WINDOWS #ifndef PUBLIC_RELEASE #include @@ -415,7 +371,9 @@ int wWinMain( _In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ L #else int main(int argc, char *argv[]) { +#if BOOST_OS_LINUX XInitThreads(); +#endif if (!LaunchSettings::HandleCommandline(argc, argv)) return 0; @@ -426,48 +384,7 @@ int main(int argc, char *argv[]) } #endif -/* Cemuhook legacy API */ - -#pragma optimize("",off) - -DLLEXPORT void gameMeta_loadForCurrent() -{ - int placeholderA = 0x11223344; - int placeholderB = 0x55667788; -} - -#pragma optimize("",on) - -DLLEXPORT uint64 gameMeta_getTitleId() +extern "C" DLLEXPORT uint64 gameMeta_getTitleId() { return CafeSystem::GetForegroundTitleId(); } - -/* Cemuhook loading */ -#if BOOST_OS_WINDOWS > 0 -#pragma init_seg(".CRT$XCT") - -HANDLE dbgLib; - -int dbghelp_init(void) -{ - // load dbghelp.dll from the system folder instead of loading outdated cemuhook via dbghelp.dll - WCHAR dllPath[MAX_PATH]; - GetSystemDirectoryW(dllPath, MAX_PATH); - wcscat_s(dllPath, sizeof(dllPath) / sizeof(WCHAR), TEXT("\\dbghelp.dll")); - - dbgLib = LoadLibraryW(dllPath); - if (dbgLib == NULL) - return -1; - - return 0; -} - -HMODULE _earlyInitFunction() -{ - dbghelp_init(); - return LoadLibraryA("cemuhook2.dll"); -} - -HMODULE _cemuHookDllHandle = _earlyInitFunction(); -#endif diff --git a/src/resource/CMakeLists.txt b/src/resource/CMakeLists.txt index e0a6e3b2..85084bca 100644 --- a/src/resource/CMakeLists.txt +++ b/src/resource/CMakeLists.txt @@ -7,8 +7,8 @@ target_precompile_headers(CemuResource PRIVATE ../Common/precompiled.h) # icon resources if(UNIX) target_sources(CemuResource PRIVATE - linux/resources.cpp - linux/resources.h + embedded/resources.cpp + embedded/resources.h ) endif() diff --git a/src/resource/linux/DEBUGGER_BP.hpng b/src/resource/embedded/DEBUGGER_BP.hpng similarity index 100% rename from src/resource/linux/DEBUGGER_BP.hpng rename to src/resource/embedded/DEBUGGER_BP.hpng diff --git a/src/resource/linux/DEBUGGER_BP_RED.hpng b/src/resource/embedded/DEBUGGER_BP_RED.hpng similarity index 100% rename from src/resource/linux/DEBUGGER_BP_RED.hpng rename to src/resource/embedded/DEBUGGER_BP_RED.hpng diff --git a/src/resource/linux/DEBUGGER_GOTO.hpng b/src/resource/embedded/DEBUGGER_GOTO.hpng similarity index 100% rename from src/resource/linux/DEBUGGER_GOTO.hpng rename to src/resource/embedded/DEBUGGER_GOTO.hpng diff --git a/src/resource/linux/DEBUGGER_PAUSE.hpng b/src/resource/embedded/DEBUGGER_PAUSE.hpng similarity index 100% rename from src/resource/linux/DEBUGGER_PAUSE.hpng rename to src/resource/embedded/DEBUGGER_PAUSE.hpng diff --git a/src/resource/linux/DEBUGGER_PLAY.hpng b/src/resource/embedded/DEBUGGER_PLAY.hpng similarity index 100% rename from src/resource/linux/DEBUGGER_PLAY.hpng rename to src/resource/embedded/DEBUGGER_PLAY.hpng diff --git a/src/resource/linux/DEBUGGER_STEP_INTO.hpng b/src/resource/embedded/DEBUGGER_STEP_INTO.hpng similarity index 100% rename from src/resource/linux/DEBUGGER_STEP_INTO.hpng rename to src/resource/embedded/DEBUGGER_STEP_INTO.hpng diff --git a/src/resource/linux/DEBUGGER_STEP_OUT.hpng b/src/resource/embedded/DEBUGGER_STEP_OUT.hpng similarity index 100% rename from src/resource/linux/DEBUGGER_STEP_OUT.hpng rename to src/resource/embedded/DEBUGGER_STEP_OUT.hpng diff --git a/src/resource/linux/DEBUGGER_STEP_OVER.hpng b/src/resource/embedded/DEBUGGER_STEP_OVER.hpng similarity index 100% rename from src/resource/linux/DEBUGGER_STEP_OVER.hpng rename to src/resource/embedded/DEBUGGER_STEP_OVER.hpng diff --git a/src/resource/linux/INPUT_CONNECTED.hpng b/src/resource/embedded/INPUT_CONNECTED.hpng similarity index 100% rename from src/resource/linux/INPUT_CONNECTED.hpng rename to src/resource/embedded/INPUT_CONNECTED.hpng diff --git a/src/resource/linux/INPUT_DISCONNECTED.hpng b/src/resource/embedded/INPUT_DISCONNECTED.hpng similarity index 100% rename from src/resource/linux/INPUT_DISCONNECTED.hpng rename to src/resource/embedded/INPUT_DISCONNECTED.hpng diff --git a/src/resource/linux/INPUT_LOW_BATTERY.hpng b/src/resource/embedded/INPUT_LOW_BATTERY.hpng similarity index 100% rename from src/resource/linux/INPUT_LOW_BATTERY.hpng rename to src/resource/embedded/INPUT_LOW_BATTERY.hpng diff --git a/src/resource/linux/M_WND_ICON128.xpm b/src/resource/embedded/M_WND_ICON128.xpm similarity index 100% rename from src/resource/linux/M_WND_ICON128.xpm rename to src/resource/embedded/M_WND_ICON128.xpm diff --git a/src/resource/linux/PNG_HELP.hpng b/src/resource/embedded/PNG_HELP.hpng similarity index 100% rename from src/resource/linux/PNG_HELP.hpng rename to src/resource/embedded/PNG_HELP.hpng diff --git a/src/resource/linux/PNG_REFRESH.hpng b/src/resource/embedded/PNG_REFRESH.hpng similarity index 100% rename from src/resource/linux/PNG_REFRESH.hpng rename to src/resource/embedded/PNG_REFRESH.hpng diff --git a/src/resource/linux/X_BOX.xpm b/src/resource/embedded/X_BOX.xpm similarity index 100% rename from src/resource/linux/X_BOX.xpm rename to src/resource/embedded/X_BOX.xpm diff --git a/src/resource/linux/X_GAME_PROFILE.xpm b/src/resource/embedded/X_GAME_PROFILE.xpm similarity index 100% rename from src/resource/linux/X_GAME_PROFILE.xpm rename to src/resource/embedded/X_GAME_PROFILE.xpm diff --git a/src/resource/linux/X_SETTINGS.xpm b/src/resource/embedded/X_SETTINGS.xpm similarity index 100% rename from src/resource/linux/X_SETTINGS.xpm rename to src/resource/embedded/X_SETTINGS.xpm diff --git a/src/resource/linux/icons8-checkmark-yes-32.hpng b/src/resource/embedded/icons8-checkmark-yes-32.hpng similarity index 100% rename from src/resource/linux/icons8-checkmark-yes-32.hpng rename to src/resource/embedded/icons8-checkmark-yes-32.hpng diff --git a/src/resource/linux/icons8-error-32.hpng b/src/resource/embedded/icons8-error-32.hpng similarity index 100% rename from src/resource/linux/icons8-error-32.hpng rename to src/resource/embedded/icons8-error-32.hpng diff --git a/src/resource/linux/resources.cpp b/src/resource/embedded/resources.cpp similarity index 100% rename from src/resource/linux/resources.cpp rename to src/resource/embedded/resources.cpp diff --git a/src/resource/linux/resources.h b/src/resource/embedded/resources.h similarity index 100% rename from src/resource/linux/resources.h rename to src/resource/embedded/resources.h diff --git a/src/util/Fiber/Fiber.h b/src/util/Fiber/Fiber.h index 75a94d51..c72c62fc 100644 --- a/src/util/Fiber/Fiber.h +++ b/src/util/Fiber/Fiber.h @@ -1,6 +1,6 @@ #pragma once -#if BOOST_OS_WINDOWS > 0 +#if BOOST_OS_WINDOWS #endif diff --git a/src/util/Fiber/FiberUnix.cpp b/src/util/Fiber/FiberUnix.cpp index e44400b9..9614fc4a 100644 --- a/src/util/Fiber/FiberUnix.cpp +++ b/src/util/Fiber/FiberUnix.cpp @@ -1,5 +1,6 @@ #include "Fiber.h" -#if BOOST_OS_LINUX +#if BOOST_OS_LINUX || BOOST_OS_MACOS +#define _XOPEN_SOURCE #include thread_local Fiber* sCurrentFiber{}; diff --git a/src/util/MemMapper/MemMapperUnix.cpp b/src/util/MemMapper/MemMapperUnix.cpp index 71e5de95..0ea52aa0 100644 --- a/src/util/MemMapper/MemMapperUnix.cpp +++ b/src/util/MemMapper/MemMapperUnix.cpp @@ -1,6 +1,6 @@ #include "util/MemMapper/MemMapper.h" -#if BOOST_OS_LINUX > 0 +#if BOOST_OS_LINUX || BOOST_OS_MACOS #include #include diff --git a/src/util/MemMapper/MemMapperWin.cpp b/src/util/MemMapper/MemMapperWin.cpp index 6606aec4..5c07949f 100644 --- a/src/util/MemMapper/MemMapperWin.cpp +++ b/src/util/MemMapper/MemMapperWin.cpp @@ -1,6 +1,6 @@ #include "util/MemMapper/MemMapper.h" -#if BOOST_OS_WINDOWS > 0 +#if BOOST_OS_WINDOWS #include diff --git a/src/util/helpers/helpers.cpp b/src/util/helpers/helpers.cpp index 83f2a6c4..a52aa439 100644 --- a/src/util/helpers/helpers.cpp +++ b/src/util/helpers/helpers.cpp @@ -9,6 +9,9 @@ #include "config/ActiveSettings.h" +#include + + #if BOOST_OS_WINDOWS #include #endif @@ -46,7 +49,7 @@ std::string_view& trim(std::string_view& str, const std::string& chars) return ltrim(rtrim(str, chars), chars); } -#if BOOST_OS_WINDOWS > 0 +#if BOOST_OS_WINDOWS std::wstring GetSystemErrorMessageW() { @@ -120,7 +123,7 @@ std::string GetSystemErrorMessage(const std::error_code& ec) return fmt::format("{}\n{}",msg, ec.message()); } -#if BOOST_OS_WINDOWS > 0 +#if BOOST_OS_WINDOWS const DWORD MS_VC_EXCEPTION = 0x406D1388; #pragma pack(push,8) typedef struct tagTHREADNAME_INFO @@ -135,7 +138,7 @@ typedef struct tagTHREADNAME_INFO void SetThreadName(const char* name) { -#if BOOST_OS_WINDOWS > 0 +#if BOOST_OS_WINDOWS #ifndef _PUBLIC_RELEASE THREADNAME_INFO info; @@ -154,12 +157,14 @@ void SetThreadName(const char* name) #endif +#elif BOOST_OS_MACOS + pthread_setname_np(name); #else pthread_setname_np(pthread_self(), name); #endif } -#if BOOST_OS_WINDOWS > 0 +#if BOOST_OS_WINDOWS std::pair GetWindowsVersion() { using RtlGetVersion_t = LONG(*)(POSVERSIONINFOEXW); @@ -417,18 +422,22 @@ std::string GenerateRandomString(size_t length) return GenerateRandomString(length, kCharacters); } -std::string GenerateRandomString(size_t length, std::string_view characters) +std::string GenerateRandomString(const size_t length, const std::string_view characters) { assert(!characters.empty()); - std::stringstream result; + std::string result; + result.resize(length); std::random_device rd; std::mt19937 gen(rd()); - std::uniform_int_distribution index_dist(0, characters.size() - 1); - for (uint32_t i = 0; i < length; ++i) - { - result << characters[index_dist(gen)]; - } + + // workaround for static asserts using boost + boost::random::uniform_int_distribution index_dist(0, characters.size() - 1); + std::generate_n( + result.begin(), + length, + [&] { return characters[index_dist(gen)]; } + ); - return result.str(); -} \ No newline at end of file + return result; +} diff --git a/src/util/helpers/helpers.h b/src/util/helpers/helpers.h index a672213d..6240d56a 100644 --- a/src/util/helpers/helpers.h +++ b/src/util/helpers/helpers.h @@ -8,7 +8,7 @@ #include "util/math/vector3.h" #ifdef __clang__ -#include "Common/linux/fast_float.h" +#include "Common/unix/fast_float.h" #endif template diff --git a/src/util/libusbWrapper/libusbWrapper.cpp b/src/util/libusbWrapper/libusbWrapper.cpp index 25a73781..e1d72985 100644 --- a/src/util/libusbWrapper/libusbWrapper.cpp +++ b/src/util/libusbWrapper/libusbWrapper.cpp @@ -60,7 +60,7 @@ void libusbWrapper::init() libusbWrapper::~libusbWrapper() { -#if BOOST_OS_WINDOWS > 0 +#if BOOST_OS_WINDOWS // destroy default context if(p_libusb_exit) p_libusb_exit(nullptr); diff --git a/src/util/libusbWrapper/libusbWrapper.h b/src/util/libusbWrapper/libusbWrapper.h index e79c5b04..ff9b0275 100644 --- a/src/util/libusbWrapper/libusbWrapper.h +++ b/src/util/libusbWrapper/libusbWrapper.h @@ -41,7 +41,7 @@ public: private: -#if BOOST_OS_WINDOWS > 0 +#if BOOST_OS_WINDOWS HMODULE m_module = nullptr; bool m_isInitialized = false; #endif diff --git a/vcpkg.json b/vcpkg.json index 1525a5a2..519a5618 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -13,7 +13,6 @@ "default-features": false }, "rapidjson", - "vulkan", "sdl2", "boost-tokenizer", "boost-container", @@ -30,6 +29,7 @@ "boost-ptr-container", "boost-property-tree", "boost-static-string", + "boost-random", "fmt", "glm", "glslang",