From 37f932208bf8f6b4155e3bd16a888595866d70de Mon Sep 17 00:00:00 2001 From: LDA Date: Tue, 27 May 2025 17:29:37 +0200 Subject: [PATCH 1/2] [HACK] Get the interface count right, I guess --- src/usb/setup.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/usb/setup.c b/src/usb/setup.c index 8b800ea..af05e1f 100644 --- a/src/usb/setup.c +++ b/src/usb/setup.c @@ -138,8 +138,9 @@ static void write_configuration_descriptor(int wLength) { usb_interface_t const * const *interfaces = usb_configure_interfaces(); size_t total_length = sizeof(usb_dc_configuration_t); + size_t interface_count = 0; - for(int i = 0; interfaces[i]; i++) + for(int i = 0; interfaces[i]; i++, interface_count++) for(int k = 0; interfaces[i]->dc[k]; k++) { uint8_t const *dc = interfaces[i]->dc[k]; @@ -149,6 +150,7 @@ static void write_configuration_descriptor(int wLength) /* Write the configuration descriptor */ dc_configuration.wTotalLength = htole16(total_length); + dc_configuration.bNumInterfaces = interface_count; /* Small hack to get it to work, need to test */ dcp_write(&dc_configuration, dc_configuration.bLength); /* For the first call, the host usually wants only this */ if(wLength <= dc_configuration.bLength) return; From 048696eb25cede0f238642e1d125223f0c486eca Mon Sep 17 00:00:00 2001 From: LDA Date: Tue, 27 May 2025 19:23:42 +0200 Subject: [PATCH 2/2] [MOD] Actually remove that comment since everything works --- src/usb/setup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/usb/setup.c b/src/usb/setup.c index af05e1f..624f301 100644 --- a/src/usb/setup.c +++ b/src/usb/setup.c @@ -150,7 +150,7 @@ static void write_configuration_descriptor(int wLength) /* Write the configuration descriptor */ dc_configuration.wTotalLength = htole16(total_length); - dc_configuration.bNumInterfaces = interface_count; /* Small hack to get it to work, need to test */ + dc_configuration.bNumInterfaces = interface_count; dcp_write(&dc_configuration, dc_configuration.bLength); /* For the first call, the host usually wants only this */ if(wLength <= dc_configuration.bLength) return;