aboutsummaryrefslogtreecommitdiff
path: root/tmk_core
diff options
context:
space:
mode:
Diffstat (limited to 'tmk_core')
-rw-r--r--tmk_core/common/report.h5
-rw-r--r--tmk_core/protocol/arm_atsam/main_arm_atsam.c26
-rw-r--r--tmk_core/protocol/chibios/usb_main.h14
-rw-r--r--tmk_core/protocol/lufa/lufa.c27
-rw-r--r--tmk_core/protocol/lufa/lufa.h6
-rw-r--r--tmk_core/protocol/vusb/vusb.c26
6 files changed, 39 insertions, 65 deletions
diff --git a/tmk_core/common/report.h b/tmk_core/common/report.h
index ccc6d599b..2a9dad881 100644
--- a/tmk_core/common/report.h
+++ b/tmk_core/common/report.h
@@ -151,6 +151,11 @@ typedef union {
151} __attribute__((packed)) report_keyboard_t; 151} __attribute__((packed)) report_keyboard_t;
152 152
153typedef struct { 153typedef struct {
154 uint8_t report_id;
155 uint16_t usage;
156} __attribute__((packed)) report_extra_t;
157
158typedef struct {
154#ifdef MOUSE_SHARED_EP 159#ifdef MOUSE_SHARED_EP
155 uint8_t report_id; 160 uint8_t report_id;
156#endif 161#endif
diff --git a/tmk_core/protocol/arm_atsam/main_arm_atsam.c b/tmk_core/protocol/arm_atsam/main_arm_atsam.c
index a42d9daf3..e15d51a26 100644
--- a/tmk_core/protocol/arm_atsam/main_arm_atsam.c
+++ b/tmk_core/protocol/arm_atsam/main_arm_atsam.c
@@ -110,40 +110,34 @@ void send_mouse(report_mouse_t *report) {
110#endif // MOUSEKEY_ENABLE 110#endif // MOUSEKEY_ENABLE
111} 111}
112 112
113void send_system(uint16_t data) {
114#ifdef EXTRAKEY_ENABLE 113#ifdef EXTRAKEY_ENABLE
114void send_extra(uint8_t report_id, uint16_t data) {
115 uint32_t irqflags; 115 uint32_t irqflags;
116 116
117 irqflags = __get_PRIMASK(); 117 irqflags = __get_PRIMASK();
118 __disable_irq(); 118 __disable_irq();
119 __DMB(); 119 __DMB();
120 120
121 udi_hid_exk_report.desc.report_id = REPORT_ID_SYSTEM; 121 udi_hid_exk_report.desc.report_id = report_id;
122 if (data != 0) data = data - SYSTEM_POWER_DOWN + 1;
123 udi_hid_exk_report.desc.report_data = data; 122 udi_hid_exk_report.desc.report_data = data;
124 udi_hid_exk_b_report_valid = 1; 123 udi_hid_exk_b_report_valid = 1;
125 udi_hid_exk_send_report(); 124 udi_hid_exk_send_report();
126 125
127 __DMB(); 126 __DMB();
128 __set_PRIMASK(irqflags); 127 __set_PRIMASK(irqflags);
128}
129#endif // EXTRAKEY_ENABLE
130
131void send_system(uint16_t data) {
132#ifdef EXTRAKEY_ENABLE
133 if (data != 0) data = data - SYSTEM_POWER_DOWN + 1;
134 send_extra(REPORT_ID_SYSTEM, data);
129#endif // EXTRAKEY_ENABLE 135#endif // EXTRAKEY_ENABLE
130} 136}
131 137
132void send_consumer(uint16_t data) { 138void send_consumer(uint16_t data) {
133#ifdef EXTRAKEY_ENABLE 139#ifdef EXTRAKEY_ENABLE
134 uint32_t irqflags; 140 send_extra(REPORT_ID_CONSUMER, data);
135
136 irqflags = __get_PRIMASK();
137 __disable_irq();
138 __DMB();
139
140 udi_hid_exk_report.desc.report_id = REPORT_ID_CONSUMER;
141 udi_hid_exk_report.desc.report_data = data;
142 udi_hid_exk_b_report_valid = 1;
143 udi_hid_exk_send_report();
144
145 __DMB();
146 __set_PRIMASK(irqflags);
147#endif // EXTRAKEY_ENABLE 141#endif // EXTRAKEY_ENABLE
148} 142}
149 143
diff --git a/tmk_core/protocol/chibios/usb_main.h b/tmk_core/protocol/chibios/usb_main.h
index cd2bb695b..17041b4f2 100644
--- a/tmk_core/protocol/chibios/usb_main.h
+++ b/tmk_core/protocol/chibios/usb_main.h
@@ -72,20 +72,6 @@ void mouse_in_cb(USBDriver *usbp, usbep_t ep);
72/* shared IN request callback handler */ 72/* shared IN request callback handler */
73void shared_in_cb(USBDriver *usbp, usbep_t ep); 73void shared_in_cb(USBDriver *usbp, usbep_t ep);
74 74
75/* ---------------
76 * Extrakey header
77 * ---------------
78 */
79
80#ifdef EXTRAKEY_ENABLE
81
82/* extra report structure */
83typedef struct {
84 uint8_t report_id;
85 uint16_t usage;
86} __attribute__((packed)) report_extra_t;
87#endif /* EXTRAKEY_ENABLE */
88
89/* -------------- 75/* --------------
90 * Console header 76 * Console header
91 * -------------- 77 * --------------
diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c
index db66a0722..792db4340 100644
--- a/tmk_core/protocol/lufa/lufa.c
+++ b/tmk_core/protocol/lufa/lufa.c
@@ -662,17 +662,17 @@ static void send_mouse(report_mouse_t *report) {
662#endif 662#endif
663} 663}
664 664
665/** \brief Send System 665/** \brief Send Extra
666 * 666 *
667 * FIXME: Needs doc 667 * FIXME: Needs doc
668 */ 668 */
669static void send_system(uint16_t data) {
670#ifdef EXTRAKEY_ENABLE 669#ifdef EXTRAKEY_ENABLE
670static void send_extra(uint8_t report_id, uint16_t data) {
671 uint8_t timeout = 255; 671 uint8_t timeout = 255;
672 672
673 if (USB_DeviceState != DEVICE_STATE_Configured) return; 673 if (USB_DeviceState != DEVICE_STATE_Configured) return;
674 674
675 report_extra_t r = {.report_id = REPORT_ID_SYSTEM, .usage = data - SYSTEM_POWER_DOWN + 1}; 675 report_extra_t r = {.report_id = report_id, .usage = data};
676 Endpoint_SelectEndpoint(SHARED_IN_EPNUM); 676 Endpoint_SelectEndpoint(SHARED_IN_EPNUM);
677 677
678 /* Check if write ready for a polling interval around 10ms */ 678 /* Check if write ready for a polling interval around 10ms */
@@ -681,6 +681,16 @@ static void send_system(uint16_t data) {
681 681
682 Endpoint_Write_Stream_LE(&r, sizeof(report_extra_t), NULL); 682 Endpoint_Write_Stream_LE(&r, sizeof(report_extra_t), NULL);
683 Endpoint_ClearIN(); 683 Endpoint_ClearIN();
684}
685#endif
686
687/** \brief Send System
688 *
689 * FIXME: Needs doc
690 */
691static void send_system(uint16_t data) {
692#ifdef EXTRAKEY_ENABLE
693 send_extra(REPORT_ID_SYSTEM, data - SYSTEM_POWER_DOWN + 1);
684#endif 694#endif
685} 695}
686 696
@@ -690,7 +700,6 @@ static void send_system(uint16_t data) {
690 */ 700 */
691static void send_consumer(uint16_t data) { 701static void send_consumer(uint16_t data) {
692#ifdef EXTRAKEY_ENABLE 702#ifdef EXTRAKEY_ENABLE
693 uint8_t timeout = 255;
694 uint8_t where = where_to_send(); 703 uint8_t where = where_to_send();
695 704
696# ifdef BLUETOOTH_ENABLE 705# ifdef BLUETOOTH_ENABLE
@@ -729,15 +738,7 @@ static void send_consumer(uint16_t data) {
729 return; 738 return;
730 } 739 }
731 740
732 report_extra_t r = {.report_id = REPORT_ID_CONSUMER, .usage = data}; 741 send_extra(REPORT_ID_CONSUMER, data);
733 Endpoint_SelectEndpoint(SHARED_IN_EPNUM);
734
735 /* Check if write ready for a polling interval around 10ms */
736 while (timeout-- && !Endpoint_IsReadWriteAllowed()) _delay_us(40);
737 if (!Endpoint_IsReadWriteAllowed()) return;
738
739 Endpoint_Write_Stream_LE(&r, sizeof(report_extra_t), NULL);
740 Endpoint_ClearIN();
741#endif 742#endif
742} 743}
743 744
diff --git a/tmk_core/protocol/lufa/lufa.h b/tmk_core/protocol/lufa/lufa.h
index 652e4e79b..1b88060f1 100644
--- a/tmk_core/protocol/lufa/lufa.h
+++ b/tmk_core/protocol/lufa/lufa.h
@@ -58,12 +58,6 @@ extern host_driver_t lufa_driver;
58} 58}
59#endif 59#endif
60 60
61/* extra report structure */
62typedef struct {
63 uint8_t report_id;
64 uint16_t usage;
65} __attribute__((packed)) report_extra_t;
66
67#ifdef API_ENABLE 61#ifdef API_ENABLE
68# include "api.h" 62# include "api.h"
69#endif 63#endif
diff --git a/tmk_core/protocol/vusb/vusb.c b/tmk_core/protocol/vusb/vusb.c
index e66938445..71263344f 100644
--- a/tmk_core/protocol/vusb/vusb.c
+++ b/tmk_core/protocol/vusb/vusb.c
@@ -112,31 +112,25 @@ static void send_mouse(report_mouse_t *report) {
112 } 112 }
113} 113}
114 114
115typedef struct { 115static void send_extra(uint8_t report_id, uint16_t data) {
116 uint8_t report_id; 116 static uint8_t last_id = 0;
117 uint16_t usage;
118} __attribute__((packed)) report_extra_t;
119
120static void send_system(uint16_t data) {
121 static uint16_t last_data = 0; 117 static uint16_t last_data = 0;
122 if (data == last_data) return; 118 if ((report_id == last_id) && (data == last_data)) return;
119 last_id = report_id;
123 last_data = data; 120 last_data = data;
124 121
125 report_extra_t report = {.report_id = REPORT_ID_SYSTEM, .usage = data}; 122 report_extra_t report = {.report_id = report_id, .usage = data};
126 if (usbInterruptIsReady3()) { 123 if (usbInterruptIsReady3()) {
127 usbSetInterrupt3((void *)&report, sizeof(report)); 124 usbSetInterrupt3((void *)&report, sizeof(report));
128 } 125 }
129} 126}
130 127
131static void send_consumer(uint16_t data) { 128static void send_system(uint16_t data) {
132 static uint16_t last_data = 0; 129 send_extra(REPORT_ID_SYSTEM, data);
133 if (data == last_data) return; 130}
134 last_data = data;
135 131
136 report_extra_t report = {.report_id = REPORT_ID_CONSUMER, .usage = data}; 132static void send_consumer(uint16_t data) {
137 if (usbInterruptIsReady3()) { 133 send_extra(REPORT_ID_CONSUMER, data);
138 usbSetInterrupt3((void *)&report, sizeof(report));
139 }
140} 134}
141 135
142/*------------------------------------------------------------------* 136/*------------------------------------------------------------------*