Skip to content

Commit

Permalink
Strip trailing whitespace on controller manufacturer identification
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed Dec 13, 2019
1 parent cd515bd commit 23c39a2
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/joystick/darwin/SDL_sysjoystick.c
Expand Up @@ -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));
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 23c39a2

Please sign in to comment.