system/bt
Revision | ade8220ad7d7db85c3bd9b7600cd3c13d6e754ae (tree) |
---|---|
Zeit | 2016-10-07 23:53:37 |
Autor | Schischu <schischu65@gmai...> |
Commiter | Dan Pasanen |
bt: Add wiimote pairing support
Change-Id: Ie1e9fa445cc1967679f3d74277df4c594fca5330
@@ -286,6 +286,18 @@ bt_status_t btif_storage_remove_hid_info(bt_bdaddr_t *remote_bd_addr); | ||
286 | 286 | *******************************************************************************/ |
287 | 287 | BOOLEAN btif_storage_is_restricted_device(const bt_bdaddr_t *remote_bd_addr); |
288 | 288 | |
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 | + | |
289 | 301 | #if (BLE_INCLUDED == TRUE) |
290 | 302 | bt_status_t btif_storage_add_ble_bonding_key( bt_bdaddr_t *remote_bd_addr, |
291 | 303 | char *key, |
@@ -70,6 +70,7 @@ | ||
70 | 70 | #define COD_MASK 0x07FF |
71 | 71 | |
72 | 72 | #define COD_UNCLASSIFIED ((0x1F) << 8) |
73 | +#define COD_HID_JOYSTICK 0x0504 | |
73 | 74 | #define COD_HID_KEYBOARD 0x0540 |
74 | 75 | #define COD_HID_POINTING 0x0580 |
75 | 76 | #define COD_HID_COMBO 0x05C0 |
@@ -1089,6 +1090,33 @@ static void btif_dm_pin_req_evt(tBTA_DM_PIN_REQ *p_pin_req) | ||
1089 | 1090 | return; |
1090 | 1091 | } |
1091 | 1092 | } |
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 | + } | |
1092 | 1120 | } |
1093 | 1121 | HAL_CBACK(bt_hal_cbacks, pin_request_cb, |
1094 | 1122 | &bd_addr, &bd_name, cod, p_pin_req->min_16_digit); |
@@ -1505,3 +1505,36 @@ BOOLEAN btif_storage_is_restricted_device(const bt_bdaddr_t *remote_bd_addr) | ||
1505 | 1505 | |
1506 | 1506 | return btif_config_exist(bdstr, "Restricted"); |
1507 | 1507 | } |
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 | +} |