aboutsummaryrefslogtreecommitdiff
path: root/keyboards/converter/usb_usb/custom_matrix.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'keyboards/converter/usb_usb/custom_matrix.cpp')
-rw-r--r--keyboards/converter/usb_usb/custom_matrix.cpp38
1 files changed, 21 insertions, 17 deletions
diff --git a/keyboards/converter/usb_usb/custom_matrix.cpp b/keyboards/converter/usb_usb/custom_matrix.cpp
index 93d13edf0..fba107c7c 100644
--- a/keyboards/converter/usb_usb/custom_matrix.cpp
+++ b/keyboards/converter/usb_usb/custom_matrix.cpp
@@ -35,6 +35,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
35#include "host.h" 35#include "host.h"
36#include "keyboard.h" 36#include "keyboard.h"
37 37
38extern "C" {
39#include "quantum.h"
40}
38 41
39/* KEY CODE to Matrix 42/* KEY CODE to Matrix
40 * 43 *
@@ -62,7 +65,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
62 65
63 66
64// Integrated key state of all keyboards 67// Integrated key state of all keyboards
65static report_keyboard_t keyboard_report; 68static report_keyboard_t local_keyboard_report;
66 69
67static bool matrix_is_mod = false; 70static bool matrix_is_mod = false;
68 71
@@ -98,13 +101,13 @@ extern "C"
98 } 101 }
99 102
100 static void or_report(report_keyboard_t report) { 103 static void or_report(report_keyboard_t report) {
101 // integrate reports into keyboard_report 104 // integrate reports into local_keyboard_report
102 keyboard_report.mods |= report.mods; 105 local_keyboard_report.mods |= report.mods;
103 for (uint8_t i = 0; i < KEYBOARD_REPORT_KEYS; i++) { 106 for (uint8_t i = 0; i < KEYBOARD_REPORT_KEYS; i++) {
104 if (IS_ANY(report.keys[i])) { 107 if (IS_ANY(report.keys[i])) {
105 for (uint8_t j = 0; j < KEYBOARD_REPORT_KEYS; j++) { 108 for (uint8_t j = 0; j < KEYBOARD_REPORT_KEYS; j++) {
106 if (! keyboard_report.keys[j]) { 109 if (! local_keyboard_report.keys[j]) {
107 keyboard_report.keys[j] = report.keys[i]; 110 local_keyboard_report.keys[j] = report.keys[i];
108 break; 111 break;
109 } 112 }
110 } 113 }
@@ -130,7 +133,7 @@ extern "C"
130 last_time_stamp4 = kbd_parser4.time_stamp; 133 last_time_stamp4 = kbd_parser4.time_stamp;
131 134
132 // clear and integrate all reports 135 // clear and integrate all reports
133 keyboard_report = {}; 136 local_keyboard_report = {};
134 or_report(kbd_parser1.report); 137 or_report(kbd_parser1.report);
135 or_report(kbd_parser2.report); 138 or_report(kbd_parser2.report);
136 or_report(kbd_parser3.report); 139 or_report(kbd_parser3.report);
@@ -138,9 +141,9 @@ extern "C"
138 141
139 matrix_is_mod = true; 142 matrix_is_mod = true;
140 143
141 dprintf("state: %02X %02X", keyboard_report.mods, keyboard_report.reserved); 144 dprintf("state: %02X %02X", local_keyboard_report.mods, local_keyboard_report.reserved);
142 for (uint8_t i = 0; i < KEYBOARD_REPORT_KEYS; i++) { 145 for (uint8_t i = 0; i < KEYBOARD_REPORT_KEYS; i++) {
143 dprintf(" %02X", keyboard_report.keys[i]); 146 dprintf(" %02X", local_keyboard_report.keys[i]);
144 } 147 }
145 dprint("\r\n"); 148 dprint("\r\n");
146 } else { 149 } else {
@@ -177,12 +180,12 @@ extern "C"
177 uint8_t code = CODE(row, col); 180 uint8_t code = CODE(row, col);
178 181
179 if (IS_MOD(code)) { 182 if (IS_MOD(code)) {
180 if (keyboard_report.mods & ROW_BITS(code)) { 183 if (local_keyboard_report.mods & ROW_BITS(code)) {
181 return true; 184 return true;
182 } 185 }
183 } 186 }
184 for (uint8_t i = 0; i < KEYBOARD_REPORT_KEYS; i++) { 187 for (uint8_t i = 0; i < KEYBOARD_REPORT_KEYS; i++) {
185 if (keyboard_report.keys[i] == code) { 188 if (local_keyboard_report.keys[i] == code) {
186 return true; 189 return true;
187 } 190 }
188 } 191 }
@@ -192,14 +195,14 @@ extern "C"
192 matrix_row_t matrix_get_row(uint8_t row) { 195 matrix_row_t matrix_get_row(uint8_t row) {
193 uint16_t row_bits = 0; 196 uint16_t row_bits = 0;
194 197
195 if (IS_MOD(CODE(row, 0)) && keyboard_report.mods) { 198 if (IS_MOD(CODE(row, 0)) && local_keyboard_report.mods) {
196 row_bits |= keyboard_report.mods; 199 row_bits |= local_keyboard_report.mods;
197 } 200 }
198 201
199 for (uint8_t i = 0; i < KEYBOARD_REPORT_KEYS; i++) { 202 for (uint8_t i = 0; i < KEYBOARD_REPORT_KEYS; i++) {
200 if (IS_ANY(keyboard_report.keys[i])) { 203 if (IS_ANY(local_keyboard_report.keys[i])) {
201 if (row == ROW(keyboard_report.keys[i])) { 204 if (row == ROW(local_keyboard_report.keys[i])) {
202 row_bits |= ROW_BITS(keyboard_report.keys[i]); 205 row_bits |= ROW_BITS(local_keyboard_report.keys[i]);
203 } 206 }
204 } 207 }
205 } 208 }
@@ -209,9 +212,9 @@ extern "C"
209 uint8_t matrix_key_count(void) { 212 uint8_t matrix_key_count(void) {
210 uint8_t count = 0; 213 uint8_t count = 0;
211 214
212 count += bitpop(keyboard_report.mods); 215 count += bitpop(local_keyboard_report.mods);
213 for (uint8_t i = 0; i < KEYBOARD_REPORT_KEYS; i++) { 216 for (uint8_t i = 0; i < KEYBOARD_REPORT_KEYS; i++) {
214 if (IS_ANY(keyboard_report.keys[i])) { 217 if (IS_ANY(local_keyboard_report.keys[i])) {
215 count++; 218 count++;
216 } 219 }
217 } 220 }
@@ -233,6 +236,7 @@ extern "C"
233 kbd2.SetReport(0, 0, 2, 0, 1, &usb_led); 236 kbd2.SetReport(0, 0, 2, 0, 1, &usb_led);
234 kbd3.SetReport(0, 0, 2, 0, 1, &usb_led); 237 kbd3.SetReport(0, 0, 2, 0, 1, &usb_led);
235 kbd4.SetReport(0, 0, 2, 0, 1, &usb_led); 238 kbd4.SetReport(0, 0, 2, 0, 1, &usb_led);
239 led_set_kb(usb_led);
236 } 240 }
237 241
238}; 242};