Don't include the manufacturer if it's already included in the product string

Sam Lantinga 2019-12-10 10:00:49 -08:00
parent bb37a1ebf5
commit 3469481ef6
1 changed files with 5 additions and 1 deletions

View File

@ -806,9 +806,13 @@ HIDAPI_AddDevice(struct hid_device_info *info)
size_t name_size = (SDL_strlen(manufacturer_string) + 1 + SDL_strlen(product_string) + 1);
device->name = (char *)SDL_malloc(name_size);
if (device->name) {
if (SDL_strncasecmp(manufacturer_string, product_string, SDL_strlen(manufacturer_string)) == 0) {
SDL_strlcpy(device->name, product_string, name_size);
} else {
SDL_snprintf(device->name, name_size, "%s %s", manufacturer_string, product_string);
}
}
}
if (manufacturer_string) {
SDL_free(manufacturer_string);
}