diff --git a/CMakeLists.txt b/CMakeLists.txt index aa491b9e..7b931808 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -159,7 +159,7 @@ if (UNIX AND NOT APPLE) BASENAME viewporter) add_library(CemuWaylandProtocols STATIC ${WAYLAND_PROTOCOL_SRCS}) target_include_directories(CemuWaylandProtocols PUBLIC "${CMAKE_CURRENT_BINARY_DIR}") - + target_include_directories(CemuWaylandProtocols PRIVATE ${Wayland_INCLUDE_DIRS}) add_compile_definitions(HAS_WAYLAND) endif() find_package(GTK3 REQUIRED) @@ -236,4 +236,4 @@ if (NOT ZArchive_FOUND) add_subdirectory("dependencies/ZArchive" EXCLUDE_FROM_ALL) endif() -add_subdirectory(src) \ No newline at end of file +add_subdirectory(src) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 04b6dfdd..67f92728 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -154,3 +154,7 @@ endif() if (ENABLE_WXWIDGETS) target_link_libraries(CemuBin PRIVATE wx::base wx::core) endif() + +if (BSD) + target_link_libraries(CemuBin PRIVATE execinfo SPIRV-Tools SPIRV-Tools-opt) +endif() diff --git a/src/Cafe/CafeSystem.cpp b/src/Cafe/CafeSystem.cpp index d20ccd9d..c5fe8b93 100644 --- a/src/Cafe/CafeSystem.cpp +++ b/src/Cafe/CafeSystem.cpp @@ -72,7 +72,7 @@ #if BOOST_OS_LINUX #include -#elif BOOST_OS_MACOS +#elif BOOST_OS_MACOS || BOOST_OS_BSD #include #include #endif @@ -476,6 +476,12 @@ namespace CafeSystem int64_t totalRam; size_t size = sizeof(totalRam); int result = sysctlbyname("hw.memsize", &totalRam, &size, NULL, 0); + if (result == 0) + cemuLog_log(LogType::Force, "RAM: {}MB", (totalRam / 1024LL / 1024LL)); + #elif BOOST_OS_BSD + int64_t totalRam + size_t size = sizeof(totalRam); + int result = sysctlbyname("hw.physmem", &totalRam, &size, NULL, 0); if (result == 0) cemuLog_log(LogType::Force, "RAM: {}MB", (totalRam / 1024LL / 1024LL)); #endif @@ -526,6 +532,16 @@ namespace CafeSystem platform = "Linux"; #elif BOOST_OS_MACOS platform = "MacOS"; + #elif BOOST_OS_BSD + #if defined(__FreeBSD__) + platform = "FreeBSD"; + #elif defined(__OpenBSD__) + platform = "OpenBSD"; + #elif defined(__NetBSD__) + platform = "NetBSD"; + #else + platform = "Unknown BSD"; + #endif #endif cemuLog_log(LogType::Force, "Platform: {}", platform); } diff --git a/src/Cafe/HW/Latte/LatteAddrLib/LatteAddrLib_Coord.cpp b/src/Cafe/HW/Latte/LatteAddrLib/LatteAddrLib_Coord.cpp index bc43202a..26da5ec1 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 || BOOST_OS_MACOS +#if BOOST_OS_LINUX || BOOST_OS_MACOS || BOOST_OS_BSD unsigned char _BitScanReverse(uint32* _Index, uint32 _Mask) { if (!_Mask) @@ -402,4 +402,4 @@ namespace LatteAddrLib return finalMacroTileOffset | pipeOffset | bankOffset; } -}; \ No newline at end of file +}; diff --git a/src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLRenderer.cpp b/src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLRenderer.cpp index bbf988bc..907e9ef3 100644 --- a/src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLRenderer.cpp +++ b/src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLRenderer.cpp @@ -210,7 +210,7 @@ void LoadOpenGLImports() #include "Common/GLInclude/glFunctions.h" #undef GLFUNC } -#elif BOOST_OS_LINUX +#elif BOOST_OS_LINUX || BOOST_OS_BSD GL_IMPORT _GetOpenGLFunction(void* hLib, PFNGLXGETPROCADDRESSPROC func, const char* name) { GL_IMPORT r = (GL_IMPORT)func((const GLubyte*)name); @@ -245,7 +245,7 @@ void LoadOpenGLImports() #undef EGLFUNC } -#if BOOST_OS_LINUX +#if BOOST_OS_LINUX || BOOST_OS_BSD // dummy function for all code that is statically linked with cemu and attempts to use eglSwapInterval // used to suppress wxWidgets calls to eglSwapInterval extern "C" diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/RendererShaderVk.cpp b/src/Cafe/HW/Latte/Renderer/Vulkan/RendererShaderVk.cpp index 8a66c81b..665a5da3 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/RendererShaderVk.cpp +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/RendererShaderVk.cpp @@ -8,7 +8,7 @@ #include #include -#include +#include "util/helpers/helpers.h" bool s_isLoadingShadersVk{ false }; class FileCache* s_spirvCache{nullptr}; diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanAPI.cpp b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanAPI.cpp index ad32b541..e09ebcd1 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanAPI.cpp +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanAPI.cpp @@ -3,7 +3,7 @@ #include "Cafe/HW/Latte/Renderer/Vulkan/VulkanAPI.h" #include // for std::iota -#if BOOST_OS_LINUX || BOOST_OS_MACOS +#if BOOST_OS_LINUX || BOOST_OS_MACOS || BOOST_OS_BSD #include #endif @@ -138,7 +138,7 @@ bool InitializeDeviceVulkan(VkDevice device) void* dlopen_vulkan_loader() { -#if BOOST_OS_LINUX +#if BOOST_OS_LINUX || BOOST_OS_BSD void* vulkan_so = dlopen("libvulkan.so", RTLD_NOW); if(!vulkan_so) vulkan_so = dlopen("libvulkan.so.1", RTLD_NOW); diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanAPI.h b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanAPI.h index ae2a62f2..e670cbd1 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanAPI.h +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanAPI.h @@ -130,7 +130,7 @@ VKFUNC_DEVICE(vkDestroyPipeline); VKFUNC_DEVICE(vkCmdBindPipeline); // swapchain -#if BOOST_OS_LINUX +#if BOOST_OS_LINUX || BOOST_OS_BSD VKFUNC_INSTANCE(vkCreateXlibSurfaceKHR); VKFUNC_INSTANCE(vkCreateXcbSurfaceKHR); #ifdef HAS_WAYLAND diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp index aed0db25..43249de2 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp @@ -112,7 +112,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); - #elif BOOST_OS_LINUX + #elif BOOST_OS_LINUX || BOOST_OS_BSD auto backend = gui_getWindowInfo().window_main.backend; if(backend == WindowHandleInfo::Backend::X11) requiredExtensions.emplace_back(VK_KHR_XLIB_SURFACE_EXTENSION_NAME); @@ -1310,7 +1310,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); - #elif BOOST_OS_LINUX + #elif BOOST_OS_LINUX || BOOST_OS_BSD auto backend = gui_getWindowInfo().window_main.backend; if(backend == WindowHandleInfo::Backend::X11) requiredInstanceExtensions.emplace_back(VK_KHR_XLIB_SURFACE_EXTENSION_NAME); @@ -1397,7 +1397,7 @@ VkSurfaceKHR VulkanRenderer::CreateWinSurface(VkInstance instance, HWND hwindow) } #endif -#if BOOST_OS_LINUX +#if BOOST_OS_LINUX || BOOST_OS_BSD VkSurfaceKHR VulkanRenderer::CreateXlibSurface(VkInstance instance, Display* dpy, Window window) { VkXlibSurfaceCreateInfoKHR sci{}; @@ -1461,7 +1461,7 @@ VkSurfaceKHR VulkanRenderer::CreateFramebufferSurface(VkInstance instance, struc { #if BOOST_OS_WINDOWS return CreateWinSurface(instance, windowInfo.hwnd); -#elif BOOST_OS_LINUX +#elif BOOST_OS_LINUX || BOOST_OS_BSD if(windowInfo.backend == WindowHandleInfo::Backend::X11) return CreateXlibSurface(instance, windowInfo.xlib_display, windowInfo.xlib_window); #ifdef HAS_WAYLAND diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h index 5cc0a6f1..6a933008 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h @@ -196,7 +196,7 @@ public: #if BOOST_OS_WINDOWS static VkSurfaceKHR CreateWinSurface(VkInstance instance, HWND hwindow); #endif -#if BOOST_OS_LINUX +#if BOOST_OS_LINUX || BOOST_OS_BSD static VkSurfaceKHR CreateXlibSurface(VkInstance instance, Display* dpy, Window window); static VkSurfaceKHR CreateXcbSurface(VkInstance instance, xcb_connection_t* connection, xcb_window_t window); #ifdef HAS_WAYLAND diff --git a/src/Cafe/HW/MMU/MMU.h b/src/Cafe/HW/MMU/MMU.h index a8367f88..6e3bee70 100644 --- a/src/Cafe/HW/MMU/MMU.h +++ b/src/Cafe/HW/MMU/MMU.h @@ -184,6 +184,16 @@ bool memory_isAddressRangeAccessible(MPTR virtualAddress, uint32 size); #define CPU_swapEndianU64(_v) OSSwapInt64((uint64)(_v)) #define CPU_swapEndianU32(_v) OSSwapInt32((uint32)(_v)) #define CPU_swapEndianU16(_v) OSSwapInt16((uint16)(_v)) +#elif BOOST_OS_BSD +#ifdef __OpenBSD__ +#define CPU_swapEndianU64(_v) swap64((uint64)(_v)) +#define CPU_swapEndianU32(_v) swap32((uint32)(_v)) +#define CPU_swapEndianU16(_v) swap16((uint16)(_v)) +#else // FreeBSD and NetBSD +#define CPU_swapEndianU64(_v) bswap64((uint64)(_v)) +#define CPU_swapEndianU32(_v) bswap32((uint32)(_v)) +#define CPU_swapEndianU16(_v) bswap16((uint16)(_v)) +#endif #endif // C-style memory access, deprecated. Use memory_read<> and memory_write<> templates instead @@ -266,4 +276,4 @@ namespace MMU } -#define MMU_IsInPPCMemorySpace(__ptr) ((const uint8*)(__ptr) >= memory_base && (const uint8*)(__ptr) < (memory_base + 0x100000000)) \ No newline at end of file +#define MMU_IsInPPCMemorySpace(__ptr) ((const uint8*)(__ptr) >= memory_base && (const uint8*)(__ptr) < (memory_base + 0x100000000)) diff --git a/src/Cafe/OS/libs/coreinit/coreinit_MCP.cpp b/src/Cafe/OS/libs/coreinit/coreinit_MCP.cpp index 330663ac..95f3c6db 100644 --- a/src/Cafe/OS/libs/coreinit/coreinit_MCP.cpp +++ b/src/Cafe/OS/libs/coreinit/coreinit_MCP.cpp @@ -466,7 +466,7 @@ typedef struct static_assert(sizeof(UCParamStruct_t) == 0x54); // unsure -#if BOOST_OS_LINUX || BOOST_OS_MACOS +#if BOOST_OS_LINUX || BOOST_OS_MACOS || BOOST_OS_BSD #define _strcmpi strcasecmp #endif diff --git a/src/Cafe/OS/libs/nsyshid/BackendLibusb.h b/src/Cafe/OS/libs/nsyshid/BackendLibusb.h index 6b2d8e1a..955b3071 100644 --- a/src/Cafe/OS/libs/nsyshid/BackendLibusb.h +++ b/src/Cafe/OS/libs/nsyshid/BackendLibusb.h @@ -1,6 +1,10 @@ #include "nsyshid.h" +#if BOOST_OS_BSD +#include +#else #include +#endif #include "Backend.h" namespace nsyshid::backend::libusb diff --git a/src/Common/CMakeLists.txt b/src/Common/CMakeLists.txt index 9a764593..dec0bc42 100644 --- a/src/Common/CMakeLists.txt +++ b/src/Common/CMakeLists.txt @@ -46,7 +46,7 @@ PRIVATE ) endif() -if(UNIX AND NOT APPLE) +if(LINUX) target_sources(CemuCommon PRIVATE ExceptionHandler/ELFSymbolTable.cpp ExceptionHandler/ELFSymbolTable.h diff --git a/src/Common/GLInclude/GLInclude.h b/src/Common/GLInclude/GLInclude.h index 86df0232..e6a4e8cf 100644 --- a/src/Common/GLInclude/GLInclude.h +++ b/src/Common/GLInclude/GLInclude.h @@ -6,7 +6,7 @@ #include "wglext.h" #endif -#if BOOST_OS_LINUX > 0 +#if ( BOOST_OS_LINUX || BOOST_OS_BSD ) > 0 // from Xlib #define Bool int diff --git a/src/Common/GLInclude/glFunctions.h b/src/Common/GLInclude/glFunctions.h index 76308fdb..412816af 100644 --- a/src/Common/GLInclude/glFunctions.h +++ b/src/Common/GLInclude/glFunctions.h @@ -297,7 +297,7 @@ GLFUNC(PFNWGLSWAPINTERVALEXTPROC, wglSwapIntervalEXT) // x -#if BOOST_OS_LINUX +#if BOOST_OS_LINUX || BOOST_OS_BSD EGLFUNC(PFNEGLSWAPINTERVALPROC, eglSwapInterval) EGLFUNC(PFNEGLGETCURRENTDISPLAYPROC, eglGetCurrentDisplay) #endif diff --git a/src/Common/platform.h b/src/Common/platform.h index 3f480f43..08462a97 100644 --- a/src/Common/platform.h +++ b/src/Common/platform.h @@ -5,8 +5,12 @@ #if BOOST_OS_WINDOWS #include "Common/windows/platform.h" -#elif BOOST_OS_LINUX +#elif BOOST_OS_LINUX || BOOST_OS_BSD +#if BOOST_OS_LINUX #include +#elif BOOST_OS_BSD +#include +#endif #include #include #include diff --git a/src/Common/precompiled.h b/src/Common/precompiled.h index 26fdfd28..d03be448 100644 --- a/src/Common/precompiled.h +++ b/src/Common/precompiled.h @@ -143,6 +143,12 @@ inline uint64 _swapEndianU64(uint64 v) { #if BOOST_OS_MACOS return OSSwapInt64(v); +#elif BOOST_OS_BSD +#ifdef __OpenBSD__ + return swap64(v); +#else // FreeBSD and NetBSD + return bswap64(v); +#endif #else return bswap_64(v); #endif @@ -152,6 +158,12 @@ inline uint32 _swapEndianU32(uint32 v) { #if BOOST_OS_MACOS return OSSwapInt32(v); +#elif BOOST_OS_BSD +#ifdef __OpenBSD__ + return swap32(v); +#else // FreeBSD and NetBSD + return bswap32(v); +#endif #else return bswap_32(v); #endif @@ -161,6 +173,12 @@ inline sint32 _swapEndianS32(sint32 v) { #if BOOST_OS_MACOS return (sint32)OSSwapInt32((uint32)v); +#elif BOOST_OS_BSD +#ifdef __OpenBSD__ + return (sint32)swap32((uint32)v); +#else // FreeBSD and NetBSD + return (sint32)bswap32((uint32)v); +#endif #else return (sint32)bswap_32((uint32)v); #endif @@ -452,6 +470,11 @@ bool match_any_of(T1&& value, Types&&... others) #elif BOOST_OS_MACOS return std::chrono::steady_clock::time_point( std::chrono::nanoseconds(clock_gettime_nsec_np(CLOCK_MONOTONIC_RAW))); +#elif BOOST_OS_BSD + struct timespec tp; + clock_gettime(CLOCK_MONOTONIC, &tp); + return std::chrono::steady_clock::time_point( + std::chrono::seconds(tp.tv_sec) + std::chrono::nanoseconds(tp.tv_nsec)); #endif } diff --git a/src/Common/unix/platform.cpp b/src/Common/unix/platform.cpp index 144d4f02..879ae4dc 100644 --- a/src/Common/unix/platform.cpp +++ b/src/Common/unix/platform.cpp @@ -9,6 +9,10 @@ uint32_t GetTickCount() return (1000 * ts.tv_sec + ts.tv_nsec / 1000000); #elif BOOST_OS_MACOS return clock_gettime_nsec_np(CLOCK_MONOTONIC_RAW) / 1000000; +#elif BOOST_OS_BSD + struct timespec ts; + clock_gettime(CLOCK_MONOTONIC, &ts); + return (1000 * ts.tv_sec + ts.tv_nsec / 1000000); #endif -} \ No newline at end of file +} diff --git a/src/gui/CemuApp.cpp b/src/gui/CemuApp.cpp index c3606292..d8cc7847 100644 --- a/src/gui/CemuApp.cpp +++ b/src/gui/CemuApp.cpp @@ -12,7 +12,7 @@ #include "gui/helpers/wxHelpers.h" #include "Cemu/ncrypto/ncrypto.h" -#if BOOST_OS_LINUX && HAS_WAYLAND +#if ( BOOST_OS_LINUX || BOOST_OS_BSD ) && HAS_WAYLAND #include "gui/helpers/wxWayland.h" #endif #if __WXGTK__ @@ -115,7 +115,7 @@ void CemuApp::DeterminePaths(std::set& failedWriteAccess) // for Windo } #endif -#if BOOST_OS_LINUX +#if BOOST_OS_LINUX || BOOST_OS_BSD void CemuApp::DeterminePaths(std::set& failedWriteAccess) // for Linux { std::error_code ec; @@ -334,7 +334,7 @@ bool CemuApp::OnInit() SetTopWindow(m_mainFrame); m_mainFrame->Show(); -#if BOOST_OS_LINUX && HAS_WAYLAND +#if ( BOOST_OS_LINUX || BOOST_OS_BSD ) && HAS_WAYLAND if (wxWlIsWaylandWindow(m_mainFrame)) wxWlSetAppId(m_mainFrame, "info.cemu.Cemu"); #endif diff --git a/src/gui/CemuUpdateWindow.cpp b/src/gui/CemuUpdateWindow.cpp index 6a4e6885..f11db205 100644 --- a/src/gui/CemuUpdateWindow.cpp +++ b/src/gui/CemuUpdateWindow.cpp @@ -109,7 +109,7 @@ bool CemuUpdateWindow::QueryUpdateInfo(std::string& downloadUrlOut, std::string& std::string urlStr("https://cemu.info/api2/version.php?v="); auto* curl = curl_easy_init(); urlStr.append(_curlUrlEscape(curl, BUILD_VERSION_STRING)); -#if BOOST_OS_LINUX +#if BOOST_OS_LINUX || BOOST_OS_BSD // dummy placeholder on BSD for now urlStr.append("&platform=linux_appimage_x86"); #elif BOOST_OS_WINDOWS urlStr.append("&platform=windows"); @@ -117,6 +117,9 @@ bool CemuUpdateWindow::QueryUpdateInfo(std::string& downloadUrlOut, std::string& urlStr.append("&platform=macos_bundle_x86"); #elif #error Name for current platform is missing +#endif +#if BOOST_OS_BSD + return false; // BSD users must update from source; no binary available #endif const auto& config = GetConfig(); if(config.receive_untested_updates) @@ -416,7 +419,7 @@ void CemuUpdateWindow::WorkerThread() #if BOOST_OS_WINDOWS const auto update_file = tmppath / L"update.zip"; -#elif BOOST_OS_LINUX +#elif BOOST_OS_LINUX || BOOST_OS_BSD // dummy placeholder on BSD for now const auto update_file = tmppath / L"Cemu.AppImage"; #elif BOOST_OS_MACOS const auto update_file = tmppath / L"cemu.dmg"; diff --git a/src/gui/GameProfileWindow.cpp b/src/gui/GameProfileWindow.cpp index f15395e4..61aa062a 100644 --- a/src/gui/GameProfileWindow.cpp +++ b/src/gui/GameProfileWindow.cpp @@ -11,7 +11,7 @@ #include "gui/helpers/wxHelpers.h" #include "input/InputManager.h" -#if BOOST_OS_LINUX || BOOST_OS_MACOS +#if BOOST_OS_LINUX || BOOST_OS_MACOS || BOOST_OS_BSD #include "resource/embedded/resources.h" #endif @@ -365,4 +365,4 @@ void GameProfileWindow::SetSliderValue(wxSlider* slider, sint32 new_value) const slider_event.SetEventObject(slider); slider_event.SetClientData((void*)IsFrozen()); wxPostEvent(slider->GetEventHandler(), slider_event); -} \ No newline at end of file +} diff --git a/src/gui/GeneralSettings2.cpp b/src/gui/GeneralSettings2.cpp index 4c23aedc..a65e443b 100644 --- a/src/gui/GeneralSettings2.cpp +++ b/src/gui/GeneralSettings2.cpp @@ -224,6 +224,8 @@ wxPanel* GeneralSettings2::AddGeneralPage(wxNotebook* notebook) if (!std::getenv("APPIMAGE")) { m_auto_update->Disable(); } +#elif BOOST_OS_BSD // BSD users must update from source so disable auto updates + m_auto_update->Disable(); #endif box_sizer->Add(second_row, 0, wxEXPAND, 5); diff --git a/src/gui/GettingStartedDialog.cpp b/src/gui/GettingStartedDialog.cpp index b613c38c..9e8c5669 100644 --- a/src/gui/GettingStartedDialog.cpp +++ b/src/gui/GettingStartedDialog.cpp @@ -16,7 +16,7 @@ #include "Cafe/TitleList/TitleList.h" -#if BOOST_OS_LINUX || BOOST_OS_MACOS +#if BOOST_OS_LINUX || BOOST_OS_MACOS || BOOST_OS_BSD #include "resource/embedded/resources.h" #endif diff --git a/src/gui/GraphicPacksWindow2.cpp b/src/gui/GraphicPacksWindow2.cpp index c49cbeae..2aa20096 100644 --- a/src/gui/GraphicPacksWindow2.cpp +++ b/src/gui/GraphicPacksWindow2.cpp @@ -12,7 +12,7 @@ #include "wxHelper.h" -#if BOOST_OS_LINUX || BOOST_OS_MACOS +#if BOOST_OS_LINUX || BOOST_OS_MACOS || BOOST_OS_BSD #include "resource/embedded/resources.h" #endif diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index bf880e48..483341e9 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -48,11 +48,11 @@ #define exit(__c) _Exit(__c) #endif -#if BOOST_OS_LINUX || BOOST_OS_MACOS +#if BOOST_OS_LINUX || BOOST_OS_MACOS || BOOST_OS_BSD #include "resource/embedded/resources.h" #endif -#if BOOST_OS_LINUX && HAS_WAYLAND +#if ( BOOST_OS_LINUX || BOOST_OS_BSD ) && HAS_WAYLAND #include "gui/helpers/wxWayland.h" #endif @@ -706,7 +706,7 @@ void MainWindow::OnInstallUpdate(wxCommandEvent& event) break; if (modalChoice == wxID_OK) { - #if BOOST_OS_LINUX || BOOST_OS_MACOS + #if BOOST_OS_LINUX || BOOST_OS_MACOS || BOOST_OS_BSD fs::path dirPath((const char*)(openDirDialog.GetPath().fn_str())); #else fs::path dirPath(openDirDialog.GetPath().fn_str()); @@ -808,7 +808,7 @@ void MainWindow::TogglePadView() m_padView->Show(true); -#if BOOST_OS_LINUX && HAS_WAYLAND +#if ( BOOST_OS_LINUX || BOOST_OS_BSD ) && HAS_WAYLAND if (wxWlIsWaylandWindow(m_padView)) wxWlSetAppId(m_padView, "info.cemu.Cemu"); #endif @@ -2313,6 +2313,8 @@ void MainWindow::RecreateMenu() if (!std::getenv("APPIMAGE")) { m_check_update_menu->Enable(false); } +#elif BOOST_OS_BSD // BSD users must update from source so disable update checks + m_check_update_menu->Enable(false); #endif helpMenu->AppendSeparator(); helpMenu->Append(MAINFRAME_MENU_ID_HELP_ABOUT, _("&About Cemu")); diff --git a/src/gui/PadViewFrame.cpp b/src/gui/PadViewFrame.cpp index e7cc5c18..6c2d7d7f 100644 --- a/src/gui/PadViewFrame.cpp +++ b/src/gui/PadViewFrame.cpp @@ -13,7 +13,7 @@ #include "gui/helpers/wxHelpers.h" #include "input/InputManager.h" -#if BOOST_OS_LINUX || BOOST_OS_MACOS +#if BOOST_OS_LINUX || BOOST_OS_MACOS || BOOST_OS_BSD #include "resource/embedded/resources.h" #endif #include "wxHelper.h" diff --git a/src/gui/canvas/OpenGLCanvas.cpp b/src/gui/canvas/OpenGLCanvas.cpp index 29ff4294..32a34d9d 100644 --- a/src/gui/canvas/OpenGLCanvas.cpp +++ b/src/gui/canvas/OpenGLCanvas.cpp @@ -70,7 +70,7 @@ public: #if BOOST_OS_WINDOWS if(wglSwapIntervalEXT) wglSwapIntervalEXT(configValue); // 1 = enabled, 0 = disabled -#elif BOOST_OS_LINUX +#elif BOOST_OS_LINUX || BOOST_OS_BSD if (eglSwapInterval) { if (eglSwapInterval(eglGetCurrentDisplay(), configValue) == EGL_FALSE) diff --git a/src/gui/canvas/VulkanCanvas.cpp b/src/gui/canvas/VulkanCanvas.cpp index 8b0c8506..246dfea5 100644 --- a/src/gui/canvas/VulkanCanvas.cpp +++ b/src/gui/canvas/VulkanCanvas.cpp @@ -2,7 +2,7 @@ #include "Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h" #include "gui/guiWrapper.h" -#if BOOST_OS_LINUX && HAS_WAYLAND +#if ( BOOST_OS_LINUX || BOOST_OS_BSD ) && HAS_WAYLAND #include "gui/helpers/wxWayland.h" #endif @@ -17,7 +17,7 @@ VulkanCanvas::VulkanCanvas(wxWindow* parent, const wxSize& size, bool is_main_wi WindowHandleInfo& canvas = is_main_window ? gui_getWindowInfo().canvas_main : gui_getWindowInfo().canvas_pad; gui_initHandleContextFromWxWidgetsWindow(canvas, this); - #if BOOST_OS_LINUX && HAS_WAYLAND + #if ( BOOST_OS_LINUX || BOOST_OS_BSD ) && HAS_WAYLAND if (canvas.backend == WindowHandleInfo::Backend::WAYLAND) { m_subsurface = std::make_unique(this); @@ -70,7 +70,7 @@ void VulkanCanvas::OnResize(wxSizeEvent& event) if (size.GetWidth() == 0 || size.GetHeight() == 0) return; -#if BOOST_OS_LINUX && HAS_WAYLAND +#if ( BOOST_OS_LINUX || BOOST_OS_BSD ) && HAS_WAYLAND if(m_subsurface) { auto sRect = GetScreenRect(); diff --git a/src/gui/canvas/VulkanCanvas.h b/src/gui/canvas/VulkanCanvas.h index 13d03a1e..e61e3988 100644 --- a/src/gui/canvas/VulkanCanvas.h +++ b/src/gui/canvas/VulkanCanvas.h @@ -9,7 +9,7 @@ class VulkanCanvas : public IRenderCanvas, public wxWindow { -#if BOOST_OS_LINUX && HAS_WAYLAND +#if ( BOOST_OS_LINUX || BOOST_OS_BSD ) && HAS_WAYLAND std::unique_ptr m_subsurface; #endif public: diff --git a/src/gui/components/wxGameList.cpp b/src/gui/components/wxGameList.cpp index e30b16f5..efcb8363 100644 --- a/src/gui/components/wxGameList.cpp +++ b/src/gui/components/wxGameList.cpp @@ -1372,7 +1372,7 @@ void wxGameList::DeleteCachedStrings() m_name_cache.clear(); } -#if BOOST_OS_LINUX +#if BOOST_OS_LINUX || BOOST_OS_BSD void wxGameList::CreateShortcut(GameInfo2& gameInfo) { const auto titleId = gameInfo.GetBaseTitleId(); diff --git a/src/gui/guiWrapper.cpp b/src/gui/guiWrapper.cpp index d887e89a..0394fa33 100644 --- a/src/gui/guiWrapper.cpp +++ b/src/gui/guiWrapper.cpp @@ -1,4 +1,4 @@ -#if BOOST_OS_LINUX +#if BOOST_OS_LINUX || BOOST_OS_BSD #include #include #include @@ -191,7 +191,7 @@ bool gui_isPadWindowOpen() return g_window_info.pad_open; } -#if BOOST_OS_LINUX +#if BOOST_OS_LINUX || BOOST_OS_BSD std::string gui_gtkRawKeyCodeToString(uint32 keyCode) { return gdk_keyval_name(keyCode); @@ -202,7 +202,7 @@ void gui_initHandleContextFromWxWidgetsWindow(WindowHandleInfo& handleInfoOut, c { #if BOOST_OS_WINDOWS handleInfoOut.hwnd = wxw->GetHWND(); -#elif BOOST_OS_LINUX +#elif BOOST_OS_LINUX || BOOST_OS_BSD GtkWidget* gtkWidget = (GtkWidget*)wxw->GetHandle(); // returns GtkWidget gtk_widget_realize(gtkWidget); GdkWindow* gdkWindow = gtk_widget_get_window(gtkWidget); diff --git a/src/gui/guiWrapper.h b/src/gui/guiWrapper.h index ec94c1a0..9bb82eb4 100644 --- a/src/gui/guiWrapper.h +++ b/src/gui/guiWrapper.h @@ -1,7 +1,7 @@ #pragma once -#if BOOST_OS_LINUX -#include "xcb/xproto.h" +#if BOOST_OS_LINUX || BOOST_OS_BSD +#include #include #endif @@ -13,7 +13,7 @@ struct WindowHandleInfo { #if BOOST_OS_WINDOWS std::atomic hwnd; -#elif BOOST_OS_LINUX +#elif BOOST_OS_LINUX || BOOST_OS_BSD enum class Backend { X11, @@ -42,7 +42,7 @@ enum struct PlatformKeyCodes : uint32 RCONTROL = VK_RCONTROL, TAB = VK_TAB, ESCAPE = VK_ESCAPE, -#elif BOOST_OS_LINUX +#elif BOOST_OS_LINUX || BOOST_OS_BSD LCONTROL = GDK_KEY_Control_L, RCONTROL = GDK_KEY_Control_R, TAB = GDK_KEY_Tab, @@ -142,7 +142,7 @@ bool gui_isFullScreen(); void gui_initHandleContextFromWxWidgetsWindow(WindowHandleInfo& handleInfoOut, class wxWindow* wxw); -#if BOOST_OS_LINUX +#if BOOST_OS_LINUX || BOOST_OS_BSD std::string gui_gtkRawKeyCodeToString(uint32 keyCode); #endif /* diff --git a/src/gui/helpers/wxWayland.cpp b/src/gui/helpers/wxWayland.cpp index c677451c..cc50df1f 100644 --- a/src/gui/helpers/wxWayland.cpp +++ b/src/gui/helpers/wxWayland.cpp @@ -1,6 +1,6 @@ #include "gui/helpers/wxWayland.h" -#if BOOST_OS_LINUX && HAS_WAYLAND +#if ( BOOST_OS_LINUX || BOOST_OS_BSD ) && HAS_WAYLAND #include diff --git a/src/gui/helpers/wxWayland.h b/src/gui/helpers/wxWayland.h index a3b82119..0f162787 100644 --- a/src/gui/helpers/wxWayland.h +++ b/src/gui/helpers/wxWayland.h @@ -1,6 +1,6 @@ #pragma once -#if BOOST_OS_LINUX && HAS_WAYLAND +#if ( BOOST_OS_LINUX || BOOST_OS_BSD ) && HAS_WAYLAND #include #include diff --git a/src/gui/input/InputAPIAddWindow.cpp b/src/gui/input/InputAPIAddWindow.cpp index 6bfb589b..fb7bc2fe 100644 --- a/src/gui/input/InputAPIAddWindow.cpp +++ b/src/gui/input/InputAPIAddWindow.cpp @@ -190,7 +190,7 @@ void InputAPIAddWindow::on_api_selected(wxCommandEvent& event) } else { -#if BOOST_OS_LINUX +#if BOOST_OS_LINUX || BOOST_OS_BSD // We rely on the wxEVT_COMBOBOX_DROPDOWN event to trigger filling the controller list, // but on wxGTK the dropdown button cannot be clicked if the list is empty // so as a quick and dirty workaround we fill the list here diff --git a/src/gui/input/InputSettings2.cpp b/src/gui/input/InputSettings2.cpp index 2ae8a74b..189e4e34 100644 --- a/src/gui/input/InputSettings2.cpp +++ b/src/gui/input/InputSettings2.cpp @@ -149,7 +149,7 @@ wxWindow* InputSettings2::initialize_page(size_t index) auto* profiles = new wxComboBox(page, wxID_ANY, kDefaultProfileName); sizer->Add(profiles, wxGBPosition(0, 1), wxDefaultSpan, wxALIGN_CENTER_VERTICAL | wxALL | wxEXPAND, 5); -#if BOOST_OS_LINUX +#if BOOST_OS_LINUX || BOOST_OS_BSD // We rely on the wxEVT_COMBOBOX_DROPDOWN event to trigger filling the profile list, // but on wxGTK the dropdown button cannot be clicked if the list is empty // so as a quick and dirty workaround we fill the list here diff --git a/src/input/api/Keyboard/KeyboardController.cpp b/src/input/api/Keyboard/KeyboardController.cpp index 1f5458fa..fc99fe95 100644 --- a/src/input/api/Keyboard/KeyboardController.cpp +++ b/src/input/api/Keyboard/KeyboardController.cpp @@ -38,7 +38,7 @@ std::string KeyboardController::get_button_name(uint64 button) const return key_name; else return fmt::format("key_{}", button); -#elif BOOST_OS_LINUX +#elif BOOST_OS_LINUX || BOOST_OS_BSD return gui_gtkRawKeyCodeToString(button); #else return fmt::format("key_{}", button); diff --git a/src/main.cpp b/src/main.cpp index ea1df684..4699b5b3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -40,7 +40,7 @@ #if BOOST_OS_LINUX #define _putenv(__s) putenv((char*)(__s)) #include -#elif BOOST_OS_MACOS +#elif BOOST_OS_MACOS || BOOST_OS_BSD #define _putenv(__s) putenv((char*)(__s)) #include #include @@ -251,7 +251,7 @@ int main(int argc, char* argv[]) int main(int argc, char *argv[]) { -#if BOOST_OS_LINUX +#if BOOST_OS_LINUX || BOOST_OS_BSD XInitThreads(); #endif if (!LaunchSettings::HandleCommandline(argc, argv)) diff --git a/src/util/highresolutiontimer/HighResolutionTimer.cpp b/src/util/highresolutiontimer/HighResolutionTimer.cpp index bb4a40ab..48a7ad1f 100644 --- a/src/util/highresolutiontimer/HighResolutionTimer.cpp +++ b/src/util/highresolutiontimer/HighResolutionTimer.cpp @@ -14,6 +14,11 @@ HighResolutionTimer HighResolutionTimer::now() return HighResolutionTimer(nsec); #elif BOOST_OS_MACOS return HighResolutionTimer(clock_gettime_nsec_np(CLOCK_MONOTONIC_RAW)); +#elif BOOST_OS_BSD + timespec pc; + clock_gettime(CLOCK_MONOTONIC, &pc); + uint64 nsec = (uint64)pc.tv_sec * (uint64)1000000000 + (uint64)pc.tv_nsec; + return HighResolutionTimer(nsec); #endif } @@ -29,6 +34,10 @@ uint64 HighResolutionTimer::m_freq = []() -> uint64 { return (uint64)(freq.QuadPart); #elif BOOST_OS_MACOS return 1000000000; +#elif BOOST_OS_BSD + timespec pc; + clock_getres(CLOCK_MONOTONIC, &pc); + return (uint64)1000000000 / (uint64)pc.tv_nsec; #else timespec pc; clock_getres(CLOCK_MONOTONIC_RAW, &pc);