From 3469481ef6bcec91dc69f5deae9f146f1bc05317 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Tue, 10 Dec 2019 10:00:49 -0800 Subject: [PATCH] Don't include the manufacturer if it's already included in the product string --- src/joystick/hidapi/SDL_hidapijoystick.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/joystick/hidapi/SDL_hidapijoystick.c b/src/joystick/hidapi/SDL_hidapijoystick.c index ca6f3e39d59e6..1cca125c6ff8c 100644 --- a/src/joystick/hidapi/SDL_hidapijoystick.c +++ b/src/joystick/hidapi/SDL_hidapijoystick.c @@ -806,7 +806,11 @@ 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) { - SDL_snprintf(device->name, name_size, "%s %s", manufacturer_string, product_string); + 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) {