2018-11-16 00:31:39 +01:00
|
|
|
/*****************************************************************************\
|
|
|
|
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
|
|
|
|
This file is licensed under the Snes9x License.
|
|
|
|
For further information, consult the LICENSE file in the root directory.
|
|
|
|
\*****************************************************************************/
|
2010-09-25 17:46:12 +02:00
|
|
|
|
|
|
|
/***********************************************************************************
|
|
|
|
SNES9X for Mac OS (c) Copyright John Stiles
|
|
|
|
|
|
|
|
Snes9x for Mac OS X
|
|
|
|
|
2011-04-10 15:44:28 +02:00
|
|
|
(c) Copyright 2001 - 2011 zones
|
2010-09-25 17:46:12 +02:00
|
|
|
(c) Copyright 2002 - 2005 107
|
|
|
|
(c) Copyright 2002 PB1400c
|
|
|
|
(c) Copyright 2004 Alexander and Sander
|
|
|
|
(c) Copyright 2004 - 2005 Steven Seeger
|
|
|
|
(c) Copyright 2005 Ryan Vogt
|
2019-09-02 19:20:32 +02:00
|
|
|
(c) Copyright 2019 Michael Donald Buckley
|
2010-09-25 17:46:12 +02:00
|
|
|
***********************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
#include "port.h"
|
|
|
|
|
|
|
|
#include "mac-prefix.h"
|
|
|
|
#include "mac-os.h"
|
|
|
|
#include "mac-snes9x.h"
|
|
|
|
#include "mac-appleevent.h"
|
|
|
|
|
|
|
|
static AEEventHandlerUPP oappUPP, rappUPP, pdocUPP, quitUPP, odocUPP;
|
|
|
|
|
2019-05-24 03:18:53 +02:00
|
|
|
static OSErr AEoapp (const AppleEvent *, AppleEvent *, long);
|
|
|
|
static OSErr AErapp (const AppleEvent *, AppleEvent *, long);
|
|
|
|
static OSErr AEpdoc (const AppleEvent *, AppleEvent *, long);
|
|
|
|
static OSErr AEquit (const AppleEvent *, AppleEvent *, long);
|
|
|
|
static OSErr AEodoc (const AppleEvent *, AppleEvent *, long);
|
2010-09-25 17:46:12 +02:00
|
|
|
|
|
|
|
|
2019-05-24 03:18:53 +02:00
|
|
|
static OSErr AEoapp (const AppleEvent *theEvent, AppleEvent *theReply, long refCon)
|
2010-09-25 17:46:12 +02:00
|
|
|
{
|
|
|
|
if (running)
|
|
|
|
return (noErr);
|
|
|
|
|
|
|
|
if (startopendlog)
|
|
|
|
{
|
|
|
|
if (SNES9X_OpenCart(NULL))
|
|
|
|
{
|
|
|
|
SNES9X_Go();
|
2019-07-14 05:42:21 +02:00
|
|
|
//QuitApplicationEventLoop();
|
2010-09-25 17:46:12 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
AdjustMenus();
|
|
|
|
}
|
|
|
|
|
|
|
|
return (noErr);
|
|
|
|
}
|
|
|
|
|
2019-05-24 03:18:53 +02:00
|
|
|
static OSErr AErapp (const AppleEvent *theEvent, AppleEvent *theReply, long refCon)
|
2010-09-25 17:46:12 +02:00
|
|
|
{
|
|
|
|
if (running)
|
|
|
|
return (noErr);
|
|
|
|
|
|
|
|
if (!cartOpen)
|
|
|
|
{
|
|
|
|
if (startopendlog)
|
|
|
|
{
|
|
|
|
if (SNES9X_OpenCart(NULL))
|
|
|
|
{
|
|
|
|
SNES9X_Go();
|
2019-07-14 05:42:21 +02:00
|
|
|
//QuitApplicationEventLoop();
|
2010-09-25 17:46:12 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
AdjustMenus();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SNES9X_Go();
|
2019-07-14 05:42:21 +02:00
|
|
|
//QuitApplicationEventLoop();
|
2010-09-25 17:46:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return (noErr);
|
|
|
|
}
|
|
|
|
|
2019-05-24 03:18:53 +02:00
|
|
|
static OSErr AEpdoc (const AppleEvent *theEvent, AppleEvent *theReply, long refCon)
|
2010-09-25 17:46:12 +02:00
|
|
|
{
|
|
|
|
return (errAEEventNotHandled);
|
|
|
|
}
|
|
|
|
|
2019-05-24 03:18:53 +02:00
|
|
|
static OSErr AEquit (const AppleEvent *theEvent, AppleEvent *theReply, long refCon)
|
2010-09-25 17:46:12 +02:00
|
|
|
{
|
|
|
|
if (running)
|
|
|
|
return (noErr);
|
|
|
|
|
|
|
|
SNES9X_Quit();
|
2019-07-14 05:42:21 +02:00
|
|
|
//QuitApplicationEventLoop();
|
2010-09-25 17:46:12 +02:00
|
|
|
|
|
|
|
return (noErr);
|
|
|
|
}
|
|
|
|
|
2019-05-24 03:18:53 +02:00
|
|
|
static OSErr AEodoc (const AppleEvent *theEvent, AppleEvent *theReply, long refCon)
|
2010-09-25 17:46:12 +02:00
|
|
|
{
|
2019-07-14 05:42:21 +02:00
|
|
|
// OSErr err;
|
|
|
|
// FSRef ref;
|
|
|
|
// AEDescList docList;
|
|
|
|
// AEKeyword keywd;
|
|
|
|
// DescType rtype;
|
|
|
|
// Size acsize;
|
|
|
|
// long count;
|
|
|
|
//
|
|
|
|
// if (running)
|
|
|
|
// return (noErr);
|
|
|
|
//
|
|
|
|
// err = AEGetParamDesc(theEvent, keyDirectObject, typeAEList, &docList);
|
|
|
|
// if (err)
|
|
|
|
// return (noErr);
|
|
|
|
//
|
|
|
|
// err = AECountItems(&docList, &count);
|
|
|
|
// if (err || (count != 1))
|
|
|
|
// {
|
|
|
|
// err = AEDisposeDesc(&docList);
|
|
|
|
// return (noErr);
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// err = AEGetNthPtr(&docList, 1, typeFSRef, &keywd, &rtype, &ref, sizeof(FSRef), &acsize);
|
|
|
|
// if (err == noErr)
|
|
|
|
// {
|
|
|
|
// if (SNES9X_OpenCart(&ref))
|
|
|
|
// {
|
|
|
|
// SNES9X_Go();
|
|
|
|
// //QuitApplicationEventLoop();
|
|
|
|
// }
|
|
|
|
// else
|
|
|
|
// AdjustMenus();
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// err = AEDisposeDesc(&docList);
|
|
|
|
//
|
|
|
|
// return (noErr);
|
|
|
|
return 0;
|
2010-09-25 17:46:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void InitAppleEvents (void)
|
|
|
|
{
|
2019-07-14 05:42:21 +02:00
|
|
|
// OSErr err;
|
|
|
|
//
|
|
|
|
// oappUPP = NewAEEventHandlerUPP(AEoapp);
|
|
|
|
// err = AEInstallEventHandler(kCoreEventClass, kAEOpenApplication, oappUPP, 0L, false);
|
|
|
|
//
|
|
|
|
// odocUPP = NewAEEventHandlerUPP(AEodoc);
|
|
|
|
// err = AEInstallEventHandler(kCoreEventClass, kAEOpenDocuments, odocUPP, 0L, false);
|
|
|
|
//
|
|
|
|
// pdocUPP = NewAEEventHandlerUPP(AEpdoc);
|
|
|
|
// err = AEInstallEventHandler(kCoreEventClass, kAEPrintDocuments, pdocUPP, 0L, false);
|
|
|
|
//
|
|
|
|
// quitUPP = NewAEEventHandlerUPP(AEquit);
|
|
|
|
// err = AEInstallEventHandler(kCoreEventClass, kAEQuitApplication, quitUPP, 0L, false);
|
|
|
|
//
|
|
|
|
// rappUPP = NewAEEventHandlerUPP(AErapp);
|
|
|
|
// err = AEInstallEventHandler(kCoreEventClass, kAEReopenApplication, rappUPP, 0L, false);
|
2010-09-25 17:46:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void DeinitAppleEvents (void)
|
|
|
|
{
|
|
|
|
DisposeAEEventHandlerUPP(oappUPP);
|
|
|
|
DisposeAEEventHandlerUPP(odocUPP);
|
|
|
|
DisposeAEEventHandlerUPP(pdocUPP);
|
|
|
|
DisposeAEEventHandlerUPP(quitUPP);
|
|
|
|
DisposeAEEventHandlerUPP(rappUPP);
|
|
|
|
}
|