- optimize _areVirtualControllerTap mechanism, fix onscreen game controller button stuck

- change keyboard toggle gesture finger number logic
This commit is contained in:
True Zhuanjia committed 2024-08-15 09:34:43 +08:00
1 parent 9618b7bb94
commit 9ff10135a8
8 files changed
+105 -45

No files matched your search

+1
View File
@@ -11,6 +11,7 @@
#define REGULAR_NATIVE_TOUCH 1 #define REGULAR_NATIVE_TOUCH 1
#define PURE_NATIVE_TOUCH 2 #define PURE_NATIVE_TOUCH 2
#define ABSOLUTE_TOUCH 3 #define ABSOLUTE_TOUCH 3
#define OSC_TOOL_FINGERS 5
@interface TemporarySettings : NSObject @interface TemporarySettings : NSObject
+1 -1
View File
@@ -14,10 +14,10 @@
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
@interface RelativeTouchHandler : UIResponder @interface RelativeTouchHandler : UIResponder
@property (nonatomic, readonly) CustomTapGestureRecognizer* mouseRightClickTapRecognizer; // this object will be passed to onscreencontrol class for areVirtualControllerTaps flag setting
- (id)initWithView:(StreamView*)view andSettings:(TemporarySettings*)settings; - (id)initWithView:(StreamView*)view andSettings:(TemporarySettings*)settings;
- (CustomTapGestureRecognizer* )getMouseRightClickTapRecognizer; // rightClickTapRec must be created from relativeTouchHandler,since there's a attr must be accessed directly from recognizer, and it's also a relative touch specific recognizer.
@end @end
+17 -9
View File
@@ -15,6 +15,7 @@
static const int REFERENCE_WIDTH = 1280; static const int REFERENCE_WIDTH = 1280;
static const int REFERENCE_HEIGHT = 720; static const int REFERENCE_HEIGHT = 720;
//static CustomTapGestureRecognizer* mouseRightClickTapRecognizer;
@implementation RelativeTouchHandler { @implementation RelativeTouchHandler {
TemporarySettings* currentSettings; TemporarySettings* currentSettings;
@@ -30,20 +31,13 @@ static const int REFERENCE_HEIGHT = 720;
#endif #endif
UIView* view; UIView* view;
CustomTapGestureRecognizer* mouseRightClickTapRecognizer;
} }
- (id)initWithView:(StreamView*)view andSettings:(TemporarySettings*)settings { - (id)initWithView:(StreamView*)view andSettings:(TemporarySettings*)settings {
self = [self init]; self = [self init];
self->view = view; self->view = view;
self->currentSettings = settings; self->currentSettings = settings;
// replace righclick recoginizing with my CustomTapGestureRecognizer for better experience, higher recoginizing rate.
_mouseRightClickTapRecognizer = [[CustomTapGestureRecognizer alloc] initWithTarget:self action:@selector(mouseRightClick)];
_mouseRightClickTapRecognizer.numberOfTouchesRequired = 2;
_mouseRightClickTapRecognizer.tapDownTimeThreshold = RIGHTCLICK_TAP_DOWN_TIME_THRESHOLD_S; // tap down time in seconds.
_mouseRightClickTapRecognizer.delaysTouchesBegan = NO;
_mouseRightClickTapRecognizer.delaysTouchesEnded = NO;
[self->view addGestureRecognizer:_mouseRightClickTapRecognizer];
#if TARGET_OS_TV #if TARGET_OS_TV
@@ -60,6 +54,20 @@ static const int REFERENCE_HEIGHT = 720;
return self; return self;
} }
// rightClickTapRec must be created from relativeTouchHandler,since there's a attr must be accessed directly from recognizer, and it's also a relative touch specific recognizer, having a right click selector in this touch handler class.
- (CustomTapGestureRecognizer* )getMouseRightClickTapRecognizer{
// replace righclick recoginizing with my CustomTapGestureRecognizer for better experience, higher recoginizing rate.
mouseRightClickTapRecognizer = [[CustomTapGestureRecognizer alloc] initWithTarget:self action:@selector(mouseRightClick)];
mouseRightClickTapRecognizer.numberOfTouchesRequired = 2;
mouseRightClickTapRecognizer.tapDownTimeThreshold = RIGHTCLICK_TAP_DOWN_TIME_THRESHOLD_S; // tap down time in seconds.
mouseRightClickTapRecognizer.delaysTouchesBegan = NO;
mouseRightClickTapRecognizer.delaysTouchesEnded = NO;
// [self->view addGestureRecognizer:mouseRightClickTapRecognizer]; //this recognizer will be added & removed by streamframeviewcontroller, instead of here by the touchHouandler.
return mouseRightClickTapRecognizer; // make sure callers outside the class get the same recognizer as the one created within the current class.
}
- (void)mouseRightClick { - (void)mouseRightClick {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
Log(LOG_D, @"Sending right mouse button press"); Log(LOG_D, @"Sending right mouse button press");
@@ -132,7 +140,7 @@ static const int REFERENCE_HEIGHT = 720;
CGPoint secondLocation = [[[[event allTouches] allObjects] objectAtIndex:1] locationInView:view]; CGPoint secondLocation = [[[[event allTouches] allObjects] objectAtIndex:1] locationInView:view];
CGPoint avgLocation = CGPointMake((firstLocation.x + secondLocation.x) / 2, (firstLocation.y + secondLocation.y) / 2); CGPoint avgLocation = CGPointMake((firstLocation.x + secondLocation.x) / 2, (firstLocation.y + secondLocation.y) / 2);
if ((CACurrentMediaTime() - _mouseRightClickTapRecognizer.gestureCapturedTime > RIGHTCLICK_TAP_DOWN_TIME_THRESHOLD_S) && touchLocation.y != avgLocation.y) { //prevent sending scrollevent while right click gesture is being recognized. The time threshold is only 150ms, resulting in a barely noticeable delay before the scroll event is activated. if ((CACurrentMediaTime() - mouseRightClickTapRecognizer.gestureCapturedTime > RIGHTCLICK_TAP_DOWN_TIME_THRESHOLD_S) && touchLocation.y != avgLocation.y) { //prevent sending scrollevent while right click gesture is being recognized. The time threshold is only 150ms, resulting in a barely noticeable delay before the scroll event is activated.
LiSendHighResScrollEvent((avgLocation.y - touchLocation.y) * 10); LiSendHighResScrollEvent((avgLocation.y - touchLocation.y) * 10);
} }
+2
View File
@@ -39,6 +39,8 @@
- (uint16_t)getRotationFromAzimuthAngle:(float)azimuthAngle; - (uint16_t)getRotationFromAzimuthAngle:(float)azimuthAngle;
- (OnScreenControlsLevel) getCurrentOscState; - (OnScreenControlsLevel) getCurrentOscState;
- (UIResponder* )getTouchHandler;
- (OnScreenControls* )getOnScreenControlsObj;
#if !TARGET_OS_TV #if !TARGET_OS_TV
- (void) updateCursorLocation:(CGPoint)location isMouse:(BOOL)isMouse; - (void) updateCursorLocation:(CGPoint)location isMouse:(BOOL)isMouse;
+15 -7
View File
@@ -79,6 +79,8 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
[self removeGestureRecognizer:keyboardToggleRecognizer]; // for reconfig streamview in realtime [self removeGestureRecognizer:keyboardToggleRecognizer]; // for reconfig streamview in realtime
isInputingText = false; isInputingText = false;
//keyboardToggleRecognizer is one of the only recognizers defined within the stream view class
keyboardToggleRecognizer = [[CustomTapGestureRecognizer alloc] initWithTarget:self action:@selector(toggleKeyboard)]; keyboardToggleRecognizer = [[CustomTapGestureRecognizer alloc] initWithTarget:self action:@selector(toggleKeyboard)];
keyboardToggleRecognizer.numberOfTouchesRequired = settings.keyboardToggleFingers.intValue; //will be changed accordinly by touch modes. keyboardToggleRecognizer.numberOfTouchesRequired = settings.keyboardToggleFingers.intValue; //will be changed accordinly by touch modes.
keyboardToggleRecognizer.tapDownTimeThreshold = 0.3; // tap down time threshold in seconds. keyboardToggleRecognizer.tapDownTimeThreshold = 0.3; // tap down time threshold in seconds.
@@ -105,14 +107,14 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
switch (settings.touchMode.intValue) { switch (settings.touchMode.intValue) {
case REGULAR_NATIVE_TOUCH: case REGULAR_NATIVE_TOUCH:
keyboardToggleRecognizer.immediateTriggering = false; keyboardToggleRecognizer.immediateTriggering = false;
if(settings.onscreenControls.intValue == OnScreenControlsLevelCustom) keyboardToggleRecognizer.numberOfTouchesRequired = 3; //fixing keyboard taps to 3, in order to invoke OSC rebase in stream view by 4-finger tap. //if(settings.onscreenControls.intValue == OnScreenControlsLevelCustom) keyboardToggleRecognizer.numberOfTouchesRequired = 3; //decprecated: fixing keyboard taps to 3, in order to invoke OSC rebase in stream view by 4-finger tap.
case PURE_NATIVE_TOUCH: case PURE_NATIVE_TOUCH:
self->touchHandler = [[NativeTouchHandler alloc] initWithView:self andSettings:settings];break; self->touchHandler = [[NativeTouchHandler alloc] initWithView:self andSettings:settings];break;
case RELATIVE_TOUCH: case RELATIVE_TOUCH:
self->touchHandler = [[RelativeTouchHandler alloc] initWithView:self andSettings:settings]; self->touchHandler = [[RelativeTouchHandler alloc] initWithView:self andSettings:settings];
keyboardToggleRecognizer.immediateTriggering = false; keyboardToggleRecognizer.immediateTriggering = false;
if(settings.onscreenControls.intValue == OnScreenControlsLevelCustom) keyboardToggleRecognizer.numberOfTouchesRequired = 3; //fixing keyboard taps to 3, in order to invoke OSC rebase in stream view by 4-finger tap. //if(settings.onscreenControls.intValue == OnScreenControlsLevelCustom) keyboardToggleRecognizer.numberOfTouchesRequired = 3; //deprecated: fixing keyboard taps to 3, in order to invoke OSC rebase in stream view by 4-finger tap.
break; break;
case ABSOLUTE_TOUCH: case ABSOLUTE_TOUCH:
self->touchHandler = [[AbsoluteTouchHandler alloc] initWithView:self]; self->touchHandler = [[AbsoluteTouchHandler alloc] initWithView:self];
@@ -124,11 +126,6 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
} }
onScreenControls = [[OnScreenControls alloc] initWithView:self controllerSup:controllerSupport streamConfig:streamConfig]; onScreenControls = [[OnScreenControls alloc] initWithView:self controllerSup:controllerSupport streamConfig:streamConfig];
// here we pass the tap recognizer to the onscreencontrols obj
if (settings.touchMode.intValue == RELATIVE_TOUCH){
RelativeTouchHandler* relativeTouchHandler = (RelativeTouchHandler*) touchHandler;
onScreenControls.mouseRightClickTapRecognizer = relativeTouchHandler.mouseRightClickTapRecognizer;
}
OnScreenControlsLevel level = (OnScreenControlsLevel)[settings.onscreenControls integerValue]; OnScreenControlsLevel level = (OnScreenControlsLevel)[settings.onscreenControls integerValue];
if (settings.touchMode.intValue != RELATIVE_TOUCH && settings.touchMode.intValue != REGULAR_NATIVE_TOUCH ) { if (settings.touchMode.intValue != RELATIVE_TOUCH && settings.touchMode.intValue != REGULAR_NATIVE_TOUCH ) {
@@ -187,6 +184,15 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
[self becomeFirstResponder]; [self becomeFirstResponder];
} }
- (UIResponder* )getTouchHandler{
return self->touchHandler;
}
- (OnScreenControls* )getOnScreenControlsObj{
return self->onScreenControls;
}
// this method also deals with lifting streamview for local keyboard // this method also deals with lifting streamview for local keyboard
- (void)keyboardWillShow:(NSNotification *)notification{ - (void)keyboardWillShow:(NSNotification *)notification{
if(settings.liftStreamViewForKeyboard && !isInputingText){ if(settings.liftStreamViewForKeyboard && !isInputingText){
@@ -205,6 +211,8 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
// NSLog(@"keyboard will show"); // NSLog(@"keyboard will show");
} }
// this method also deals with recovering streamview when local keyboard is turned off // this method also deals with recovering streamview when local keyboard is turned off
- (void)keyboardWillHide:(NSNotification *)notification{ - (void)keyboardWillHide:(NSNotification *)notification{
+8 -8
View File
@@ -2119,48 +2119,48 @@
} }
} }
}, },
"Tap 4 fingers to change on-screen controller layout in stream view" : { "Tap 5 fingers to change on-screen controller layout in stream view" : {
"extractionState" : "manual", "extractionState" : "manual",
"localizations" : { "localizations" : {
"zh-Hans" : { "zh-Hans" : {
"stringUnit" : { "stringUnit" : {
"state" : "translated", "state" : "translated",
"value" : "在串流视图中轻按4根手指修改虚拟手柄布局" "value" : "在串流视图中轻按5根手指修改虚拟手柄布局"
} }
}, },
"zh-Hant" : { "zh-Hant" : {
"stringUnit" : { "stringUnit" : {
"state" : "translated", "state" : "translated",
"value" : "在串流视图中轻按4根手指修改虚拟手柄布局" "value" : "在串流视图中轻按5根手指修改虚拟手柄布局"
} }
}, },
"zh-HK" : { "zh-HK" : {
"stringUnit" : { "stringUnit" : {
"state" : "translated", "state" : "translated",
"value" : "在串流视图中轻按4根手指修改虚拟手柄布局" "value" : "在串流视图中轻按5根手指修改虚拟手柄布局"
} }
} }
} }
}, },
"Tap 4 Fingers to Change OSC Layout in Stream View" : { "Tap 5 Fingers to Change OSC Layout in Stream View" : {
"extractionState" : "manual", "extractionState" : "manual",
"localizations" : { "localizations" : {
"zh-Hans" : { "zh-Hans" : {
"stringUnit" : { "stringUnit" : {
"state" : "translated", "state" : "translated",
"value" : "在串流视图中轻按4根手指修改虚拟手柄布局" "value" : "在串流视图中轻按5根手指修改虚拟手柄布局"
} }
}, },
"zh-Hant" : { "zh-Hant" : {
"stringUnit" : { "stringUnit" : {
"state" : "translated", "state" : "translated",
"value" : "在串流视图中轻按4根手指修改虚拟手柄布局" "value" : "在串流视图中轻按5根手指修改虚拟手柄布局"
} }
}, },
"zh-HK" : { "zh-HK" : {
"stringUnit" : { "stringUnit" : {
"state" : "translated", "state" : "translated",
"value" : "在串流视图中轻按4根手指修改虚拟手柄布局" "value" : "在串流视图中轻按5根手指修改虚拟手柄布局"
} }
} }
} }
@@ -483,7 +483,7 @@ BOOL isCustomResolution(CGSize res) {
- (void)showCustomOSCTip { - (void)showCustomOSCTip {
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:[LocalizationHelper localizedStringForKey:@"Rebase in Stream View"] UIAlertController *alertController = [UIAlertController alertControllerWithTitle:[LocalizationHelper localizedStringForKey:@"Rebase in Stream View"]
message:[LocalizationHelper localizedStringForKey:@"Tap 4 fingers to change on-screen controller layout in stream view"] message:[LocalizationHelper localizedStringForKey:@"Tap 5 fingers to change on-screen controller layout in stream view"]
preferredStyle:UIAlertControllerStyleAlert]; preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *okAction = [UIAlertAction actionWithTitle:[LocalizationHelper localizedStringForKey: @"Got it!"] UIAlertAction *okAction = [UIAlertAction actionWithTitle:[LocalizationHelper localizedStringForKey: @"Got it!"]
style:UIAlertActionStyleDefault style:UIAlertActionStyleDefault
@@ -513,11 +513,12 @@ BOOL isCustomResolution(CGSize res) {
bool oscEnabled = ([self.touchModeSelector selectedSegmentIndex] == RELATIVE_TOUCH || [self.touchModeSelector selectedSegmentIndex] == REGULAR_NATIVE_TOUCH) && [self.onscreenControlSelector selectedSegmentIndex] != OnScreenControlsLevelOff; bool oscEnabled = ([self.touchModeSelector selectedSegmentIndex] == RELATIVE_TOUCH || [self.touchModeSelector selectedSegmentIndex] == REGULAR_NATIVE_TOUCH) && [self.onscreenControlSelector selectedSegmentIndex] != OnScreenControlsLevelOff;
bool customOscEnabled = oscEnabled && [self.onscreenControlSelector selectedSegmentIndex] == OnScreenControlsLevelCustom; bool customOscEnabled = oscEnabled && [self.onscreenControlSelector selectedSegmentIndex] == OnScreenControlsLevelCustom;
[self widget:self.keyboardToggleFingerNumSlider setEnabled:!customOscEnabled]; // [self widget:self.keyboardToggleFingerNumSlider setEnabled:!customOscEnabled];
if(customOscEnabled && !justEnteredSettingsViewDoNotOpenOscLayoutTool) { if(customOscEnabled && !justEnteredSettingsViewDoNotOpenOscLayoutTool) {
[self.keyboardToggleFingerNumSlider setValue:3.0]; // [self.keyboardToggleFingerNumSlider setValue:3.0];
[self keyboardToggleFingerNumSliderMoved]; // [self keyboardToggleFingerNumSliderMoved];
[self.onscreenControllerLabel setText:[LocalizationHelper localizedStringForKey: @"Tap 4 Fingers to Change OSC Layout in Stream View"]]; [self keyboardToggleFingerNumSliderMoved]; // go to exclude 5 fingers
[self.onscreenControllerLabel setText:[LocalizationHelper localizedStringForKey: @"Tap 5 Fingers to Change OSC Layout in Stream View"]];
[self showCustomOSCTip]; [self showCustomOSCTip];
justEnteredSettingsViewDoNotOpenOscLayoutTool = false; justEnteredSettingsViewDoNotOpenOscLayoutTool = false;
//if (self.layoutOnScreenControlsVC.isBeingPresented == NO) //if (self.layoutOnScreenControlsVC.isBeingPresented == NO)
@@ -605,12 +606,13 @@ BOOL isCustomResolution(CGSize res) {
[self widget:self.mousePointerVelocityFactorSlider setEnabled:[self.touchModeSelector selectedSegmentIndex] == RELATIVE_TOUCH]; // mouse velocity scaling works only in relative 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 will be fixed to 3 when OSC is enabled. // number of touches required to toggle keyboard will be fixed to 3 when OSC is enabled.
[self widget:self.keyboardToggleFingerNumSlider setEnabled: !customOscEnabled]; // cancel OSC limitation for regular native touch, // [self widget:self.keyboardToggleFingerNumSlider setEnabled: !customOscEnabled]; // cancel OSC limitation for regular native touch,
// when CustomOSC is enabled: // when CustomOSC is enabled:
if(customOscEnabled) { if(customOscEnabled) {
[self.keyboardToggleFingerNumSlider setValue:3.0]; // [self.keyboardToggleFingerNumSlider setValue:3.0];
[self.keyboardToggleFingerNumLabel setText:[LocalizationHelper localizedStringForKey:@"To Toggle Local Keyboard: Tap %d Fingers", (uint16_t)self.keyboardToggleFingerNumSlider.value]]; // [self.keyboardToggleFingerNumLabel setText:[LocalizationHelper localizedStringForKey:@"To Toggle Local Keyboard: Tap %d Fingers", (uint16_t)self.keyboardToggleFingerNumSlider.value]];
[self.onscreenControllerLabel setText:[LocalizationHelper localizedStringForKey: @"Tap 4 Fingers to Change OSC Layout in Stream View"]]; [self.onscreenControllerLabel setText:[LocalizationHelper localizedStringForKey: @"Tap 5 Fingers to Change OSC Layout in Stream View"]];
[self keyboardToggleFingerNumSliderMoved]; // go exclude 5 fingers
//if (self.layoutOnScreenControlsVC.isBeingPresented == NO) //if (self.layoutOnScreenControlsVC.isBeingPresented == NO)
} }
else{ else{
@@ -807,8 +809,19 @@ BOOL isCustomResolution(CGSize res) {
} }
- (void) keyboardToggleFingerNumSliderMoved{ - (void) keyboardToggleFingerNumSliderMoved{
if (self.keyboardToggleFingerNumSlider.value > 10.5f) [self.keyboardToggleFingerNumLabel setText:[LocalizationHelper localizedStringForKey:@"Local Keyboard Toggle Disabled"]]; bool oscEnabled = ([self.touchModeSelector selectedSegmentIndex] == RELATIVE_TOUCH || [self.touchModeSelector selectedSegmentIndex] == REGULAR_NATIVE_TOUCH) && [self.onscreenControlSelector selectedSegmentIndex] != OnScreenControlsLevelOff;
else [self.keyboardToggleFingerNumLabel setText:[LocalizationHelper localizedStringForKey:@"To Toggle Local Keyboard: Tap %d Fingers", (uint16_t)self.keyboardToggleFingerNumSlider.value]]; // Initiate label display bool customOscEnabled = oscEnabled && [self.onscreenControlSelector selectedSegmentIndex] == OnScreenControlsLevelCustom;
CGFloat sliderValue = self.keyboardToggleFingerNumSlider.value;
if(customOscEnabled){
// exclude 5 fingers when custom osc is enabled
if(sliderValue > OSC_TOOL_FINGERS - 1 && sliderValue < OSC_TOOL_FINGERS) [self.keyboardToggleFingerNumSlider setValue:4.0];
if(sliderValue >= OSC_TOOL_FINGERS && sliderValue < OSC_TOOL_FINGERS + 1) [self.keyboardToggleFingerNumSlider setValue:6.0];
}
sliderValue = self.keyboardToggleFingerNumSlider.value;
if(sliderValue > 10.5f) [self.keyboardToggleFingerNumLabel setText:[LocalizationHelper localizedStringForKey:@"Local Keyboard Toggle Disabled"]];
else [self.keyboardToggleFingerNumLabel setText:[LocalizationHelper localizedStringForKey:@"To Toggle Local Keyboard: Tap %d Fingers", (uint16_t)sliderValue]]; // Initiate label display, exclude 5 fingers.
} }
- (void) slideToMenuDistanceSliderMoved{ - (void) slideToMenuDistanceSliderMoved{
@@ -15,7 +15,9 @@
#import "CustomEdgeSwipeGestureRecognizer.h" #import "CustomEdgeSwipeGestureRecognizer.h"
#import "CustomTapGestureRecognizer.h" #import "CustomTapGestureRecognizer.h"
#import "LocalizationHelper.h" #import "LocalizationHelper.h"
#import "RelativeTouchHandler.h"
#import "Moonlight-Swift.h" #import "Moonlight-Swift.h"
#import "SettingsViewController.h"
#include <sys/socket.h> #include <sys/socket.h>
#include <netinet/in.h> #include <netinet/in.h>
@@ -56,22 +58,24 @@
#if !TARGET_OS_TV #if !TARGET_OS_TV
CustomEdgeSwipeGestureRecognizer *_slideToSettingsRecognizer; CustomEdgeSwipeGestureRecognizer *_slideToSettingsRecognizer;
CustomEdgeSwipeGestureRecognizer *_slideToCmdToolRecognizer; CustomEdgeSwipeGestureRecognizer *_slideToCmdToolRecognizer;
CustomTapGestureRecognizer *_oscLayoutTapRecoginizer; CustomTapGestureRecognizer *_oscLayoutTapRecognizer;
CustomTapGestureRecognizer *_mouseRightClickRecognizer;
LayoutOnScreenControlsViewController *_layoutOnScreenControlsVC; LayoutOnScreenControlsViewController *_layoutOnScreenControlsVC;
#endif #endif
} }
- (void)configOscLayoutTool{ - (void)configOscLayoutTool{
[self.view removeGestureRecognizer:_oscLayoutTapRecoginizer]; [self.view removeGestureRecognizer:_oscLayoutTapRecognizer];
if((_settings.touchMode.intValue == RELATIVE_TOUCH || _settings.touchMode.intValue == REGULAR_NATIVE_TOUCH) && _settings.onscreenControls.intValue == OnScreenControlsLevelCustom){ if((_settings.touchMode.intValue == RELATIVE_TOUCH || _settings.touchMode.intValue == REGULAR_NATIVE_TOUCH) && _settings.onscreenControls.intValue == OnScreenControlsLevelCustom){
_oscLayoutTapRecoginizer = [[CustomTapGestureRecognizer alloc] initWithTarget:self action:@selector(layoutOSC)]; _oscLayoutTapRecognizer = [[CustomTapGestureRecognizer alloc] initWithTarget:self action:@selector(layoutOSC)];
_oscLayoutTapRecoginizer.numberOfTouchesRequired = 4; //tap 4 fingers to invoke OSC rebase _oscLayoutTapRecognizer.numberOfTouchesRequired = OSC_TOOL_FINGERS; //Tap 5 fingers to invoke OSC rebase
_oscLayoutTapRecoginizer.tapDownTimeThreshold = 1; _oscLayoutTapRecognizer.tapDownTimeThreshold = 1;
_oscLayoutTapRecoginizer.delaysTouchesBegan = NO; _oscLayoutTapRecognizer.delaysTouchesBegan = NO;
_oscLayoutTapRecoginizer.delaysTouchesEnded = NO; _oscLayoutTapRecognizer.delaysTouchesEnded = NO;
[self.view addGestureRecognizer:_oscLayoutTapRecoginizer]; [self.view addGestureRecognizer:_oscLayoutTapRecognizer];
/* sets a reference to the correct 'LayoutOnScreenControlsViewController' depending on whether the user is on an iPhone or iPad */ /* sets a reference to the correct 'LayoutOnScreenControlsViewController' depending on whether the user is on an iPhone or iPad */
_layoutOnScreenControlsVC = [[LayoutOnScreenControlsViewController alloc] init]; _layoutOnScreenControlsVC = [[LayoutOnScreenControlsViewController alloc] init];
BOOL isIPhone = ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone); BOOL isIPhone = ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone);
@@ -94,6 +98,22 @@
[self presentViewController:cmdManViewController animated:YES completion:nil]; [self presentViewController:cmdManViewController animated:YES completion:nil];
} }
- (void)configMouseRightClickGesture{
[self.view removeGestureRecognizer:_mouseRightClickRecognizer];// remove the recognizer first
OnScreenControls* onScreenControls = [_streamView getOnScreenControlsObj];// retrieve onScreenControls obj from sreamview
onScreenControls.mouseRightClickTapRecognizer = nil;
if(_settings.touchMode.intValue == RELATIVE_TOUCH){
// retrieve mouse right click recognizer from streamview
RelativeTouchHandler* touchHandler = (RelativeTouchHandler* ) [_streamView getTouchHandler];
_mouseRightClickRecognizer = [touchHandler getMouseRightClickTapRecognizer];
onScreenControls.mouseRightClickTapRecognizer = _mouseRightClickRecognizer; // pass the recognizer to the onscreen controls obj.
// add the recognizer to the streamframe view.
[self.view addGestureRecognizer:_mouseRightClickRecognizer];
}
// reset this recognizer for streamview.
}
- (void)configSwipeGestures{ - (void)configSwipeGestures{
[self.view removeGestureRecognizer:_slideToSettingsRecognizer]; [self.view removeGestureRecognizer:_slideToSettingsRecognizer];
_slideToSettingsRecognizer = [[CustomEdgeSwipeGestureRecognizer alloc] initWithTarget:self action:@selector(edgeSwiped)]; _slideToSettingsRecognizer = [[CustomEdgeSwipeGestureRecognizer alloc] initWithTarget:self action:@selector(edgeSwiped)];
@@ -139,9 +159,11 @@
- (void)reConfigStreamViewRealtime{ - (void)reConfigStreamViewRealtime{
//[self.view removeGestureRecognizer:] //[self.view removeGestureRecognizer:]
_settings = [[[DataManager alloc] init] getSettings]; //StreamFrameViewController retrieve the settings here. _settings = [[[DataManager alloc] init] getSettings]; //StreamFrameViewController retrieve the settings here.
/*
[self configOscLayoutTool]; [self configOscLayoutTool];
[self configSwipeGestures]; [self configSwipeGestures];
[self configZoomGesture]; [self configMouseRightClickGesture]; // added in relative touch mode.
[self configZoomGesture]; */
[self->_streamView disableOnScreenControls]; //don't know why but this must be called outside the streamview class, just put it here. execute in streamview class cause hang [self->_streamView disableOnScreenControls]; //don't know why but this must be called outside the streamview class, just put it here. execute in streamview class cause hang
[self.mainFrameViewcontroller reloadStreamConfig]; // reload streamconfig [self.mainFrameViewcontroller reloadStreamConfig]; // reload streamconfig
_controllerSupport = [[ControllerSupport alloc] initWithConfig:self.streamConfig delegate:self]; // reload controllerSupport obj, this is mandatory for OSC reload,especially when the stream view is launched without OSC _controllerSupport = [[ControllerSupport alloc] initWithConfig:self.streamConfig delegate:self]; // reload controllerSupport obj, this is mandatory for OSC reload,especially when the stream view is launched without OSC
@@ -155,6 +177,11 @@
selector:@selector(updateStatsOverlay) selector:@selector(updateStatsOverlay)
userInfo:nil userInfo:nil
repeats:_settings.statsOverlay]; repeats:_settings.statsOverlay];
// these must be congured in the last step:
[self configOscLayoutTool];
[self configSwipeGestures];
[self configMouseRightClickGesture]; // added in relative touch mode.
[self configZoomGesture];
} }
@@ -270,6 +297,7 @@
#else #else
[self configSwipeGestures]; // swipe & exit gesture configured here [self configSwipeGestures]; // swipe & exit gesture configured here
[self configMouseRightClickGesture]; // added in relative touch mode.
[self configOscLayoutTool]; //_oscLayoutTapRecoginizer will be added or removed to the view here [self configOscLayoutTool]; //_oscLayoutTapRecoginizer will be added or removed to the view here
#endif #endif