# simulator_input

> 这个 MCP 工具向团队的模拟器发送一个原始输入事件，用于其他输入工具无法实现的手势。

Source: https://air.build/cn/docs/mcp-tools/simulator_input/

`simulator_input` 向团队正在运行的模拟器发送一个原始输入事件。用它来做其他工具做不到的事：跨多次调用保持按下的触摸、双指捏合，或从屏幕边缘轻扫进入。一个完整手势由多个事件组成（按下、一次或多次移动、抬起），所以请按顺序发送，或作为 [simulator_batch](https://air.build/cn/docs/mcp-tools/simulator_batch/) 的 `input` 步骤一起发送。点使用 [屏幕坐标](https://air.build/cn/docs/mcp-tools/simulator_screen/#coordinates)，不会与元素进行核对。日常的点按、轻扫、输入和按钮，请优先使用为它们设计的工具。

| 只读 | 破坏性 | 幂等 |
| --- | --- | --- |
| 否 | 否 | 否 |

## 事件

`event` 是一个对象，包含 `type` 以及该类型的字段：

| `type` | 字段 | 作用 |
| --- | --- | --- |
| `touch1-down`, `touch1-move`, `touch1-up`, `touch1-cancel` | `x`、`y`；`edge`（可选） | 单指：按下、移动、抬起或取消。`edge`（例如 `left`、`bottom`）会使它成为从屏幕该边缘轻扫进入 |
| `touch2-down`, `touch2-move`, `touch2-up`, `touch2-cancel` | `x1`, `y1`, `x2`, `y2` | 同时两根手指，用于捏合或双指旋转 |
| `tap` | `x`、`y`；`duration`（可选） | 点按，与使用坐标的 [simulator_tap](https://air.build/cn/docs/mcp-tools/simulator_tap/) 相同 |
| `swipe` | `startX`、`startY`、`endX`、`endY`；`duration`（可选） | 与 [simulator_swipe](https://air.build/cn/docs/mcp-tools/simulator_swipe/) 相同 |
| `type` | `text` | 与 [simulator_type_text](https://air.build/cn/docs/mcp-tools/simulator_type_text/) 相同 |
| `key` | `code`；`modifiers`、`duration`（可选） | 与 [simulator_key](https://air.build/cn/docs/mcp-tools/simulator_key/) 相同 |
| `button` | `button`；`duration`（可选） | 与 [simulator_button](https://air.build/cn/docs/mcp-tools/simulator_button/) 相同 |
| `orientation` | `orientation` | 与 [simulator_rotate](https://air.build/cn/docs/mcp-tools/simulator_rotate/) 相同 |
| `fold` | `degrees`（0 到 180） | 转动折叠设备的铰链，与 [simulator_fold](https://air.build/cn/docs/mcp-tools/simulator_fold/) 相同 |

每个指针事件（`touch1-*`、`touch2-*`、`tap`、`swipe`）还接受可选的 `width` 和 `height`：发送它们后，坐标就以该尺寸的框架为准，而不是设备的屏幕，并会按比例缩放以适配。任何事件都可以带上 `display`，即来自 [simulator_displays](https://air.build/cn/docs/mcp-tools/simulator_displays/) 的显示屏 `screenId`，以指定折叠设备的某一块显示屏。

## 输入

| 输入 | 类型 | 必填 | 默认值 | 作用 |
| --- | --- | --- | --- | --- |
| `teamId` | 字符串（UUID） | 是 | — | 团队，来自 [list_teams](https://air.build/cn/docs/mcp-tools/list_teams/) |
| `simulator` | string | 否 | 团队的默认设备 | 哪种设备，使用 [list_simulators](https://air.build/cn/docs/mcp-tools/list_simulators/#result) 中的 `id` |
| `event` | 带有 `type` 的对象 | 是 | — | [事件](https://air.build/cn/docs/mcp-tools/simulator_input/#events) |

## 结果

| 字段 | 说明 |
| --- | --- |
| `ok` | `true` |

```json
{ "ok": true }
```

## 错误

| 消息 | 何时出现 | 怎么办 |
| --- | --- | --- |
| event is an object with a "type". | 缺少 `event`、它不是对象，或没有 `type` | 发送一个带有 `type` 的对象 |
| Failed to deserialize the JSON body into the target type: _…_ | 未知的 `type`、缺少字段，或字段类型错误 | 修正消息中指出的字段 |

另外还有每个模拟器工具都可能返回的错误：见 [start_simulator](https://air.build/cn/docs/mcp-tools/start_simulator/#device-errors)。

## 示例

从左边缘轻扫进入（返回），分三次调用：

```json
{"name": "simulator_input", "arguments": {"teamId": "00000000-0000-0000-0000-000000000000", "event": {"type": "touch1-down", "x": 2, "y": 400, "edge": "left"}}}
```

```json
{"name": "simulator_input", "arguments": {"teamId": "00000000-0000-0000-0000-000000000000", "event": {"type": "touch1-move", "x": 200, "y": 400, "edge": "left"}}}
```

```json
{"name": "simulator_input", "arguments": {"teamId": "00000000-0000-0000-0000-000000000000", "event": {"type": "touch1-up", "x": 300, "y": 400, "edge": "left"}}}
```
