summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSchischu <schischu65@gmail.com>2014-05-03 14:43:52 +0200
committerMichael Bestas <mikeioannina@gmail.com>2017-01-02 01:02:18 +0200
commitaa4939b4e214cd4e3406d590e5a9b8ada8f74ed3 (patch)
treed1a081a1c7a4f5431558c9c46d53f2319e70e8ab
parent733a458a4acc16aeb8ca8230ea85287f17afb98f (diff)
downloadandroid_system_bt-aa4939b4e214cd4e3406d590e5a9b8ada8f74ed3.tar.gz
android_system_bt-aa4939b4e214cd4e3406d590e5a9b8ada8f74ed3.tar.bz2
android_system_bt-aa4939b4e214cd4e3406d590e5a9b8ada8f74ed3.zip
bt: Add wiimote pairing support
Change-Id: Ie1e9fa445cc1967679f3d74277df4c594fca5330
-rw-r--r--btif/include/btif_storage.h12
-rw-r--r--btif/src/btif_dm.c28
-rw-r--r--btif/src/btif_storage.c33
3 files changed, 73 insertions, 0 deletions
diff --git a/btif/include/btif_storage.h b/btif/include/btif_storage.h
index 2da8bd121..2559c94df 100644
--- a/btif/include/btif_storage.h
+++ b/btif/include/btif_storage.h
@@ -286,6 +286,18 @@ bt_status_t btif_storage_remove_hid_info(bt_bdaddr_t *remote_bd_addr);
*******************************************************************************/
BOOLEAN btif_storage_is_restricted_device(const bt_bdaddr_t *remote_bd_addr);
+/*******************************************************************************
+**
+** Function btif_storage_is_wiimote
+**
+** Description BTIF storage API - checks if this device is a wiimote
+**
+** Returns TRUE if the device is found in wiimote device list
+** FALSE otherwise
+**
+*******************************************************************************/
+BOOLEAN btif_storage_is_wiimote(bt_bdaddr_t *remote_bd_addr, bt_bdname_t *remote_bd_name);
+
#if (BLE_INCLUDED == TRUE)
bt_status_t btif_storage_add_ble_bonding_key( bt_bdaddr_t *remote_bd_addr,
char *key,
diff --git a/btif/src/btif_dm.c b/btif/src/btif_dm.c
index 78a6c4cfc..b3a6e7bd0 100644
--- a/btif/src/btif_dm.c
+++ b/btif/src/btif_dm.c
@@ -70,6 +70,7 @@
#define COD_MASK 0x07FF
#define COD_UNCLASSIFIED ((0x1F) << 8)
+#define COD_HID_JOYSTICK 0x0504
#define COD_HID_KEYBOARD 0x0540
#define COD_HID_POINTING 0x0580
#define COD_HID_COMBO 0x05C0
@@ -1089,6 +1090,33 @@ static void btif_dm_pin_req_evt(tBTA_DM_PIN_REQ *p_pin_req)
return;
}
}
+ else if (check_cod(&bd_addr, COD_HID_JOYSTICK))
+ {
+ if(( btif_storage_is_wiimote (&bd_addr, &bd_name) == TRUE) &&
+ (pairing_cb.autopair_attempts == 0))
+ {
+ bt_bdaddr_t ad_addr;
+ bt_status_t status;
+ bt_property_t prop;
+ prop.type = BT_PROPERTY_BDADDR;
+ prop.val = (void*) &ad_addr;
+
+ status = btif_storage_get_adapter_property(&prop);
+
+ BTIF_TRACE_DEBUG("%s() Attempting auto pair", __FUNCTION__);
+
+ pin_code.pin[0] = ad_addr.address[5];
+ pin_code.pin[1] = ad_addr.address[4];
+ pin_code.pin[2] = ad_addr.address[3];
+ pin_code.pin[3] = ad_addr.address[2];
+ pin_code.pin[4] = ad_addr.address[1];
+ pin_code.pin[5] = ad_addr.address[0];
+
+ pairing_cb.autopair_attempts++;
+ BTA_DmPinReply( (UINT8*)bd_addr.address, TRUE, 6, pin_code.pin);
+ return;
+ }
+ }
}
HAL_CBACK(bt_hal_cbacks, pin_request_cb,
&bd_addr, &bd_name, cod, p_pin_req->min_16_digit);
diff --git a/btif/src/btif_storage.c b/btif/src/btif_storage.c
index 7fdb5141d..36bafa981 100644
--- a/btif/src/btif_storage.c
+++ b/btif/src/btif_storage.c
@@ -1505,3 +1505,36 @@ BOOLEAN btif_storage_is_restricted_device(const bt_bdaddr_t *remote_bd_addr)
return btif_config_exist(bdstr, "Restricted");
}
+
+static const char *wii_names[4] = {
+ "Nintendo RVL-CNT-01", /* 1st gen */
+ "Nintendo RVL-CNT-01-TR", /* 2nd gen */
+ "Nintendo RVL-CNT-01-UC", /* Wii U Pro Controller */
+ "Nintendo RVL-WBC-01", /* Balance Board */
+};
+
+/*******************************************************************************
+**
+** Function btif_storage_is_wiimote
+**
+** Description BTIF storage API - checks if this device is a wiimote
+**
+** Returns TRUE if the device is found in wiimote device list
+** FALSE otherwise
+**
+*******************************************************************************/
+BOOLEAN btif_storage_is_wiimote(bt_bdaddr_t *remote_bd_addr, bt_bdname_t *remote_bd_name)
+{
+ uint8_t wii_names_size = sizeof(wii_names) / sizeof(wii_names[0]);
+ uint8_t i = 0;
+
+ /* Check device name */
+ for (i = 0; i < wii_names_size; i++)
+ {
+ if (!strcmp((char*)remote_bd_name->name, wii_names[i]))
+ return TRUE;
+ }
+
+ return FALSE;
+
+}