From 0789a2f27e57cb8d97e4d18ad7341e875de5ea36 Mon Sep 17 00:00:00 2001 From: True Zhuanjia Date: Thu, 4 Jul 2024 01:04:00 +0800 Subject: [PATCH] native only & native touch mode --- Limelight/Base.lproj/iPad.storyboard | 3 +- Limelight/Database/TemporarySettings.h | 7 ++- Limelight/Input/ControllerSupport.m | 2 +- Limelight/Input/StreamView.m | 17 +++--- .../ViewControllers/SettingsViewController.m | 33 +++++----- .../StreamFrameViewController.m | 4 +- Limelight/mul.lproj/iPad.xcstrings | 60 +++++++++++-------- 7 files changed, 72 insertions(+), 54 deletions(-) diff --git a/Limelight/Base.lproj/iPad.storyboard b/Limelight/Base.lproj/iPad.storyboard index f1b2e39a..dc74fa01 100644 --- a/Limelight/Base.lproj/iPad.storyboard +++ b/Limelight/Base.lproj/iPad.storyboard @@ -134,7 +134,8 @@ - + + diff --git a/Limelight/Database/TemporarySettings.h b/Limelight/Database/TemporarySettings.h index 664a5232..8f3183d8 100644 --- a/Limelight/Database/TemporarySettings.h +++ b/Limelight/Database/TemporarySettings.h @@ -7,9 +7,10 @@ // #import "Settings+CoreDataClass.h" -#define RELATIVE_TOUCH_MODE 0 -#define NATIVE_TOUCH_MODE 1 -#define ABSOLUTE_TOUCH_MODE 2 +#define RELATIVE_TOUCH 0 +#define REGULAR_NATIVE_TOUCH 1 +#define PURE_NATIVE_TOUCH 2 +#define ABSOLUTE_TOUCH 3 @interface TemporarySettings : NSObject diff --git a/Limelight/Input/ControllerSupport.m b/Limelight/Input/ControllerSupport.m index 0b2a82ca..dad29d74 100644 --- a/Limelight/Input/ControllerSupport.m +++ b/Limelight/Input/ControllerSupport.m @@ -1061,7 +1061,7 @@ static const double MOUSE_SPEED_DIVISOR = 1.25; // Even if no gamepads are present, we will always count one if OSC is enabled, // or it's set to auto and no keyboard or mouse is present. Absolute touch mode // disables the OSC. - if (level != OnScreenControlsLevelOff && (![ControllerSupport hasKeyboardOrMouse] || level != OnScreenControlsLevelAuto) && (settings.touchMode.intValue == RELATIVE_TOUCH_MODE)) { + if (level != OnScreenControlsLevelOff && (![ControllerSupport hasKeyboardOrMouse] || level != OnScreenControlsLevelAuto) && (settings.touchMode.intValue == RELATIVE_TOUCH)) { mask |= 0x1; } diff --git a/Limelight/Input/StreamView.m b/Limelight/Input/StreamView.m index c18cd396..5fc389bf 100644 --- a/Limelight/Input/StreamView.m +++ b/Limelight/Input/StreamView.m @@ -97,14 +97,15 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5; switch (settings.touchMode.intValue) { - case NATIVE_TOUCH_MODE: + case PURE_NATIVE_TOUCH: + case REGULAR_NATIVE_TOUCH: self->touchHandler = [[NativeTouchHandler alloc] initWithView:self andSettings:settings];break; - case RELATIVE_TOUCH_MODE: + case RELATIVE_TOUCH: self->touchHandler = [[RelativeTouchHandler alloc] initWithView:self andSettings:settings]; keyboardToggleRecognizer.immediateTriggering = false; keyboardToggleRecognizer.numberOfTouchesRequired = 3; //fixing keyboard taps to 3, in order to invoke OSC rebase in stream view by 4-finger tap. break; - case ABSOLUTE_TOUCH_MODE: + case ABSOLUTE_TOUCH: self->touchHandler = [[AbsoluteTouchHandler alloc] initWithView:self]; keyboardToggleRecognizer.immediateTriggering = true; //triggers signal in touchesBegan callback stage break; @@ -115,7 +116,7 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5; onScreenControls = [[OnScreenControls alloc] initWithView:self controllerSup:controllerSupport streamConfig:streamConfig]; OnScreenControlsLevel level = (OnScreenControlsLevel)[settings.onscreenControls integerValue]; - if (settings.touchMode.intValue != RELATIVE_TOUCH_MODE) { + if (settings.touchMode.intValue != RELATIVE_TOUCH) { Log(LOG_I, @"On-screen controls disabled in non-relative touch mode"); [onScreenControls setLevel:OnScreenControlsLevelOff]; } @@ -436,7 +437,7 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5; - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { #if !TARGET_OS_TV if (@available(iOS 13.4, *)) { - if (settings.touchMode.intValue == NATIVE_TOUCH_MODE) { + if (settings.touchMode.intValue == PURE_NATIVE_TOUCH) { [touchHandler touchesBegan:touches withEvent:event]; return; //This is a native touch oriented fork, in native touch mode, this call back method deals with native touch only. } @@ -594,7 +595,7 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5; - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { #if !TARGET_OS_TV if (@available(iOS 13.4, *)) { - if (settings.touchMode.intValue == NATIVE_TOUCH_MODE) { + if (settings.touchMode.intValue == PURE_NATIVE_TOUCH) { [touchHandler touchesMoved:touches withEvent:event]; return; //This is a native touch oriented fork, in native touch mode, this call back method deals with native touch only. } @@ -674,7 +675,7 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5; - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { #if !TARGET_OS_TV if (@available(iOS 13.4, *)) { - if (settings.touchMode.intValue == NATIVE_TOUCH_MODE) { + if (settings.touchMode.intValue == PURE_NATIVE_TOUCH) { [touchHandler touchesEnded:touches withEvent:event]; return; //This is a native touch oriented fork, in native touch mode, this call back method deals with native touch only. } @@ -707,7 +708,7 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5; [touchHandler touchesCancelled:touches withEvent:event]; #if !TARGET_OS_TV if (@available(iOS 13.4, *)) { - if (settings.touchMode.intValue == NATIVE_TOUCH_MODE) return; //This is a native touch oriented fork, in native touch mode, this call back method deals with native touch only. + if (settings.touchMode.intValue == PURE_NATIVE_TOUCH) return; //This is a native touch oriented fork, in native touch mode, this call back method deals with native touch only. else{ for (UITouch* touch in touches) { if (touch.type == UITouchTypePencil) { diff --git a/Limelight/ViewControllers/SettingsViewController.m b/Limelight/ViewControllers/SettingsViewController.m index 38db0efe..0eb4dc55 100644 --- a/Limelight/ViewControllers/SettingsViewController.m +++ b/Limelight/ViewControllers/SettingsViewController.m @@ -282,7 +282,7 @@ BOOL isCustomResolution(CGSize res) { [self.framerateSelector setSelectedSegmentIndex:framerate]; [self.framerateSelector addTarget:self action:@selector(updateBitrate) forControlEvents:UIControlEventValueChanged]; [self.onscreenControlSelector setSelectedSegmentIndex:onscreenControls]; - [self.onscreenControlSelector setEnabled: currentSettings.touchMode.intValue == RELATIVE_TOUCH_MODE];//enable/disable controller UI widget for the first time. + [self.onscreenControlSelector setEnabled: currentSettings.touchMode.intValue == RELATIVE_TOUCH];//enable/disable controller UI widget for the first time. [self.bitrateSlider setMinimumValue:0]; [self.bitrateSlider setMaximumValue:(sizeof(bitrateTable) / sizeof(*bitrateTable)) - 1]; [self.bitrateSlider setValue:[self getSliderValueForBitrate:_bitrate] animated:YES]; @@ -291,8 +291,8 @@ BOOL isCustomResolution(CGSize res) { [self updateResolutionDisplayViewText]; //init keyboardToggle settings - if(currentSettings.touchMode.intValue == RELATIVE_TOUCH_MODE){ - [self widget:self.keyboardToggleFingerNumSlider setEnabled:[self.touchModeSelector selectedSegmentIndex] != RELATIVE_TOUCH_MODE]; + if(currentSettings.touchMode.intValue == RELATIVE_TOUCH){ + [self widget:self.keyboardToggleFingerNumSlider setEnabled:[self.touchModeSelector selectedSegmentIndex] != RELATIVE_TOUCH]; [self.keyboardToggleFingerNumSlider setValue:3.0]; //force 3 finger tap to toggle keyboard in relative touch mode. This is for the 4 finger OSC layout tool gesture. [self.keyboardToggleFingerNumLabel setText:[LocalizationHelper localizedStringForKey:@"To Toggle Local Keyboard: Tap %d Fingers", (uint16_t)self.keyboardToggleFingerNumSlider.value]]; } @@ -319,19 +319,19 @@ BOOL isCustomResolution(CGSize res) { [self.pointerVelocityModeDividerSlider setValue:currentSettings.pointerVelocityModeDivider.floatValue * 100 animated:YES]; // Load old setting. [self.pointerVelocityModeDividerUILabel setText:[LocalizationHelper localizedStringForKey:@"Touch Pointer Velocity: Scaled on %d%% of Right Screen", 100 - (uint8_t)self.pointerVelocityModeDividerSlider.value]]; // Initiate label display [self.pointerVelocityModeDividerSlider addTarget:self action:@selector(pointerVelocityModeDividerSliderMoved) forControlEvents:(UIControlEventValueChanged)]; // Update label display when slider is being moved. - [self widget:self.pointerVelocityModeDividerSlider setEnabled: currentSettings.touchMode.intValue == NATIVE_TOUCH_MODE]; // pointer velocity scaling works only in native touch mode. + [self widget:self.pointerVelocityModeDividerSlider setEnabled: currentSettings.touchMode.intValue == PURE_NATIVE_TOUCH || currentSettings.touchMode.intValue == REGULAR_NATIVE_TOUCH]; // pointer velocity scaling works only in native touch mode. // init pointer veloc setting [self.touchPointerVelocityFactorSlider setValue:currentSettings.touchPointerVelocityFactor.floatValue * 100 animated:YES]; // Load old setting. [self.touchPointerVelocityFactorUILabel setText:[LocalizationHelper localizedStringForKey: @"Touch Pointer Velocity: %d%%", (uint16_t)self.touchPointerVelocityFactorSlider.value]]; // Initiate label display [self.touchPointerVelocityFactorSlider addTarget:self action:@selector(touchPointerVelocityFactorSliderMoved) forControlEvents:(UIControlEventValueChanged)]; // Update label display when slider is being moved. - [self widget:self.touchPointerVelocityFactorSlider setEnabled: currentSettings.touchMode.intValue == NATIVE_TOUCH_MODE]; // pointer velocity scaling works only in native touch mode. + [self widget:self.touchPointerVelocityFactorSlider setEnabled: currentSettings.touchMode.intValue == PURE_NATIVE_TOUCH || currentSettings.touchMode.intValue == REGULAR_NATIVE_TOUCH]; // pointer velocity scaling works only in native touch mode. // init relative touch mouse pointer veloc setting [self.mousePointerVelocityFactorSlider setValue:currentSettings.mousePointerVelocityFactor.floatValue * 100 animated:YES]; // Load old setting. [self.mousePointerVelocityFactorUILabel setText:[LocalizationHelper localizedStringForKey: @"Mouse Pointer Velocity: %d%%", (uint16_t)self.mousePointerVelocityFactorSlider.value]]; // Initiate label display [self.mousePointerVelocityFactorSlider addTarget:self action:@selector(mousePointerVelocityFactorSliderMoved) forControlEvents:(UIControlEventValueChanged)]; // Update label display when slider is being moved. - [self widget:self.mousePointerVelocityFactorSlider setEnabled: currentSettings.touchMode.intValue == RELATIVE_TOUCH_MODE]; // mouse velocity scaling works only in relative touch mode. + [self widget:self.mousePointerVelocityFactorSlider setEnabled: currentSettings.touchMode.intValue == RELATIVE_TOUCH]; // mouse velocity scaling works only in relative touch mode. // init CustomOSC stuff @@ -348,7 +348,7 @@ BOOL isCustomResolution(CGSize res) { self.layoutOnScreenControlsVC = [storyboard instantiateViewControllerWithIdentifier:@"LayoutOnScreenControlsViewController"]; self.layoutOnScreenControlsVC.modalPresentationStyle = UIModalPresentationFullScreen; } - if(currentSettings.onscreenControls.intValue == OnScreenControlsCustom && currentSettings.touchMode.intValue == RELATIVE_TOUCH_MODE) { //load OSC slider UI Lable to remind user: + if(currentSettings.onscreenControls.intValue == OnScreenControlsCustom && currentSettings.touchMode.intValue == RELATIVE_TOUCH) { //load OSC slider UI Lable to remind user: [self.onscreenControllerLabel setText:[LocalizationHelper localizedStringForKey: @"Tap 4 Fingers to Change OSC Layout in Stream View"]]; //keyboard is force set to 3 finger to make this working. //if (self.layoutOnScreenControlsVC.isBeingPresented == NO) } @@ -387,7 +387,7 @@ BOOL isCustomResolution(CGSize res) { self.layoutOnScreenControlsVC.modalPresentationStyle = UIModalPresentationFullScreen; } - if([self.onscreenControlSelector selectedSegmentIndex] == OnScreenControlsCustom && [self.touchModeSelector selectedSegmentIndex] == RELATIVE_TOUCH_MODE) { + if([self.onscreenControlSelector selectedSegmentIndex] == OnScreenControlsCustom && [self.touchModeSelector selectedSegmentIndex] == RELATIVE_TOUCH) { [self.onscreenControllerLabel setText:[LocalizationHelper localizedStringForKey: @"Tap 4 Fingers to Change OSC Layout in Stream View"]]; [self showCustomOSCTip]; //if (self.layoutOnScreenControlsVC.isBeingPresented == NO) @@ -444,19 +444,22 @@ BOOL isCustomResolution(CGSize res) { - (void) touchModeChanged { // Disable on-screen controls in non-relative touch mode - [self.onscreenControlSelector setEnabled:[self.touchModeSelector selectedSegmentIndex] == RELATIVE_TOUCH_MODE]; - [self widget:self.pointerVelocityModeDividerSlider setEnabled:[self.touchModeSelector selectedSegmentIndex] == NATIVE_TOUCH_MODE]; // pointer velocity scaling works only in native touch mode. - [self widget:self.touchPointerVelocityFactorSlider setEnabled:[self.touchModeSelector selectedSegmentIndex] == NATIVE_TOUCH_MODE]; // pointer velocity scaling works only in native touch mode. - [self widget:self.mousePointerVelocityFactorSlider setEnabled:[self.touchModeSelector selectedSegmentIndex] == RELATIVE_TOUCH_MODE]; // mouse velocity scaling works only in relative touch mode. + bool isNative = [self.touchModeSelector selectedSegmentIndex] == PURE_NATIVE_TOUCH || [self.touchModeSelector selectedSegmentIndex] == REGULAR_NATIVE_TOUCH; + + [self.onscreenControlSelector setEnabled:[self.touchModeSelector selectedSegmentIndex] == RELATIVE_TOUCH]; + + [self widget:self.pointerVelocityModeDividerSlider setEnabled:isNative]; // pointer velocity scaling works only in native touch mode. + [self widget:self.touchPointerVelocityFactorSlider setEnabled:isNative]; // pointer velocity scaling works only in native touch mode. + [self widget:self.mousePointerVelocityFactorSlider setEnabled:[self.touchModeSelector selectedSegmentIndex] == RELATIVE_TOUCH]; // mouse velocity scaling works only in relative touch mode. // number of touches required to toggle keyboard in relative touch mode will be fixed to 3. - [self widget:self.keyboardToggleFingerNumSlider setEnabled:[self.touchModeSelector selectedSegmentIndex] != RELATIVE_TOUCH_MODE]; - if([self.touchModeSelector selectedSegmentIndex] == RELATIVE_TOUCH_MODE) { + [self widget:self.keyboardToggleFingerNumSlider setEnabled:[self.touchModeSelector selectedSegmentIndex] != RELATIVE_TOUCH]; + if([self.touchModeSelector selectedSegmentIndex] == RELATIVE_TOUCH) { [self.keyboardToggleFingerNumSlider setValue:3.0]; [self.keyboardToggleFingerNumLabel setText:[LocalizationHelper localizedStringForKey:@"To Toggle Local Keyboard: Tap %d Fingers", (uint16_t)self.keyboardToggleFingerNumSlider.value]]; } - if([self.onscreenControlSelector selectedSegmentIndex] == OnScreenControlsCustom && [self.touchModeSelector selectedSegmentIndex] == RELATIVE_TOUCH_MODE) { + if([self.onscreenControlSelector selectedSegmentIndex] == OnScreenControlsCustom && [self.touchModeSelector selectedSegmentIndex] == RELATIVE_TOUCH) { [self.onscreenControllerLabel setText:[LocalizationHelper localizedStringForKey: @"Tap 4 Fingers to Change OSC Layout in Stream View"]]; //if (self.layoutOnScreenControlsVC.isBeingPresented == NO) } diff --git a/Limelight/ViewControllers/StreamFrameViewController.m b/Limelight/ViewControllers/StreamFrameViewController.m index 59a9b818..22dd003b 100644 --- a/Limelight/ViewControllers/StreamFrameViewController.m +++ b/Limelight/ViewControllers/StreamFrameViewController.m @@ -144,7 +144,7 @@ [self.view addGestureRecognizer:_exitSwipeRecognizer]; - if(_settings.touchMode.intValue == RELATIVE_TOUCH_MODE && _settings.onscreenControls.intValue == OnScreenControlsCustom){ + if(_settings.touchMode.intValue == RELATIVE_TOUCH && _settings.onscreenControls.intValue == OnScreenControlsCustom){ _oscLayoutTapRecoginizer = [[CustomTapGestureRecognizer alloc] initWithTarget:self action:@selector(layoutOSC)]; _oscLayoutTapRecoginizer.numberOfTouchesRequired = 4; //tap 4 fingers to invoke OSC rebase _oscLayoutTapRecoginizer.tapDownTimeThreshold = 1; @@ -225,7 +225,7 @@ #endif // Only enable scroll and zoom in absolute touch mode - if (_settings.touchMode.intValue == ABSOLUTE_TOUCH_MODE) { + if (_settings.touchMode.intValue == ABSOLUTE_TOUCH) { _scrollView = [[UIScrollView alloc] initWithFrame:self.view.frame]; #if !TARGET_OS_TV [_scrollView.panGestureRecognizer setMinimumNumberOfTouches:2]; diff --git a/Limelight/mul.lproj/iPad.xcstrings b/Limelight/mul.lproj/iPad.xcstrings index bb028e4b..cf60166f 100644 --- a/Limelight/mul.lproj/iPad.xcstrings +++ b/Limelight/mul.lproj/iPad.xcstrings @@ -626,37 +626,67 @@ } }, "e4G-id-vjI.segmentTitles[1]" : { - "comment" : "Class = \"UISegmentedControl\"; e4G-id-vjI.segmentTitles[1] = \"Native Multi-Touch\"; ObjectID = \"e4G-id-vjI\";", + "comment" : "Class = \"UISegmentedControl\"; e4G-id-vjI.segmentTitles[1] = \"Native Touch\"; ObjectID = \"e4G-id-vjI\";", "extractionState" : "extracted_with_value", "localizations" : { "en" : { "stringUnit" : { "state" : "new", - "value" : "Native Multi-Touch" + "value" : "Native Touch" } }, "zh-Hans" : { "stringUnit" : { - "state" : "translated", + "state" : "needs_review", "value" : "原生多点触控" } }, "zh-Hant" : { "stringUnit" : { - "state" : "translated", + "state" : "needs_review", "value" : "原生多点触控" } }, "zh-HK" : { "stringUnit" : { - "state" : "translated", + "state" : "needs_review", "value" : "原生多点触控" } } } }, "e4G-id-vjI.segmentTitles[2]" : { - "comment" : "Class = \"UISegmentedControl\"; e4G-id-vjI.segmentTitles[2] = \"Absolute Touch\"; ObjectID = \"e4G-id-vjI\";", + "comment" : "Class = \"UISegmentedControl\"; e4G-id-vjI.segmentTitles[2] = \"Native Only\"; ObjectID = \"e4G-id-vjI\";", + "extractionState" : "extracted_with_value", + "localizations" : { + "en" : { + "stringUnit" : { + "state" : "new", + "value" : "Native Only" + } + }, + "zh-Hans" : { + "stringUnit" : { + "state" : "needs_review", + "value" : "鼠标模式" + } + }, + "zh-Hant" : { + "stringUnit" : { + "state" : "needs_review", + "value" : "鼠标模式" + } + }, + "zh-HK" : { + "stringUnit" : { + "state" : "needs_review", + "value" : "鼠标模式" + } + } + } + }, + "e4G-id-vjI.segmentTitles[3]" : { + "comment" : "Class = \"UISegmentedControl\"; e4G-id-vjI.segmentTitles[3] = \"Absolute Touch\"; ObjectID = \"e4G-id-vjI\";", "extractionState" : "extracted_with_value", "localizations" : { "en" : { @@ -664,24 +694,6 @@ "state" : "new", "value" : "Absolute Touch" } - }, - "zh-Hans" : { - "stringUnit" : { - "state" : "translated", - "value" : "鼠标模式" - } - }, - "zh-Hant" : { - "stringUnit" : { - "state" : "translated", - "value" : "鼠标模式" - } - }, - "zh-HK" : { - "stringUnit" : { - "state" : "translated", - "value" : "鼠标模式" - } } } },