mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-09-21 03:41:42 +02:00
MainNoGUI: Remove old OS X backend that doesn't work, rearchitect
This commit is contained in:
parent
e3a9ba30e3
commit
09eb30ea3b
1 changed files with 118 additions and 108 deletions
|
@ -18,24 +18,26 @@
|
||||||
#include "Core/Core.h"
|
#include "Core/Core.h"
|
||||||
#include "Core/CoreParameter.h"
|
#include "Core/CoreParameter.h"
|
||||||
#include "Core/Host.h"
|
#include "Core/Host.h"
|
||||||
|
#include "Core/State.h"
|
||||||
#include "Core/HW/Wiimote.h"
|
#include "Core/HW/Wiimote.h"
|
||||||
#include "Core/PowerPC/PowerPC.h"
|
#include "Core/PowerPC/PowerPC.h"
|
||||||
|
|
||||||
#include "VideoCommon/VideoBackendBase.h"
|
#include "VideoCommon/VideoBackendBase.h"
|
||||||
|
|
||||||
#if HAVE_X11
|
|
||||||
#include <X11/keysym.h>
|
|
||||||
#include "Core/State.h"
|
|
||||||
#include "DolphinWX/X11Utils.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __APPLE__
|
|
||||||
#import <Cocoa/Cocoa.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static bool rendererHasFocus = true;
|
static bool rendererHasFocus = true;
|
||||||
static bool running = true;
|
static bool running = true;
|
||||||
|
|
||||||
|
class Platform
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual void Init() = 0;
|
||||||
|
virtual void MainLoop() = 0;
|
||||||
|
virtual void Shutdown() = 0;
|
||||||
|
virtual ~Platform() {};
|
||||||
|
};
|
||||||
|
|
||||||
|
static Platform* platform;
|
||||||
|
|
||||||
void Host_NotifyMapLoaded() {}
|
void Host_NotifyMapLoaded() {}
|
||||||
void Host_RefreshDSPDebuggerWindow() {}
|
void Host_RefreshDSPDebuggerWindow() {}
|
||||||
|
|
||||||
|
@ -121,54 +123,67 @@ void Host_SetWiiMoteConnectionState(int _State) {}
|
||||||
void Host_ShowVideoConfig(void*, const std::string&, const std::string&) {}
|
void Host_ShowVideoConfig(void*, const std::string&, const std::string&) {}
|
||||||
|
|
||||||
#if HAVE_X11
|
#if HAVE_X11
|
||||||
static void X11_MainLoop()
|
#include <X11/keysym.h>
|
||||||
|
#include "DolphinWX/X11Utils.h"
|
||||||
|
|
||||||
|
class PlatformX11 : public Platform
|
||||||
{
|
{
|
||||||
bool fullscreen = SConfig::GetInstance().m_LocalCoreStartupParameter.bFullscreen;
|
Display *dpy;
|
||||||
while (!Core::IsRunning())
|
|
||||||
updateMainFrameEvent.Wait();
|
|
||||||
|
|
||||||
Display *dpy = XOpenDisplay(0);
|
|
||||||
Window win = (Window)Core::GetWindowHandle();
|
|
||||||
XSelectInput(dpy, win, KeyPressMask | FocusChangeMask);
|
|
||||||
|
|
||||||
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bDisableScreenSaver)
|
|
||||||
X11Utils::InhibitScreensaver(dpy, win, true);
|
|
||||||
|
|
||||||
#if defined(HAVE_XRANDR) && HAVE_XRANDR
|
|
||||||
X11Utils::XRRConfiguration *XRRConfig = new X11Utils::XRRConfiguration(dpy, win);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
Cursor blankCursor = None;
|
Cursor blankCursor = None;
|
||||||
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor)
|
|
||||||
{
|
|
||||||
// make a blank cursor
|
|
||||||
Pixmap Blank;
|
|
||||||
XColor DummyColor;
|
|
||||||
char ZeroData[1] = {0};
|
|
||||||
Blank = XCreateBitmapFromData (dpy, win, ZeroData, 1, 1);
|
|
||||||
blankCursor = XCreatePixmapCursor(dpy, Blank, Blank, &DummyColor, &DummyColor, 0, 0);
|
|
||||||
XFreePixmap (dpy, Blank);
|
|
||||||
XDefineCursor(dpy, win, blankCursor);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fullscreen)
|
|
||||||
{
|
|
||||||
X11Utils::EWMH_Fullscreen(dpy, _NET_WM_STATE_TOGGLE);
|
|
||||||
#if defined(HAVE_XRANDR) && HAVE_XRANDR
|
#if defined(HAVE_XRANDR) && HAVE_XRANDR
|
||||||
XRRConfig->ToggleDisplayMode(True);
|
X11Utils::XRRConfiguration *XRRConfig;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void Init() override
|
||||||
|
{
|
||||||
|
XInitThreads();
|
||||||
|
dpy = XOpenDisplay(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
// The actual loop
|
void MainLoop() override
|
||||||
while (running)
|
|
||||||
{
|
{
|
||||||
XEvent event;
|
Window win = (Window)Core::GetWindowHandle();
|
||||||
KeySym key;
|
XSelectInput(dpy, win, KeyPressMask | FocusChangeMask);
|
||||||
for (int num_events = XPending(dpy); num_events > 0; num_events--)
|
|
||||||
|
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bDisableScreenSaver)
|
||||||
|
X11Utils::InhibitScreensaver(dpy, win, true);
|
||||||
|
|
||||||
|
#if defined(HAVE_XRANDR) && HAVE_XRANDR
|
||||||
|
XRRConfig = new X11Utils::XRRConfiguration(dpy, win);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor)
|
||||||
{
|
{
|
||||||
XNextEvent(dpy, &event);
|
// make a blank cursor
|
||||||
switch (event.type)
|
Pixmap Blank;
|
||||||
|
XColor DummyColor;
|
||||||
|
char ZeroData[1] = {0};
|
||||||
|
Blank = XCreateBitmapFromData (dpy, win, ZeroData, 1, 1);
|
||||||
|
blankCursor = XCreatePixmapCursor(dpy, Blank, Blank, &DummyColor, &DummyColor, 0, 0);
|
||||||
|
XFreePixmap (dpy, Blank);
|
||||||
|
XDefineCursor(dpy, win, blankCursor);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool fullscreen = SConfig::GetInstance().m_LocalCoreStartupParameter.bFullscreen;
|
||||||
|
|
||||||
|
if (fullscreen)
|
||||||
|
{
|
||||||
|
X11Utils::EWMH_Fullscreen(dpy, _NET_WM_STATE_TOGGLE);
|
||||||
|
#if defined(HAVE_XRANDR) && HAVE_XRANDR
|
||||||
|
XRRConfig->ToggleDisplayMode(True);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
// The actual loop
|
||||||
|
while (running)
|
||||||
|
{
|
||||||
|
XEvent event;
|
||||||
|
KeySym key;
|
||||||
|
for (int num_events = XPending(dpy); num_events > 0; num_events--)
|
||||||
{
|
{
|
||||||
|
XNextEvent(dpy, &event);
|
||||||
|
switch (event.type)
|
||||||
|
{
|
||||||
case KeyPress:
|
case KeyPress:
|
||||||
key = XLookupKeysym((XKeyEvent*)&event, 0);
|
key = XLookupKeysym((XKeyEvent*)&event, 0);
|
||||||
if (key == XK_Escape)
|
if (key == XK_Escape)
|
||||||
|
@ -217,7 +232,7 @@ static void X11_MainLoop()
|
||||||
case FocusIn:
|
case FocusIn:
|
||||||
rendererHasFocus = true;
|
rendererHasFocus = true;
|
||||||
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor &&
|
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor &&
|
||||||
Core::GetState() != Core::CORE_PAUSE)
|
Core::GetState() != Core::CORE_PAUSE)
|
||||||
XDefineCursor(dpy, win, blankCursor);
|
XDefineCursor(dpy, win, blankCursor);
|
||||||
break;
|
break;
|
||||||
case FocusOut:
|
case FocusOut:
|
||||||
|
@ -225,44 +240,47 @@ static void X11_MainLoop()
|
||||||
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor)
|
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor)
|
||||||
XUndefineCursor(dpy, win);
|
XUndefineCursor(dpy, win);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
if (!fullscreen)
|
||||||
|
{
|
||||||
|
Window winDummy;
|
||||||
|
unsigned int borderDummy, depthDummy;
|
||||||
|
XGetGeometry(dpy, win, &winDummy,
|
||||||
|
&SConfig::GetInstance().m_LocalCoreStartupParameter.iRenderWindowXPos,
|
||||||
|
&SConfig::GetInstance().m_LocalCoreStartupParameter.iRenderWindowYPos,
|
||||||
|
(unsigned int *)&SConfig::GetInstance().m_LocalCoreStartupParameter.iRenderWindowWidth,
|
||||||
|
(unsigned int *)&SConfig::GetInstance().m_LocalCoreStartupParameter.iRenderWindowHeight,
|
||||||
|
&borderDummy, &depthDummy);
|
||||||
|
}
|
||||||
|
usleep(100000);
|
||||||
}
|
}
|
||||||
if (!fullscreen)
|
|
||||||
{
|
|
||||||
Window winDummy;
|
|
||||||
unsigned int borderDummy, depthDummy;
|
|
||||||
XGetGeometry(dpy, win, &winDummy,
|
|
||||||
&SConfig::GetInstance().m_LocalCoreStartupParameter.iRenderWindowXPos,
|
|
||||||
&SConfig::GetInstance().m_LocalCoreStartupParameter.iRenderWindowYPos,
|
|
||||||
(unsigned int *)&SConfig::GetInstance().m_LocalCoreStartupParameter.iRenderWindowWidth,
|
|
||||||
(unsigned int *)&SConfig::GetInstance().m_LocalCoreStartupParameter.iRenderWindowHeight,
|
|
||||||
&borderDummy, &depthDummy);
|
|
||||||
}
|
|
||||||
usleep(100000);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Shutdown() override
|
||||||
|
{
|
||||||
#if defined(HAVE_XRANDR) && HAVE_XRANDR
|
#if defined(HAVE_XRANDR) && HAVE_XRANDR
|
||||||
delete XRRConfig;
|
delete XRRConfig;
|
||||||
#endif
|
#endif
|
||||||
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bDisableScreenSaver)
|
|
||||||
X11Utils::InhibitScreensaver(dpy, win, false);
|
|
||||||
|
|
||||||
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor)
|
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor)
|
||||||
XFreeCursor(dpy, blankCursor);
|
XFreeCursor(dpy, blankCursor);
|
||||||
XCloseDisplay(dpy);
|
|
||||||
Core::Stop();
|
XCloseDisplay(dpy);
|
||||||
}
|
}
|
||||||
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static Platform* GetPlatform()
|
||||||
|
{
|
||||||
|
#if HAVE_X11
|
||||||
|
return new PlatformX11();
|
||||||
|
#endif
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
#ifdef __APPLE__
|
|
||||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
|
||||||
NSEvent *event = [[NSEvent alloc] init];
|
|
||||||
[NSApplication sharedApplication];
|
|
||||||
[NSApp activateIgnoringOtherApps: YES];
|
|
||||||
[NSApp finishLaunching];
|
|
||||||
#endif
|
|
||||||
int ch, help = 0;
|
int ch, help = 0;
|
||||||
struct option longopts[] = {
|
struct option longopts[] = {
|
||||||
{ "exec", no_argument, nullptr, 'e' },
|
{ "exec", no_argument, nullptr, 'e' },
|
||||||
|
@ -298,6 +316,13 @@ int main(int argc, char* argv[])
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
platform = GetPlatform();
|
||||||
|
if (!platform)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "No platform found\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
LogManager::Init();
|
LogManager::Init();
|
||||||
SConfig::Init();
|
SConfig::Init();
|
||||||
VideoBackend::PopulateList();
|
VideoBackend::PopulateList();
|
||||||
|
@ -305,45 +330,30 @@ int main(int argc, char* argv[])
|
||||||
m_LocalCoreStartupParameter.m_strVideoBackend);
|
m_LocalCoreStartupParameter.m_strVideoBackend);
|
||||||
WiimoteReal::LoadSettings();
|
WiimoteReal::LoadSettings();
|
||||||
|
|
||||||
// No use running the loop when booting fails
|
platform->Init();
|
||||||
if (BootManager::BootCore(argv[optind]))
|
|
||||||
|
if (!BootManager::BootCore(argv[optind]))
|
||||||
{
|
{
|
||||||
#if HAVE_X11
|
fprintf(stderr, "Could not boot %s\n", argv[optind]);
|
||||||
XInitThreads();
|
return 1;
|
||||||
X11_MainLoop();
|
|
||||||
#endif
|
|
||||||
#ifdef __APPLE__
|
|
||||||
while (running)
|
|
||||||
{
|
|
||||||
event = [NSApp nextEventMatchingMask: NSAnyEventMask
|
|
||||||
untilDate: [NSDate distantFuture]
|
|
||||||
inMode: NSDefaultRunLoopMode dequeue: YES];
|
|
||||||
|
|
||||||
if ([event type] == NSKeyDown &&
|
|
||||||
[event modifierFlags] & NSCommandKeyMask &&
|
|
||||||
[[event characters] UTF8String][0] == 'q')
|
|
||||||
{
|
|
||||||
Core::Stop();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ([event type] != NSKeyDown)
|
|
||||||
[NSApp sendEvent: event];
|
|
||||||
}
|
|
||||||
|
|
||||||
[event release];
|
|
||||||
[pool release];
|
|
||||||
#else
|
|
||||||
while (PowerPC::GetState() != PowerPC::CPU_POWERDOWN)
|
|
||||||
updateMainFrameEvent.Wait();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
while (!Core::IsRunning())
|
||||||
|
updateMainFrameEvent.Wait();
|
||||||
|
|
||||||
|
platform->MainLoop();
|
||||||
|
Core::Stop();
|
||||||
|
while (PowerPC::GetState() != PowerPC::CPU_POWERDOWN)
|
||||||
|
updateMainFrameEvent.Wait();
|
||||||
|
|
||||||
|
platform->Shutdown();
|
||||||
Core::Shutdown();
|
Core::Shutdown();
|
||||||
WiimoteReal::Shutdown();
|
WiimoteReal::Shutdown();
|
||||||
VideoBackend::ClearList();
|
VideoBackend::ClearList();
|
||||||
SConfig::Shutdown();
|
SConfig::Shutdown();
|
||||||
LogManager::Shutdown();
|
LogManager::Shutdown();
|
||||||
|
|
||||||
|
delete platform;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue