updated on Sun Jan 15 16:02:00 UTC 2012
[aur-mirror.git] / bluez-git-wiimote / 0002-Detect-Wii-Remotes-by-device-name.patch
bloba8f0a8b754fe2adcdeb6772c959c8fa3e470041a
1 From ee2b70a486671016ca33e48fe25c99474465e1c4 Mon Sep 17 00:00:00 2001
2 From: David Herrmann <dh.herrmann@googlemail.com>
3 Date: Thu, 29 Dec 2011 17:35:30 +0100
4 Subject: [PATCH 2/2] Detect Wii Remotes by device name
6 We currently detect Wii Remotes by DID information. However, not all Wii Remotes
7 (especially 3rd party Wii Remotes) provide DID information. Moreover, they
8 provide no way of identifying them aside from their device name. Hence, this
9 adds an experimental name-detection for Wii Remotes.
10 ---
11 plugins/wiimote.c | 13 ++++++++-----
12 1 files changed, 8 insertions(+), 5 deletions(-)
14 diff --git a/plugins/wiimote.c b/plugins/wiimote.c
15 index 1ae638b..568bfd5 100644
16 --- a/plugins/wiimote.c
17 +++ b/plugins/wiimote.c
18 @@ -26,6 +26,7 @@
19 #endif
21 #include <bluetooth/bluetooth.h>
22 +#include <glib.h>
24 #include "plugin.h"
25 #include "adapter.h"
26 @@ -60,18 +61,20 @@ static ssize_t wii_pincb(struct btd_adapter *adapter, struct btd_device *device,
28 uint16_t vendor, product;
29 bdaddr_t sba, dba;
30 - char addr[18];
31 + char addr[18], name[25];
33 adapter_get_address(adapter, &sba);
34 device_get_address(device, &dba, NULL);
35 ba2str(&dba, addr);
37 vendor = btd_device_get_vendor(device);
38 - if (vendor != 0x057e)
39 - return 0;
41 product = btd_device_get_product(device);
42 - if (product == 0x0306) {
44 + device_get_name(device, name, sizeof(name));
45 + name[sizeof(name) - 1] = 0;
47 + if (g_str_equal(name, "Nintendo RVL-CNT-01") ||
48 + (vendor == 0x057e && product == 0x0306)) {
49 DBG("Forcing fixed pin on detected wiimote %s", addr);
50 memcpy(pinbuf, &sba, 6);
51 return 6;
52 --
53 1.7.8.1