inputAccessoryBar for soft keyboard

This commit is contained in:
True Zhuanjia committed 2026-04-24 22:59:37 +08:00
1 parent 7e21292a62
commit e78a351c28
15 files changed
+1640 -46

No files matched your search

+1 -1
View File
@@ -3100,7 +3100,7 @@
<segments>
<segment title="slide-toggle"/>
<segment title="slide-hold"/>
<segment title="regular"/>
<segment title="normal"/>
<segment title="tap to toggle"/>
<segment title="movable"/>
</segments>
+6 -6
View File
@@ -794,7 +794,7 @@
<segments>
<segment title="slide-toggle"/>
<segment title="slide-hold"/>
<segment title="regular"/>
<segment title="normal"/>
<segment title="tap to toggle"/>
<segment title="movable"/>
</segments>
@@ -3556,19 +3556,19 @@
<image name="trash.fill" catalog="system" width="117" height="128"/>
<image name="tray.full.fill" catalog="system" width="128" height="88"/>
<systemColor name="linkColor">
<color red="0.0" green="0.47843137254901963" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color red="0.0" green="0.47843137250000001" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</systemColor>
<systemColor name="systemBrownColor">
<color red="0.67450980392156867" green="0.49803921568627452" blue="0.36862745098039218" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color red="0.63529411759999999" green="0.51764705879999995" blue="0.36862745099999999" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</systemColor>
<systemColor name="systemGray2Color">
<color red="0.68235294117647061" green="0.68235294117647061" blue="0.69803921568627447" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color red="0.68235294120000001" green="0.68235294120000001" blue="0.69803921570000005" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</systemColor>
<systemColor name="systemGray3Color">
<color red="0.7803921568627451" green="0.7803921568627451" blue="0.80000000000000004" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color red="0.78039215689999997" green="0.78039215689999997" blue="0.80000000000000004" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</systemColor>
<systemColor name="systemTealColor">
<color red="0.0" green="0.76470588235294112" blue="0.81568627450980391" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color red="0.18823529410000001" green="0.69019607839999997" blue="0.78039215689999997" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</systemColor>
</resources>
</document>
File diff suppressed because it is too large. Load diff
-13
View File
@@ -489,19 +489,6 @@ final class PressureCurveLUT {
}
}
extension UIView {
var parentViewController: UIViewController? {
var responder: UIResponder? = self
while let r = responder {
if let vc = r as? UIViewController {
return vc
}
responder = r.next
}
return nil
}
}
// MARK: - ViewController
class PressureCurveViewController: UIViewController, UIGestureRecognizerDelegate {
+2 -2
View File
@@ -31,7 +31,7 @@
#if TARGET_OS_TV
@interface StreamView : UIView <X1KitMouseDelegate, UITextFieldDelegate>
#else
@interface StreamView : UIView <X1KitMouseDelegate, UITextFieldDelegate, UIPointerInteractionDelegate>
@interface StreamView : UIView <X1KitMouseDelegate, UITextFieldDelegate, UIPointerInteractionDelegate, InputAccessoryBarDelegate>
#endif
@property (weak, nonatomic) UIView* streamFrameTopLayerView;
@@ -73,7 +73,7 @@
- (void)readyToBringUpSoftKeyboardByToolbox;
- (void)keyboardWillShow:(NSNotification *)notification;
- (void)keyboardWillHide;
- (void)handleAbnormalKeyboards:(NSNotification *)notification;
- (void)handleNonStandardKeyboard:(NSNotification *)notification;
- (void)liftMetalVideoViewIfNeeded:(CGFloat)liftHeight;
- (void)alterAbsTouchDragWith:(int32_t)mouseButton;
+35 -4
View File
@@ -270,7 +270,7 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
CGRect keyboardFrame = [userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue];
CGFloat screenHeight = GenericUtils.screenHeight;
CGFloat totalKeyboardHeight = keyboardFrame.size.height;
CGFloat toolbarHeight = settings.showKeyboardToolbar ? GenericUtils.legacyToolbarHeight : 0;
CGFloat toolbarHeight = settings.showKeyboardToolbar ? GenericUtils.inputAccessoryBarHeight : 0;
if(totalKeyboardHeight < screenHeight * 0.33333333333 + toolbarHeight
|| totalKeyboardHeight > screenHeight*0.8 + toolbarHeight){
@@ -311,7 +311,18 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
NSLog(@"keyboard will show %f", CACurrentMediaTime());
}
- (void)handleAbnormalKeyboards:(NSNotification *)notification{
- (void)handleNonStandardKeyboard:(NSNotification *)notification{
if(!self->dockedKeyboardActionDetected){
[self->keyboardToggleTip removeFromSuperview];
[self refreshKeyboardToggleRecognizer:settings.keyboardToggleFingers.intValue];
self->dockedKeyboardActionDetected = false;
self->isInputingText = !self->isInputingText;
}
return;
/*
dispatch_time_t delayTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.05 * NSEC_PER_SEC));
dispatch_after(delayTime, dispatch_get_main_queue(), ^{// Code to execute after the delay
if(!self->dockedKeyboardActionDetected){
@@ -332,6 +343,7 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
}
});
*/
}
- (UIViewController *)parentViewController {
@@ -347,6 +359,11 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
// this method also deals with recovering streamview when local keyboard is turned off
- (void)keyboardWillHide{
if (@available(iOS 13.0, *)) {
InputAccessoryBar* bar = (InputAccessoryBar* ) keyInputField.inputAccessoryView;
if(bar) [bar releasePressedKeys];
}
dockedKeyboardActionDetected = true;
// NSLog(@"keyboard will hide markmark %f", CACurrentMediaTime());
@@ -459,7 +476,16 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
[customToolbarView sendSubviewToBack:glassView];
}
}
keyInputField.inputAccessoryView = customToolbarView;
if (@available(iOS 13.0, *)) {
InputAccessoryBar *barView = [[InputAccessoryBar alloc] initWithFrame:CGRectMake(0, 0, self.bounds.size.width, GenericUtils.inputAccessoryBarHeight)];
barView.delegate = self;
keyInputField.inputAccessoryView = barView;
}
else {
keyInputField.inputAccessoryView = customToolbarView;
}
}
#endif
[keyInputField becomeFirstResponder];
@@ -645,7 +671,7 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
MotionHandler* motionHandler = [MotionHandler sharedWithProfile:profile];
// get streamFrameVC
if(!self->_streamFrameVC) self->_streamFrameVC = [self parentViewController];
if(!self->_streamFrameVC) self->_streamFrameVC = [GenericUtils parentViewControllerForView:self];
/*
if (@available(iOS 13.0, *)) {
@@ -1481,6 +1507,11 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
[keysDown removeAllObjects];
}
- (void)inputAccessoryBarDidTapClose:(InputAccessoryBar *)bar API_AVAILABLE(ios(13.0)){
[keyInputField resignFirstResponder];
isInputingText = false;
}
- (void)onKeyboardPressed:(UITextField *)textField {
if (textField.markedTextRange) return;
@@ -21,6 +21,11 @@
<attribute name="uuid" optional="YES" attributeType="String" syncable="YES"/>
<relationship name="appList" optional="YES" toMany="YES" deletionRule="Cascade" destinationEntity="App" inverseName="host" inverseEntity="App" syncable="YES"/>
</entity>
<entity name="InputAccessoryBarButton" representedClassName="InputAccessoryBarButton" syncable="YES" codeGenerationType="class">
<attribute name="buttonLabel" optional="YES" attributeType="String" syncable="YES"/>
<attribute name="cmdString" optional="YES" attributeType="String" syncable="YES"/>
<attribute name="index" optional="YES" attributeType="Integer 32" defaultValueString="0" usesScalarValueType="NO" syncable="YES"/>
</entity>
<entity name="Settings" representedClassName="Settings" syncable="YES" codeGenerationType="class">
<attribute name="appTheme" optional="YES" attributeType="Integer 16" defaultValueString="0" usesScalarValueType="NO" syncable="YES"/>
<attribute name="asyncFrameDequeue" attributeType="Boolean" defaultValueString="YES" usesScalarValueType="YES" syncable="YES"/>
@@ -111,4 +116,4 @@
<attribute name="useBuiltinMic" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES" syncable="YES"/>
<attribute name="width" attributeType="Integer 32" defaultValueString="1280" usesScalarValueType="NO" syncable="YES"/>
</entity>
</model>
</model>
+124
View File
@@ -2401,6 +2401,29 @@
}
}
},
"Button mode" : {
"extractionState" : "manual",
"localizations" : {
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "按键模式"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
"value" : "按鍵模式"
}
},
"zh-HK" : {
"stringUnit" : {
"state" : "translated",
"value" : "按鍵模式"
}
}
}
},
"Calibrating..." : {
"extractionState" : "manual",
"localizations" : {
@@ -6105,6 +6128,35 @@
}
}
},
"inputAccessoryBarTip" : {
"extractionState" : "manual",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "After long-pressing any button for 2 seconds, you can drag to reorder buttons or delete them."
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "needs_review",
"value" : "长按任意按键2秒后,可拖拽调整按键顺序、删除按键"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "needs_review",
"value" : "長按任意按鍵2秒後,可拖曳調整按鍵順序、刪除按鍵"
}
},
"zh-HK" : {
"stringUnit" : {
"state" : "needs_review",
"value" : "長按任意按鍵2秒後,可拖曳調整按鍵順序、刪除按鍵"
}
}
}
},
"Interval of Multi-Touch Move Events: %d μs" : {
"extractionState" : "manual",
"localizations" : {
@@ -7580,6 +7632,29 @@
}
}
},
"Normal" : {
"extractionState" : "manual",
"localizations" : {
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "常规"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
"value" : "常規"
}
},
"zh-HK" : {
"stringUnit" : {
"state" : "translated",
"value" : "常規"
}
}
}
},
"Nothing to Undo" : {
"extractionState" : "manual",
"localizations" : {
@@ -9565,6 +9640,9 @@
}
}
},
"Regular" : {
"extractionState" : "manual"
},
"relativeTouchSlideThresholdStackLink" : {
"extractionState" : "manual",
"localizations" : {
@@ -11005,6 +11083,29 @@
}
}
},
"Soft Keyboard Toolbar" : {
"extractionState" : "manual",
"localizations" : {
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "软键盘工具栏"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
"value" : "軟鍵盤工具欄"
}
},
"zh-HK" : {
"stringUnit" : {
"state" : "translated",
"value" : "軟鍵盤工具欄"
}
}
}
},
"SoftKeyboard" : {
"extractionState" : "manual",
"localizations" : {
@@ -11605,6 +11706,29 @@
}
}
},
"Tap to toggle" : {
"extractionState" : "manual",
"localizations" : {
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "点按切换"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
"value" : "點按切換"
}
},
"zh-HK" : {
"stringUnit" : {
"state" : "translated",
"value" : "點按切換"
}
}
}
},
"Tap where you're going to input text, view will be lifted automatically " : {
"extractionState" : "manual",
"localizations" : {
+46
View File
@@ -8,6 +8,7 @@
import Foundation
import UIKit
@objc public class GenericUtils: NSObject {
@@ -65,6 +66,18 @@ import Foundation
}
return false
}
@objc static func isFirstTappingInputAccessoryBar() -> Bool {
let key = "isFirstTappingInputAccessoryBar"
let defaults = UserDefaults.standard
let launchedBefore = defaults.bool(forKey: key)
if !launchedBefore {
defaults.set(true, forKey: key)
return true
}
return false
}
@objc static func gamepadOverlayFeatureTipTitle() -> String {
SwiftLocalizationHelper.localizedString(forKey: "Gamepad Overlay")
@@ -102,6 +115,13 @@ import Foundation
return 44
}
@objc static var inputAccessoryBarHeight: CGFloat {
if #available(iOS 13.0, *){
return GenericUtils.isIPhone() ? 46 : 55
}
else {return 44}
}
@objc static var hostViewNavigationBarHeight: CGFloat {
switch UIDevice.current.userInterfaceIdiom {
case .phone:
@@ -248,4 +268,30 @@ import Foundation
@objc static var screenHeight: CGFloat {
return UIScreen.main.bounds.height
}
@objc(parentViewControllerForView:)
static func parentViewController(for view: UIView?) -> UIViewController? {
var responder: UIResponder? = view
while let currentResponder = responder {
if let viewController = currentResponder as? UIViewController {
return viewController
}
responder = currentResponder.next
}
return nil
}
}
extension UIView {
var parentViewController: UIViewController? {
var responder: UIResponder? = self
while let r = responder {
if let vc = r as? UIViewController {
return vc
}
responder = r.next
}
return nil
}
}
@@ -542,7 +542,7 @@
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(handleAbnormalKeyboards:)
selector:@selector(handleNonStandardKeyboard:)
name:UIKeyboardWillChangeFrameNotification
object:nil];
@@ -768,7 +768,7 @@
}
- (void)handleAbnormalKeyboards:(NSNotification *)notification{
[_streamView handleAbnormalKeyboards:notification];
[_streamView handleNonStandardKeyboard:notification];
}
- (void)handleWidgetLayoutGesture{
+5 -5
View File
@@ -2276,30 +2276,30 @@
}
},
"cKS-fy-Zpg.segmentTitles[2]" : {
"comment" : "Class = \"UISegmentedControl\"; cKS-fy-Zpg.segmentTitles[2] = \"regular\"; ObjectID = \"cKS-fy-Zpg\";",
"comment" : "Class = \"UISegmentedControl\"; cKS-fy-Zpg.segmentTitles[2] = \"normal\"; ObjectID = \"cKS-fy-Zpg\";",
"extractionState" : "extracted_with_value",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "new",
"value" : "regular"
"value" : "normal"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"state" : "needs_review",
"value" : "常规模式"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
"state" : "needs_review",
"value" : "一般模式"
}
},
"zh-HK" : {
"stringUnit" : {
"state" : "translated",
"state" : "needs_review",
"value" : "一般模式"
}
}
+5 -5
View File
@@ -4178,30 +4178,30 @@
}
},
"ojp-aS-m8w.segmentTitles[2]" : {
"comment" : "Class = \"UISegmentedControl\"; ojp-aS-m8w.segmentTitles[2] = \"regular\"; ObjectID = \"ojp-aS-m8w\";",
"comment" : "Class = \"UISegmentedControl\"; ojp-aS-m8w.segmentTitles[2] = \"normal\"; ObjectID = \"ojp-aS-m8w\";",
"extractionState" : "extracted_with_value",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "new",
"value" : "regular"
"value" : "normal"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"state" : "needs_review",
"value" : "常规模式"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
"state" : "needs_review",
"value" : "一般模式"
}
},
"zh-HK" : {
"stringUnit" : {
"state" : "translated",
"state" : "needs_review",
"value" : "一般模式"
}
}