mirror of
https://github.com/Relintai/sdl2_frt.git
synced 2024-12-20 22:16:49 +01:00
Strip trailing whitespace on controller manufacturer identification
This commit is contained in:
parent
cd515bd1b9
commit
23c39a2e44
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user