Files
ppsspp/headless/SDLUtil.cpp
T
libretroadmin f0b97a2e90 Remove the standalone frontends
The libretro core is the frontend, and the headless tools are the test and
debugging hosts. The Windows, UWP, Android, iOS, macOS and SDL apps, the UI
framework and imgui go, along with what only they used: the Win32 debugger
hooks (g_frameMutex, the shutdown lock), JNI thread attachment, the Android
text drawer, RAIntegration, Discord, recent files, game installs, tilt input,
the audio resamplers, the control mapper, memstick moving and the remote ISO
and upload server modes. The web server keeps the debugger. The MSVC, Gradle
and ndk-build projects go too.
2026-10-09 04:56:10 +02:00

67 lines
2.4 KiB
C++

#include <SDL3/SDL.h>
#include "ppsspp_config.h"
#if PPSSPP_PLATFORM(MAC) || PPSSPP_PLATFORM(IOS)
#include "headless/SDLCocoaMetalLayer.h"
#endif
#include "Common/GPU/MiscTypes.h"
#include "Common/GPU/Vulkan/VulkanLoader.h"
#include "Common/GPU/Vulkan/VulkanContext.h"
#include "Common/GPU/GraphicsContext.h"
#include "headless/SDLUtil.h"
bool DetermineVulkanWindowSystem(SDL_Window *window, WindowDesc *desc, std::string *errorMessage) {
_dbg_assert_(window);
SDL_PropertiesID windowProps = SDL_GetWindowProperties(window);
void *x11Display = SDL_GetPointerProperty(windowProps, SDL_PROP_WINDOW_X11_DISPLAY_POINTER, nullptr);
if (x11Display != nullptr) {
intptr_t x11Window = (intptr_t)SDL_GetNumberProperty(windowProps, SDL_PROP_WINDOW_X11_WINDOW_NUMBER, 0);
#if defined(VK_USE_PLATFORM_XLIB_KHR)
desc->winsys = WINDOWSYSTEM_XLIB;
desc->data1 = x11Display;
desc->data2 = (void *)x11Window;
#elif defined(VK_USE_PLATFORM_XCB_KHR)
desc->winsys = WINDOWSYSTEM_XCB;
desc->data1 = (void *)XGetXCBConnection((Display *)x11Display);
desc->data2 = (void *)x11Window;
#endif
return true;
}
#if defined(VK_USE_PLATFORM_WAYLAND_KHR)
void *waylandDisplay = SDL_GetPointerProperty(windowProps, SDL_PROP_WINDOW_WAYLAND_DISPLAY_POINTER, nullptr);
void *waylandSurface = SDL_GetPointerProperty(windowProps, SDL_PROP_WINDOW_WAYLAND_SURFACE_POINTER, nullptr);
if (waylandDisplay != nullptr && waylandSurface != nullptr) {
desc->winsys = WINDOWSYSTEM_WAYLAND;
desc->data1 = waylandDisplay;
desc->data2 = waylandSurface;
return true;
}
#elif defined(VK_USE_PLATFORM_METAL_EXT)
#if PPSSPP_PLATFORM(MAC)
void *cocoaWindow = SDL_GetPointerProperty(windowProps, SDL_PROP_WINDOW_COCOA_WINDOW_POINTER, nullptr);
if (cocoaWindow != nullptr) {
desc->winsys = WINDOWSYSTEM_METAL_EXT;
desc->data1 = makeWindowMetalCompatible(cocoaWindow);
desc->data2 = nullptr;
return true;
}
#else
// This path is currently not used as we do not use SDL on iOS, but it is here for completeness.
void *uikitWindow = SDL_GetPointerProperty(windowProps, SDL_PROP_WINDOW_UIKIT_WINDOW_POINTER, nullptr);
if (uikitWindow != nullptr) {
desc->winsys = WINDOWSYSTEM_METAL_EXT;
desc->data1 = makeWindowMetalCompatible(uikitWindow);
desc->data2 = nullptr;
return true;
}
#endif
#endif // VK_USE_PLATFORM_METAL_EXT
if (errorMessage) {
*errorMessage = "Unable to determine Vulkan window system from SDL3 window properties";
}
return false;
}