diff options
| -rw-r--r-- | common/action.c | 92 | ||||
| -rw-r--r-- | common/action_layer.c | 19 | ||||
| -rw-r--r-- | common/action_macro.c | 7 | ||||
| -rw-r--r-- | common/action_tapping.c | 6 | ||||
| -rw-r--r-- | common/host.c | 10 |
5 files changed, 72 insertions, 62 deletions
diff --git a/common/action.c b/common/action.c index 065188744..c7c8f71f2 100644 --- a/common/action.c +++ b/common/action.c | |||
| @@ -19,7 +19,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 19 | #include "keyboard.h" | 19 | #include "keyboard.h" |
| 20 | #include "mousekey.h" | 20 | #include "mousekey.h" |
| 21 | #include "command.h" | 21 | #include "command.h" |
| 22 | #include "debug.h" | ||
| 23 | #include "led.h" | 22 | #include "led.h" |
| 24 | #include "action_layer.h" | 23 | #include "action_layer.h" |
| 25 | #include "action_tapping.h" | 24 | #include "action_tapping.h" |
| @@ -27,12 +26,18 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 27 | #include "action_macro.h" | 26 | #include "action_macro.h" |
| 28 | #include "action.h" | 27 | #include "action.h" |
| 29 | 28 | ||
| 29 | #ifdef DEBUG_ACTION | ||
| 30 | #include "debug.h" | ||
| 31 | #else | ||
| 32 | #include "nodebug.h" | ||
| 33 | #endif | ||
| 34 | |||
| 30 | 35 | ||
| 31 | void action_exec(keyevent_t event) | 36 | void action_exec(keyevent_t event) |
| 32 | { | 37 | { |
| 33 | if (!IS_NOEVENT(event)) { | 38 | if (!IS_NOEVENT(event)) { |
| 34 | debug("\n---- action_exec: start -----\n"); | 39 | dprint("\n---- action_exec: start -----\n"); |
| 35 | debug("EVENT: "); debug_event(event); debug("\n"); | 40 | dprint("EVENT: "); debug_event(event); dprintln(); |
| 36 | } | 41 | } |
| 37 | 42 | ||
| 38 | keyrecord_t record = { .event = event }; | 43 | keyrecord_t record = { .event = event }; |
| @@ -42,7 +47,7 @@ void action_exec(keyevent_t event) | |||
| 42 | #else | 47 | #else |
| 43 | process_action(&record); | 48 | process_action(&record); |
| 44 | if (!IS_NOEVENT(record.event)) { | 49 | if (!IS_NOEVENT(record.event)) { |
| 45 | debug("processed: "); debug_record(record); debug("\n"); | 50 | dprint("processed: "); debug_record(record); dprintln(); |
| 46 | } | 51 | } |
| 47 | #endif | 52 | #endif |
| 48 | } | 53 | } |
| @@ -57,12 +62,12 @@ void process_action(keyrecord_t *record) | |||
| 57 | if (IS_NOEVENT(event)) { return; } | 62 | if (IS_NOEVENT(event)) { return; } |
| 58 | 63 | ||
| 59 | action_t action = layer_switch_get_action(event.key); | 64 | action_t action = layer_switch_get_action(event.key); |
| 60 | debug("ACTION: "); debug_action(action); | 65 | dprint("ACTION: "); debug_action(action); |
| 61 | #ifndef NO_ACTION_LAYER | 66 | #ifndef NO_ACTION_LAYER |
| 62 | debug(" layer_state: "); layer_debug(); | 67 | dprint(" layer_state: "); layer_debug(); |
| 63 | debug(" default_layer_state: "); default_layer_debug(); | 68 | dprint(" default_layer_state: "); default_layer_debug(); |
| 64 | #endif | 69 | #endif |
| 65 | debug("\n"); | 70 | dprintln(); |
| 66 | 71 | ||
| 67 | switch (action.kind.id) { | 72 | switch (action.kind.id) { |
| 68 | /* Key and Mods */ | 73 | /* Key and Mods */ |
| @@ -98,37 +103,37 @@ void process_action(keyrecord_t *record) | |||
| 98 | // Oneshot modifier | 103 | // Oneshot modifier |
| 99 | if (event.pressed) { | 104 | if (event.pressed) { |
| 100 | if (tap_count == 0) { | 105 | if (tap_count == 0) { |
| 101 | debug("MODS_TAP: Oneshot: add_mods\n"); | 106 | dprint("MODS_TAP: Oneshot: add_mods\n"); |
| 102 | add_mods(mods); | 107 | add_mods(mods); |
| 103 | } | 108 | } |
| 104 | else if (tap_count == 1) { | 109 | else if (tap_count == 1) { |
| 105 | debug("MODS_TAP: Oneshot: start\n"); | 110 | dprint("MODS_TAP: Oneshot: start\n"); |
| 106 | oneshot_start(mods); | 111 | oneshot_start(mods); |
| 107 | } | 112 | } |
| 108 | else if (tap_count == TAPPING_TOGGLE) { | 113 | else if (tap_count == TAPPING_TOGGLE) { |
| 109 | debug("MODS_TAP: Oneshot: toggle\n"); | 114 | dprint("MODS_TAP: Oneshot: toggle\n"); |
| 110 | oneshot_toggle(); | 115 | oneshot_toggle(); |
| 111 | } | 116 | } |
| 112 | else { | 117 | else { |
| 113 | debug("MODS_TAP: Oneshot: cancel&add_mods\n"); | 118 | dprint("MODS_TAP: Oneshot: cancel&add_mods\n"); |
| 114 | // double tap cancels oneshot and works as normal modifier. | 119 | // double tap cancels oneshot and works as normal modifier. |
| 115 | oneshot_cancel(); | 120 | oneshot_cancel(); |
| 116 | add_mods(mods); | 121 | add_mods(mods); |
| 117 | } | 122 | } |
| 118 | } else { | 123 | } else { |
| 119 | if (tap_count == 0) { | 124 | if (tap_count == 0) { |
| 120 | debug("MODS_TAP: Oneshot: cancel/del_mods\n"); | 125 | dprint("MODS_TAP: Oneshot: cancel/del_mods\n"); |
| 121 | // cancel oneshot on hold | 126 | // cancel oneshot on hold |
| 122 | oneshot_cancel(); | 127 | oneshot_cancel(); |
| 123 | del_mods(mods); | 128 | del_mods(mods); |
| 124 | } | 129 | } |
| 125 | else if (tap_count == 1) { | 130 | else if (tap_count == 1) { |
| 126 | debug("MODS_TAP: Oneshot: del_mods\n"); | 131 | dprint("MODS_TAP: Oneshot: del_mods\n"); |
| 127 | // retain Oneshot | 132 | // retain Oneshot |
| 128 | del_mods(mods); | 133 | del_mods(mods); |
| 129 | } | 134 | } |
| 130 | else { | 135 | else { |
| 131 | debug("MODS_TAP: Oneshot: del_mods\n"); | 136 | dprint("MODS_TAP: Oneshot: del_mods\n"); |
| 132 | // cancel Mods | 137 | // cancel Mods |
| 133 | del_mods(mods); | 138 | del_mods(mods); |
| 134 | } | 139 | } |
| @@ -139,24 +144,24 @@ void process_action(keyrecord_t *record) | |||
| 139 | if (event.pressed) { | 144 | if (event.pressed) { |
| 140 | if (tap_count > 0) { | 145 | if (tap_count > 0) { |
| 141 | if (record->tap.interrupted) { | 146 | if (record->tap.interrupted) { |
| 142 | debug("MODS_TAP: Tap: Cancel: add_mods\n"); | 147 | dprint("MODS_TAP: Tap: Cancel: add_mods\n"); |
| 143 | // ad hoc: set 0 to cancel tap | 148 | // ad hoc: set 0 to cancel tap |
| 144 | record->tap.count = 0; | 149 | record->tap.count = 0; |
| 145 | add_mods(mods); | 150 | add_mods(mods); |
| 146 | } else { | 151 | } else { |
| 147 | debug("MODS_TAP: Tap: register_code\n"); | 152 | dprint("MODS_TAP: Tap: register_code\n"); |
| 148 | register_code(action.key.code); | 153 | register_code(action.key.code); |
| 149 | } | 154 | } |
| 150 | } else { | 155 | } else { |
| 151 | debug("MODS_TAP: No tap: add_mods\n"); | 156 | dprint("MODS_TAP: No tap: add_mods\n"); |
| 152 | add_mods(mods); | 157 | add_mods(mods); |
| 153 | } | 158 | } |
| 154 | } else { | 159 | } else { |
| 155 | if (tap_count > 0) { | 160 | if (tap_count > 0) { |
| 156 | debug("MODS_TAP: Tap: unregister_code\n"); | 161 | dprint("MODS_TAP: Tap: unregister_code\n"); |
| 157 | unregister_code(action.key.code); | 162 | unregister_code(action.key.code); |
| 158 | } else { | 163 | } else { |
| 159 | debug("MODS_TAP: No tap: add_mods\n"); | 164 | dprint("MODS_TAP: No tap: add_mods\n"); |
| 160 | del_mods(mods); | 165 | del_mods(mods); |
| 161 | } | 166 | } |
| 162 | } | 167 | } |
| @@ -261,18 +266,18 @@ void process_action(keyrecord_t *record) | |||
| 261 | /* tap key */ | 266 | /* tap key */ |
| 262 | if (event.pressed) { | 267 | if (event.pressed) { |
| 263 | if (tap_count > 0) { | 268 | if (tap_count > 0) { |
| 264 | debug("KEYMAP_TAP_KEY: Tap: register_code\n"); | 269 | dprint("KEYMAP_TAP_KEY: Tap: register_code\n"); |
| 265 | register_code(action.layer_tap.code); | 270 | register_code(action.layer_tap.code); |
| 266 | } else { | 271 | } else { |
| 267 | debug("KEYMAP_TAP_KEY: No tap: On on press\n"); | 272 | dprint("KEYMAP_TAP_KEY: No tap: On on press\n"); |
| 268 | layer_on(action.layer_tap.val); | 273 | layer_on(action.layer_tap.val); |
| 269 | } | 274 | } |
| 270 | } else { | 275 | } else { |
| 271 | if (tap_count > 0) { | 276 | if (tap_count > 0) { |
| 272 | debug("KEYMAP_TAP_KEY: Tap: unregister_code\n"); | 277 | dprint("KEYMAP_TAP_KEY: Tap: unregister_code\n"); |
| 273 | unregister_code(action.layer_tap.code); | 278 | unregister_code(action.layer_tap.code); |
| 274 | } else { | 279 | } else { |
| 275 | debug("KEYMAP_TAP_KEY: No tap: Off on release\n"); | 280 | dprint("KEYMAP_TAP_KEY: No tap: Off on release\n"); |
| 276 | layer_off(action.layer_tap.val); | 281 | layer_off(action.layer_tap.val); |
| 277 | } | 282 | } |
| 278 | } | 283 | } |
| @@ -448,40 +453,33 @@ bool is_tap_key(key_t key) | |||
| 448 | */ | 453 | */ |
| 449 | void debug_event(keyevent_t event) | 454 | void debug_event(keyevent_t event) |
| 450 | { | 455 | { |
| 451 | debug_hex16((event.key.row<<8) | event.key.col); | 456 | dprintf("%04X%c(%u)", (event.key.row<<8 | event.key.col), (event.pressed ? 'd' : 'u'), event.time); |
| 452 | if (event.pressed) debug("d("); else debug("u("); | ||
| 453 | debug_dec(event.time); debug(")"); | ||
| 454 | } | 457 | } |
| 455 | 458 | ||
| 456 | void debug_record(keyrecord_t record) | 459 | void debug_record(keyrecord_t record) |
| 457 | { | 460 | { |
| 458 | debug_event(record.event); | 461 | debug_event(record.event); |
| 459 | #ifndef NO_ACTION_TAPPING | 462 | #ifndef NO_ACTION_TAPPING |
| 460 | debug(":"); debug_dec(record.tap.count); | 463 | dprintf(":%u%c", record.tap.count, (record.tap.interrupted ? '-' : ' ')); |
| 461 | if (record.tap.interrupted) debug("-"); | ||
| 462 | #endif | 464 | #endif |
| 463 | } | 465 | } |
| 464 | 466 | ||
| 465 | void debug_action(action_t action) | 467 | void debug_action(action_t action) |
| 466 | { | 468 | { |
| 467 | switch (action.kind.id) { | 469 | switch (action.kind.id) { |
| 468 | case ACT_LMODS: debug("ACT_LMODS"); break; | 470 | case ACT_LMODS: dprint("ACT_LMODS"); break; |
| 469 | case ACT_RMODS: debug("ACT_RMODS"); break; | 471 | case ACT_RMODS: dprint("ACT_RMODS"); break; |
| 470 | case ACT_LMODS_TAP: debug("ACT_LMODS_TAP"); break; | 472 | case ACT_LMODS_TAP: dprint("ACT_LMODS_TAP"); break; |
| 471 | case ACT_RMODS_TAP: debug("ACT_RMODS_TAP"); break; | 473 | case ACT_RMODS_TAP: dprint("ACT_RMODS_TAP"); break; |
| 472 | case ACT_USAGE: debug("ACT_USAGE"); break; | 474 | case ACT_USAGE: dprint("ACT_USAGE"); break; |
| 473 | case ACT_MOUSEKEY: debug("ACT_MOUSEKEY"); break; | 475 | case ACT_MOUSEKEY: dprint("ACT_MOUSEKEY"); break; |
| 474 | case ACT_LAYER: debug("ACT_LAYER"); break; | 476 | case ACT_LAYER: dprint("ACT_LAYER"); break; |
| 475 | case ACT_LAYER_TAP: debug("ACT_LAYER_TAP"); break; | 477 | case ACT_LAYER_TAP: dprint("ACT_LAYER_TAP"); break; |
| 476 | case ACT_LAYER_TAP1: debug("ACT_LAYER_TAP1"); break; | 478 | case ACT_LAYER_TAP1: dprint("ACT_LAYER_TAP1"); break; |
| 477 | case ACT_MACRO: debug("ACT_MACRO"); break; | 479 | case ACT_MACRO: dprint("ACT_MACRO"); break; |
| 478 | case ACT_COMMAND: debug("ACT_COMMAND"); break; | 480 | case ACT_COMMAND: dprint("ACT_COMMAND"); break; |
| 479 | case ACT_FUNCTION: debug("ACT_FUNCTION"); break; | 481 | case ACT_FUNCTION: dprint("ACT_FUNCTION"); break; |
| 480 | default: debug("UNKNOWN"); break; | 482 | default: dprint("UNKNOWN"); break; |
| 481 | } | 483 | } |
| 482 | debug("["); | 484 | dprintf("[%X:%02X]", action.kind.param>>8, action.kind.param&0xff); |
| 483 | debug_hex4(action.kind.param>>8); | ||
| 484 | debug(":"); | ||
| 485 | debug_hex8(action.kind.param & 0xff); | ||
| 486 | debug("]"); | ||
| 487 | } | 485 | } |
diff --git a/common/action_layer.c b/common/action_layer.c index 3413c53e6..d24aa2e19 100644 --- a/common/action_layer.c +++ b/common/action_layer.c | |||
| @@ -1,10 +1,15 @@ | |||
| 1 | #include <stdint.h> | 1 | #include <stdint.h> |
| 2 | #include "keyboard.h" | 2 | #include "keyboard.h" |
| 3 | #include "action.h" | 3 | #include "action.h" |
| 4 | #include "debug.h" | ||
| 5 | #include "util.h" | 4 | #include "util.h" |
| 6 | #include "action_layer.h" | 5 | #include "action_layer.h" |
| 7 | 6 | ||
| 7 | #ifdef DEBUG_ACTION | ||
| 8 | #include "debug.h" | ||
| 9 | #else | ||
| 10 | #include "nodebug.h" | ||
| 11 | #endif | ||
| 12 | |||
| 8 | 13 | ||
| 9 | /* | 14 | /* |
| 10 | * Default Layer State | 15 | * Default Layer State |
| @@ -22,8 +27,7 @@ static void default_layer_state_set(uint32_t state) | |||
| 22 | 27 | ||
| 23 | void default_layer_debug(void) | 28 | void default_layer_debug(void) |
| 24 | { | 29 | { |
| 25 | debug_hex32(default_layer_state); | 30 | dprintf("%08lX(%u)", default_layer_state, biton32(default_layer_state)); |
| 26 | debug("("); debug_dec(biton32(default_layer_state)); debug(")"); | ||
| 27 | } | 31 | } |
| 28 | 32 | ||
| 29 | void default_layer_set(uint8_t layer) | 33 | void default_layer_set(uint8_t layer) |
| @@ -55,10 +59,10 @@ uint32_t layer_state = 0; | |||
| 55 | 59 | ||
| 56 | static void layer_state_set(uint32_t state) | 60 | static void layer_state_set(uint32_t state) |
| 57 | { | 61 | { |
| 58 | debug("layer_state: "); | 62 | dprint("layer_state: "); |
| 59 | layer_debug(); debug(" to "); | 63 | layer_debug(); dprint(" to "); |
| 60 | layer_state = state; | 64 | layer_state = state; |
| 61 | layer_debug(); debug("\n"); | 65 | layer_debug(); dprintln(); |
| 62 | clear_keyboard_but_mods(); // To avoid stuck keys | 66 | clear_keyboard_but_mods(); // To avoid stuck keys |
| 63 | } | 67 | } |
| 64 | 68 | ||
| @@ -102,8 +106,7 @@ void layer_xor(uint32_t state) | |||
| 102 | 106 | ||
| 103 | void layer_debug(void) | 107 | void layer_debug(void) |
| 104 | { | 108 | { |
| 105 | debug_hex32(layer_state); | 109 | dprintf("%08lX(%u)", layer_state, biton32(layer_state)); |
| 106 | debug("("); debug_dec(biton32(layer_state)); debug(")"); | ||
| 107 | } | 110 | } |
| 108 | #endif | 111 | #endif |
| 109 | 112 | ||
diff --git a/common/action_macro.c b/common/action_macro.c index 6d81a1efb..71d1506f5 100644 --- a/common/action_macro.c +++ b/common/action_macro.c | |||
| @@ -15,10 +15,15 @@ You should have received a copy of the GNU General Public License | |||
| 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 16 | */ | 16 | */ |
| 17 | #include <util/delay.h> | 17 | #include <util/delay.h> |
| 18 | #include "debug.h" | ||
| 19 | #include "action.h" | 18 | #include "action.h" |
| 20 | #include "action_macro.h" | 19 | #include "action_macro.h" |
| 21 | 20 | ||
| 21 | #ifdef DEBUG_ACTION | ||
| 22 | #include "debug.h" | ||
| 23 | #else | ||
| 24 | #include "nodebug.h" | ||
| 25 | #endif | ||
| 26 | |||
| 22 | 27 | ||
| 23 | #ifndef NO_ACTION_MACRO | 28 | #ifndef NO_ACTION_MACRO |
| 24 | 29 | ||
diff --git a/common/action_tapping.c b/common/action_tapping.c index abb0bf518..8b466079d 100644 --- a/common/action_tapping.c +++ b/common/action_tapping.c | |||
| @@ -3,8 +3,12 @@ | |||
| 3 | #include "action.h" | 3 | #include "action.h" |
| 4 | #include "action_tapping.h" | 4 | #include "action_tapping.h" |
| 5 | #include "timer.h" | 5 | #include "timer.h" |
| 6 | #include "debug.h" | ||
| 7 | 6 | ||
| 7 | #ifdef DEBUG_ACTION | ||
| 8 | #include "debug.h" | ||
| 9 | #else | ||
| 10 | #include "nodebug.h" | ||
| 11 | #endif | ||
| 8 | 12 | ||
| 9 | #ifndef NO_ACTION_TAPPING | 13 | #ifndef NO_ACTION_TAPPING |
| 10 | 14 | ||
diff --git a/common/host.c b/common/host.c index 6ed3d780f..2c2279aa4 100644 --- a/common/host.c +++ b/common/host.c | |||
| @@ -63,11 +63,11 @@ void host_keyboard_send(report_keyboard_t *report) | |||
| 63 | (*driver->send_keyboard)(report); | 63 | (*driver->send_keyboard)(report); |
| 64 | 64 | ||
| 65 | if (debug_keyboard) { | 65 | if (debug_keyboard) { |
| 66 | print("keys: "); | 66 | dprint("keys: "); |
| 67 | for (int i = 0; i < REPORT_KEYS; i++) { | 67 | for (int i = 0; i < REPORT_KEYS; i++) { |
| 68 | phex(keyboard_report->keys[i]); print(" "); | 68 | dprintf("%02X ", keyboard_report->keys[i]); |
| 69 | } | 69 | } |
| 70 | print(" mods: "); phex(keyboard_report->mods); print("\n"); | 70 | dprintf(" mods: %02X\n", keyboard_report->mods); |
| 71 | } | 71 | } |
| 72 | } | 72 | } |
| 73 | 73 | ||
| @@ -235,7 +235,7 @@ static inline void add_key_bit(uint8_t code) | |||
| 235 | if ((code>>3) < REPORT_KEYS) { | 235 | if ((code>>3) < REPORT_KEYS) { |
| 236 | keyboard_report->keys[code>>3] |= 1<<(code&7); | 236 | keyboard_report->keys[code>>3] |= 1<<(code&7); |
| 237 | } else { | 237 | } else { |
| 238 | debug("add_key_bit: can't add: "); phex(code); debug("\n"); | 238 | dprintf("add_key_bit: can't add: %02X\n", code); |
| 239 | } | 239 | } |
| 240 | } | 240 | } |
| 241 | 241 | ||
| @@ -244,6 +244,6 @@ static inline void del_key_bit(uint8_t code) | |||
| 244 | if ((code>>3) < REPORT_KEYS) { | 244 | if ((code>>3) < REPORT_KEYS) { |
| 245 | keyboard_report->keys[code>>3] &= ~(1<<(code&7)); | 245 | keyboard_report->keys[code>>3] &= ~(1<<(code&7)); |
| 246 | } else { | 246 | } else { |
| 247 | debug("del_key_bit: can't del: "); phex(code); debug("\n"); | 247 | dprintf("del_key_bit: can't del: %02X\n", code); |
| 248 | } | 248 | } |
| 249 | } | 249 | } |
