Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions firmware/src/our_descriptor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions firmware/src/our_descriptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
12 changes: 10 additions & 2 deletions firmware/src/tinyusb_stuff.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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];
Expand Down