From d22595086216d3c145e1c0c876ccdf70a50fe6ed Mon Sep 17 00:00:00 2001 From: Gerasim Troeglazov <3dEyes@gmail.com> Date: Wed, 23 Dec 2020 14:30:54 +1000 Subject: applying patch dolphin-5.0.13178.patch diff --git a/CMakeLists.txt b/CMakeLists.txt index b01b90f..0685107 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,7 +20,7 @@ set(DISTRIBUTOR "None" CACHE STRING "Name of the distributor.") if(UNIX AND NOT APPLE AND NOT ANDROID) option(ENABLE_X11 "Enables X11 Support" ON) endif() -if(NOT WIN32 AND NOT APPLE) +if(NOT WIN32 AND NOT APPLE AND NOT HAIKU) option(ENABLE_EGL "Enables EGL OpenGL Interface" ON) endif() diff --git a/Source/Core/Common/CMakeLists.txt b/Source/Core/Common/CMakeLists.txt index 543c4cf..7656fd1 100644 --- a/Source/Core/Common/CMakeLists.txt +++ b/Source/Core/Common/CMakeLists.txt @@ -168,6 +168,8 @@ elseif (ANDROID) PRIVATE androidcommon ) +elseif(HAIKU) + target_link_libraries(common PRIVATE be GL) endif() if(ANDROID) @@ -256,6 +258,11 @@ elseif(APPLE) GL/GLInterface/AGL.h GL/GLInterface/AGL.mm ) +elseif(HAIKU) + target_sources(common PRIVATE + GL/GLInterface/BGL.h + GL/GLInterface/BGL.cpp + ) elseif(ENABLE_X11 AND X11_FOUND) target_sources(common PRIVATE GL/GLX11Window.cpp diff --git a/Source/Core/Common/GL/GLContext.cpp b/Source/Core/Common/GL/GLContext.cpp index 2f72204..9450085 100644 --- a/Source/Core/Common/GL/GLContext.cpp +++ b/Source/Core/Common/GL/GLContext.cpp @@ -12,6 +12,9 @@ #if defined(_WIN32) #include "Common/GL/GLInterface/WGL.h" #endif +#if defined(__HAIKU__) +#include "Common/GL/GLInterface/BGL.h" +#endif #if HAVE_X11 #include "Common/GL/GLInterface/GLX.h" #endif @@ -92,6 +95,10 @@ std::unique_ptr GLContext::Create(const WindowSystemInfo& wsi, bool s if (wsi.type == WindowSystemType::Android) context = std::make_unique(); #endif +#if defined(__HAIKU__) + if (wsi.type == WindowSystemType::Haiku) + context = std::make_unique(); +#endif #if HAVE_X11 if (wsi.type == WindowSystemType::X11) { diff --git a/Source/Core/Common/GL/GLInterface/BGL.cpp b/Source/Core/Common/GL/GLInterface/BGL.cpp new file mode 100644 index 0000000..118639c --- /dev/null +++ b/Source/Core/Common/GL/GLInterface/BGL.cpp @@ -0,0 +1,93 @@ +// Copyright 2017 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#include "Common/GL/GLInterface/BGL.h" + +#include +#include +#include + +BGLView* GLContextBGL::m_current = nullptr; + +GLContextBGL::~GLContextBGL() +{ + if (!m_window) + delete m_gl; +} + +bool GLContextBGL::Initialize(const WindowSystemInfo& wsi, bool stereo, bool core) +{ + m_window = static_cast(wsi.render_window); + + m_gl = new BGLView(m_window ? m_window->Bounds() : BRect(), "GLContextBGL", B_FOLLOW_ALL_SIDES, 0, + BGL_RGB | BGL_DOUBLE | BGL_ALPHA); + if (m_window) + m_window->AddChild(m_gl); + + m_opengl_mode = Mode::OpenGL; + + m_gl->LockLooper(); + BRect size = m_gl->Frame(); + m_gl->UnlockLooper(); + + m_backbuffer_width = size.IntegerWidth(); + m_backbuffer_height = size.IntegerHeight(); + + MakeCurrent(); + + return true; +} + +bool GLContextBGL::IsHeadless() const +{ + return !m_window; +} + +bool GLContextBGL::MakeCurrent() +{ + if (m_current) + m_current->UnlockGL(); + m_gl->LockGL(); + m_current = m_gl; + return true; +} + +bool GLContextBGL::ClearCurrent() +{ + if (!m_current) + return true; + + //assert(m_gl == m_current); + m_current->UnlockGL(); + m_current = nullptr; + return true; +} + +void GLContextBGL::Swap() +{ + m_gl->SwapBuffers(); +} + +void GLContextBGL::Update() +{ + m_gl->LockLooper(); + BRect size = m_gl->Frame(); + if (m_backbuffer_width == size.IntegerWidth() && m_backbuffer_height == size.IntegerHeight()) { + m_gl->UnlockLooper(); + return; + } + + ClearCurrent(); + m_gl->FrameResized(size.Width(), size.Height()); + MakeCurrent(); + m_gl->UnlockLooper(); + + m_backbuffer_width = size.IntegerWidth(); + m_backbuffer_height = size.IntegerHeight(); +} + +void* GLContextBGL::GetFuncAddress(const std::string& name) +{ + return m_gl->GetGLProcAddress(name.c_str()); +} diff --git a/Source/Core/Common/GL/GLInterface/BGL.h b/Source/Core/Common/GL/GLInterface/BGL.h new file mode 100644 index 0000000..54089a3 --- /dev/null +++ b/Source/Core/Common/GL/GLInterface/BGL.h @@ -0,0 +1,36 @@ +// Copyright 2017 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#pragma once + +#include "Common/GL/GLContext.h" + +class BWindow; +class BGLView; + +class GLContextBGL final : public GLContext +{ +public: + ~GLContextBGL() override; + + bool IsHeadless() const override; + + bool MakeCurrent() override; + bool ClearCurrent() override; + + void Update() override; + + void Swap() override; + + void* GetFuncAddress(const std::string& name) override; + +protected: + bool Initialize(const WindowSystemInfo& wsi, bool stereo, bool core) override; + +private: + BWindow* m_window; + BGLView* m_gl; + + static BGLView* m_current; +}; diff --git a/Source/Core/Common/WindowSystemInfo.h b/Source/Core/Common/WindowSystemInfo.h index 244a985..ff2beba 100644 --- a/Source/Core/Common/WindowSystemInfo.h +++ b/Source/Core/Common/WindowSystemInfo.h @@ -13,6 +13,7 @@ enum class WindowSystemType X11, Wayland, FBDev, + Haiku, }; struct WindowSystemInfo diff --git a/Source/Core/Core/HW/EXI/EXI_DeviceEthernet.h b/Source/Core/Core/HW/EXI/EXI_DeviceEthernet.h index ed79b9a..0075e40 100644 --- a/Source/Core/Core/HW/EXI/EXI_DeviceEthernet.h +++ b/Source/Core/Core/HW/EXI/EXI_DeviceEthernet.h @@ -383,7 +383,7 @@ private: bool m_bba_link_up = false; bool m_bba_failure_notified = false; #if defined(WIN32) || defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || \ - defined(__OpenBSD__) + defined(__OpenBSD__) || defined(__HAIKU__) sf::UdpSocket m_sf_socket; sf::IpAddress m_sf_recipient_ip; char m_in_frame[9004]; diff --git a/Source/Core/DolphinQt/MainWindow.cpp b/Source/Core/DolphinQt/MainWindow.cpp index 54deeb4..f4a062a 100644 --- a/Source/Core/DolphinQt/MainWindow.cpp +++ b/Source/Core/DolphinQt/MainWindow.cpp @@ -152,6 +152,8 @@ static WindowSystemType GetWindowSystemType() return WindowSystemType::X11; else if (platform_name == QStringLiteral("wayland")) return WindowSystemType::Wayland; + else if (platform_name == QStringLiteral("haiku")) + return WindowSystemType::Haiku; ModalMessageBox::critical( nullptr, QStringLiteral("Error"), @@ -165,7 +167,7 @@ static WindowSystemInfo GetWindowSystemInfo(QWindow* window) wsi.type = GetWindowSystemType(); // Our Win32 Qt external doesn't have the private API. -#if defined(WIN32) || defined(__APPLE__) +#if defined(WIN32) || defined(__APPLE__) || defined(__HAIKU__) wsi.render_window = window ? reinterpret_cast(window->winId()) : nullptr; wsi.render_surface = wsi.render_window; #else diff --git a/Source/Core/VideoCommon/DriverDetails.cpp b/Source/Core/VideoCommon/DriverDetails.cpp index 88a482e..990894f 100644 --- a/Source/Core/VideoCommon/DriverDetails.cpp +++ b/Source/Core/VideoCommon/DriverDetails.cpp @@ -35,6 +35,8 @@ constexpr u32 m_os = OS_ALL | OS_LINUX; constexpr u32 m_os = OS_ALL | OS_FREEBSD; #elif __OpenBSD__ constexpr u32 m_os = OS_ALL | OS_OPENBSD; +#elif __HAIKU__ +constexpr u32 m_os = OS_ALL | OS_HAIKU; #endif static API m_api = API_OPENGL; diff --git a/Source/Core/VideoCommon/DriverDetails.h b/Source/Core/VideoCommon/DriverDetails.h index 3e58a5f..9707b1b 100644 --- a/Source/Core/VideoCommon/DriverDetails.h +++ b/Source/Core/VideoCommon/DriverDetails.h @@ -27,6 +27,7 @@ enum OS OS_ANDROID = (1 << 4), OS_FREEBSD = (1 << 5), OS_OPENBSD = (1 << 6), + OS_HAIKU = (1 << 7), }; // Enum of known vendors // Tegra and Nvidia are separated out due to such substantial differences -- 2.28.0 From ea8df0aac409204f109b9738a08af246f19076ca Mon Sep 17 00:00:00 2001 From: Gerasim Troeglazov <3dEyes@gmail.com> Date: Wed, 23 Dec 2020 14:43:33 +1000 Subject: Add haiku platform for SFML diff --git a/Externals/SFML/include/SFML/Config.hpp b/Externals/SFML/include/SFML/Config.hpp index aae5f54..4ea7e52 100644 --- a/Externals/SFML/include/SFML/Config.hpp +++ b/Externals/SFML/include/SFML/Config.hpp @@ -75,11 +75,11 @@ // Android #define SFML_SYSTEM_ANDROID - + #elif defined(__linux__) // Linux - #define SFML_SYSTEM_LINUX + #define SFML_SYSTEM_LINUXs #elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) @@ -98,6 +98,10 @@ #endif +#elif defined(__HAIKU__) + + // Haiku + #define SFML_SYSTEM_HAIKU #else // Unsupported system -- 2.28.0 From 98edbfb2c281c59c6cc9e4b0f110e81c2ba1033f Mon Sep 17 00:00:00 2001 From: Gerasim Troeglazov <3dEyes@gmail.com> Date: Wed, 23 Dec 2020 14:43:58 +1000 Subject: Fix build miniupnpc diff --git a/Externals/miniupnpc/src/minissdpc.c b/Externals/miniupnpc/src/minissdpc.c index 235175c..10942cd 100644 --- a/Externals/miniupnpc/src/minissdpc.c +++ b/Externals/miniupnpc/src/minissdpc.c @@ -63,7 +63,7 @@ struct sockaddr_un { #define PRINT_SOCKET_ERROR(x) perror(x) #endif -#if !defined(__DragonFly__) && !defined(__OpenBSD__) && !defined(__NetBSD__) && !defined(__APPLE__) && !defined(_WIN32) && !defined(__CYGWIN__) && !defined(__sun) && !defined(__GNU__) && !defined(__FreeBSD_kernel__) +#if !defined(__HAIKU__) && !defined(__DragonFly__) && !defined(__OpenBSD__) && !defined(__NetBSD__) && !defined(__APPLE__) && !defined(_WIN32) && !defined(__CYGWIN__) && !defined(__sun) && !defined(__GNU__) && !defined(__FreeBSD_kernel__) #define HAS_IP_MREQN #endif diff --git a/Externals/miniupnpc/src/portlistingparse.c b/Externals/miniupnpc/src/portlistingparse.c index 0e09278..ed6165d 100644 --- a/Externals/miniupnpc/src/portlistingparse.c +++ b/Externals/miniupnpc/src/portlistingparse.c @@ -31,7 +31,7 @@ static const struct { /* Helper function */ static UNSIGNED_INTEGER -atoui(const char * p, int l) +atoui2(const char * p, int l) { UNSIGNED_INTEGER r = 0; while(l > 0 && *p) @@ -107,7 +107,7 @@ data(void * d, const char * data, int l) pm->remoteHost[l] = '\0'; break; case NewExternalPort: - pm->externalPort = (unsigned short)atoui(data, l); + pm->externalPort = (unsigned short)atoui2(data, l); break; case NewProtocol: if(l > 3) @@ -116,21 +116,21 @@ data(void * d, const char * data, int l) pm->protocol[l] = '\0'; break; case NewInternalPort: - pm->internalPort = (unsigned short)atoui(data, l); + pm->internalPort = (unsigned short)atoui2(data, l); break; case NewInternalClient: memcpy(pm->internalClient, data, l); pm->internalClient[l] = '\0'; break; case NewEnabled: - pm->enabled = (unsigned char)atoui(data, l); + pm->enabled = (unsigned char)atoui2(data, l); break; case NewDescription: memcpy(pm->description, data, l); pm->description[l] = '\0'; break; case NewLeaseTime: - pm->leaseTime = atoui(data, l); + pm->leaseTime = atoui2(data, l); break; default: break; -- 2.28.0 From 666173360da2692c19590baa9fe7185988a9c708 Mon Sep 17 00:00:00 2001 From: Gerasim Troeglazov <3dEyes@gmail.com> Date: Wed, 23 Dec 2020 15:21:28 +1000 Subject: Fix minizip build diff --git a/Externals/minizip/ioapi.h b/Externals/minizip/ioapi.h index efb94a4..4644eaf 100644 --- a/Externals/minizip/ioapi.h +++ b/Externals/minizip/ioapi.h @@ -25,7 +25,7 @@ # define ftello64 ftell # define fseeko64 fseek #else -# if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__) || defined(__OpenBSD__) || defined(__APPLE__) +# if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__) || defined(__OpenBSD__) || defined(__APPLE__) || defined(__HAIKU__) # define fopen64 fopen # define ftello64 ftello # define fseeko64 fseeko -- 2.28.0 From 1f562378b2a8d3a26a530846b9e3f54fbf5b23b0 Mon Sep 17 00:00:00 2001 From: Gerasim Troeglazov <3dEyes@gmail.com> Date: Wed, 23 Dec 2020 15:22:09 +1000 Subject: Disable SetLocale for Haiku diff --git a/Source/Core/UICommon/UICommon.cpp b/Source/Core/UICommon/UICommon.cpp index ec612df..dcd00ec 100644 --- a/Source/Core/UICommon/UICommon.cpp +++ b/Source/Core/UICommon/UICommon.cpp @@ -116,6 +116,7 @@ void Shutdown() void SetLocale(std::string locale_name) { +#ifndef __HAIKU__ auto set_locale = [](const std::string& locale) { #ifdef __linux__ std::string adjusted_locale = locale; @@ -169,6 +170,7 @@ void SetLocale(std::string locale_name) // If none of the locales tried above are supported, we just keep using whatever locale is set // (which is the classic locale by default). +#endif } void CreateDirectories() -- 2.28.0