利用树莓派模拟switch的Joycon

利用树莓派模拟switch的Joycon

请注意,本文编写于  998  天前,最后编辑于  979  天前,内容可能已经不具有时效性,请谨慎参考。

利用树莓派模拟switch的Joycon

准备

1. 项目地址

Github: https://github.com/mart1nro/joycontrol

  • 可以模仿joycon L,joycon R,Pro手柄
  • 模拟摇杆
  • 读取nfc数据

使用git直接下载到树莓派或者下载到本地再上传
image.png
共有这些文件

2. 安装依赖

sudo apt install python3-dbus libhidapi-hidraw0
sudo pip3 install aioconsole
sudo pip3 install hid
sudo pip3 install crc8

使用

注意

Issue:https://github.com/mart1nro/joycontrol/issues/8
根据问题描述,我们需要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

image.png
此时打开switch设置中的更改握把/顺序,等待模拟手柄连接
QQ图片20200705202826.jpg
可以看到弹出匹配成功
image.png
连接完成后,按回车
image.png
此时可以输入指令,可以按help查看可以输入哪些指令
image.png

测试

输入
image.png
显示
image.png

nfc

如果要使用nfc,只需要上传nfc卡数据后,输入

nfc file_path

编写自己的脚本

也可以利用joycontrol模块来构建自己的自动化脚本,之后有时间可以尝试下