From 7b5d9cde2e31c6f6fd923653f872d0ca45d8c139 Mon Sep 17 00:00:00 2001 From: TrueZhuanjia Date: Sat, 9 Aug 2025 23:50:28 +0800 Subject: [PATCH] - feat: vibration available for controller & keyboard direction pad sliding --- VoidLink/Input/CustomTapGestureRecognizer.m | 4 ++-- VoidLink/Input/OnScreenWidgetView.swift | 14 +++++++++++++- VoidLink/Input/RelativeTouchHandler.m | 4 ++-- VoidLink/Input/StreamView.m | 4 ++-- VoidLink/ViewControllers/SettingsViewController.m | 4 +--- 5 files changed, 20 insertions(+), 10 deletions(-) diff --git a/VoidLink/Input/CustomTapGestureRecognizer.m b/VoidLink/Input/CustomTapGestureRecognizer.m index 79e9fe13..2814ddc4 100644 --- a/VoidLink/Input/CustomTapGestureRecognizer.m +++ b/VoidLink/Input/CustomTapGestureRecognizer.m @@ -53,7 +53,7 @@ static CGFloat screenWidthInPoints; } */ _lowestTouchPointHeight = screenHeightInPoints - lowestTouchPointYCoord; - NSLog(@"gen _lowestTouchPointHeight %f markmark", _lowestTouchPointHeight); + // NSLog(@"gen _lowestTouchPointHeight %f markmark", _lowestTouchPointHeight); if(_immediateTriggering){ lowestTouchPointYCoord = 0.0; //reset for next recoginition self.state = UIGestureRecognizerStateRecognized; @@ -81,7 +81,7 @@ static CGFloat screenWidthInPoints; if((CACurrentMediaTime() - _gestureCapturedTime) < _tapDownTimeThreshold){ lowestTouchPointYCoord = 0.0; //reset for next recognition self.state = UIGestureRecognizerStateRecognized; - NSLog(@"gen _lowestTouchPointHeight %f markmark touchesEnd", _lowestTouchPointHeight); + // NSLog(@"gen _lowestTouchPointHeight %f markmark touchesEnd", _lowestTouchPointHeight); } } if (allTouchesCount == [touches count]) _isOnScreenControllerBeingPressed = false; // need to reset this flag anyway, when all fingers are lefting diff --git a/VoidLink/Input/OnScreenWidgetView.swift b/VoidLink/Input/OnScreenWidgetView.swift index 47652eae..5e5633f8 100644 --- a/VoidLink/Input/OnScreenWidgetView.swift +++ b/VoidLink/Input/OnScreenWidgetView.swift @@ -707,7 +707,15 @@ import UIKit self.layer.superlayer?.insertSublayer(indicatorLayer, below: self.layer) // show the indicator based on the touchBeganLocation - indicatorLayer.position = CGPointMake(CGRectGetMinX(self.frame)+touchBeganLocation.x, CGRectGetMinY(self.frame)+touchBeganLocation.y) + let newPosition = CGPointMake(CGRectGetMinX(self.frame)+touchBeganLocation.x, CGRectGetMinY(self.frame)+touchBeganLocation.y) + + if indicatorLayer.position != newPosition && vibrationOn { + vibrationGenerator.prepare() + vibrationGenerator.impactOccurred() + // print("vibrationInstance: \(vibrationGenerator)") + } + + indicatorLayer.position = newPosition } private func handleLrudTouchMove(){ @@ -757,6 +765,7 @@ import UIKit } else{ self.upIndicator.removeFromSuperlayer() + self.upIndicator.position = CGPointMake(0, 0) switch touchPadString { case "WASDPAD": LiSendKeyboardEvent(CommandManager.keyboardButtonMappings["W"]!,Int8(KEY_ACTION_UP), 0) case "ARROWPAD": LiSendKeyboardEvent(CommandManager.keyboardButtonMappings["UP_ARROW"]!,Int8(KEY_ACTION_UP), 0) @@ -775,6 +784,7 @@ import UIKit } else{ self.downIndicator.removeFromSuperlayer() + self.downIndicator.position = CGPointMake(0, 0) switch touchPadString { case "WASDPAD": LiSendKeyboardEvent(CommandManager.keyboardButtonMappings["S"]!,Int8(KEY_ACTION_UP), 0) case "ARROWPAD": LiSendKeyboardEvent(CommandManager.keyboardButtonMappings["DOWN_ARROW"]!,Int8(KEY_ACTION_UP), 0) @@ -793,6 +803,7 @@ import UIKit } else{ self.leftIndicator.removeFromSuperlayer() + self.leftIndicator.position = CGPointMake(0, 0) switch touchPadString { case "WASDPAD": LiSendKeyboardEvent(CommandManager.keyboardButtonMappings["A"]!,Int8(KEY_ACTION_UP), 0) case "ARROWPAD": LiSendKeyboardEvent(CommandManager.keyboardButtonMappings["LEFT_ARROW"]!,Int8(KEY_ACTION_UP), 0) @@ -811,6 +822,7 @@ import UIKit } else{ self.rightIndicator.removeFromSuperlayer() + self.rightIndicator.position = CGPointMake(0, 0) switch touchPadString { case "WASDPAD": LiSendKeyboardEvent(CommandManager.keyboardButtonMappings["D"]!,Int8(KEY_ACTION_UP), 0) case "ARROWPAD": LiSendKeyboardEvent(CommandManager.keyboardButtonMappings["RIGHT_ARROW"]!,Int8(KEY_ACTION_UP), 0) diff --git a/VoidLink/Input/RelativeTouchHandler.m b/VoidLink/Input/RelativeTouchHandler.m index d6983319..0aba3acc 100644 --- a/VoidLink/Input/RelativeTouchHandler.m +++ b/VoidLink/Input/RelativeTouchHandler.m @@ -177,7 +177,7 @@ static const float QUICK_TAP_TIME_INTERVAL = 0.2; // we must use [event allTouches] to check if touchLockedForMouseMove is captured, because the UITouch object could be captured by upper layer of UIView(in cases like tap gestures), not passed to the touches callbacks in this class, but still available in [event allTouches] if(candidateTouch != nil && ![[event allTouches] containsObject:touchLockedForMouseMove]){ touchLockedForMouseMove = candidateTouch; - NSLog(@"Candidate touch for mouse movement locked"); + // NSLog(@"Candidate touch for mouse movement locked"); mousePointerTimestamp = CACurrentMediaTime(); initialMousePointerLocation = latestMousePointerLocation = [touchLockedForMouseMove locationInView:streamView]; } @@ -278,7 +278,7 @@ static const float QUICK_TAP_TIME_INTERVAL = 0.2; if(!self->quickTapDetected){ LiSendMouseButtonEvent(BUTTON_ACTION_RELEASE, BUTTON_LEFT); } - else NSLog(@"Left mouse button release cancelled, keep pressing down, turning into dragging..."); + // else NSLog(@"Left mouse button release cancelled, keep pressing down, turning into dragging..."); // do not release the button if we're still dragging, this will prevent the dragging from being interrupted. }); diff --git a/VoidLink/Input/StreamView.m b/VoidLink/Input/StreamView.m index dfe1541b..c1efbc92 100644 --- a/VoidLink/Input/StreamView.m +++ b/VoidLink/Input/StreamView.m @@ -253,7 +253,7 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5; // this method also deals with recovering streamview when local keyboard is turned off - (void)keyboardWillHide{ - NSLog(@"keyboard will hide markmark %f", CACurrentMediaTime()); + // NSLog(@"keyboard will hide markmark %f", CACurrentMediaTime()); keyboardToggleRecognizer.numberOfTouchesRequired = settings.keyboardToggleFingers.intValue; // reset this number if(isInputingText){ @@ -280,7 +280,7 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5; - (void)toggleKeyboard{ - NSLog(@"toggleKeyboard markmark, %d", isInputingText); + // NSLog(@"toggleKeyboard markmark, %d", isInputingText); if (isInputingText) { Log(LOG_D, @"Closing the keyboard"); [keyInputField resignFirstResponder]; diff --git a/VoidLink/ViewControllers/SettingsViewController.m b/VoidLink/ViewControllers/SettingsViewController.m index fc4bb18b..0ab109e3 100644 --- a/VoidLink/ViewControllers/SettingsViewController.m +++ b/VoidLink/ViewControllers/SettingsViewController.m @@ -1566,9 +1566,7 @@ BOOL isCustomResolution(int resolutionSelected) { } [self findDynamicLabelFromStack:self.onScreenWidgetStack].text = [self isCustomOswEnabled] ? [LocalizationHelper localizedStringForKey:@"%d finger tap", self->oswLayoutFingers] : @""; - //markmark - [self handleOswGestureChange]; - }]; + [self handleOswGestureChange];}]; [alertController addAction:cancelAction]; [alertController addAction:okAction];