You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

树莓派无法识别Wii手柄或建立通信的问题求助

Wii手柄连接树莓派报错排查(用于Pygame)

尝试将Wii手柄连接树莓派以在Pygame中使用,已完成基础配置,但运行连接脚本时出现Socket connect error (control channel)错误。仅hcitool scan能检测到手柄,cwiid库、wmgui均无法识别手柄。

相关配置与脚本

/mywinput 配置文件

#WiiMote
Wiimote.A  = BTN_A
Wiimote.B = BTN_B
Wiimote.Dpad.X = ABS_Y
Wiimote.Dpad.Y = -ABS_X
Wiimote.Minus = BTN_SELECT
Wiimote.Plus = BTN_START
Wiimote.Home = BTN_MODE
Wiimote.1 = BTN_X
Wiimote.2 = BTN_Y
# Nunchuk
Nunchuk.C = BTN_C
Nunchuk.Z = BTN_Z

Plugin.led.Led1 = 1
#Plugin.led.Led2 = 1
Plugin.led.Led3 = 1
#Plugin.led.Led4 = 1

/wiicontroller.sh 连接脚本

#!/bin/bash
sleep 1 # Wait until Bluetooth services are fully initialized
hcitool dev | grep hci >/dev/null
if test $? -eq 0 ; then
    wminput -d -c  /home/pi/mywinput CC:FB:65:2C:52:8F &
else
    echo "Blue-tooth adapter not present!"
    exit 1

fi

权限设置命令

sudo chmod 775 /home/pi/bin/connectwii.sh

错误现象

  • 运行脚本后立即返回,按下手柄1+2键触发报错:Socket connect error (control channel)
  • cwiid库、wmgui均无法识别手柄,仅hcitool scan可检测到目标手柄

排查与解决建议

  • 手动完成蓝牙配对信任:
    1. 执行sudo bluetoothctl进入蓝牙控制台
    2. 依次输入agent on、default-agent开启代理
    3. 按住手柄的1+2键,输入scan on找到设备后,执行pair CC:FB:65:2C:52:8F完成配对,再输入trust CC:FB:65:2C:52:8F设置信任
    4. 退出控制台后重新运行连接脚本
  • 延长蓝牙服务启动延迟:将脚本中的sleep 1修改为sleep 5,确保蓝牙服务完全初始化
  • 以root权限运行脚本:执行sudo ./wiicontroller.sh,避免普通用户权限不足导致的socket连接失败
  • 重置蓝牙服务:执行sudo systemctl restart bluetooth后再尝试连接
  • 检查手柄电量:确保Wii手柄电量充足,低电量可能导致连接不稳定

内容的提问来源于stack exchange,提问作者mr.r

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.25 20:20:03