Make it easier to build Cemu on the BSDs. Tested on amd64 FreeBSD 14.3-STABLE. Should work on at least OpenBSD as well.

This commit is contained in:
Kevin Reinholz 2025-07-04 09:04:55 -07:00
parent e68c31e5fb
commit 7454d54cf2
40 changed files with 139 additions and 58 deletions

View File

@ -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)
add_subdirectory(src)

View File

@ -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()

View File

@ -72,7 +72,7 @@
#if BOOST_OS_LINUX
#include <sys/sysinfo.h>
#elif BOOST_OS_MACOS
#elif BOOST_OS_MACOS || BOOST_OS_BSD
#include <sys/types.h>
#include <sys/sysctl.h>
#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);
}

View File

@ -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;
}
};
};

View File

@ -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"

View File

@ -8,7 +8,7 @@
#include <glslang/Public/ShaderLang.h>
#include <glslang/SPIRV/GlslangToSpv.h>
#include <util/helpers/helpers.h>
#include "util/helpers/helpers.h"
bool s_isLoadingShadersVk{ false };
class FileCache* s_spirvCache{nullptr};

View File

@ -3,7 +3,7 @@
#include "Cafe/HW/Latte/Renderer/Vulkan/VulkanAPI.h"
#include <numeric> // for std::iota
#if BOOST_OS_LINUX || BOOST_OS_MACOS
#if BOOST_OS_LINUX || BOOST_OS_MACOS || BOOST_OS_BSD
#include <dlfcn.h>
#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);

View File

@ -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

View File

@ -112,7 +112,7 @@ std::vector<VulkanRenderer::DeviceInfo> 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<const char*> 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

View File

@ -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

View File

@ -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))
#define MMU_IsInPPCMemorySpace(__ptr) ((const uint8*)(__ptr) >= memory_base && (const uint8*)(__ptr) < (memory_base + 0x100000000))

View File

@ -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

View File

@ -1,6 +1,10 @@
#include "nsyshid.h"
#if BOOST_OS_BSD
#include <libusb.h>
#else
#include <libusb-1.0/libusb.h>
#endif
#include "Backend.h"
namespace nsyshid::backend::libusb

View File

@ -46,7 +46,7 @@ PRIVATE
)
endif()
if(UNIX AND NOT APPLE)
if(LINUX)
target_sources(CemuCommon PRIVATE
ExceptionHandler/ELFSymbolTable.cpp
ExceptionHandler/ELFSymbolTable.h

View File

@ -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

View File

@ -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

View File

@ -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 <byteswap.h>
#elif BOOST_OS_BSD
#include <endian.h>
#endif
#include <X11/Xlib.h>
#include <X11/extensions/Xrender.h>
#include <X11/Xutil.h>

View File

@ -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
}

View File

@ -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
}
}

View File

@ -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<fs::path>& failedWriteAccess) // for Windo
}
#endif
#if BOOST_OS_LINUX
#if BOOST_OS_LINUX || BOOST_OS_BSD
void CemuApp::DeterminePaths(std::set<fs::path>& 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

View File

@ -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";

View File

@ -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);
}
}

View File

@ -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);

View File

@ -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

View File

@ -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

View File

@ -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"));

View File

@ -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"

View File

@ -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)

View File

@ -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<wxWlSubsurface>(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();

View File

@ -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<class wxWlSubsurface> m_subsurface;
#endif
public:

View File

@ -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();

View File

@ -1,4 +1,4 @@
#if BOOST_OS_LINUX
#if BOOST_OS_LINUX || BOOST_OS_BSD
#include <gtk/gtk.h>
#include <gdk/gdk.h>
#include <gdk/gdkwindow.h>
@ -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);

View File

@ -1,7 +1,7 @@
#pragma once
#if BOOST_OS_LINUX
#include "xcb/xproto.h"
#if BOOST_OS_LINUX || BOOST_OS_BSD
#include <xcb/xproto.h>
#include <gdk/gdkkeysyms.h>
#endif
@ -13,7 +13,7 @@ struct WindowHandleInfo
{
#if BOOST_OS_WINDOWS
std::atomic<HWND> 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
/*

View File

@ -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 <dlfcn.h>

View File

@ -1,6 +1,6 @@
#pragma once
#if BOOST_OS_LINUX && HAS_WAYLAND
#if ( BOOST_OS_LINUX || BOOST_OS_BSD ) && HAS_WAYLAND
#include <gdk/gdk.h>
#include <gdk/gdkwayland.h>

View File

@ -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

View File

@ -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

View File

@ -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);

View File

@ -40,7 +40,7 @@
#if BOOST_OS_LINUX
#define _putenv(__s) putenv((char*)(__s))
#include <sys/sysinfo.h>
#elif BOOST_OS_MACOS
#elif BOOST_OS_MACOS || BOOST_OS_BSD
#define _putenv(__s) putenv((char*)(__s))
#include <sys/types.h>
#include <sys/sysctl.h>
@ -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))

View File

@ -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);