summaryrefslogtreecommitdiff
path: root/tmk_core/protocol/usb_descriptor.c
diff options
context:
space:
mode:
authorRyan <fauxpark@gmail.com>2020-12-05 21:14:19 +1100
committerDrashna Jael're <drashna@live.com>2021-01-12 22:46:06 -0800
commit3272f6ee6abd3dcfdff4de3bb11369f7e9365c54 (patch)
tree1bc9022c64bea1df230c3e3d5f19e27b5dd0e1f5 /tmk_core/protocol/usb_descriptor.c
parent10d4cfd8dd2fed2ecc530c95d513f12f36696b63 (diff)
Omit serial number if not defined (#11104)
Diffstat (limited to 'tmk_core/protocol/usb_descriptor.c')
-rw-r--r--tmk_core/protocol/usb_descriptor.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/tmk_core/protocol/usb_descriptor.c b/tmk_core/protocol/usb_descriptor.c
index 1d5a62aaa1..4a5edb1907 100644
--- a/tmk_core/protocol/usb_descriptor.c
+++ b/tmk_core/protocol/usb_descriptor.c
@@ -386,7 +386,11 @@ const USB_Descriptor_Device_t PROGMEM DeviceDescriptor = {
.ReleaseNumber = DEVICE_VER,
.ManufacturerStrIndex = 0x01,
.ProductStrIndex = 0x02,
+#if defined(SERIAL_NUMBER)
.SerialNumStrIndex = 0x03,
+#else
+ .SerialNumStrIndex = 0x00,
+#endif
.NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS
};
@@ -994,10 +998,7 @@ const USB_Descriptor_String_t PROGMEM ProductString = {
.UnicodeString = LSTR(PRODUCT)
};
-#ifndef SERIAL_NUMBER
-# define SERIAL_NUMBER 0
-#endif
-
+#if defined(SERIAL_NUMBER)
const USB_Descriptor_String_t PROGMEM SerialNumberString = {
.Header = {
.Size = USB_STRING_LEN(sizeof(STR(SERIAL_NUMBER)) - 1), // Subtract 1 for null terminator
@@ -1005,6 +1006,7 @@ const USB_Descriptor_String_t PROGMEM SerialNumberString = {
},
.UnicodeString = LSTR(SERIAL_NUMBER)
};
+#endif
// clang-format on
@@ -1056,11 +1058,13 @@ uint16_t get_usb_descriptor(const uint16_t wValue, const uint16_t wIndex, const
Size = pgm_read_byte(&ProductString.Header.Size);
break;
+#if defined(SERIAL_NUMBER)
case 0x03:
Address = &SerialNumberString;
Size = pgm_read_byte(&SerialNumberString.Header.Size);
break;
+#endif
}
break;