最近收到Raspberry Pi 5,退役下来一个Raspberry Pi 4,于是打算装上RetroPie来用模拟器打游戏。刚好有两个PS4的Dualshock 4手柄,于是按照官网的文档想通过蓝牙把它们和RetroPie配对。但是不管通过RetroPie自带的蓝牙管理程序,还是Python编写的userspace驱动程序ds4drv,都无法正确进行配对。
研究了一番,终于找到可行的办法:用Raspbian系统的bluetoothctl进行配对。
首先运行bluetoothctl进入命令行模式:
pi@retropie:~ $ sudo bluetoothctl
Agent registered
[bluetooth]#
然后运行以下命令开启配对模式:
[bluetooth]# agent on
Agent is already registered
[bluetooth]# discoverable on
Changing discoverable on succeeded
[CHG] Controller AA:AA:AA:AA:AA:AA Discoverable: yes
[bluetooth]# pairable on
Changing pairable on succeeded
[bluetooth]# default-agent
Default agent request successful
[bluetooth]#
接下来同时hold住DS4手柄的Share和PS按钮,直到LED灯开始快速闪烁,此时手柄进入配对模式。接下来在RetroPie开启scan:
[bluetooth]# scan on
Discovery started
[CHG] Controller AA:AA:AA:AA:AA:AA Discovering: yes
[NEW] Device XX:XX:XX:XX:XX:XX XX-XX-XX-XX-XX-XX
[NEW] Device XX:XX:XX:XX:XX:XX XX-XX-XX-XX-XX-XX
[CHG] Device XX:XX:XX:XX:XX:XX RSSI: -68
[CHG] Device XX:XX:XX:XX:XX:XX TxPower: 5
此时命令行会输出大量探测到的Bluetooth设备及其MAC地址,找到其中DS4手柄的MAC地址(名称一般为“Wireless Controller”):
[NEW] Device XX:XX:XX:XX:XX:XX Wireless Controller
找到对应的MAC地址后,运行以下命令尝试连接:
[bluetooth]# connect XX:XX:XX:XX:XX:XX
Attempting to connect to XX:XX:XX:XX:XX:XX
[CHG] Device XX:XX:XX:XX:XX:XX Connected: yes
Connection successful
接下来把已连接的设备加入信任列表,以便之后在每次打开手柄时都能自动连接:
[bluetooth]# trust XX:XX:XX:XX:XX:XX
Changing XX:XX:XX:XX:XX:XX trust succeeded
完成之后重启RetroPie,每次打开DS4手柄时应该就可以自动连接了。此时尚需按照正常流程对DS4手柄按键进行配置:
