fixed: broken touch input caused by Absolute Touch

This commit is contained in:
TrueZhuanjia
2025-09-11 23:14:58 +08:00
parent c094d74d8e
commit daa4fc80eb
3 changed files with 16 additions and 6 deletions
@@ -25,6 +25,7 @@
@property (nonatomic, strong) IBOutlet UIBarButtonItem *settingsButton;
#if !TARGET_OS_TV
@property (nonatomic, assign) bool settingsExpandedInStreamView;
@property (nonatomic, assign) bool sessionLaunchedWithAbsoluteTouch;
@property (nonatomic, strong) HostCollectionViewController *hostCollectionVC;
@property (weak, nonatomic) IBOutlet UINavigationItem *navigationItem;
@@ -1181,6 +1181,7 @@ static NSMutableSet* hostList;
// [settingsViewController widget:settingsViewController.bitrateSlider setEnabled:!self.settingsExpandedInStreamView];
[settingsViewController setHidden:_settingsExpandedInStreamView forStack:settingsViewController.optimizeGamesStack];
[settingsViewController setHidden:_settingsExpandedInStreamView forStack:settingsViewController.audioOnPcStack];
[settingsViewController.touchModeSelector setEnabled:!_settingsExpandedInStreamView || !_sessionLaunchedWithAbsoluteTouch];
[settingsViewController.codecSelector setEnabled:!_settingsExpandedInStreamView];
[settingsViewController.yuv444Switch setEnabled:!_settingsExpandedInStreamView];
[settingsViewController.hdrSwitch setEnabled:!_settingsExpandedInStreamView && [settingsViewController hdrSupported]];
@@ -308,7 +308,7 @@
- (void)configZoomGestureAndAddStreamView{
if (_settings.touchMode.intValue == AbsoluteTouch) {
_scrollView = [[UIScrollView alloc] initWithFrame:self.view.frame];
if(!_scrollView) _scrollView = [[UIScrollView alloc] initWithFrame:self.view.frame];
#if !TARGET_OS_TV
[_scrollView.panGestureRecognizer setMinimumNumberOfTouches:2];
[_scrollView.panGestureRecognizer setMaximumNumberOfTouches:2]; // reduce competing with keyboardToggleRecognizer in StreamView.
@@ -317,15 +317,21 @@
[_scrollView setShowsVerticalScrollIndicator:NO];
[_scrollView setDelegate:self];
[_scrollView setMaximumZoomScale:10.0f];
// Add StreamView inside a UIScrollView for absolute mode
[_scrollView addSubview:_streamView];
// Insert at index 0 to ensure it doesn't cover OSC controls (CALayers)
[self.view insertSubview:_scrollView atIndex:0];
if(!_mainFrameViewcontroller.settingsExpandedInStreamView){
// Add StreamView inside a UIScrollView for absolute mode
[_scrollView addSubview:_streamView];
// Insert at index 0 to ensure it doesn't cover OSC controls (CALayers)
[self.view insertSubview:_scrollView atIndex:0];
}
}
else{
// Add streamView directly to self.view in other touch modes
// Insert at index 0 to ensure it doesn't cover OSC controls (CALayers)
if([_streamView.superview isKindOfClass:[UIScrollView class]]){
[_streamView removeFromSuperview];
NSLog(@"removeFromSuperview %f", CACurrentMediaTime());
}
[self.view insertSubview:_streamView atIndex:0];
}
}
@@ -728,6 +734,8 @@
[self.view insertSubview:self.metalViewController.view atIndex:0];
[self.metalViewController didMoveToParentViewController:self];
}
_mainFrameViewcontroller.sessionLaunchedWithAbsoluteTouch = _settings.touchMode.intValue == AbsoluteTouch;
}
- (void)keyboardWillShow:(NSNotification *)notification{