From 849e7fe1c36e4fc12fc50843c9c75739588c1cd1 Mon Sep 17 00:00:00 2001 From: fauxpark Date: Thu, 1 Jul 2021 21:15:16 +1000 Subject: [PATCH 1/2] Use string literals for `SERIAL_NUMBER` --- tmk_core/protocol/usb_descriptor.c | 4 ++-- tmk_core/protocol/usb_descriptor_common.h | 4 ++++ tmk_core/protocol/vusb/vusb.c | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/tmk_core/protocol/usb_descriptor.c b/tmk_core/protocol/usb_descriptor.c index c88aceb6ed5c..7a4a79031545 100644 --- a/tmk_core/protocol/usb_descriptor.c +++ b/tmk_core/protocol/usb_descriptor.c @@ -953,10 +953,10 @@ const USB_Descriptor_String_t PROGMEM ProductString = { #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 + .Size = USB_STRING_LEN(sizeof(SERIAL_NUMBER) - 1), // Subtract 1 for null terminator .Type = DTYPE_String }, - .UnicodeString = LSTR(SERIAL_NUMBER) + .UnicodeString = USBSTR(SERIAL_NUMBER) }; #endif diff --git a/tmk_core/protocol/usb_descriptor_common.h b/tmk_core/protocol/usb_descriptor_common.h index b1f602c82eba..198ff50165f5 100644 --- a/tmk_core/protocol/usb_descriptor_common.h +++ b/tmk_core/protocol/usb_descriptor_common.h @@ -16,6 +16,10 @@ #pragma once +// Prefix string literal with L for descriptors +#define USBCONCAT(a, b) a ## b +#define USBSTR(s) USBCONCAT(L, s) + ///////////////////// // RAW Usage page and ID configuration diff --git a/tmk_core/protocol/vusb/vusb.c b/tmk_core/protocol/vusb/vusb.c index 876a31378613..98cebf6012f9 100644 --- a/tmk_core/protocol/vusb/vusb.c +++ b/tmk_core/protocol/vusb/vusb.c @@ -599,10 +599,10 @@ const PROGMEM usbStringDescriptor_t usbStringDescriptorProduct = { #if defined(SERIAL_NUMBER) const PROGMEM usbStringDescriptor_t usbStringDescriptorSerial = { .header = { - .bLength = USB_STRING_LEN(sizeof(STR(SERIAL_NUMBER)) - 1), + .bLength = USB_STRING_LEN(sizeof(SERIAL_NUMBER) - 1), .bDescriptorType = USBDESCR_STRING }, - .bString = LSTR(SERIAL_NUMBER) + .bString = USBSTR(SERIAL_NUMBER) }; #endif From 38f65f19226e429e52ea11b3a1d98820216a9c1c Mon Sep 17 00:00:00 2001 From: fauxpark Date: Thu, 1 Jul 2021 22:45:28 +1000 Subject: [PATCH 2/2] Format --- tmk_core/protocol/usb_descriptor_common.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmk_core/protocol/usb_descriptor_common.h b/tmk_core/protocol/usb_descriptor_common.h index 198ff50165f5..ce0cf09763bc 100644 --- a/tmk_core/protocol/usb_descriptor_common.h +++ b/tmk_core/protocol/usb_descriptor_common.h @@ -17,7 +17,7 @@ #pragma once // Prefix string literal with L for descriptors -#define USBCONCAT(a, b) a ## b +#define USBCONCAT(a, b) a##b #define USBSTR(s) USBCONCAT(L, s) /////////////////////