From e334be135df06695011c64a8e6beb02c5ad7d4aa Mon Sep 17 00:00:00 2001 From: Michael Richters Date: Thu, 27 May 2021 11:55:03 -0500 Subject: [PATCH] Add testcase for OneShot/TapDance/Macros compatibility OneShot keys should apply to all the key events generated by a Macros key, not just the first one, even if the Macros key is injected by TapDance. Signed-off-by: Michael Richters --- tests/issues/423/423.ino | 18 +++++++++++-- tests/issues/423/test.ktest | 52 +++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+), 2 deletions(-) diff --git a/tests/issues/423/423.ino b/tests/issues/423/423.ino index dcf02840..0cf1d584 100644 --- a/tests/issues/423/423.ino +++ b/tests/issues/423/423.ino @@ -15,6 +15,7 @@ */ #include +#include #include #include @@ -46,13 +47,26 @@ void tapDanceAction(uint8_t tap_dance_index, switch (tap_dance_index) { case 0: return tapDanceActionKeys(tap_count, tap_dance_action, - Key_Period, LSHIFT(Key_1)); + Key_Period, M(0), LSHIFT(Key_1)); default: break; } } -KALEIDOSCOPE_INIT_PLUGINS(OneShot, TapDance); +const macro_t *macroAction(uint8_t macro_id, KeyEvent &event) { + if (keyToggledOn(event.state)) { + switch (macro_id) { + case 0: + Macros.type(PSTR("abc")); + break; + default: + break; + } + } + return MACRO_NONE; +} + +KALEIDOSCOPE_INIT_PLUGINS(Macros, OneShot, TapDance); void setup() { Kaleidoscope.setup(); diff --git a/tests/issues/423/test.ktest b/tests/issues/423/test.ktest index c734e0e9..fb5d1075 100644 --- a/tests/issues/423/test.ktest +++ b/tests/issues/423/test.ktest @@ -122,4 +122,56 @@ RELEASE A RUN 1 cycle EXPECT keyboard-report empty +RUN 5 ms + +# ============================================================================== +NAME OSM applies to whole Macro + +RUN 4 ms +PRESS OS_SHIFT +RUN 1 cycle +EXPECT keyboard-report Key_LeftShift # report: { e1 } + +RUN 4 ms +RELEASE OS_SHIFT +RUN 1 cycle + +RUN 4 ms +PRESS TD_0 +RUN 1 cycle + +RUN 4 ms +RELEASE TD_0 +RUN 1 cycle + +RUN 4 ms +PRESS TD_0 +RUN 1 cycle + +RUN 4 ms +RELEASE TD_0 +RUN 1 cycle + +# ------------------------------------------------------------------------------ +# Next, we press `space`, triggering both the resolution of the TapDance key and +# the release of the OneShot key, in that order. +RUN 4 ms +PRESS SPACE +RUN 1 cycle +EXPECT keyboard-report Key_LeftShift Key_A # report: { 4 e1 } +EXPECT keyboard-report Key_LeftShift # report: { e1 } +EXPECT keyboard-report Key_LeftShift Key_B # report: { 5 e1 } +EXPECT keyboard-report Key_LeftShift # report: { e1 } +EXPECT keyboard-report Key_LeftShift Key_C # report: { 6 e1 } +EXPECT keyboard-report Key_LeftShift # report: { e1 } +EXPECT keyboard-report empty # report: { } +EXPECT keyboard-report Key_Spacebar # report: { 2c } + +RUN 4 ms +RELEASE SPACE +RUN 1 cycle +EXPECT keyboard-report empty + + + RUN 5 ms