aboutsummaryrefslogtreecommitdiff
path: root/tmk_core/protocol
diff options
context:
space:
mode:
Diffstat (limited to 'tmk_core/protocol')
-rw-r--r--tmk_core/protocol/chibios/usb_main.c34
-rw-r--r--tmk_core/protocol/lufa/lufa.c34
-rw-r--r--tmk_core/protocol/usb_descriptor.c6
-rw-r--r--tmk_core/protocol/usb_descriptor_common.h4
-rw-r--r--tmk_core/protocol/vusb/vusb.c7
5 files changed, 45 insertions, 40 deletions
diff --git a/tmk_core/protocol/chibios/usb_main.c b/tmk_core/protocol/chibios/usb_main.c
index d04302aca..407b8ea75 100644
--- a/tmk_core/protocol/chibios/usb_main.c
+++ b/tmk_core/protocol/chibios/usb_main.c
@@ -903,7 +903,8 @@ static void send_extra(uint8_t report_id, uint16_t data) {
903 return; 903 return;
904 } 904 }
905 905
906 report_extra_t report = {.report_id = report_id, .usage = data}; 906 static report_extra_t report;
907 report = (report_extra_t){.report_id = report_id, .usage = data};
907 908
908 usbStartTransmitI(&USB_DRIVER, SHARED_IN_EPNUM, (uint8_t *)&report, sizeof(report_extra_t)); 909 usbStartTransmitI(&USB_DRIVER, SHARED_IN_EPNUM, (uint8_t *)&report, sizeof(report_extra_t));
909 osalSysUnlock(); 910 osalSysUnlock();
@@ -1051,45 +1052,44 @@ void virtser_task(void) {
1051#ifdef JOYSTICK_ENABLE 1052#ifdef JOYSTICK_ENABLE
1052 1053
1053void send_joystick_packet(joystick_t *joystick) { 1054void send_joystick_packet(joystick_t *joystick) {
1054 joystick_report_t rep = { 1055 static joystick_report_t rep;
1056 rep = (joystick_report_t) {
1055# if JOYSTICK_AXES_COUNT > 0 1057# if JOYSTICK_AXES_COUNT > 0
1056 .axes = 1058 .axes =
1057 { 1059 { joystick->axes[0],
1058 joystick->axes[0],
1059 1060
1060# if JOYSTICK_AXES_COUNT >= 2 1061# if JOYSTICK_AXES_COUNT >= 2
1061 joystick->axes[1], 1062 joystick->axes[1],
1062# endif 1063# endif
1063# if JOYSTICK_AXES_COUNT >= 3 1064# if JOYSTICK_AXES_COUNT >= 3
1064 joystick->axes[2], 1065 joystick->axes[2],
1065# endif 1066# endif
1066# if JOYSTICK_AXES_COUNT >= 4 1067# if JOYSTICK_AXES_COUNT >= 4
1067 joystick->axes[3], 1068 joystick->axes[3],
1068# endif 1069# endif
1069# if JOYSTICK_AXES_COUNT >= 5 1070# if JOYSTICK_AXES_COUNT >= 5
1070 joystick->axes[4], 1071 joystick->axes[4],
1071# endif 1072# endif
1072# if JOYSTICK_AXES_COUNT >= 6 1073# if JOYSTICK_AXES_COUNT >= 6
1073 joystick->axes[5], 1074 joystick->axes[5],
1074# endif 1075# endif
1075 }, 1076 },
1076# endif // JOYSTICK_AXES_COUNT>0 1077# endif // JOYSTICK_AXES_COUNT>0
1077 1078
1078# if JOYSTICK_BUTTON_COUNT > 0 1079# if JOYSTICK_BUTTON_COUNT > 0
1079 .buttons = 1080 .buttons = {
1080 { 1081 joystick->buttons[0],
1081 joystick->buttons[0],
1082 1082
1083# if JOYSTICK_BUTTON_COUNT > 8 1083# if JOYSTICK_BUTTON_COUNT > 8
1084 joystick->buttons[1], 1084 joystick->buttons[1],
1085# endif 1085# endif
1086# if JOYSTICK_BUTTON_COUNT > 16 1086# if JOYSTICK_BUTTON_COUNT > 16
1087 joystick->buttons[2], 1087 joystick->buttons[2],
1088# endif 1088# endif
1089# if JOYSTICK_BUTTON_COUNT > 24 1089# if JOYSTICK_BUTTON_COUNT > 24
1090 joystick->buttons[3], 1090 joystick->buttons[3],
1091# endif 1091# endif
1092 } 1092 }
1093# endif // JOYSTICK_BUTTON_COUNT>0 1093# endif // JOYSTICK_BUTTON_COUNT>0
1094 }; 1094 };
1095 1095
diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c
index 63619fdb3..4ac079e16 100644
--- a/tmk_core/protocol/lufa/lufa.c
+++ b/tmk_core/protocol/lufa/lufa.c
@@ -314,45 +314,44 @@ static void Console_Task(void) {
314void send_joystick_packet(joystick_t *joystick) { 314void send_joystick_packet(joystick_t *joystick) {
315 uint8_t timeout = 255; 315 uint8_t timeout = 255;
316 316
317 joystick_report_t r = { 317 static joystick_report_t;
318 r = (joystick_report_t) {
318# if JOYSTICK_AXES_COUNT > 0 319# if JOYSTICK_AXES_COUNT > 0
319 .axes = 320 .axes =
320 { 321 { joystick->axes[0],
321 joystick->axes[0],
322 322
323# if JOYSTICK_AXES_COUNT >= 2 323# if JOYSTICK_AXES_COUNT >= 2
324 joystick->axes[1], 324 joystick->axes[1],
325# endif 325# endif
326# if JOYSTICK_AXES_COUNT >= 3 326# if JOYSTICK_AXES_COUNT >= 3
327 joystick->axes[2], 327 joystick->axes[2],
328# endif 328# endif
329# if JOYSTICK_AXES_COUNT >= 4 329# if JOYSTICK_AXES_COUNT >= 4
330 joystick->axes[3], 330 joystick->axes[3],
331# endif 331# endif
332# if JOYSTICK_AXES_COUNT >= 5 332# if JOYSTICK_AXES_COUNT >= 5
333 joystick->axes[4], 333 joystick->axes[4],
334# endif 334# endif
335# if JOYSTICK_AXES_COUNT >= 6 335# if JOYSTICK_AXES_COUNT >= 6
336 joystick->axes[5], 336 joystick->axes[5],
337# endif 337# endif
338 }, 338 },
339# endif // JOYSTICK_AXES_COUNT>0 339# endif // JOYSTICK_AXES_COUNT>0
340 340
341# if JOYSTICK_BUTTON_COUNT > 0 341# if JOYSTICK_BUTTON_COUNT > 0
342 .buttons = 342 .buttons = {
343 { 343 joystick->buttons[0],
344 joystick->buttons[0],
345 344
346# if JOYSTICK_BUTTON_COUNT > 8 345# if JOYSTICK_BUTTON_COUNT > 8
347 joystick->buttons[1], 346 joystick->buttons[1],
348# endif 347# endif
349# if JOYSTICK_BUTTON_COUNT > 16 348# if JOYSTICK_BUTTON_COUNT > 16
350 joystick->buttons[2], 349 joystick->buttons[2],
351# endif 350# endif
352# if JOYSTICK_BUTTON_COUNT > 24 351# if JOYSTICK_BUTTON_COUNT > 24
353 joystick->buttons[3], 352 joystick->buttons[3],
354# endif 353# endif
355 } 354 }
356# endif // JOYSTICK_BUTTON_COUNT>0 355# endif // JOYSTICK_BUTTON_COUNT>0
357 }; 356 };
358 357
@@ -768,7 +767,8 @@ static void send_extra(uint8_t report_id, uint16_t data) {
768 767
769 if (USB_DeviceState != DEVICE_STATE_Configured) return; 768 if (USB_DeviceState != DEVICE_STATE_Configured) return;
770 769
771 report_extra_t r = {.report_id = report_id, .usage = data}; 770 static report_extra_t r;
771 r = (report_extra_t){.report_id = report_id, .usage = data};
772 Endpoint_SelectEndpoint(SHARED_IN_EPNUM); 772 Endpoint_SelectEndpoint(SHARED_IN_EPNUM);
773 773
774 /* Check if write ready for a polling interval around 10ms */ 774 /* Check if write ready for a polling interval around 10ms */
diff --git a/tmk_core/protocol/usb_descriptor.c b/tmk_core/protocol/usb_descriptor.c
index ba7760f28..7a4a79031 100644
--- a/tmk_core/protocol/usb_descriptor.c
+++ b/tmk_core/protocol/usb_descriptor.c
@@ -351,7 +351,7 @@ const USB_Descriptor_Device_t PROGMEM DeviceDescriptor = {
351 .Size = sizeof(USB_Descriptor_Device_t), 351 .Size = sizeof(USB_Descriptor_Device_t),
352 .Type = DTYPE_Device 352 .Type = DTYPE_Device
353 }, 353 },
354 .USBSpecification = VERSION_BCD(1, 1, 0), 354 .USBSpecification = VERSION_BCD(2, 0, 0),
355 355
356#if VIRTSER_ENABLE 356#if VIRTSER_ENABLE
357 .Class = USB_CSCP_IADDeviceClass, 357 .Class = USB_CSCP_IADDeviceClass,
@@ -953,10 +953,10 @@ const USB_Descriptor_String_t PROGMEM ProductString = {
953#if defined(SERIAL_NUMBER) 953#if defined(SERIAL_NUMBER)
954const USB_Descriptor_String_t PROGMEM SerialNumberString = { 954const USB_Descriptor_String_t PROGMEM SerialNumberString = {
955 .Header = { 955 .Header = {
956 .Size = USB_STRING_LEN(sizeof(STR(SERIAL_NUMBER)) - 1), // Subtract 1 for null terminator 956 .Size = USB_STRING_LEN(sizeof(SERIAL_NUMBER) - 1), // Subtract 1 for null terminator
957 .Type = DTYPE_String 957 .Type = DTYPE_String
958 }, 958 },
959 .UnicodeString = LSTR(SERIAL_NUMBER) 959 .UnicodeString = USBSTR(SERIAL_NUMBER)
960}; 960};
961#endif 961#endif
962 962
diff --git a/tmk_core/protocol/usb_descriptor_common.h b/tmk_core/protocol/usb_descriptor_common.h
index b1f602c82..ce0cf0976 100644
--- a/tmk_core/protocol/usb_descriptor_common.h
+++ b/tmk_core/protocol/usb_descriptor_common.h
@@ -16,6 +16,10 @@
16 16
17#pragma once 17#pragma once
18 18
19// Prefix string literal with L for descriptors
20#define USBCONCAT(a, b) a##b
21#define USBSTR(s) USBCONCAT(L, s)
22
19///////////////////// 23/////////////////////
20// RAW Usage page and ID configuration 24// RAW Usage page and ID configuration
21 25
diff --git a/tmk_core/protocol/vusb/vusb.c b/tmk_core/protocol/vusb/vusb.c
index 9362fbde7..98cebf601 100644
--- a/tmk_core/protocol/vusb/vusb.c
+++ b/tmk_core/protocol/vusb/vusb.c
@@ -272,7 +272,8 @@ static void send_extra(uint8_t report_id, uint16_t data) {
272 last_id = report_id; 272 last_id = report_id;
273 last_data = data; 273 last_data = data;
274 274
275 report_extra_t report = {.report_id = report_id, .usage = data}; 275 static report_extra_t report;
276 report = (report_extra_t){.report_id = report_id, .usage = data};
276 if (usbInterruptIsReadyShared()) { 277 if (usbInterruptIsReadyShared()) {
277 usbSetInterruptShared((void *)&report, sizeof(report_extra_t)); 278 usbSetInterruptShared((void *)&report, sizeof(report_extra_t));
278 } 279 }
@@ -598,10 +599,10 @@ const PROGMEM usbStringDescriptor_t usbStringDescriptorProduct = {
598#if defined(SERIAL_NUMBER) 599#if defined(SERIAL_NUMBER)
599const PROGMEM usbStringDescriptor_t usbStringDescriptorSerial = { 600const PROGMEM usbStringDescriptor_t usbStringDescriptorSerial = {
600 .header = { 601 .header = {
601 .bLength = USB_STRING_LEN(sizeof(STR(SERIAL_NUMBER)) - 1), 602 .bLength = USB_STRING_LEN(sizeof(SERIAL_NUMBER) - 1),
602 .bDescriptorType = USBDESCR_STRING 603 .bDescriptorType = USBDESCR_STRING
603 }, 604 },
604 .bString = LSTR(SERIAL_NUMBER) 605 .bString = USBSTR(SERIAL_NUMBER)
605}; 606};
606#endif 607#endif
607 608