From c35eca7a93a094415c3b6b500b2fc8e8e6c2face Mon Sep 17 00:00:00 2001 From: Drashna Jael're Date: Sat, 13 Aug 2022 10:15:09 -0700 Subject: [PATCH 01/10] Fix functions when NO_ACTION_TAPPING is defined --- quantum/action.c | 44 +++++++++++++++++++++++++++++----------- quantum/action_tapping.h | 4 ++-- 2 files changed, 34 insertions(+), 14 deletions(-) diff --git a/quantum/action.c b/quantum/action.c index 79ea2b763598..c9970a5dd27f 100644 --- a/quantum/action.c +++ b/quantum/action.c @@ -395,9 +395,9 @@ void process_action(keyrecord_t *record, action_t action) { } } } break; -#ifndef NO_ACTION_TAPPING case ACT_LMODS_TAP: case ACT_RMODS_TAP: { +#ifndef NO_ACTION_TAPPING uint8_t mods = (action.kind.id == ACT_LMODS_TAP) ? action.key.mods : action.key.mods << 4; switch (action.layer_tap.code) { # ifndef NO_ACTION_ONESHOT @@ -519,8 +519,8 @@ void process_action(keyrecord_t *record, action_t action) { } break; } - } break; #endif + } break; #ifdef EXTRAKEY_ENABLE /* other HID usage */ case ACT_USAGE: @@ -533,7 +533,7 @@ void process_action(keyrecord_t *record, action_t action) { break; } break; -#endif +#endif // EXTRAKEY_ENABLE /* Mouse key */ case ACT_MOUSEKEY: register_mouse(action.key.code, event.pressed); @@ -593,10 +593,10 @@ void process_action(keyrecord_t *record, action_t action) { layer_off(action.layer_mods.layer); } break; -# ifndef NO_ACTION_TAPPING case ACT_LAYER_TAP: case ACT_LAYER_TAP_EXT: switch (action.layer_tap.code) { +# ifndef NO_ACTION_TAPPING case OP_TAP_TOGGLE: /* tap toggle */ if (event.pressed) { @@ -609,6 +609,7 @@ void process_action(keyrecord_t *record, action_t action) { } } break; +# endif case OP_ON_OFF: event.pressed ? layer_on(action.layer_tap.val) : layer_off(action.layer_tap.val); break; @@ -618,7 +619,7 @@ void process_action(keyrecord_t *record, action_t action) { case OP_SET_CLEAR: event.pressed ? layer_move(action.layer_tap.val) : layer_clear(); break; -# ifndef NO_ACTION_ONESHOT +# if !defined(NO_ACTION_ONESHOT) && !defined(NO_ACTION_TAPPING) case OP_ONESHOT: // Oneshot modifier if (!keymap_config.oneshot_enable) { @@ -628,7 +629,7 @@ void process_action(keyrecord_t *record, action_t action) { layer_off(action.layer_tap.val); } } else { -# if defined(ONESHOT_TAP_TOGGLE) && ONESHOT_TAP_TOGGLE > 1 +# if defined(ONESHOT_TAP_TOGGLE) && ONESHOT_TAP_TOGGLE > 1 do_release_oneshot = false; if (event.pressed) { if (get_oneshot_layer_state() == ONESHOT_TOGGLED) { @@ -647,7 +648,7 @@ void process_action(keyrecord_t *record, action_t action) { clear_oneshot_layer_state(ONESHOT_PRESSED); } } -# else +# else if (event.pressed) { layer_on(action.layer_tap.val); set_oneshot_layer(action.layer_tap.val, ONESHOT_START); @@ -657,12 +658,18 @@ void process_action(keyrecord_t *record, action_t action) { clear_oneshot_layer_state(ONESHOT_OTHER_KEY_PRESSED); } } -# endif +# endif } +# else // NO_ACTION_ONESHOT && NO_ACTION_TAPPING + if (event.pressed) { + layer_on(action.layer_tap.val); + } else { + layer_off(action.layer_tap.val); + } +# endif // !defined(NO_ACTION_ONESHOT) && !defined(NO_ACTION_TAPPING) break; -# endif default: - /* tap key */ +# ifndef NO_ACTION_TAPPING /* tap key */ if (event.pressed) { if (tap_count > 0) { ac_dprintf("KEYMAP_TAP_KEY: Tap: register_code\n"); @@ -685,11 +692,24 @@ void process_action(keyrecord_t *record, action_t action) { layer_off(action.layer_tap.val); } } +# else + if (event.pressed) { + dprint("KEYMAP_TAP_KEY: Tap: register_code\n"); + register_code(action.layer_tap.code); + } else { + dprint("KEYMAP_TAP_KEY: Tap: unregister_code\n"); + if (action.layer_tap.code == KC_CAPS) { + wait_ms(TAP_HOLD_CAPS_DELAY); + } else { + wait_ms(TAP_CODE_DELAY); + } + unregister_code(action.layer_tap.code); + } +# endif break; } break; -# endif -#endif +#endif // NO_ACTION_LAYER #ifdef SWAP_HANDS_ENABLE case ACT_SWAP_HANDS: diff --git a/quantum/action_tapping.h b/quantum/action_tapping.h index c078488c0437..6099d80d6d05 100644 --- a/quantum/action_tapping.h +++ b/quantum/action_tapping.h @@ -51,9 +51,9 @@ bool get_hold_on_other_key_press(uint16_t keycode, keyrecord_t *record); extern uint16_t g_tapping_term; #endif -#ifdef TAPPING_TERM_PER_KEY +#if defined(TAPPING_TERM_PER_KEY) && !defined(NO_ACTION_TAPPING) # define GET_TAPPING_TERM(keycode, record) get_tapping_term(keycode, record) -#elif defined(DYNAMIC_TAPPING_TERM_ENABLE) +#elif defined(DYNAMIC_TAPPING_TERM_ENABLE) && !defined(NO_ACTION_TAPPING) # define GET_TAPPING_TERM(keycode, record) g_tapping_term #else # define GET_TAPPING_TERM(keycode, record) (TAPPING_TERM) From 498fe4e71de8594751069247d8d0f6e2d3d2f93d Mon Sep 17 00:00:00 2001 From: Drashna Jael're Date: Tue, 10 Jan 2023 02:57:53 -0800 Subject: [PATCH 02/10] Fix MT/TT/OSM and more But make the action stack just that much more swiss cheese --- quantum/action.c | 6 +-- quantum/keymap_common.c | 40 ++++++++++++++++--- quantum/process_keycode/process_autocorrect.c | 6 ++- quantum/process_keycode/process_caps_word.c | 6 ++- 4 files changed, 47 insertions(+), 11 deletions(-) diff --git a/quantum/action.c b/quantum/action.c index c9970a5dd27f..cd820f1c2c42 100644 --- a/quantum/action.c +++ b/quantum/action.c @@ -519,7 +519,7 @@ void process_action(keyrecord_t *record, action_t action) { } break; } -#endif +#endif // NO_ACTION_TAPPING } break; #ifdef EXTRAKEY_ENABLE /* other HID usage */ @@ -694,10 +694,10 @@ void process_action(keyrecord_t *record, action_t action) { } # else if (event.pressed) { - dprint("KEYMAP_TAP_KEY: Tap: register_code\n"); + ac_dprintf("KEYMAP_TAP_KEY: Tap: register_code\n"); register_code(action.layer_tap.code); } else { - dprint("KEYMAP_TAP_KEY: Tap: unregister_code\n"); + ac_dprintf("KEYMAP_TAP_KEY: Tap: unregister_code\n"); if (action.layer_tap.code == KC_CAPS) { wait_ms(TAP_HOLD_CAPS_DELAY); } else { diff --git a/quantum/keymap_common.c b/quantum/keymap_common.c index c4336440f9c2..2a2e17b0c1f7 100644 --- a/quantum/keymap_common.c +++ b/quantum/keymap_common.c @@ -76,10 +76,16 @@ action_t action_for_keycode(uint16_t keycode) { // Split it up action.code = ACTION_MODS_KEY(QK_MODS_GET_MODS(keycode), QK_MODS_GET_BASIC_KEYCODE(keycode)); // adds modifier to key break; -#ifndef NO_ACTION_LAYER case QK_LAYER_TAP ... QK_LAYER_TAP_MAX: +#if !defined(NO_ACTION_LAYER) && !defined(NO_ACTION_TAPPING) action.code = ACTION_LAYER_TAP_KEY(QK_LAYER_TAP_GET_LAYER(keycode), QK_LAYER_TAP_GET_TAP_KEYCODE(keycode)); +#else + // pass through keycode_config again, since it previously missed it + // and then only send as ACTION_KEY to bypass most of action.c handling + action.code = ACTION_KEY(keycode_config(QK_LAYER_TAP_GET_TAP_KEYCODE(keycode))); +#endif break; +#ifndef NO_ACTION_LAYER case QK_TO ... QK_TO_MAX:; // Layer set "GOTO" action_layer = QK_TO_GET_LAYER(keycode); @@ -107,28 +113,50 @@ action_t action_for_keycode(uint16_t keycode) { action_layer = QK_ONE_SHOT_LAYER_GET_LAYER(keycode); action.code = ACTION_LAYER_ONESHOT(action_layer); break; +#endif // NO_ACTION_ONESHOT case QK_ONE_SHOT_MOD ... QK_ONE_SHOT_MOD_MAX:; // OSM(mod) - One-shot mod - mod = mod_config(QK_ONE_SHOT_MOD_GET_MODS(keycode)); + mod = mod_config(QK_ONE_SHOT_MOD_GET_MODS(keycode)); +#if defined(NO_ACTION_TAPPING) || defined(NO_ACTION_ONESHOT) + action.code = ACTION_MODS(mod); +#else // defined(NO_ACTION_TAPPING) || defined(NO_ACTION_ONESHOT) action.code = ACTION_MODS_ONESHOT(mod); +#endif // defined(NO_ACTION_TAPPING) || defined(NO_ACTION_ONESHOT) break; -#endif #ifndef NO_ACTION_LAYER case QK_LAYER_TAP_TOGGLE ... QK_LAYER_TAP_TOGGLE_MAX: +# ifndef NO_ACTION_TAPPING action.code = ACTION_LAYER_TAP_TOGGLE(QK_LAYER_TAP_TOGGLE_GET_LAYER(keycode)); +# else // NO_ACTION_TAPPING +# ifdef NO_ACTION_TAPPING_TAP_TOGGLE_MO + action.code = ACTION_LAYER_MOMENTARY(QK_LAYER_TAP_TOGGLE_GET_LAYER(keycode)); +# else // NO_ACTION_TAPPING_TAP_TOGGLE_MO + action.code = ACTION_LAYER_TOGGLE(QK_LAYER_TAP_TOGGLE_GET_LAYER(keycode)); +# endif // NO_ACTION_TAPPING_TAP_TOGGLE_MO +# endif // NO_ACTION_TAPPING break; case QK_LAYER_MOD ... QK_LAYER_MOD_MAX: mod = mod_config(QK_LAYER_MOD_GET_MODS(keycode)); action_layer = QK_LAYER_MOD_GET_LAYER(keycode); action.code = ACTION_LAYER_MODS(action_layer, mod); break; -#endif -#ifndef NO_ACTION_TAPPING +#endif // NO_ACTION_LAYER case QK_MOD_TAP ... QK_MOD_TAP_MAX: +#ifndef NO_ACTION_TAPPING mod = mod_config(QK_MOD_TAP_GET_MODS(keycode)); action.code = ACTION_MODS_TAP_KEY(mod, QK_MOD_TAP_GET_TAP_KEYCODE(keycode)); +#else // NO_ACTION_TAPPING +# ifdef NO_ACTION_TAPPING_MODTAP_MODS + // pass through mod_config again, since it previously missed it + // and then only send as ACTION_KEY to bypass most of action.c handling + action.code = ACTION_MODS(mod_config(QK_MOD_TAP_GET_MODS(keycode))); +# else // NO_ACTION_TAPPING_MODTAP_MODS + // pass through keycode_config again, since it previously missed it + // and then only send as ACTION_KEY to bypass most of action.c handling + action.code = ACTION_KEY(keycode_config(QK_MOD_TAP_GET_TAP_KEYCODE(keycode))); +# endif // NO_ACTION_TAPPING_MODTAP_MODS +#endif // NO_ACTION_TAPPING break; -#endif #ifdef SWAP_HANDS_ENABLE case QK_SWAP_HANDS ... QK_SWAP_HANDS_MAX: action.code = ACTION(ACT_SWAP_HANDS, QK_SWAP_HANDS_GET_TAP_KEYCODE(keycode)); diff --git a/quantum/process_keycode/process_autocorrect.c b/quantum/process_keycode/process_autocorrect.c index 8aeebf0e06a4..031079a79247 100644 --- a/quantum/process_keycode/process_autocorrect.c +++ b/quantum/process_keycode/process_autocorrect.c @@ -128,7 +128,11 @@ __attribute__((weak)) bool process_autocorrect_user(uint16_t *keycode, keyrecord #ifdef SWAP_HANDS_ENABLE // Note: IS_SWAP_HANDS_KEYCODE() actually tests for the special action keycodes like SH_TG, SH_TT, ..., // which currently overlap the SH_T(kc) range. - if (IS_SWAP_HANDS_KEYCODE(*keycode) || !record->tap.count) { + if (IS_SWAP_HANDS_KEYCODE(*keycode) +#ifndef NO_ACTION_TAPPING + || !record->tap.count +#endif + ) { return false; } *keycode = QK_SWAP_HANDS_GET_TAP_KEYCODE(*keycode); diff --git a/quantum/process_keycode/process_caps_word.c b/quantum/process_keycode/process_caps_word.c index 4c0217eba7a2..5bebf642708a 100644 --- a/quantum/process_keycode/process_caps_word.c +++ b/quantum/process_keycode/process_caps_word.c @@ -145,7 +145,11 @@ bool process_caps_word(uint16_t keycode, keyrecord_t* record) { case QK_SWAP_HANDS ... QK_SWAP_HANDS_MAX: // Note: IS_SWAP_HANDS_KEYCODE() actually tests for the special action keycodes like SH_TG, SH_TT, ..., // which currently overlap the SH_T(kc) range. - if (IS_SWAP_HANDS_KEYCODE(keycode) || record->tap.count == 0) { + if (IS_SWAP_HANDS_KEYCODE(keycode) +#ifndef NO_ACTION_TAPPING + || record->tap.count == 0 +#endif + ) { return true; } keycode = QK_SWAP_HANDS_GET_TAP_KEYCODE(keycode); From 2a1fe15ced586740a086e7b075bc97ff0d7e6316 Mon Sep 17 00:00:00 2001 From: Drashna Jael're Date: Tue, 10 Jan 2023 10:26:51 -0800 Subject: [PATCH 03/10] Update for linting --- quantum/action.c | 2 +- quantum/process_keycode/process_autocorrect.c | 6 +++--- quantum/process_keycode/process_caps_word.c | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/quantum/action.c b/quantum/action.c index cd820f1c2c42..af4ce18bc17a 100644 --- a/quantum/action.c +++ b/quantum/action.c @@ -519,7 +519,7 @@ void process_action(keyrecord_t *record, action_t action) { } break; } -#endif // NO_ACTION_TAPPING +#endif // NO_ACTION_TAPPING } break; #ifdef EXTRAKEY_ENABLE /* other HID usage */ diff --git a/quantum/process_keycode/process_autocorrect.c b/quantum/process_keycode/process_autocorrect.c index 031079a79247..81c7f7f88187 100644 --- a/quantum/process_keycode/process_autocorrect.c +++ b/quantum/process_keycode/process_autocorrect.c @@ -129,10 +129,10 @@ __attribute__((weak)) bool process_autocorrect_user(uint16_t *keycode, keyrecord // Note: IS_SWAP_HANDS_KEYCODE() actually tests for the special action keycodes like SH_TG, SH_TT, ..., // which currently overlap the SH_T(kc) range. if (IS_SWAP_HANDS_KEYCODE(*keycode) -#ifndef NO_ACTION_TAPPING +# ifndef NO_ACTION_TAPPING || !record->tap.count -#endif - ) { +# endif // NO_ACTION_TAPPING + ) { return false; } *keycode = QK_SWAP_HANDS_GET_TAP_KEYCODE(*keycode); diff --git a/quantum/process_keycode/process_caps_word.c b/quantum/process_keycode/process_caps_word.c index 5bebf642708a..3f49f9894fbe 100644 --- a/quantum/process_keycode/process_caps_word.c +++ b/quantum/process_keycode/process_caps_word.c @@ -146,9 +146,9 @@ bool process_caps_word(uint16_t keycode, keyrecord_t* record) { // Note: IS_SWAP_HANDS_KEYCODE() actually tests for the special action keycodes like SH_TG, SH_TT, ..., // which currently overlap the SH_T(kc) range. if (IS_SWAP_HANDS_KEYCODE(keycode) -#ifndef NO_ACTION_TAPPING - || record->tap.count == 0 -#endif +# ifndef NO_ACTION_TAPPING + || record->tap.count == 0 +# endif // NO_ACTION_TAPPING ) { return true; } From a0441d490a0eb1f9c14eafb6b82205265514ba7d Mon Sep 17 00:00:00 2001 From: Drashna Jael're Date: Tue, 10 Jan 2023 11:09:00 -0800 Subject: [PATCH 04/10] Add NO_ACTION_TAPPING MT/LT unit tests --- tests/no_tapping/no_layer_tap/config.h | 21 ++++ tests/no_tapping/no_layer_tap/test.mk | 18 +++ .../no_tapping/no_layer_tap/test_tapping.cpp | 106 ++++++++++++++++++ tests/no_tapping/no_mod_tap_kc/config.h | 21 ++++ tests/no_tapping/no_mod_tap_kc/test.mk | 18 +++ .../no_tapping/no_mod_tap_kc/test_tapping.cpp | 106 ++++++++++++++++++ tests/no_tapping/no_mod_tap_mods/config.h | 22 ++++ tests/no_tapping/no_mod_tap_mods/test.mk | 18 +++ .../no_mod_tap_mods/test_tapping.cpp | 106 ++++++++++++++++++ 9 files changed, 436 insertions(+) create mode 100644 tests/no_tapping/no_layer_tap/config.h create mode 100644 tests/no_tapping/no_layer_tap/test.mk create mode 100644 tests/no_tapping/no_layer_tap/test_tapping.cpp create mode 100644 tests/no_tapping/no_mod_tap_kc/config.h create mode 100644 tests/no_tapping/no_mod_tap_kc/test.mk create mode 100644 tests/no_tapping/no_mod_tap_kc/test_tapping.cpp create mode 100644 tests/no_tapping/no_mod_tap_mods/config.h create mode 100644 tests/no_tapping/no_mod_tap_mods/test.mk create mode 100644 tests/no_tapping/no_mod_tap_mods/test_tapping.cpp diff --git a/tests/no_tapping/no_layer_tap/config.h b/tests/no_tapping/no_layer_tap/config.h new file mode 100644 index 000000000000..3156e697fb6c --- /dev/null +++ b/tests/no_tapping/no_layer_tap/config.h @@ -0,0 +1,21 @@ +/* Copyright 2017 Fred Sundvik + * + * 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 . + */ + +#pragma once + +#include "test_common.h" + +#define NO_ACTION_TAPPING diff --git a/tests/no_tapping/no_layer_tap/test.mk b/tests/no_tapping/no_layer_tap/test.mk new file mode 100644 index 000000000000..29690d1adf7b --- /dev/null +++ b/tests/no_tapping/no_layer_tap/test.mk @@ -0,0 +1,18 @@ +# Copyright 2017 Fred Sundvik +# +# 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 . + +# -------------------------------------------------------------------------------- +# Keep this file, even if it is empty, as a marker that this folder contains tests +# -------------------------------------------------------------------------------- \ No newline at end of file diff --git a/tests/no_tapping/no_layer_tap/test_tapping.cpp b/tests/no_tapping/no_layer_tap/test_tapping.cpp new file mode 100644 index 000000000000..aee11b69ea53 --- /dev/null +++ b/tests/no_tapping/no_layer_tap/test_tapping.cpp @@ -0,0 +1,106 @@ +/* Copyright 2017 Fred Sundvik + * + * 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 . + */ + +#include "keyboard_report_util.hpp" +#include "keycode.h" +#include "test_common.hpp" +#include "action_tapping.h" +#include "test_keymap_key.hpp" + +using testing::_; +using testing::InSequence; + +class Tapping : public TestFixture {}; + +TEST_F(Tapping, TapA_SHFT_T_KeyReportsKey) { + TestDriver driver; + InSequence s; + auto key_shift_hold_p_tap = KeymapKey(0, 7, 0, LT(1,KC_P)); + + set_keymap({key_shift_hold_p_tap}); + + key_shift_hold_p_tap.press(); + EXPECT_REPORT(driver, (KC_P)); + run_one_scan_loop(); + + key_shift_hold_p_tap.release(); + EXPECT_EMPTY_REPORT(driver); + run_one_scan_loop(); +} + +TEST_F(Tapping, HoldA_SHFT_T_KeyReportsShift) { + TestDriver driver; + InSequence s; + auto mod_tap_hold_key = KeymapKey(0, 7, 0, LT(1,KC_P)); + + set_keymap({mod_tap_hold_key}); + + mod_tap_hold_key.press(); + EXPECT_REPORT(driver, (KC_P)); + + idle_for(TAPPING_TERM); + run_one_scan_loop(); + EXPECT_NO_REPORT(driver); + + mod_tap_hold_key.release(); + EXPECT_EMPTY_REPORT(driver); + run_one_scan_loop(); +} + +TEST_F(Tapping, ANewTapWithinTappingTermIsBuggy) { + // See issue #1478 for more information + TestDriver driver; + InSequence s; + auto key_shift_hold_p_tap = KeymapKey(0, 7, 0, LT(1,KC_P)); + + set_keymap({key_shift_hold_p_tap}); + + // Tapping keys does nothing on press + key_shift_hold_p_tap.press(); + EXPECT_REPORT(driver, (KC_P)); + run_one_scan_loop(); + + key_shift_hold_p_tap.release(); + EXPECT_EMPTY_REPORT(driver); + run_one_scan_loop(); + + + key_shift_hold_p_tap.press(); + EXPECT_REPORT(driver, (KC_P)); + run_one_scan_loop(); + + key_shift_hold_p_tap.release(); + EXPECT_EMPTY_REPORT(driver); + idle_for(TAPPING_TERM + 1); + + key_shift_hold_p_tap.press(); + EXPECT_REPORT(driver, (KC_P)); + run_one_scan_loop(); + key_shift_hold_p_tap.release(); + + EXPECT_EMPTY_REPORT(driver); + idle_for(TAPPING_TERM + 1); + + + key_shift_hold_p_tap.press(); + // Shouldn't be called here really + EXPECT_REPORT(driver, (KC_P)); + idle_for(TAPPING_TERM); + + EXPECT_EMPTY_REPORT(driver); + key_shift_hold_p_tap.release(); + run_one_scan_loop(); +} diff --git a/tests/no_tapping/no_mod_tap_kc/config.h b/tests/no_tapping/no_mod_tap_kc/config.h new file mode 100644 index 000000000000..3156e697fb6c --- /dev/null +++ b/tests/no_tapping/no_mod_tap_kc/config.h @@ -0,0 +1,21 @@ +/* Copyright 2017 Fred Sundvik + * + * 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 . + */ + +#pragma once + +#include "test_common.h" + +#define NO_ACTION_TAPPING diff --git a/tests/no_tapping/no_mod_tap_kc/test.mk b/tests/no_tapping/no_mod_tap_kc/test.mk new file mode 100644 index 000000000000..29690d1adf7b --- /dev/null +++ b/tests/no_tapping/no_mod_tap_kc/test.mk @@ -0,0 +1,18 @@ +# Copyright 2017 Fred Sundvik +# +# 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 . + +# -------------------------------------------------------------------------------- +# Keep this file, even if it is empty, as a marker that this folder contains tests +# -------------------------------------------------------------------------------- \ No newline at end of file diff --git a/tests/no_tapping/no_mod_tap_kc/test_tapping.cpp b/tests/no_tapping/no_mod_tap_kc/test_tapping.cpp new file mode 100644 index 000000000000..26f9d9418ad5 --- /dev/null +++ b/tests/no_tapping/no_mod_tap_kc/test_tapping.cpp @@ -0,0 +1,106 @@ +/* Copyright 2017 Fred Sundvik + * + * 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 . + */ + +#include "keyboard_report_util.hpp" +#include "keycode.h" +#include "test_common.hpp" +#include "action_tapping.h" +#include "test_keymap_key.hpp" + +using testing::_; +using testing::InSequence; + +class Tapping : public TestFixture {}; + +TEST_F(Tapping, TapA_SHFT_T_KeyReportsKey) { + TestDriver driver; + InSequence s; + auto key_shift_hold_p_tap = KeymapKey(0, 7, 0, SFT_T(KC_P)); + + set_keymap({key_shift_hold_p_tap}); + + key_shift_hold_p_tap.press(); + EXPECT_REPORT(driver, (KC_P)); + run_one_scan_loop(); + + key_shift_hold_p_tap.release(); + EXPECT_EMPTY_REPORT(driver); + run_one_scan_loop(); +} + +TEST_F(Tapping, HoldA_SHFT_T_KeyReportsShift) { + TestDriver driver; + InSequence s; + auto mod_tap_hold_key = KeymapKey(0, 7, 0, SFT_T(KC_P)); + + set_keymap({mod_tap_hold_key}); + + mod_tap_hold_key.press(); + EXPECT_REPORT(driver, (KC_P)); + + idle_for(TAPPING_TERM); + run_one_scan_loop(); + EXPECT_NO_REPORT(driver); + + mod_tap_hold_key.release(); + EXPECT_EMPTY_REPORT(driver); + run_one_scan_loop(); +} + +TEST_F(Tapping, ANewTapWithinTappingTermIsBuggy) { + // See issue #1478 for more information + TestDriver driver; + InSequence s; + auto key_shift_hold_p_tap = KeymapKey(0, 7, 0, SFT_T(KC_P)); + + set_keymap({key_shift_hold_p_tap}); + + // Tapping keys does nothing on press + key_shift_hold_p_tap.press(); + EXPECT_REPORT(driver, (KC_P)); + run_one_scan_loop(); + + key_shift_hold_p_tap.release(); + EXPECT_EMPTY_REPORT(driver); + run_one_scan_loop(); + + + key_shift_hold_p_tap.press(); + EXPECT_REPORT(driver, (KC_P)); + run_one_scan_loop(); + + key_shift_hold_p_tap.release(); + EXPECT_EMPTY_REPORT(driver); + idle_for(TAPPING_TERM + 1); + + key_shift_hold_p_tap.press(); + EXPECT_REPORT(driver, (KC_P)); + run_one_scan_loop(); + key_shift_hold_p_tap.release(); + + EXPECT_EMPTY_REPORT(driver); + idle_for(TAPPING_TERM + 1); + + + key_shift_hold_p_tap.press(); + // Shouldn't be called here really + EXPECT_REPORT(driver, (KC_P)); + idle_for(TAPPING_TERM); + + EXPECT_EMPTY_REPORT(driver); + key_shift_hold_p_tap.release(); + run_one_scan_loop(); +} diff --git a/tests/no_tapping/no_mod_tap_mods/config.h b/tests/no_tapping/no_mod_tap_mods/config.h new file mode 100644 index 000000000000..5fca42a8ead9 --- /dev/null +++ b/tests/no_tapping/no_mod_tap_mods/config.h @@ -0,0 +1,22 @@ +/* Copyright 2017 Fred Sundvik + * + * 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 . + */ + +#pragma once + +#include "test_common.h" + +#define NO_ACTION_TAPPING +#define NO_ACTION_TAPPING_MODTAP_MODS diff --git a/tests/no_tapping/no_mod_tap_mods/test.mk b/tests/no_tapping/no_mod_tap_mods/test.mk new file mode 100644 index 000000000000..29690d1adf7b --- /dev/null +++ b/tests/no_tapping/no_mod_tap_mods/test.mk @@ -0,0 +1,18 @@ +# Copyright 2017 Fred Sundvik +# +# 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 . + +# -------------------------------------------------------------------------------- +# Keep this file, even if it is empty, as a marker that this folder contains tests +# -------------------------------------------------------------------------------- \ No newline at end of file diff --git a/tests/no_tapping/no_mod_tap_mods/test_tapping.cpp b/tests/no_tapping/no_mod_tap_mods/test_tapping.cpp new file mode 100644 index 000000000000..178c96297770 --- /dev/null +++ b/tests/no_tapping/no_mod_tap_mods/test_tapping.cpp @@ -0,0 +1,106 @@ +/* Copyright 2017 Fred Sundvik + * + * 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 . + */ + +#include "keyboard_report_util.hpp" +#include "keycode.h" +#include "test_common.hpp" +#include "action_tapping.h" +#include "test_keymap_key.hpp" + +using testing::_; +using testing::InSequence; + +class Tapping : public TestFixture {}; + +TEST_F(Tapping, TapA_SHFT_T_KeyReportsKey) { + TestDriver driver; + InSequence s; + auto key_shift_hold_p_tap = KeymapKey(0, 7, 0, SFT_T(KC_P)); + + set_keymap({key_shift_hold_p_tap}); + + key_shift_hold_p_tap.press(); + EXPECT_REPORT(driver, (KC_LSFT)); + run_one_scan_loop(); + + key_shift_hold_p_tap.release(); + EXPECT_EMPTY_REPORT(driver); + run_one_scan_loop(); +} + +TEST_F(Tapping, HoldA_SHFT_T_KeyReportsShift) { + TestDriver driver; + InSequence s; + auto mod_tap_hold_key = KeymapKey(0, 7, 0, SFT_T(KC_P)); + + set_keymap({mod_tap_hold_key}); + + mod_tap_hold_key.press(); + EXPECT_REPORT(driver, (KC_LSFT)); + + idle_for(TAPPING_TERM); + run_one_scan_loop(); + EXPECT_NO_REPORT(driver); + + mod_tap_hold_key.release(); + EXPECT_EMPTY_REPORT(driver); + run_one_scan_loop(); +} + +TEST_F(Tapping, ANewTapWithinTappingTermIsBuggy) { + // See issue #1478 for more information + TestDriver driver; + InSequence s; + auto key_shift_hold_p_tap = KeymapKey(0, 7, 0, SFT_T(KC_P)); + + set_keymap({key_shift_hold_p_tap}); + + // Tapping keys does nothing on press + key_shift_hold_p_tap.press(); + EXPECT_REPORT(driver, (KC_LSFT)); + run_one_scan_loop(); + + key_shift_hold_p_tap.release(); + EXPECT_EMPTY_REPORT(driver); + run_one_scan_loop(); + + + key_shift_hold_p_tap.press(); + EXPECT_REPORT(driver, (KC_LSFT)); + run_one_scan_loop(); + + key_shift_hold_p_tap.release(); + EXPECT_EMPTY_REPORT(driver); + idle_for(TAPPING_TERM + 1); + + key_shift_hold_p_tap.press(); + EXPECT_REPORT(driver, (KC_LSFT)); + run_one_scan_loop(); + key_shift_hold_p_tap.release(); + + EXPECT_EMPTY_REPORT(driver); + idle_for(TAPPING_TERM + 1); + + + key_shift_hold_p_tap.press(); + // Shouldn't be called here really + EXPECT_REPORT(driver, (KC_LSFT)); + idle_for(TAPPING_TERM); + + EXPECT_EMPTY_REPORT(driver); + key_shift_hold_p_tap.release(); + run_one_scan_loop(); +} From cd71bf4eaf9f6acf00dbab97cea1f2b0568b6869 Mon Sep 17 00:00:00 2001 From: Drashna Jael're Date: Tue, 10 Jan 2023 11:36:42 -0800 Subject: [PATCH 05/10] Fix lints --- tests/no_tapping/no_mod_tap_kc/test_tapping.cpp | 2 -- tests/no_tapping/no_mod_tap_mods/test_tapping.cpp | 2 -- 2 files changed, 4 deletions(-) diff --git a/tests/no_tapping/no_mod_tap_kc/test_tapping.cpp b/tests/no_tapping/no_mod_tap_kc/test_tapping.cpp index 26f9d9418ad5..ef0c599c0d69 100644 --- a/tests/no_tapping/no_mod_tap_kc/test_tapping.cpp +++ b/tests/no_tapping/no_mod_tap_kc/test_tapping.cpp @@ -77,7 +77,6 @@ TEST_F(Tapping, ANewTapWithinTappingTermIsBuggy) { EXPECT_EMPTY_REPORT(driver); run_one_scan_loop(); - key_shift_hold_p_tap.press(); EXPECT_REPORT(driver, (KC_P)); run_one_scan_loop(); @@ -94,7 +93,6 @@ TEST_F(Tapping, ANewTapWithinTappingTermIsBuggy) { EXPECT_EMPTY_REPORT(driver); idle_for(TAPPING_TERM + 1); - key_shift_hold_p_tap.press(); // Shouldn't be called here really EXPECT_REPORT(driver, (KC_P)); diff --git a/tests/no_tapping/no_mod_tap_mods/test_tapping.cpp b/tests/no_tapping/no_mod_tap_mods/test_tapping.cpp index 178c96297770..079c008833a2 100644 --- a/tests/no_tapping/no_mod_tap_mods/test_tapping.cpp +++ b/tests/no_tapping/no_mod_tap_mods/test_tapping.cpp @@ -77,7 +77,6 @@ TEST_F(Tapping, ANewTapWithinTappingTermIsBuggy) { EXPECT_EMPTY_REPORT(driver); run_one_scan_loop(); - key_shift_hold_p_tap.press(); EXPECT_REPORT(driver, (KC_LSFT)); run_one_scan_loop(); @@ -94,7 +93,6 @@ TEST_F(Tapping, ANewTapWithinTappingTermIsBuggy) { EXPECT_EMPTY_REPORT(driver); idle_for(TAPPING_TERM + 1); - key_shift_hold_p_tap.press(); // Shouldn't be called here really EXPECT_REPORT(driver, (KC_LSFT)); From 9b509fd5774eda68cc220f44fe42f8e394b20aba Mon Sep 17 00:00:00 2001 From: Drashna Jael're Date: Tue, 10 Jan 2023 11:37:13 -0800 Subject: [PATCH 06/10] Fix lints --- tests/no_tapping/no_layer_tap/test_tapping.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/tests/no_tapping/no_layer_tap/test_tapping.cpp b/tests/no_tapping/no_layer_tap/test_tapping.cpp index aee11b69ea53..cf9d7358ced8 100644 --- a/tests/no_tapping/no_layer_tap/test_tapping.cpp +++ b/tests/no_tapping/no_layer_tap/test_tapping.cpp @@ -28,7 +28,7 @@ class Tapping : public TestFixture {}; TEST_F(Tapping, TapA_SHFT_T_KeyReportsKey) { TestDriver driver; InSequence s; - auto key_shift_hold_p_tap = KeymapKey(0, 7, 0, LT(1,KC_P)); + auto key_shift_hold_p_tap = KeymapKey(0, 7, 0, LT(1, KC_P)); set_keymap({key_shift_hold_p_tap}); @@ -44,7 +44,7 @@ TEST_F(Tapping, TapA_SHFT_T_KeyReportsKey) { TEST_F(Tapping, HoldA_SHFT_T_KeyReportsShift) { TestDriver driver; InSequence s; - auto mod_tap_hold_key = KeymapKey(0, 7, 0, LT(1,KC_P)); + auto mod_tap_hold_key = KeymapKey(0, 7, 0, LT(1, KC_P)); set_keymap({mod_tap_hold_key}); @@ -64,7 +64,7 @@ TEST_F(Tapping, ANewTapWithinTappingTermIsBuggy) { // See issue #1478 for more information TestDriver driver; InSequence s; - auto key_shift_hold_p_tap = KeymapKey(0, 7, 0, LT(1,KC_P)); + auto key_shift_hold_p_tap = KeymapKey(0, 7, 0, LT(1, KC_P)); set_keymap({key_shift_hold_p_tap}); @@ -77,7 +77,6 @@ TEST_F(Tapping, ANewTapWithinTappingTermIsBuggy) { EXPECT_EMPTY_REPORT(driver); run_one_scan_loop(); - key_shift_hold_p_tap.press(); EXPECT_REPORT(driver, (KC_P)); run_one_scan_loop(); @@ -94,7 +93,6 @@ TEST_F(Tapping, ANewTapWithinTappingTermIsBuggy) { EXPECT_EMPTY_REPORT(driver); idle_for(TAPPING_TERM + 1); - key_shift_hold_p_tap.press(); // Shouldn't be called here really EXPECT_REPORT(driver, (KC_P)); From ae9bdc122a1d78480221eeaabe8e96dbb5bca63a Mon Sep 17 00:00:00 2001 From: Drashna Jael're Date: Tue, 10 Jan 2023 13:41:37 -0800 Subject: [PATCH 07/10] Better/more tests --- .../config.h | 0 .../test.mk | 0 .../test_layer_tap.cpp} | 49 +------- .../test_mod_tap.cpp} | 3 + .../no_action_tapping/test_one_shot_keys.cpp | 107 ++++++++++++++++++ tests/no_tapping/no_mod_tap_kc/config.h | 21 ---- tests/no_tapping/no_mod_tap_kc/test.mk | 18 --- 7 files changed, 114 insertions(+), 84 deletions(-) rename tests/no_tapping/{no_layer_tap => no_action_tapping}/config.h (100%) rename tests/no_tapping/{no_layer_tap => no_action_tapping}/test.mk (100%) rename tests/no_tapping/{no_layer_tap/test_tapping.cpp => no_action_tapping/test_layer_tap.cpp} (57%) rename tests/no_tapping/{no_mod_tap_kc/test_tapping.cpp => no_action_tapping/test_mod_tap.cpp} (96%) create mode 100644 tests/no_tapping/no_action_tapping/test_one_shot_keys.cpp delete mode 100644 tests/no_tapping/no_mod_tap_kc/config.h delete mode 100644 tests/no_tapping/no_mod_tap_kc/test.mk diff --git a/tests/no_tapping/no_layer_tap/config.h b/tests/no_tapping/no_action_tapping/config.h similarity index 100% rename from tests/no_tapping/no_layer_tap/config.h rename to tests/no_tapping/no_action_tapping/config.h diff --git a/tests/no_tapping/no_layer_tap/test.mk b/tests/no_tapping/no_action_tapping/test.mk similarity index 100% rename from tests/no_tapping/no_layer_tap/test.mk rename to tests/no_tapping/no_action_tapping/test.mk diff --git a/tests/no_tapping/no_layer_tap/test_tapping.cpp b/tests/no_tapping/no_action_tapping/test_layer_tap.cpp similarity index 57% rename from tests/no_tapping/no_layer_tap/test_tapping.cpp rename to tests/no_tapping/no_action_tapping/test_layer_tap.cpp index cf9d7358ced8..568c3c35d604 100644 --- a/tests/no_tapping/no_layer_tap/test_tapping.cpp +++ b/tests/no_tapping/no_action_tapping/test_layer_tap.cpp @@ -25,7 +25,7 @@ using testing::InSequence; class Tapping : public TestFixture {}; -TEST_F(Tapping, TapA_SHFT_T_KeyReportsKey) { +TEST_F(Tapping, TapP_Layer_Tap_KeyReportsKey) { TestDriver driver; InSequence s; auto key_shift_hold_p_tap = KeymapKey(0, 7, 0, LT(1, KC_P)); @@ -39,9 +39,10 @@ TEST_F(Tapping, TapA_SHFT_T_KeyReportsKey) { key_shift_hold_p_tap.release(); EXPECT_EMPTY_REPORT(driver); run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); } -TEST_F(Tapping, HoldA_SHFT_T_KeyReportsShift) { +TEST_F(Tapping, HoldP_Layer_Tap_KeyReportsKey) { TestDriver driver; InSequence s; auto mod_tap_hold_key = KeymapKey(0, 7, 0, LT(1, KC_P)); @@ -58,47 +59,5 @@ TEST_F(Tapping, HoldA_SHFT_T_KeyReportsShift) { mod_tap_hold_key.release(); EXPECT_EMPTY_REPORT(driver); run_one_scan_loop(); -} - -TEST_F(Tapping, ANewTapWithinTappingTermIsBuggy) { - // See issue #1478 for more information - TestDriver driver; - InSequence s; - auto key_shift_hold_p_tap = KeymapKey(0, 7, 0, LT(1, KC_P)); - - set_keymap({key_shift_hold_p_tap}); - - // Tapping keys does nothing on press - key_shift_hold_p_tap.press(); - EXPECT_REPORT(driver, (KC_P)); - run_one_scan_loop(); - - key_shift_hold_p_tap.release(); - EXPECT_EMPTY_REPORT(driver); - run_one_scan_loop(); - - key_shift_hold_p_tap.press(); - EXPECT_REPORT(driver, (KC_P)); - run_one_scan_loop(); - - key_shift_hold_p_tap.release(); - EXPECT_EMPTY_REPORT(driver); - idle_for(TAPPING_TERM + 1); - - key_shift_hold_p_tap.press(); - EXPECT_REPORT(driver, (KC_P)); - run_one_scan_loop(); - key_shift_hold_p_tap.release(); - - EXPECT_EMPTY_REPORT(driver); - idle_for(TAPPING_TERM + 1); - - key_shift_hold_p_tap.press(); - // Shouldn't be called here really - EXPECT_REPORT(driver, (KC_P)); - idle_for(TAPPING_TERM); - - EXPECT_EMPTY_REPORT(driver); - key_shift_hold_p_tap.release(); - run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); } diff --git a/tests/no_tapping/no_mod_tap_kc/test_tapping.cpp b/tests/no_tapping/no_action_tapping/test_mod_tap.cpp similarity index 96% rename from tests/no_tapping/no_mod_tap_kc/test_tapping.cpp rename to tests/no_tapping/no_action_tapping/test_mod_tap.cpp index ef0c599c0d69..68d8ab5a12dd 100644 --- a/tests/no_tapping/no_mod_tap_kc/test_tapping.cpp +++ b/tests/no_tapping/no_action_tapping/test_mod_tap.cpp @@ -39,6 +39,7 @@ TEST_F(Tapping, TapA_SHFT_T_KeyReportsKey) { key_shift_hold_p_tap.release(); EXPECT_EMPTY_REPORT(driver); run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); } TEST_F(Tapping, HoldA_SHFT_T_KeyReportsShift) { @@ -58,6 +59,7 @@ TEST_F(Tapping, HoldA_SHFT_T_KeyReportsShift) { mod_tap_hold_key.release(); EXPECT_EMPTY_REPORT(driver); run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); } TEST_F(Tapping, ANewTapWithinTappingTermIsBuggy) { @@ -101,4 +103,5 @@ TEST_F(Tapping, ANewTapWithinTappingTermIsBuggy) { EXPECT_EMPTY_REPORT(driver); key_shift_hold_p_tap.release(); run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); } diff --git a/tests/no_tapping/no_action_tapping/test_one_shot_keys.cpp b/tests/no_tapping/no_action_tapping/test_one_shot_keys.cpp new file mode 100644 index 000000000000..b67c083def90 --- /dev/null +++ b/tests/no_tapping/no_action_tapping/test_one_shot_keys.cpp @@ -0,0 +1,107 @@ +/* Copyright 2021 Stefan Kerkmann + * + * 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 . + */ + +#include "action_util.h" +#include "keyboard_report_util.hpp" +#include "test_common.hpp" + +using testing::_; +using testing::InSequence; + +class OneShot : public TestFixture {}; + +TEST_F(OneShot, OSMWithoutAdditionalKeypressDoesNothing) { + TestDriver driver; + auto osm_key = KeymapKey(0, 0, 0, OSM(MOD_LSFT), KC_LSFT); + + set_keymap({osm_key}); + + /* Press and release OSM key*/ + EXPECT_NO_REPORT(driver); + osm_key.press(); + EXPECT_REPORT(driver, (osm_key.report_code)); + run_one_scan_loop(); + EXPECT_NO_REPORT(driver); + osm_key.release(); + EXPECT_EMPTY_REPORT(driver); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); +} + +// TEST_F(OneShot, OSL_No_ReportPress) { +// TestDriver driver; +// auto osl_key = KeymapKey{0, 0, 0, OSL(1)}; +// auto empty_key = KeymapKey{0, 1, 0, KC_NO}; +// auto regular_key = KeymapKey{1, 1, 0, KC_A}; + +// set_keymap({osl_key, empty_key, regular_key}); + +// /* Press OSL key */ +// EXPECT_NO_REPORT(driver); +// osl_key.press(); +// run_one_scan_loop(); +// VERIFY_AND_CLEAR(driver); + +// /* Release OSL key */ +// EXPECT_NO_REPORT(driver); +// osl_key.release(); +// run_one_scan_loop(); +// VERIFY_AND_CLEAR(driver); + +// /* Press regular key */ +// EXPECT_NO_REPORT(driver); +// regular_key.press(); +// run_one_scan_loop(); +// VERIFY_AND_CLEAR(driver); + +// /* Release regular key */ +// EXPECT_NO_REPORT(driver); +// regular_key.release(); +// run_one_scan_loop(); +// VERIFY_AND_CLEAR(driver); +// } + + +// TEST_F(OneShot, OSL_ReportPress) { +// TestDriver driver; +// auto osl_key = KeymapKey{0, 0, 0, OSL(1)}; +// auto empty_key = KeymapKey{0, 1, 0, KC_NO}; +// auto regular_key = KeymapKey{1, 1, 0, KC_A}; + +// set_keymap({osl_key, empty_key, regular_key}); + +// /* Press OSL key */ +// osl_key.press(); +// run_one_scan_loop(); +// EXPECT_NO_REPORT(driver); + +// /* Press regular key */ +// regular_key.press(); +// run_one_scan_loop(); +// EXPECT_NO_REPORT(driver); + +// /* Release regular key */ +// regular_key.release(); +// run_one_scan_loop(); +// EXPECT_NO_REPORT(driver); + +// /* Release OSL key */ +// osl_key.release(); +// run_one_scan_loop(); +// EXPECT_NO_REPORT(driver); +// VERIFY_AND_CLEAR(driver); + +// } diff --git a/tests/no_tapping/no_mod_tap_kc/config.h b/tests/no_tapping/no_mod_tap_kc/config.h deleted file mode 100644 index 3156e697fb6c..000000000000 --- a/tests/no_tapping/no_mod_tap_kc/config.h +++ /dev/null @@ -1,21 +0,0 @@ -/* Copyright 2017 Fred Sundvik - * - * 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 . - */ - -#pragma once - -#include "test_common.h" - -#define NO_ACTION_TAPPING diff --git a/tests/no_tapping/no_mod_tap_kc/test.mk b/tests/no_tapping/no_mod_tap_kc/test.mk deleted file mode 100644 index 29690d1adf7b..000000000000 --- a/tests/no_tapping/no_mod_tap_kc/test.mk +++ /dev/null @@ -1,18 +0,0 @@ -# Copyright 2017 Fred Sundvik -# -# 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 . - -# -------------------------------------------------------------------------------- -# Keep this file, even if it is empty, as a marker that this folder contains tests -# -------------------------------------------------------------------------------- \ No newline at end of file From c34f64a805fb8669df2e02156fe69a2ff4dba498 Mon Sep 17 00:00:00 2001 From: Drashna Jael're Date: Sun, 12 Feb 2023 10:09:15 -0800 Subject: [PATCH 08/10] Fix submodules --- lib/chibios | 2 +- lib/chibios-contrib | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/chibios b/lib/chibios index 0e9d558b525a..0062927e3058 160000 --- a/lib/chibios +++ b/lib/chibios @@ -1 +1 @@ -Subproject commit 0e9d558b525a8f28285f3bb509fd48a897c43151 +Subproject commit 0062927e3058a8b5ef587234bbd98d42fb4e595e diff --git a/lib/chibios-contrib b/lib/chibios-contrib index 1130173eae6b..a224be155ae1 160000 --- a/lib/chibios-contrib +++ b/lib/chibios-contrib @@ -1 +1 @@ -Subproject commit 1130173eae6b7402443aff18ad68228acbe25cc4 +Subproject commit a224be155ae18d38deccf33a6c1d259b9a5ad8d3 From a01366d3c84c1b6ce38e1e873a27f1a0457734be Mon Sep 17 00:00:00 2001 From: Drashna Jael're Date: Sun, 12 Feb 2023 13:29:31 -0800 Subject: [PATCH 09/10] Fix linting issues and re-add tests --- quantum/keymap_common.c | 2 +- .../no_action_tapping/test_one_shot_keys.cpp | 127 +++++++++--------- 2 files changed, 64 insertions(+), 65 deletions(-) diff --git a/quantum/keymap_common.c b/quantum/keymap_common.c index 5377a74c9f85..f5e101755fc5 100644 --- a/quantum/keymap_common.c +++ b/quantum/keymap_common.c @@ -157,7 +157,7 @@ action_t action_for_keycode(uint16_t keycode) { # else // LEGACY_MAGIC_HANDLING action.code = ACTION_MODS_TAP_KEY(mod, keycode_config(QK_MOD_TAP_GET_TAP_KEYCODE(keycode))); # endif // LEGACY_MAGIC_HANDLING -#else // NO_ACTION_TAPPING +#else // NO_ACTION_TAPPING # ifdef NO_ACTION_TAPPING_MODTAP_MODS // pass through mod_config again, since it previously missed it // and then only send as ACTION_KEY to bypass most of action.c handling diff --git a/tests/no_tapping/no_action_tapping/test_one_shot_keys.cpp b/tests/no_tapping/no_action_tapping/test_one_shot_keys.cpp index b67c083def90..080642475356 100644 --- a/tests/no_tapping/no_action_tapping/test_one_shot_keys.cpp +++ b/tests/no_tapping/no_action_tapping/test_one_shot_keys.cpp @@ -41,67 +41,66 @@ TEST_F(OneShot, OSMWithoutAdditionalKeypressDoesNothing) { VERIFY_AND_CLEAR(driver); } -// TEST_F(OneShot, OSL_No_ReportPress) { -// TestDriver driver; -// auto osl_key = KeymapKey{0, 0, 0, OSL(1)}; -// auto empty_key = KeymapKey{0, 1, 0, KC_NO}; -// auto regular_key = KeymapKey{1, 1, 0, KC_A}; - -// set_keymap({osl_key, empty_key, regular_key}); - -// /* Press OSL key */ -// EXPECT_NO_REPORT(driver); -// osl_key.press(); -// run_one_scan_loop(); -// VERIFY_AND_CLEAR(driver); - -// /* Release OSL key */ -// EXPECT_NO_REPORT(driver); -// osl_key.release(); -// run_one_scan_loop(); -// VERIFY_AND_CLEAR(driver); - -// /* Press regular key */ -// EXPECT_NO_REPORT(driver); -// regular_key.press(); -// run_one_scan_loop(); -// VERIFY_AND_CLEAR(driver); - -// /* Release regular key */ -// EXPECT_NO_REPORT(driver); -// regular_key.release(); -// run_one_scan_loop(); -// VERIFY_AND_CLEAR(driver); -// } - - -// TEST_F(OneShot, OSL_ReportPress) { -// TestDriver driver; -// auto osl_key = KeymapKey{0, 0, 0, OSL(1)}; -// auto empty_key = KeymapKey{0, 1, 0, KC_NO}; -// auto regular_key = KeymapKey{1, 1, 0, KC_A}; - -// set_keymap({osl_key, empty_key, regular_key}); - -// /* Press OSL key */ -// osl_key.press(); -// run_one_scan_loop(); -// EXPECT_NO_REPORT(driver); - -// /* Press regular key */ -// regular_key.press(); -// run_one_scan_loop(); -// EXPECT_NO_REPORT(driver); - -// /* Release regular key */ -// regular_key.release(); -// run_one_scan_loop(); -// EXPECT_NO_REPORT(driver); - -// /* Release OSL key */ -// osl_key.release(); -// run_one_scan_loop(); -// EXPECT_NO_REPORT(driver); -// VERIFY_AND_CLEAR(driver); - -// } +TEST_F(OneShot, OSL_No_ReportPress) { + TestDriver driver; + auto osl_key = KeymapKey{0, 0, 0, OSL(1)}; + auto empty_key = KeymapKey{0, 1, 0, KC_NO}; + auto regular_key = KeymapKey{1, 1, 0, KC_A}; + + set_keymap({osl_key, empty_key, regular_key}); + + /* Press OSL key */ + EXPECT_NO_REPORT(driver); + osl_key.press(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + /* Release OSL key */ + EXPECT_NO_REPORT(driver); + osl_key.release(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + /* Press regular key */ + EXPECT_NO_REPORT(driver); + regular_key.press(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + /* Release regular key */ + EXPECT_NO_REPORT(driver); + regular_key.release(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); +} + +TEST_F(OneShot, OSL_ReportPress) { + TestDriver driver; + auto osl_key = KeymapKey{0, 0, 0, OSL(1)}; + auto empty_key = KeymapKey{0, 1, 0, KC_NO}; + auto regular_key = KeymapKey{1, 1, 0, KC_A}; + + set_keymap({osl_key, empty_key, regular_key}); + + /* Press OSL key */ + osl_key.press(); + run_one_scan_loop(); + EXPECT_NO_REPORT(driver); + + /* Press regular key */ + regular_key.press(); + run_one_scan_loop(); + EXPECT_NO_REPORT(driver); + + /* Release regular key */ + regular_key.release(); + run_one_scan_loop(); + EXPECT_NO_REPORT(driver); + + /* Release OSL key */ + osl_key.release(); + run_one_scan_loop(); + EXPECT_NO_REPORT(driver); + VERIFY_AND_CLEAR(driver); + +} From c5315a186051fec115c08e3e772ddc00bb39104d Mon Sep 17 00:00:00 2001 From: Drashna Jael're Date: Sun, 12 Feb 2023 13:30:08 -0800 Subject: [PATCH 10/10] formatting --- tests/no_tapping/no_action_tapping/test_one_shot_keys.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/no_tapping/no_action_tapping/test_one_shot_keys.cpp b/tests/no_tapping/no_action_tapping/test_one_shot_keys.cpp index 080642475356..e2ca61120d1b 100644 --- a/tests/no_tapping/no_action_tapping/test_one_shot_keys.cpp +++ b/tests/no_tapping/no_action_tapping/test_one_shot_keys.cpp @@ -102,5 +102,4 @@ TEST_F(OneShot, OSL_ReportPress) { run_one_scan_loop(); EXPECT_NO_REPORT(driver); VERIFY_AND_CLEAR(driver); - }