From d32a688698aa36a2e5ebe244c74853a78b6cbd7d Mon Sep 17 00:00:00 2001 From: Michael Richters Date: Tue, 8 Jun 2021 13:30:19 -0500 Subject: [PATCH] Add testcases for issues reported to Chrysalis Signed-off-by: Michael Richters --- tests/issues/1057/1057.ino | 86 +++++++++++++++++++++++ tests/issues/1057/common.h | 33 +++++++++ tests/issues/1057/sketch.json | 6 ++ tests/issues/1057/test.ktest | 124 ++++++++++++++++++++++++++++++++++ 4 files changed, 249 insertions(+) create mode 100644 tests/issues/1057/1057.ino create mode 100644 tests/issues/1057/common.h create mode 100644 tests/issues/1057/sketch.json create mode 100644 tests/issues/1057/test.ktest diff --git a/tests/issues/1057/1057.ino b/tests/issues/1057/1057.ino new file mode 100644 index 00000000..885277da --- /dev/null +++ b/tests/issues/1057/1057.ino @@ -0,0 +1,86 @@ +/* -*- mode: c++ -*- + * Copyright (C) 2021 Keyboard.io, Inc. + * + * 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, version 3. + * + * 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 +#include +#include + +#include "./common.h" + +// *INDENT-OFF* +KEYMAPS( + [0] = KEYMAP_STACKED + ( + OSL(1), Key_1, Key_2, Key_3, Key_4, Key_5, XXX, + Key_Backtick, Key_Q, Key_W, Key_E, Key_R, Key_T, Key_Tab, + Key_PageUp, Key_A, Key_S, Key_D, Key_F, Key_G, + Key_PageDown, Key_Z, Key_X, Key_C, Key_V, Key_B, Key_Escape, + + Key_LeftControl, Key_Backspace, Key_LeftGui, Key_LeftShift, + Key_Q, + + XXX, OSM(LeftGui), LSHIFT(Key_LeftShift), LSHIFT(Key_RightShift), Key_9, Key_0, XXX, + Key_Enter, Key_Y, Key_U, Key_I, Key_O, Key_P, Key_Equals, + Key_H, SFT_T(J), CTL_T(K), ALT_T(L), GUI_T(Semicolon), Key_Quote, + Key_skip, Key_N, Key_M, Key_Comma, Key_Period, Key_Slash, Key_Minus, + + Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl, + LT(1,E) + ), + [1] = KEYMAP_STACKED + ( + ___, SFT_T(A), Key_C, Key_D, Key_E, Key_F, Key_G, + Key_A, Key_B, Key_C, Key_D, Key_E, Key_F, Key_G, + Key_A, Key_B, Key_C, Key_D, Key_E, Key_F, + Key_A, Key_B, Key_C, Key_D, Key_E, Key_F, Key_G, + + Key_1, Key_2, Key_3, Key_4, + ___, + + + ___, Key_B, Key_C, Key_D, Key_E, Key_F, Key_G, + Key_A, Key_B, Key_C, Key_D, Key_E, Key_F, Key_G, + Key_A, Key_B, Key_C, Key_D, Key_E, Key_F, + Key_A, Key_B, Key_C, Key_D, Key_E, Key_F, Key_G, + + Key_1, Key_2, Key_3, Key_4, + ___ + ), +) +// *INDENT-ON* + +KALEIDOSCOPE_INIT_PLUGINS(Qukeys, OneShot); + +void setup() { + QUKEYS( + kaleidoscope::plugin::Qukey(0, KeyAddr(2, 1), Key_LeftGui), // A/cmd + kaleidoscope::plugin::Qukey(0, KeyAddr(2, 2), Key_LeftAlt), // S/alt + kaleidoscope::plugin::Qukey(0, KeyAddr(2, 3), Key_LeftControl), // D/ctrl + kaleidoscope::plugin::Qukey(0, KeyAddr(2, 4), Key_LeftShift), // F/shift + kaleidoscope::plugin::Qukey(0, KeyAddr(3, 6), ShiftToLayer(1)) // Q/layer-shift (on `fn`) + ) + Qukeys.setHoldTimeout(kaleidoscope::testing::QUKEYS_HOLD_TIMEOUT); + Qukeys.setOverlapThreshold(kaleidoscope::testing::QUKEYS_OVERLAP_THRESHOLD); + Qukeys.setMinimumHoldTime(kaleidoscope::testing::QUKEYS_MINIMUM_HOLD_TIME); + Qukeys.setMinimumPriorInterval(kaleidoscope::testing::QUKEYS_MIN_PRIOR_INTERVAL); + Qukeys.setMaxIntervalForTapRepeat(kaleidoscope::testing::QUKEYS_MAX_INTERVAL_FOR_TAP_REPEAT); + + Kaleidoscope.setup(); +} + +void loop() { + Kaleidoscope.loop(); +} diff --git a/tests/issues/1057/common.h b/tests/issues/1057/common.h new file mode 100644 index 00000000..424d2ce4 --- /dev/null +++ b/tests/issues/1057/common.h @@ -0,0 +1,33 @@ +// -*- mode: c++ -*- + +/* Kaleidoscope - Firmware for computer input devices + * Copyright (C) 2021 Keyboard.io, Inc. + * + * 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, version 3. + * + * 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 + +namespace kaleidoscope { +namespace testing { + +constexpr uint16_t QUKEYS_HOLD_TIMEOUT = 200; +constexpr uint8_t QUKEYS_OVERLAP_THRESHOLD = 0; +constexpr uint8_t QUKEYS_MINIMUM_HOLD_TIME = 0; +constexpr uint8_t QUKEYS_MIN_PRIOR_INTERVAL = 0; +constexpr uint8_t QUKEYS_MAX_INTERVAL_FOR_TAP_REPEAT = 0; + +} // namespace testing +} // namespace kaleidoscope diff --git a/tests/issues/1057/sketch.json b/tests/issues/1057/sketch.json new file mode 100644 index 00000000..8cc86922 --- /dev/null +++ b/tests/issues/1057/sketch.json @@ -0,0 +1,6 @@ +{ + "cpu": { + "fqbn": "keyboardio:virtual:model01", + "port": "" + } +} diff --git a/tests/issues/1057/test.ktest b/tests/issues/1057/test.ktest new file mode 100644 index 00000000..7c4d583a --- /dev/null +++ b/tests/issues/1057/test.ktest @@ -0,0 +1,124 @@ +VERSION 1 + +KEYSWITCH OSL 0 0 # 0: OSL(1) +KEYSWITCH QK 0 1 # 1: SFT_T(A) +KEYSWITCH C 0 2 # 1: Key_C +KEYSWITCH A 2 1 # 0: Key_A, Qukey(Key_LeftGui) +KEYSWITCH H 2 10 # 0: Key_H +KEYSWITCH Y 1 10 # 0: Key_Y +KEYSWITCH K 2 12 # 0: CTL_T(K) + +KEYSWITCH OSG 0 10 # 0: OSM(LeftGui) +KEYSWITCH LS 0 11 # 0: LSHIFT(Key_LeftShift) +KEYSWITCH RS 0 12 # 0: LSHIFT(Key_RightShift) + +# ============================================================================== +NAME Chrysalis 566 and 605 + +RUN 4 ms +PRESS OSL # OSL(1) +RUN 1 cycle + +RUN 4 ms +RELEASE OSL +RUN 1 cycle + +RUN 4 ms +PRESS QK # SFT_T(A) +RUN 1 cycle + +RUN 4 ms +PRESS C # 1: Key_C +RUN 1 cycle + +RUN 4 ms +RELEASE C +RUN 1 cycle +EXPECT keyboard-report Key_LeftShift +EXPECT keyboard-report Key_LeftShift Key_C +EXPECT keyboard-report Key_LeftShift + +RUN 4 ms +RELEASE QK +RUN 1 cycle +EXPECT keyboard-report empty + +RUN 5 ms + +# ============================================================================== +NAME Chrysalis 688 + +# plain key press +RUN 4 ms +PRESS H # Key_H +RUN 1 cycle +EXPECT keyboard-report Key_H + +# qukey press +RUN 4 ms +PRESS K # CTL_T(K) +RUN 1 cycle + +# plain key release +RUN 9 ms +RELEASE H +RUN 1 cycle +# There should be no report here + +# plain key press +RUN 4 ms +PRESS Y # Key_Y +RUN 1 cycle + +# plain key release +RUN 4 ms +RELEASE Y +RUN 1 cycle +# This event resolves the qukey's state and flushes the queue +EXPECT keyboard-report Key_H Key_LeftControl +EXPECT keyboard-report Key_LeftControl +EXPECT keyboard-report Key_LeftControl Key_Y +EXPECT keyboard-report Key_LeftControl + +# qukey release +RUN 4 ms +RELEASE K +RUN 1 cycle +EXPECT keyboard-report empty + +RUN 5 ms + +# ============================================================================== +NAME Chrysalis 427 workaround + +RUN 4 ms +PRESS OSG # OSM(LeftGui) +RUN 1 cycle +EXPECT keyboard-report Key_LeftGui + +RUN 4 ms +RELEASE OSG +RUN 1 cycle + +RUN 4 ms +PRESS LS # LSHIFT(Key_LeftShift) +RUN 1 cycle +EXPECT keyboard-report Key_LeftGui Key_LeftShift + +RUN 4 ms +PRESS H +RUN 1 cycle +EXPECT keyboard-report Key_LeftGui Key_LeftShift Key_H +EXPECT keyboard-report Key_LeftShift Key_H + +RUN 4 ms +RELEASE H +RUN 1 cycle +EXPECT keyboard-report Key_LeftShift + +RUN 4 ms +RELEASE LS +RUN 1 cycle +EXPECT keyboard-report empty + +RUN 5 ms