aboutsummaryrefslogtreecommitdiff
path: root/common/keyboard.c
diff options
context:
space:
mode:
Diffstat (limited to 'common/keyboard.c')
-rw-r--r--common/keyboard.c28
1 files changed, 11 insertions, 17 deletions
diff --git a/common/keyboard.c b/common/keyboard.c
index be01e5540..c7ea2b840 100644
--- a/common/keyboard.c
+++ b/common/keyboard.c
@@ -28,9 +28,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
28#ifdef MOUSEKEY_ENABLE 28#ifdef MOUSEKEY_ENABLE
29#include "mousekey.h" 29#include "mousekey.h"
30#endif 30#endif
31#ifdef EXTRAKEY_ENABLE
32#include <util/delay.h>
33#endif
34 31
35 32
36#define LAYER_DELAY 250 33#define LAYER_DELAY 250
@@ -154,8 +151,12 @@ static bool layer_switch_off(uint8_t code)
154static void register_code(uint8_t code) 151static void register_code(uint8_t code)
155{ 152{
156 if IS_KEY(code) { 153 if IS_KEY(code) {
157 host_add_key(code); 154 if (command_proc(code)) {
158 host_send_keyboard_report(); 155 //clear_keyboard();
156 } else {
157 host_add_key(code);
158 host_send_keyboard_report();
159 }
159 } 160 }
160 else if IS_MOD(code) { 161 else if IS_MOD(code) {
161 host_add_mod_bit(MOD_BIT(code)); 162 host_add_mod_bit(MOD_BIT(code));
@@ -330,9 +331,9 @@ static void unregister_code(uint8_t code)
330 * Ld: Switch back to default layer(*unregister* all keys but modifiers) 331 * Ld: Switch back to default layer(*unregister* all keys but modifiers)
331 */ 332 */
332#define NEXT(state) do { \ 333#define NEXT(state) do { \
333 debug("NEXT: "); print_P(state_str(kbdstate)); \ 334 debug("NEXT: "); debug_P(state_str(kbdstate)); \
334 kbdstate = state; \ 335 kbdstate = state; \
335 debug(" -> "); print_P(state_str(kbdstate)); debug("\n"); \ 336 debug(" -> "); debug_P(state_str(kbdstate)); debug("\n"); \
336} while (0) 337} while (0)
337 338
338static inline void process_key(keyevent_t event) 339static inline void process_key(keyevent_t event)
@@ -342,7 +343,7 @@ static inline void process_key(keyevent_t event)
342 343
343 uint8_t tmp_mods; 344 uint8_t tmp_mods;
344 345
345 debug("state: "); print_P(state_str(kbdstate)); 346 debug("state: "); debug_P(state_str(kbdstate));
346 debug(" kind: "); debug_hex(kind); 347 debug(" kind: "); debug_hex(kind);
347 debug(" code: "); debug_hex(code); 348 debug(" code: "); debug_hex(code);
348 if (event.pressed) { debug("d"); } else { debug("u"); } 349 if (event.pressed) { debug("d"); } else { debug("u"); }
@@ -554,18 +555,11 @@ void keyboard_task(void)
554 matrix_row_t matrix_change = 0; 555 matrix_row_t matrix_change = 0;
555 556
556 matrix_scan(); 557 matrix_scan();
557 if (command_proc()) {
558 debug("COMMAND\n");
559 // TODO: COMMAND state?
560 clear_keyboard();
561 return;
562 }
563
564 for (int r = 0; r < MATRIX_ROWS; r++) { 558 for (int r = 0; r < MATRIX_ROWS; r++) {
565 matrix_row = matrix_get_row(r); 559 matrix_row = matrix_get_row(r);
566 matrix_change = matrix_row ^ matrix_prev[r]; 560 matrix_change = matrix_row ^ matrix_prev[r];
567 if (matrix_change) { 561 if (matrix_change) {
568 if (debug_matrix) matrix_print(); 562 matrix_debug();
569 563
570 for (int c = 0; c < MATRIX_COLS; c++) { 564 for (int c = 0; c < MATRIX_COLS; c++) {
571 if (matrix_change & (1<<c)) { 565 if (matrix_change & (1<<c)) {
@@ -618,7 +612,7 @@ void keyboard_task(void)
618 current_layer = default_layer; 612 current_layer = default_layer;
619 } 613 }
620 } 614 }
621 615
622 return; 616 return;
623} 617}
624 618