[Core] guard action related debug messages (#19348)
This commit is contained in:
parent
233ae20d33
commit
dedc54a328
@ -16,12 +16,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
*/
|
*/
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
||||||
#ifdef DEBUG_ACTION
|
|
||||||
# include "debug.h"
|
|
||||||
#else
|
|
||||||
# include "nodebug.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "host.h"
|
#include "host.h"
|
||||||
#include "keycode.h"
|
#include "keycode.h"
|
||||||
#include "keyboard.h"
|
#include "keyboard.h"
|
||||||
@ -77,10 +71,10 @@ __attribute__((weak)) bool pre_process_record_quantum(keyrecord_t *record) {
|
|||||||
*/
|
*/
|
||||||
void action_exec(keyevent_t event) {
|
void action_exec(keyevent_t event) {
|
||||||
if (!IS_NOEVENT(event)) {
|
if (!IS_NOEVENT(event)) {
|
||||||
dprint("\n---- action_exec: start -----\n");
|
ac_dprintf("\n---- action_exec: start -----\n");
|
||||||
dprint("EVENT: ");
|
ac_dprintf("EVENT: ");
|
||||||
debug_event(event);
|
debug_event(event);
|
||||||
dprintln();
|
ac_dprintf("\n");
|
||||||
#if defined(RETRO_TAPPING) || defined(RETRO_TAPPING_PER_KEY) || (defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT))
|
#if defined(RETRO_TAPPING) || defined(RETRO_TAPPING_PER_KEY) || (defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT))
|
||||||
retro_tapping_counter++;
|
retro_tapping_counter++;
|
||||||
#endif
|
#endif
|
||||||
@ -132,7 +126,7 @@ void action_exec(keyevent_t event) {
|
|||||||
process_record(&record);
|
process_record(&record);
|
||||||
}
|
}
|
||||||
if (!IS_NOEVENT(record.event)) {
|
if (!IS_NOEVENT(record.event)) {
|
||||||
dprint("processed: ");
|
ac_dprintf("processed: ");
|
||||||
debug_record(record);
|
debug_record(record);
|
||||||
dprintln();
|
dprintln();
|
||||||
}
|
}
|
||||||
@ -280,15 +274,15 @@ void process_record_handler(keyrecord_t *record) {
|
|||||||
#else
|
#else
|
||||||
action_t action = store_or_get_action(record->event.pressed, record->event.key);
|
action_t action = store_or_get_action(record->event.pressed, record->event.key);
|
||||||
#endif
|
#endif
|
||||||
dprint("ACTION: ");
|
ac_dprintf("ACTION: ");
|
||||||
debug_action(action);
|
debug_action(action);
|
||||||
#ifndef NO_ACTION_LAYER
|
#ifndef NO_ACTION_LAYER
|
||||||
dprint(" layer_state: ");
|
ac_dprintf(" layer_state: ");
|
||||||
layer_debug();
|
layer_debug();
|
||||||
dprint(" default_layer_state: ");
|
ac_dprintf(" default_layer_state: ");
|
||||||
default_layer_debug();
|
default_layer_debug();
|
||||||
#endif
|
#endif
|
||||||
dprintln();
|
ac_dprintf("\n");
|
||||||
|
|
||||||
process_action(record, action);
|
process_action(record, action);
|
||||||
}
|
}
|
||||||
@ -432,14 +426,14 @@ void process_action(keyrecord_t *record, action_t action) {
|
|||||||
} else {
|
} else {
|
||||||
if (event.pressed) {
|
if (event.pressed) {
|
||||||
if (tap_count == 0) {
|
if (tap_count == 0) {
|
||||||
dprint("MODS_TAP: Oneshot: 0\n");
|
ac_dprintf("MODS_TAP: Oneshot: 0\n");
|
||||||
register_mods(mods | get_oneshot_mods());
|
register_mods(mods | get_oneshot_mods());
|
||||||
} else if (tap_count == 1) {
|
} else if (tap_count == 1) {
|
||||||
dprint("MODS_TAP: Oneshot: start\n");
|
ac_dprintf("MODS_TAP: Oneshot: start\n");
|
||||||
set_oneshot_mods(mods | get_oneshot_mods());
|
set_oneshot_mods(mods | get_oneshot_mods());
|
||||||
# if defined(ONESHOT_TAP_TOGGLE) && ONESHOT_TAP_TOGGLE > 1
|
# if defined(ONESHOT_TAP_TOGGLE) && ONESHOT_TAP_TOGGLE > 1
|
||||||
} else if (tap_count == ONESHOT_TAP_TOGGLE) {
|
} else if (tap_count == ONESHOT_TAP_TOGGLE) {
|
||||||
dprint("MODS_TAP: Toggling oneshot");
|
ac_dprintf("MODS_TAP: Toggling oneshot");
|
||||||
register_mods(mods);
|
register_mods(mods);
|
||||||
clear_oneshot_mods();
|
clear_oneshot_mods();
|
||||||
set_oneshot_locked_mods(mods | get_oneshot_locked_mods());
|
set_oneshot_locked_mods(mods | get_oneshot_locked_mods());
|
||||||
@ -490,23 +484,23 @@ void process_action(keyrecord_t *record, action_t action) {
|
|||||||
get_hold_on_other_key_press(get_event_keycode(record->event, false), record) &&
|
get_hold_on_other_key_press(get_event_keycode(record->event, false), record) &&
|
||||||
# endif
|
# endif
|
||||||
record->tap.interrupted) {
|
record->tap.interrupted) {
|
||||||
dprint("mods_tap: tap: cancel: add_mods\n");
|
ac_dprintf("mods_tap: tap: cancel: add_mods\n");
|
||||||
// ad hoc: set 0 to cancel tap
|
// ad hoc: set 0 to cancel tap
|
||||||
record->tap.count = 0;
|
record->tap.count = 0;
|
||||||
register_mods(mods);
|
register_mods(mods);
|
||||||
} else
|
} else
|
||||||
# endif
|
# endif
|
||||||
{
|
{
|
||||||
dprint("MODS_TAP: Tap: register_code\n");
|
ac_dprintf("MODS_TAP: Tap: register_code\n");
|
||||||
register_code(action.key.code);
|
register_code(action.key.code);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
dprint("MODS_TAP: No tap: add_mods\n");
|
ac_dprintf("MODS_TAP: No tap: add_mods\n");
|
||||||
register_mods(mods);
|
register_mods(mods);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (tap_count > 0) {
|
if (tap_count > 0) {
|
||||||
dprint("MODS_TAP: Tap: unregister_code\n");
|
ac_dprintf("MODS_TAP: Tap: unregister_code\n");
|
||||||
if (action.layer_tap.code == KC_CAPS_LOCK) {
|
if (action.layer_tap.code == KC_CAPS_LOCK) {
|
||||||
wait_ms(TAP_HOLD_CAPS_DELAY);
|
wait_ms(TAP_HOLD_CAPS_DELAY);
|
||||||
} else {
|
} else {
|
||||||
@ -514,7 +508,7 @@ void process_action(keyrecord_t *record, action_t action) {
|
|||||||
}
|
}
|
||||||
unregister_code(action.key.code);
|
unregister_code(action.key.code);
|
||||||
} else {
|
} else {
|
||||||
dprint("MODS_TAP: No tap: add_mods\n");
|
ac_dprintf("MODS_TAP: No tap: add_mods\n");
|
||||||
unregister_mods(mods);
|
unregister_mods(mods);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -666,15 +660,15 @@ void process_action(keyrecord_t *record, action_t action) {
|
|||||||
/* tap key */
|
/* tap key */
|
||||||
if (event.pressed) {
|
if (event.pressed) {
|
||||||
if (tap_count > 0) {
|
if (tap_count > 0) {
|
||||||
dprint("KEYMAP_TAP_KEY: Tap: register_code\n");
|
ac_dprintf("KEYMAP_TAP_KEY: Tap: register_code\n");
|
||||||
register_code(action.layer_tap.code);
|
register_code(action.layer_tap.code);
|
||||||
} else {
|
} else {
|
||||||
dprint("KEYMAP_TAP_KEY: No tap: On on press\n");
|
ac_dprintf("KEYMAP_TAP_KEY: No tap: On on press\n");
|
||||||
layer_on(action.layer_tap.val);
|
layer_on(action.layer_tap.val);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (tap_count > 0) {
|
if (tap_count > 0) {
|
||||||
dprint("KEYMAP_TAP_KEY: Tap: unregister_code\n");
|
ac_dprintf("KEYMAP_TAP_KEY: Tap: unregister_code\n");
|
||||||
if (action.layer_tap.code == KC_CAPS_LOCK) {
|
if (action.layer_tap.code == KC_CAPS_LOCK) {
|
||||||
wait_ms(TAP_HOLD_CAPS_DELAY);
|
wait_ms(TAP_HOLD_CAPS_DELAY);
|
||||||
} else {
|
} else {
|
||||||
@ -682,7 +676,7 @@ void process_action(keyrecord_t *record, action_t action) {
|
|||||||
}
|
}
|
||||||
unregister_code(action.layer_tap.code);
|
unregister_code(action.layer_tap.code);
|
||||||
} else {
|
} else {
|
||||||
dprint("KEYMAP_TAP_KEY: No tap: Off on release\n");
|
ac_dprintf("KEYMAP_TAP_KEY: No tap: Off on release\n");
|
||||||
layer_off(action.layer_tap.val);
|
layer_off(action.layer_tap.val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -882,22 +876,6 @@ __attribute__((weak)) void register_code(uint8_t code) {
|
|||||||
// TODO: should push command_proc out of this block?
|
// TODO: should push command_proc out of this block?
|
||||||
if (command_proc(code)) return;
|
if (command_proc(code)) return;
|
||||||
|
|
||||||
#ifndef NO_ACTION_ONESHOT
|
|
||||||
/* TODO: remove
|
|
||||||
if (oneshot_state.mods && !oneshot_state.disabled) {
|
|
||||||
uint8_t tmp_mods = get_mods();
|
|
||||||
add_mods(oneshot_state.mods);
|
|
||||||
|
|
||||||
add_key(code);
|
|
||||||
send_keyboard_report();
|
|
||||||
|
|
||||||
set_mods(tmp_mods);
|
|
||||||
send_keyboard_report();
|
|
||||||
oneshot_cancel();
|
|
||||||
} else
|
|
||||||
*/
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
// Force a new key press if the key is already pressed
|
// Force a new key press if the key is already pressed
|
||||||
// without this, keys with the same keycode, but different
|
// without this, keys with the same keycode, but different
|
||||||
// modifiers will be reported incorrectly, see issue #1708
|
// modifiers will be reported incorrectly, see issue #1708
|
||||||
@ -907,7 +885,6 @@ __attribute__((weak)) void register_code(uint8_t code) {
|
|||||||
}
|
}
|
||||||
add_key(code);
|
add_key(code);
|
||||||
send_keyboard_report();
|
send_keyboard_report();
|
||||||
}
|
|
||||||
} else if IS_MOD (code) {
|
} else if IS_MOD (code) {
|
||||||
add_mods(MOD_BIT(code));
|
add_mods(MOD_BIT(code));
|
||||||
send_keyboard_report();
|
send_keyboard_report();
|
||||||
@ -1139,7 +1116,7 @@ bool is_tap_action(action_t action) {
|
|||||||
* FIXME: Needs documentation.
|
* FIXME: Needs documentation.
|
||||||
*/
|
*/
|
||||||
void debug_event(keyevent_t event) {
|
void debug_event(keyevent_t event) {
|
||||||
dprintf("%04X%c(%u)", (event.key.row << 8 | event.key.col), (event.pressed ? 'd' : 'u'), event.time);
|
ac_dprintf("%04X%c(%u)", (event.key.row << 8 | event.key.col), (event.pressed ? 'd' : 'u'), event.time);
|
||||||
}
|
}
|
||||||
/** \brief Debug print (FIXME: Needs better description)
|
/** \brief Debug print (FIXME: Needs better description)
|
||||||
*
|
*
|
||||||
@ -1148,7 +1125,7 @@ void debug_event(keyevent_t event) {
|
|||||||
void debug_record(keyrecord_t record) {
|
void debug_record(keyrecord_t record) {
|
||||||
debug_event(record.event);
|
debug_event(record.event);
|
||||||
#ifndef NO_ACTION_TAPPING
|
#ifndef NO_ACTION_TAPPING
|
||||||
dprintf(":%u%c", record.tap.count, (record.tap.interrupted ? '-' : ' '));
|
ac_dprintf(":%u%c", record.tap.count, (record.tap.interrupted ? '-' : ' '));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1159,41 +1136,41 @@ void debug_record(keyrecord_t record) {
|
|||||||
void debug_action(action_t action) {
|
void debug_action(action_t action) {
|
||||||
switch (action.kind.id) {
|
switch (action.kind.id) {
|
||||||
case ACT_LMODS:
|
case ACT_LMODS:
|
||||||
dprint("ACT_LMODS");
|
ac_dprintf("ACT_LMODS");
|
||||||
break;
|
break;
|
||||||
case ACT_RMODS:
|
case ACT_RMODS:
|
||||||
dprint("ACT_RMODS");
|
ac_dprintf("ACT_RMODS");
|
||||||
break;
|
break;
|
||||||
case ACT_LMODS_TAP:
|
case ACT_LMODS_TAP:
|
||||||
dprint("ACT_LMODS_TAP");
|
ac_dprintf("ACT_LMODS_TAP");
|
||||||
break;
|
break;
|
||||||
case ACT_RMODS_TAP:
|
case ACT_RMODS_TAP:
|
||||||
dprint("ACT_RMODS_TAP");
|
ac_dprintf("ACT_RMODS_TAP");
|
||||||
break;
|
break;
|
||||||
case ACT_USAGE:
|
case ACT_USAGE:
|
||||||
dprint("ACT_USAGE");
|
ac_dprintf("ACT_USAGE");
|
||||||
break;
|
break;
|
||||||
case ACT_MOUSEKEY:
|
case ACT_MOUSEKEY:
|
||||||
dprint("ACT_MOUSEKEY");
|
ac_dprintf("ACT_MOUSEKEY");
|
||||||
break;
|
break;
|
||||||
case ACT_LAYER:
|
case ACT_LAYER:
|
||||||
dprint("ACT_LAYER");
|
ac_dprintf("ACT_LAYER");
|
||||||
break;
|
break;
|
||||||
case ACT_LAYER_MODS:
|
case ACT_LAYER_MODS:
|
||||||
dprint("ACT_LAYER_MODS");
|
ac_dprintf("ACT_LAYER_MODS");
|
||||||
break;
|
break;
|
||||||
case ACT_LAYER_TAP:
|
case ACT_LAYER_TAP:
|
||||||
dprint("ACT_LAYER_TAP");
|
ac_dprintf("ACT_LAYER_TAP");
|
||||||
break;
|
break;
|
||||||
case ACT_LAYER_TAP_EXT:
|
case ACT_LAYER_TAP_EXT:
|
||||||
dprint("ACT_LAYER_TAP_EXT");
|
ac_dprintf("ACT_LAYER_TAP_EXT");
|
||||||
break;
|
break;
|
||||||
case ACT_SWAP_HANDS:
|
case ACT_SWAP_HANDS:
|
||||||
dprint("ACT_SWAP_HANDS");
|
ac_dprintf("ACT_SWAP_HANDS");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
dprint("UNKNOWN");
|
ac_dprintf("UNKNOWN");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
dprintf("[%X:%02X]", action.kind.param >> 8, action.kind.param & 0xff);
|
ac_dprintf("[%X:%02X]", action.kind.param >> 8, action.kind.param & 0xff);
|
||||||
}
|
}
|
||||||
|
@ -112,7 +112,19 @@ bool is_tap_action(action_t action);
|
|||||||
void process_record_tap_hint(keyrecord_t *record);
|
void process_record_tap_hint(keyrecord_t *record);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* debug */
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Helpers
|
||||||
|
|
||||||
|
#ifdef ACTION_DEBUG
|
||||||
|
# include "debug.h"
|
||||||
|
# include "print.h"
|
||||||
|
# define ac_dprintf(...) dprintf(__VA_ARGS__)
|
||||||
|
#else
|
||||||
|
# define ac_dprintf(...) \
|
||||||
|
do { \
|
||||||
|
} while (0)
|
||||||
|
#endif
|
||||||
|
|
||||||
void debug_event(keyevent_t event);
|
void debug_event(keyevent_t event);
|
||||||
void debug_record(keyrecord_t record);
|
void debug_record(keyrecord_t record);
|
||||||
void debug_action(action_t action);
|
void debug_action(action_t action);
|
||||||
|
@ -1,12 +1,6 @@
|
|||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#ifdef DEBUG_ACTION
|
|
||||||
# include "debug.h"
|
|
||||||
#else
|
|
||||||
# include "nodebug.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "keyboard.h"
|
#include "keyboard.h"
|
||||||
#include "keymap.h"
|
#include "keymap.h"
|
||||||
#include "action.h"
|
#include "action.h"
|
||||||
@ -39,12 +33,12 @@ __attribute__((weak)) layer_state_t default_layer_state_set_kb(layer_state_t sta
|
|||||||
*/
|
*/
|
||||||
static void default_layer_state_set(layer_state_t state) {
|
static void default_layer_state_set(layer_state_t state) {
|
||||||
state = default_layer_state_set_kb(state);
|
state = default_layer_state_set_kb(state);
|
||||||
debug("default_layer_state: ");
|
ac_dprintf("default_layer_state: ");
|
||||||
default_layer_debug();
|
default_layer_debug();
|
||||||
debug(" to ");
|
ac_dprintf(" to ");
|
||||||
default_layer_state = state;
|
default_layer_state = state;
|
||||||
default_layer_debug();
|
default_layer_debug();
|
||||||
debug("\n");
|
ac_dprintf("\n");
|
||||||
#if defined(STRICT_LAYER_RELEASE)
|
#if defined(STRICT_LAYER_RELEASE)
|
||||||
clear_keyboard_but_mods(); // To avoid stuck keys
|
clear_keyboard_but_mods(); // To avoid stuck keys
|
||||||
#elif defined(SEMI_STRICT_LAYER_RELEASE)
|
#elif defined(SEMI_STRICT_LAYER_RELEASE)
|
||||||
@ -57,7 +51,7 @@ static void default_layer_state_set(layer_state_t state) {
|
|||||||
* Print out the hex value of the 32-bit default layer state, as well as the value of the highest bit.
|
* Print out the hex value of the 32-bit default layer state, as well as the value of the highest bit.
|
||||||
*/
|
*/
|
||||||
void default_layer_debug(void) {
|
void default_layer_debug(void) {
|
||||||
dprintf("%08lX(%u)", default_layer_state, get_highest_layer(default_layer_state));
|
ac_dprintf("%08hX(%u)", default_layer_state, get_highest_layer(default_layer_state));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \brief Default Layer Set
|
/** \brief Default Layer Set
|
||||||
@ -119,12 +113,12 @@ __attribute__((weak)) layer_state_t layer_state_set_kb(layer_state_t state) {
|
|||||||
*/
|
*/
|
||||||
void layer_state_set(layer_state_t state) {
|
void layer_state_set(layer_state_t state) {
|
||||||
state = layer_state_set_kb(state);
|
state = layer_state_set_kb(state);
|
||||||
dprint("layer_state: ");
|
ac_dprintf("layer_state: ");
|
||||||
layer_debug();
|
layer_debug();
|
||||||
dprint(" to ");
|
ac_dprintf(" to ");
|
||||||
layer_state = state;
|
layer_state = state;
|
||||||
layer_debug();
|
layer_debug();
|
||||||
dprintln();
|
ac_dprintf("\n");
|
||||||
# if defined(STRICT_LAYER_RELEASE)
|
# if defined(STRICT_LAYER_RELEASE)
|
||||||
clear_keyboard_but_mods(); // To avoid stuck keys
|
clear_keyboard_but_mods(); // To avoid stuck keys
|
||||||
# elif defined(SEMI_STRICT_LAYER_RELEASE)
|
# elif defined(SEMI_STRICT_LAYER_RELEASE)
|
||||||
@ -218,7 +212,7 @@ void layer_xor(layer_state_t state) {
|
|||||||
* Print out the hex value of the 32-bit layer state, as well as the value of the highest bit.
|
* Print out the hex value of the 32-bit layer state, as well as the value of the highest bit.
|
||||||
*/
|
*/
|
||||||
void layer_debug(void) {
|
void layer_debug(void) {
|
||||||
dprintf("%08lX(%u)", layer_state, get_highest_layer(layer_state));
|
ac_dprintf("%08hX(%u)", layer_state, get_highest_layer(layer_state));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1,12 +1,6 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
#ifdef DEBUG_ACTION
|
|
||||||
# include "debug.h"
|
|
||||||
#else
|
|
||||||
# include "nodebug.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "action.h"
|
#include "action.h"
|
||||||
#include "action_layer.h"
|
#include "action_layer.h"
|
||||||
#include "action_tapping.h"
|
#include "action_tapping.h"
|
||||||
@ -92,14 +86,14 @@ static void debug_waiting_buffer(void);
|
|||||||
void action_tapping_process(keyrecord_t record) {
|
void action_tapping_process(keyrecord_t record) {
|
||||||
if (process_tapping(&record)) {
|
if (process_tapping(&record)) {
|
||||||
if (!IS_NOEVENT(record.event)) {
|
if (!IS_NOEVENT(record.event)) {
|
||||||
debug("processed: ");
|
ac_dprintf("processed: ");
|
||||||
debug_record(record);
|
debug_record(record);
|
||||||
debug("\n");
|
ac_dprintf("\n");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!waiting_buffer_enq(record)) {
|
if (!waiting_buffer_enq(record)) {
|
||||||
// clear all in case of overflow.
|
// clear all in case of overflow.
|
||||||
debug("OVERFLOW: CLEAR ALL STATES\n");
|
ac_dprintf("OVERFLOW: CLEAR ALL STATES\n");
|
||||||
clear_keyboard();
|
clear_keyboard();
|
||||||
waiting_buffer_clear();
|
waiting_buffer_clear();
|
||||||
tapping_key = (keyrecord_t){};
|
tapping_key = (keyrecord_t){};
|
||||||
@ -108,21 +102,19 @@ void action_tapping_process(keyrecord_t record) {
|
|||||||
|
|
||||||
// process waiting_buffer
|
// process waiting_buffer
|
||||||
if (!IS_NOEVENT(record.event) && waiting_buffer_head != waiting_buffer_tail) {
|
if (!IS_NOEVENT(record.event) && waiting_buffer_head != waiting_buffer_tail) {
|
||||||
debug("---- action_exec: process waiting_buffer -----\n");
|
ac_dprintf("---- action_exec: process waiting_buffer -----\n");
|
||||||
}
|
}
|
||||||
for (; waiting_buffer_tail != waiting_buffer_head; waiting_buffer_tail = (waiting_buffer_tail + 1) % WAITING_BUFFER_SIZE) {
|
for (; waiting_buffer_tail != waiting_buffer_head; waiting_buffer_tail = (waiting_buffer_tail + 1) % WAITING_BUFFER_SIZE) {
|
||||||
if (process_tapping(&waiting_buffer[waiting_buffer_tail])) {
|
if (process_tapping(&waiting_buffer[waiting_buffer_tail])) {
|
||||||
debug("processed: waiting_buffer[");
|
ac_dprintf("processed: waiting_buffer[%u] =", waiting_buffer_tail);
|
||||||
debug_dec(waiting_buffer_tail);
|
|
||||||
debug("] = ");
|
|
||||||
debug_record(waiting_buffer[waiting_buffer_tail]);
|
debug_record(waiting_buffer[waiting_buffer_tail]);
|
||||||
debug("\n\n");
|
ac_dprintf("\n\n");
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!IS_NOEVENT(record.event)) {
|
if (!IS_NOEVENT(record.event)) {
|
||||||
debug("\n");
|
ac_dprintf("\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -195,7 +187,7 @@ bool process_tapping(keyrecord_t *keyp) {
|
|||||||
retroshift_swap_times();
|
retroshift_swap_times();
|
||||||
# endif
|
# endif
|
||||||
// first tap!
|
// first tap!
|
||||||
debug("Tapping: First tap(0->1).\n");
|
ac_dprintf("Tapping: First tap(0->1).\n");
|
||||||
tapping_key.tap.count = 1;
|
tapping_key.tap.count = 1;
|
||||||
debug_tapping_key();
|
debug_tapping_key();
|
||||||
process_record(&tapping_key);
|
process_record(&tapping_key);
|
||||||
@ -237,7 +229,7 @@ bool process_tapping(keyrecord_t *keyp) {
|
|||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
// clang-format on
|
// clang-format on
|
||||||
debug("Tapping: End. No tap. Interfered by typing key\n");
|
ac_dprintf("Tapping: End. No tap. Interfered by typing key\n");
|
||||||
process_record(&tapping_key);
|
process_record(&tapping_key);
|
||||||
tapping_key = (keyrecord_t){};
|
tapping_key = (keyrecord_t){};
|
||||||
debug_tapping_key();
|
debug_tapping_key();
|
||||||
@ -274,7 +266,7 @@ bool process_tapping(keyrecord_t *keyp) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// Release of key should be process immediately.
|
// Release of key should be process immediately.
|
||||||
debug("Tapping: release event of a key pressed before tapping\n");
|
ac_dprintf("Tapping: release event of a key pressed before tapping\n");
|
||||||
process_record(keyp);
|
process_record(keyp);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
@ -282,7 +274,7 @@ bool process_tapping(keyrecord_t *keyp) {
|
|||||||
if (event.pressed) {
|
if (event.pressed) {
|
||||||
tapping_key.tap.interrupted = true;
|
tapping_key.tap.interrupted = true;
|
||||||
if (TAP_GET_HOLD_ON_OTHER_KEY_PRESS) {
|
if (TAP_GET_HOLD_ON_OTHER_KEY_PRESS) {
|
||||||
debug("Tapping: End. No tap. Interfered by pressed key\n");
|
ac_dprintf("Tapping: End. No tap. Interfered by pressed key\n");
|
||||||
process_record(&tapping_key);
|
process_record(&tapping_key);
|
||||||
tapping_key = (keyrecord_t){};
|
tapping_key = (keyrecord_t){};
|
||||||
debug_tapping_key();
|
debug_tapping_key();
|
||||||
@ -297,9 +289,7 @@ bool process_tapping(keyrecord_t *keyp) {
|
|||||||
// tap_count > 0
|
// tap_count > 0
|
||||||
else {
|
else {
|
||||||
if (IS_TAPPING_RECORD(keyp) && !event.pressed) {
|
if (IS_TAPPING_RECORD(keyp) && !event.pressed) {
|
||||||
debug("Tapping: Tap release(");
|
ac_dprintf("Tapping: Tap release(%u)\n", tapping_key.tap.count);
|
||||||
debug_dec(tapping_key.tap.count);
|
|
||||||
debug(")\n");
|
|
||||||
keyp->tap = tapping_key.tap;
|
keyp->tap = tapping_key.tap;
|
||||||
process_record(keyp);
|
process_record(keyp);
|
||||||
tapping_key = *keyp;
|
tapping_key = *keyp;
|
||||||
@ -307,7 +297,7 @@ bool process_tapping(keyrecord_t *keyp) {
|
|||||||
return true;
|
return true;
|
||||||
} else if (is_tap_record(keyp) && event.pressed) {
|
} else if (is_tap_record(keyp) && event.pressed) {
|
||||||
if (tapping_key.tap.count > 1) {
|
if (tapping_key.tap.count > 1) {
|
||||||
debug("Tapping: Start new tap with releasing last tap(>1).\n");
|
ac_dprintf("Tapping: Start new tap with releasing last tap(>1).\n");
|
||||||
// unregister key
|
// unregister key
|
||||||
process_record(&(keyrecord_t){
|
process_record(&(keyrecord_t){
|
||||||
.tap = tapping_key.tap,
|
.tap = tapping_key.tap,
|
||||||
@ -319,7 +309,7 @@ bool process_tapping(keyrecord_t *keyp) {
|
|||||||
# endif
|
# endif
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
debug("Tapping: Start while last tap(1).\n");
|
ac_dprintf("Tapping: Start while last tap(1).\n");
|
||||||
}
|
}
|
||||||
tapping_key = *keyp;
|
tapping_key = *keyp;
|
||||||
waiting_buffer_scan_tap();
|
waiting_buffer_scan_tap();
|
||||||
@ -327,7 +317,7 @@ bool process_tapping(keyrecord_t *keyp) {
|
|||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
if (!IS_NOEVENT(event)) {
|
if (!IS_NOEVENT(event)) {
|
||||||
debug("Tapping: key event while last tap(>0).\n");
|
ac_dprintf("Tapping: key event while last tap(>0).\n");
|
||||||
}
|
}
|
||||||
process_record(keyp);
|
process_record(keyp);
|
||||||
return true;
|
return true;
|
||||||
@ -337,23 +327,23 @@ bool process_tapping(keyrecord_t *keyp) {
|
|||||||
// after TAPPING_TERM
|
// after TAPPING_TERM
|
||||||
else {
|
else {
|
||||||
if (tapping_key.tap.count == 0) {
|
if (tapping_key.tap.count == 0) {
|
||||||
debug("Tapping: End. Timeout. Not tap(0): ");
|
ac_dprintf("Tapping: End. Timeout. Not tap(0): ");
|
||||||
debug_event(event);
|
debug_event(event);
|
||||||
debug("\n");
|
ac_dprintf("\n");
|
||||||
process_record(&tapping_key);
|
process_record(&tapping_key);
|
||||||
tapping_key = (keyrecord_t){};
|
tapping_key = (keyrecord_t){};
|
||||||
debug_tapping_key();
|
debug_tapping_key();
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
if (IS_TAPPING_RECORD(keyp) && !event.pressed) {
|
if (IS_TAPPING_RECORD(keyp) && !event.pressed) {
|
||||||
debug("Tapping: End. last timeout tap release(>0).");
|
ac_dprintf("Tapping: End. last timeout tap release(>0).");
|
||||||
keyp->tap = tapping_key.tap;
|
keyp->tap = tapping_key.tap;
|
||||||
process_record(keyp);
|
process_record(keyp);
|
||||||
tapping_key = (keyrecord_t){};
|
tapping_key = (keyrecord_t){};
|
||||||
return true;
|
return true;
|
||||||
} else if (is_tap_record(keyp) && event.pressed) {
|
} else if (is_tap_record(keyp) && event.pressed) {
|
||||||
if (tapping_key.tap.count > 1) {
|
if (tapping_key.tap.count > 1) {
|
||||||
debug("Tapping: Start new tap with releasing last timeout tap(>1).\n");
|
ac_dprintf("Tapping: Start new tap with releasing last timeout tap(>1).\n");
|
||||||
// unregister key
|
// unregister key
|
||||||
process_record(&(keyrecord_t){
|
process_record(&(keyrecord_t){
|
||||||
.tap = tapping_key.tap,
|
.tap = tapping_key.tap,
|
||||||
@ -365,7 +355,7 @@ bool process_tapping(keyrecord_t *keyp) {
|
|||||||
# endif
|
# endif
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
debug("Tapping: Start while last timeout tap(1).\n");
|
ac_dprintf("Tapping: Start while last timeout tap(1).\n");
|
||||||
}
|
}
|
||||||
tapping_key = *keyp;
|
tapping_key = *keyp;
|
||||||
waiting_buffer_scan_tap();
|
waiting_buffer_scan_tap();
|
||||||
@ -373,7 +363,7 @@ bool process_tapping(keyrecord_t *keyp) {
|
|||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
if (!IS_NOEVENT(event)) {
|
if (!IS_NOEVENT(event)) {
|
||||||
debug("Tapping: key event while last timeout tap(>0).\n");
|
ac_dprintf("Tapping: key event while last timeout tap(>0).\n");
|
||||||
}
|
}
|
||||||
process_record(keyp);
|
process_record(keyp);
|
||||||
return true;
|
return true;
|
||||||
@ -388,9 +378,7 @@ bool process_tapping(keyrecord_t *keyp) {
|
|||||||
// sequential tap.
|
// sequential tap.
|
||||||
keyp->tap = tapping_key.tap;
|
keyp->tap = tapping_key.tap;
|
||||||
if (keyp->tap.count < 15) keyp->tap.count += 1;
|
if (keyp->tap.count < 15) keyp->tap.count += 1;
|
||||||
debug("Tapping: Tap press(");
|
ac_dprintf("Tapping: Tap press(%u)\n", keyp->tap.count);
|
||||||
debug_dec(keyp->tap.count);
|
|
||||||
debug(")\n");
|
|
||||||
process_record(keyp);
|
process_record(keyp);
|
||||||
tapping_key = *keyp;
|
tapping_key = *keyp;
|
||||||
debug_tapping_key();
|
debug_tapping_key();
|
||||||
@ -401,7 +389,7 @@ bool process_tapping(keyrecord_t *keyp) {
|
|||||||
return true;
|
return true;
|
||||||
} else if (is_tap_record(keyp)) {
|
} else if (is_tap_record(keyp)) {
|
||||||
// Sequential tap can be interfered with other tap key.
|
// Sequential tap can be interfered with other tap key.
|
||||||
debug("Tapping: Start with interfering other tap.\n");
|
ac_dprintf("Tapping: Start with interfering other tap.\n");
|
||||||
tapping_key = *keyp;
|
tapping_key = *keyp;
|
||||||
waiting_buffer_scan_tap();
|
waiting_buffer_scan_tap();
|
||||||
debug_tapping_key();
|
debug_tapping_key();
|
||||||
@ -414,16 +402,16 @@ bool process_tapping(keyrecord_t *keyp) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!IS_NOEVENT(event)) debug("Tapping: other key just after tap.\n");
|
if (!IS_NOEVENT(event)) ac_dprintf("Tapping: other key just after tap.\n");
|
||||||
process_record(keyp);
|
process_record(keyp);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// FIX: process_action here?
|
// FIX: process_action here?
|
||||||
// timeout. no sequential tap.
|
// timeout. no sequential tap.
|
||||||
debug("Tapping: End(Timeout after releasing last tap): ");
|
ac_dprintf("Tapping: End(Timeout after releasing last tap): ");
|
||||||
debug_event(event);
|
debug_event(event);
|
||||||
debug("\n");
|
ac_dprintf("\n");
|
||||||
tapping_key = (keyrecord_t){};
|
tapping_key = (keyrecord_t){};
|
||||||
debug_tapping_key();
|
debug_tapping_key();
|
||||||
return false;
|
return false;
|
||||||
@ -432,7 +420,7 @@ bool process_tapping(keyrecord_t *keyp) {
|
|||||||
// not tapping state
|
// not tapping state
|
||||||
else {
|
else {
|
||||||
if (event.pressed && is_tap_record(keyp)) {
|
if (event.pressed && is_tap_record(keyp)) {
|
||||||
debug("Tapping: Start(Press tap key).\n");
|
ac_dprintf("Tapping: Start(Press tap key).\n");
|
||||||
tapping_key = *keyp;
|
tapping_key = *keyp;
|
||||||
process_record_tap_hint(&tapping_key);
|
process_record_tap_hint(&tapping_key);
|
||||||
waiting_buffer_scan_tap();
|
waiting_buffer_scan_tap();
|
||||||
@ -455,14 +443,14 @@ bool waiting_buffer_enq(keyrecord_t record) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((waiting_buffer_head + 1) % WAITING_BUFFER_SIZE == waiting_buffer_tail) {
|
if ((waiting_buffer_head + 1) % WAITING_BUFFER_SIZE == waiting_buffer_tail) {
|
||||||
debug("waiting_buffer_enq: Over flow.\n");
|
ac_dprintf("waiting_buffer_enq: Over flow.\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
waiting_buffer[waiting_buffer_head] = record;
|
waiting_buffer[waiting_buffer_head] = record;
|
||||||
waiting_buffer_head = (waiting_buffer_head + 1) % WAITING_BUFFER_SIZE;
|
waiting_buffer_head = (waiting_buffer_head + 1) % WAITING_BUFFER_SIZE;
|
||||||
|
|
||||||
debug("waiting_buffer_enq: ");
|
ac_dprintf("waiting_buffer_enq: ");
|
||||||
debug_waiting_buffer();
|
debug_waiting_buffer();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -516,9 +504,7 @@ void waiting_buffer_scan_tap(void) {
|
|||||||
waiting_buffer[i].tap.count = 1;
|
waiting_buffer[i].tap.count = 1;
|
||||||
process_record(&tapping_key);
|
process_record(&tapping_key);
|
||||||
|
|
||||||
debug("waiting_buffer_scan_tap: found at [");
|
ac_dprintf("waiting_buffer_scan_tap: found at [%u]\n", i);
|
||||||
debug_dec(i);
|
|
||||||
debug("]\n");
|
|
||||||
debug_waiting_buffer();
|
debug_waiting_buffer();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -530,9 +516,9 @@ void waiting_buffer_scan_tap(void) {
|
|||||||
* FIXME: Needs docs
|
* FIXME: Needs docs
|
||||||
*/
|
*/
|
||||||
static void debug_tapping_key(void) {
|
static void debug_tapping_key(void) {
|
||||||
debug("TAPPING_KEY=");
|
ac_dprintf("TAPPING_KEY=");
|
||||||
debug_record(tapping_key);
|
debug_record(tapping_key);
|
||||||
debug("\n");
|
ac_dprintf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \brief Waiting buffer debug print
|
/** \brief Waiting buffer debug print
|
||||||
@ -540,15 +526,13 @@ static void debug_tapping_key(void) {
|
|||||||
* FIXME: Needs docs
|
* FIXME: Needs docs
|
||||||
*/
|
*/
|
||||||
static void debug_waiting_buffer(void) {
|
static void debug_waiting_buffer(void) {
|
||||||
debug("{ ");
|
ac_dprintf("{ ");
|
||||||
for (uint8_t i = waiting_buffer_tail; i != waiting_buffer_head; i = (i + 1) % WAITING_BUFFER_SIZE) {
|
for (uint8_t i = waiting_buffer_tail; i != waiting_buffer_head; i = (i + 1) % WAITING_BUFFER_SIZE) {
|
||||||
debug("[");
|
ac_dprintf("[%u]=", i);
|
||||||
debug_dec(i);
|
|
||||||
debug("]=");
|
|
||||||
debug_record(waiting_buffer[i]);
|
debug_record(waiting_buffer[i]);
|
||||||
debug(" ");
|
ac_dprintf(" ");
|
||||||
}
|
}
|
||||||
debug("}\n");
|
ac_dprintf("}\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,26 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 2013 Jun Wako <wakojun@gmail.com>
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 2 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#ifndef NO_DEBUG
|
|
||||||
# define NO_DEBUG
|
|
||||||
# include "debug.h"
|
|
||||||
# undef NO_DEBUG
|
|
||||||
#else
|
|
||||||
# include "debug.h"
|
|
||||||
#endif
|
|
Loading…
Reference in New Issue
Block a user