Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions src/btrCore.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
Loading