aboutsummaryrefslogtreecommitdiff
path: root/tmk_core/protocol
diff options
context:
space:
mode:
Diffstat (limited to 'tmk_core/protocol')
-rw-r--r--tmk_core/protocol/arm_atsam/usb/udi_device_conf.h10
-rw-r--r--tmk_core/protocol/chibios/usb_main.c36
-rw-r--r--tmk_core/protocol/chibios/usb_util.c2
-rw-r--r--tmk_core/protocol/lufa/lufa.c34
-rw-r--r--tmk_core/protocol/lufa/usb_util.c2
-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/usb_util.c2
-rw-r--r--tmk_core/protocol/vusb/vusb.c7
9 files changed, 56 insertions, 47 deletions
diff --git a/tmk_core/protocol/arm_atsam/usb/udi_device_conf.h b/tmk_core/protocol/arm_atsam/usb/udi_device_conf.h
index 9c9d94789..1c0983115 100644
--- a/tmk_core/protocol/arm_atsam/usb/udi_device_conf.h
+++ b/tmk_core/protocol/arm_atsam/usb/udi_device_conf.h
@@ -23,6 +23,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
23#include "compiler.h" 23#include "compiler.h"
24#include "usb_protocol_hid.h" 24#include "usb_protocol_hid.h"
25 25
26#ifndef USB_POLLING_INTERVAL_MS
27# define USB_POLLING_INTERVAL_MS 10
28#endif
29
26#ifdef VIRTSER_ENABLE 30#ifdef VIRTSER_ENABLE
27// because CDC uses IAD (interface association descriptor 31// because CDC uses IAD (interface association descriptor
28// per USB Interface Association Descriptor Device Class Code and Use Model 7/23/2003 Rev 1.0) 32// per USB Interface Association Descriptor Device Class Code and Use Model 7/23/2003 Rev 1.0)
@@ -118,7 +122,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
118#define UDI_HID_KBD_EP_IN KEYBOARD_IN_EPNUM 122#define UDI_HID_KBD_EP_IN KEYBOARD_IN_EPNUM
119#define NEXT_IN_EPNUM_1 (KEYBOARD_IN_EPNUM + 1) 123#define NEXT_IN_EPNUM_1 (KEYBOARD_IN_EPNUM + 1)
120#define UDI_HID_KBD_EP_SIZE KEYBOARD_EPSIZE 124#define UDI_HID_KBD_EP_SIZE KEYBOARD_EPSIZE
121#define KBD_POLLING_INTERVAL 10 125#define KBD_POLLING_INTERVAL USB_POLLING_INTERVAL_MS
122#ifndef UDI_HID_KBD_STRING_ID 126#ifndef UDI_HID_KBD_STRING_ID
123# define UDI_HID_KBD_STRING_ID 0 127# define UDI_HID_KBD_STRING_ID 0
124#endif 128#endif
@@ -128,7 +132,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
128# define NEXT_IN_EPNUM_2 (MOUSE_IN_EPNUM + 1) 132# define NEXT_IN_EPNUM_2 (MOUSE_IN_EPNUM + 1)
129# define UDI_HID_MOU_EP_IN MOUSE_IN_EPNUM 133# define UDI_HID_MOU_EP_IN MOUSE_IN_EPNUM
130# define UDI_HID_MOU_EP_SIZE MOUSE_EPSIZE 134# define UDI_HID_MOU_EP_SIZE MOUSE_EPSIZE
131# define MOU_POLLING_INTERVAL 10 135# define MOU_POLLING_INTERVAL USB_POLLING_INTERVAL_MS
132# ifndef UDI_HID_MOU_STRING_ID 136# ifndef UDI_HID_MOU_STRING_ID
133# define UDI_HID_MOU_STRING_ID 0 137# define UDI_HID_MOU_STRING_ID 0
134# endif 138# endif
@@ -141,7 +145,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
141# define UDI_HID_EXK_EP_IN EXTRAKEY_IN_EPNUM 145# define UDI_HID_EXK_EP_IN EXTRAKEY_IN_EPNUM
142# define NEXT_IN_EPNUM_3 (EXTRAKEY_IN_EPNUM + 1) 146# define NEXT_IN_EPNUM_3 (EXTRAKEY_IN_EPNUM + 1)
143# define UDI_HID_EXK_EP_SIZE EXTRAKEY_EPSIZE 147# define UDI_HID_EXK_EP_SIZE EXTRAKEY_EPSIZE
144# define EXTRAKEY_POLLING_INTERVAL 10 148# define EXTRAKEY_POLLING_INTERVAL USB_POLLING_INTERVAL_MS
145# ifndef UDI_HID_EXK_STRING_ID 149# ifndef UDI_HID_EXK_STRING_ID
146# define UDI_HID_EXK_STRING_ID 0 150# define UDI_HID_EXK_STRING_ID 0
147# endif 151# endif
diff --git a/tmk_core/protocol/chibios/usb_main.c b/tmk_core/protocol/chibios/usb_main.c
index d04302aca..3adbb9799 100644
--- a/tmk_core/protocol/chibios/usb_main.c
+++ b/tmk_core/protocol/chibios/usb_main.c
@@ -518,7 +518,7 @@ static uint16_t get_hword(uint8_t *p) {
518 * Other Device Required Optional Optional Optional Optional Optional 518 * Other Device Required Optional Optional Optional Optional Optional
519 */ 519 */
520 520
521static uint8_t set_report_buf[2] __attribute__((aligned(2))); 521static uint8_t set_report_buf[2] __attribute__((aligned(4)));
522static void set_led_transfer_cb(USBDriver *usbp) { 522static void set_led_transfer_cb(USBDriver *usbp) {
523 if (usbp->setup[6] == 2) { /* LSB(wLength) */ 523 if (usbp->setup[6] == 2) { /* LSB(wLength) */
524 uint8_t report_id = set_report_buf[0]; 524 uint8_t report_id = set_report_buf[0];
@@ -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/chibios/usb_util.c b/tmk_core/protocol/chibios/usb_util.c
index 5945e8a8d..e32d6ebfa 100644
--- a/tmk_core/protocol/chibios/usb_util.c
+++ b/tmk_core/protocol/chibios/usb_util.c
@@ -16,6 +16,6 @@
16#include <hal.h> 16#include <hal.h>
17#include "usb_util.h" 17#include "usb_util.h"
18 18
19void usb_disable(void) { usbStop(&USBD1); } 19void usb_disconnect(void) { usbStop(&USBD1); }
20 20
21bool usb_connected_state(void) { return usbGetDriverStateI(&USBD1) == USB_ACTIVE; } 21bool usb_connected_state(void) { return usbGetDriverStateI(&USBD1) == USB_ACTIVE; }
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/lufa/usb_util.c b/tmk_core/protocol/lufa/usb_util.c
index 9e943a21b..9691eff1e 100644
--- a/tmk_core/protocol/lufa/usb_util.c
+++ b/tmk_core/protocol/lufa/usb_util.c
@@ -17,7 +17,7 @@
17#include "usb_util.h" 17#include "usb_util.h"
18#include "wait.h" 18#include "wait.h"
19 19
20void usb_disable(void) { 20void usb_disconnect(void) {
21 USB_Disable(); 21 USB_Disable();
22 USB_DeviceState = DEVICE_STATE_Unattached; 22 USB_DeviceState = DEVICE_STATE_Unattached;
23} 23}
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/usb_util.c b/tmk_core/protocol/vusb/usb_util.c
index 602854dbe..4ee2d3188 100644
--- a/tmk_core/protocol/vusb/usb_util.c
+++ b/tmk_core/protocol/vusb/usb_util.c
@@ -16,7 +16,7 @@
16#include <usbdrv/usbdrv.h> 16#include <usbdrv/usbdrv.h>
17#include "usb_util.h" 17#include "usb_util.h"
18 18
19void usb_disable(void) { usbDeviceDisconnect(); } 19void usb_disconnect(void) { usbDeviceDisconnect(); }
20 20
21bool usb_connected_state(void) { 21bool usb_connected_state(void) {
22 usbPoll(); 22 usbPoll();
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