利用树莓派模拟switch的Joycon
准备
1. 项目地址
Github: https://github.com/mart1nro/joycontrol
- 可以模仿joycon L,joycon R,Pro手柄
- 模拟摇杆
- 读取nfc数据
使用git直接下载到树莓派或者下载到本地再上传
共有这些文件
2. 安装依赖
sudo apt install python3-dbus libhidapi-hidraw0
sudo pip3 install aioconsole
sudo pip3 install hid
sudo pip3 install crc8
使用
注意
根据问题描述,我们需要disable掉bluez的"input" plugin
编辑bluetooh的文件
sudo vim /lib/systemd/system/bluetooth.service
将其中的ExecStart
项改为
ExecStart=/usr/lib/bluetooth/bluetoothd --noplugin=input
保存并退出,然后
sudo systemctl daemon-reload
sudo systemctl restart bluetooth
这么连接后,我们就能够连接switch,但是这个时候,我们便不可以连接到其他蓝牙设备,解决办法就是将ExecStart
项复原再重启
运行
# 参数为"JOYCON_R", "JOYCON_L" or "PRO_CONTROLLER"
sudo python3 run_controller_cli.py PRO_CONTROLLER
此时打开switch设置中的更改握把/顺序
,等待模拟手柄连接
可以看到弹出匹配成功
连接完成后,按回车
此时可以输入指令,可以按help查看可以输入哪些指令
测试
输入
显示
nfc
如果要使用nfc,只需要上传nfc卡数据后,输入
nfc file_path
编写自己的脚本
也可以利用joycontrol模块来构建自己的自动化脚本,之后有时间可以尝试下
Comments | 7 条评论