tips for first keyboard or mouse connection on iOS
This commit is contained in:
1 parent
237f03a501
commit
fe6954cb9c
5 files changed
+125
-35
No files matched your search
@@ -15,6 +15,8 @@
|
|||||||
|
|
||||||
- (void)gamepadPresenceChanged;
|
- (void)gamepadPresenceChanged;
|
||||||
- (void)mousePresenceChanged;
|
- (void)mousePresenceChanged;
|
||||||
|
- (void)mouseConnected;
|
||||||
|
- (void)keyboardConnected;
|
||||||
- (void)streamExitRequested;
|
- (void)streamExitRequested;
|
||||||
- (void)controllerArrivalWithPlayerIndex:(int8_t)index;
|
- (void)controllerArrivalWithPlayerIndex:(int8_t)index;
|
||||||
|
|
||||||
|
|||||||
@@ -1938,6 +1938,7 @@ double rc_expo(double x, double expo) {
|
|||||||
|
|
||||||
// Notify the delegate
|
// Notify the delegate
|
||||||
[self->_delegate mousePresenceChanged];
|
[self->_delegate mousePresenceChanged];
|
||||||
|
[self->_delegate mouseConnected];
|
||||||
}];
|
}];
|
||||||
_mouseDisconnectObserver = [[NSNotificationCenter defaultCenter] addObserverForName:GCMouseDidDisconnectNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *note) {
|
_mouseDisconnectObserver = [[NSNotificationCenter defaultCenter] addObserverForName:GCMouseDidDisconnectNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *note) {
|
||||||
Log(LOG_I, @"Mouse disconnected!");
|
Log(LOG_I, @"Mouse disconnected!");
|
||||||
@@ -1956,6 +1957,8 @@ double rc_expo(double x, double expo) {
|
|||||||
_keyboardConnectObserver = [[NSNotificationCenter defaultCenter] addObserverForName:GCKeyboardDidConnectNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *note) {
|
_keyboardConnectObserver = [[NSNotificationCenter defaultCenter] addObserverForName:GCKeyboardDidConnectNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *note) {
|
||||||
Log(LOG_I, @"Keyboard connected!");
|
Log(LOG_I, @"Keyboard connected!");
|
||||||
|
|
||||||
|
[self->_delegate keyboardConnected];
|
||||||
|
|
||||||
// Re-evaluate the on-screen control mode
|
// Re-evaluate the on-screen control mode
|
||||||
[self updateAutoOnScreenControlMode];
|
[self updateAutoOnScreenControlMode];
|
||||||
}];
|
}];
|
||||||
|
|||||||
@@ -6892,6 +6892,58 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"Keyboard/Mouse Connected" : {
|
||||||
|
"extractionState" : "manual",
|
||||||
|
"localizations" : {
|
||||||
|
"zh-Hans" : {
|
||||||
|
"stringUnit" : {
|
||||||
|
"state" : "translated",
|
||||||
|
"value" : "检测到键鼠接入"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"zh-Hant" : {
|
||||||
|
"stringUnit" : {
|
||||||
|
"state" : "translated",
|
||||||
|
"value" : "檢測到鍵鼠接入"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"zh-HK" : {
|
||||||
|
"stringUnit" : {
|
||||||
|
"state" : "translated",
|
||||||
|
"value" : "檢測到鍵鼠接入"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"keyboard&MouseStreamingTip" : {
|
||||||
|
"extractionState" : "manual",
|
||||||
|
"localizations" : {
|
||||||
|
"en" : {
|
||||||
|
"stringUnit" : {
|
||||||
|
"state" : "translated",
|
||||||
|
"value" : "\nKeyboard Shortcuts for VoidLink (Desktop Mode):\n\nCtrl(Control) + Alt(Opt) + Shift + D — Disconnect the current session\n\nCtrl(Control) + Alt(Opt) + Shift + Q — Disconnect the current session and quit current app\n\nCtrl(Control) + Alt(Opt) + Shift + S — Expand the settings menu\n\nCtrl(Control) + Alt(Opt) + Shift + O — Toggle the statistics overlay\n\nCtrl(Control) + Alt(Opt) + Shift + C — Toggle mouse pointer visibility\n\nBy default, the mouse cannot control the camera in 3D games. To stream games, please disconnect the current session, then go to Settings → Peripheral Section → Local Mouse Cursor, and select “Capture”."
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"zh-Hans" : {
|
||||||
|
"stringUnit" : {
|
||||||
|
"state" : "translated",
|
||||||
|
"value" : "\nVoidLink 桌面模式快捷键:\n\nCtrl(Control) + Alt(Opt) + Shift + D — 断开当前会话\n\nCtrl(Control) + Alt(Opt) + Shift + Q — 断开当前会话并退出当前app\n\nCtrl(Control) + Alt(Opt) + Shift + S — 展开设置菜单\n\nCtrl(Control) + Alt(Opt) + Shift + O — 切换性能信息叠加\n\nCtrl(Control) + Alt(Opt) + Shift + C — 切换鼠标指针可见性\n\n默认状态下鼠标无法在3D游戏中转动视角。如需串流游戏,请断开当前会话,前往设置菜单 -> 外设分区 -> 本地鼠标指针,选择“被窗口捕获”。"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"zh-Hant" : {
|
||||||
|
"stringUnit" : {
|
||||||
|
"state" : "translated",
|
||||||
|
"value" : "\nVoidLink 桌面模式快速鍵:\n\nCtrl(Control) + Alt(Opt) + Shift + D — 中斷目前連線\n\nCtrl(Control) + Alt(Opt) + Shift + Q — 中斷目前連線並退出目前app\n\nCtrl(Control) + Alt(Opt) + Shift + S — 展開設定選單\n\nCtrl(Control) + Alt(Opt) + Shift + O — 切換統計資訊覆蓋\n\nCtrl(Control) + Alt(Opt) + Shift + C — 切換滑鼠指標可見性\n\n預設狀態下,滑鼠無法在 3D 遊戲中轉動視角。如需進行串流遊戲,請中斷目前會話,前往設定選單 → 外設分區 → 本地滑鼠指標,選擇「被視窗捕獲」。"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"zh-HK" : {
|
||||||
|
"stringUnit" : {
|
||||||
|
"state" : "translated",
|
||||||
|
"value" : "\nVoidLink 桌面模式快速鍵:\n\nCtrl(Control) + Alt(Opt) + Shift + D — 中斷目前連線\n\nCtrl(Control) + Alt(Opt) + Shift + Q — 中斷目前連線並退出目前app\n\nCtrl(Control) + Alt(Opt) + Shift + S — 展開設定選單\n\nCtrl(Control) + Alt(Opt) + Shift + O — 切換統計資訊覆蓋\n\nCtrl(Control) + Alt(Opt) + Shift + C — 切換滑鼠指標可見性\n\n預設狀態下,滑鼠無法在 3D 遊戲中轉動視角。如需進行串流遊戲,請中斷目前會話,前往設定選單 → 外設分區 → 本地滑鼠指標,選擇「被視窗捕獲」。"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"Label alpha" : {
|
"Label alpha" : {
|
||||||
"extractionState" : "manual",
|
"extractionState" : "manual",
|
||||||
"localizations" : {
|
"localizations" : {
|
||||||
@@ -7554,35 +7606,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"macFirstLaunchTip" : {
|
|
||||||
"extractionState" : "manual",
|
|
||||||
"localizations" : {
|
|
||||||
"en" : {
|
|
||||||
"stringUnit" : {
|
|
||||||
"state" : "translated",
|
|
||||||
"value" : "\nKeyboard Shortcuts for VoidLink (Desktop Mode):\n\nCtrl + Alt + Shift + D — Disconnect the current session\n\nCtrl + Alt + Shift + Q — Disconnect the current session and quit current app\n\nCtrl + Alt + Shift + S — Expand the settings menu\n\nCtrl + Alt + Shift + O — Toggle the statistics overlay\n\nCtrl + Alt + Shift + C — Toggle mouse pointer visibility\n\nBy default, the mouse cannot control the camera in 3D games. To stream games, please disconnect the current session, then go to Settings → Peripheral Section → Local Mouse Cursor, and select “Capture”."
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"zh-Hans" : {
|
|
||||||
"stringUnit" : {
|
|
||||||
"state" : "translated",
|
|
||||||
"value" : "\nVoidLink 桌面模式快捷键:\n\nCtrl + Alt + Shift + D — 断开当前会话\n\nCtrl + Alt + Shift + Q — 断开当前会话并退出当前app\n\nCtrl + Alt + Shift + S — 展开设置菜单\n\nCtrl + Alt + Shift + O — 切换性能信息叠加\n\nCtrl + Alt + Shift + C — 切换鼠标指针可见性\n\n默认状态下鼠标无法在3D游戏中转动视角。如需串流游戏,请断开当前会话,前往设置菜单 -> 外设分区 -> 本地鼠标指针,选择“被窗口捕获”。"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"zh-Hant" : {
|
|
||||||
"stringUnit" : {
|
|
||||||
"state" : "translated",
|
|
||||||
"value" : "\nVoidLink 桌面模式快速鍵:\n\nCtrl + Alt + Shift + D — 中斷目前連線\n\nCtrl + Alt + Shift + Q — 中斷目前連線並退出目前app\n\nCtrl + Alt + Shift + S — 展開設定選單\n\nCtrl + Alt + Shift + O — 切換統計資訊覆蓋\n\nCtrl + Alt + Shift + C — 切換滑鼠指標可見性\n\n預設狀態下,滑鼠無法在 3D 遊戲中轉動視角。如需進行串流遊戲,請中斷目前會話,前往設定選單 → 外設分區 → 本地滑鼠指標,選擇「被視窗捕獲」。"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"zh-HK" : {
|
|
||||||
"stringUnit" : {
|
|
||||||
"state" : "translated",
|
|
||||||
"value" : "\nVoidLink 桌面模式快速鍵:\n\nCtrl + Alt + Shift + D — 中斷目前連線\n\nCtrl + Alt + Shift + Q — 中斷目前連線並退出目前app\n\nCtrl + Alt + Shift + S — 展開設定選單\n\nCtrl + Alt + Shift + O — 切換統計資訊覆蓋\n\nCtrl + Alt + Shift + C — 切換滑鼠指標可見性\n\n預設狀態下,滑鼠無法在 3D 遊戲中轉動視角。如需進行串流遊戲,請中斷目前會話,前往設定選單 → 外設分區 → 本地滑鼠指標,選擇「被視窗捕獲」。"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Magnifier" : {
|
"Magnifier" : {
|
||||||
"extractionState" : "manual",
|
"extractionState" : "manual",
|
||||||
"localizations" : {
|
"localizations" : {
|
||||||
|
|||||||
@@ -8,9 +8,49 @@
|
|||||||
|
|
||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
import GameController
|
||||||
import UIKit
|
import UIKit
|
||||||
|
|
||||||
@objc public class GenericUtils: NSObject {
|
@objc public class GenericUtils: NSObject {
|
||||||
|
|
||||||
|
@objc static var hardwareKeyboardAlreadyDetected: Bool = false
|
||||||
|
|
||||||
|
@objc static func isHardwareKeyboardConnected() -> Bool {
|
||||||
|
if #available(iOS 14.0, tvOS 14.0, *) {
|
||||||
|
hardwareKeyboardAlreadyDetected = GCKeyboard.coalesced != nil
|
||||||
|
return GCKeyboard.coalesced != nil
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc static func isFirstHardwareKeyboardOrMouseConnection() -> Bool {
|
||||||
|
let key = "hasConnectedHardwareKeyboardOrMouse"
|
||||||
|
guard !UserDefaults.standard.bool(forKey: key) else {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
UserDefaults.standard.set(true, forKey: key)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc static func handleKeyboardOrMouseConnectionTip(in vc: UIViewController) {
|
||||||
|
if isRunningOnMacAsiPadApp {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if hardwareKeyboardAlreadyDetected {
|
||||||
|
_ = isFirstHardwareKeyboardOrMouseConnection()
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if isFirstHardwareKeyboardOrMouseConnection() {
|
||||||
|
AlertControllerUtil.showAlert(
|
||||||
|
in: vc,
|
||||||
|
title: SwiftLocalizationHelper.localizedString(forKey: "Keyboard/Mouse Connected"),
|
||||||
|
message: SwiftLocalizationHelper.localizedString(forKey:"keyboard&MouseStreamingTip"),
|
||||||
|
withCancel: false,
|
||||||
|
buttonTitle: SwiftLocalizationHelper.localizedString(forKey: "This tip won't be shown again"),
|
||||||
|
countdown: 11,
|
||||||
|
completion: {})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@objc static func needUpdateDefaultSettings() -> Bool {
|
@objc static func needUpdateDefaultSettings() -> Bool {
|
||||||
// let key = "needUpdateDefaultSettings20260226-1"
|
// let key = "needUpdateDefaultSettings20260226-1"
|
||||||
|
|||||||
@@ -748,6 +748,18 @@
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
- (void)popKeyboardAndMouseStreamingTip {
|
||||||
|
[AlertControllerUtil showAlertIn:self
|
||||||
|
title:[LocalizationHelper localizedStringForKey:@"Keyboard/Mouse Connected"]
|
||||||
|
message:[LocalizationHelper localizedStringForKey:@"keyboard&MouseStreamingTip"]
|
||||||
|
withCancel:NO
|
||||||
|
buttonTitle:[LocalizationHelper localizedStringForKey:@"This tip won't be shown again"]
|
||||||
|
countdown:5
|
||||||
|
action:^{}
|
||||||
|
completion:^{
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
|
||||||
- (void)popFirstStreamingTip {
|
- (void)popFirstStreamingTip {
|
||||||
// 初始化倒计时秒数
|
// 初始化倒计时秒数
|
||||||
|
|
||||||
@@ -756,17 +768,19 @@
|
|||||||
uint8_t slideDist = (uint8_t)(_settings.slideToSettingsDistance.floatValue * 100);
|
uint8_t slideDist = (uint8_t)(_settings.slideToSettingsDistance.floatValue * 100);
|
||||||
// 创建弹窗
|
// 创建弹窗
|
||||||
NSString* tipText = (GenericUtils.isRunningOnMacAsiPadApp
|
NSString* tipText = (GenericUtils.isRunningOnMacAsiPadApp
|
||||||
? [LocalizationHelper localizedStringForKey:@"macFirstLaunchTip"]
|
? [LocalizationHelper localizedStringForKey:@"keyboard&MouseStreamingTip"]
|
||||||
: [LocalizationHelper localizedStringForKey:@"firstLaunchTip", settingsEdgeSide, slideDist, cmdToolEdgeSide, slideDist]) ;
|
: [LocalizationHelper localizedStringForKey:@"firstLaunchTip", settingsEdgeSide, slideDist, cmdToolEdgeSide, slideDist]);
|
||||||
|
|
||||||
[AlertControllerUtil showAlertIn:self
|
[AlertControllerUtil showAlertIn:self
|
||||||
title:[LocalizationHelper localizedStringForKey:@"First Launch Tips"]
|
title:[LocalizationHelper localizedStringForKey:@"First Launch Tips"]
|
||||||
message:tipText
|
message:tipText
|
||||||
withCancel:NO
|
withCancel:NO
|
||||||
buttonTitle:[LocalizationHelper localizedStringForKey:@"Got it!"]
|
buttonTitle:[LocalizationHelper localizedStringForKey:@"This tip won't be shown again"]
|
||||||
countdown:16
|
countdown:16
|
||||||
action:^{}
|
action:^{}
|
||||||
completion:^{}];
|
completion:^{
|
||||||
|
if(!GenericUtils.isRunningOnMacAsiPadApp && GenericUtils.isHardwareKeyboardConnected) [self popKeyboardAndMouseStreamingTip];
|
||||||
|
}];
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -903,7 +917,7 @@
|
|||||||
selector:@selector(gameProfileSelectorClosed)
|
selector:@selector(gameProfileSelectorClosed)
|
||||||
name:@"GameProfileSelectorCloseNotification"
|
name:@"GameProfileSelectorCloseNotification"
|
||||||
object:nil];
|
object:nil];
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
// FIXME: This doesn't work reliably on iPad for some reason. Showing and hiding the keyboard
|
// FIXME: This doesn't work reliably on iPad for some reason. Showing and hiding the keyboard
|
||||||
// several times in a row will not correctly restore the state of the UIScrollView.
|
// several times in a row will not correctly restore the state of the UIScrollView.
|
||||||
@@ -1819,6 +1833,14 @@
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)keyboardConnected {
|
||||||
|
[GenericUtils handleKeyboardOrMouseConnectionTipIn:self];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)mouseConnected {
|
||||||
|
[GenericUtils handleKeyboardOrMouseConnectionTipIn:self];
|
||||||
|
}
|
||||||
|
|
||||||
- (void)mousePresenceChanged {
|
- (void)mousePresenceChanged {
|
||||||
#if !TARGET_OS_TV
|
#if !TARGET_OS_TV
|
||||||
if (@available(iOS 14.0, *)) {
|
if (@available(iOS 14.0, *)) {
|
||||||
|
|||||||
Reference in new issue
Block a user