From e28cc949460b4940fb31f33cbbfd030ffe96de4f Mon Sep 17 00:00:00 2001 From: Vegard Storheil Eriksen Date: Thu, 27 Feb 2014 23:20:52 +0100 Subject: Implemented configurable label. --- main.cpp | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/main.cpp b/main.cpp index 26ad6de..d7d3a5c 100644 --- a/main.cpp +++ b/main.cpp @@ -449,7 +449,8 @@ class USB_strings : public USB_class_driver { // Get string descriptor. if(bmRequestType == 0x80 && bRequest == 0x06 && (wValue & 0xff00) == 0x0300) { const void* desc = nullptr; - uint16_t buf[9]; + uint16_t buf[64] = {0x300}; + uint32_t i = 1; switch(wValue & 0xff) { case 0: @@ -461,7 +462,24 @@ class USB_strings : public USB_class_driver { break; case 2: - desc = u"\u030carcin"; + for(const char* p = "arcin"; *p; p++) { + buf[i++] = *p; + } + + if(config.label[0]) { + buf[i++] = ' '; + buf[i++] = '('; + + for(uint8_t* p = config.label; *p; p++) { + buf[i++] = *p; + } + + buf[i++] = ')'; + } + + buf[0] |= i * 2; + + desc = buf; break; case 3: -- cgit v1.2.3