udpate
This commit is contained in:
@@ -18,9 +18,9 @@
|
||||
@property (nonatomic, assign) uint8_t numberOfTouchesRequired;
|
||||
@property (nonatomic, assign) bool immediateTriggering; // if enabled, trigger the signal on touchesBegan stage.
|
||||
@property (nonatomic, assign) double tapDownTimeThreshold; // tap down threshold in seconds.
|
||||
@property (nonatomic, assign) bool areVirtualControllerTaps; // will be set by the onscreencontrol class
|
||||
@property (nonatomic, readonly) CGFloat lowestTouchPointHeight;
|
||||
@property (nonatomic, readonly) bool gestureCaptured;
|
||||
@property (nonatomic, readonly) bool areVirtualControllerTaps;
|
||||
@property (nonatomic, readonly) NSTimeInterval gestureCapturedTime;
|
||||
|
||||
@end
|
||||
|
||||
@@ -45,10 +45,11 @@ static CGFloat screenWidthInPoints;
|
||||
if(lowestTouchPointYCoord < [touch locationInView:self.view].y) lowestTouchPointYCoord = [touch locationInView:self.view].y;
|
||||
}
|
||||
|
||||
if(_numberOfTouchesRequired == 2){
|
||||
// this mechanism is deprecated.
|
||||
/* if(_numberOfTouchesRequired == 2){
|
||||
NSArray *twoTouches = [[event allTouches] allObjects];
|
||||
_areVirtualControllerTaps = fabs([twoTouches[1] locationInView:self.view].x - [twoTouches[0] locationInView:self.view].x) > screenWidthInPoints/3;
|
||||
}
|
||||
} */
|
||||
|
||||
_lowestTouchPointHeight = screenHeightInPoints - lowestTouchPointYCoord;
|
||||
if(_immediateTriggering){
|
||||
@@ -67,17 +68,19 @@ static CGFloat screenWidthInPoints;
|
||||
- (void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
|
||||
// [super touchesEnded:touches withEvent:event];
|
||||
if(_immediateTriggering) return;
|
||||
if([[event allTouches] count] > _numberOfTouchesRequired) {
|
||||
uint8_t allTouchesCount = [[event allTouches] count];
|
||||
if(allTouchesCount > _numberOfTouchesRequired) {
|
||||
_gestureCaptured = false;
|
||||
self.state = UIGestureRecognizerStateFailed;
|
||||
}
|
||||
else if(_gestureCaptured && [[event allTouches] count] == [touches count] && !_areVirtualControllerTaps){ //must exclude virtual controller taps here to prevent stucked button
|
||||
}
|
||||
else if(_gestureCaptured && allTouchesCount == [touches count] && !_areVirtualControllerTaps){ //must exclude virtual controller taps here to prevent stucked button, _areVirtualControllerTaps flag is set by onscreencontrols or anyother related classes.
|
||||
_gestureCaptured = false; //reset for next recognition
|
||||
if((CACurrentMediaTime() - _gestureCapturedTime) < _tapDownTimeThreshold){
|
||||
lowestTouchPointYCoord = 0.0; //reset for next recognition
|
||||
self.state = UIGestureRecognizerStateRecognized;
|
||||
}
|
||||
}
|
||||
if (allTouchesCount == [touches count]) _areVirtualControllerTaps = false; // need to reset this flag anyway, when all fingers are lefting
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "ControllerSupport.h"
|
||||
#import "CustomTapGestureRecognizer.h"
|
||||
#import "OSCProfile.h"
|
||||
|
||||
@class ControllerSupport;
|
||||
@@ -31,6 +32,8 @@ typedef NS_ENUM(NSInteger, OnScreenControlsLevel) {
|
||||
OnScreenControlsLevelAutoGCExtendedGamepadWithStickButtons
|
||||
};
|
||||
|
||||
|
||||
@property (nonatomic, assign) CustomTapGestureRecognizer* mouseRightClickTapRecognizer; // this object will be passed to onscreencontrols class for areVirtualControllerTaps flag setting
|
||||
@property CALayer* _aButton;
|
||||
@property CALayer* _bButton;
|
||||
@property CALayer* _xButton;
|
||||
|
||||
@@ -1037,6 +1037,8 @@ static float L3_Y;
|
||||
}
|
||||
}
|
||||
if (updated) {
|
||||
_mouseRightClickTapRecognizer.areVirtualControllerTaps = true; //inform the tap recognizer that this will be a controller tap.
|
||||
|
||||
[_controllerSupport updateFinished:_controller];
|
||||
}
|
||||
return updated || stickTouch;
|
||||
|
||||
@@ -8,10 +8,14 @@
|
||||
|
||||
#import "StreamView.h"
|
||||
#import "DataManager.h"
|
||||
#import "CustomTapGestureRecognizer.h"
|
||||
|
||||
|
||||
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;
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
//
|
||||
|
||||
#import "RelativeTouchHandler.h"
|
||||
#import "CustomTapGestureRecognizer.h"
|
||||
#import "DataManager.h"
|
||||
|
||||
#include <Limelight.h>
|
||||
@@ -24,7 +23,6 @@ static const int REFERENCE_HEIGHT = 720;
|
||||
BOOL isDragging;
|
||||
NSTimer* dragTimer;
|
||||
NSUInteger peakTouchCount;
|
||||
CustomTapGestureRecognizer* rightClickTapRecognizer;
|
||||
|
||||
#if TARGET_OS_TV
|
||||
UIGestureRecognizer* remotePressRecognizer;
|
||||
@@ -39,12 +37,12 @@ static const int REFERENCE_HEIGHT = 720;
|
||||
self->view = view;
|
||||
self->currentSettings = settings;
|
||||
// replace righclick recoginizing with my CustomTapGestureRecognizer for better experience, higher recoginizing rate.
|
||||
rightClickTapRecognizer = [[CustomTapGestureRecognizer alloc] initWithTarget:self action:@selector(mouseRightClick)];
|
||||
rightClickTapRecognizer.numberOfTouchesRequired = 2;
|
||||
rightClickTapRecognizer.tapDownTimeThreshold = RIGHTCLICK_TAP_DOWN_TIME_THRESHOLD_S; // tap down time in seconds.
|
||||
rightClickTapRecognizer.delaysTouchesBegan = NO;
|
||||
rightClickTapRecognizer.delaysTouchesEnded = NO;
|
||||
[self->view addGestureRecognizer:rightClickTapRecognizer];
|
||||
_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];
|
||||
|
||||
|
||||
|
||||
@@ -134,7 +132,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() - rightClickTapRecognizer.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);
|
||||
}
|
||||
|
||||
|
||||
@@ -124,6 +124,12 @@ 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 ) {
|
||||
Log(LOG_I, @"On-screen controls disabled in non-relative touch mode");
|
||||
|
||||
Reference in New Issue
Block a user