@@ -1988,6 +1988,9 @@ static NSArray<NSString *> *dyyy_qualityRank = nil;
19881988%hook AWEPlayInteractionSpeedController
19891989
19901990static BOOL hasChangedSpeed = NO ;
1991+ static CGFloat currentLongPressSpeed = 0 ;
1992+ static CGFloat initialTouchX = 0 ;
1993+ static BOOL isGestureActive = NO ;
19911994
19921995- (CGFloat)longPressFastSpeedValue {
19931996 float longPressSpeed = DYYYGetFloat (@" DYYYLongPressSpeed" );
@@ -2000,6 +2003,11 @@ static BOOL hasChangedSpeed = NO;
20002003- (void )changeSpeed:(double )speed {
20012004 float longPressSpeed = DYYYGetFloat (@" DYYYLongPressSpeed" );
20022005
2006+ if (isGestureActive && currentLongPressSpeed > 0 ) {
2007+ %orig (currentLongPressSpeed);
2008+ return ;
2009+ }
2010+
20032011 if (speed == 2.0 ) {
20042012 if (!hasChangedSpeed) {
20052013 if (longPressSpeed != 0 && longPressSpeed != 2.0 ) {
@@ -2020,6 +2028,52 @@ static BOOL hasChangedSpeed = NO;
20202028 }
20212029}
20222030
2031+ - (void )handleLongPressFastSpeed:(UILongPressGestureRecognizer *)gesture {
2032+ %orig ;
2033+
2034+ if (!DYYYGetBool (@" DYYYEnableLongPressSpeedGesture" )) {
2035+ return ;
2036+ }
2037+
2038+ CGPoint location = [gesture locationInView: gesture.view];
2039+
2040+ static CGFloat initialTouchY = 0 ;
2041+
2042+ if (gesture.state == UIGestureRecognizerStateBegan) {
2043+ initialTouchY = location.y ;
2044+ isGestureActive = YES ;
2045+
2046+ float longPressSpeed = DYYYGetFloat (@" DYYYLongPressSpeed" );
2047+ if (longPressSpeed == 0 ) {
2048+ longPressSpeed = 2.0 ;
2049+ }
2050+ currentLongPressSpeed = longPressSpeed;
2051+ }
2052+ else if (gesture.state == UIGestureRecognizerStateChanged && isGestureActive) {
2053+ CGFloat deltaY = location.y - initialTouchY;
2054+ CGFloat threshold = 10.0 ;
2055+
2056+ if (fabs (deltaY) > threshold) {
2057+ CGFloat speedChange;
2058+ speedChange = (deltaY > 0 ) ? 0.25 : -0.25 ;
2059+
2060+ CGFloat newSpeed = currentLongPressSpeed + speedChange;
2061+ newSpeed = MAX (0.5 , MIN (3.0 , newSpeed));
2062+
2063+ if (newSpeed != currentLongPressSpeed) {
2064+ currentLongPressSpeed = newSpeed;
2065+ initialTouchY = location.y ;
2066+ [self changeSpeed: currentLongPressSpeed];
2067+ }
2068+ }
2069+ }
2070+ else if (gesture.state == UIGestureRecognizerStateEnded ||
2071+ gesture.state == UIGestureRecognizerStateCancelled) {
2072+ isGestureActive = NO ;
2073+ currentLongPressSpeed = 0 ;
2074+ initialTouchY = 0 ;
2075+ }
2076+ }
20232077%end
20242078
20252079%hook UILabel
@@ -2028,12 +2082,12 @@ static BOOL hasChangedSpeed = NO;
20282082 UIView *superview = self.superview ;
20292083
20302084 if ([superview isKindOfClass: %c (AFDFastSpeedView)] && text) {
2031- float longPressSpeed = DYYYGetFloat (@" DYYYLongPressSpeed" );
2032- if (longPressSpeed == 0 ) {
2033- longPressSpeed = 2.0 ;
2085+ CGFloat displaySpeed = isGestureActive && currentLongPressSpeed > 0 ? currentLongPressSpeed : DYYYGetFloat (@" DYYYLongPressSpeed" );
2086+ if (displaySpeed == 0 ) {
2087+ displaySpeed = 2.0 ;
20342088 }
20352089
2036- NSString *speedString = [NSString stringWithFormat: @" %.2f " , longPressSpeed ];
2090+ NSString *speedString = [NSString stringWithFormat: @" %.2f " , displaySpeed ];
20372091 if ([speedString hasSuffix: @" .00" ]) {
20382092 speedString = [speedString substringToIndex: speedString.length - 3 ];
20392093 } else if ([speedString hasSuffix: @" 0" ] && [speedString containsString: @" ." ]) {
0 commit comments