[PATCH 3/4] sixaxis: Skip controller setup if already connected over Bluetooth

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

 



If controller is already connected over Bluetooth but was then
plugged-in via USB (eg. to charge battery) there is no need to do
any setup.
---
 plugins/sixaxis.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/plugins/sixaxis.c b/plugins/sixaxis.c
index c3ca267..b8fe287 100644
--- a/plugins/sixaxis.c
+++ b/plugins/sixaxis.c
@@ -194,6 +194,12 @@ static void setup_device(int fd, int index, struct btd_adapter *adapter)
 	if (get_master_bdaddr(fd, &master_bdaddr) < 0)
 		return;
 
+	/* This can happen if controller was plugged while already connected
+	 * eg. to charge up battery */
+	device = btd_adapter_find_device(adapter, &device_bdaddr);
+	if (device && btd_device_is_connected(device))
+		return;
+
 	adapter_bdaddr = btd_adapter_get_address(adapter);
 
 	if (bacmp(adapter_bdaddr, &master_bdaddr)) {
-- 
1.8.5

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[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