RetroPie 和蓝牙配置
RetroPie and Bluetooth configuration
我有一个 Raspberry Pi 3B+ 运行ning RetroPie 并且正在尝试将我的 PS3 控制器设置为始终 运行 在 'slave' 模式下以减少延迟问题。我从这个 post 得到了灵感。我在 运行 命令后进行了测试,它确实有所作为。
问题是,在控制器断开连接或重新启动设备后,它会返回到 'defaults'。所以我试图让它始终适用。
我有这个 shell 脚本(是的,我知道它写得不好 - 我打算在一切正常后清理它):
#!/bin/sh
concount=0
while [ ! "$(hcitool con | grep -o "[[:xdigit:]:]\{11,17\}")" ]; do
sleep 0.1
if [ $concount -eq 30 ]; then
break
else
echo "Try $concount - Device not found, retrying."
fi
concount=$(($concount + 1))
done
if [ $concount -eq 30 ]; then
echo "Device not found after $concount checks."
else
sudo hcitool sr $(hcitool con | grep -o "[[:xdigit:]:]\{11,17\}") slave
echo "Device found and set to slave"
fi
延迟部分是因为它会在控制器完成连接并失败之前触发。这基本上给了它 3 秒的工作时间。
无论如何,当我通过命令行手动 运行 它工作正常并且延迟大大减少。
Connections:
> ACL 00:26:43:CC:B0:FB handle 11 state 1 lm SLAVE
Ping: 00:26:43:CC:B0:FB from B8:27:EB:68:0E:9E (data size 44) ...
4 bytes from 00:26:43:CC:B0:FB id 0 time 14.97ms
4 bytes from 00:26:43:CC:B0:FB id 1 time 16.09ms
4 bytes from 00:26:43:CC:B0:FB id 2 time 9.78ms
4 bytes from 00:26:43:CC:B0:FB id 3 time 11.11ms
4 bytes from 00:26:43:CC:B0:FB id 4 time 13.58ms
我制作了一个文件 /etc/udev/rules.d/50-btslave.rules
包含:
ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="054C", ATTR{idProduct}=="0268", RUN+="/home/pi/btslave.sh"
(idvendor/idproduct 来自阅读系统日志)
并将其添加到 99-sixaxis.rules
。
ACTION=="add", SUBSYSTEMS=="input", ATTRS{name}=="*PLAYSTATION(R)3 Controller", TAG+="systemd", RUN+="/home/pi/btslave.sh"
然后 udevadm control --reload
应用规则。
当我尝试重新连接时,系统日志似乎没有显示任何不同之处。它回到 'master',我得到了更高的延迟和尖峰。
Feb 12 20:31:14 retropie kernel: [ 2121.796762] sony 0005:054C:0268.0005: unknown main item tag 0x0
Feb 12 20:31:15 retropie kernel: [ 2122.292506] input: Sony PLAYSTATION(R)3 Controller Motion Sensors as /devices/platform/soc/3f201000.serial/tty/ttyAMA0/hci0/hci0:11/0005:054C:0268.0005/input/input7
Feb 12 20:31:15 retropie kernel: [ 2122.293773] input: Sony PLAYSTATION(R)3 Controller as /devices/platform/soc/3f201000.serial/tty/ttyAMA0/hci0/hci0:11/0005:054C:0268.0005/input/input6
Feb 12 20:31:15 retropie kernel: [ 2122.294645] sony 0005:054C:0268.0005: input,hidraw2: BLUETOOTH HID v80.00 Joystick [Sony PLAYSTATION(R)3 Controller] on b8:27:eb:68:0e:9e
Feb 12 20:31:15 retropie systemd[1]: Started sixaxis helper (sys/devices/platform/soc/3f201000.serial/tty/ttyAMA0/hci0/hci0:11/0005:054C:0268.0005/input/input6).
Feb 12 20:31:15 retropie systemd[1]: Started sixaxis helper (/dev/input/event3).
Feb 12 20:31:15 retropie sixaxis-helper.sh[1403]: Calibrating: Sony PLAYSTATION(R)3 Controller (00:26:43:CC:B0:FB)
Feb 12 20:31:16 retropie sixaxis-helper.sh[1403]: Setting 600 second timeout on: Sony PLAYSTATION(R)3 Controller (00:26:43:CC:B0:FB)
Connections:
> ACL 00:26:43:CC:B0:FB handle 11 state 1 lm MASTER
4 bytes from 00:26:43:CC:B0:FB id 0 time 36.31ms
4 bytes from 00:26:43:CC:B0:FB id 1 time 35.97ms
4 bytes from 00:26:43:CC:B0:FB id 2 time 36.07ms
4 bytes from 00:26:43:CC:B0:FB id 3 time 36.10ms
4 bytes from 00:26:43:CC:B0:FB id 4 time 34.82ms
当我将脚本移到别处并再次测试时,系统日志中显示找不到脚本的错误:
Feb 12 20:40:36 retropie systemd-udevd[1579]: failed to execute '/home/pi/btslave.sh' '/home/pi/btslave.sh': No such file or directory
Feb 12 20:40:36 retropie systemd-udevd[1577]: Process '/home/pi/btslave.sh' failed with exit code 2.
Feb 12 20:40:36 retropie systemd-udevd[1591]: failed to execute '/home/pi/btslave.sh' '/home/pi/btslave.sh': No such file or directory
Feb 12 20:40:36 retropie systemd-udevd[1574]: Process '/home/pi/btslave.sh' failed with exit code 2.
Feb 12 20:40:36 retropie systemd-udevd[1592]: failed to execute '/home/pi/btslave.sh' '/home/pi/btslave.sh': No such file or directory
Feb 12 20:40:36 retropie systemd-udevd[1577]: Process '/home/pi/btslave.sh' failed with exit code 2.
所以这告诉我事件似乎确实发生了。只是……实际上并没有这样做。我搜索了 Google 一段时间,没有找到任何结果。我是不是遗漏了什么,或者有更简单的方法吗?
谢谢。
所以,几个小时后,经过大量调试(以及来自 reddit post 的一些想法),我设法解决了这个问题。显然 udev 在序列中被触发得太早了,没有多少 'waiting' 实际上能够检索控制器的地址。它需要很晚才开火。
所以,我删除了 udev 规则并选择只编辑 /usr/bin/sixaxis-helper.sh
:
已添加
hcitool sr "$SIXAXIS_MAC" slave
之后
sixaxis_calibrate
(在底部的方式)它很丑但很管用。 :) 控制器立即配对到 'slave' 模式,延迟非常性感。
将它留给那些希望实施相同解决方案的人。现在,我很高兴并且可以继续前进。也许我稍后会重新访问并尝试改进它,这样它就不需要我编辑现有脚本(或其他人接受挑战)。
我有一个 Raspberry Pi 3B+ 运行ning RetroPie 并且正在尝试将我的 PS3 控制器设置为始终 运行 在 'slave' 模式下以减少延迟问题。我从这个 post 得到了灵感。我在 运行 命令后进行了测试,它确实有所作为。
问题是,在控制器断开连接或重新启动设备后,它会返回到 'defaults'。所以我试图让它始终适用。
我有这个 shell 脚本(是的,我知道它写得不好 - 我打算在一切正常后清理它):
#!/bin/sh
concount=0
while [ ! "$(hcitool con | grep -o "[[:xdigit:]:]\{11,17\}")" ]; do
sleep 0.1
if [ $concount -eq 30 ]; then
break
else
echo "Try $concount - Device not found, retrying."
fi
concount=$(($concount + 1))
done
if [ $concount -eq 30 ]; then
echo "Device not found after $concount checks."
else
sudo hcitool sr $(hcitool con | grep -o "[[:xdigit:]:]\{11,17\}") slave
echo "Device found and set to slave"
fi
延迟部分是因为它会在控制器完成连接并失败之前触发。这基本上给了它 3 秒的工作时间。
无论如何,当我通过命令行手动 运行 它工作正常并且延迟大大减少。
Connections:
> ACL 00:26:43:CC:B0:FB handle 11 state 1 lm SLAVE
Ping: 00:26:43:CC:B0:FB from B8:27:EB:68:0E:9E (data size 44) ...
4 bytes from 00:26:43:CC:B0:FB id 0 time 14.97ms
4 bytes from 00:26:43:CC:B0:FB id 1 time 16.09ms
4 bytes from 00:26:43:CC:B0:FB id 2 time 9.78ms
4 bytes from 00:26:43:CC:B0:FB id 3 time 11.11ms
4 bytes from 00:26:43:CC:B0:FB id 4 time 13.58ms
我制作了一个文件 /etc/udev/rules.d/50-btslave.rules
包含:
ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="054C", ATTR{idProduct}=="0268", RUN+="/home/pi/btslave.sh"
(idvendor/idproduct 来自阅读系统日志)
并将其添加到 99-sixaxis.rules
。
ACTION=="add", SUBSYSTEMS=="input", ATTRS{name}=="*PLAYSTATION(R)3 Controller", TAG+="systemd", RUN+="/home/pi/btslave.sh"
然后 udevadm control --reload
应用规则。
当我尝试重新连接时,系统日志似乎没有显示任何不同之处。它回到 'master',我得到了更高的延迟和尖峰。
Feb 12 20:31:14 retropie kernel: [ 2121.796762] sony 0005:054C:0268.0005: unknown main item tag 0x0
Feb 12 20:31:15 retropie kernel: [ 2122.292506] input: Sony PLAYSTATION(R)3 Controller Motion Sensors as /devices/platform/soc/3f201000.serial/tty/ttyAMA0/hci0/hci0:11/0005:054C:0268.0005/input/input7
Feb 12 20:31:15 retropie kernel: [ 2122.293773] input: Sony PLAYSTATION(R)3 Controller as /devices/platform/soc/3f201000.serial/tty/ttyAMA0/hci0/hci0:11/0005:054C:0268.0005/input/input6
Feb 12 20:31:15 retropie kernel: [ 2122.294645] sony 0005:054C:0268.0005: input,hidraw2: BLUETOOTH HID v80.00 Joystick [Sony PLAYSTATION(R)3 Controller] on b8:27:eb:68:0e:9e
Feb 12 20:31:15 retropie systemd[1]: Started sixaxis helper (sys/devices/platform/soc/3f201000.serial/tty/ttyAMA0/hci0/hci0:11/0005:054C:0268.0005/input/input6).
Feb 12 20:31:15 retropie systemd[1]: Started sixaxis helper (/dev/input/event3).
Feb 12 20:31:15 retropie sixaxis-helper.sh[1403]: Calibrating: Sony PLAYSTATION(R)3 Controller (00:26:43:CC:B0:FB)
Feb 12 20:31:16 retropie sixaxis-helper.sh[1403]: Setting 600 second timeout on: Sony PLAYSTATION(R)3 Controller (00:26:43:CC:B0:FB)
Connections:
> ACL 00:26:43:CC:B0:FB handle 11 state 1 lm MASTER
4 bytes from 00:26:43:CC:B0:FB id 0 time 36.31ms
4 bytes from 00:26:43:CC:B0:FB id 1 time 35.97ms
4 bytes from 00:26:43:CC:B0:FB id 2 time 36.07ms
4 bytes from 00:26:43:CC:B0:FB id 3 time 36.10ms
4 bytes from 00:26:43:CC:B0:FB id 4 time 34.82ms
当我将脚本移到别处并再次测试时,系统日志中显示找不到脚本的错误:
Feb 12 20:40:36 retropie systemd-udevd[1579]: failed to execute '/home/pi/btslave.sh' '/home/pi/btslave.sh': No such file or directory
Feb 12 20:40:36 retropie systemd-udevd[1577]: Process '/home/pi/btslave.sh' failed with exit code 2.
Feb 12 20:40:36 retropie systemd-udevd[1591]: failed to execute '/home/pi/btslave.sh' '/home/pi/btslave.sh': No such file or directory
Feb 12 20:40:36 retropie systemd-udevd[1574]: Process '/home/pi/btslave.sh' failed with exit code 2.
Feb 12 20:40:36 retropie systemd-udevd[1592]: failed to execute '/home/pi/btslave.sh' '/home/pi/btslave.sh': No such file or directory
Feb 12 20:40:36 retropie systemd-udevd[1577]: Process '/home/pi/btslave.sh' failed with exit code 2.
所以这告诉我事件似乎确实发生了。只是……实际上并没有这样做。我搜索了 Google 一段时间,没有找到任何结果。我是不是遗漏了什么,或者有更简单的方法吗?
谢谢。
所以,几个小时后,经过大量调试(以及来自 reddit post 的一些想法),我设法解决了这个问题。显然 udev 在序列中被触发得太早了,没有多少 'waiting' 实际上能够检索控制器的地址。它需要很晚才开火。
所以,我删除了 udev 规则并选择只编辑 /usr/bin/sixaxis-helper.sh
:
已添加
hcitool sr "$SIXAXIS_MAC" slave
之后
sixaxis_calibrate
(在底部的方式)它很丑但很管用。 :) 控制器立即配对到 'slave' 模式,延迟非常性感。
将它留给那些希望实施相同解决方案的人。现在,我很高兴并且可以继续前进。也许我稍后会重新访问并尝试改进它,这样它就不需要我编辑现有脚本(或其他人接受挑战)。