From 66be3351028f92df3e118e6d6799023b6bc69ce5 Mon Sep 17 00:00:00 2001 From: ChestnutLUO Date: Thu, 8 Jan 2026 22:56:53 -0800 Subject: [PATCH] feat: Add WDA (WebDriverAgent) touch mode support Add WDA as a new touch mode option for controlling real iOS devices via WebDriverAgent HTTP API. Co-Authored-By: Claude Opus 4.5 --- MeoAsstMac/Model/MAAViewModel.swift | 7 +++- .../Settings/ConnectionSettingsView.swift | 6 +++ Resources/Localizable.xcstrings | 42 ++++++++++++------- 3 files changed, 38 insertions(+), 17 deletions(-) diff --git a/MeoAsstMac/Model/MAAViewModel.swift b/MeoAsstMac/Model/MAAViewModel.swift index 27e4c2b94..86ba4a1d5 100644 --- a/MeoAsstMac/Model/MAAViewModel.swift +++ b/MeoAsstMac/Model/MAAViewModel.swift @@ -118,6 +118,9 @@ import SwiftUI if touchMode == .MacPlayTools { useAdbLite = false connectionProfile = "CompatMac" + } else if touchMode == .WDA { + useAdbLite = false + connectionProfile = "CompatMac" } else { useAdbLite = true } @@ -227,6 +230,8 @@ extension MAAViewModel { logTrace("ConnectingToEmulator") if touchMode == .MacPlayTools { logTrace("如果长时间连接不上或出错,请尝试下载使用“文件” > “PlayCover链接…”中的最新版本") + } else if touchMode == .WDA { + logTrace("正在通过 WebDriverAgent 连接,请确保 WDA 已在 iOS 设备上运行") } try await handle?.connect(adbPath: adbPath, address: connectionAddress, profile: connectionProfile) logTrace("Running") @@ -282,7 +287,7 @@ extension MAAViewModel { private func loadResource(url: URL) async throws { try await MAAProvider.shared.loadResource(path: url.path) - if touchMode == .MacPlayTools { + if touchMode == .MacPlayTools || touchMode == .WDA { let platformResource = url.appendingPathComponent("resource") .appendingPathComponent("platform_diff") .appendingPathComponent("iOS") diff --git a/MeoAsstMac/Settings/ConnectionSettingsView.swift b/MeoAsstMac/Settings/ConnectionSettingsView.swift index ee7803f4e..84bc524a0 100644 --- a/MeoAsstMac/Settings/ConnectionSettingsView.swift +++ b/MeoAsstMac/Settings/ConnectionSettingsView.swift @@ -23,6 +23,11 @@ struct ConnectionSettingsView: View { .font(.caption).foregroundStyle(.secondary) } + if viewModel.touchMode == .WDA { + Text("使用 WebDriverAgent 连接真实 iOS 设备。请确保 WDA 已在设备上运行(默认端口 8100)。") + .font(.caption).foregroundStyle(.secondary) + } + HStack { Text("连接地址") TextField("", text: $viewModel.connectionAddress) @@ -75,4 +80,5 @@ enum MaaTouchMode: String, CaseIterable { case minitouch case maatouch case MacPlayTools + case WDA } diff --git a/Resources/Localizable.xcstrings b/Resources/Localizable.xcstrings index c18c93d8b..8f18847bb 100644 --- a/Resources/Localizable.xcstrings +++ b/Resources/Localizable.xcstrings @@ -295,22 +295,6 @@ } } }, - "CombatOps" : { - "localizations" : { - "ko" : { - "stringUnit" : { - "state" : "translated", - "value" : "스테이지: 일반 작전" - } - }, - "zh-Hans" : { - "stringUnit" : { - "state" : "translated", - "value" : "关卡:普通作战" - } - } - } - }, "CDK" : { "shouldTranslate" : false }, @@ -378,6 +362,22 @@ } } }, + "CombatOps" : { + "localizations" : { + "ko" : { + "stringUnit" : { + "state" : "translated", + "value" : "스테이지: 일반 작전" + } + }, + "zh-Hans" : { + "stringUnit" : { + "state" : "translated", + "value" : "关卡:普通作战" + } + } + } + }, "CompleteCombat" : { "localizations" : { "ko" : { @@ -1998,6 +1998,9 @@ } } } + }, + "使用 WebDriverAgent 连接真实 iOS 设备。请确保 WDA 已在设备上运行(默认端口 8100)。" : { + }, "使用密文板" : { "localizations" : { @@ -2800,8 +2803,12 @@ } } } + }, + "如果长时间连接不上或出错,请尝试下载使用\"文件\" > \"PlayCover链接…\"中的最新版本" : { + }, "如果长时间连接不上或出错,请尝试下载使用“文件” > “PlayCover链接…”中的最新版本" : { + "extractionState" : "stale", "localizations" : { "ko" : { "stringUnit" : { @@ -3670,6 +3677,9 @@ } } } + }, + "正在通过 WebDriverAgent 连接,请确保 WDA 已在 iOS 设备上运行" : { + }, "每次执行时最大招募次数: " : { "localizations" : {