[PATCH] sixaxis: Fall back to matching VID/PID for unknown devices

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxx>
---
 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



[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux