summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVegard Storheil Eriksen <zyp@jvnv.net>2014-02-27 23:20:52 +0100
committerVegard Storheil Eriksen <zyp@jvnv.net>2014-02-27 23:22:03 +0100
commite28cc949460b4940fb31f33cbbfd030ffe96de4f (patch)
tree58f314f5ac86b72b719826a7381625fa2c1bf600
parent88e93d1d8a56112818e7360888aa9a2e3af52883 (diff)
Implemented configurable label.
-rw-r--r--main.cpp22
1 files 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: