From d64c746dab15489f63849577b0f181e5c993b3e8 Mon Sep 17 00:00:00 2001 From: True Zhuanjia Date: Sun, 26 May 2024 14:08:00 +0800 Subject: [PATCH] add menu entries for streamview lift & keyboard toolbar --- Limelight/Database/DataManager.h | 2 + Limelight/Database/DataManager.m | 4 + Limelight/Database/TemporarySettings.h | 3 + Limelight/Database/TemporarySettings.m | 2 + Limelight/Input/StreamView.m | 36 +++-- .../Moonlight v1.10.xcdatamodel/contents | 2 + .../ViewControllers/SettingsViewController.h | 2 + .../ViewControllers/SettingsViewController.m | 7 +- iPad.storyboard | 87 ++++++++---- iPhone.storyboard | 132 +++++++++++------- 10 files changed, 189 insertions(+), 88 deletions(-) diff --git a/Limelight/Database/DataManager.h b/Limelight/Database/DataManager.h index 03be812d..0a9e0bc7 100644 --- a/Limelight/Database/DataManager.h +++ b/Limelight/Database/DataManager.h @@ -22,6 +22,8 @@ keyboardToggleFingers:(NSInteger)keyboardToggleFingers swipeExitScreenEdge:(NSInteger)swipeExitScreenEdge swipeToExitDistance:(CGFloat)swipeToExitDistance + liftStreamViewForKeyboard:(BOOL)liftStreamViewForKeyboard + showKeyboardToolbar:(BOOL)showKeyboardToolbar optimizeGames:(BOOL)optimizeGames multiController:(BOOL)multiController swapABXYButtons:(BOOL)swapABXYButtons diff --git a/Limelight/Database/DataManager.m b/Limelight/Database/DataManager.m index 32df7b84..608fe3f5 100644 --- a/Limelight/Database/DataManager.m +++ b/Limelight/Database/DataManager.m @@ -61,6 +61,8 @@ keyboardToggleFingers:(NSInteger)keyboardToggleFingers swipeExitScreenEdge:(NSInteger)swipeExitScreenEdge swipeToExitDistance:(CGFloat)swipeToExitDistance + liftStreamViewForKeyboard:(BOOL)liftStreamViewForKeyboard + showKeyboardToolbar:(BOOL)showKeyboardToolbar optimizeGames:(BOOL)optimizeGames multiController:(BOOL)multiController swapABXYButtons:(BOOL)swapABXYButtons @@ -83,6 +85,8 @@ settingsToSave.keyboardToggleFingers = [NSNumber numberWithInteger:(uint16_t)keyboardToggleFingers]; settingsToSave.swipeExitScreenEdge = [NSNumber numberWithInteger:(uint32_t)swipeExitScreenEdge]; settingsToSave.swipeToExitDistance = [NSNumber numberWithFloat:swipeToExitDistance]; + settingsToSave.liftStreamViewForKeyboard = liftStreamViewForKeyboard; + settingsToSave.showKeyboardToolbar = showKeyboardToolbar; settingsToSave.optimizeGames = optimizeGames; settingsToSave.multiController = multiController; settingsToSave.swapABXYButtons = swapABXYButtons; diff --git a/Limelight/Database/TemporarySettings.h b/Limelight/Database/TemporarySettings.h index a5aa7459..13cf6bad 100644 --- a/Limelight/Database/TemporarySettings.h +++ b/Limelight/Database/TemporarySettings.h @@ -37,6 +37,9 @@ @property (nonatomic) BOOL btMouseSupport; @property (nonatomic) BOOL absoluteTouchMode; @property (nonatomic) BOOL statsOverlay; +@property (nonatomic) BOOL liftStreamViewForKeyboard; +@property (nonatomic) BOOL showKeyboardToolbar; + - (id) initFromSettings:(Settings*)settings; diff --git a/Limelight/Database/TemporarySettings.m b/Limelight/Database/TemporarySettings.m index 1ed58632..d8cd6288 100644 --- a/Limelight/Database/TemporarySettings.m +++ b/Limelight/Database/TemporarySettings.m @@ -88,6 +88,8 @@ self.keyboardToggleFingers = settings.keyboardToggleFingers; self.swipeExitScreenEdge = settings.swipeExitScreenEdge; self.swipeToExitDistance = settings.swipeToExitDistance; + self.liftStreamViewForKeyboard = settings.liftStreamViewForKeyboard; + self.showKeyboardToolbar = settings.showKeyboardToolbar; #endif self.uniqueId = settings.uniqueId; diff --git a/Limelight/Input/StreamView.m b/Limelight/Input/StreamView.m index 8f2484cc..2d1e2228 100644 --- a/Limelight/Input/StreamView.m +++ b/Limelight/Input/StreamView.m @@ -21,6 +21,8 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5; @implementation StreamView { + TemporarySettings* settings; + OnScreenControls* onScreenControls; KeyboardInputField* keyInputField; @@ -61,7 +63,7 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5; self->interactionDelegate = interactionDelegate; self->streamAspectRatio = (float)streamConfig.width / (float)streamConfig.height; - TemporarySettings* settings = [[[DataManager alloc] init] getSettings]; + settings = [[[DataManager alloc] init] getSettings]; keysDown = [[NSMutableSet alloc] init]; keyInputField = [[KeyboardInputField alloc] initWithFrame:CGRectZero]; @@ -155,25 +157,31 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5; - (void)keyboardWillShow:(NSNotification *)notification{ - NSDictionary *userInfo = notification.userInfo; - // Get the keyboard size from the notification - CGRect keyboardFrame = [userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue]; - liftViewToHeight = keyboardFrame.size.height - keyboardToggleRecognizer.lowestTouchPointHeight + CGRectGetHeight([[UIScreen mainScreen] bounds]) * 0.1; // lift the StreamView to the height of lowest touch point of multi-finger tap gesture, while reserving the view of 1/10 screen height for remote typing. - if(liftViewToHeight < 0) liftViewToHeight = 0; // set liftViewtoHeight to 0 if it is high enough and not going to be covered by keyboard. + if(settings.liftStreamViewForKeyboard){ + NSDictionary *userInfo = notification.userInfo; + // Get the keyboard size from the notification + CGRect keyboardFrame = [userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue]; + liftViewToHeight = keyboardFrame.size.height - keyboardToggleRecognizer.lowestTouchPointHeight + CGRectGetHeight([[UIScreen mainScreen] bounds]) * 0.1; // lift the StreamView to the height of lowest touch point of multi-finger tap gesture, while reserving the view of 1/10 screen height for remote typing. + if(liftViewToHeight < 0) liftViewToHeight = 0; // set liftViewtoHeight to 0 if it is high enough and not going to be covered by keyboard. + CGRect liftedStreamFrame = self.frame; + liftedStreamFrame.origin.y -= liftViewToHeight; + self.frame = liftedStreamFrame; + } - CGRect liftedStreamFrame = self.frame; - liftedStreamFrame.origin.y -= liftViewToHeight; - self.frame = liftedStreamFrame; isInputingText = true; // NSLog(@"keyboard will show"); } - (void)keyboardWillHide:(NSNotification *)notification{ - CGRect liftedStreamFrame = self.frame; - // recover view position in keyboard hiding. - liftedStreamFrame.origin.y += liftViewToHeight; - self.frame = liftedStreamFrame; + + if(settings.liftStreamViewForKeyboard){ + CGRect liftedStreamFrame = self.frame; + // recover view position in keyboard hiding. + liftedStreamFrame.origin.y += liftViewToHeight; + self.frame = liftedStreamFrame; + } + isInputingText = false; // NSLog(@"keyboard will hide"); } @@ -194,7 +202,7 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5; keyInputField.text = @"0"; #if !TARGET_OS_TV // Prepare the toolbar above the keyboard for more options - if(false){ + if(settings.showKeyboardToolbar){ UIToolbar *customToolbarView = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, self.bounds.size.width, 44)]; UIBarButtonItem *doneBarButton = [self createButtonWithImageNamed:@"DoneIcon.png" backgroundColor:[UIColor clearColor] target:self action:@selector(toolbarButtonClicked:) keyCode:0x00 isToggleable:NO]; UIBarButtonItem *windowsBarButton = [self createButtonWithImageNamed:@"WindowsIcon.png" backgroundColor:[UIColor blackColor] target:self action:@selector(toolbarButtonClicked:) keyCode:0x5B isToggleable:YES]; diff --git a/Limelight/Limelight.xcdatamodeld/Moonlight v1.10.xcdatamodel/contents b/Limelight/Limelight.xcdatamodeld/Moonlight v1.10.xcdatamodel/contents index 9d689e69..57bd8c42 100644 --- a/Limelight/Limelight.xcdatamodeld/Moonlight v1.10.xcdatamodel/contents +++ b/Limelight/Limelight.xcdatamodeld/Moonlight v1.10.xcdatamodel/contents @@ -30,11 +30,13 @@ + + diff --git a/Limelight/ViewControllers/SettingsViewController.h b/Limelight/ViewControllers/SettingsViewController.h index 944d2e94..ebc521b3 100644 --- a/Limelight/ViewControllers/SettingsViewController.h +++ b/Limelight/ViewControllers/SettingsViewController.h @@ -29,6 +29,8 @@ @property (strong, nonatomic) IBOutlet UIScrollView *scrollView; @property (strong, nonatomic) IBOutlet UILabel *keyboardToggleFingerNumLabel; @property (strong, nonatomic) IBOutlet UISlider *keyboardToggleFingerNumSlider; +@property (strong, nonatomic) IBOutlet UISegmentedControl *liftStreamViewForKeyboardSelector; +@property (strong, nonatomic) IBOutlet UISegmentedControl *showKeyboardToolbarSelector; @property (strong, nonatomic) IBOutlet UISegmentedControl *swipeExitScreenEdgeSelector; @property (strong, nonatomic) IBOutlet UILabel *swipeToExitDistanceUILabel; @property (strong, nonatomic) IBOutlet UISlider *swipeToExitDistanceSlider; diff --git a/Limelight/ViewControllers/SettingsViewController.m b/Limelight/ViewControllers/SettingsViewController.m index 686359d0..fdc71155 100644 --- a/Limelight/ViewControllers/SettingsViewController.m +++ b/Limelight/ViewControllers/SettingsViewController.m @@ -269,7 +269,8 @@ BOOL isCustomResolution(CGSize res) { if (self.keyboardToggleFingerNumSlider.value > 10.5f) [self.keyboardToggleFingerNumLabel setText:[NSString stringWithFormat:@"Tap-Toggle Local Keyboard Disabled"]]; // Initiate label display. Allow higher required finger number to completely disable keyboard toggle else [self.keyboardToggleFingerNumLabel setText:[NSString stringWithFormat:@"Fingers to Tap-Toggle Local Keyboard: %d", (uint16_t)self.keyboardToggleFingerNumSlider.value]]; // Initiate label display [self.keyboardToggleFingerNumSlider addTarget:self action:@selector(keyboardToggleFingerNumSliderMoved) forControlEvents:(UIControlEventValueChanged)]; // Update label display when slider is being moved. - + [self.liftStreamViewForKeyboardSelector setSelectedSegmentIndex:currentSettings.liftStreamViewForKeyboard ? 1 : 0];// Load old setting + [self.showKeyboardToolbarSelector setSelectedSegmentIndex:currentSettings.showKeyboardToolbar ? 1 : 0];// Load old setting [self.swipeExitScreenEdgeSelector setSelectedSegmentIndex:[self getSelectorIndexFromScreenEdge:(uint32_t)currentSettings.swipeExitScreenEdge.integerValue]]; // Load old setting [self.swipeToExitDistanceSlider setValue:(CGFloat)currentSettings.swipeToExitDistance.floatValue animated:YES]; // Load old setting. [self.swipeToExitDistanceUILabel setText:[NSString stringWithFormat:@"Swipe & Exit Distance: %.2f * screen-width", self.swipeToExitDistanceSlider.value]]; // Initiate label display @@ -572,6 +573,8 @@ BOOL isCustomResolution(CGSize res) { // NSLog(@"saveSettings keyboardToggleFingers %d", (uint16_t)keyboardToggleFingers); CGFloat swipeToExitDistance = self.swipeToExitDistanceSlider.value; uint32_t swipeExitScreenEdge = [self getScreenEdgeFromSelector]; + BOOL liftStreamViewForKeyboard = [self.liftStreamViewForKeyboardSelector selectedSegmentIndex] == 1; + BOOL showKeyboardToolbar = [self.showKeyboardToolbarSelector selectedSegmentIndex] == 1; BOOL optimizeGames = [self.optimizeSettingsSelector selectedSegmentIndex] == 1; BOOL multiController = [self.multiControllerSelector selectedSegmentIndex] == 1; BOOL swapABXYButtons = [self.swapABXYButtonsSelector selectedSegmentIndex] == 1; @@ -591,6 +594,8 @@ BOOL isCustomResolution(CGSize res) { keyboardToggleFingers:keyboardToggleFingers swipeExitScreenEdge:swipeExitScreenEdge swipeToExitDistance:swipeToExitDistance + liftStreamViewForKeyboard:liftStreamViewForKeyboard + showKeyboardToolbar:showKeyboardToolbar optimizeGames:optimizeGames multiController:multiController swapABXYButtons:swapABXYButtons diff --git a/iPad.storyboard b/iPad.storyboard index 7c806a9b..c74e6901 100644 --- a/iPad.storyboard +++ b/iPad.storyboard @@ -59,7 +59,7 @@ - + - + @@ -110,7 +110,7 @@ - + @@ -179,14 +179,14 @@ - + @@ -196,14 +196,14 @@ - + @@ -213,21 +213,21 @@ - + @@ -237,14 +237,14 @@ - + @@ -256,14 +256,14 @@ - + @@ -273,14 +273,14 @@ - + @@ -290,14 +290,14 @@ - + @@ -307,14 +307,14 @@ - + @@ -324,7 +324,41 @@ - + + + + + + + + + + + + + + + + + + + + + + + @@ -347,12 +381,12 @@ - + + @@ -373,15 +408,17 @@ + + - + diff --git a/iPhone.storyboard b/iPhone.storyboard index bd9de16d..a0c9bbfb 100644 --- a/iPhone.storyboard +++ b/iPhone.storyboard @@ -93,7 +93,7 @@ - + @@ -160,25 +160,6 @@ - - - - - - - - - - - -