diff --git a/tests/plugins/TapDance/basic/common.h b/tests/plugins/TapDance/basic/common.h new file mode 100644 index 00000000..dcfcc35b --- /dev/null +++ b/tests/plugins/TapDance/basic/common.h @@ -0,0 +1,27 @@ +// -*- mode: c++ -*- + +/* Kaleidoscope - Firmware for computer input devices + * Copyright (C) 2020 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 { + +} // namespace testing +} // namespace kaleidoscope diff --git a/tests/plugins/TapDance/basic/sketch.ino b/tests/plugins/TapDance/basic/sketch.ino new file mode 100644 index 00000000..2e7f342f --- /dev/null +++ b/tests/plugins/TapDance/basic/sketch.ino @@ -0,0 +1,65 @@ +/* -*- mode: c++ -*- + * Copyright (C) 2020 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 "./common.h" + +// *INDENT-OFF* +KEYMAPS( + [0] = KEYMAP_STACKED + ( + Key_X, ___, ___, ___, ___, ___, ___, + TD(0), ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, + ___, + + ___, ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, + ___ + ), +) +// *INDENT-ON* + +void tapDanceAction(uint8_t tap_dance_index, + KeyAddr key_addr, + uint8_t tap_count, + kaleidoscope::plugin::TapDance::ActionType tap_dance_action) { + switch (tap_dance_index) { + case 0: + return tapDanceActionKeys(tap_count, tap_dance_action, + Key_A, Key_B, Key_C); + default: + break; + } +} + +KALEIDOSCOPE_INIT_PLUGINS(TapDance); + +void setup() { + Kaleidoscope.setup(); + TapDance.time_out = 25; +} + +void loop() { + Kaleidoscope.loop(); +} diff --git a/tests/plugins/TapDance/basic/test.ktest b/tests/plugins/TapDance/basic/test.ktest new file mode 100644 index 00000000..64d90c94 --- /dev/null +++ b/tests/plugins/TapDance/basic/test.ktest @@ -0,0 +1,105 @@ +VERSION 1 + +KEYSWITCH X 0 0 +KEYSWITCH TD_0 1 0 + +# ============================================================================== +NAME Tapdance interrupt + +RUN 5 ms +PRESS TD_0 +RUN 5 ms +RELEASE TD_0 + +RUN 10 ms +PRESS TD_0 +RUN 5 ms +RELEASE TD_0 + +RUN 5 ms +PRESS X +RUN 1 cycle +EXPECT keyboard-report Key_B # The report should contain `B` +EXPECT keyboard-report empty # Report should be empty +RUN 1 cycle +EXPECT keyboard-report Key_X # Report should contain `X` + +RUN 5 ms +RELEASE X +RUN 1 cycle +EXPECT keyboard-report empty # Report should be empty + +# ============================================================================== +NAME Tapdance timeout + +RUN 50 ms + +PRESS TD_0 +RUN 5 ms +RELEASE TD_0 +RUN 10 ms + +PRESS TD_0 +RUN 1 cycle +RUN 5 ms +RELEASE TD_0 +RUN 20 ms # Timeout = 25ms + +RUN 2 ms # Extra 2 cycles for some reason +EXPECT keyboard-report Key_B # The report should contain `B` +EXPECT keyboard-report empty # Report should be empty + +# ============================================================================== +# The testcases below are commented out because they are currently failing. + +# # ============================================================================== +# NAME Tapdance interrupt with rollover + +# RUN 5 ms +# PRESS TD_0 +# RUN 5 ms +# RELEASE TD_0 + +# RUN 10 ms +# PRESS TD_0 + +# RUN 5 ms +# PRESS X +# RUN 1 cycle +# EXPECT keyboard-report Key_B # The report should contain `B` +# RUN 1 cycle +# EXPECT keyboard-report Key_B Key_X # Report should contain `B` & `X` + +# RUN 5 ms +# RELEASE TD_0 +# RUN 1 cycle +# EXPECT keyboard-report Key_X # Report should contain `X` + + +# RUN 5 ms +# RELEASE X +# RUN 1 cycle +# EXPECT keyboard-report empty # Report should be empty + +# # ============================================================================== +# NAME Tapdance timeout while held + +# RUN 5 ms + +# PRESS TD_0 +# RUN 5 ms +# RELEASE TD_0 +# RUN 10 ms + +# PRESS TD_0 +# RUN 1 cycle +# RUN 25 ms + +# RUN 2 cycles +# EXPECT keyboard-report Key_B # The report should contain `B` + +# RUN 10 ms +# RELEASE TD_0 +# RUN 1 cycle + +# EXPECT keyboard-report empty # Report should be empty