linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Detect Wii Remotes by device name
@ 2012-02-22 20:29 David Herrmann
  2012-03-16 15:20 ` Johan Hedberg
  0 siblings, 1 reply; 2+ messages in thread
From: David Herrmann @ 2012-02-22 20:29 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: johan.hedberg, David Herrmann

We currently detect Wii Remotes by DID information. However, not all Wii Remotes
(especially 3rd party Wii Remotes) provide DID information. Moreover, they
provide no way of identifying them aside from their device name. Hence, this
adds an experimental name-detection for Wii Remotes.
---
 plugins/wiimote.c |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/plugins/wiimote.c b/plugins/wiimote.c
index 1ae638b..568bfd5 100644
--- a/plugins/wiimote.c
+++ b/plugins/wiimote.c
@@ -26,6 +26,7 @@
 #endif
 
 #include <bluetooth/bluetooth.h>
+#include <glib.h>
 
 #include "plugin.h"
 #include "adapter.h"
@@ -60,18 +61,20 @@ static ssize_t wii_pincb(struct btd_adapter *adapter, struct btd_device *device,
 {
 	uint16_t vendor, product;
 	bdaddr_t sba, dba;
-	char addr[18];
+	char addr[18], name[25];
 
 	adapter_get_address(adapter, &sba);
 	device_get_address(device, &dba, NULL);
 	ba2str(&dba, addr);
 
 	vendor = btd_device_get_vendor(device);
-	if (vendor != 0x057e)
-		return 0;
-
 	product = btd_device_get_product(device);
-	if (product == 0x0306) {
+
+	device_get_name(device, name, sizeof(name));
+	name[sizeof(name) - 1] = 0;
+
+	if (g_str_equal(name, "Nintendo RVL-CNT-01") ||
+				(vendor == 0x057e && product == 0x0306)) {
 		DBG("Forcing fixed pin on detected wiimote %s", addr);
 		memcpy(pinbuf, &sba, 6);
 		return 6;
-- 
1.7.8.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] Detect Wii Remotes by device name
  2012-02-22 20:29 [PATCH] Detect Wii Remotes by device name David Herrmann
@ 2012-03-16 15:20 ` Johan Hedberg
  0 siblings, 0 replies; 2+ messages in thread
From: Johan Hedberg @ 2012-03-16 15:20 UTC (permalink / raw)
  To: David Herrmann; +Cc: linux-bluetooth

Hi David,

On Wed, Feb 22, 2012, David Herrmann wrote:
> We currently detect Wii Remotes by DID information. However, not all
> Wii Remotes (especially 3rd party Wii Remotes) provide DID
> information. Moreover, they provide no way of identifying them aside
> from their device name. Hence, this adds an experimental
> name-detection for Wii Remotes.
> ---
>  plugins/wiimote.c |   13 ++++++++-----
>  1 files changed, 8 insertions(+), 5 deletions(-)

Applied. Thanks.

Johan

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-03-16 15:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-22 20:29 [PATCH] Detect Wii Remotes by device name David Herrmann
2012-03-16 15:20 ` Johan Hedberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).