* [PATCH bluez] wiimote: add Wii-Remote-Plus ID and name detection
@ 2012-10-22 8:31 David Herrmann
2012-11-28 12:50 ` Johan Hedberg
0 siblings, 1 reply; 4+ messages in thread
From: David Herrmann @ 2012-10-22 8:31 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Johan Hedberg, Peter Olson, David Herrmann
The Nintendo Wii Remote Plus uses a new product ID and name. To detect
them properly, we need to add them to the wiimote-module.
To avoid an overlong "if" statement, this converts the match-function to
walk over an array and check all VID/PID pairs and device-names. This
makes adding new devices much easier.
---
Hi Johan
I am actually not sure why Nintendo changed the VID/PID for the new revisions of
the WiimotePlus. I have a WiimotePlus which still uses the old numbers and works
here quite well. However, I have now got multiple requests from people with the
new device name and IDs. Unfortunately, I cannot test these so I'd like to have
a "Tested-by" by Peter (CC'ed) before this is applied.
Thanks
David
plugins/wiimote.c | 35 ++++++++++++++++++++++++++++-------
1 file changed, 28 insertions(+), 7 deletions(-)
diff --git a/plugins/wiimote.c b/plugins/wiimote.c
index 5708bf8..f506ed6 100644
--- a/plugins/wiimote.c
+++ b/plugins/wiimote.c
@@ -2,7 +2,7 @@
*
* BlueZ - Bluetooth protocol stack for Linux
*
- * Copyright (C) 2011 David Herrmann <dh.herrmann@googlemail.com>
+ * Copyright (C) 2011-2012 David Herrmann <dh.herrmann@googlemail.com>
*
*
* This program is free software; you can redistribute it and/or modify
@@ -58,11 +58,23 @@
* is pressed.
*/
+static uint16_t wii_ids[][2] = {
+ { 0x057e, 0x0306 },
+ { 0x057e, 0x0330 },
+};
+
+static const char *wii_names[] = {
+ "Nintendo RVL-CNT-01",
+ "Nintendo RVL-CNT-01-TR",
+ "Nintendo RVL-WBC-01",
+};
+
static ssize_t wii_pincb(struct btd_adapter *adapter, struct btd_device *device,
char *pinbuf, gboolean *display)
{
uint16_t vendor, product;
char addr[18], name[25];
+ unsigned int i, len;
ba2str(device_get_address(device), addr);
@@ -72,15 +84,24 @@ static ssize_t wii_pincb(struct btd_adapter *adapter, struct btd_device *device,
device_get_name(device, name, sizeof(name));
name[sizeof(name) - 1] = 0;
- if (g_str_equal(name, "Nintendo RVL-CNT-01") ||
- g_str_equal(name, "Nintendo RVL-WBC-01") ||
- (vendor == 0x057e && product == 0x0306)) {
- DBG("Forcing fixed pin on detected wiimote %s", addr);
- memcpy(pinbuf, adapter_get_address(adapter), 6);
- return 6;
+ len = sizeof(wii_ids) / sizeof(wii_ids[0]);
+ for (i = 0; i < len; ++i) {
+ if (vendor == wii_ids[i][0] && product == wii_ids[i][1])
+ goto found;
+ }
+
+ len = sizeof(wii_names) / sizeof(wii_names[0]);
+ for (i = 0; i < len; ++i) {
+ if (g_str_equal(name, wii_names[i]))
+ goto found;
}
return 0;
+
+found:
+ DBG("Forcing fixed pin on detected wiimote %s", addr);
+ memcpy(pinbuf, adapter_get_address(adapter), 6);
+ return 6;
}
static int wii_probe(struct btd_adapter *adapter)
--
1.7.12.4
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH bluez] wiimote: add Wii-Remote-Plus ID and name detection
2012-10-22 8:31 [PATCH bluez] wiimote: add Wii-Remote-Plus ID and name detection David Herrmann
@ 2012-11-28 12:50 ` Johan Hedberg
2012-11-28 13:00 ` David Herrmann
0 siblings, 1 reply; 4+ messages in thread
From: Johan Hedberg @ 2012-11-28 12:50 UTC (permalink / raw)
To: David Herrmann; +Cc: linux-bluetooth, Peter Olson
Hi David,
On Mon, Oct 22, 2012, David Herrmann wrote:
> The Nintendo Wii Remote Plus uses a new product ID and name. To detect
> them properly, we need to add them to the wiimote-module.
>
> To avoid an overlong "if" statement, this converts the match-function to
> walk over an array and check all VID/PID pairs and device-names. This
> makes adding new devices much easier.
> ---
> Hi Johan
>
> I am actually not sure why Nintendo changed the VID/PID for the new revisions of
> the WiimotePlus. I have a WiimotePlus which still uses the old numbers and works
> here quite well. However, I have now got multiple requests from people with the
> new device name and IDs. Unfortunately, I cannot test these so I'd like to have
> a "Tested-by" by Peter (CC'ed) before this is applied.
>
> Thanks
> David
>
> plugins/wiimote.c | 35 ++++++++++++++++++++++++++++-------
> 1 file changed, 28 insertions(+), 7 deletions(-)
Well, the Tested-by never came, but since the patch looks ok to me I
went ahead and applied it anyway (with a minor fix to use G_N_ELEMENTS()
instead of your custom array length calculation).
Johan
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH bluez] wiimote: add Wii-Remote-Plus ID and name detection
2012-11-28 12:50 ` Johan Hedberg
@ 2012-11-28 13:00 ` David Herrmann
2012-11-28 18:03 ` Peter Olson
0 siblings, 1 reply; 4+ messages in thread
From: David Herrmann @ 2012-11-28 13:00 UTC (permalink / raw)
To: David Herrmann, linux-bluetooth@vger.kernel.org, Peter Olson
Hi Johan
On Wed, Nov 28, 2012 at 1:50 PM, Johan Hedberg <johan.hedberg@gmail.com> wrote:
> Hi David,
>
> On Mon, Oct 22, 2012, David Herrmann wrote:
>> The Nintendo Wii Remote Plus uses a new product ID and name. To detect
>> them properly, we need to add them to the wiimote-module.
>>
>> To avoid an overlong "if" statement, this converts the match-function to
>> walk over an array and check all VID/PID pairs and device-names. This
>> makes adding new devices much easier.
>> ---
>> Hi Johan
>>
>> I am actually not sure why Nintendo changed the VID/PID for the new revisions of
>> the WiimotePlus. I have a WiimotePlus which still uses the old numbers and works
>> here quite well. However, I have now got multiple requests from people with the
>> new device name and IDs. Unfortunately, I cannot test these so I'd like to have
>> a "Tested-by" by Peter (CC'ed) before this is applied.
>>
>> Thanks
>> David
>>
>> plugins/wiimote.c | 35 ++++++++++++++++++++++++++++-------
>> 1 file changed, 28 insertions(+), 7 deletions(-)
>
> Well, the Tested-by never came, but since the patch looks ok to me I
> went ahead and applied it anyway (with a minor fix to use G_N_ELEMENTS()
> instead of your custom array length calculation).
Sorry for the long delay. But I don't have the device so it sometimes
takes a bit longer. Anyway, it doesn't do any harm if we apply it so
yes, thanks for not forgetting about it.
Cheers
David
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH bluez] wiimote: add Wii-Remote-Plus ID and name detection
2012-11-28 13:00 ` David Herrmann
@ 2012-11-28 18:03 ` Peter Olson
0 siblings, 0 replies; 4+ messages in thread
From: Peter Olson @ 2012-11-28 18:03 UTC (permalink / raw)
To: David Herrmann; +Cc: linux-bluetooth@vger.kernel.org
Apologies, the testing as a whole is not yet complete as I have some
issues still. However, the bluez portion of the fixes David was making
so seem to work properly. Before the patch I would have to use blueman
to force a connection without a paring code, after the patch the
bluetooth recognizes the device automatically and prompts for
accepting the connection. My remaining issues lie with getting some
userspace tools to recognize the wiimote, not with the bluez.
Peter
On Wed, Nov 28, 2012 at 5:00 AM, David Herrmann
<dh.herrmann@googlemail.com> wrote:
> Hi Johan
>
> On Wed, Nov 28, 2012 at 1:50 PM, Johan Hedberg <johan.hedberg@gmail.com> wrote:
>> Hi David,
>>
>> On Mon, Oct 22, 2012, David Herrmann wrote:
>>> The Nintendo Wii Remote Plus uses a new product ID and name. To detect
>>> them properly, we need to add them to the wiimote-module.
>>>
>>> To avoid an overlong "if" statement, this converts the match-function to
>>> walk over an array and check all VID/PID pairs and device-names. This
>>> makes adding new devices much easier.
>>> ---
>>> Hi Johan
>>>
>>> I am actually not sure why Nintendo changed the VID/PID for the new revisions of
>>> the WiimotePlus. I have a WiimotePlus which still uses the old numbers and works
>>> here quite well. However, I have now got multiple requests from people with the
>>> new device name and IDs. Unfortunately, I cannot test these so I'd like to have
>>> a "Tested-by" by Peter (CC'ed) before this is applied.
>>>
>>> Thanks
>>> David
>>>
>>> plugins/wiimote.c | 35 ++++++++++++++++++++++++++++-------
>>> 1 file changed, 28 insertions(+), 7 deletions(-)
>>
>> Well, the Tested-by never came, but since the patch looks ok to me I
>> went ahead and applied it anyway (with a minor fix to use G_N_ELEMENTS()
>> instead of your custom array length calculation).
>
> Sorry for the long delay. But I don't have the device so it sometimes
> takes a bit longer. Anyway, it doesn't do any harm if we apply it so
> yes, thanks for not forgetting about it.
>
> Cheers
> David
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-11-28 18:03 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-22 8:31 [PATCH bluez] wiimote: add Wii-Remote-Plus ID and name detection David Herrmann
2012-11-28 12:50 ` Johan Hedberg
2012-11-28 13:00 ` David Herrmann
2012-11-28 18:03 ` Peter Olson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox