Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp7484317pxb; Thu, 18 Feb 2021 11:14:35 -0800 (PST) X-Google-Smtp-Source: ABdhPJy8k7sodpcXP9R+uu2lV9vU95gt8nQfSqt3nBYJmrboy5gfQ1j5urOtKX1Vc1xyAK5+56HC X-Received: by 2002:a05:6402:5112:: with SMTP id m18mr5559090edd.129.1613675674964; Thu, 18 Feb 2021 11:14:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613675674; cv=none; d=google.com; s=arc-20160816; b=KIMnckFxAxTKx7fDJEObxRiHFypxULm2jOpGs3H619byuEScHyK/FCaiHNQFB2A3G2 Er8RIwA0IbV7lxiQ2vmrhRFQYPVxM16tApYoYHPu7q579NfiJjmIuW6/VGQdKMFR6P0A yviA+2V+rNlmiLOxoMLUTmsvBqUE1LspNFt1Kut1I00IRXxi2GTopQ2mgtsJ6ie8A+zc Gm5/0twZPYeqEc1NXLNR8f0Wk7UzVUpvkOj0jGlNyp9zLGW++Pt6hvdYU2tp/Lt/ykUf qtwPZ8/zUvGC3ZIYestqpxScVeZIF7tgBsgjGGq4435AkI9d2dg3gA3f9pAHrUWJbH2p yspQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=nAXgGci66qbhAJq8l5ejLymuCWSkeyTNArYeTD6BWP4=; b=Og/wgjEqXy79qOT/DFyI+F32KOA07qvlDLqJesLGYtjbBHLukEzhsS/wORVCqqdJiX AFvHJaVgwzX4ljvmCSyudAt9mhkBR89FF6/N79k39kraF/5/ppnHEHk6D1+BLJVvhXX1 l3iGCWO4QMd9on0YWOeZmV5Q/LO9OP7kMGKlSBKS5sToYfZp2kjChG3BSHZS7EWchkb3 EAl3SPjsY7aYCAaMqfpWN6QW65trfG10603eWwo2e3WPwqnPywEkZLHaZWfvfpyuHzqJ +Yh04XFq8YCgJlvrkb7Raytm9jVMVvctfBu6Vdmx+20pXIpPEaxBwbMuXfb3qYTs+R6e 2sKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codecoup-pl.20150623.gappssmtp.com header.s=20150623 header.b=2Ooi9JMt; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id oz27si1528525ejb.458.2021.02.18.11.13.52; Thu, 18 Feb 2021 11:14:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@codecoup-pl.20150623.gappssmtp.com header.s=20150623 header.b=2Ooi9JMt; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232950AbhBRTL4 (ORCPT + 99 others); Thu, 18 Feb 2021 14:11:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233752AbhBRTGf (ORCPT ); Thu, 18 Feb 2021 14:06:35 -0500 Received: from mail-lj1-x232.google.com (mail-lj1-x232.google.com [IPv6:2a00:1450:4864:20::232]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD5AEC061574 for ; Thu, 18 Feb 2021 11:05:54 -0800 (PST) Received: by mail-lj1-x232.google.com with SMTP id a17so7442417ljq.2 for ; Thu, 18 Feb 2021 11:05:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=codecoup-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=nAXgGci66qbhAJq8l5ejLymuCWSkeyTNArYeTD6BWP4=; b=2Ooi9JMtm364bq8N9i2w4A01+5zl7lREhzfD9gYa7xKs75vG+ZwJXh7sDkw7+3ZPWT nFJMwc+OJzTC+WSMfmSSix6sWlL/2F3ZI3TLomcdzpmntnLChEOGLpj5Rqz5bcp7C+Yp sEQXm+WAU+JbdFUc1t4TEcFwIUs9jrcre3ZObbcFmBevsOcGccH78D5frCOQT9W9AuPE UXBpsuTsay25t9RhIUXU0uQSkDzlJ0F2CjXJutOB7zlD83SKkvbB2z3YLa9xZzRH5+Bf 2aF4QJ9t83mZsQuJK0IOSdoJBvN5mZz+v3PbH6jOjGZ5tyLGuytvGvWTAVKy21FCXivO EgZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=nAXgGci66qbhAJq8l5ejLymuCWSkeyTNArYeTD6BWP4=; b=qoupQGOtPLKd6tFGz1Jfu6tYhamr0C+BpAigmRmCz9QsRat2HxlxJ8ugwGQPULD8Kr dGoNuqlZgY/dSXqdepymjnhfTdpSLAddNsXlZcae0wDienIirLJPzz0YlFZe77yTEI8A VX99sdy5l0cS1tTX9lzDLyPHBPDxN4mjy0SPwNXKmE7QGQIITSJ3cac+4LZIwkv/Yxr8 q9XY9+08cnmVUEzgyPkqwpxnt93gPVuUawLfdTi8PX1YCyC4yP97qSH+Ae/cbdgJ+byu X6a4W0D/UnPiSfB4MVN28M0UwHdhnlMslqXHjAHrReneS0ZZ7QbMYXXj7p3xqt2CuJDk pI/A== X-Gm-Message-State: AOAM5338A36er4KLaz66ZtpaGVQL87VlAF8qbNiJSqL+7Z7SBQbjdbIt t7/pkZ6A2EDj4kxk2PPJwWjpHlFz0CO4MA== X-Received: by 2002:a19:7d1:: with SMTP id 200mr3285656lfh.110.1613675153153; Thu, 18 Feb 2021 11:05:53 -0800 (PST) Received: from localhost.localdomain (45-11-60-42.ip4.greenlan.pl. [45.11.60.42]) by smtp.gmail.com with ESMTPSA id w21sm689138lfe.33.2021.02.18.11.05.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Feb 2021 11:05:52 -0800 (PST) From: Szymon Janc To: linux-bluetooth@vger.kernel.org Cc: Szymon Janc Subject: [PATCH] sixaxis: Fix Bluetooth PS3 clone joypad being named like the original Date: Thu, 18 Feb 2021 20:05:45 +0100 Message-Id: <20210218190545.109454-1-szymon.janc@codecoup.pl> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org When cable pairing a PS3 clone device, we should try and keep the USB device name to create a new btd_device so that the joypad is named after its USB name when connecting through Bluetooth. If that isn't done, "Shanwan" clone joypads are named like the genuine joypads, and kernel Bluetooth quirks aren't applied. gh-issue: https://github.com/bluez/bluez/issues/46 --- plugins/sixaxis.c | 5 ++++- profiles/input/server.c | 2 +- profiles/input/sixaxis.h | 13 ++++++++++++- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/plugins/sixaxis.c b/plugins/sixaxis.c index d693a86c0..517cecc47 100644 --- a/plugins/sixaxis.c +++ b/plugins/sixaxis.c @@ -387,6 +387,7 @@ get_pairing_type_for_device(struct udev_device *udevice, uint16_t *bus, char **sysfs_path) { struct udev_device *hid_parent; + const char *hid_name; const char *hid_id; const struct cable_pairing *cp; uint16_t vid, pid; @@ -401,7 +402,9 @@ get_pairing_type_for_device(struct udev_device *udevice, uint16_t *bus, if (!hid_id || sscanf(hid_id, "%hx:%hx:%hx", bus, &vid, &pid) != 3) return NULL; - cp = get_pairing(vid, pid); + hid_name = udev_device_get_property_value(hid_parent, "HID_NAME"); + + cp = get_pairing(vid, pid, hid_name); *sysfs_path = g_strdup(udev_device_get_syspath(udevice)); return cp; diff --git a/profiles/input/server.c b/profiles/input/server.c index d8b413744..79cf08a66 100644 --- a/profiles/input/server.c +++ b/profiles/input/server.c @@ -120,7 +120,7 @@ static bool dev_is_sixaxis(const bdaddr_t *src, const bdaddr_t *dst) vid = btd_device_get_vendor(device); pid = btd_device_get_product(device); - cp = get_pairing(vid, pid); + cp = get_pairing(vid, pid, NULL); if (cp && (cp->type == CABLE_PAIRING_SIXAXIS || cp->type == CABLE_PAIRING_DS4)) return true; diff --git a/profiles/input/sixaxis.h b/profiles/input/sixaxis.h index a3cda70e4..ab8831995 100644 --- a/profiles/input/sixaxis.h +++ b/profiles/input/sixaxis.h @@ -29,7 +29,7 @@ struct cable_pairing { }; static inline const struct cable_pairing * -get_pairing(uint16_t vid, uint16_t pid) +get_pairing(uint16_t vid, uint16_t pid, const char *name) { static const struct cable_pairing devices[] = { { @@ -40,6 +40,14 @@ get_pairing(uint16_t vid, uint16_t pid) .version = 0x0000, .type = CABLE_PAIRING_SIXAXIS, }, + { + .name = "SHANWAN PS3 GamePad", + .source = 0x0002, + .vid = 0x054c, + .pid = 0x0268, + .version = 0x0000, + .type = CABLE_PAIRING_SIXAXIS, + }, { .name = "Navigation Controller", .source = 0x0002, @@ -73,6 +81,9 @@ get_pairing(uint16_t vid, uint16_t pid) if (devices[i].pid != pid) continue; + if (name && strcmp(name, devices[i].name)) + continue; + return &devices[i]; } -- 2.29.2