mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-09 07:39:26 +01:00
Add headless support on macOS
This commit is contained in:
parent
a389ae0711
commit
5298328cb1
@ -414,9 +414,13 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
endif()
|
||||
|
||||
if(ENABLE_HEADLESS)
|
||||
message(STATUS "Enabling Headless! Disabling GUI, force enabling EGL!")
|
||||
if(APPLE)
|
||||
message(STATUS "Enabling Headless! Disabling GUI.")
|
||||
else()
|
||||
message(STATUS "Enabling Headless! Disabling GUI, force enabling EGL!")
|
||||
set(USE_EGL 1)
|
||||
endif()
|
||||
set(USE_X11 0)
|
||||
set(USE_EGL 1)
|
||||
set(DISABLE_WX 1)
|
||||
set(ENABLE_QT2 0)
|
||||
add_definitions(-DUSE_HEADLESS)
|
||||
|
@ -14,22 +14,6 @@ void cInterfaceAGL::Swap()
|
||||
// Call browser: Core.cpp:EmuThread() > main.cpp:Video_Initialize()
|
||||
bool cInterfaceAGL::Create(void* window_handle, bool core)
|
||||
{
|
||||
cocoaWin = reinterpret_cast<NSView*>(window_handle);
|
||||
NSSize size = [cocoaWin frame].size;
|
||||
|
||||
// Enable high-resolution display support.
|
||||
[cocoaWin setWantsBestResolutionOpenGLSurface:YES];
|
||||
|
||||
NSWindow* window = [cocoaWin window];
|
||||
|
||||
float scale = [window backingScaleFactor];
|
||||
size.width *= scale;
|
||||
size.height *= scale;
|
||||
|
||||
// Control window size and picture scaling
|
||||
s_backbuffer_width = size.width;
|
||||
s_backbuffer_height = size.height;
|
||||
|
||||
NSOpenGLPixelFormatAttribute attr[] = {NSOpenGLPFADoubleBuffer, NSOpenGLPFAOpenGLProfile,
|
||||
core ? NSOpenGLProfileVersion3_2Core :
|
||||
NSOpenGLProfileVersionLegacy,
|
||||
@ -49,15 +33,34 @@ bool cInterfaceAGL::Create(void* window_handle, bool core)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (cocoaWin == nil)
|
||||
if (window_handle)
|
||||
{
|
||||
ERROR_LOG(VIDEO, "failed to create window");
|
||||
return false;
|
||||
}
|
||||
cocoaWin = reinterpret_cast<NSView*>(window_handle);
|
||||
NSSize size = [cocoaWin frame].size;
|
||||
|
||||
[window makeFirstResponder:cocoaWin];
|
||||
[cocoaCtx setView:cocoaWin];
|
||||
[window makeKeyAndOrderFront:nil];
|
||||
// Enable high-resolution display support.
|
||||
[cocoaWin setWantsBestResolutionOpenGLSurface:YES];
|
||||
|
||||
NSWindow* window = [cocoaWin window];
|
||||
|
||||
float scale = [window backingScaleFactor];
|
||||
size.width *= scale;
|
||||
size.height *= scale;
|
||||
|
||||
// Control window size and picture scaling
|
||||
s_backbuffer_width = size.width;
|
||||
s_backbuffer_height = size.height;
|
||||
|
||||
if (cocoaWin == nil)
|
||||
{
|
||||
ERROR_LOG(VIDEO, "failed to create window");
|
||||
return false;
|
||||
}
|
||||
|
||||
[window makeFirstResponder:cocoaWin];
|
||||
[cocoaCtx setView:cocoaWin];
|
||||
[window makeKeyAndOrderFront:nil];
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -84,18 +87,21 @@ void cInterfaceAGL::Shutdown()
|
||||
|
||||
void cInterfaceAGL::Update()
|
||||
{
|
||||
NSWindow* window = [cocoaWin window];
|
||||
NSSize size = [cocoaWin frame].size;
|
||||
if (cocoaWin)
|
||||
{
|
||||
NSWindow* window = [cocoaWin window];
|
||||
NSSize size = [cocoaWin frame].size;
|
||||
|
||||
float scale = [window backingScaleFactor];
|
||||
size.width *= scale;
|
||||
size.height *= scale;
|
||||
float scale = [window backingScaleFactor];
|
||||
size.width *= scale;
|
||||
size.height *= scale;
|
||||
|
||||
if (s_backbuffer_width == size.width && s_backbuffer_height == size.height)
|
||||
return;
|
||||
if (s_backbuffer_width == size.width && s_backbuffer_height == size.height)
|
||||
return;
|
||||
|
||||
s_backbuffer_width = size.width;
|
||||
s_backbuffer_height = size.height;
|
||||
s_backbuffer_width = size.width;
|
||||
s_backbuffer_height = size.height;
|
||||
}
|
||||
|
||||
[cocoaCtx update];
|
||||
}
|
||||
|
@ -370,7 +370,7 @@ class PlatformX11 : public Platform
|
||||
|
||||
static Platform* GetPlatform()
|
||||
{
|
||||
#if defined(USE_EGL) && defined(USE_HEADLESS)
|
||||
#if defined(USE_HEADLESS)
|
||||
return new Platform();
|
||||
#elif HAVE_X11
|
||||
return new PlatformX11();
|
||||
|
@ -173,13 +173,21 @@ static void DeviceMatchingCallback(void* inContext, IOReturn inResult, void* inS
|
||||
|
||||
// Add a device if it's of a type we want
|
||||
if (IOHIDDeviceConformsTo(inIOHIDDeviceRef, kHIDPage_GenericDesktop, kHIDUsage_GD_Keyboard))
|
||||
g_controller_interface.AddDevice(std::make_shared<Keyboard>(inIOHIDDeviceRef, name, g_window));
|
||||
{
|
||||
if (g_window)
|
||||
g_controller_interface.AddDevice(
|
||||
std::make_shared<Keyboard>(inIOHIDDeviceRef, name, g_window));
|
||||
}
|
||||
#if 0
|
||||
else if (IOHIDDeviceConformsTo(inIOHIDDeviceRef, kHIDPage_GenericDesktop, kHIDUsage_GD_Mouse))
|
||||
{
|
||||
g_controller_interface.AddDevice(new Mouse(inIOHIDDeviceRef, name));
|
||||
}
|
||||
#endif
|
||||
else
|
||||
{
|
||||
g_controller_interface.AddDevice(std::make_shared<Joystick>(inIOHIDDeviceRef, name));
|
||||
}
|
||||
|
||||
NOTICE_LOG(SERIALINTERFACE, "Added device: %s", name.c_str());
|
||||
g_controller_interface.InvokeHotplugCallbacks();
|
||||
@ -187,12 +195,12 @@ static void DeviceMatchingCallback(void* inContext, IOReturn inResult, void* inS
|
||||
|
||||
void Init(void* window)
|
||||
{
|
||||
g_window = window;
|
||||
|
||||
HIDManager = IOHIDManagerCreate(kCFAllocatorDefault, kIOHIDOptionsTypeNone);
|
||||
if (!HIDManager)
|
||||
ERROR_LOG(SERIALINTERFACE, "Failed to create HID Manager reference");
|
||||
|
||||
g_window = window;
|
||||
|
||||
IOHIDManagerSetDeviceMatching(HIDManager, nullptr);
|
||||
if (IOHIDManagerOpen(HIDManager, kIOHIDOptionsTypeNone) != kIOReturnSuccess)
|
||||
ERROR_LOG(SERIALINTERFACE, "Failed to open HID Manager");
|
||||
|
@ -12,6 +12,9 @@ namespace Quartz
|
||||
{
|
||||
void PopulateDevices(void* window)
|
||||
{
|
||||
if (!window)
|
||||
return;
|
||||
|
||||
g_controller_interface.AddDevice(std::make_shared<KeyboardAndMouse>(window));
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user