vita_gamepad/docs/protocol.md

29 lines
1.1 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Vita Gamepad 网络协议 v1
电脑每秒向 UDP `5001` 广播一次 ASCII 文本 `VGPD_HOST_V1`。Vita 收到后,将该
数据包的来源 IP 作为接收端,并向其 UDP `5000` 端口发送输入包。
所有多字节整数均为网络字节序。输入包固定为 20 字节:
| 偏移 | 大小 | 字段 | 含义 |
|---:|---:|---|---|
| 0 | 4 | magic | `VGPD` |
| 4 | 1 | version | `1` |
| 5 | 1 | flags | 保留,当前为 0 |
| 6 | 2 | size | `20` |
| 8 | 4 | sequence | 每包递增,允许 32 位回绕 |
| 12 | 2 | buttons | 按键位图 |
| 14 | 1 | lx | 左摇杆 X0255中心 128 |
| 15 | 1 | ly | 左摇杆 Y0255中心 128 |
| 16 | 1 | rx | 右摇杆 X0255中心 128 |
| 17 | 1 | ry | 右摇杆 Y0255中心 128 |
| 18 | 1 | lt | 左扳机0255 |
| 19 | 1 | rt | 右扳机0255 |
按键位从低到高依次为A、B、X、Y、LB、RB、Back、Start、L3、R3、Up、
Down、Left、Right第 14、15 位保留。
协议不包含鉴权或加密,设计用途是可信的家庭局域网。可在电脑端使用
`--allow <Vita IP>` 限制来源。