我正在尝试将一台安卓设备与PlayStation 4(或5)配对,这样我就可以使用蓝牙HID配置文件了。问题是PlayStation固件不喜欢与未经授权的设备配对。我已经看到有人能够在Raspberry Pi Zero上解决这个问题,方法是使用ConfigFS和FunctionFS来模拟PlayStation控制器,并通过USB启动配对过程。因此,我已经开始尝试将their code移植到我的安卓设备上,但这两种设备的差异阻碍了我的脚步。我的Android设备的内核版本是3.10,而Pi Zero使用的是较新的4.x或5.x内核。
我立即发现了一些不同之处,例如安卓设备已经在/config上挂载了ConfigFS,而在/dev/usb-ffs上挂载了其他FunctionFS文件。在更改代码以跳过挂载并指向正确的位置后,我遇到了其他一些问题。第一个问题存在于这段代码中:
if (echo_to(CONFIGFS_MP "/" GADGET_PATH "/bDeviceClass", "0x00") < 0)
goto fail_2;
if (echo_to(CONFIGFS_MP "/" GADGET_PATH "/bDeviceSubClass", "0x00") < 0)
goto fail_2;
if (echo_to(CONFIGFS_MP "/" GADGET_PATH "/bDeviceProtocol", "0x00") < 0)
goto fail_2;
if (echo_to(CONFIGFS_MP "/" GADGET_PATH "/bMaxPacketSize0", "0x40") < 0)
goto fail_2;
if (echo_to(CONFIGFS_MP "/" GADGET_PATH "/idVendor", "0x054c") < 0)
goto fail_2;
if (echo_to(CONFIGFS_MP "/" GADGET_PATH "/idProduct", "0x09cc") < 0)
goto fail_2;
if (echo_to(CONFIGFS_MP "/" GADGET_PATH "/bcdDevice", "0x100") < 0)
goto fail_2;
if (mkdir(CONFIGFS_MP "/" GADGET_PATH "/configs/c.1", 0700) < 0)
goto fail_2;
if (echo_to(CONFIGFS_MP "/" GADGET_PATH "/configs/c.1/bmAttributes", "0xc0") < 0)
goto fail_3;
if (echo_to(CONFIGFS_MP "/" GADGET_PATH "/configs/c.1/MaxPower", "500") < 0)
goto fail_3;
if (mkdir(CONFIGFS_MP "/" GADGET_PATH "/functions/ffs.dualshock", 0700) < 0)
goto fail_3;
if (mkdir(CONFIGFS_MP "/" GADGET_PATH "/strings/0x409", 0700) < 0)
goto fail_4;
if (echo_to(CONFIGFS_MP "/" GADGET_PATH "/strings/0x409/manufacturer", "Sony Interactive Entertainment") < 0)
goto fail_5;
if (echo_to(CONFIGFS_MP "/" GADGET_PATH "/strings/0x409/product", "Wireless Controller") < 0)
goto fail_5;
if (symlink(CONFIGFS_MP "/" GADGET_PATH "/functions/ffs.dualshock", CONFIGFS_MP "/" GADGET_PATH "/configs/c.1/ffs.dualshock") < 0)特别是这一部分:
if (mkdir(CONFIGFS_MP "/" GADGET_PATH "/functions/ffs.dualshock", 0700) < 0)
goto fail_3;这个错误消息是Function not implemented,我无法找出原因。我不熟悉ConfigFS或FunctionFS,在谷歌上搜索这个错误信息以及我能想到的任何关键字都是徒劳的。如果我注释掉这一部分(以及稍后对其进行符号链接的部分),那么这段代码的其余部分就可以工作了,但随后我又在do_functions()函数中遇到了错误:
int do_functions(const char* udc, options_t *opt)
{
int ret = -1;
fprintf(stdout, "Writing functions for %s...\n", udc);
int fd = open(FUNCTIONFS_MP "/ep0", O_RDWR);
if (fd < 0) {
perror("open");
goto failed0;
}
if (write(fd, &descriptor, sizeof(descriptor)) < 0) {
perror("write descriptor"); // <-- Logs out "write descriptor: Invalid Argument"
goto failed1;
}
if (write(fd, &strings, sizeof(strings)) < 0) {
perror("write strings");
goto failed1;
}我不确定我对其他代码的注释是否会导致此操作失败,或者如果我让其他代码工作,它是否也会失败。谁能帮我更好地理解这段代码,ConfigFS和FunctionFS?
发布于 2021-04-22 22:07:17
Gentoo's wiki上有一个相关资源,提供了有关如何配置DualShock控制器的说明。本文建议使用3.15以上的内核版本,因此这可能是问题背后的一个潜在来源。
在搜索android内核的git之后,有一个针对索尼设备的driver,它提供了对蓝牙连接的支持,同时也更具体地介绍了Gentoo的维基页面中提到的DS4的hid字段修改。提交似乎是在2015年左右,当时大多数设备附带的内核版本类似于3.18.x,因此它可能仍然不适用于您的内核版本。
如果问题看起来确实是缺乏对内核版本的支持,那么你应该考虑升级到支持的版本,因为@0andriy建议你应该将最新的内核移植到你的设备上。但是如果这对你的项目来说是一个不必要的开销,那么你可以搜索你的设备是否被其他自定义的安卓发行版支持,例如,Lineage OS提供了一个当前支持的设备here的列表。从你的内核版本来看,你的设备可能已经安装了Android KitKat。
https://stackoverflow.com/questions/67073294
复制相似问题