Compare commits
20 Commits
main
...
f/keymap-c
Author | SHA1 | Date |
---|---|---|
Jesse Vincent | a98074ae47 | 4 years ago |
Michael Richters | 9165475da1 | 4 years ago |
Michael Richters | 03a8872a95 | 4 years ago |
Michael Richters | e5ba44a6da | 4 years ago |
Michael Richters | 23d8c6577e | 4 years ago |
Michael Richters | 2e4110d171 | 4 years ago |
Michael Richters | b06afda760 | 4 years ago |
Michael Richters | b13aaba529 | 4 years ago |
Michael Richters | 77546706a3 | 4 years ago |
Michael Richters | 5434f82a0f | 4 years ago |
Michael Richters | 60d1e2faaf | 4 years ago |
Michael Richters | 38c18cdcc7 | 4 years ago |
Michael Richters | 3b1500a526 | 4 years ago |
Michael Richters | 62d0ec70ea | 4 years ago |
Michael Richters | c9d6a04335 | 4 years ago |
Michael Richters | b0c9c18004 | 4 years ago |
Michael Richters | 4fdff6c9ec | 4 years ago |
Michael Richters | dc4cdc28e0 | 4 years ago |
Michael Richters | cc9d531f8e | 4 years ago |
Michael Richters | 7efc9743ef | 4 years ago |
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace kaleidoscope {
|
||||
namespace testing {
|
||||
|
||||
} // namespace testing
|
||||
} // namespace kaleidoscope
|
@ -0,0 +1,82 @@
|
||||
/* -*- 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <Kaleidoscope.h>
|
||||
#include <Kaleidoscope-Macros.h>
|
||||
|
||||
#include "./common.h"
|
||||
|
||||
#undef min
|
||||
#undef max
|
||||
#include <iostream>
|
||||
|
||||
// *INDENT-OFF*
|
||||
KEYMAPS(
|
||||
[0] = KEYMAP_STACKED
|
||||
(
|
||||
Key_A, ___, ___, ___, ___, ___, ___,
|
||||
ShiftToLayer(1), ___, ___, ___, ___, ___, ___,
|
||||
___, ___, ___, ___, ___, ___,
|
||||
___, ___, ___, ___, ___, ___, ___,
|
||||
___, ___, ___, ___,
|
||||
___,
|
||||
|
||||
___, ___, ___, ___, ___, ___, ___,
|
||||
___, ___, ___, ___, ___, ___, ___,
|
||||
___, ___, ___, ___, ___, ___,
|
||||
___, ___, ___, ___, ___, ___, ___,
|
||||
___, ___, ___, ___,
|
||||
___
|
||||
),
|
||||
[1] = KEYMAP_STACKED
|
||||
(
|
||||
M(0), ___, ___, ___, ___, ___, ___,
|
||||
___, ___, ___, ___, ___, ___, ___,
|
||||
___, ___, ___, ___, ___, ___,
|
||||
___, ___, ___, ___, ___, ___, ___,
|
||||
___, ___, ___, ___,
|
||||
___,
|
||||
|
||||
___, ___, ___, ___, ___, ___, ___,
|
||||
___, ___, ___, ___, ___, ___, ___,
|
||||
___, ___, ___, ___, ___, ___,
|
||||
___, ___, ___, ___, ___, ___, ___,
|
||||
___, ___, ___, ___,
|
||||
___
|
||||
),
|
||||
)
|
||||
// *INDENT-ON*
|
||||
|
||||
const macro_t *macroAction(uint8_t index, uint8_t key_state) {
|
||||
if (keyToggledOn(key_state)) {
|
||||
switch (index) {
|
||||
case 0:
|
||||
Kaleidoscope.hid().keyboard().pressKey(Key_Y);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return MACRO_NONE;
|
||||
}
|
||||
|
||||
KALEIDOSCOPE_INIT_PLUGINS(Macros);
|
||||
|
||||
void setup() {
|
||||
Kaleidoscope.setup();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
Kaleidoscope.loop();
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
{
|
||||
"cpu": {
|
||||
"fqbn": "keyboardio:virtual:model01",
|
||||
"port": ""
|
||||
}
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
VERSION 1
|
||||
|
||||
KEYSWITCH A 0 0
|
||||
KEYSWITCH LAYER_SHIFT 1 0
|
||||
|
||||
# ==============================================================================
|
||||
# Active Keys Cache
|
||||
NAME Active keys cache cleared
|
||||
|
||||
RUN 10 ms
|
||||
|
||||
PRESS A
|
||||
RUN 1 cycle
|
||||
EXPECT keyboard-report Key_A # Report should contain only `A`
|
||||
|
||||
RUN 5 ms
|
||||
|
||||
RELEASE A
|
||||
RUN 1 cycle
|
||||
EXPECT keyboard-report empty # Report should be empty
|
||||
|
||||
RUN 5 ms
|
||||
|
||||
# Press and hold `ShiftToLayer(1)`, changing the `A` key to `X`
|
||||
PRESS LAYER_SHIFT
|
||||
RUN 5 ms
|
||||
|
||||
PRESS A
|
||||
RUN 1 cycle
|
||||
EXPECT keyboard-report Key_Y # Report should contain only `Y`
|
||||
RUN 1 cycle
|
||||
EXPECT keyboard-report empty # Report should be empty
|
||||
|
||||
RUN 5 ms
|
||||
|
||||
RELEASE A
|
||||
|
||||
RUN 5 ms
|
||||
|
||||
RELEASE LAYER_SHIFT
|
||||
RUN 5 ms
|
||||
|
||||
PRESS A
|
||||
RUN 1 cycle
|
||||
EXPECT keyboard-report Key_A # Report should contain only `A`
|
||||
|
||||
RUN 5 ms
|
||||
|
||||
RELEASE A
|
||||
RUN 1 cycle
|
||||
EXPECT keyboard-report empty # Report should be empty
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace kaleidoscope {
|
||||
namespace testing {
|
||||
|
||||
} // namespace testing
|
||||
} // namespace kaleidoscope
|
@ -0,0 +1,104 @@
|
||||
/* -*- 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <Kaleidoscope.h>
|
||||
|
||||
#include "./common.h"
|
||||
|
||||
#undef min
|
||||
#undef max
|
||||
#include <iostream>
|
||||
|
||||
// *INDENT-OFF*
|
||||
KEYMAPS(
|
||||
[0] = KEYMAP_STACKED
|
||||
(
|
||||
Key_A, ___, ___, ___, ___, ___, ___,
|
||||
ShiftToLayer(1), ___, ___, ___, ___, ___, ___,
|
||||
___, ___, ___, ___, ___, ___,
|
||||
___, ___, ___, ___, ___, ___, ___,
|
||||
___, ___, ___, ___,
|
||||
___,
|
||||
|
||||
___, ___, ___, ___, ___, ___, ___,
|
||||
___, ___, ___, ___, ___, ___, ___,
|
||||
___, ___, ___, ___, ___, ___,
|
||||
___, ___, ___, ___, ___, ___, ___,
|
||||
___, ___, ___, ___,
|
||||
___
|
||||
),
|
||||
[1] = KEYMAP_STACKED
|
||||
(
|
||||
Key_X, ___, ___, ___, ___, ___, ___,
|
||||
___, ___, ___, ___, ___, ___, ___,
|
||||
___, ___, ___, ___, ___, ___,
|
||||
___, ___, ___, ___, ___, ___, ___,
|
||||
___, ___, ___, ___,
|
||||
___,
|
||||
|
||||
___, ___, ___, ___, ___, ___, ___,
|
||||
___, ___, ___, ___, ___, ___, ___,
|
||||
___, ___, ___, ___, ___, ___,
|
||||
___, ___, ___, ___, ___, ___, ___,
|
||||
___, ___, ___, ___,
|
||||
___
|
||||
),
|
||||
)
|
||||
// *INDENT-ON*
|
||||
|
||||
namespace kaleidoscope {
|
||||
namespace plugin {
|
||||
|
||||
class ConvertXtoY : public kaleidoscope::Plugin {
|
||||
public:
|
||||
EventHandlerResult onKeyswitchEvent(Key &key, KeyAddr key_addr, uint8_t key_state) {
|
||||
if (keyToggledOn(key_state)) {
|
||||
if (key == Key_X)
|
||||
key = Key_Y;
|
||||
}
|
||||
// It should be impossible to get a `Key_X` at this point, because the
|
||||
// previous block changes any `Key_X` to `Key_Y`, which results in the
|
||||
// active keys cache storing that value. On subsequent cycles (while the key
|
||||
// is still pressed), the `key` value should be `Key_Y`.
|
||||
if (keyIsPressed(key_state) && key == Key_X) {
|
||||
std::cerr << "t=" << Runtime.millisAtCycleStart() << ": "
|
||||
<< "Error: we shouldn't see a key with value `X`" << std::endl;
|
||||
}
|
||||
// When `Key_Y` toggles off, return `EVENT_CONSUMED`. Despite this, the
|
||||
// active keys cache entry should be cleared. If it's not, then a subsequent
|
||||
// press of the same key without the layer shift in effect will still result
|
||||
// in `Key_Y` instead of `Key_A`.
|
||||
if (keyToggledOff(key_state) && (key == Key_Y)) {
|
||||
return EventHandlerResult::EVENT_CONSUMED;
|
||||
}
|
||||
return EventHandlerResult::OK;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace plugin
|
||||
} // namespace kaleidoscope
|
||||
|
||||
kaleidoscope::plugin::ConvertXtoY ConvertXtoY;
|
||||
|
||||
KALEIDOSCOPE_INIT_PLUGINS(ConvertXtoY);
|
||||
|
||||
void setup() {
|
||||
Kaleidoscope.setup();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
Kaleidoscope.loop();
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
{
|
||||
"cpu": {
|
||||
"fqbn": "keyboardio:virtual:model01",
|
||||
"port": ""
|
||||
}
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
VERSION 1
|
||||
|
||||
KEYSWITCH A 0 0
|
||||
KEYSWITCH LAYER_SHIFT 1 0
|
||||
|
||||
# ==============================================================================
|
||||
# Active Keys Cache
|
||||
NAME Active keys cache cleared
|
||||
|
||||
RUN 10 ms
|
||||
|
||||
PRESS A
|
||||
RUN 1 cycle
|
||||
EXPECT keyboard-report Key_A # Report should contain only `A`
|
||||
|
||||
RUN 5 ms
|
||||
|
||||
RELEASE A
|
||||
RUN 1 cycle
|
||||
EXPECT keyboard-report empty # Report should be empty
|
||||
|
||||
RUN 5 ms
|
||||
|
||||
# Press and hold `ShiftToLayer(1)`, changing the `A` key to `X`
|
||||
PRESS LAYER_SHIFT
|
||||
RUN 5 ms
|
||||
|
||||
# Press `X`, which gets converted to `Y` by the `ConvertXtoY` plugin defined in
|
||||
# the sketch. The plugin simply changes the value of the key, which causes it to
|
||||
# get set to `Key_Y` in the active keys cache.
|
||||
PRESS A
|
||||
RUN 1 cycle
|
||||
EXPECT keyboard-report Key_Y # Report should contain only `Y`
|
||||
|
||||
RUN 5 ms
|
||||
|
||||
# Release the `X` key (on Layer 1), which has become a `Y` key in the active
|
||||
# keys cache. This should clear its entry in that cache.
|
||||
RELEASE A
|
||||
RUN 1 cycle
|
||||
EXPECT keyboard-report empty # Report should be empty
|
||||
|
||||
RUN 5 ms
|
||||
|
||||
# Release `ShiftToLayer(1)`. This should restore the `A` key to its base layer
|
||||
# value on subsequent presses, unless the Macros key gets "stuck" in the active
|
||||
# keys array because it returns `EVENT_CONSUMED`.
|
||||
RELEASE LAYER_SHIFT
|
||||
RUN 5 ms
|
||||
|
||||
PRESS A
|
||||
RUN 1 cycle
|
||||
EXPECT keyboard-report Key_A # Report should contain only `A`
|
||||
|
||||
RUN 5 ms
|
||||
|
||||
RELEASE A
|
||||
RUN 1 cycle
|
||||
EXPECT keyboard-report empty # Report should be empty
|
@ -0,0 +1,85 @@
|
||||
/* -*- 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <Kaleidoscope.h>
|
||||
#include <Kaleidoscope-TapDance.h>
|
||||
|
||||
#include "./common.h"
|
||||
|
||||
#undef min
|
||||
#undef max
|
||||
#include <iostream>
|
||||
|
||||
// *INDENT-OFF*
|
||||
KEYMAPS(
|
||||
[0] = KEYMAP_STACKED
|
||||
(
|
||||
Key_X, ___, ___, ___, ___, ___, ___,
|
||||
TD(0), ___, ___, ___, ___, ___, ___,
|
||||
LockLayer(1), ___, ___, ___, ___, ___,
|
||||
___, ___, ___, ___, ___, ___, ___,
|
||||
___, ___, ___, ___,
|
||||
___,
|
||||
|
||||
___, ___, ___, ___, ___, ___, ___,
|
||||
___, ___, ___, ___, ___, ___, ___,
|
||||
___, ___, ___, ___, ___, ___,
|
||||
___, ___, ___, ___, ___, ___, ___,
|
||||
___, ___, ___, ___,
|
||||
___
|
||||
),
|
||||
[1] = KEYMAP_STACKED
|
||||
(
|
||||
Key_Y, ___, ___, ___, ___, ___, ___,
|
||||
___, ___, ___, ___, ___, ___, ___,
|
||||
___, ___, ___, ___, ___, ___,
|
||||
___, ___, ___, ___, ___, ___, ___,
|
||||
___, ___, ___, ___,
|
||||
___,
|
||||
|
||||
___, ___, ___, ___, ___, ___, ___,
|
||||
___, ___, ___, ___, ___, ___, ___,
|
||||
___, ___, ___, ___, ___, ___,
|
||||
___, ___, ___, ___, ___, ___, ___,
|
||||
___, ___, ___, ___,
|
||||
___
|
||||
),
|
||||
)
|
||||
// *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, LockLayer(1));
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
KALEIDOSCOPE_INIT_PLUGINS(TapDance);
|
||||
|
||||
void setup() {
|
||||
Kaleidoscope.setup();
|
||||
TapDance.time_out = 25;
|
||||
}
|
||||
|
||||
void loop() {
|
||||
Kaleidoscope.loop();
|
||||
}
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace kaleidoscope {
|
||||
namespace testing {
|
||||
|
||||
} // namespace testing
|
||||
} // namespace kaleidoscope
|
@ -0,0 +1,6 @@
|
||||
{
|
||||
"cpu": {
|
||||
"fqbn": "keyboardio:virtual:model01",
|
||||
"port": ""
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
VERSION 1
|
||||
|
||||
KEYSWITCH X 0 0
|
||||
KEYSWITCH TD_0 1 0
|
||||
KEYSWITCH LL_1 2 0
|
||||
|
||||
# ==============================================================================
|
||||
NAME TapDance hold past timeout
|
||||
|
||||
RUN 5 ms
|
||||
|
||||
PRESS TD_0
|
||||
RUN 1 cycle
|
||||
RUN 25 ms # timeout is 25 ms
|
||||
|
||||
RUN 2 cycles
|
||||
EXPECT keyboard-report Key_A # The report should contain only `A`
|
||||
|
||||
RUN 20 ms
|
||||
|
||||
RELEASE TD_0
|
||||
RUN 1 cycle
|
||||
|
||||
EXPECT keyboard-report empty # The report should be empty
|
@ -0,0 +1,72 @@
|
||||
/* -*- 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <Kaleidoscope.h>
|
||||
#include <Kaleidoscope-TapDance.h>
|
||||
|
||||
#include "./common.h"
|
||||
|
||||
#undef min
|
||||
#undef max
|
||||
#include <iostream>
|
||||
|
||||
// *INDENT-OFF*
|
||||
KEYMAPS(
|
||||
[0] = KEYMAP_STACKED
|
||||
(
|
||||
TD(0), TD(1), ___, ___, ___, ___, ___,
|
||||
___, ___, ___, ___, ___, ___, ___,
|
||||
___, ___, ___, ___, ___, ___,
|
||||
___, ___, ___, ___, ___, ___, ___,
|
||||
___, ___, ___, ___,
|
||||
___,
|
||||
|
||||
___, ___, ___, ___, ___, ___, ___,
|
||||
___, ___, ___, ___, ___, ___, ___,
|
||||
___, ___, ___, ___, ___, ___,
|
||||
___, ___, ___, ___, ___, ___, ___,
|
||||
___, ___, ___, ___,
|
||||
___
|
||||
),
|
||||
)
|
||||
// *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_X);
|
||||
case 1:
|
||||
return tapDanceActionKeys(tap_count, tap_dance_action,
|
||||
Key_B, Key_Y);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
KALEIDOSCOPE_INIT_PLUGINS(TapDance);
|
||||
|
||||
void setup() {
|
||||
Kaleidoscope.setup();
|
||||
TapDance.time_out = 25;
|
||||
}
|
||||
|
||||
void loop() {
|
||||
Kaleidoscope.loop();
|
||||
}
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace kaleidoscope {
|
||||
namespace testing {
|
||||
|
||||
} // namespace testing
|
||||
} // namespace kaleidoscope
|
@ -0,0 +1,6 @@
|
||||
{
|
||||
"cpu": {
|
||||
"fqbn": "keyboardio:virtual:model01",
|
||||
"port": ""
|
||||
}
|
||||
}
|
@ -0,0 +1,121 @@
|
||||
VERSION 1
|
||||
|
||||
KEYSWITCH TD_0 0 0
|
||||
KEYSWITCH TD_1 0 1
|
||||
|
||||
# ==============================================================================
|
||||
NAME TapDance to TapDance rollover left to right
|
||||
|
||||
RUN 5 ms
|
||||
PRESS TD_0
|
||||
RUN 5 ms
|
||||
PRESS TD_1
|
||||
RUN 1 cycle
|
||||
EXPECT keyboard-report Key_A # TD_0 should be interrupted, yielding `A`
|
||||
RUN 4 ms
|
||||
RELEASE TD_0
|
||||
RUN 1 cycle
|
||||
EXPECT keyboard-report empty # Empty report on TD_0 release
|
||||
RUN 4 ms
|
||||
RELEASE TD_1
|
||||
RUN 18 ms
|
||||
EXPECT keyboard-report Key_B # TD_1 should time out, yielding `B`
|
||||
RUN 1 cycle
|
||||
EXPECT keyboard-report empty # Empty report after TD_1 timeout
|
||||
RUN 11 ms
|
||||
|
||||
RUN 5 ms
|
||||
PRESS TD_0
|
||||
RUN 5 ms
|
||||
PRESS TD_1
|
||||
RUN 1 cycle
|
||||
EXPECT keyboard-report Key_A # TD_0 should be interrupted, yielding `A`
|
||||
RUN 4 ms
|
||||
RELEASE TD_0
|
||||
RUN 1 cycle
|
||||
EXPECT keyboard-report empty # Empty report on TD_0 release
|
||||
RUN 4 ms
|
||||
RELEASE TD_1
|
||||
RUN 18 ms
|
||||
EXPECT keyboard-report Key_B # TD_1 should time out, yielding `B`
|
||||
RUN 1 cycle
|
||||
EXPECT keyboard-report empty # Empty report after TD_1 timeout
|
||||
RUN 11 ms
|
||||
|
||||
# ==============================================================================
|
||||
NAME TapDance to TapDance rollover right to left
|
||||
|
||||
RUN 5 ms
|
||||
PRESS TD_1
|
||||
RUN 5 ms
|
||||
PRESS TD_0
|
||||
RUN 1 cycle
|
||||
EXPECT keyboard-report Key_B # TD_1 should be interrupted, yielding `B`
|
||||
RUN 4 ms
|
||||
RELEASE TD_1
|
||||
RUN 1 cycle
|
||||
EXPECT keyboard-report empty # Empty report on TD_1 release
|
||||
RUN 4 ms
|
||||
RELEASE TD_0
|
||||
RUN 18 ms
|
||||
EXPECT keyboard-report Key_A # TD_0 should time out, yielding `A`
|
||||
RUN 1 cycle
|
||||
EXPECT keyboard-report empty # Empty report after TD_0 timeout
|
||||
RUN 11 ms
|
||||
|
||||
RUN 5 ms
|
||||
PRESS TD_1
|
||||
RUN 5 ms
|
||||
PRESS TD_0
|
||||
RUN 1 cycle
|
||||
EXPECT keyboard-report Key_B # TD_1 should be interrupted, yielding `B`
|
||||
RUN 4 ms
|
||||
RELEASE TD_1
|
||||
RUN 1 cycle
|
||||
EXPECT keyboard-report empty # Empty report on TD_1 release
|
||||
RUN 4 ms
|
||||
RELEASE TD_0
|
||||
RUN 18 ms
|
||||
EXPECT keyboard-report Key_A # TD_0 should time out, yielding `A`
|
||||
RUN 1 cycle
|
||||
EXPECT keyboard-report empty # Empty report after TD_0 timeout
|
||||
RUN 11 ms
|
||||
|
||||
# ==============================================================================
|
||||
NAME TapDance to TapDance rollover back and forth
|
||||
|
||||
RUN 5 ms
|
||||
PRESS TD_0
|
||||
RUN 5 ms
|
||||
PRESS TD_1
|
||||
RUN 1 cycle
|
||||
EXPECT keyboard-report Key_A # TD_0 should be interrupted, yielding `A`
|
||||
RUN 4 ms
|
||||
RELEASE TD_0
|
||||
RUN 1 cycle
|
||||
EXPECT keyboard-report empty # Empty report on TD_0 release
|
||||
RUN 4 ms
|
||||
RELEASE TD_1
|
||||
RUN 18 ms
|
||||
EXPECT keyboard-report Key_B # TD_1 should time out, yielding `B`
|
||||
RUN 1 cycle
|
||||
EXPECT keyboard-report empty # Empty report after TD_1 timeout
|
||||
RUN 11 ms
|
||||
|
||||
RUN 5 ms
|
||||
PRESS TD_1
|
||||
RUN 5 ms
|
||||
PRESS TD_0
|
||||
RUN 1 cycle
|
||||
EXPECT keyboard-report Key_B # TD_1 should be interrupted, yielding `B`
|
||||
RUN 4 ms
|
||||
RELEASE TD_1
|
||||
RUN 1 cycle
|
||||
EXPECT keyboard-report empty # Empty report on TD_1 release
|
||||
RUN 4 ms
|
||||
RELEASE TD_0
|
||||
RUN 18 ms
|
||||
EXPECT keyboard-report Key_A # TD_0 should time out, yielding `A`
|
||||
RUN 1 cycle
|
||||
EXPECT keyboard-report empty # Empty report after TD_0 timeout
|
||||
RUN 11 ms
|
@ -0,0 +1,85 @@
|
||||
/* -*- 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <Kaleidoscope.h>
|
||||
#include <Kaleidoscope-TapDance.h>
|
||||
|
||||
#include "./common.h"
|
||||
|
||||
#undef min
|
||||
#undef max
|
||||
#include <iostream>
|
||||
|
||||
// *INDENT-OFF*
|
||||
KEYMAPS(
|
||||
[0] = KEYMAP_STACKED
|
||||
(
|
||||
Key_X, ___, ___, ___, ___, ___, ___,
|
||||
TD(0), ___, ___, ___, ___, ___, ___,
|
||||
LockLayer(1), ___, ___, ___, ___, ___,
|
||||
___, ___, ___, ___, ___, ___, ___,
|
||||
___, ___, ___, ___,
|
||||
___,
|
||||
|
||||
___, ___, ___, ___, ___, ___, ___,
|
||||
___, ___, ___, ___, ___, ___, ___,
|
||||
___, ___, ___, ___, ___, ___,
|
||||
___, ___, ___, ___, ___, ___, ___,
|
||||
___, ___, ___, ___,
|
||||
___
|
||||
),
|
||||
[1] = KEYMAP_STACKED
|
||||
(
|
||||
Key_Y, ___, ___, ___, ___, ___, ___,
|
||||
___, ___, ___, ___, ___, ___, ___,
|
||||
___, ___, ___, ___, ___, ___,
|
||||
___, ___, ___, ___, ___, ___, ___,
|
||||
___, ___, ___, ___,
|
||||
___,
|
||||
|
||||
___, ___, ___, ___, ___, ___, ___,
|
||||
___, ___, ___, ___, ___, ___, ___,
|
||||
___, ___, ___, ___, ___, ___,
|
||||
___, ___, ___, ___, ___, ___, ___,
|
||||
___, ___, ___, ___,
|
||||
___
|
||||
),
|
||||
)
|
||||
// *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, LockLayer(1));
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
KALEIDOSCOPE_INIT_PLUGINS(TapDance);
|
||||
|
||||
void setup() {
|
||||
Kaleidoscope.setup();
|
||||
TapDance.time_out = 25;
|
||||
}
|
||||
|
||||
void loop() {
|
||||
Kaleidoscope.loop();
|
||||
}
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace kaleidoscope {
|
||||
namespace testing {
|
||||
|
||||
} // namespace testing
|
||||
} // namespace kaleidoscope
|
@ -0,0 +1,6 @@
|
||||
{
|
||||
"cpu": {
|
||||
"fqbn": "keyboardio:virtual:model01",
|
||||
"port": ""
|
||||
}
|
||||
}
|
@ -0,0 +1,69 @@
|
||||
VERSION 1
|
||||
|
||||
KEYSWITCH X 0 0
|
||||
KEYSWITCH TD_0 1 0
|
||||
KEYSWITCH LL_1 2 0
|
||||
|
||||
# ==============================================================================
|
||||
NAME TapDance issue 980 no overlap
|
||||
|
||||
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 2 cycles
|
||||
EXPECT keyboard-report Key_Y # The key should be mapped from layer 1 (Y), not layer 0 (X)
|
||||
RUN 5 ms
|
||||
|
||||
RELEASE X
|
||||
RUN 1 cycle
|
||||
EXPECT keyboard-report empty # The report should be empty
|
||||
RUN 5 ms
|
||||
|
||||
PRESS LL_1
|
||||
RUN 1 cycle
|
||||
|
||||
RELEASE LL_1
|
||||
RUN 1 cycle
|
||||
|
||||
# ==============================================================================
|
||||
NAME TapDance issue 980 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 2 cycles
|
||||
EXPECT keyboard-report Key_Y # The key should be mapped from layer 1 (Y), not layer 0 (X)
|
||||
RUN 5 ms
|
||||
|
||||
RELEASE TD_0
|
||||
RUN 5 ms
|
||||
|
||||
RELEASE X
|
||||
RUN 1 cycle
|
||||
EXPECT keyboard-report empty # The report should be empty
|
||||
RUN 5 ms
|
||||
|
||||
PRESS LL_1
|
||||
RUN 1 cycle
|
||||
|
||||
RELEASE LL_1
|
||||
RUN 1 cycle
|
Loading…
Reference in new issue