From 67c269d17185ae531058951dadfad05ef4442faf Mon Sep 17 00:00:00 2001 From: Szymon Janc Date: Sun, 1 Dec 2013 14:41:55 +0100 Subject: [PATCH] sixaxis: Skip controller setup if already connected over Bluetooth 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 c3ca26797..b8fe287fc 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)) { -- 2.47.3