Strip trailing whitespace on controller manufacturer identification

Sam Lantinga 2019-12-12 19:14:37 -08:00
parent cd515bd1b9
commit 23c39a2e44
1 changed files with 8 additions and 0 deletions

View File

@ -405,6 +405,7 @@ GetDeviceInfo(IOHIDDeviceRef hidDevice, recDevice *pDevice)
CFTypeRef refCF = NULL;
CFArrayRef array = NULL;
Uint16 *guid16 = (Uint16 *)pDevice->guid.data;
int i;
/* get usage page and usage */
refCF = IOHIDDeviceGetProperty(hidDevice, CFSTR(kIOHIDPrimaryUsagePageKey));
@ -456,6 +457,13 @@ GetDeviceInfo(IOHIDDeviceRef hidDevice, recDevice *pDevice)
if ((!refCF) || (!CFStringGetCString(refCF, product_string, sizeof(product_string), kCFStringEncodingUTF8))) {
SDL_strlcpy(product_string, "Unidentified joystick", sizeof(product_string));
}
for (i = SDL_strlen(manufacturer_string) - 1; i > 0; --i) {
if (SDL_isspace(manufacturer_string[i])) {
manufacturer_string[i] = '\0';
} else {
break;
}
}
if (SDL_strncasecmp(manufacturer_string, product_string, SDL_strlen(manufacturer_string)) == 0) {
SDL_strlcpy(pDevice->product, product_string, sizeof(pDevice->product));
} else {