diff --git a/OpenEmuKit.xcodeproj/project.pbxproj b/OpenEmuKit.xcodeproj/project.pbxproj index 5e54f3a..a3ff3c1 100644 --- a/OpenEmuKit.xcodeproj/project.pbxproj +++ b/OpenEmuKit.xcodeproj/project.pbxproj @@ -20,8 +20,8 @@ 0547FDCF24E850EB005C1FFC /* NSXPCListener+HelperApp.m in Sources */ = {isa = PBXBuildFile; fileRef = 0547FDCD24E850EB005C1FFC /* NSXPCListener+HelperApp.m */; }; 0547FDD224E85783005C1FFC /* OEXPCGameCoreManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 0547FDD024E85783005C1FFC /* OEXPCGameCoreManager.h */; settings = {ATTRIBUTES = (Public, ); }; }; 0547FDD324E85783005C1FFC /* OEXPCGameCoreManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 0547FDD124E85783005C1FFC /* OEXPCGameCoreManager.m */; }; - 0547FDDF24E8622B005C1FFC /* OpenEmuXPCHelperAppBase.h in Headers */ = {isa = PBXBuildFile; fileRef = 0547FDDD24E8622B005C1FFC /* OpenEmuXPCHelperAppBase.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 0547FDE024E8622B005C1FFC /* OpenEmuXPCHelperAppBase.m in Sources */ = {isa = PBXBuildFile; fileRef = 0547FDDE24E8622B005C1FFC /* OpenEmuXPCHelperAppBase.m */; }; + 0547FDDF24E8622B005C1FFC /* OpenEmuXPCHelperApp.h in Headers */ = {isa = PBXBuildFile; fileRef = 0547FDDD24E8622B005C1FFC /* OpenEmuXPCHelperApp.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 0547FDE024E8622B005C1FFC /* OpenEmuXPCHelperApp.m in Sources */ = {isa = PBXBuildFile; fileRef = 0547FDDE24E8622B005C1FFC /* OpenEmuXPCHelperApp.m */; }; 054A774925B2399100F2F3D6 /* ShaderParameterGroupModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 054A774825B2399100F2F3D6 /* ShaderParameterGroupModel.swift */; }; 05713219259C33B9001CB13A /* NSFileManager+ExtendedAttributes.h in Headers */ = {isa = PBXBuildFile; fileRef = 05713217259C33B9001CB13A /* NSFileManager+ExtendedAttributes.h */; settings = {ATTRIBUTES = (Public, ); }; }; 0571321A259C33B9001CB13A /* NSFileManager+ExtendedAttributes.m in Sources */ = {isa = PBXBuildFile; fileRef = 05713218259C33B9001CB13A /* NSFileManager+ExtendedAttributes.m */; }; @@ -108,8 +108,8 @@ 0547FDCD24E850EB005C1FFC /* NSXPCListener+HelperApp.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSXPCListener+HelperApp.m"; sourceTree = ""; }; 0547FDD024E85783005C1FFC /* OEXPCGameCoreManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OEXPCGameCoreManager.h; sourceTree = ""; }; 0547FDD124E85783005C1FFC /* OEXPCGameCoreManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = OEXPCGameCoreManager.m; sourceTree = ""; }; - 0547FDDD24E8622B005C1FFC /* OpenEmuXPCHelperAppBase.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OpenEmuXPCHelperAppBase.h; sourceTree = ""; }; - 0547FDDE24E8622B005C1FFC /* OpenEmuXPCHelperAppBase.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = OpenEmuXPCHelperAppBase.m; sourceTree = ""; }; + 0547FDDD24E8622B005C1FFC /* OpenEmuXPCHelperApp.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OpenEmuXPCHelperApp.h; sourceTree = ""; }; + 0547FDDE24E8622B005C1FFC /* OpenEmuXPCHelperApp.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = OpenEmuXPCHelperApp.m; sourceTree = ""; }; 054A774825B2399100F2F3D6 /* ShaderParameterGroupModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ShaderParameterGroupModel.swift; sourceTree = ""; }; 05713217259C33B9001CB13A /* NSFileManager+ExtendedAttributes.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSFileManager+ExtendedAttributes.h"; sourceTree = ""; }; 05713218259C33B9001CB13A /* NSFileManager+ExtendedAttributes.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSFileManager+ExtendedAttributes.m"; sourceTree = ""; }; @@ -281,8 +281,8 @@ 05E6B9FF24CCD47400ACFB35 /* Video */, 05E6B9DB24CCD43800ACFB35 /* OpenEmuHelperApp.h */, 05E6B9DC24CCD43900ACFB35 /* OpenEmuHelperApp.m */, - 0547FDDD24E8622B005C1FFC /* OpenEmuXPCHelperAppBase.h */, - 0547FDDE24E8622B005C1FFC /* OpenEmuXPCHelperAppBase.m */, + 0547FDDD24E8622B005C1FFC /* OpenEmuXPCHelperApp.h */, + 0547FDDE24E8622B005C1FFC /* OpenEmuXPCHelperApp.m */, ); name = "Helper App (Remote Layer)"; sourceTree = ""; @@ -458,7 +458,7 @@ 05E6BA5D24CCDFC700ACFB35 /* OEShaderParamValue.h in Headers */, 05E6958424CA5D4200ACFB35 /* OpenEmuKit.h in Headers */, 05E6BA0624CCD49600ACFB35 /* OECoreVideoTexture.h in Headers */, - 0547FDDF24E8622B005C1FFC /* OpenEmuXPCHelperAppBase.h in Headers */, + 0547FDDF24E8622B005C1FFC /* OpenEmuXPCHelperApp.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -545,7 +545,7 @@ files = ( 0547FDD324E85783005C1FFC /* OEXPCGameCoreManager.m in Sources */, 05E6BA5C24CCDFC700ACFB35 /* OEShaderParamValue.m in Sources */, - 0547FDE024E8622B005C1FFC /* OpenEmuXPCHelperAppBase.m in Sources */, + 0547FDE024E8622B005C1FFC /* OpenEmuXPCHelperApp.m in Sources */, 05E6BA4B24CCD7DB00ACFB35 /* OEGameCoreManager.m in Sources */, 0518D6E424F2BA4B0037101D /* OEGameStartupInfo.m in Sources */, 05D828D524E9881E00BB975E /* OEXPCMatchMaking.swift in Sources */, diff --git a/OpenEmuKit/OpenEmuKit.h b/OpenEmuKit/OpenEmuKit.h index 1c59427..1b26835 100644 --- a/OpenEmuKit/OpenEmuKit.h +++ b/OpenEmuKit/OpenEmuKit.h @@ -38,7 +38,7 @@ FOUNDATION_EXPORT const unsigned char OpenEmuKitVersionString[]; #import #import #import -#import +#import #import #import #import diff --git a/Source/OEGameCoreHelper.h b/Source/OEGameCoreHelper.h index ae89499..2d30d35 100644 --- a/Source/OEGameCoreHelper.h +++ b/Source/OEGameCoreHelper.h @@ -32,18 +32,38 @@ NS_ASSUME_NONNULL_BEGIN +/*! + * A protocol that defines the behaviour required to control an emulator core. + * + * A host application obtains an instance of @c OEGameCoreHelper in order + * to communicate with the core, which may be running in another thread or + * a remote process. + */ @protocol OEGameCoreHelper +/*! + * Adjust the output volume of the core. + * @param value The new volume level, from @c [0, 1.0] + */ - (void)setVolume:(CGFloat)value; + +/*! + * Manage the paused status of the core. + * + * @param pauseEmulation Specify @c true to pause the core. + */ - (void)setPauseEmulation:(BOOL)pauseEmulation; - (void)setAudioOutputDeviceID:(AudioDeviceID)deviceID; - (void)setOutputBounds:(NSRect)rect; - (void)setBackingScaleFactor:(CGFloat)newBackingScaleFactor; #pragma mark - Shader management + - (void)setShaderURL:(NSURL *)url parameters:(NSDictionary *)parameters completionHandler:(void (^)(BOOL success, NSError * _Nullable error))block; - (void)setShaderParameterValue:(CGFloat)value forKey:(NSString *)key; +#pragma mark - Emulator control + - (void)setupEmulationWithCompletionHandler:(void(^)(OEIntSize screenSize, OEIntSize aspectSize))handler; - (void)startEmulationWithCompletionHandler:(void(^)(void))handler; - (void)resetEmulationWithCompletionHandler:(void(^)(void))handler; @@ -65,9 +85,16 @@ NS_ASSUME_NONNULL_BEGIN - (void)systemBindingsDidSetEvent:(OEHIDEvent *)event forBinding:(__kindof OEBindingDescription *)bindingDescription playerNumber:(NSUInteger)playerNumber; - (void)systemBindingsDidUnsetEvent:(OEHIDEvent *)event forBinding:(__kindof OEBindingDescription *)bindingDescription playerNumber:(NSUInteger)playerNumber; -#pragma mark - screenshot support +#pragma mark - Screenshot support +/** + * Capture an image of the final core video display buffer, which includes all shader effects. + */ - (void)captureOutputImageWithCompletionHandler:(void (^)(NSBitmapImageRep *image))block; + +/** + * Capture an image of the raw core video display buffer with no effects. + */ - (void)captureSourceImageWithCompletionHandler:(void (^)(NSBitmapImageRep *image))block; @end @@ -93,11 +120,20 @@ NS_ASSUME_NONNULL_BEGIN - (void)nextDisplayMode; - (void)lastDisplayMode; -/// Notify the host application the the screen and aspect sizes have changed for the core. -/// -/// @details -/// The host application would use this to adjust the size of the display window. +/** + * Notify the host application that the screen and aspect sizes have changed for the core. + * + * The host application would use this information to adjust the size of the display window. + * + * @param newScreenSize The updated screen size + * @param newAspectSize The updated aspect size + */ - (void)setScreenSize:(OEIntSize)newScreenSize aspectSize:(OEIntSize)newAspectSize; +/** + * Notify the host application that the disc count has changed + * + * + */ - (void)setDiscCount:(NSUInteger)discCount; - (void)setDisplayModes:(NSArray *> *)displayModes; - (void)setRemoteContextID:(NSUInteger)contextID; diff --git a/Source/OEThreadGameCoreManager.m b/Source/OEThreadGameCoreManager.m index dd04b28..f28d252 100644 --- a/Source/OEThreadGameCoreManager.m +++ b/Source/OEThreadGameCoreManager.m @@ -63,11 +63,6 @@ [_helperThread start]; } -- (void)dummyTimer:(NSTimer *)dummyTimer -{ - -} - - (void)_executionThread:(id)object { @autoreleasepool @@ -80,7 +75,7 @@ { if(_errorHandler != nil) { - __block typeof(_errorHandler) errorHandler = _errorHandler; + __block __auto_type errorHandler = _errorHandler; _errorHandler = nil; dispatch_async(self.queue, ^{ errorHandler(error); @@ -94,7 +89,7 @@ _completionHandler = nil; } - _dummyTimer = [NSTimer scheduledTimerWithTimeInterval:1e9 target:self selector:@selector(dummyTimer:) userInfo:nil repeats:YES]; + _dummyTimer = [NSTimer scheduledTimerWithTimeInterval:1e9 repeats:YES block:^(NSTimer * _Nonnull timer) {}]; CFRunLoopRun(); diff --git a/Source/OpenEmuXPCHelperAppBase.h b/Source/OpenEmuXPCHelperApp.h similarity index 94% rename from Source/OpenEmuXPCHelperAppBase.h rename to Source/OpenEmuXPCHelperApp.h index a714dbf..a979ac5 100644 --- a/Source/OpenEmuXPCHelperAppBase.h +++ b/Source/OpenEmuXPCHelperApp.h @@ -26,9 +26,7 @@ NS_ASSUME_NONNULL_BEGIN -@interface OpenEmuXPCHelperAppBase : OpenEmuHelperApp - -@property (readonly) NSString *serviceName; +@interface OpenEmuXPCHelperApp : OpenEmuHelperApp @end diff --git a/Source/OpenEmuXPCHelperAppBase.m b/Source/OpenEmuXPCHelperApp.m similarity index 93% rename from Source/OpenEmuXPCHelperAppBase.m rename to Source/OpenEmuXPCHelperApp.m index 11eb8c6..a968dc8 100644 --- a/Source/OpenEmuXPCHelperAppBase.m +++ b/Source/OpenEmuXPCHelperApp.m @@ -23,14 +23,14 @@ // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #import "OEXPCGameCoreHelper.h" -#import "OpenEmuXPCHelperAppBase.h" +#import "OpenEmuXPCHelperApp.h" #import #import "OEShaderParamValue.h" #import "NSXPCListener+HelperApp.h" #import "OEGameStartupInfo.h" #import "OELogging.h" -@interface OpenEmuXPCHelperAppBase () +@interface OpenEmuXPCHelperApp () { NSXPCListener *_mainListener; NSXPCConnection *_gameCoreConnection; @@ -41,12 +41,19 @@ @end -@implementation OpenEmuXPCHelperAppBase +@implementation OpenEmuXPCHelperApp + +- (NSDictionary *)infoDictionary { + id obj = [NSBundle.mainBundle objectForInfoDictionaryKey:@"OpenEmuKit"]; + if ([obj isKindOfClass:NSDictionary.class]) { + return obj; + } + return nil; +} - (NSString *)serviceName { - [self doesNotImplementSelector:_cmd]; - return nil; + return [self.infoDictionary objectForKey:@"XPCBrokerServiceName"]; } - (void)launchApplication @@ -176,11 +183,4 @@ completionHandler(error); } -- (void)stopEmulationWithCompletionHandler:(void(^)(void))handler -{ - [super stopEmulationWithCompletionHandler:^{ - handler(); - }]; -} - @end