From: Benjamin Valentin <benpicco@googlemail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH] sixaxis: Fall back to matching VID/PID for unknown devices
Date: Mon, 30 Aug 2021 21:36:55 +0200 [thread overview]
Message-ID: <20210830213655.16e6c37a@rechenknecht2k11> (raw)
Commit 61745d2bb made device matching stricter.
Before, a third party device would be matched according to it's
vendor / device ID only.
Now we require it's name to be in the list of known devices too,
so the name is retained later on.
This regresses unknown third-party devices that are not in the list
(as reported by [0]).
We can try to keep up by expanding the list, but let's also gracefully
fall back to vid/pid matching if there is a device that we don't know.
[0] https://www.reddit.com/r/archlinux/comments/pdvdfd/a_dirty_fix_for_ps3_controller_bluetooth/
Signed-off-by: Benjamin Valentin <benpicco@googlemail.com>
---
profiles/input/sixaxis.h | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/profiles/input/sixaxis.h b/profiles/input/sixaxis.h
index ab8831995..db518997a 100644
--- a/profiles/input/sixaxis.h
+++ b/profiles/input/sixaxis.h
@@ -74,6 +74,7 @@ get_pairing(uint16_t vid, uint16_t pid, const char *name)
},
};
guint i;
+ const struct cable_pairing *best_match = NULL;
for (i = 0; i < G_N_ELEMENTS(devices); i++) {
if (devices[i].vid != vid)
@@ -81,13 +82,16 @@ get_pairing(uint16_t vid, uint16_t pid, const char *name)
if (devices[i].pid != pid)
continue;
- if (name && strcmp(name, devices[i].name))
+ /* if the device is unknown, use the next best match */
+ if (name && strcmp(name, devices[i].name)) {
+ best_match = &devices[i];
continue;
+ }
return &devices[i];
}
- return NULL;
+ return best_match;
}
#endif /* _SIXAXIS_H_ */
--
2.30.2
next reply other threads:[~2021-08-30 19:37 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-30 19:36 Benjamin Valentin [this message]
2021-08-30 19:53 ` sixaxis: Fall back to matching VID/PID for unknown devices bluez.test.bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210830213655.16e6c37a@rechenknecht2k11 \
--to=benpicco@googlemail.com \
--cc=linux-bluetooth@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox