mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-30 01:29:42 -06:00
Revert parts of r5576 and r5598 for Sonicadvance1's sake.
This reenables the option for building without wx on OS X, but still leaves wxgl as the default. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5599 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
@ -714,7 +714,7 @@ void CFrame::OnCustomHostMessage(int Id)
|
||||
|
||||
CPluginManager::GetInstance().OpenDebug(
|
||||
GetHandle(),
|
||||
SConfig::GetInstance().m_LocalCoreStartupParameter.m_strDSPPlugin.c_str(),
|
||||
SConfig::GetInstance().m_LocalCoreStartupParameter.m_strDSPPlugin,
|
||||
PLUGIN_TYPE_DSP, false
|
||||
);
|
||||
|
||||
|
@ -32,6 +32,10 @@
|
||||
#include "X11Utils.h"
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE__
|
||||
#import "cocoaApp.h"
|
||||
#endif
|
||||
|
||||
#include "Core.h"
|
||||
#include "Globals.h"
|
||||
#include "Host.h"
|
||||
@ -255,12 +259,110 @@ void X11_MainLoop()
|
||||
}
|
||||
#endif
|
||||
|
||||
//for cocoa we need to hijack the main to get event
|
||||
#ifdef __APPLE__
|
||||
|
||||
@interface CocoaThread : NSObject
|
||||
{
|
||||
NSThread *Thread;
|
||||
}
|
||||
- (void)cocoaThreadStart;
|
||||
- (void)cocoaThreadRun:(id)sender;
|
||||
- (void)cocoaThreadQuit:(NSNotification*)note;
|
||||
- (bool)cocoaThreadRunning;
|
||||
@end
|
||||
|
||||
static NSString *CocoaThreadHaveFinish = @"CocoaThreadHaveFinish";
|
||||
|
||||
int cocoaArgc;
|
||||
char **cocoaArgv;
|
||||
int appleMain(int argc, char *argv[]);
|
||||
|
||||
@implementation CocoaThread
|
||||
|
||||
- (void)cocoaThreadStart
|
||||
{
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(cocoaThreadQuit:) name:CocoaThreadHaveFinish object:nil];
|
||||
[NSThread detachNewThreadSelector:@selector(cocoaThreadRun:) toTarget:self withObject:nil];
|
||||
|
||||
}
|
||||
|
||||
- (void)cocoaThreadRun:(id)sender
|
||||
{
|
||||
|
||||
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
|
||||
Thread = [NSThread currentThread];
|
||||
//launch main
|
||||
appleMain(cocoaArgc,cocoaArgv);
|
||||
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:CocoaThreadHaveFinish object:nil];
|
||||
|
||||
[pool release];
|
||||
|
||||
}
|
||||
|
||||
- (void)cocoaThreadQuit:(NSNotification*)note
|
||||
{
|
||||
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
|
||||
}
|
||||
|
||||
- (bool)cocoaThreadRunning
|
||||
{
|
||||
if([Thread isFinished])
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
|
||||
cocoaArgc = argc;
|
||||
cocoaArgv = argv;
|
||||
|
||||
cocoaCreateApp();
|
||||
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
CocoaThread *thread = [[CocoaThread alloc] init];
|
||||
NSEvent *event = [[NSEvent alloc] init];
|
||||
|
||||
[thread cocoaThreadStart];
|
||||
|
||||
//cocoa event loop
|
||||
while(1)
|
||||
{
|
||||
event = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:[NSDate distantPast] inMode:NSDefaultRunLoopMode dequeue:YES ];
|
||||
if(cocoaSendEvent(event))
|
||||
{
|
||||
Core::Stop();
|
||||
break;
|
||||
}
|
||||
if(![thread cocoaThreadRunning])
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
[event release];
|
||||
[thread release];
|
||||
[pool release];
|
||||
}
|
||||
|
||||
|
||||
int appleMain(int argc, char *argv[])
|
||||
#else
|
||||
// Include SDL header so it can hijack main().
|
||||
#if defined(USE_SDL) && USE_SDL
|
||||
#include <SDL.h>
|
||||
#endif
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
#endif
|
||||
{
|
||||
gengetopt_args_info args_info;
|
||||
|
||||
|
@ -44,27 +44,37 @@ if wxenv['HAVE_WX']:
|
||||
'NetWindow.cpp',
|
||||
]
|
||||
|
||||
CPPDEFINE = [
|
||||
CPPDEFINES = [
|
||||
'wxNEEDS_CHARPP',
|
||||
],
|
||||
|
||||
compileFlags = [
|
||||
],
|
||||
|
||||
|
||||
libs = [ 'debwx', 'debugger_ui_util'] + libs
|
||||
|
||||
if sys.platform == 'darwin':
|
||||
files += [ 'cocoaApp.m', ]
|
||||
compileFlags = [
|
||||
'-x',
|
||||
'objective-c++',
|
||||
]
|
||||
wxenv.Append(
|
||||
CXXFLAGS = compileFlags,
|
||||
LINKFLAGS = [
|
||||
'-pthread', '-framework', 'IOKit'
|
||||
],
|
||||
LIBS = libs
|
||||
)
|
||||
else:
|
||||
wxenv.Append(
|
||||
LINKFLAGS = [
|
||||
'-pthread',
|
||||
],
|
||||
LIBS = libs
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
if sys.platform == 'darwin':
|
||||
compileFlags = [
|
||||
'-x',
|
||||
'objective-c++',
|
||||
]
|
||||
|
||||
linkflags = [
|
||||
'-pthread', '-framework', 'IOKit'
|
||||
]
|
||||
|
||||
exeGUI = env['binary_dir'] + 'Dolphin.app/Contents/MacOS/Dolphin'
|
||||
exeNoGUI = env['binary_dir'] + 'DolphinNoGUI'
|
||||
|
||||
@ -86,17 +96,11 @@ if sys.platform == 'darwin':
|
||||
else:
|
||||
exeGUI = env['binary_dir'] + 'dolphin-emu'
|
||||
exeNoGUI = env['binary_dir'] + 'dolphin-emu-nogui'
|
||||
linkflags = [ '-pthread' ]
|
||||
|
||||
if wxenv['HAVE_X11']:
|
||||
files += [ 'X11Utils.cpp' ]
|
||||
|
||||
|
||||
wxenv.Append(
|
||||
CXXFLAGS = compileFlags,
|
||||
LINKFLAGS = linkflags,
|
||||
LIBS = libs,
|
||||
)
|
||||
#objects = [ wxenv.Object(srcFile) for srcFile in files ]
|
||||
|
||||
if wxenv['HAVE_WX']:
|
||||
wxenv.Program(exeGUI, files + [ 'Main.cpp' ])
|
||||
|
15
Source/Core/DolphinWX/Src/cocoaApp.h
Normal file
15
Source/Core/DolphinWX/Src/cocoaApp.h
Normal file
@ -0,0 +1,15 @@
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
bool cocoaSendEvent(NSEvent *event);
|
||||
|
||||
void cocoaCreateApp();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
109
Source/Core/DolphinWX/Src/cocoaApp.m
Normal file
109
Source/Core/DolphinWX/Src/cocoaApp.m
Normal file
@ -0,0 +1,109 @@
|
||||
#import "cocoaApp.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 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];
|
||||
|
||||
}
|
||||
|
||||
bool cocoaKeyCode(NSEvent *event)
|
||||
{
|
||||
static bool CMDDown = false, QDown = false;
|
||||
bool Return = false;
|
||||
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
NSConnection *connec = [[NSConnection new] autorelease];
|
||||
|
||||
[connec setRootObject: event];
|
||||
if ([connec registerName: @"DolphinCocoaEvent"] == NO)
|
||||
{
|
||||
//printf("error creating nsconnection\n");
|
||||
}
|
||||
|
||||
if( [event type] != NSFlagsChanged )
|
||||
{
|
||||
const char *Keys = [[event characters] UTF8String];
|
||||
|
||||
if( Keys[0] == 'q' && [event type] == NSKeyDown )
|
||||
QDown = true;
|
||||
if( Keys[0] == 'q' && [event type] == NSKeyUp )
|
||||
QDown = false;
|
||||
}
|
||||
else
|
||||
if( [event modifierFlags] & NSCommandKeyMask )
|
||||
CMDDown = true;
|
||||
else
|
||||
CMDDown = false;
|
||||
|
||||
if( QDown && CMDDown )
|
||||
Return = true;
|
||||
|
||||
[pool release];
|
||||
return Return;
|
||||
}
|
||||
|
||||
bool cocoaSendEvent(NSEvent *event)
|
||||
{
|
||||
|
||||
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
if ( event != nil ) {
|
||||
switch ([event type]) {
|
||||
case NSKeyDown:
|
||||
case NSKeyUp:
|
||||
case NSFlagsChanged: // For Command
|
||||
return cocoaKeyCode(event);
|
||||
break;
|
||||
default:
|
||||
[NSApp sendEvent:event];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[pool release];
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user