diff --git a/src/btrCore.c b/src/btrCore.c index c97a173..1abe189 100644 --- a/src/btrCore.c +++ b/src/btrCore.c @@ -70,6 +70,7 @@ int b_rdk_logger_enabled = 0; #define BTRCORE_REMOTE_OUI_LENGTH 8 #define BTRCORE_AMAZON_OUI_LENGTH 8 #define BTRCORE_GOOGLE_OUI_LENGTH 8 +#define BTRCORE_XBOX_GEN3_OUI_LENGTH 8 static char * BTRCORE_REMOTE_OUI_VALUES[] = { "20:44:41", //LC103 @@ -96,6 +97,13 @@ static char * BTRCORE_GOOGLE_OUI_VALUES[] = { "CA:7B:25", //Stadia2TFX-0fa6 NULL }; + +static char * BTRCORE_XBOX_GEN3_OUI_VALUES[] = { + "44:16:22", // Microsoft (Xbox Gen3) + "9C:AA:1B", // Microsoft (Xbox Gen3) + NULL +}; + /* Local types */ //TODO: Move to a private header typedef enum _enBTRCoreTaskOp { @@ -857,6 +865,25 @@ static BOOLEAN btrCore_IsLunaGamepad( } return FALSE; } + +static BOOLEAN btrCore_IsXboxGen3Gamepad( + char * pcAddress +) { + unsigned char i; + if (pcAddress == NULL) { + BTRCORELOG_ERROR("Received NULL mac address\n"); + return FALSE; + } + + for (i = 0; BTRCORE_XBOX_GEN3_OUI_VALUES[i] != NULL; i++) { + if (!strncmp(pcAddress, BTRCORE_XBOX_GEN3_OUI_VALUES[i], BTRCORE_XBOX_GEN3_OUI_LENGTH)) { + BTRCORELOG_DEBUG("Device OUI matches Xbox Gen3 gamepad\n"); + return TRUE; + } + } + return FALSE; +} + static BOOLEAN btrCore_IsDeviceRdkRcu( char * pcAddress, unsigned short ui16Appearance @@ -7113,6 +7140,23 @@ btrCore_BTDeviceStatusUpdateCb ( strncpy(FoundDevice.pcDeviceName, apstBTDeviceInfo->pcName, BD_NAME_LEN); strncpy(FoundDevice.pcDeviceAddress, apstBTDeviceInfo->pcAddress, BD_NAME_LEN); + /* Xbox Gen3 exception: force immediate UI update with a temporary name */ + if (btrCore_IsDevNameSameAsAddress(&FoundDevice) && + (lenBTRCoreDevType == enBTRCoreHID) && + btrCore_IsXboxGen3Gamepad(FoundDevice.pcDeviceAddress)) { + static const char* xboxTempName = "Xbox Wireless Controller"; + errno_t rc; + MEMSET_S(FoundDevice.pcDeviceName, sizeof(FoundDevice.pcDeviceName), 0, sizeof(FoundDevice.pcDeviceName)); + rc = strcpy_s(FoundDevice.pcDeviceName, sizeof(FoundDevice.pcDeviceName), xboxTempName); + ERR_CHK(rc); + MEMSET_S(apstBTDeviceInfo->pcName, sizeof(apstBTDeviceInfo->pcName), 0, sizeof(apstBTDeviceInfo->pcName)); + rc = strcpy_s(apstBTDeviceInfo->pcName, sizeof(apstBTDeviceInfo->pcName), xboxTempName); + ERR_CHK(rc); + + BTRCORELOG_INFO("Gen3 detected by OUI; forcing UI update with temporary name for %s\n",FoundDevice.pcDeviceName); + } + + if(btrCore_IsDevNameSameAsAddress(&FoundDevice)) { if ((lenBTRCoreDevType == enBTRCoreSpeakers) || (lenBTRCoreDevType == enBTRCoreHeadSet) || (enBTRCoreHID == lenBTRCoreDevType)) { BTRCORELOG_INFO("pcName - %s pcAddress - %s DeviceType - %d skipCount - %lld\n",apstBTDeviceInfo->pcName,apstBTDeviceInfo->pcAddress,lenBTRCoreDevType,lpstlhBTRCore->skipDeviceDiscUpdate);