From 18d97e52efbfef125ac85c9a54e798701ff62e7a Mon Sep 17 00:00:00 2001 From: alextrical <35117191+alextrical@users.noreply.github.com> Date: Sun, 22 Mar 2026 12:32:40 +0000 Subject: [PATCH] Added ability to define Manufacturer and Product name in device desctiptors --- firmware/src/our_descriptor.cc | 5 +++++ firmware/src/our_descriptor.h | 2 ++ firmware/src/tinyusb_stuff.cc | 12 ++++++++++-- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/firmware/src/our_descriptor.cc b/firmware/src/our_descriptor.cc index 0902867c..937d7123 100644 --- a/firmware/src/our_descriptor.cc +++ b/firmware/src/our_descriptor.cc @@ -656,6 +656,8 @@ const our_descriptor_def_t our_descriptors[] = { .descriptor_length = sizeof(our_report_descriptor_horipad), .vid = 0x0F0D, .pid = 0x00C1, + .manufacturer = "HORI CO., LTD.", + .product = "HORIPAD for Nintendo Switch", .handle_received_report = do_handle_received_report, .clear_report = horipad_clear_report, .default_value = horipad_default_value, @@ -666,6 +668,7 @@ const our_descriptor_def_t our_descriptors[] = { .descriptor_length = sizeof(our_report_descriptor_ps4), .vid = 0x054C, .pid = 0x1234, + .manufacturer = "Sony Corp.", .device_connected = ps4_device_connected, .device_disconnected = ps4_device_disconnected, .main_loop_task = ps4_main_loop_task, @@ -683,6 +686,8 @@ const our_descriptor_def_t our_descriptors[] = { .descriptor_length = sizeof(our_report_descriptor_stadia), .vid = 0x18D1, .pid = 0x9400, + .manufacturer = "Google Inc.", + .product = "Stadia Controller", .handle_received_report = do_handle_received_report, .clear_report = stadia_clear_report, .default_value = ps4_stadia_default_value, diff --git a/firmware/src/our_descriptor.h b/firmware/src/our_descriptor.h index e09a03af..dcc3a325 100644 --- a/firmware/src/our_descriptor.h +++ b/firmware/src/our_descriptor.h @@ -35,6 +35,8 @@ struct our_descriptor_def_t { uint32_t descriptor_length; uint16_t vid = 0; uint16_t pid = 0; + const char* manufacturer; + const char* product; device_connected_t device_connected = nullptr; device_disconnected_t device_disconnected = nullptr; main_loop_task_t main_loop_task = nullptr; diff --git a/firmware/src/tinyusb_stuff.cc b/firmware/src/tinyusb_stuff.cc index a9b81d20..c11cd650 100644 --- a/firmware/src/tinyusb_stuff.cc +++ b/firmware/src/tinyusb_stuff.cc @@ -161,7 +161,14 @@ uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid) { if (!(index < sizeof(string_desc_arr) / sizeof(string_desc_arr[0]))) return NULL; - const char* str = string_desc_arr[index]; + const char* str = NULL; + if (index == 1 && our_descriptor->manufacturer[0] != '\0') { + str = our_descriptor->manufacturer; + } else if (index == 2 && our_descriptor->product[0] != '\0') { + str = our_descriptor->product; + } else { + str = string_desc_arr[index]; + } // Cap at max char chr_count = strlen(str); @@ -173,7 +180,8 @@ uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid) { _desc_str[1 + i] = str[i]; } - if (index == 2) { + //write unique id, only if we haven't defined a specific device name + if (index == 2 && our_descriptor->product[0] == '\0') { uint64_t unique_id = get_unique_id(); for (uint8_t i = 0; i < 4; i++) { _desc_str[1 + chr_count - 4 + i] = id_chars[(unique_id >> (15 - i * 5)) & 0x1F];