diff --git a/Source/Core/DolphinWX/Src/MainNoGUI.cpp b/Source/Core/DolphinWX/Src/MainNoGUI.cpp index 32e5a2d76c..594d32e7f5 100644 --- a/Source/Core/DolphinWX/Src/MainNoGUI.cpp +++ b/Source/Core/DolphinWX/Src/MainNoGUI.cpp @@ -17,6 +17,10 @@ #include "Thread.h" #include "PowerPC/PowerPC.h" +#if defined(HAVE_COCOA) && HAVE_COCOA +#include "cocoaApp.h" +#endif + #include "BootManager.h" void* g_pCodeWindow = NULL; void* main_frame = NULL; @@ -86,11 +90,28 @@ void Host_UpdateStatus() void Host_SetWiiMoteConnectionState(int _State) {} + +//for cocoa we need to hijack the main to get event +#if defined(HAVE_COCOA) && HAVE_COCOA +int appleMain(int argc, char *argv[]); + +int main(int argc, char *argv[]) +{ + + cocoaCreateApp(); + return appleMain(argc, argv); + +} + + +int appleMain(int argc, char *argv[]) +#else // Include SDL header so it can hijack main(). #if defined(USE_SDL) && USE_SDL #include #endif int main(int argc, char* argv[]) +#endif { gengetopt_args_info args_info; diff --git a/Source/Core/DolphinWX/Src/SConscript b/Source/Core/DolphinWX/Src/SConscript index e64271c5d6..fe71f02c8d 100644 --- a/Source/Core/DolphinWX/Src/SConscript +++ b/Source/Core/DolphinWX/Src/SConscript @@ -44,13 +44,29 @@ if wxenv['HAVE_WX']: libs = [ 'debwx' ] + libs +if wxenv['HAVE_COCOA']: + files += [ 'cocoaApp.m', ] + compileFlags = [ + '-x', + 'objective-c++', + ] + wxenv.Append( + CXXFLAGS = compileFlags, + LINKFLAGS = [ + '-pthread', + ], + LIBS = libs + ) +else: + wxenv.Append( + LINKFLAGS = [ + '-pthread', + ], + LIBS = libs + ) + + -wxenv.Append( - LINKFLAGS = [ - '-pthread', - ], - LIBS = libs - ) if sys.platform == 'darwin': exeGUI = env['binary_dir'] + 'Dolphin.app/Contents/MacOS/Dolphin' diff --git a/Source/Core/DolphinWX/Src/cocoaApp.h b/Source/Core/DolphinWX/Src/cocoaApp.h new file mode 100644 index 0000000000..259566a33a --- /dev/null +++ b/Source/Core/DolphinWX/Src/cocoaApp.h @@ -0,0 +1,11 @@ +#ifdef __cplusplus +extern "C" +{ +#endif + + +void cocoaCreateApp(); + +#ifdef __cplusplus +} +#endif diff --git a/Source/Core/DolphinWX/Src/cocoaApp.m b/Source/Core/DolphinWX/Src/cocoaApp.m new file mode 100644 index 0000000000..b6a2ea287f --- /dev/null +++ b/Source/Core/DolphinWX/Src/cocoaApp.m @@ -0,0 +1,49 @@ +#import "cocoaApp.h" +#import + +@implementation NSApplication(i) +- (void)appRunning +{ + _running = 1; +} +@end + +@interface cocoaAppDelegate : NSObject +- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender; +@end + +@implementation cocoaAppDelegate : NSObject +- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender +{ + return NSTerminateCancel; +} +@end + +void cocoaCreateApp() +{ + ProcessSerialNumber psn; + NSAutoreleasePool *pool; + + if (!GetCurrentProcess(&psn)) { + TransformProcessType(&psn, kProcessTransformToForegroundApplication); + SetFrontProcess(&psn); + } + + pool = [[NSAutoreleasePool alloc] init]; + + if (NSApp == nil) { + [NSApplication sharedApplication]; + //TODO : Create menu + [NSApp finishLaunching]; + } + + if ([NSApp delegate] == nil) { + [NSApp setDelegate:[[cocoaAppDelegate alloc] init]]; + } + + [NSApp appRunning]; + + [pool release]; + +} + diff --git a/Source/Plugins/Plugin_PadSimple/Src/SConscript b/Source/Plugins/Plugin_PadSimple/Src/SConscript index 7a112ba687..884394256c 100644 --- a/Source/Plugins/Plugin_PadSimple/Src/SConscript +++ b/Source/Plugins/Plugin_PadSimple/Src/SConscript @@ -6,18 +6,27 @@ import sys name = "Plugin_PadSimple" if not env['HAVE_X11']: - print name + " must have X11 to be built" - Return() + if not env['HAVE_COCOA']: + print name + " must have X11 to be built" + Return() if env['GLTEST']: print name + " Doesn't work with testgl" Return() + files = [ "PadSimple.cpp", ] padenv = env.Clone() + +if padenv['HAVE_COCOA']: + compileFlags = [ + '-x', + 'objective-c++', + ] + if padenv['HAVE_WX']: files += [ "GUI/ConfigDlg.cpp", diff --git a/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.cpp b/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.cpp index c7d88c15ef..5fc19a5483 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.cpp @@ -230,7 +230,6 @@ bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _iwidth, int _iheight //setup ogl to use double buffering SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); #elif defined(HAVE_COCOA) && HAVE_COCOA - cocoaGLCreateApp(); GLWin.width = nBackbufferWidth; GLWin.height = nBackbufferHeight; GLWin.cocoaWin = cocoaGLCreateWindow(GLWin.width, GLWin.height); diff --git a/Source/Plugins/Plugin_VideoOGL/Src/cocoaGL.m b/Source/Plugins/Plugin_VideoOGL/Src/cocoaGL.m index dcd7896067..47b6389226 100755 --- a/Source/Plugins/Plugin_VideoOGL/Src/cocoaGL.m +++ b/Source/Plugins/Plugin_VideoOGL/Src/cocoaGL.m @@ -1,52 +1,5 @@ #import "cocoaGL.h" -@implementation NSApplication(i) -- (void)appRunning -{ - _running = 1; -} -@end - -@interface cocoaAppDelegate : NSObject -- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender; -@end - -@implementation cocoaAppDelegate : NSObject -- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender -{ - return NSTerminateCancel; -} -@end - - -void cocoaGLCreateApp() -{ - ProcessSerialNumber psn; - NSAutoreleasePool *pool; - - if (!GetCurrentProcess(&psn)) { - TransformProcessType(&psn, kProcessTransformToForegroundApplication); - SetFrontProcess(&psn); - } - - pool = [[NSAutoreleasePool alloc] init]; - - if (NSApp == nil) { - [NSApplication sharedApplication]; - //TODO : Create menu - [NSApp finishLaunching]; - } - - if ([NSApp delegate] == nil) { - [NSApp setDelegate:[[cocoaAppDelegate alloc] init]]; - } - - [NSApp appRunning]; - - [pool release]; - -} - NSWindow *cocoaGLCreateWindow(int w,int h) {