- optimize _areVirtualControllerTap mechanism, fix onscreen game controller button stuck
- change keyboard toggle gesture finger number logic
This commit is contained in:
1 parent
9618b7bb94
commit
9ff10135a8
8 files changed
+105
-45
No files matched your search
@@ -14,10 +14,10 @@
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@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;
|
||||
- (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
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
|
||||
static const int REFERENCE_WIDTH = 1280;
|
||||
static const int REFERENCE_HEIGHT = 720;
|
||||
//static CustomTapGestureRecognizer* mouseRightClickTapRecognizer;
|
||||
|
||||
@implementation RelativeTouchHandler {
|
||||
TemporarySettings* currentSettings;
|
||||
@@ -30,22 +31,15 @@ static const int REFERENCE_HEIGHT = 720;
|
||||
#endif
|
||||
|
||||
UIView* view;
|
||||
CustomTapGestureRecognizer* mouseRightClickTapRecognizer;
|
||||
}
|
||||
|
||||
- (id)initWithView:(StreamView*)view andSettings:(TemporarySettings*)settings {
|
||||
self = [self init];
|
||||
self->view = view;
|
||||
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
|
||||
remotePressRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(remoteButtonPressed:)];
|
||||
remotePressRecognizer.allowedPressTypes = @[@(UIPressTypeSelect)];
|
||||
@@ -60,6 +54,20 @@ static const int REFERENCE_HEIGHT = 720;
|
||||
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 {
|
||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
|
||||
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 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);
|
||||
}
|
||||
|
||||
|
||||
@@ -39,6 +39,8 @@
|
||||
- (uint16_t)getRotationFromAzimuthAngle:(float)azimuthAngle;
|
||||
|
||||
- (OnScreenControlsLevel) getCurrentOscState;
|
||||
- (UIResponder* )getTouchHandler;
|
||||
- (OnScreenControls* )getOnScreenControlsObj;
|
||||
|
||||
#if !TARGET_OS_TV
|
||||
- (void) updateCursorLocation:(CGPoint)location isMouse:(BOOL)isMouse;
|
||||
|
||||
@@ -79,6 +79,8 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
|
||||
|
||||
[self removeGestureRecognizer:keyboardToggleRecognizer]; // for reconfig streamview in realtime
|
||||
isInputingText = false;
|
||||
|
||||
//keyboardToggleRecognizer is one of the only recognizers defined within the stream view class
|
||||
keyboardToggleRecognizer = [[CustomTapGestureRecognizer alloc] initWithTarget:self action:@selector(toggleKeyboard)];
|
||||
keyboardToggleRecognizer.numberOfTouchesRequired = settings.keyboardToggleFingers.intValue; //will be changed accordinly by touch modes.
|
||||
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) {
|
||||
case REGULAR_NATIVE_TOUCH:
|
||||
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:
|
||||
self->touchHandler = [[NativeTouchHandler alloc] initWithView:self andSettings:settings];break;
|
||||
case RELATIVE_TOUCH:
|
||||
self->touchHandler = [[RelativeTouchHandler alloc] initWithView:self andSettings:settings];
|
||||
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;
|
||||
case ABSOLUTE_TOUCH:
|
||||
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];
|
||||
// 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];
|
||||
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];
|
||||
}
|
||||
|
||||
|
||||
- (UIResponder* )getTouchHandler{
|
||||
return self->touchHandler;
|
||||
}
|
||||
|
||||
- (OnScreenControls* )getOnScreenControlsObj{
|
||||
return self->onScreenControls;
|
||||
}
|
||||
|
||||
// this method also deals with lifting streamview for local keyboard
|
||||
- (void)keyboardWillShow:(NSNotification *)notification{
|
||||
if(settings.liftStreamViewForKeyboard && !isInputingText){
|
||||
@@ -205,6 +211,8 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
|
||||
// NSLog(@"keyboard will show");
|
||||
}
|
||||
|
||||
|
||||
|
||||
// this method also deals with recovering streamview when local keyboard is turned off
|
||||
- (void)keyboardWillHide:(NSNotification *)notification{
|
||||
|
||||
|
||||
Reference in new issue
Block a user