Dark Mode & Stream Overlay [macOS] (#315)

* dark mode & stream overlay

* removed all redundant imports

* update for the new xcode version with fixes for the new 'implicitly retains self warning'

* reworked the overlay view

* cleaning up unused variables

* small corrections
This commit is contained in:
Felix Kratz
2018-04-22 06:44:22 +02:00
committed by Cameron Gutman
parent 74283a6763
commit f759f719e6
50 changed files with 358 additions and 146 deletions

View File

@@ -6,8 +6,6 @@
// Copyright (c) 2014 Moonlight Stream. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface CryptoManager : NSObject
+ (void) generateKeyPairUsingSSl;

View File

@@ -6,8 +6,6 @@
// Copyright © 2015 Moonlight Stream. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface IdManager : NSObject
+ (NSString*) getUniqueId;

View File

@@ -6,9 +6,6 @@
// Copyright © 2015 Limelight Stream. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>
@class Host;
@interface App : NSManagedObject

View File

@@ -6,7 +6,6 @@
// Copyright (c) 2014 Moonlight Stream. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "AppDelegate.h"
#import "TemporaryHost.h"
#import "TemporaryApp.h"

View File

@@ -27,7 +27,7 @@
}
else {
dispatch_sync(dispatch_get_main_queue(), ^{
_appDelegate = (AppDelegate *)[[OSApplication sharedApplication] delegate];
self->_appDelegate = (AppDelegate *)[[OSApplication sharedApplication] delegate];
});
}
@@ -76,8 +76,8 @@
// Add a new persistent managed object if one doesn't exist
Host* parent = [self getHostForTemporaryHost:host withHostRecords:[self fetchRecords:@"Host"]];
if (parent == nil) {
NSEntityDescription* entity = [NSEntityDescription entityForName:@"Host" inManagedObjectContext:_managedObjectContext];
parent = [[Host alloc] initWithEntity:entity insertIntoManagedObjectContext:_managedObjectContext];
NSEntityDescription* entity = [NSEntityDescription entityForName:@"Host" inManagedObjectContext:self->_managedObjectContext];
parent = [[Host alloc] initWithEntity:entity insertIntoManagedObjectContext:self->_managedObjectContext];
}
// Push changes from the temp host to the persistent one
@@ -101,8 +101,8 @@
// Add a new persistent managed object if one doesn't exist
App* parentApp = [self getAppForTemporaryApp:app withAppRecords:appRecords];
if (parentApp == nil) {
NSEntityDescription* entity = [NSEntityDescription entityForName:@"App" inManagedObjectContext:_managedObjectContext];
parentApp = [[App alloc] initWithEntity:entity insertIntoManagedObjectContext:_managedObjectContext];
NSEntityDescription* entity = [NSEntityDescription entityForName:@"App" inManagedObjectContext:self->_managedObjectContext];
parentApp = [[App alloc] initWithEntity:entity insertIntoManagedObjectContext:self->_managedObjectContext];
}
[app propagateChangesToParent:parentApp withHost:parent];
@@ -158,7 +158,7 @@
[_managedObjectContext performBlockAndWait:^{
App* managedApp = [self getAppForTemporaryApp:app withAppRecords:[self fetchRecords:@"App"]];
if (managedApp != nil) {
[_managedObjectContext deleteObject:managedApp];
[self->_managedObjectContext deleteObject:managedApp];
[self saveData];
}
}];
@@ -168,7 +168,7 @@
[_managedObjectContext performBlockAndWait:^{
Host* managedHost = [self getHostForTemporaryHost:host withHostRecords:[self fetchRecords:@"Host"]];
if (managedHost != nil) {
[_managedObjectContext deleteObject:managedHost];
[self->_managedObjectContext deleteObject:managedHost];
[self saveData];
}
}];

View File

@@ -6,8 +6,6 @@
// Copyright © 2015 Limelight Stream. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>
#import "Utils.h"
@interface Host : NSManagedObject

View File

@@ -6,10 +6,6 @@
// Copyright (c) 2014 Moonlight Stream. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>
@interface Settings : NSManagedObject
@property (nonatomic, retain) NSNumber * bitrate;

View File

@@ -6,7 +6,6 @@
// Copyright © 2015 Moonlight Stream. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "TemporaryHost.h"
#import "App.h"

View File

@@ -6,7 +6,6 @@
// Copyright © 2015 Moonlight Stream. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "Utils.h"
#import "Host.h"

View File

@@ -6,7 +6,6 @@
// Copyright © 2015 Moonlight Stream. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "Settings.h"
@interface TemporarySettings : NSObject

View File

@@ -6,8 +6,6 @@
// Copyright (c) 2014 Moonlight Stream. All rights reserved.
//
#import <Foundation/Foundation.h>
// Swift
#import "Moonlight-Swift.h"
#if !TARGET_OS_IPHONE

View File

