mirror of
https://github.com/moonlight-stream/moonlight-ios.git
synced 2026-06-17 14:11:35 +00:00
Add on-screen connection status warning
This commit is contained in:
@@ -18,6 +18,7 @@
|
|||||||
- (void) stageFailed:(const char*)stageName withError:(long)errorCode;
|
- (void) stageFailed:(const char*)stageName withError:(long)errorCode;
|
||||||
- (void) launchFailed:(NSString*)message;
|
- (void) launchFailed:(NSString*)message;
|
||||||
- (void) rumble:(unsigned short)controllerNumber lowFreqMotor:(unsigned short)lowFreqMotor highFreqMotor:(unsigned short)highFreqMotor;
|
- (void) rumble:(unsigned short)controllerNumber lowFreqMotor:(unsigned short)lowFreqMotor highFreqMotor:(unsigned short)highFreqMotor;
|
||||||
|
- (void) connectionStatusUpdate:(int)status;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|||||||
@@ -238,6 +238,11 @@ void ClRumble(unsigned short controllerNumber, unsigned short lowFreqMotor, unsi
|
|||||||
[_callbacks rumble:controllerNumber lowFreqMotor:lowFreqMotor highFreqMotor:highFreqMotor];
|
[_callbacks rumble:controllerNumber lowFreqMotor:lowFreqMotor highFreqMotor:highFreqMotor];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ClConnectionStatusUpdate(int status)
|
||||||
|
{
|
||||||
|
[_callbacks connectionStatusUpdate:status];
|
||||||
|
}
|
||||||
|
|
||||||
-(void) terminate
|
-(void) terminate
|
||||||
{
|
{
|
||||||
// Interrupt any action blocking LiStartConnection(). This is
|
// Interrupt any action blocking LiStartConnection(). This is
|
||||||
@@ -369,6 +374,7 @@ void ClRumble(unsigned short controllerNumber, unsigned short lowFreqMotor, unsi
|
|||||||
_clCallbacks.connectionTerminated = ClConnectionTerminated;
|
_clCallbacks.connectionTerminated = ClConnectionTerminated;
|
||||||
_clCallbacks.logMessage = ClLogMessage;
|
_clCallbacks.logMessage = ClLogMessage;
|
||||||
_clCallbacks.rumble = ClRumble;
|
_clCallbacks.rumble = ClRumble;
|
||||||
|
_clCallbacks.connectionStatusUpdate = ClConnectionStatusUpdate;
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
|
#include <Limelight.h>
|
||||||
|
|
||||||
@implementation StreamFrameViewController {
|
@implementation StreamFrameViewController {
|
||||||
ControllerSupport *_controllerSupport;
|
ControllerSupport *_controllerSupport;
|
||||||
@@ -22,6 +23,7 @@
|
|||||||
NSTimer *_inactivityTimer;
|
NSTimer *_inactivityTimer;
|
||||||
UITapGestureRecognizer *_menuGestureRecognizer;
|
UITapGestureRecognizer *_menuGestureRecognizer;
|
||||||
UITapGestureRecognizer *_menuDoubleTapGestureRecognizer;
|
UITapGestureRecognizer *_menuDoubleTapGestureRecognizer;
|
||||||
|
UITextView *_overlayView;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)viewDidAppear:(BOOL)animated
|
- (void)viewDidAppear:(BOOL)animated
|
||||||
@@ -118,6 +120,31 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)updateOverlayText:(NSString*)text {
|
||||||
|
if (_overlayView == nil) {
|
||||||
|
_overlayView = [[UITextView alloc] init];
|
||||||
|
[_overlayView setEditable:NO];
|
||||||
|
[_overlayView setSelectable:NO];
|
||||||
|
[_overlayView setScrollEnabled:NO];
|
||||||
|
[_overlayView setTextAlignment:NSTextAlignmentCenter];
|
||||||
|
[_overlayView setTextColor:[OSColor lightGrayColor]];
|
||||||
|
[_overlayView setBackgroundColor:[OSColor blackColor]];
|
||||||
|
[_overlayView setFont:[UIFont systemFontOfSize:12]];
|
||||||
|
[_overlayView setAlpha:0.5];
|
||||||
|
[self.view addSubview:_overlayView];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (text != nil) {
|
||||||
|
[_overlayView setText:text];
|
||||||
|
[_overlayView sizeToFit];
|
||||||
|
[_overlayView setCenter:CGPointMake(self.view.frame.size.width / 2, _overlayView.frame.size.height / 2)];
|
||||||
|
[_overlayView setHidden:NO];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
[_overlayView setHidden:YES];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
- (void) returnToMainFrame {
|
- (void) returnToMainFrame {
|
||||||
[self.navigationController popToRootViewControllerAnimated:YES];
|
[self.navigationController popToRootViewControllerAnimated:YES];
|
||||||
}
|
}
|
||||||
@@ -264,6 +291,27 @@
|
|||||||
[_controllerSupport rumble:controllerNumber lowFreqMotor:lowFreqMotor highFreqMotor:highFreqMotor];
|
[_controllerSupport rumble:controllerNumber lowFreqMotor:lowFreqMotor highFreqMotor:highFreqMotor];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)connectionStatusUpdate:(int)status {
|
||||||
|
Log(LOG_W, @"Connection status update: %d", status);
|
||||||
|
|
||||||
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
|
switch (status) {
|
||||||
|
case CONN_STATUS_OKAY:
|
||||||
|
[self updateOverlayText:nil];
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CONN_STATUS_POOR:
|
||||||
|
if (self->_streamConfig.bitRate > 5000) {
|
||||||
|
[self updateOverlayText:@"Slow connection to PC\nReduce your bitrate"];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
[self updateOverlayText:@"Poor connection to PC"];
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
- (void)didReceiveMemoryWarning
|
- (void)didReceiveMemoryWarning
|
||||||
{
|
{
|
||||||
[super didReceiveMemoryWarning];
|
[super didReceiveMemoryWarning];
|
||||||
|
|||||||
Reference in New Issue
Block a user