From: Szymon Janc <szymon.janc@gmail.com>
To: linux-bluetooth@vger.kernel.org
Cc: Szymon Janc <szymon.janc@gmail.com>
Subject: [PATCH 3/4] sixaxis: Skip controller setup if already connected over Bluetooth
Date: Sun, 1 Dec 2013 14:41:55 +0100 [thread overview]
Message-ID: <1385905316-21800-4-git-send-email-szymon.janc@gmail.com> (raw)
In-Reply-To: <1385905316-21800-1-git-send-email-szymon.janc@gmail.com>
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
next prev parent reply other threads:[~2013-12-01 13:41 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-01 13:41 [PATCH 0/4] more sixaxis goodies Szymon Janc
2013-12-01 13:41 ` [PATCH 1/4] sixaxis: Add support for setting PS3 controller LEDs Szymon Janc
2013-12-01 13:41 ` [PATCH 2/4] Rename device_is_connected to btd_device_is_connected Szymon Janc
2013-12-01 13:41 ` Szymon Janc [this message]
2013-12-01 13:41 ` [PATCH 4/4] sixaxis: Add support for setting LEDs when connected over USB Szymon Janc
2013-12-03 7:48 ` [PATCH 0/4] more sixaxis goodies Johan Hedberg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1385905316-21800-4-git-send-email-szymon.janc@gmail.com \
--to=szymon.janc@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox