From e8832ed746cc829adbe6fb40d59f93599cb8486f Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Tue, 27 Mar 2018 00:34:38 -0700 Subject: [PATCH] Refactor new macOS code to reduce #ifs, increase shared code, and fix warnings --- Limelight/Database/DataManager.m | 12 +---- Limelight/Input/ControllerSupport.h | 3 +- Limelight/Input/ControllerSupport.m | 34 +++----------- Limelight/Input/OnScreenControls.h | 2 + Limelight/Input/StreamView.h | 4 +- Limelight/Limelight-Prefix.pch | 7 +-- Limelight/Network/AppAssetResponse.m | 13 +++--- Limelight/Network/AppAssetRetriever.m | 6 +-- Limelight/OSPortabilityDefs.h | 24 ++++++++++ Limelight/Stream/Connection.m | 5 +-- Limelight/Stream/StreamManager.h | 6 +-- Limelight/Stream/StreamManager.m | 24 +--------- Limelight/Stream/VideoDecoderRenderer.h | 7 +-- Limelight/Stream/VideoDecoderRenderer.m | 44 +++---------------- Moonlight macOS.xcodeproj/project.pbxproj | 34 ++------------ Moonlight macOS/Info.plist | 4 +- Moonlight macOSTests/Info.plist | 22 ---------- Moonlight macOSTests/Moonlight_macOSTests.m | 39 ---------------- Moonlight macOSUITests/Info.plist | 22 ---------- .../Moonlight_macOSUITests.m | 40 ----------------- Moonlight.xcodeproj/project.pbxproj | 2 + libs/gamepad/include/gamepad/Gamepad.h | 12 ++--- 22 files changed, 73 insertions(+), 293 deletions(-) create mode 100644 Limelight/OSPortabilityDefs.h delete mode 100644 Moonlight macOSTests/Info.plist delete mode 100644 Moonlight macOSTests/Moonlight_macOSTests.m delete mode 100644 Moonlight macOSUITests/Info.plist delete mode 100644 Moonlight macOSUITests/Moonlight_macOSUITests.m diff --git a/Limelight/Database/DataManager.m b/Limelight/Database/DataManager.m index 5dfc1e5..d59ba91 100644 --- a/Limelight/Database/DataManager.m +++ b/Limelight/Database/DataManager.m @@ -22,20 +22,12 @@ // HACK: Avoid calling [UIApplication delegate] off the UI thread to keep // Main Thread Checker happy. if ([NSThread isMainThread]) { -#if TARGET_OS_IPHONE - _appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate]; -#else - _appDelegate = (AppDelegate *)[[NSApplication sharedApplication] delegate]; -#endif + _appDelegate = (AppDelegate *)[[OSApplication sharedApplication] delegate]; } else { dispatch_sync(dispatch_get_main_queue(), ^{ -#if TARGET_OS_IPHONE - _appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate]; -#else - _appDelegate = (AppDelegate *)[[NSApplication sharedApplication] delegate]; -#endif + _appDelegate = (AppDelegate *)[[OSApplication sharedApplication] delegate]; }); } diff --git a/Limelight/Input/ControllerSupport.h b/Limelight/Input/ControllerSupport.h index 3ee9d4f..7bdbf3e 100644 --- a/Limelight/Input/ControllerSupport.h +++ b/Limelight/Input/ControllerSupport.h @@ -10,8 +10,7 @@ // Swift #import "Moonlight-Swift.h" -#if TARGET_OS_IPHONE -#else +#if !TARGET_OS_IPHONE #import "Gamepad.h" #endif @class Controller; diff --git a/Limelight/Input/ControllerSupport.m b/Limelight/Input/ControllerSupport.m index 68bac43..796abe0 100644 --- a/Limelight/Input/ControllerSupport.m +++ b/Limelight/Input/ControllerSupport.m @@ -8,9 +8,8 @@ #import "ControllerSupport.h" -#if TARGET_OS_IPHONE #import "OnScreenControls.h" -#else +#if !TARGET_OS_IPHONE #import "Gamepad.h" #import "Control.h" #endif @@ -28,7 +27,6 @@ NSLock *_controllerStreamLock; NSMutableDictionary *_controllers; -#if TARGET_OS_IPHONE OnScreenControls *_osc; // This controller object is shared between on-screen controls @@ -37,7 +35,6 @@ #define EMULATING_SELECT 0x1 #define EMULATING_SPECIAL 0x2 -#endif bool _oscEnabled; char _controllerNumbers; @@ -85,7 +82,6 @@ } } -#if TARGET_OS_IPHONE -(void) handleSpecialCombosReleased:(Controller*)controller releasedButtons:(int)releasedButtons { if ((controller.emulatingButtonFlags & EMULATING_SELECT) && @@ -120,7 +116,6 @@ } } -#endif -(void) updateButtonFlags:(Controller*)controller flags:(int)flags { @@ -129,14 +124,12 @@ // This must be called before handleSpecialCombosPressed // because we clear the original button flags there -#if TARGET_OS_IPHONE int releasedButtons = (controller.lastButtonFlags ^ flags) & ~flags; int pressedButtons = (controller.lastButtonFlags ^ flags) & flags; [self handleSpecialCombosReleased:controller releasedButtons:releasedButtons]; [self handleSpecialCombosPressed:controller pressedButtons:pressedButtons]; -#endif } } @@ -144,9 +137,7 @@ { @synchronized(controller) { controller.lastButtonFlags |= flags; -#if TARGET_OS_IPHONE [self handleSpecialCombosPressed:controller pressedButtons:flags]; -#endif } } @@ -154,9 +145,7 @@ { @synchronized(controller) { controller.lastButtonFlags &= ~flags; -#if TARGET_OS_IPHONE [self handleSpecialCombosReleased:controller releasedButtons:flags]; -#endif } } @@ -258,7 +247,6 @@ } } -#if TARGET_OS_IPHONE -(void) updateAutoOnScreenControlMode { // Auto on-screen control support may not be enabled @@ -285,7 +273,9 @@ } } +#if TARGET_OS_IPHONE [_osc setLevel:level]; +#endif } -(void) initAutoOnScreenControlMode:(OnScreenControls*)osc @@ -294,7 +284,6 @@ [self updateAutoOnScreenControlMode]; } -#endif -(void) assignController:(GCController*)controller { for (int i = 0; i < 4; i++) { @@ -303,7 +292,7 @@ controller.playerIndex = i; Controller* limeController; -#if TARGET_OS_IPHONE + if (i == 0) { // Player 0 shares a controller object with the on-screen controls limeController = _player0osc; @@ -311,10 +300,6 @@ limeController = [[Controller alloc] init]; limeController.playerIndex = i; } -#else - limeController = [[Controller alloc] init]; - limeController.playerIndex = i; -#endif [_controllers setObject:limeController forKey:[NSNumber numberWithInteger:controller.playerIndex]]; @@ -387,10 +372,10 @@ _controllers = [[NSMutableDictionary alloc] init]; _controllerNumbers = 0; -#if TARGET_OS_IPHONE _player0osc = [[Controller alloc] init]; _player0osc.playerIndex = 0; - + +#if TARGET_OS_IPHONE DataManager* dataMan = [[DataManager alloc] init]; _oscEnabled = (OnScreenControlsLevel)[[dataMan getSettings].onscreenControls integerValue] != OnScreenControlsLevelOff; #else @@ -403,10 +388,7 @@ for (GCController* controller in [GCController controllers]) { [self assignController:controller]; [self registerControllerCallbacks:controller]; - -#if TARGET_OS_IPHONE [self updateAutoOnScreenControlMode]; -#endif } self.connectObserver = [[NSNotificationCenter defaultCenter] addObserverForName:GCControllerDidConnectNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *note) { @@ -418,10 +400,8 @@ // Register callbacks on the new controller [self registerControllerCallbacks:controller]; -#if TARGET_OS_IPHONE // Re-evaluate the on-screen control mode [self updateAutoOnScreenControlMode]; -#endif }]; self.disconnectObserver = [[NSNotificationCenter defaultCenter] addObserverForName:GCControllerDidDisconnectNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *note) { Log(LOG_I, @"Controller disconnected!"); @@ -435,10 +415,8 @@ [self updateFinished:[_controllers objectForKey:[NSNumber numberWithInteger:controller.playerIndex]]]; [_controllers removeObjectForKey:[NSNumber numberWithInteger:controller.playerIndex]]; -#if TARGET_OS_IPHONE // Re-evaluate the on-screen control mode [self updateAutoOnScreenControlMode]; -#endif }]; return self; } diff --git a/Limelight/Input/OnScreenControls.h b/Limelight/Input/OnScreenControls.h index 23ee57b..a294bdf 100644 --- a/Limelight/Input/OnScreenControls.h +++ b/Limelight/Input/OnScreenControls.h @@ -24,10 +24,12 @@ typedef NS_ENUM(NSInteger, OnScreenControlsLevel) { OnScreenControlsLevelAutoGCExtendedGamepad, }; +#if TARGET_OS_IPHONE - (id) initWithView:(UIView*)view controllerSup:(ControllerSupport*)controllerSupport swipeDelegate:(id)edgeDelegate; - (BOOL) handleTouchDownEvent:(NSSet*)touches; - (BOOL) handleTouchUpEvent:(NSSet*)touches; - (BOOL) handleTouchMovedEvent:(NSSet*)touches; - (void) setLevel:(OnScreenControlsLevel)level; +#endif @end diff --git a/Limelight/Input/StreamView.h b/Limelight/Input/StreamView.h index 492fb60..dddb864 100644 --- a/Limelight/Input/StreamView.h +++ b/Limelight/Input/StreamView.h @@ -6,8 +6,6 @@ // Copyright (c) 2014 Moonlight Stream. All rights reserved. // -// This is redundant, as it is part of the prefix header -//#import #import "ControllerSupport.h" @protocol EdgeDetectionDelegate @@ -16,7 +14,7 @@ @end -@interface StreamView : UIView +@interface StreamView : OSView - (void) setupOnScreenControls:(ControllerSupport*)controllerSupport swipeDelegate:(id)swipeDelegate; - (void) setMouseDeltaFactors:(float)x y:(float)y; diff --git a/Limelight/Limelight-Prefix.pch b/Limelight/Limelight-Prefix.pch index c4445bb..a945904 100644 --- a/Limelight/Limelight-Prefix.pch +++ b/Limelight/Limelight-Prefix.pch @@ -18,7 +18,8 @@ #elif TARGET_OS_MAC #import #endif - #import - #import - #import "Logger.h" +#import +#import +#import "Logger.h" +#include "OSPortabilityDefs.h" #endif diff --git a/Limelight/Network/AppAssetResponse.m b/Limelight/Network/AppAssetResponse.m index 4cdb0a3..8def731 100644 --- a/Limelight/Network/AppAssetResponse.m +++ b/Limelight/Network/AppAssetResponse.m @@ -16,16 +16,13 @@ self.statusMessage = @"App asset has no status message"; self.statusCode = -1; } +- (OSImage*) getImage { #if TARGET_OS_IPHONE -- (UIImage*) getImage { - UIImage* appImage = [[UIImage alloc] initWithData:self.data]; + OSImage* appImage = [[OSImage alloc] initWithData:self.data]; +#else + OSImage* appImage = nil; +#endif return appImage; } -#else -- (NSImage*) getImage { - return nil; -} -#endif - @end diff --git a/Limelight/Network/AppAssetRetriever.m b/Limelight/Network/AppAssetRetriever.m index 7f42f4f..43d3aeb 100644 --- a/Limelight/Network/AppAssetRetriever.m +++ b/Limelight/Network/AppAssetRetriever.m @@ -19,11 +19,7 @@ static const int MAX_ATTEMPTS = 5; - (void) main { -#if TARGET_OS_IPHONE - UIImage* appImage = nil; -#else - NSImage* appImage = nil; -#endif + OSImage* appImage = nil; int attempts = 0; while (![self isCancelled] && appImage == nil && attempts++ < MAX_ATTEMPTS) { diff --git a/Limelight/OSPortabilityDefs.h b/Limelight/OSPortabilityDefs.h new file mode 100644 index 0000000..8767c9b --- /dev/null +++ b/Limelight/OSPortabilityDefs.h @@ -0,0 +1,24 @@ +// +// OSPortabilityDefs.h +// Moonlight +// +// Created by Cameron Gutman on 3/26/18. +// Copyright © 2018 Moonlight Stream. All rights reserved. +// + +#ifndef OSPortabilityDefs_h +#define OSPortabilityDefs_h + +#if TARGET_OS_IPHONE +#define OSImage UIImage +#define OSColor UIColor +#define OSView UIView +#define OSApplication UIApplication +#else +#define OSImage NSImage +#define OSColor NSColor +#define OSView NSView +#define OSApplication NSApplication +#endif + +#endif /* OSPortabilityDefs_h */ diff --git a/Limelight/Stream/Connection.m b/Limelight/Stream/Connection.m index 9e943be..37ded72 100644 --- a/Limelight/Stream/Connection.m +++ b/Limelight/Stream/Connection.m @@ -98,7 +98,6 @@ int ArInit(int audioConfiguration, POPUS_MULTISTREAM_CONFIGURATION opusConfig, v audioLock = [[NSLock alloc] init]; #if TARGET_OS_IPHONE - // Configure the audio session for our app NSError *audioSessionError = nil; AVAudioSession* audioSession = [AVAudioSession sharedInstance]; @@ -108,8 +107,8 @@ int ArInit(int audioConfiguration, POPUS_MULTISTREAM_CONFIGURATION opusConfig, v [audioSession setPreferredOutputNumberOfChannels:opusConfig->channelCount error:&audioSessionError]; [audioSession setPreferredIOBufferDuration:0.005 error:&audioSessionError]; [audioSession setActive: YES error: &audioSessionError]; - #endif + OSStatus status; AudioComponentDescription audioDesc; @@ -355,7 +354,7 @@ void ClLogMessage(const char* format, ...) #else if (@available(macOS 10.13, *)) { if (VTIsHardwareDecodeSupported(kCMVideoCodecType_HEVC) || _streamConfig.streamingRemotely != 0) - _streamConfig.supportsHevc = true; + _streamConfig.supportsHevc = true; } #endif diff --git a/Limelight/Stream/StreamManager.h b/Limelight/Stream/StreamManager.h index 243f38c..951d2a6 100644 --- a/Limelight/Stream/StreamManager.h +++ b/Limelight/Stream/StreamManager.h @@ -12,11 +12,7 @@ @interface StreamManager : NSOperation -#if TARGET_OS_IPHONE -- (id) initWithConfig:(StreamConfiguration*)config renderView:(UIView*)view connectionCallbacks:(id)callback; -#else -- (id) initWithConfig:(StreamConfiguration*)config renderView:(NSView*)view connectionCallbacks:(id)callback; -#endif +- (id) initWithConfig:(StreamConfiguration*)config renderView:(OSView*)view connectionCallbacks:(id)callback; - (void) stopStream; diff --git a/Limelight/Stream/StreamManager.m b/Limelight/Stream/StreamManager.m index e4a378d..c924027 100644 --- a/Limelight/Stream/StreamManager.m +++ b/Limelight/Stream/StreamManager.m @@ -11,10 +11,6 @@ #import "HttpManager.h" #import "Utils.h" -#if TARGET_OS_IPHONE -#import "OnScreenControls.h" -#endif - #import "StreamView.h" #import "ServerInfoResponse.h" #import "HttpResponse.h" @@ -24,17 +20,12 @@ @implementation StreamManager { StreamConfiguration* _config; -#if TARGET_OS_IPHONE - UIView* _renderView; -#else - NSView* _renderView; -#endif + OSView* _renderView; id _callbacks; Connection* _connection; } -#if TARGET_OS_IPHONE -- (id) initWithConfig:(StreamConfiguration*)config renderView:(UIView*)view connectionCallbacks:(id)callbacks { +- (id) initWithConfig:(StreamConfiguration*)config renderView:(OSView*)view connectionCallbacks:(id)callbacks { self = [super init]; _config = config; _renderView = view; @@ -43,17 +34,6 @@ _config.riKeyId = arc4random(); return self; } -#else -- (id) initWithConfig:(StreamConfiguration*)config renderView:(NSView*)view connectionCallbacks:(id)callbacks { - self = [super init]; - _config = config; - _renderView = view; - _callbacks = callbacks; - _config.riKey = [Utils randomBytes:16]; - _config.riKeyId = arc4random(); - return self; -} -#endif - (void)main { [CryptoManager generateKeyPairUsingSSl]; diff --git a/Limelight/Stream/VideoDecoderRenderer.h b/Limelight/Stream/VideoDecoderRenderer.h index 463d584..e7c3b65 100644 --- a/Limelight/Stream/VideoDecoderRenderer.h +++ b/Limelight/Stream/VideoDecoderRenderer.h @@ -11,11 +11,8 @@ @import AVFoundation; @interface VideoDecoderRenderer : NSObject -#if TARGET_OS_IPHONE -- (id)initWithView:(UIView*)view; -#else -- (id)initWithView:(NSView*)view; -#endif + +- (id)initWithView:(OSView*)view; - (void)setupWithVideoFormat:(int)videoFormat; diff --git a/Limelight/Stream/VideoDecoderRenderer.m b/Limelight/Stream/VideoDecoderRenderer.m index 42eceb3..0e823c7 100644 --- a/Limelight/Stream/VideoDecoderRenderer.m +++ b/Limelight/Stream/VideoDecoderRenderer.m @@ -11,11 +11,7 @@ #include "Limelight.h" @implementation VideoDecoderRenderer { -#if TARGET_OS_IPHONE - UIView *_view; -#else - NSView *_view; -#endif + OSView *_view; AVSampleBufferDisplayLayer* displayLayer; Boolean waitingForSps, waitingForPps, waitingForVps; @@ -31,11 +27,7 @@ displayLayer = [[AVSampleBufferDisplayLayer alloc] init]; displayLayer.bounds = _view.bounds; -#if TARGET_OS_IPHONE - displayLayer.backgroundColor = [UIColor blackColor].CGColor; -#else - displayLayer.backgroundColor = [NSColor blackColor].CGColor; -#endif + displayLayer.backgroundColor = [OSColor blackColor].CGColor; displayLayer.position = CGPointMake(CGRectGetMidX(_view.bounds), CGRectGetMidY(_view.bounds)); displayLayer.videoGravity = AVLayerVideoGravityResizeAspect; @@ -61,8 +53,8 @@ formatDesc = nil; } } -#if TARGET_OS_IPHONE -- (id)initWithView:(UIView*)view + +- (id)initWithView:(OSView*)view { self = [super init]; @@ -72,20 +64,6 @@ return self; } -#else -- (id)initWithView:(NSView*)view -{ - self = [super init]; - - _view = view; - - [self reinitializeDisplayLayer]; - - return self; -} - -#endif - - (void)setupWithVideoFormat:(int)videoFormat { @@ -248,20 +226,9 @@ #if TARGET_OS_IPHONE if (@available(iOS 11.0, *)) { - status = CMVideoFormatDescriptionCreateFromHEVCParameterSets(kCFAllocatorDefault, - 3, /* count of parameter sets */ - parameterSetPointers, - parameterSetSizes, - NAL_LENGTH_PREFIX_SIZE, - nil, - &formatDesc); - } else { - // This means Moonlight-common-c decided to give us an HEVC stream - // even though we said we couldn't support it. All we can do is abort(). - abort(); - } #else if (@available(macOS 10.13, *)) { +#endif status = CMVideoFormatDescriptionCreateFromHEVCParameterSets(kCFAllocatorDefault, 3, /* count of parameter sets */ parameterSetPointers, @@ -274,7 +241,6 @@ // even though we said we couldn't support it. All we can do is abort(). abort(); } -#endif if (status != noErr) { Log(LOG_E, @"Failed to create HEVC format description: %d", (int)status); diff --git a/Moonlight macOS.xcodeproj/project.pbxproj b/Moonlight macOS.xcodeproj/project.pbxproj index e4c87f5..ad2e187 100644 --- a/Moonlight macOS.xcodeproj/project.pbxproj +++ b/Moonlight macOS.xcodeproj/project.pbxproj @@ -48,8 +48,6 @@ DC5EF54D2052FBDB00C9BF55 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = DC5EF54C2052FBDB00C9BF55 /* ViewController.m */; }; DC5EF5522052FBDB00C9BF55 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = DC5EF5512052FBDB00C9BF55 /* Assets.xcassets */; }; DC5EF5582052FBDB00C9BF55 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = DC5EF5572052FBDB00C9BF55 /* main.m */; }; - DC5EF5632052FBDB00C9BF55 /* Moonlight_macOSTests.m in Sources */ = {isa = PBXBuildFile; fileRef = DC5EF5622052FBDB00C9BF55 /* Moonlight_macOSTests.m */; }; - DC5EF56E2052FBDB00C9BF55 /* Moonlight_macOSUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = DC5EF56D2052FBDB00C9BF55 /* Moonlight_macOSUITests.m */; }; DC5FA8FC205DBEE3008B7054 /* StreamConfiguration.m in Sources */ = {isa = PBXBuildFile; fileRef = DC5FA8F6205DBEE3008B7054 /* StreamConfiguration.m */; }; DC5FA8FD205DBEE3008B7054 /* StreamManager.m in Sources */ = {isa = PBXBuildFile; fileRef = DC5FA8F8205DBEE3008B7054 /* StreamManager.m */; }; DC5FA8FE205DBEE3008B7054 /* Connection.m in Sources */ = {isa = PBXBuildFile; fileRef = DC5FA8F9205DBEE3008B7054 /* Connection.m */; }; @@ -125,6 +123,7 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 98878AE1206A261F00586E90 /* OSPortabilityDefs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OSPortabilityDefs.h; path = Limelight/OSPortabilityDefs.h; sourceTree = SOURCE_ROOT; }; DC0F7506205C04A90087B187 /* keepAlive.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = keepAlive.h; sourceTree = ""; }; DC0F7507205C04A90087B187 /* keepAlive.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = keepAlive.m; sourceTree = ""; }; DC153B34205A990800E7559B /* Moonlight macOS-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Moonlight macOS-Bridging-Header.h"; sourceTree = ""; }; @@ -194,11 +193,7 @@ DC5EF5562052FBDB00C9BF55 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; DC5EF5572052FBDB00C9BF55 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; DC5EF55E2052FBDB00C9BF55 /* Moonlight macOSTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "Moonlight macOSTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; - DC5EF5622052FBDB00C9BF55 /* Moonlight_macOSTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Moonlight_macOSTests.m; sourceTree = ""; }; - DC5EF5642052FBDB00C9BF55 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; DC5EF5692052FBDB00C9BF55 /* Moonlight macOSUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "Moonlight macOSUITests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; - DC5EF56D2052FBDB00C9BF55 /* Moonlight_macOSUITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Moonlight_macOSUITests.m; sourceTree = ""; }; - DC5EF56F2052FBDB00C9BF55 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; DC5EF5CE2052FC8B00C9BF55 /* opus.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = opus.h; sourceTree = ""; }; DC5EF5CF2052FC8B00C9BF55 /* opus_multistream.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = opus_multistream.h; sourceTree = ""; }; DC5EF5D02052FC8B00C9BF55 /* opus_types.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = opus_types.h; sourceTree = ""; }; @@ -460,8 +455,6 @@ children = ( DCECF42A205DBBAB00831862 /* moonlight-common_mac.xcodeproj */, DC5EF5472052FBDB00C9BF55 /* Moonlight macOS */, - DC5EF5612052FBDB00C9BF55 /* Moonlight macOSTests */, - DC5EF56C2052FBDB00C9BF55 /* Moonlight macOSUITests */, DC5EF5462052FBDB00C9BF55 /* Products */, DC5EF5C92052FC8B00C9BF55 /* Frameworks */, ); @@ -480,6 +473,7 @@ DC5EF5472052FBDB00C9BF55 /* Moonlight macOS */ = { isa = PBXGroup; children = ( + 98878AE1206A261F00586E90 /* OSPortabilityDefs.h */, DC9CD51E20601658001A5DCD /* AppDelegate.m */, DCAF0516205F3E6A00AD1DBA /* Limelight.xcdatamodeld */, DCAF04FD205F38B100AD1DBA /* AppDelegate.h */, @@ -500,24 +494,6 @@ path = "Moonlight macOS"; sourceTree = ""; }; - DC5EF5612052FBDB00C9BF55 /* Moonlight macOSTests */ = { - isa = PBXGroup; - children = ( - DC5EF5622052FBDB00C9BF55 /* Moonlight_macOSTests.m */, - DC5EF5642052FBDB00C9BF55 /* Info.plist */, - ); - path = "Moonlight macOSTests"; - sourceTree = ""; - }; - DC5EF56C2052FBDB00C9BF55 /* Moonlight macOSUITests */ = { - isa = PBXGroup; - children = ( - DC5EF56D2052FBDB00C9BF55 /* Moonlight_macOSUITests.m */, - DC5EF56F2052FBDB00C9BF55 /* Info.plist */, - ); - path = "Moonlight macOSUITests"; - sourceTree = ""; - }; DC5EF5962052FC4300C9BF55 /* Utility */ = { isa = PBXGroup; children = ( @@ -958,7 +934,6 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - DC5EF5632052FBDB00C9BF55 /* Moonlight_macOSTests.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -966,7 +941,6 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - DC5EF56E2052FBDB00C9BF55 /* Moonlight_macOSUITests.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1129,7 +1103,7 @@ ); MACOSX_DEPLOYMENT_TARGET = 10.13; OTHER_LDFLAGS = ""; - PRODUCT_BUNDLE_IDENTIFIER = "fkx.Moonlight-macOS"; + PRODUCT_BUNDLE_IDENTIFIER = "com.moonlight-stream.Moonlight-macOS"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Moonlight macOS/Input/Moonlight macOS-Bridging-Header.h"; SWIFT_OBJC_INTERFACE_HEADER_NAME = "Moonlight-Swift.h"; @@ -1178,7 +1152,7 @@ ONLY_ACTIVE_ARCH = YES; OTHER_LDFLAGS = ""; PRECOMPS_INCLUDE_HEADERS_FROM_BUILT_PRODUCTS_DIR = NO; - PRODUCT_BUNDLE_IDENTIFIER = "fkx.Moonlight-macOS"; + PRODUCT_BUNDLE_IDENTIFIER = "com.moonlight-stream.Moonlight-macOS"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Moonlight macOS/Input/Moonlight macOS-Bridging-Header.h"; SWIFT_OBJC_INTERFACE_HEADER_NAME = "Moonlight-Swift.h"; diff --git a/Moonlight macOS/Info.plist b/Moonlight macOS/Info.plist index 7b2169b..cb58548 100644 --- a/Moonlight macOS/Info.plist +++ b/Moonlight macOS/Info.plist @@ -18,6 +18,8 @@ 1.0 CFBundleVersion 1 + LSApplicationCategoryType + public.app-category.entertainment LSMinimumSystemVersion $(MACOSX_DEPLOYMENT_TARGET) NSAppTransportSecurity @@ -28,7 +30,7 @@ NSHighResolutionCapable NSHumanReadableCopyright - Copyright © 2018 Felix. All rights reserved. + Copyright © 2018 Moonlight Game Streaming Project. All rights reserved. NSMainStoryboardFile Mac NSPrincipalClass diff --git a/Moonlight macOSTests/Info.plist b/Moonlight macOSTests/Info.plist deleted file mode 100644 index 6c40a6c..0000000 --- a/Moonlight macOSTests/Info.plist +++ /dev/null @@ -1,22 +0,0 @@ - - - - - CFBundleDevelopmentRegion - $(DEVELOPMENT_LANGUAGE) - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - $(PRODUCT_NAME) - CFBundlePackageType - BNDL - CFBundleShortVersionString - 1.0 - CFBundleVersion - 1 - - diff --git a/Moonlight macOSTests/Moonlight_macOSTests.m b/Moonlight macOSTests/Moonlight_macOSTests.m deleted file mode 100644 index 8d3b546..0000000 --- a/Moonlight macOSTests/Moonlight_macOSTests.m +++ /dev/null @@ -1,39 +0,0 @@ -// -// Moonlight_macOSTests.m -// Moonlight macOSTests -// -// Created by Felix on 09.03.18. -// Copyright © 2018 Felix. All rights reserved. -// - -#import - -@interface Moonlight_macOSTests : XCTestCase - -@end - -@implementation Moonlight_macOSTests - -- (void)setUp { - [super setUp]; - // Put setup code here. This method is called before the invocation of each test method in the class. -} - -- (void)tearDown { - // Put teardown code here. This method is called after the invocation of each test method in the class. - [super tearDown]; -} - -- (void)testExample { - // This is an example of a functional test case. - // Use XCTAssert and related functions to verify your tests produce the correct results. -} - -- (void)testPerformanceExample { - // This is an example of a performance test case. - [self measureBlock:^{ - // Put the code you want to measure the time of here. - }]; -} - -@end diff --git a/Moonlight macOSUITests/Info.plist b/Moonlight macOSUITests/Info.plist deleted file mode 100644 index 6c40a6c..0000000 --- a/Moonlight macOSUITests/Info.plist +++ /dev/null @@ -1,22 +0,0 @@ - - - - - CFBundleDevelopmentRegion - $(DEVELOPMENT_LANGUAGE) - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - $(PRODUCT_NAME) - CFBundlePackageType - BNDL - CFBundleShortVersionString - 1.0 - CFBundleVersion - 1 - - diff --git a/Moonlight macOSUITests/Moonlight_macOSUITests.m b/Moonlight macOSUITests/Moonlight_macOSUITests.m deleted file mode 100644 index e76407e..0000000 --- a/Moonlight macOSUITests/Moonlight_macOSUITests.m +++ /dev/null @@ -1,40 +0,0 @@ -// -// Moonlight_macOSUITests.m -// Moonlight macOSUITests -// -// Created by Felix on 09.03.18. -// Copyright © 2018 Felix. All rights reserved. -// - -#import - -@interface Moonlight_macOSUITests : XCTestCase - -@end - -@implementation Moonlight_macOSUITests - -- (void)setUp { - [super setUp]; - - // Put setup code here. This method is called before the invocation of each test method in the class. - - // In UI tests it is usually best to stop immediately when a failure occurs. - self.continueAfterFailure = NO; - // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. - [[[XCUIApplication alloc] init] launch]; - - // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. -} - -- (void)tearDown { - // Put teardown code here. This method is called after the invocation of each test method in the class. - [super tearDown]; -} - -- (void)testExample { - // Use recording to get started writing UI tests. - // Use XCTAssert and related functions to verify your tests produce the correct results. -} - -@end diff --git a/Moonlight.xcodeproj/project.pbxproj b/Moonlight.xcodeproj/project.pbxproj index 94989be..5f840ff 100644 --- a/Moonlight.xcodeproj/project.pbxproj +++ b/Moonlight.xcodeproj/project.pbxproj @@ -105,6 +105,7 @@ /* Begin PBXFileReference section */ 9832D1341BBCD5C50036EF48 /* TemporaryApp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TemporaryApp.h; path = Database/TemporaryApp.h; sourceTree = ""; }; 9832D1351BBCD5C50036EF48 /* TemporaryApp.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TemporaryApp.m; path = Database/TemporaryApp.m; sourceTree = ""; }; + 98878AE0206A226D00586E90 /* OSPortabilityDefs.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OSPortabilityDefs.h; sourceTree = ""; }; 9890CF6A203B7EE1006C4B06 /* libxml2.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libxml2.tbd; path = usr/lib/libxml2.tbd; sourceTree = SDKROOT; }; 98AB2E7F1CAD46830089BB98 /* moonlight-common.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = "moonlight-common.xcodeproj"; path = "moonlight-common/moonlight-common.xcodeproj"; sourceTree = ""; }; 98D5856B1C0EA79600F6CC00 /* TemporaryHost.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TemporaryHost.h; path = Database/TemporaryHost.h; sourceTree = ""; }; @@ -447,6 +448,7 @@ FB1D59961BBCCB6400F482CA /* ComputerScrollView.m */, FB1D59981BBCCD7E00F482CA /* AppCollectionView.h */, FB1D59991BBCCD7E00F482CA /* AppCollectionView.m */, + 98878AE0206A226D00586E90 /* OSPortabilityDefs.h */, ); name = Moonlight; path = Limelight; diff --git a/libs/gamepad/include/gamepad/Gamepad.h b/libs/gamepad/include/gamepad/Gamepad.h index abd96c0..3e2acf1 100755 --- a/libs/gamepad/include/gamepad/Gamepad.h +++ b/libs/gamepad/include/gamepad/Gamepad.h @@ -26,7 +26,7 @@ extern "C" { #endif -#if _MSC_VER <= 1600 +#if _MSC_VER && _MSC_VER <= 1600 #define bool int #define true 1 #define false 0 @@ -71,15 +71,15 @@ struct Gamepad_device { This function must be called from the same thread that will be calling Gamepad_processEvents() and Gamepad_detectDevices(). */ -void Gamepad_init(); +void Gamepad_init(void); /* Tears down all data structures created by the gamepad library and releases any memory that was allocated. It is not necessary to call this function at application termination, but it's provided in case you want to free memory associated with gamepads at some earlier time. */ -void Gamepad_shutdown(); +void Gamepad_shutdown(void); /* Returns the number of currently attached gamepad devices. */ -unsigned int Gamepad_numDevices(); +unsigned int Gamepad_numDevices(void); /* Returns the specified Gamepad_device struct, or NULL if deviceIndex is out of bounds. */ struct Gamepad_device * Gamepad_deviceAtIndex(unsigned int deviceIndex); @@ -92,11 +92,11 @@ struct Gamepad_device * Gamepad_deviceAtIndex(unsigned int deviceIndex); devices that have not yet been detected with Gamepad_detectDevices(). You can safely ignore these events, but be aware that your callbacks might receive a device ID that hasn't been seen by your deviceAttachFunc. */ -void Gamepad_detectDevices(); +void Gamepad_detectDevices(void); /* Reads pending input from all attached devices and calls the appropriate input callbacks, if any have been registered. */ -void Gamepad_processEvents(); +void Gamepad_processEvents(void); /* Registers a function to be called whenever a device is attached. The specified function will be called only during calls to Gamepad_init() and Gamepad_detectDevices(), in the thread from