From 20d6e221a429f7b0ac7de137bce7c9c861e59986 Mon Sep 17 00:00:00 2001 From: True Zhuanjia Date: Wed, 26 Aug 2026 00:25:56 +0800 Subject: [PATCH] minor fixes --- VoidLink/Input/ControllerSupport.m | 7 +++-- VoidLink/Localization/Localizable.xcstrings | 29 +++++++++++++++++++ VoidLink/Utility/GenericUtils.swift | 26 +++++++++++++++++ .../ViewControllers/SettingsViewController.m | 7 +++++ 4 files changed, 66 insertions(+), 3 deletions(-) diff --git a/VoidLink/Input/ControllerSupport.m b/VoidLink/Input/ControllerSupport.m index 6944c746..e951a11e 100644 --- a/VoidLink/Input/ControllerSupport.m +++ b/VoidLink/Input/ControllerSupport.m @@ -331,7 +331,7 @@ static void ApplyAdaptiveTriggerEffect(GCDualSenseAdaptiveTrigger* trigger, deviceAccelSample.x += voidController.motionManager.deviceMotion.gravity.x; deviceAccelSample.y += voidController.motionManager.deviceMotion.gravity.y; deviceAccelSample.z += voidController.motionManager.deviceMotion.gravity.z; - NSLog(@"sending device accel %f", CACurrentMediaTime()); + // NSLog(@"sending device accel %f", CACurrentMediaTime()); UIInterfaceOrientation interfaceOrientation = [self currentInterfaceOrientation]; CMAcceleration mappedDeviceAccelSample = {}; @@ -486,10 +486,10 @@ static void ApplyAdaptiveTriggerEffect(GCDualSenseAdaptiveTrigger* trigger, block:^(NSTimer *timer) { GCAcceleration lastAccelSample = voidController.lastAccelSample; GCAcceleration accelSample = voidController.gamepad.motion.acceleration; - if (memcmp(&accelSample, &lastAccelSample, sizeof(accelSample)) == 0) { return; } + // NSLog(@"sending controller accel %f", CACurrentMediaTime()); voidController.lastAccelSample = accelSample; @@ -1345,7 +1345,8 @@ double rc_expo(double x, double expo) { - (bool)useMotionHandler{ - return true; + return tempSettings.gyroMode.intValue == GyroModeOff + || tempSettings.gyroMode.intValue == AlwaysDevice; } - (void)switchMotionControlOnOffByControllerButton{ diff --git a/VoidLink/Localization/Localizable.xcstrings b/VoidLink/Localization/Localizable.xcstrings index e2d9ccf0..fca9b3b4 100644 --- a/VoidLink/Localization/Localizable.xcstrings +++ b/VoidLink/Localization/Localizable.xcstrings @@ -20225,6 +20225,35 @@ } } }, + "emulatedGyroModeDisablesBuiltinMotionControlTip" : { + "extractionState" : "manual", + "localizations" : { + "en" : { + "stringUnit" : { + "state" : "translated", + "value" : "Turning this option on will disable VoidLink's built-in motion control. If you need the app to convert gyroscope input directly into mouse or controller-stick signals, remember to turn this option off." + } + }, + "zh-Hans" : { + "stringUnit" : { + "state" : "translated", + "value" : "打开该选项,将导致 VoidLink 内置的体感控制功能失效。如果您需要在 App 内部直接将陀螺仪转换为鼠标或手柄摇杆信号,请记得关闭该选项。" + } + }, + "zh-Hant" : { + "stringUnit" : { + "state" : "translated", + "value" : "開啟該選項,將導致 VoidLink 內建的體感控制功能失效。如果您需要在 App 內部直接將陀螺儀轉換為滑鼠或手把搖桿訊號,請記得關閉該選項。" + } + }, + "zh-HK" : { + "stringUnit" : { + "state" : "translated", + "value" : "開啟該選項,將導致 VoidLink 內置的體感控制功能失效。如果您需要在 App 內部直接將陀螺儀轉換為滑鼠或手掣搖桿訊號,請記得關閉該選項。" + } + } + } + }, "yuv444StackTip" : { "extractionState" : "manual", "localizations" : { diff --git a/VoidLink/Utility/GenericUtils.swift b/VoidLink/Utility/GenericUtils.swift index 30f267fa..283ba013 100644 --- a/VoidLink/Utility/GenericUtils.swift +++ b/VoidLink/Utility/GenericUtils.swift @@ -638,6 +638,32 @@ import UIKit } ) } + + @objc public static func isFirstEnablingEmulatedGyroMode() -> Bool { + let key = "hasEnabledEmulatedGyroMode20260825" + let defaults = UserDefaults.standard + let launchedBefore = defaults.bool(forKey: key) + if !launchedBefore { + defaults.set(true, forKey: key) + return true + } + return false + } + + @objc public static func handleEmulatedGyroModeTip(in vc: UIViewController?) { + if isFirstEnablingEmulatedGyroMode() { + AlertControllerUtil.showAlert( + in: vc, + title: LocalizationHelper.localizedString(forKey: "Tips"), + message: "\n\(LocalizationHelper.localizedString(forKey: "emulatedGyroModeDisablesBuiltinMotionControlTip"))", + withCancel: false, + buttonTitle: LocalizationHelper.localizedString(forKey: "This tip won't be shown again"), + countdown: 7 + ) + } + } + + @objc public static func gamepadOverlayFeatureTipTitle() -> String { LocalizationHelper.localizedString(forKey: "Gamepad Overlay") diff --git a/VoidLink/ViewControllers/SettingsViewController.m b/VoidLink/ViewControllers/SettingsViewController.m index 5e0f6bbe..4566cc53 100644 --- a/VoidLink/ViewControllers/SettingsViewController.m +++ b/VoidLink/ViewControllers/SettingsViewController.m @@ -2347,6 +2347,8 @@ BOOL isCustomResolution(int resolutionSelected) { [self.dualSenseTransientSlider addTarget:self action:@selector(dualSenseTransientSliderMoved:) forControlEvents:UIControlEventValueChanged]; self.gyroModeSelector.selectedSegmentIndex = self->tempSettings.gyroMode.intValue; + [self.gyroModeSelector addTarget:self action:@selector(emulatedGyroModeChanged:) forControlEvents:(UIControlEventValueChanged)]; // Update label display when slider is being moved. + [self.gyroSensitivitySlider setValue: (uint16_t)(self->tempSettings.gyroSensitivity.floatValue * 100) animated:NO]; // Load old setting. [self.gyroSensitivitySlider addTarget:self action:@selector(gyroSensitivitySliderMoved:) forControlEvents:(UIControlEventValueChanged)]; // Update label display when slider is being moved. [self.gyroSensitivitySlider sendActionsForControlEvents:UIControlEventValueChanged]; // Load old setting. @@ -3458,6 +3460,11 @@ BOOL isCustomResolution(int resolutionSelected) { [self findDynamicLabelFromStack:(UIStackView*)sender.superview].text = [NSString stringWithFormat:@" %d%% ", (uint16_t)sender.value]; // Update label display } +- (void)emulatedGyroModeChanged:(UISegmentedControl* )sender { + if(sender.selectedSegmentIndex == GyroModeOff) return; + [GenericUtils handleEmulatedGyroModeTipIn:self]; +} + - (void) localVolumeSliderMoved:(UISlider* )sender { [self findDynamicLabelFromStack:(UIStackView*)sender.superview].text = [NSString stringWithFormat:@" %d%% ", (uint16_t)sender.value]; // Update label display if(_mainFrameViewController.settingsExpandedInStreamView) [Connection setVolume:sender.value/100];