diff --git a/macosx/Snes9x/AppDelegate.h b/macosx/Snes9x/AppDelegate.h index 3d171eb7..ec6ff939 100644 --- a/macosx/Snes9x/AppDelegate.h +++ b/macosx/Snes9x/AppDelegate.h @@ -19,9 +19,12 @@ ***********************************************************************************/ #import +#import @interface AppDelegate : NSObject +@property (nonatomic, readonly, assign) BOOL isRunningEmulation; + - (void)setButtonCode:(S9xButtonCode)buttonCode forKeyCode:(int16)keyCode player:(int8)player; - (void)clearButton:(S9xButtonCode)button forPlayer:(int8)player; diff --git a/macosx/Snes9x/AppDelegate.m b/macosx/Snes9x/AppDelegate.m index 4f999eeb..655fb6f2 100644 --- a/macosx/Snes9x/AppDelegate.m +++ b/macosx/Snes9x/AppDelegate.m @@ -19,7 +19,6 @@ ***********************************************************************************/ #import -#import #import "AppDelegate.h" @@ -456,7 +455,13 @@ static NSWindowFrameAutosaveName const kMainWindowIdentifier = @"s9xMainWindow"; - (BOOL)validateMenuItem:(NSMenuItem *)menuItem { - return [self.s9xEngine isPaused] || ![self.s9xEngine isRunning]; + return !self.isRunningEmulation; +} + +@dynamic isRunningEmulation; +- (BOOL)isRunningEmulation +{ + return [self.s9xEngine isRunning] && ![self.s9xEngine isPaused]; } - (IBAction)terminate:(id)sender diff --git a/macosx/Snes9x/Info.plist b/macosx/Snes9x/Info.plist index 92191109..ac546840 100644 --- a/macosx/Snes9x/Info.plist +++ b/macosx/Snes9x/Info.plist @@ -29,7 +29,7 @@ CFBundleHelpBookName Snes9x Help NSPrincipalClass - NSApplication + S9xApplication CFBundleDocumentTypes diff --git a/macosx/Snes9x/S9xApplication.h b/macosx/Snes9x/S9xApplication.h new file mode 100644 index 00000000..54d737e9 --- /dev/null +++ b/macosx/Snes9x/S9xApplication.h @@ -0,0 +1,29 @@ +/*****************************************************************************\ + 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. +\*****************************************************************************/ + +/*********************************************************************************** + SNES9X for Mac OS (c) Copyright John Stiles + + Snes9x for Mac OS X + + (c) Copyright 2001 - 2011 zones + (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 + (c) Copyright 2019 Michael Donald Buckley + ***********************************************************************************/ + +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface S9xApplication : NSApplication + +@end + +NS_ASSUME_NONNULL_END diff --git a/macosx/Snes9x/S9xApplication.m b/macosx/Snes9x/S9xApplication.m new file mode 100644 index 00000000..98201a30 --- /dev/null +++ b/macosx/Snes9x/S9xApplication.m @@ -0,0 +1,38 @@ +/*****************************************************************************\ + 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. +\*****************************************************************************/ + +/*********************************************************************************** + SNES9X for Mac OS (c) Copyright John Stiles + + Snes9x for Mac OS X + + (c) Copyright 2001 - 2011 zones + (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 + (c) Copyright 2019 Michael Donald Buckley + ***********************************************************************************/ + +#import "S9xApplication.h" +#import "AppDelegate.h" + +@implementation S9xApplication + +- (void)sendEvent:(NSEvent *)event +{ + if (event.modifierFlags * NSEventModifierFlagCommand && event.type == NSEventTypeKeyUp && ((AppDelegate *)self.delegate).isRunningEmulation) + { + [self.keyWindow sendEvent:event]; + } + else + { + [super sendEvent:event]; + } +} + +@end diff --git a/macosx/snes9x.xcodeproj/project.pbxproj b/macosx/snes9x.xcodeproj/project.pbxproj index 3fa6d545..c70ac733 100755 --- a/macosx/snes9x.xcodeproj/project.pbxproj +++ b/macosx/snes9x.xcodeproj/project.pbxproj @@ -59,6 +59,7 @@ 3082C4252378BCE80081CA7C /* FakeHandles.c in Sources */ = {isa = PBXBuildFile; fileRef = 3082C4202378BCE80081CA7C /* FakeHandles.c */; }; 3082C4262378BCE80081CA7C /* FakeResources.c in Sources */ = {isa = PBXBuildFile; fileRef = 3082C4212378BCE80081CA7C /* FakeResources.c */; }; 3082C4272378BCE80081CA7C /* FakeResources.h in Headers */ = {isa = PBXBuildFile; fileRef = 3082C4222378BCE80081CA7C /* FakeResources.h */; }; + 3082C42A2379199F0081CA7C /* S9xApplication.m in Sources */ = {isa = PBXBuildFile; fileRef = 3082C4292379199F0081CA7C /* S9xApplication.m */; }; 30D15CF322CE6B5A005BC352 /* snes9x_framework.h in Headers */ = {isa = PBXBuildFile; fileRef = 30D15CF122CE6B5A005BC352 /* snes9x_framework.h */; settings = {ATTRIBUTES = (Public, ); }; }; 30D15CFC22CE6B74005BC352 /* sha256.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 85FEF90A20DDB18D00C038E9 /* sha256.cpp */; }; 30D15CFE22CE6B74005BC352 /* bml.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 85FEF90620DDB15B00C038E9 /* bml.cpp */; }; @@ -267,6 +268,8 @@ 3082C4202378BCE80081CA7C /* FakeHandles.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = FakeHandles.c; sourceTree = ""; }; 3082C4212378BCE80081CA7C /* FakeResources.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = FakeResources.c; sourceTree = ""; }; 3082C4222378BCE80081CA7C /* FakeResources.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FakeResources.h; sourceTree = ""; }; + 3082C4282379199F0081CA7C /* S9xApplication.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = S9xApplication.h; sourceTree = ""; }; + 3082C4292379199F0081CA7C /* S9xApplication.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = S9xApplication.m; sourceTree = ""; }; 30AD1D1E22FBB2EA000EE989 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 30AD1D1F22FBB2EA000EE989 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = ""; }; 30AD1D2022FBB2EA000EE989 /* en */ = {isa = PBXFileReference; lastKnownFileType = folder; name = en; path = "en.lproj/Snes9x Help"; sourceTree = ""; }; @@ -631,6 +634,8 @@ 30D709C4236F90DF00AAB7C3 /* S9xButtonConfigTextField.m */, 30D2506D2373AACC0076A160 /* S9xPrefsConstants.m */, 30D2506F2373AB880076A160 /* S9xPrefsConstants.h */, + 3082C4282379199F0081CA7C /* S9xApplication.h */, + 3082C4292379199F0081CA7C /* S9xApplication.m */, ); path = Snes9x; sourceTree = ""; @@ -1184,6 +1189,7 @@ 30D709C5236F90DF00AAB7C3 /* S9xButtonConfigTextField.m in Sources */, 30714721230E379600917F82 /* main.m in Sources */, 30714719230E379500917F82 /* AppDelegate.m in Sources */, + 3082C42A2379199F0081CA7C /* S9xApplication.m in Sources */, 30D709C1236F7E3200AAB7C3 /* S9xPrefsViewController.m in Sources */, 30D2506E2373AACC0076A160 /* S9xPrefsConstants.m in Sources */, );