@@ -56,6 +56,8 @@ byte layoutLength = 0;
5656String currentLayout = " " ;
5757// For maximum 10 layers
5858const short jsonDocSize = 16384 ;
59+ size_t tapToggleOrginalLayerIndex = 0 ;
60+ bool isTemporaryToggled = false ;
5961
6062byte inputs[] = {23 , 19 , 18 , 5 , 32 , 33 , 25 }; // declaring inputs and outputs
6163const int inputCount = sizeof (inputs) / sizeof (inputs[0 ]);
@@ -655,11 +657,25 @@ void loop() {
655657 .substring (6 , sizeof (keyMap[r][c].keyInfo ) - 1 )
656658 .toInt ();
657659 macroPress (macroMap[index]);
660+ } else if (keyMap[r][c].keyInfo .startsWith (" TT_" )) {
661+ // Tap-Toggle press
662+ if (!isTemporaryToggled) {
663+ size_t index =
664+ keyMap[r][c]
665+ .keyInfo
666+ .substring (3 , sizeof (keyMap[r][c].keyInfo ) - 1 )
667+ .toInt ();
668+ tapToggleActive (index);
669+ }
658670 } else {
659671 // Standard key press
660672 keyPress (keyMap[r][c]);
661673 }
662674 } else {
675+ if (keyMap[r][c].keyInfo .startsWith (" TT_" ) &&
676+ isTemporaryToggled) {
677+ tapToggleRelease (tapToggleOrginalLayerIndex);
678+ }
663679 keyRelease (keyMap[r][c]);
664680 }
665681 delayMicroseconds (10 );
@@ -884,6 +900,29 @@ void macroPress(Macro ¯o) {
884900 delay (100 );
885901}
886902
903+ /* *
904+ * Tap toggle layer
905+ *
906+ * @param {size_t} index of the layer to be toggled
907+ */
908+ void tapToggleActive (size_t index) {
909+ isTemporaryToggled = true ;
910+ tapToggleOrginalLayerIndex = currentLayoutIndex;
911+ currentLayoutIndex = index;
912+ initKeys ();
913+ }
914+
915+ /* *
916+ * Tap toggle layer release
917+ *
918+ * @param {size_t} original layer index of the layer to be restored
919+ */
920+ void tapToggleRelease (size_t orginalLayerIndex) {
921+ isTemporaryToggled = false ;
922+ currentLayoutIndex = orginalLayerIndex;
923+ initKeys ();
924+ }
925+
887926/* *
888927 * Switch keymap layout
889928 *
0 commit comments