Add testcase for issue 1061

This is a demonstration that another plugin can use the new public OneShot
methods to turn a non-OneShot key into a OneShot.

Signed-off-by: Michael Richters <gedankenexperimenter@gmail.com>
pull/1062/head
Michael Richters 4 years ago
parent 03c086f34f
commit 25c975eae7
No known key found for this signature in database
GPG Key ID: 1288FD13E4EEF0C0

@ -0,0 +1,70 @@
/* -*- 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 <http://www.gnu.org/licenses/>.
*/
#include <Kaleidoscope.h>
#include <Kaleidoscope-OneShot.h>
// *INDENT-OFF*
KEYMAPS(
[0] = KEYMAP_STACKED
(
Key_Insert, ___, ___, ___, ___, ___, ___,
Key_A, Key_B, ___, ___, ___, ___, ___,
___, ___, ___, ___, ___, ___,
___, ___, ___, ___, ___, ___, ___,
___, ___, ___, ___,
___,
___, ___, ___, ___, ___, ___, ___,
___, ___, ___, ___, ___, ___, ___,
___, ___, ___, ___, ___, ___,
___, ___, ___, ___, ___, ___, ___,
___, ___, ___, ___,
___
),
)
// *INDENT-ON*
namespace kaleidoscope {
namespace plugin {
class OneShotInsert : public Plugin {
public:
EventHandlerResult onKeyEvent(KeyEvent &event) {
if (keyToggledOn(event.state) && (event.state & INJECTED) == 0 &&
event.key == Key_Insert && live_keys[event.addr] != event.key)
::OneShot.setPending(event.addr);
return EventHandlerResult::OK;
}
};
} // namespace plugin
} // namespace kaleidoscope
kaleidoscope::plugin::OneShotInsert OneShotInsert;
KALEIDOSCOPE_INIT_PLUGINS(OneShot, OneShotInsert);
void setup() {
Kaleidoscope.setup();
OneShot.setTimeout(50);
OneShot.setHoldTimeout(20);
OneShot.setDoubleTapTimeout(20);
}
void loop() {
Kaleidoscope.loop();
}

@ -0,0 +1,6 @@
{
"cpu": {
"fqbn": "keyboardio:virtual:model01",
"port": ""
}
}

@ -0,0 +1,100 @@
VERSION 1
KEYSWITCH INSERT 0 0
KEYSWITCH A 1 0
KEYSWITCH B 1 1
# ==============================================================================
NAME OneShot insert timeout
RUN 4 ms
PRESS INSERT
RUN 1 cycle
EXPECT keyboard-report Key_Insert
RUN 4 ms
RELEASE INSERT
RUN 1 cycle
RUN 45 ms
EXPECT keyboard-report empty
RUN 4 ms
PRESS A
RUN 1 cycle
EXPECT keyboard-report Key_A
RUN 4 ms
RELEASE A
RUN 1 cycle
EXPECT keyboard-report empty
RUN 5 ms
# ==============================================================================
NAME OneShot insert interrupt
RUN 4 ms
PRESS INSERT
RUN 1 cycle
EXPECT keyboard-report Key_Insert
RUN 4 ms
RELEASE INSERT
RUN 1 cycle
RUN 4 ms
PRESS A
RUN 1 cycle
EXPECT keyboard-report Key_Insert Key_A
EXPECT keyboard-report Key_A
RUN 4 ms
RELEASE A
RUN 1 cycle
EXPECT keyboard-report empty
RUN 5 ms
# ==============================================================================
NAME OneShot insert sticky
RUN 4 ms
PRESS INSERT
RUN 1 cycle
EXPECT keyboard-report Key_Insert
RUN 4 ms
RELEASE INSERT
RUN 1 cycle
RUN 4 ms
PRESS INSERT
RUN 1 cycle
RUN 4 ms
RELEASE INSERT
RUN 1 cycle
RUN 4 ms
PRESS A
RUN 1 cycle
EXPECT keyboard-report Key_Insert Key_A
RUN 4 ms
RELEASE A
RUN 1 cycle
EXPECT keyboard-report Key_Insert
RUN 100 ms
RUN 4 ms
PRESS INSERT
RUN 1 cycle
RUN 4 ms
RELEASE INSERT
RUN 1 cycle
EXPECT keyboard-report empty
RUN 5 ms
Loading…
Cancel
Save