Mac: fix controls getting "stuck" when combined with modifier keys

This commit is contained in:
Michael Buckley 2019-11-10 20:31:49 -08:00
parent ef30c1626a
commit cd4f69b65a
6 changed files with 84 additions and 3 deletions

View File

@ -19,9 +19,12 @@
***********************************************************************************/
#import <Cocoa/Cocoa.h>
#import <snes9x_framework/snes9x_framework.h>
@interface AppDelegate : NSObject <NSApplicationDelegate, S9xInputDelegate>
@property (nonatomic, readonly, assign) BOOL isRunningEmulation;
- (void)setButtonCode:(S9xButtonCode)buttonCode forKeyCode:(int16)keyCode player:(int8)player;
- (void)clearButton:(S9xButtonCode)button forPlayer:(int8)player;

View File

@ -19,7 +19,6 @@
***********************************************************************************/
#import <Carbon/Carbon.h>
#import <snes9x_framework/snes9x_framework.h>
#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

View File

@ -29,7 +29,7 @@
<key>CFBundleHelpBookName</key>
<string>Snes9x Help</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
<string>S9xApplication</string>
<key>CFBundleDocumentTypes</key>
<array>
<dict>

View File

@ -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 <Cocoa/Cocoa.h>
NS_ASSUME_NONNULL_BEGIN
@interface S9xApplication : NSApplication
@end
NS_ASSUME_NONNULL_END

View File

@ -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

View File

@ -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 = "<group>"; };
3082C4212378BCE80081CA7C /* FakeResources.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = FakeResources.c; sourceTree = "<group>"; };
3082C4222378BCE80081CA7C /* FakeResources.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FakeResources.h; sourceTree = "<group>"; };
3082C4282379199F0081CA7C /* S9xApplication.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = S9xApplication.h; sourceTree = "<group>"; };
3082C4292379199F0081CA7C /* S9xApplication.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = S9xApplication.m; sourceTree = "<group>"; };
30AD1D1E22FBB2EA000EE989 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
30AD1D1F22FBB2EA000EE989 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = "<group>"; };
30AD1D2022FBB2EA000EE989 /* en */ = {isa = PBXFileReference; lastKnownFileType = folder; name = en; path = "en.lproj/Snes9x Help"; sourceTree = "<group>"; };
@ -631,6 +634,8 @@
30D709C4236F90DF00AAB7C3 /* S9xButtonConfigTextField.m */,
30D2506D2373AACC0076A160 /* S9xPrefsConstants.m */,
30D2506F2373AB880076A160 /* S9xPrefsConstants.h */,
3082C4282379199F0081CA7C /* S9xApplication.h */,
3082C4292379199F0081CA7C /* S9xApplication.m */,
);
path = Snes9x;
sourceTree = "<group>";
@ -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 */,
);