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)
|
||||
if(APPLE)
|
||||
message(STATUS "Enabling Headless! Disabling GUI.")
|
||||
else()
|
||||
message(STATUS "Enabling Headless! Disabling GUI, force enabling EGL!")
|
||||
set(USE_X11 0)
|
||||
set(USE_EGL 1)
|
||||
endif()
|
||||
set(USE_X11 0)
|
||||
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,6 +33,24 @@ bool cInterfaceAGL::Create(void* window_handle, bool core)
|
|||
return false;
|
||||
}
|
||||
|
||||
if (window_handle)
|
||||
{
|
||||
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;
|
||||
|
||||
if (cocoaWin == nil)
|
||||
{
|
||||
ERROR_LOG(VIDEO, "failed to create window");
|
||||
|
@ -58,6 +60,7 @@ bool cInterfaceAGL::Create(void* window_handle, bool core)
|
|||
[window makeFirstResponder:cocoaWin];
|
||||
[cocoaCtx setView:cocoaWin];
|
||||
[window makeKeyAndOrderFront:nil];
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -84,6 +87,8 @@ void cInterfaceAGL::Shutdown()
|
|||
|
||||
void cInterfaceAGL::Update()
|
||||
{
|
||||
if (cocoaWin)
|
||||
{
|
||||
NSWindow* window = [cocoaWin window];
|
||||
NSSize size = [cocoaWin frame].size;
|
||||
|
||||
|
@ -96,6 +101,7 @@ void cInterfaceAGL::Update()
|
|||
|
||||
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…
Reference in New Issue