@@ -177,7 +177,7 @@
{
if (controller != NULL) {
controller.controllerPausedHandler = ^(GCController *controller) {
Controller* limeController = [_controllers objectForKey:[NSNumber numberWithInteger:controller.playerIndex]];
Controller* limeController = [self->_controllers objectForKey:[NSNumber numberWithInteger:controller.playerIndex]];
[self setButtonFlag:limeController flags:PLAY_FLAG];
[self updateFinished:limeController];
@@ -190,7 +190,7 @@
if (controller.extendedGamepad != NULL) {
controller.extendedGamepad.valueChangedHandler = ^(GCExtendedGamepad *gamepad, GCControllerElement *element) {
Controller* limeController = [_controllers objectForKey:[NSNumber numberWithInteger:gamepad.controller.playerIndex]];
Controller* limeController = [self->_controllers objectForKey:[NSNumber numberWithInteger:gamepad.controller.playerIndex]];
short leftStickX, leftStickY;
short rightStickX, rightStickY;
char leftTrigger, rightTrigger;
@@ -225,7 +225,7 @@
}
else if (controller.gamepad != NULL) {
controller.gamepad.valueChangedHandler = ^(GCGamepad *gamepad, GCControllerElement *element) {
Controller* limeController = [_controllers objectForKey:[NSNumber numberWithInteger:gamepad.controller.playerIndex]];
Controller* limeController = [self->_controllers objectForKey:[NSNumber numberWithInteger:gamepad.controller.playerIndex]];
UPDATE_BUTTON_FLAG(limeController, A_FLAG, gamepad.buttonA.pressed);
UPDATE_BUTTON_FLAG(limeController, B_FLAG, gamepad.buttonB.pressed);
UPDATE_BUTTON_FLAG(limeController, X_FLAG, gamepad.buttonX.pressed);
@@ -408,12 +408,12 @@
GCController* controller = note.object;
[self unregisterControllerCallbacks:controller];
_controllerNumbers &= ~(1 << controller.playerIndex);
self->_controllerNumbers &= ~(1 << controller.playerIndex);
Log(LOG_I, @"Unassigning controller index: %ld", (long)controller.playerIndex);
// Inform the server of the updated active gamepads before removing this controller
[self updateFinished:[_controllers objectForKey:[NSNumber numberWithInteger:controller.playerIndex]]];
[_controllers removeObjectForKey:[NSNumber numberWithInteger:controller.playerIndex]];
[self updateFinished:[self->_controllers objectForKey:[NSNumber numberWithInteger:controller.playerIndex]]];
[self->_controllers removeObjectForKey:[NSNumber numberWithInteger:controller.playerIndex]];
// Re-evaluate the on-screen control mode
[self updateAutoOnScreenControlMode];

View File

@@ -6,7 +6,6 @@
// Copyright (c) 2014 Moonlight Stream. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "TemporaryApp.h"
#import "HttpManager.h"
#import "TemporaryHost.h"

View File

@@ -6,7 +6,6 @@
// Copyright (c) 2015 Moonlight Stream. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "HttpResponse.h"
@interface AppAssetResponse : NSObject <Response>

View File

@@ -6,7 +6,6 @@
// Copyright (c) 2015 Moonlight Stream. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "TemporaryHost.h"
#import "TemporaryApp.h"
#import "AppAssetManager.h"

View File

@@ -2,11 +2,10 @@
// ConnectionHelper.h
// Moonlight macOS
//
// Created by Felix on 22.03.18.
// Copyright © 2018 Felix. All rights reserved.
// Created by Felix Kratz on 22.03.18.
// Copyright © 2018 Felix Kratz. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "AppListResponse.h"
#ifndef ConnectionHelper_h

View File

@@ -2,8 +2,8 @@
// ConnectionHelper.m
// Moonlight macOS
//
// Created by Felix on 22.03.18.
// Copyright © 2018 Felix. All rights reserved.
// Created by Felix Kratz on 22.03.18.
// Copyright © 2018 Felix Kratz. All rights reserved.
//
#import "ConnectionHelper.h"

View File

@@ -6,7 +6,6 @@
// Copyright (c) 2015 Moonlight Stream. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "MDNSManager.h"
#import "TemporaryHost.h"

View File

@@ -153,7 +153,7 @@
[worker discoverHost];
if ([self addHostToDiscovery:host]) {
Log(LOG_I, @"Adding host to discovery: %@", host.name);
[_callback updateAllHosts:_hostQueue];
[self->_callback updateAllHosts:self->_hostQueue];
} else {
Log(LOG_I, @"Not adding host to discovery: %@", host.name);
}

View File

@@ -6,7 +6,6 @@
// Copyright (c) 2015 Moonlight Stream. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "TemporaryHost.h"
@interface DiscoveryWorker : NSOperation

View File

@@ -6,7 +6,6 @@
// Copyright (c) 2014 Moonlight Stream. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "HttpResponse.h"
#import "HttpRequest.h"

View File

@@ -69,23 +69,23 @@ static const NSString* HTTPS_PORT = @"47984";
if (error != NULL) {
Log(LOG_D, @"Connection error: %@", error);
_errorOccurred = true;
self->_errorOccurred = true;
}
else {
Log(LOG_D, @"Received response: %@", response);
if (data != NULL) {
Log(LOG_D, @"\n\nReceived data: %@\n\n", [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]);
[_respData appendData:data];
if ([[NSString alloc] initWithData:_respData encoding:NSUTF8StringEncoding] != nil) {
_requestResp = [HttpManager fixXmlVersion:_respData];
[self->_respData appendData:data];
if ([[NSString alloc] initWithData:self->_respData encoding:NSUTF8StringEncoding] != nil) {
self->_requestResp = [HttpManager fixXmlVersion:self->_respData];
} else {
_requestResp = _respData;
self->_requestResp = self->_respData;
}
}
}
dispatch_semaphore_signal(_requestLock);
dispatch_semaphore_signal(self->_requestLock);
}] resume];
dispatch_semaphore_wait(_requestLock, DISPATCH_TIME_FOREVER);

View File

@@ -6,7 +6,6 @@
// Copyright (c) 2015 Moonlight Stream. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "HttpResponse.h"
@interface HttpRequest : NSObject

View File

@@ -6,8 +6,6 @@
// Copyright (c) 2015 Moonlight Stream. All rights reserved.
//
#import <Foundation/Foundation.h>
static NSString* TAG_STATUS_CODE = @"status_code";
static NSString* TAG_STATUS_MESSAGE = @"status_message";

View File

@@ -6,8 +6,6 @@
// Copyright (c) 2014 Moonlight Stream. All rights reserved.
//
#import <Foundation/Foundation.h>
@protocol MDNSCallback <NSObject>
- (void) updateHosts:(NSArray*)hosts;

View File

@@ -6,7 +6,6 @@
// Copyright (c) 2014 Moonlight Stream. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "HttpManager.h"
@protocol PairCallback <NSObject>

View File

@@ -6,7 +6,6 @@
// Copyright (c) 2015 Moonlight Stream. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "TemporaryHost.h"
@interface WakeOnLanManager : NSObject

View File

@@ -6,7 +6,6 @@
// Copyright (c) 2014 Moonlight Stream. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "VideoDecoderRenderer.h"
#import "StreamConfiguration.h"

View File

@@ -6,8 +6,6 @@
// Copyright (c) 2014 Moonlight Stream. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface StreamConfiguration : NSObject
@property NSString* host;

View File

@@ -6,7 +6,6 @@
// Copyright (c) 2014 Moonlight Stream. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "StreamConfiguration.h"
#import "Connection.h"

View File

@@ -6,8 +6,6 @@
// Copyright (c) 2014 Moonlight Stream. All rights reserved.
//
#import <Foundation/Foundation.h>
@import AVFoundation;
@interface VideoDecoderRenderer : NSObject

View File

@@ -7,11 +7,12 @@
//
#import "VideoDecoderRenderer.h"
#import "StreamView.h"
#include "Limelight.h"
@implementation VideoDecoderRenderer {
OSView *_view;
StreamView* _view;
AVSampleBufferDisplayLayer* displayLayer;
Boolean waitingForSps, waitingForPps, waitingForVps;
@@ -54,7 +55,7 @@
}
}
- (id)initWithView:(OSView*)view
- (id)initWithView:(StreamView*)view
{
self = [super init];
@@ -68,6 +69,9 @@
- (void)setupWithVideoFormat:(int)videoFormat
{
self->videoFormat = videoFormat;
#if !TARGET_OS_IPHONE
_view.codec = videoFormat;
#endif
}
#define FRAME_START_PREFIX_SIZE 4
@@ -335,7 +339,9 @@
}
[displayLayer enqueueSampleBuffer:sampleBuffer];
#if !TARGET_OS_IPHONE
_view.frameCount++;
#endif
// Dereference the buffers
CFRelease(blockBuffer);
CFRelease(sampleBuffer);

View File

@@ -6,8 +6,6 @@
// Copyright (c) 2014 Moonlight Stream. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface Utils : NSObject
typedef NS_ENUM(int, PairState) {
@@ -29,4 +27,4 @@ FOUNDATION_EXPORT NSString *const deviceName;
- (NSString*) trim;
@end
@end

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="13771" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" initialViewController="B8D-0N-5wS">
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="14109" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" initialViewController="B8D-0N-5wS">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="13771"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14109"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
@@ -832,38 +832,26 @@
<objects>
<viewController title="StreamFrame" storyboardIdentifier="streamFrameVC" id="8UI-ob-rLN" customClass="StreamFrameViewController" sceneMemberID="viewController">
<customView key="view" wantsLayer="YES" id="0nI-m2-hfb" customClass="StreamView">
<rect key="frame" x="0.0" y="0.0" width="200" height="200"/>
<rect key="frame" x="0.0" y="0.0" width="362" height="187"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<progressIndicator wantsLayer="YES" horizontalHuggingPriority="750" verticalHuggingPriority="750" maxValue="100" bezeled="NO" indeterminate="YES" controlSize="small" style="spinning" translatesAutoresizingMaskIntoConstraints="NO" id="dCg-Rb-XtM">
<rect key="frame" x="92" y="92" width="16" height="16"/>
<rect key="frame" x="173" y="86" width="16" height="16"/>
</progressIndicator>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Fbs-og-fmy">
<rect key="frame" x="18" y="65" width="164" height="19"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="center" id="T2I-Dw-oy5">
<font key="font" metaFont="system" size="15"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
</subviews>
<constraints>
<constraint firstItem="dCg-Rb-XtM" firstAttribute="centerY" secondItem="0nI-m2-hfb" secondAttribute="centerY" id="4KU-wx-Rei"/>
<constraint firstItem="Fbs-og-fmy" firstAttribute="leading" secondItem="0nI-m2-hfb" secondAttribute="leading" constant="20" id="6Bo-xo-1Kh"/>
<constraint firstAttribute="trailing" secondItem="Fbs-og-fmy" secondAttribute="trailing" constant="20" id="D6H-sy-lYF"/>
<constraint firstItem="dCg-Rb-XtM" firstAttribute="centerX" secondItem="0nI-m2-hfb" secondAttribute="centerX" id="LXb-65-YYS"/>
<constraint firstItem="Fbs-og-fmy" firstAttribute="top" secondItem="dCg-Rb-XtM" secondAttribute="bottom" constant="8" id="yOt-Xm-ghe"/>
</constraints>
</customView>
<connections>
<outlet property="progressIndicator" destination="dCg-Rb-XtM" id="KDw-2J-5Vx"/>
<outlet property="stageLabel" destination="Fbs-og-fmy" id="CQl-qn-f1H"/>
<outlet property="streamView" destination="0nI-m2-hfb" id="87h-Js-htb"/>
</connections>
</viewController>
<customObject id="SeL-fy-qhv" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="101" y="660"/>
<point key="canvasLocation" x="199" y="661"/>
</scene>
<!--SettingsFrame-->
<scene sceneID="z96-VP-gUP">
@@ -875,6 +863,7 @@
<subviews>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="hYZ-tr-UfS">
<rect key="frame" x="18" y="80" width="72" height="17"/>
<string key="toolTip">Any resolution different from 1080p/720p may not be supported by the host and could result in worse picture quality. Setup a custom resolution on the host PC that matches the aspect ratio of the client PC to get full-screen rendering.</string>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Resolution:" id="w6X-ji-ba4">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
@@ -883,6 +872,7 @@
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="4hp-dI-fwU">
<rect key="frame" x="18" y="51" width="48" height="17"/>
<string key="toolTip">This will be the bitrate for the video stream. Note that if not streaming remotely and using HEVC the effective video bitrate will be lower. Also note that this is only the video bitrate and there will be ~1Mbps for audio traffic. </string>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Bitrate:" id="1ex-3K-9IU">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
@@ -944,7 +934,7 @@
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="op8-KP-yTY">
<textField toolTip="Framerates different from 30fps or 60fps will (currently) fall back to one of these." horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="op8-KP-yTY">
<rect key="frame" x="18" y="20" width="70" height="17"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Framerate:" id="fzt-Ma-FGg">
<font key="font" metaFont="system"/>
@@ -952,7 +942,7 @@
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="tB7-JI-smj">
<button toolTip="If activated, the stream will be optimized for streaming over the internet." verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="tB7-JI-smj">
<rect key="frame" x="200" y="20" width="144" height="18"/>
<buttonCell key="cell" type="check" title="Streaming Remotely" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="RAr-f3-mlU">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>

View File

@@ -31,6 +31,7 @@
DC2F1746205DA35700C3021E /* PairManager.m in Sources */ = {isa = PBXBuildFile; fileRef = DC2F1734205DA35700C3021E /* PairManager.m */; };
DC2F174E205DA39600C3021E /* Utils.m in Sources */ = {isa = PBXBuildFile; fileRef = DC2F174A205DA39600C3021E /* Utils.m */; };
DC2F174F205DA39600C3021E /* Logger.m in Sources */ = {isa = PBXBuildFile; fileRef = DC2F174C205DA39600C3021E /* Logger.m */; };
DC381F8E206D74F600E0931A /* NetworkTraffic.m in Sources */ = {isa = PBXBuildFile; fileRef = DC381F8D206D74F600E0931A /* NetworkTraffic.m */; };
DC38D540205ACC360045FE93 /* Control.m in Sources */ = {isa = PBXBuildFile; fileRef = DC38D53F205ACC360045FE93 /* Control.m */; };
DC38D548205AD8D00045FE93 /* libstem_gamepad.a in Frameworks */ = {isa = PBXBuildFile; fileRef = DC38D544205AD8D00045FE93 /* libstem_gamepad.a */; };
DC38D549205AD9860045FE93 /* libstem_gamepad.a in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = DC38D544205AD8D00045FE93 /* libstem_gamepad.a */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
@@ -57,6 +58,7 @@
DC6A60862064299700A0673D /* ConnectionHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = DC6A60852064299700A0673D /* ConnectionHelper.m */; };
DC7029D5205B28340016D44B /* LICENSE.txt in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = DC7029D4205B28340016D44B /* LICENSE.txt */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
DC9CD51F20601658001A5DCD /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = DC9CD51E20601658001A5DCD /* AppDelegate.m */; };
DCA3B3F22070EED0006565D9 /* OverlayView.m in Sources */ = {isa = PBXBuildFile; fileRef = DCA3B3F02070EED0006565D9 /* OverlayView.m */; };
DCAF051C205F3E6A00AD1DBA /* Limelight.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = DCAF0516205F3E6A00AD1DBA /* Limelight.xcdatamodeld */; };
DCAF0522205FCADB00AD1DBA /* Controller.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCAF051F205FCADA00AD1DBA /* Controller.swift */; };
DCAF0523205FCADB00AD1DBA /* ControllerSupport.m in Sources */ = {isa = PBXBuildFile; fileRef = DCAF0521205FCADA00AD1DBA /* ControllerSupport.m */; };
@@ -176,6 +178,8 @@
DC2F174C205DA39600C3021E /* Logger.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Logger.m; path = Limelight/Utility/Logger.m; sourceTree = SOURCE_ROOT; };
DC2F174D205DA39600C3021E /* Utils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Utils.h; path = Limelight/Utility/Utils.h; sourceTree = SOURCE_ROOT; };
DC2F1751205DA48D00C3021E /* Limelight-Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "Limelight-Prefix.pch"; path = "Limelight/Limelight-Prefix.pch"; sourceTree = SOURCE_ROOT; };
DC381F8C206D74F600E0931A /* NetworkTraffic.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NetworkTraffic.h; path = "Moonlight macOS/Network/NetworkTraffic.h"; sourceTree = SOURCE_ROOT; };
DC381F8D206D74F600E0931A /* NetworkTraffic.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = NetworkTraffic.m; path = "Moonlight macOS/Network/NetworkTraffic.m"; sourceTree = SOURCE_ROOT; };
DC38D53E205ACC360045FE93 /* Control.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Control.h; sourceTree = "<group>"; };
DC38D53F205ACC360045FE93 /* Control.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Control.m; sourceTree = "<group>"; };
DC38D544205AD8D00045FE93 /* libstem_gamepad.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libstem_gamepad.a; sourceTree = "<group>"; };
@@ -288,6 +292,8 @@
DC6A60852064299700A0673D /* ConnectionHelper.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ConnectionHelper.m; sourceTree = "<group>"; };
DC7029D4205B28340016D44B /* LICENSE.txt */ = {isa = PBXFileReference; lastKnownFileType = text; path = LICENSE.txt; sourceTree = "<group>"; };
DC9CD51E20601658001A5DCD /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AppDelegate.m; path = Limelight/AppDelegate.m; sourceTree = SOURCE_ROOT; };
DCA3B3F02070EED0006565D9 /* OverlayView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OverlayView.m; sourceTree = "<group>"; };
DCA3B3F12070EED0006565D9 /* OverlayView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OverlayView.h; sourceTree = "<group>"; };
DCAF04FD205F38B100AD1DBA /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AppDelegate.h; path = Limelight/AppDelegate.h; sourceTree = SOURCE_ROOT; };
DCAF0517205F3E6A00AD1DBA /* Limelight.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = Limelight.xcdatamodel; sourceTree = "<group>"; };
DCAF0518205F3E6A00AD1DBA /* Moonlight v1.0-2.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = "Moonlight v1.0-2.xcdatamodel"; sourceTree = "<group>"; };
@@ -391,6 +397,8 @@
DC2F171C205DA35700C3021E /* Network */ = {
isa = PBXGroup;
children = (
DC381F8C206D74F600E0931A /* NetworkTraffic.h */,
DC381F8D206D74F600E0931A /* NetworkTraffic.m */,
DC2F171D205DA35700C3021E /* WakeOnLanManager.m */,
DC2F171E205DA35700C3021E /* ServerInfoResponse.m */,
DC2F171F205DA35700C3021E /* HttpResponse.m */,
@@ -696,6 +704,8 @@
DCAF13DB20530BE100896C35 /* Input */ = {
isa = PBXGroup;
children = (
DCA3B3F12070EED0006565D9 /* OverlayView.h */,
DCA3B3F02070EED0006565D9 /* OverlayView.m */,
DCAF051F205FCADA00AD1DBA /* Controller.swift */,
DCAF0520205FCADA00AD1DBA /* ControllerSupport.h */,
DCAF0521205FCADA00AD1DBA /* ControllerSupport.m */,
@@ -793,7 +803,7 @@
DC5EF53D2052FBDB00C9BF55 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0920;
LastUpgradeCheck = 0930;
ORGANIZATIONNAME = "Moonlight Game Streaming Project";
TargetAttributes = {
DC5EF5442052FBDB00C9BF55 = {
@@ -901,10 +911,12 @@
DC2F1742205DA35700C3021E /* AppListResponse.m in Sources */,
DC2F1741205DA35700C3021E /* AppAssetResponse.m in Sources */,
DC6A60862064299700A0673D /* ConnectionHelper.m in Sources */,
DC381F8E206D74F600E0931A /* NetworkTraffic.m in Sources */,
DCC23C26205DAC5C00BF3C25 /* Settings.m in Sources */,
DCD464E22053417800CC8950 /* StreamFrameViewController.m in Sources */,
DC5EF5582052FBDB00C9BF55 /* main.m in Sources */,
DC2F173A205DA35700C3021E /* WakeOnLanManager.m in Sources */,
DCA3B3F22070EED0006565D9 /* OverlayView.m in Sources */,
DCAF051C205F3E6A00AD1DBA /* Limelight.xcdatamodeld in Sources */,
DC0F7508205C04A90087B187 /* keepAlive.m in Sources */,
DC2634D4205438DC00D44F88 /* keyboardTranslation.m in Sources */,
@@ -979,6 +991,7 @@
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
@@ -986,6 +999,7 @@
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
@@ -1034,6 +1048,7 @@
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
@@ -1041,6 +1056,7 @@
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
@@ -1065,6 +1081,7 @@
MACOSX_DEPLOYMENT_TARGET = 10.13;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = macosx;
SWIFT_COMPILATION_MODE = wholemodule;
};
name = Release;
};
@@ -1076,6 +1093,7 @@
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = "Moonlight macOS/Moonlight macOS.entitlements";
CODE_SIGN_IDENTITY = "Mac Developer";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
DEVELOPMENT_TEAM = DQ6R9YE8BF;
@@ -1105,6 +1123,7 @@
OTHER_LDFLAGS = "";
PRODUCT_BUNDLE_IDENTIFIER = "com.moonlight-stream.Moonlight-macOS";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_OBJC_BRIDGING_HEADER = "Moonlight macOS/Input/Moonlight macOS-Bridging-Header.h";
SWIFT_OBJC_INTERFACE_HEADER_NAME = "Moonlight-Swift.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
@@ -1121,6 +1140,7 @@
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = "Moonlight macOS/Moonlight macOS.entitlements";
CODE_SIGN_IDENTITY = "Mac Developer";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
DEVELOPMENT_TEAM = DQ6R9YE8BF;
@@ -1154,6 +1174,8 @@
PRECOMPS_INCLUDE_HEADERS_FROM_BUILT_PRODUCTS_DIR = NO;
PRODUCT_BUNDLE_IDENTIFIER = "com.moonlight-stream.Moonlight-macOS";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_OBJC_BRIDGING_HEADER = "Moonlight macOS/Input/Moonlight macOS-Bridging-Header.h";
SWIFT_OBJC_INTERFACE_HEADER_NAME = "Moonlight-Swift.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>

View File

@@ -160,32 +160,37 @@ void onButtonUp(struct Gamepad_device * device, unsigned int buttonID, double ti
void onAxisMoved(struct Gamepad_device * device, unsigned int axisID, float value, float lastValue, double timestamp, void * context) {
if (fabsf(lastValue - value) > 0.01) {
_controller = [_controllers objectForKey:[NSNumber numberWithInteger:device->deviceID]];
// The dualshock controller has much more than these axis because of the motion axis, so it
// is better to call the updateFinished in the cases, because otherwise all of these
// motion axis will also trigger an updateFinished event.
switch (axisID) {
case LEFT_X:
_controller = [_controllers objectForKey:[NSNumber numberWithInteger:device->deviceID]];
_controller.lastLeftStickX = value * 0X7FFE;
[_controllerSupport updateFinished:_controller];
break;
case LEFT_Y:
_controller = [_controllers objectForKey:[NSNumber numberWithInteger:device->deviceID]];
_controller.lastLeftStickY = -value * 0X7FFE;
[_controllerSupport updateFinished:_controller];
break;
case RIGHT_X:
_controller = [_controllers objectForKey:[NSNumber numberWithInteger:device->deviceID]];
_controller.lastRightStickX = value * 0X7FFE;
[_controllerSupport updateFinished:_controller];
break;
case RIGHT_Y:
_controller = [_controllers objectForKey:[NSNumber numberWithInteger:device->deviceID]];
_controller.lastRightStickY = -value * 0X7FFE;
[_controllerSupport updateFinished:_controller];
break;
case LT:
_controller = [_controllers objectForKey:[NSNumber numberWithInteger:device->deviceID]];
_controller.lastLeftTrigger = value * 0xFF;
[_controllerSupport updateFinished:_controller];
break;
case RT:
_controller = [_controllers objectForKey:[NSNumber numberWithInteger:device->deviceID]];
_controller.lastRightTrigger = value * 0xFF;
[_controllerSupport updateFinished:_controller];
break;
@@ -208,11 +213,11 @@ void onDeviceRemoved(struct Gamepad_device * device, void * context) {
void initGamepad(ControllerSupport* controllerSupport) {
_controllerSupport = controllerSupport;
_controller = [[Controller alloc] init];
Gamepad_deviceAttachFunc(onDeviceAttached, NULL);
Gamepad_deviceRemoveFunc(onDeviceRemoved, NULL);
Gamepad_buttonDownFunc(onButtonDown, NULL);
Gamepad_buttonUpFunc(onButtonUp, NULL);
Gamepad_axisMoveFunc(onAxisMoved, NULL);
Gamepad_init();
_controller = [[Controller alloc] init];
}

View File

@@ -0,0 +1,16 @@
//
// OverlayView.h
// Moonlight macOS
//
// Created by Felix Kratz on 01.04.18.
// Copyright © 2018 Felix Kratz. All rights reserved.
//
#import <Cocoa/Cocoa.h>
@interface OverlayView : NSView
- (id)initWithFrame:(NSRect)frame sender:(StreamView*)sender;
- (void)toggleOverlay:(int)codec;
@end

View File

@@ -0,0 +1,98 @@
//
// OverlayView.m
// Moonlight macOS
//
// Created by Felix Kratz on 01.04.18.
// Copyright © 2018 Felix Kratz. All rights reserved.
//
#import "StreamView.h"
#import "OverlayView.h"
#import "NetworkTraffic.h"
@implementation OverlayView {
StreamView* _streamView;
bool statsDisplayed;
unsigned long lastNetworkDown;
unsigned long lastNetworkUp;
NSTextField* _textFieldIncomingBitrate;
NSTextField* _textFieldOutgoingBitrate;
NSTextField* _textFieldCodec;
NSTextField* _textFieldFramerate;
NSTextField* _stageLabel;
NSTimer* _statTimer;
}
- (id)initWithFrame:(NSRect)frame sender:(StreamView*)sender
{
self = [super initWithFrame:frame];
if (self) {
_streamView = sender;
}
return self;
}
- (void)initStats {
_textFieldCodec = [[NSTextField alloc] initWithFrame:NSMakeRect(5, NSScreen.mainScreen.frame.size.height - 22, 200, 17)];
_textFieldIncomingBitrate = [[NSTextField alloc] initWithFrame:NSMakeRect(5, 5, 250, 17)];
_textFieldOutgoingBitrate = [[NSTextField alloc] initWithFrame:NSMakeRect(5, 5 + 20, 250, 17)];
_textFieldFramerate = [[NSTextField alloc] initWithFrame:NSMakeRect(NSScreen.mainScreen.frame.size.width - 50, NSScreen.mainScreen.frame.size.height - 22, 50, 17)];
[self setupTextField:_textFieldOutgoingBitrate];
[self setupTextField:_textFieldIncomingBitrate];
[self setupTextField:_textFieldCodec];
[self setupTextField:_textFieldFramerate];
}
- (void)setupTextField:(NSTextField*)textField {
textField.drawsBackground = false;
textField.bordered = false;
textField.editable = false;
textField.alignment = NSTextAlignmentLeft;
textField.textColor = [NSColor whiteColor];
[self addSubview:textField];
}
- (void)toggleOverlay:(int)codec {
statsDisplayed = !statsDisplayed;
if (statsDisplayed) {
_streamView.frameCount = 0;
if (_textFieldIncomingBitrate == nil || _textFieldCodec == nil || _textFieldOutgoingBitrate == nil || _textFieldFramerate == nil) {
[self initStats];
}
_statTimer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(statTimerTick) userInfo:nil repeats:true];
NSLog(@"display stats");
if (codec == 1) {
_textFieldCodec.stringValue = @"Codec: H.264";
}
else if (codec == 256) {
_textFieldCodec.stringValue = @"Codec: HEVC/H.265";
}
else {
_textFieldCodec.stringValue = @"Codec: Unknown";
}
[self statTimerTick];
}
else {
[_statTimer invalidate];
_textFieldCodec.stringValue = @"";
_textFieldIncomingBitrate.stringValue = @"";
_textFieldOutgoingBitrate.stringValue = @"";
_textFieldFramerate.stringValue = @"";
}
}
- (void)statTimerTick {
_textFieldFramerate.stringValue = [NSString stringWithFormat:@"%i fps", _streamView.frameCount];
_streamView.frameCount = 0;
unsigned long currentNetworkDown = getBytesDown();
_textFieldIncomingBitrate.stringValue = [NSString stringWithFormat:@"Incoming Bitrate (System): %lu kbps", (currentNetworkDown - lastNetworkDown)*8 / 1000];
lastNetworkDown = currentNetworkDown;
unsigned long currentNetworkUp = getBytesUp();
_textFieldOutgoingBitrate.stringValue = [NSString stringWithFormat:@"Outgoing Bitrate (System): %lu kbps", (currentNetworkUp - lastNetworkUp)*8 / 1000];
lastNetworkUp = currentNetworkUp;
}
@end

View File

@@ -8,5 +8,10 @@
@interface StreamView : NSView
- (void)drawMessage:(NSString*)message;
@property int codec;
@property unsigned short frameCount;
@end

View File

@@ -11,26 +11,27 @@
#import "DataManager.h"
#include <ApplicationServices/ApplicationServices.h>
#include "keyboardTranslation.h"
#import "OverlayView.h"
@implementation StreamView {
BOOL isDragging;
NSTrackingArea *trackingArea;
bool isDragging;
NSTrackingArea* _trackingArea;
OverlayView* _overlay;
NSTextField* _stageLabel;
}
- (void) updateTrackingAreas {
// This will be the area used to track the mouse movement
if (trackingArea != nil) {
[self removeTrackingArea:trackingArea];
if (_trackingArea != nil) {
[self removeTrackingArea:_trackingArea];
}
NSTrackingAreaOptions options = (NSTrackingActiveAlways | NSTrackingInVisibleRect |
NSTrackingMouseEnteredAndExited | NSTrackingMouseMoved);
trackingArea = [[NSTrackingArea alloc] initWithRect:[self bounds]
_trackingArea = [[NSTrackingArea alloc] initWithRect:[self bounds]
options:options
owner:self
userInfo:nil];
[self addTrackingArea:trackingArea];
[self addTrackingArea:_trackingArea];
}
-(void)mouseDragged:(NSEvent *)event {
@@ -59,24 +60,20 @@
- (void)mouseDown:(NSEvent *)mouseEvent {
LiSendMouseButtonEvent(BUTTON_ACTION_PRESS, BUTTON_LEFT);
[self setNeedsDisplay:YES];
}
- (void)mouseUp:(NSEvent *)mouseEvent {
isDragging = false;
LiSendMouseButtonEvent(BUTTON_ACTION_RELEASE, BUTTON_LEFT);
[self setNeedsDisplay:YES];
}
- (void)rightMouseUp:(NSEvent *)mouseEvent {
isDragging = false;
LiSendMouseButtonEvent(BUTTON_ACTION_RELEASE, BUTTON_RIGHT);
[self setNeedsDisplay:YES];
}
- (void)rightMouseDown:(NSEvent *)mouseEvent {
LiSendMouseButtonEvent(BUTTON_ACTION_PRESS, BUTTON_RIGHT);
[self setNeedsDisplay:YES];
}
- (void)mouseMoved:(NSEvent *)mouseEvent {
@@ -85,22 +82,24 @@
-(void)keyDown:(NSEvent *)event {
unsigned char keyChar = keyCharFromKeyCode(event.keyCode);
printf("DOWN: KeyCode: %hu, keyChar: %d, keyModifier: %lu \n", event.keyCode, keyChar, event.modifierFlags);
NSLog(@"DOWN: KeyCode: %hu, keyChar: %d, keyModifier: %lu \n", event.keyCode, keyChar, event.modifierFlags);
LiSendKeyboardEvent(keyChar, KEY_ACTION_DOWN, modifierFlagForKeyModifier(event.modifierFlags));
if (event.modifierFlags & kCGEventFlagMaskCommand && event.keyCode == kVK_ANSI_I) {
[self toggleStats];
}
}
-(void)keyUp:(NSEvent *)event {
unsigned char keyChar = keyCharFromKeyCode(event.keyCode);
printf("UP: KeyChar: %d \n", keyChar);
NSLog(@"UP: KeyChar: %d \n", keyChar);
LiSendKeyboardEvent(keyChar, KEY_ACTION_UP, modifierFlagForKeyModifier(event.modifierFlags));
}
- (void)flagsChanged:(NSEvent *)event
{
- (void)flagsChanged:(NSEvent *)event {
unsigned char keyChar = keyCodeFromModifierKey(event.modifierFlags);
if(keyChar) {
printf("DOWN: FlagChanged: %hhu \n", keyChar);
NSLog(@"DOWN: FlagChanged: %hhu \n", keyChar);
LiSendKeyboardEvent(keyChar, KEY_ACTION_DOWN, 0x00);
}
else {
@@ -108,6 +107,33 @@
}
}
- (void)initStageLabel {
_stageLabel = [[NSTextField alloc] initWithFrame:NSMakeRect(NSScreen.mainScreen.frame.size.width/2 - 100, NSScreen.mainScreen.frame.size.height/2 - 8, 200, 17)];
_stageLabel.drawsBackground = false;
_stageLabel.bordered = false;
_stageLabel.alignment = NSTextAlignmentCenter;
_stageLabel.textColor = [NSColor blackColor];
[self addSubview:_stageLabel];
}
- (void)toggleStats {
if (_overlay == nil) {
_overlay = [[OverlayView alloc] initWithFrame:self.frame sender:self];
[self addSubview:_overlay];
}
[_overlay toggleOverlay:_codec];
}
- (void)drawMessage:(NSString*)message {
dispatch_async(dispatch_get_main_queue(), ^{
if (self->_stageLabel == nil) {
[self initStageLabel];
}
self->_stageLabel.stringValue = message;
});
}
- (BOOL)acceptsFirstResponder {
return YES;
}

View File

@@ -0,0 +1,15 @@
//
// NetworkTraffic.h
// Moonlight macOS
//
// Created by Felix Kratz on 28.03.18.
// Copyright © 2018 Felix Kratz. All rights reserved.
//
#ifndef NetworkTraffic_h
#define NetworkTraffic_h
unsigned long getBytesDown(void);
unsigned long getBytesUp(void);
#endif /* NetworkTraffic_h */

View File

@@ -0,0 +1,50 @@
//
// NetworkTraffic.m
// Moonlight macOS
//
// Created by Felix Kratz on 28.03.18.
// Copyright © 2018 Felix Kratz. All rights reserved.
//
#import "NetworkTraffic.h"
#include <ifaddrs.h>
#include <net/if.h>
struct ifaddrs *ifap, *ifa;
unsigned long da;
unsigned long getBytesDown() {
da = 0;
getifaddrs (&ifap);
ifa = ifap;
while (ifa != NULL) {
if (ifa->ifa_addr->sa_family == AF_LINK) {
const struct if_data *ifa_data = (struct if_data *)ifa->ifa_data;
if (ifa_data != NULL) {
da += ifa_data->ifi_ibytes;
}
}
ifa = ifa->ifa_next;
}
freeifaddrs(ifap);
return da;
}
unsigned long getBytesUp() {
da = 0;
getifaddrs (&ifap);
ifa = ifap;
while (ifa != NULL) {
if (ifa->ifa_addr->sa_family == AF_LINK) {
const struct if_data *ifa_data = (struct if_data *)ifa->ifa_data;
if (ifa_data != NULL) {
da += ifa_data->ifi_obytes;
}
}
ifa = ifa->ifa_next;
}
freeifaddrs(ifap);
return da;
}

View File

@@ -5,7 +5,6 @@
// Created by Felix Kratz on 31.10.17.
// Copyright © 2017 Felix Kratz. All rights reserved.
//
#import <Foundation/Foundation.h>
#ifndef keepAlive_h
#define keepAlive_h

View File

@@ -6,7 +6,6 @@
// Copyright © 2018 Felix Kratz. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "keyboardTranslation.h"
#import <Limelight.h>

View File

@@ -21,6 +21,5 @@
@property (nonatomic) StreamConfiguration* streamConfig;
@property (strong) IBOutlet StreamView *streamView;
@property (weak) IBOutlet NSProgressIndicator *progressIndicator;
@property (weak) IBOutlet NSTextField *stageLabel;
@end

View File

@@ -12,6 +12,7 @@
#import "Gamepad.h"
#import "keepAlive.h"
#import "ControllerSupport.h"
#import "StreamView.h"
@interface StreamFrameViewController ()
@end
@@ -48,11 +49,11 @@
// Can someone test this?
_controllerSupport = [[ControllerSupport alloc] init];
// The gamepad currently gets polled at 60Hz, this could very well be set as 1/Framerate in the future.
_eventTimer = [NSTimer scheduledTimerWithTimeInterval:1.0/60.0 target:self selector:@selector(eventTimerTick) userInfo:nil repeats:true];
// The gamepad currently gets polled at 1/Framerate.
_eventTimer = [NSTimer scheduledTimerWithTimeInterval:1.0/_streamConfig.frameRate target:self selector:@selector(eventTimerTick) userInfo:nil repeats:true];
// We search for new devices every second.
_searchTimer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(searchTimerTick) userInfo:nil repeats:true];
// We search for new devices every 2 seconds.
_searchTimer = [NSTimer scheduledTimerWithTimeInterval:2 target:self selector:@selector(searchTimerTick) userInfo:nil repeats:true];
}
- (void)eventTimerTick {
@@ -94,36 +95,38 @@
- (void)connectionStarted {
dispatch_async(dispatch_get_main_queue(), ^{
[_progressIndicator stopAnimation:nil];
_progressIndicator.hidden = true;
_stageLabel.stringValue = @"Waiting for the first frame";
[self->_progressIndicator stopAnimation:nil];
self->_progressIndicator.hidden = true;
});
}
- (void)connectionTerminated:(long)errorCode {
[_streamMan stopStream];
[self transitionToSetupView:1];
}
- (void)transitionToSetupView:(long)errorCode {
dispatch_async(dispatch_get_main_queue(), ^{
NSLog(@"error has occured: %ld", errorCode);
NSStoryboard *storyBoard = [NSStoryboard storyboardWithName:@"Mac" bundle:nil];
ViewController* view = (ViewController*)[storyBoard instantiateControllerWithIdentifier :@"setupFrameVC"];
[view setError:1];
[view setError:errorCode];
self.view.window.contentViewController = view;
});
}
- (void)setOrigin: (ViewController*) viewController
{
- (void)setOrigin: (ViewController*) viewController {
_origin = viewController;
}
- (void)displayMessage:(const char *)message {
//[_streamView drawMessage:[NSString stringWithFormat:@"%s", message]];
}
- (void)displayTransientMessage:(const char *)message {
}
- (void)launchFailed:(NSString *)message {
}
- (void)stageComplete:(const char *)stageName {
@@ -131,10 +134,11 @@
}
- (void)stageFailed:(const char *)stageName withError:(long)errorCode {
//[_streamView drawMessage:[NSString stringWithFormat:@"Stage: %s failed with code: %li", stageName, errorCode]];
}
- (void)stageStarting:(const char *)stageName {
//[_streamView drawMessage:[NSString stringWithFormat:@"%s", stageName]];
}
@end

View File

@@ -7,7 +7,6 @@
//
#import <Cocoa/Cocoa.h>
#import <AppKit/AppKit.h>
#import "PairManager.h"
#import "StreamConfiguration.h"

View File

@@ -58,6 +58,14 @@
// Do any additional setup after loading the view.
}
- (void)viewWillAppear {
[super viewWillAppear];
if ([[[NSUserDefaults standardUserDefaults] stringForKey:@"AppleInterfaceStyle"] isEqual: @"Dark"]) {
[self.view.window setAppearance:[NSAppearance appearanceNamed:NSAppearanceNameVibrantDark]];
}
}
- (void)viewDidAppear {
[super viewDidAppear];
@@ -84,9 +92,9 @@
-(void) showAlert:(NSString*) message {
dispatch_async(dispatch_get_main_queue(), ^{
_alert = [NSAlert new];
_alert.messageText = message;
[_alert beginSheetModalForWindow:[self.view window] completionHandler:^(NSInteger result) {
self->_alert = [NSAlert new];
self->_alert.messageText = message;
[self->_alert beginSheetModalForWindow:[self.view window] completionHandler:^(NSInteger result) {
NSLog(@"Success");
}];
});
@@ -138,7 +146,7 @@
_host = _textFieldHost.stringValue;
HttpManager* hMan = [[HttpManager alloc] initWithHost:_textFieldHost.stringValue
uniqueId:_uniqueId
deviceName:@"roth"
deviceName:deviceName
cert:_cert];
ServerInfoResponse* serverInfoResp = [[ServerInfoResponse alloc] init];
@@ -152,9 +160,9 @@
// Polling the server while pairing causes the server to screw up
NSLog(@"Pairing");
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
HttpManager* hMan = [[HttpManager alloc] initWithHost:_host uniqueId:_uniqueId deviceName:deviceName cert:_cert];
PairManager* pMan = [[PairManager alloc] initWithManager:hMan andCert:_cert callback:self];
[_opQueue addOperation:pMan];
HttpManager* hMan = [[HttpManager alloc] initWithHost:self->_host uniqueId:self->_uniqueId deviceName:deviceName cert:self->_cert];
PairManager* pMan = [[PairManager alloc] initWithManager:hMan andCert:self->_cert callback:self];
[self->_opQueue addOperation:pMan];
});
}
}
@@ -174,12 +182,12 @@
- (void)alreadyPaired {
dispatch_async(dispatch_get_main_queue(), ^{
[_popupButtonSelection setEnabled:true];
[_popupButtonSelection setHidden:false];
[_buttonConnect setEnabled:false];
[_buttonConnect setHidden:true];
[_buttonLaunch setEnabled:true];
[_textFieldHost setEnabled:false];
[self->_popupButtonSelection setEnabled:true];
[self->_popupButtonSelection setHidden:false];
[self->_buttonConnect setEnabled:false];
[self->_buttonConnect setHidden:true];
[self->_buttonLaunch setEnabled:true];
[self->_textFieldHost setEnabled:false];
});
[self searchForHost:_host];
[self updateAppsForHost];
@@ -202,8 +210,8 @@
- (void)pairSuccessful {
dispatch_async(dispatch_get_main_queue(), ^{
[self.view.window endSheet:_alert.window];
_alert = nil;
[self.view.window endSheet:self->_alert.window];
self->_alert = nil;
[self alreadyPaired];
});
}

View File

@@ -285,7 +285,7 @@
FB290E2619B37A4E004C83CF /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0920;
LastUpgradeCheck = 0930;
ORGANIZATIONNAME = "Moonlight Stream";
};
buildConfigurationList = FB290E2919B37A4E004C83CF /* Build configuration list for PBXProject "moonlight-common_mac" */;
@@ -355,12 +355,14 @@
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
@@ -390,6 +392,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
MACOSX_DEPLOYMENT_TARGET = 10.10;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
@@ -409,12 +412,14 @@
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
@@ -437,6 +442,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
MACOSX_DEPLOYMENT_TARGET = 10.10;
PROVISIONING_PROFILE = "";
SDKROOT = macosx;
@@ -447,7 +453,6 @@
FB290E3319B37A4E004C83CF /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD)";
CODE_SIGN_IDENTITY = "Mac Developer";
EXECUTABLE_PREFIX = lib;
HEADER_SEARCH_PATHS = (
@@ -458,7 +463,7 @@
MACOSX_DEPLOYMENT_TARGET = 10.13;
ONLY_ACTIVE_ARCH = NO;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx10.13;
SDKROOT = macosx;
SUPPORTED_PLATFORMS = macosx;
};
name = Debug;
@@ -466,7 +471,6 @@
FB290E3419B37A4E004C83CF /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD)";
CODE_SIGN_IDENTITY = "Mac Developer";
EXECUTABLE_PREFIX = lib;
GCC_OPTIMIZATION_LEVEL = 0;
@@ -478,7 +482,7 @@
MACOSX_DEPLOYMENT_TARGET = 10.13;
ONLY_ACTIVE_ARCH = NO;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx10.13;
SDKROOT = macosx;
SUPPORTED_PLATFORMS = macosx;
};
name = Release;