All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] sixaxis: Fall back to matching VID/PID for unknown devices
@ 2021-08-30 19:36 Benjamin Valentin
  2021-08-30 19:53 ` bluez.test.bot
  0 siblings, 1 reply; 2+ messages in thread
From: Benjamin Valentin @ 2021-08-30 19:36 UTC (permalink / raw)
  To: linux-bluetooth

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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-08-30 19:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-30 19:36 [PATCH] sixaxis: Fall back to matching VID/PID for unknown devices Benjamin Valentin
2021-08-30 19:53 ` bluez.test.bot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.