• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Keine Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

system/bt


Commit MetaInfo

Revisionade8220ad7d7db85c3bd9b7600cd3c13d6e754ae (tree)
Zeit2016-10-07 23:53:37
AutorSchischu <schischu65@gmai...>
CommiterDan Pasanen

Log Message

bt: Add wiimote pairing support

Change-Id: Ie1e9fa445cc1967679f3d74277df4c594fca5330

Ändern Zusammenfassung

Diff

--- 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);
286286 *******************************************************************************/
287287 BOOLEAN btif_storage_is_restricted_device(const bt_bdaddr_t *remote_bd_addr);
288288
289+/*******************************************************************************
290+**
291+** Function btif_storage_is_wiimote
292+**
293+** Description BTIF storage API - checks if this device is a wiimote
294+**
295+** Returns TRUE if the device is found in wiimote device list
296+** FALSE otherwise
297+**
298+*******************************************************************************/
299+BOOLEAN btif_storage_is_wiimote(bt_bdaddr_t *remote_bd_addr, bt_bdname_t *remote_bd_name);
300+
289301 #if (BLE_INCLUDED == TRUE)
290302 bt_status_t btif_storage_add_ble_bonding_key( bt_bdaddr_t *remote_bd_addr,
291303 char *key,
--- a/btif/src/btif_dm.c
+++ b/btif/src/btif_dm.c
@@ -70,6 +70,7 @@
7070 #define COD_MASK 0x07FF
7171
7272 #define COD_UNCLASSIFIED ((0x1F) << 8)
73+#define COD_HID_JOYSTICK 0x0504
7374 #define COD_HID_KEYBOARD 0x0540
7475 #define COD_HID_POINTING 0x0580
7576 #define COD_HID_COMBO 0x05C0
@@ -1089,6 +1090,33 @@ static void btif_dm_pin_req_evt(tBTA_DM_PIN_REQ *p_pin_req)
10891090 return;
10901091 }
10911092 }
1093+ else if (check_cod(&bd_addr, COD_HID_JOYSTICK))
1094+ {
1095+ if(( btif_storage_is_wiimote (&bd_addr, &bd_name) == TRUE) &&
1096+ (pairing_cb.autopair_attempts == 0))
1097+ {
1098+ bt_bdaddr_t ad_addr;
1099+ bt_status_t status;
1100+ bt_property_t prop;
1101+ prop.type = BT_PROPERTY_BDADDR;
1102+ prop.val = (void*) &ad_addr;
1103+
1104+ status = btif_storage_get_adapter_property(&prop);
1105+
1106+ BTIF_TRACE_DEBUG("%s() Attempting auto pair", __FUNCTION__);
1107+
1108+ pin_code.pin[0] = ad_addr.address[5];
1109+ pin_code.pin[1] = ad_addr.address[4];
1110+ pin_code.pin[2] = ad_addr.address[3];
1111+ pin_code.pin[3] = ad_addr.address[2];
1112+ pin_code.pin[4] = ad_addr.address[1];
1113+ pin_code.pin[5] = ad_addr.address[0];
1114+
1115+ pairing_cb.autopair_attempts++;
1116+ BTA_DmPinReply( (UINT8*)bd_addr.address, TRUE, 6, pin_code.pin);
1117+ return;
1118+ }
1119+ }
10921120 }
10931121 HAL_CBACK(bt_hal_cbacks, pin_request_cb,
10941122 &bd_addr, &bd_name, cod, p_pin_req->min_16_digit);
--- 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)
15051505
15061506 return btif_config_exist(bdstr, "Restricted");
15071507 }
1508+
1509+static const char *wii_names[4] = {
1510+ "Nintendo RVL-CNT-01", /* 1st gen */
1511+ "Nintendo RVL-CNT-01-TR", /* 2nd gen */
1512+ "Nintendo RVL-CNT-01-UC", /* Wii U Pro Controller */
1513+ "Nintendo RVL-WBC-01", /* Balance Board */
1514+};
1515+
1516+/*******************************************************************************
1517+**
1518+** Function btif_storage_is_wiimote
1519+**
1520+** Description BTIF storage API - checks if this device is a wiimote
1521+**
1522+** Returns TRUE if the device is found in wiimote device list
1523+** FALSE otherwise
1524+**
1525+*******************************************************************************/
1526+BOOLEAN btif_storage_is_wiimote(bt_bdaddr_t *remote_bd_addr, bt_bdname_t *remote_bd_name)
1527+{
1528+ uint8_t wii_names_size = sizeof(wii_names) / sizeof(wii_names[0]);
1529+ uint8_t i = 0;
1530+
1531+ /* Check device name */
1532+ for (i = 0; i < wii_names_size; i++)
1533+ {
1534+ if (!strcmp((char*)remote_bd_name->name, wii_names[i]))
1535+ return TRUE;
1536+ }
1537+
1538+ return FALSE;
1539+
1540+}