From ccc0a0cba8a2fdb8cfb148276e7c9413a3e22dc8 Mon Sep 17 00:00:00 2001
From: MilhouseVH <milhouseVH.github@nmacleod.com>
Date: Thu, 19 Sep 2019 22:48:19 +0100
Subject: [PATCH] sixaxis: Fix PID for Navigation Controller

Newsgroups: gmane.linux.bluez.kernel
Date: 2015-06-15 18:28:26 GMT (36 weeks, 4 days, 21 hours and 32 minutes ago)

Navigation Controller is using PID 0x042f over USB but PID 0x0268
(same as Dualshock 3) over BT.
---
 plugins/sixaxis.c        | 8 +++++++-
 profiles/input/sixaxis.h | 2 ++
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/plugins/sixaxis.c b/plugins/sixaxis.c
index 939fed7..f6baea7 100644
--- a/plugins/sixaxis.c
+++ b/plugins/sixaxis.c
@@ -354,7 +354,13 @@ static bool setup_device(int fd, const char *sysfs_path,
 	info("sixaxis: setting up new device");
 
 	btd_device_device_set_name(device, cp->name);
-	btd_device_set_pnpid(device, cp->source, cp->vid, cp->pid, cp->version);
+
+	/* if device reports different pid/vid on BT prefer those over USB */
+	if (cp->bt_pid)
+		btd_device_set_pnpid(device, cp->source, cp->vid, cp->bt_pid, cp->version);
+	else
+		btd_device_set_pnpid(device, cp->source, cp->vid, cp->pid, cp->version);
+
 	btd_device_set_temporary(device, true);
 
 	closure = g_new0(struct authentication_closure, 1);
diff --git a/profiles/input/sixaxis.h b/profiles/input/sixaxis.h
index 8e6f3cc..321a918 100644
--- a/profiles/input/sixaxis.h
+++ b/profiles/input/sixaxis.h
@@ -25,6 +25,7 @@ struct cable_pairing {
 	uint16_t vid;
 	uint16_t pid;
 	uint16_t version;
+	uint16_t bt_pid;
 	CablePairingType type;
 };
 
@@ -54,6 +55,7 @@ get_pairing(uint16_t vid, uint16_t pid)
 			.vid = 0x054c,
 			.pid = 0x042f,
 			.version = 0x0000,
+			.bt_pid = 0x0268,
 			.type = CABLE_PAIRING_SIXAXIS,
 		},
 		{
-- 
2.7.4

