mirror of
https://github.com/moonlight-stream/moonlight-ios.git
synced 2026-06-15 21:21:45 +00:00
Refactor OSC handling
This commit is contained in:
@@ -7,8 +7,8 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
#import "StreamView.h"
|
|
||||||
|
|
||||||
|
@protocol EdgeDetectionDelegate;
|
||||||
@class ControllerSupport;
|
@class ControllerSupport;
|
||||||
|
|
||||||
@interface OnScreenControls : NSObject
|
@interface OnScreenControls : NSObject
|
||||||
@@ -30,5 +30,7 @@ typedef NS_ENUM(NSInteger, OnScreenControlsLevel) {
|
|||||||
- (BOOL) handleTouchUpEvent:(NSSet*)touches;
|
- (BOOL) handleTouchUpEvent:(NSSet*)touches;
|
||||||
- (BOOL) handleTouchMovedEvent:(NSSet*)touches;
|
- (BOOL) handleTouchMovedEvent:(NSSet*)touches;
|
||||||
- (void) setLevel:(OnScreenControlsLevel)level;
|
- (void) setLevel:(OnScreenControlsLevel)level;
|
||||||
|
- (OnScreenControlsLevel) getLevel;
|
||||||
|
- (void) show;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#import "OnScreenControls.h"
|
#import "OnScreenControls.h"
|
||||||
|
#import "StreamView.h"
|
||||||
#import "ControllerSupport.h"
|
#import "ControllerSupport.h"
|
||||||
#import "Controller.h"
|
#import "Controller.h"
|
||||||
#include "Limelight.h"
|
#include "Limelight.h"
|
||||||
@@ -64,6 +65,7 @@
|
|||||||
CGRect _controlArea;
|
CGRect _controlArea;
|
||||||
UIView* _view;
|
UIView* _view;
|
||||||
OnScreenControlsLevel _level;
|
OnScreenControlsLevel _level;
|
||||||
|
BOOL _visible;
|
||||||
|
|
||||||
ControllerSupport *_controllerSupport;
|
ControllerSupport *_controllerSupport;
|
||||||
Controller *_controller;
|
Controller *_controller;
|
||||||
@@ -156,14 +158,29 @@ static float L3_Y;
|
|||||||
_rightStick = [CALayer layer];
|
_rightStick = [CALayer layer];
|
||||||
_edge = [CALayer layer];
|
_edge = [CALayer layer];
|
||||||
|
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) show {
|
||||||
|
_visible = YES;
|
||||||
|
|
||||||
[self setupEdgeDetection];
|
[self setupEdgeDetection];
|
||||||
|
|
||||||
return self;
|
[self updateControls];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setLevel:(OnScreenControlsLevel)level {
|
- (void) setLevel:(OnScreenControlsLevel)level {
|
||||||
_level = level;
|
_level = level;
|
||||||
[self updateControls];
|
|
||||||
|
// Only update controls if we're showing, otherwise
|
||||||
|
// show will do it for us.
|
||||||
|
if (_visible) {
|
||||||
|
[self updateControls];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (OnScreenControlsLevel) getLevel {
|
||||||
|
return _level;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) updateControls {
|
- (void) updateControls {
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#import "ControllerSupport.h"
|
#import "ControllerSupport.h"
|
||||||
|
#import "OnScreenControls.h"
|
||||||
|
|
||||||
@protocol EdgeDetectionDelegate <NSObject>
|
@protocol EdgeDetectionDelegate <NSObject>
|
||||||
|
|
||||||
@@ -18,8 +19,9 @@
|
|||||||
|
|
||||||
@property (nonatomic, retain) IBOutlet UITextField* keyInputField;
|
@property (nonatomic, retain) IBOutlet UITextField* keyInputField;
|
||||||
|
|
||||||
- (void) setupStreamView;
|
- (void) setupStreamView:(ControllerSupport*)controllerSupport swipeDelegate:(id<EdgeDetectionDelegate>)swipeDelegate;
|
||||||
- (void) setupOnScreenControls:(ControllerSupport*)controllerSupport swipeDelegate:(id<EdgeDetectionDelegate>)swipeDelegate;
|
- (void) showOnScreenControls;
|
||||||
- (void) setMouseDeltaFactors:(float)x y:(float)y;
|
- (void) setMouseDeltaFactors:(float)x y:(float)y;
|
||||||
|
- (OnScreenControlsLevel) getCurrentOscState;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
|
|
||||||
#import "StreamView.h"
|
#import "StreamView.h"
|
||||||
#include <Limelight.h>
|
#include <Limelight.h>
|
||||||
#import "OnScreenControls.h"
|
|
||||||
#import "DataManager.h"
|
#import "DataManager.h"
|
||||||
#import "ControllerSupport.h"
|
#import "ControllerSupport.h"
|
||||||
#import "KeyboardSupport.h"
|
#import "KeyboardSupport.h"
|
||||||
@@ -47,7 +46,7 @@
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setupStreamView {
|
- (void) setupStreamView:(ControllerSupport*)controllerSupport swipeDelegate:(id<EdgeDetectionDelegate>)swipeDelegate {
|
||||||
#if TARGET_OS_TV
|
#if TARGET_OS_TV
|
||||||
remotePressRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(remoteButtonPressed:)];
|
remotePressRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(remoteButtonPressed:)];
|
||||||
remotePressRecognizer.allowedPressTypes = @[@(UIPressTypeSelect)];
|
remotePressRecognizer.allowedPressTypes = @[@(UIPressTypeSelect)];
|
||||||
@@ -57,14 +56,10 @@
|
|||||||
|
|
||||||
[self addGestureRecognizer:remotePressRecognizer];
|
[self addGestureRecognizer:remotePressRecognizer];
|
||||||
[self addGestureRecognizer:remoteLongPressRecognizer];
|
[self addGestureRecognizer:remoteLongPressRecognizer];
|
||||||
#endif
|
#else
|
||||||
}
|
|
||||||
|
|
||||||
- (void) setupOnScreenControls:(ControllerSupport*)controllerSupport swipeDelegate:(id<EdgeDetectionDelegate>)swipeDelegate {
|
|
||||||
onScreenControls = [[OnScreenControls alloc] initWithView:self controllerSup:controllerSupport swipeDelegate:swipeDelegate];
|
onScreenControls = [[OnScreenControls alloc] initWithView:self controllerSup:controllerSupport swipeDelegate:swipeDelegate];
|
||||||
DataManager* dataMan = [[DataManager alloc] init];
|
DataManager* dataMan = [[DataManager alloc] init];
|
||||||
OnScreenControlsLevel level = (OnScreenControlsLevel)[[dataMan getSettings].onscreenControls integerValue];
|
OnScreenControlsLevel level = (OnScreenControlsLevel)[[dataMan getSettings].onscreenControls integerValue];
|
||||||
|
|
||||||
if (level == OnScreenControlsLevelAuto) {
|
if (level == OnScreenControlsLevelAuto) {
|
||||||
[controllerSupport initAutoOnScreenControlMode:onScreenControls];
|
[controllerSupport initAutoOnScreenControlMode:onScreenControls];
|
||||||
}
|
}
|
||||||
@@ -72,7 +67,23 @@
|
|||||||
Log(LOG_I, @"Setting manual on-screen controls level: %d", (int)level);
|
Log(LOG_I, @"Setting manual on-screen controls level: %d", (int)level);
|
||||||
[onScreenControls setLevel:level];
|
[onScreenControls setLevel:level];
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) showOnScreenControls {
|
||||||
|
#if !TARGET_OS_TV
|
||||||
|
[onScreenControls show];
|
||||||
[self becomeFirstResponder];
|
[self becomeFirstResponder];
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
- (OnScreenControlsLevel) getCurrentOscState {
|
||||||
|
if (onScreenControls == nil) {
|
||||||
|
return OnScreenControlsLevelOff;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return [onScreenControls getLevel];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (Boolean)isConfirmedMove:(CGPoint)currentPoint from:(CGPoint)originalPoint {
|
- (Boolean)isConfirmedMove:(CGPoint)currentPoint from:(CGPoint)originalPoint {
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
UITapGestureRecognizer *_menuGestureRecognizer;
|
UITapGestureRecognizer *_menuGestureRecognizer;
|
||||||
UITapGestureRecognizer *_menuDoubleTapGestureRecognizer;
|
UITapGestureRecognizer *_menuDoubleTapGestureRecognizer;
|
||||||
UITextView *_overlayView;
|
UITextView *_overlayView;
|
||||||
|
StreamView *_streamView;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)viewDidAppear:(BOOL)animated
|
- (void)viewDidAppear:(BOOL)animated
|
||||||
@@ -50,8 +51,6 @@
|
|||||||
|
|
||||||
[self.navigationController setNavigationBarHidden:YES animated:YES];
|
[self.navigationController setNavigationBarHidden:YES animated:YES];
|
||||||
|
|
||||||
[(StreamView*)self.view setupStreamView];
|
|
||||||
|
|
||||||
[self.stageLabel setText:[NSString stringWithFormat:@"Starting %@...", self.streamConfig.appName]];
|
[self.stageLabel setText:[NSString stringWithFormat:@"Starting %@...", self.streamConfig.appName]];
|
||||||
[self.stageLabel sizeToFit];
|
[self.stageLabel sizeToFit];
|
||||||
self.stageLabel.textAlignment = NSTextAlignmentCenter;
|
self.stageLabel.textAlignment = NSTextAlignmentCenter;
|
||||||
@@ -61,6 +60,10 @@
|
|||||||
|
|
||||||
_controllerSupport = [[ControllerSupport alloc] initWithConfig:self.streamConfig];
|
_controllerSupport = [[ControllerSupport alloc] initWithConfig:self.streamConfig];
|
||||||
_inactivityTimer = nil;
|
_inactivityTimer = nil;
|
||||||
|
|
||||||
|
_streamView = (StreamView*)self.view;
|
||||||
|
[_streamView setupStreamView:_controllerSupport swipeDelegate:self];
|
||||||
|
|
||||||
#if TARGET_OS_TV
|
#if TARGET_OS_TV
|
||||||
if (!_menuGestureRecognizer || !_menuDoubleTapGestureRecognizer) {
|
if (!_menuGestureRecognizer || !_menuDoubleTapGestureRecognizer) {
|
||||||
_menuGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(controllerPauseButtonPressed:)];
|
_menuGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(controllerPauseButtonPressed:)];
|
||||||
@@ -221,9 +224,8 @@
|
|||||||
// the first frame of video.
|
// the first frame of video.
|
||||||
self.stageLabel.hidden = YES;
|
self.stageLabel.hidden = YES;
|
||||||
self.tipLabel.hidden = YES;
|
self.tipLabel.hidden = YES;
|
||||||
#if !TARGET_OS_TV
|
|
||||||
[(StreamView*)self.view setupOnScreenControls: self->_controllerSupport swipeDelegate:self];
|
[self->_streamView showOnScreenControls];
|
||||||
#endif
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user