Merge pull request #1157 from gedankenexperimenter/clang-format-improved

Replace clang-format wrapper script
pull/1159/head
Jesse Vincent 3 years ago committed by GitHub
commit ea291858b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -106,10 +106,18 @@ find-filename-conflicts:
.PHONY: format check-formatting cpplint cpplint-noisy shellcheck smoke-examples find-filename-conflicts prepare-virtual checkout-platform adjust-git-timestamps docker-bash docker-simulator-tests run-tests simulator-tests setup
format:
bin/format-code.sh
bin/format-code.py \
--exclude-dir 'testing/googletest' \
--exclude-file 'generated-testcase.cpp' \
src plugins examples testing
check-formatting:
bin/format-code.sh --check
bin/format-code.py \
--exclude-dir 'testing/googletest' \
--exclude-file 'generated-testcase.cpp' \
--check \
--verbose \
src plugins examples testing
cpplint-noisy:
-bin/cpplint.py --config=.cpplint-noisy --recursive src plugins examples

@ -0,0 +1,271 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# ------------------------------------------------------------------------------
# Copyright (c) 2022 Michael Richters <gedankenexperimenter@gmail.com>
# This is free and unencumbered software released into the public domain.
# Anyone is free to copy, modify, publish, use, compile, sell, or
# distribute this software, either in source code form or as a compiled
# binary, for any purpose, commercial or non-commercial, and by any
# means.
# In jurisdictions that recognize copyright laws, the author or authors
# of this software dedicate any and all copyright interest in the
# software to the public domain. We make this dedication for the benefit
# of the public at large and to the detriment of our heirs and
# successors. We intend this dedication to be an overt act of
# relinquishment in perpetuity of all present and future rights to this
# software under copyright law.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
# For more information, please refer to <http://unlicense.org/>
# ------------------------------------------------------------------------------
"""This script runs clang-format on Kaleidoscope's codebase."""
import argparse
import glob
import logging
import os
import re
import subprocess
import sys
# ==============================================================================
def parse_args(args):
"""Parse command line parameters
Args:
args (List[str]): command line parameters as list of strings
(for example ``["--help"]``).
Returns:
:obj:`argparse.Namespace`: command line parameters namespace
"""
parser = argparse.ArgumentParser(
description="""
Recursively search specified directories and format source files with
clang-format. By default, it operates on Arduino C++ source files with
extensions: *.{cpp,h,hpp,inc,ino}.""")
parser.add_argument(
'-v',
'--verbose',
dest='loglevel',
help="Verbose output",
action='store_const',
const=logging.INFO,
)
parser.add_argument(
'-q',
'--quiet',
dest='loglevel',
help="Suppress all non-error output",
action='store_const',
const=logging.ERROR,
)
parser.add_argument(
'-X',
'--exclude-dir',
metavar="<path>",
dest='exclude_dirs',
help="Exclude dir from search (path relative to the pwd)",
action='append',
default=[],
)
parser.add_argument(
'-x',
'--exclude-file',
metavar="<file>",
dest='exclude_files',
help="Exclude <file> (base name only, not a full path) from formatting",
action='append',
default=[],
)
parser.add_argument(
'-e',
'--regex',
metavar="<regex>",
dest='src_re_str',
help="Regular expression for matching source file names",
default=r'\.(cpp|h|hpp|inc|ino)$',
)
parser.add_argument(
'-f',
'--force',
action='store_true',
help="Format code even if there are unstaged changes",
)
parser.add_argument(
'--check',
action='store_true',
help="Check for changes after formatting",
)
parser.add_argument(
'targets',
metavar="<search_dir>",
nargs='+',
help="""A list of files and/or directories to search for source files to format""",
)
return parser.parse_args(args)
# ==============================================================================
def setup_logging(loglevel):
"""Setup basic logging
Args:
loglevel (int): minimum loglevel for emitting messages
"""
logformat = "%(message)s"
logging.basicConfig(
level=loglevel,
stream=sys.stdout,
format=logformat,
datefmt="",
)
return logging.getLogger()
# ==============================================================================
def format_code(path, opts, clang_format_cmd):
"""Run clang-format on a directory."""
logging.info("Formatting code in %s...", path)
src_regex = re.compile(opts.src_re_str)
src_files = []
for root, dirs, files in os.walk(path):
for exclude_path in opts.exclude_dirs:
exclude_path = exclude_path.rstrip(os.path.sep)
if os.path.dirname(exclude_path) == root:
exclude_dir = os.path.basename(exclude_path)
if exclude_dir in dirs:
dirs.remove(exclude_dir)
for name in files:
if name in opts.exclude_files:
continue
if src_regex.search(name):
src_files.append(os.path.join(root, name))
proc = subprocess.run(clang_format_cmd + src_files)
if proc.returncode != 0:
logging.error("Error: clang-format returned non-zero status: %s", proc.returncode)
return
# ==============================================================================
def build_file_list(path, src_regex):
"""Docstring"""
# If the specified path is a filename, return it (as a list), regardless of
# whether or not it matches the regex.
if os.path.isfile(path):
return [path]
# If the specified path is not valid, just return an empty list.
if not os.path.isdir(path):
return []
# The specified path is a directory, so we search recursively for files
# contained therein that match the specified regular expression.
source_files = []
for root, dirs, files in os.walk(path):
# First, ignore all dotfiles (and directories).
dotfiles = set(glob.glob('.*'))
dirs = set(dirs) - dotfiles
files = set(dirs) - dotfiles
# Check for a list of file glob patterns that should be excluded.
if IWYU_IGNORE_FILE in files:
with open(os.path.join(root, IWYU_IGNORE_FILE)) as f:
for pattern in f.read().splitlines():
matches = set(glob.glob(os.path.join(root, pattern)))
dirs = set(dirs) - matches
files = set(files) - matches
# Add all matching files to the list of source files to be formatted.
for f in filter(src_regex.search, files):
source_files.append(os.path.join(root, f))
return source_files
# ==============================================================================
def warn_if_output(byte_str, msg):
"""Convert a string of bytes to a UTF-8 string, break it on newlines. If
there is any output, print a warning message, followed by each line,
indented by four spaces."""
lines = byte_str.decode('utf-8').splitlines()
if '' in lines:
lines.remove('')
if len(lines) > 0:
logging.warning('%s', msg)
for line in lines:
logging.warning(' %s', line)
return
# ==============================================================================
def main(cli_args):
"""Parse command-line arguments and format source files."""
args = parse_args(cli_args)
if args.loglevel is None:
args.loglevel = logging.WARNING
setup_logging(args.loglevel)
clang_format = os.getenv('CLANG_FORMAT_CMD')
if clang_format is None:
clang_format = 'clang-format'
clang_format_cmd = [clang_format, '-i']
git_diff_cmd = ['git', 'diff', '--exit-code']
proc = subprocess.run(git_diff_cmd + ['--name-only'], capture_output=True)
if proc.returncode != 0:
warn_if_output(proc.stdout, 'Warning: you have unstaged changes to these files:')
if not args.force:
logging.warning(
'Formatting aborted. Stage your changes or use --force to override.')
sys.exit(proc.returncode)
if args.loglevel >= logging.WARNING:
git_diff_cmd.append('--quiet')
elif args.loglevel <= logging.INFO:
git_diff_cmd.append('--name-only')
for path in args.targets:
format_code(path, args, clang_format_cmd)
if args.check:
logging.warning('Checking for changes made by the formatter...')
proc = subprocess.run(git_diff_cmd + ['--cached'], capture_output=True)
if proc.returncode != 0:
logging.warning(
'Warning: Your working tree has staged changes. ' +
'Committed changes might not pass this check.')
warn_if_output(proc.stdout, 'The following files have unstaged changes:')
proc = subprocess.run(git_diff_cmd, capture_output=True)
if proc.returncode != 0:
warn_if_output(proc.stdout, 'The following files have changes:')
logging.error(
'Check failed: Please commit formatting changes before submitting.')
sys.exit(proc.returncode)
return
# ==============================================================================
if __name__ == "__main__":
main(sys.argv[1:])

@ -1,25 +1,12 @@
#!/usr/bin/env bash
# Allow the caller to specify a particular version of clang-format to use:
: "${CLANG_FORMAT_CMD:=clang-format}"
: "${KALEIDOSCOPE_DIR:=$(pwd)}"
cd "${KALEIDOSCOPE_DIR}" || exit 1
# Find all *.cpp and *.h files, except those in `testing/googletest/` and files
# generated by testcase scripts, and run `clang-format` on them:
find ./* -type f \( -name '*.h' -o -name '*.cpp' \) \
-not \( -path './testing/googletest/*' -o -name 'generated-testcase.cpp' \) \
-print0 | \
xargs -0 "${CLANG_FORMAT_CMD}" -i
: "${VERBOSE:=}"
# If we get the `--check` option, return an error if there are any changes to
# the git working tree after running `clang-format`:
if [[ $1 == '--check' ]]; then
if ! git diff --quiet; then
cat >&2 <<EOF
Differences found between git head and working tree. Either 'clang-format' made
formatting changes to your code, or you had uncommitted changes in your working
tree. Please remember to run 'bin/format-code.sh' before committing changes.
EOF
exit 1
fi
fi
"${KALEIDOSCOPE_DIR}/bin/format-code.py" \
--exclude-dir 'testing/googletest' \
--exclude-file 'generated-testcase.cpp' \
--verbose \
src plugins testing

@ -2398,7 +2398,7 @@ New code should not contain calls to deprecated interface points. Use the new in
Coding style and formatting are pretty arbitrary, but a project is much easier to follow if everyone uses the same style. Individuals may not agree with every aspect of the formatting rules, and some of the rules may take some getting used to, but it is important that all project contributors follow the style rules so that they can all read and understand everyone's code easily.
To help you format code correctly, we use "Artistic Style" 3.0. The `make astyle` target is available in the Kaleidoscope and plugin Makefiles. Our CI infrastructure enforces `astyle`'s decisions.
To help format code in compliance with this style guide, we use `clang-format`, which many editors can be configured to call automatically. There is also `make format` target available in the Kaleidoscope Makefile that will use `clang-format` to format all the core and plugin code. Our CI infrastructure checks to ensure that code has been formatted to these specifications.
### Line Length

@ -17,7 +17,7 @@
#include "Kaleidoscope.h"
/* *INDENT-OFF* */
// clang-format off
KEYMAPS(
[0] = KEYMAP_STACKED
(
@ -38,7 +38,7 @@ KEYMAPS(
Key_NoKey
),
)
/* *INDENT-ON* */
// clang-format on
void setup() {
Kaleidoscope.setup();

@ -19,7 +19,7 @@
#include "Kaleidoscope.h"
/* *INDENT-OFF* */
// clang-format off
KEYMAPS(
[0] = KEYMAP_STACKED
(
@ -46,7 +46,7 @@ KEYMAPS(
Key_PageDown, Key_Tab, Key_Enter
),
)
/* *INDENT-ON* */
// clang-format on
void setup() {
Kaleidoscope.setup();

@ -31,7 +31,7 @@ enum {
#define MO(n) ShiftToLayer(n)
/* *INDENT-OFF* */
// clang-format off
KEYMAPS(
/* Qwerty
@ -71,7 +71,7 @@ KEYMAPS(
,___ ,___ ,___ ,___ ,___ ,___ ,___ ,___ ,___ ,___ ,___
)
);
/* *INDENT-ON* */
// clang-format on
KALEIDOSCOPE_INIT_PLUGINS(Macros);

@ -32,7 +32,6 @@
#include "Kaleidoscope-SpaceCadet.h"
#define MO(n) ShiftToLayer(n)
#define TG(n) LockLayer(n)
@ -42,14 +41,14 @@ enum {
};
#define Key_Exclamation LSHIFT(Key_1)
#define Key_At LSHIFT(Key_2)
#define Key_Hash LSHIFT(Key_3)
#define Key_Dollar LSHIFT(Key_4)
#define Key_Percent LSHIFT(Key_5)
#define Key_Caret LSHIFT(Key_6)
#define Key_And LSHIFT(Key_7)
#define Key_Star LSHIFT(Key_8)
#define Key_Plus LSHIFT(Key_Equals)
#define Key_At LSHIFT(Key_2)
#define Key_Hash LSHIFT(Key_3)
#define Key_Dollar LSHIFT(Key_4)
#define Key_Percent LSHIFT(Key_5)
#define Key_Caret LSHIFT(Key_6)
#define Key_And LSHIFT(Key_7)
#define Key_Star LSHIFT(Key_8)
#define Key_Plus LSHIFT(Key_Equals)
enum {
QWERTY,
@ -57,7 +56,7 @@ enum {
UPPER
};
/* *INDENT-OFF* */
// clang-format off
KEYMAPS(
[QWERTY] = KEYMAP_STACKED
(
@ -98,7 +97,7 @@ KEYMAPS(
,___ ,___ ,MoveToLayer(QWERTY) ,Key_PrintScreen ,Key_ScrollLock ,Consumer_PlaySlashPause
)
)
/* *INDENT-ON* */
// clang-format on
KALEIDOSCOPE_INIT_PLUGINS(
EEPROMSettings,
@ -110,8 +109,7 @@ KALEIDOSCOPE_INIT_PLUGINS(
SpaceCadet,
OneShot,
Macros,
MouseKeys
);
MouseKeys);
const macro_t *macroAction(uint8_t macro_id, KeyEvent &event) {
if (keyToggledOn(event.state)) {

@ -50,11 +50,12 @@
#include "Kaleidoscope-USB-Quirks.h"
enum { _QWERTY,
};
enum {
_QWERTY,
};
/* *INDENT-OFF* */
// clang-format off
KEYMAPS(
[_QWERTY] = KEYMAP(
@ -67,8 +68,7 @@ Key_F5, Key_LeftControl,Key_LeftAlt, Key_LeftGui, Key_Backspace, Key_LeftAr
));
/* *INDENT-ON* */
// clang-format on
// These 'solid' color effect definitions define a rainbow of
@ -133,51 +133,57 @@ static void toggleKeyboardProtocol(uint8_t combo_index) {
/** Magic combo list, a list of key combo and action pairs the firmware should
* recognise.
*/
USE_MAGIC_COMBOS({.action = toggleKeyboardProtocol,
// Left Fn + Esc + Shift
.keys = { R3C6, R2C6, R3C7 }
});
USE_MAGIC_COMBOS(
{.action = toggleKeyboardProtocol,
// Left Fn + Esc + Shift
.keys = {R3C6, R2C6, R3C7}});
KALEIDOSCOPE_INIT_PLUGINS(Macros,
KALEIDOSCOPE_INIT_PLUGINS(
Macros,
// LEDControl provides support for other LED modes
LEDControl,
// LEDControl provides support for other LED modes
LEDControl,
// The rainbow effect changes the color of all of the keyboard's keys at the same time
// running through all the colors of the rainbow.
LEDRainbowEffect,
// The rainbow effect changes the color of all of the keyboard's keys at the same time
// running through all the colors of the rainbow.
LEDRainbowEffect,
// The rainbow wave effect lights up your keyboard with all the colors of a rainbow
// and slowly moves the rainbow across your keyboard
LEDRainbowWaveEffect,
// The rainbow wave effect lights up your keyboard with all the colors of a rainbow
// and slowly moves the rainbow across your keyboard
LEDRainbowWaveEffect,
// The chase effect follows the adventure of a blue pixel which chases a red pixel across
// your keyboard. Spoiler: the blue pixel never catches the red pixel
LEDChaseEffect,
// The chase effect follows the adventure of a blue pixel which chases a red pixel across
// your keyboard. Spoiler: the blue pixel never catches the red pixel
LEDChaseEffect,
// These static effects turn your keyboard's LEDs a variety of colors
solidRed, solidOrange, solidYellow, solidGreen, solidBlue, solidIndigo, solidViolet,
// These static effects turn your keyboard's LEDs a variety of colors
solidRed,
solidOrange,
solidYellow,
solidGreen,
solidBlue,
solidIndigo,
solidViolet,
// The breathe effect slowly pulses all of the LEDs on your keyboard
LEDBreatheEffect,
// The breathe effect slowly pulses all of the LEDs on your keyboard
LEDBreatheEffect,
// The HostPowerManagement plugin allows us to turn LEDs off when then host
// goes to sleep, and resume them when it wakes up.
HostPowerManagement,
// The HostPowerManagement plugin allows us to turn LEDs off when then host
// goes to sleep, and resume them when it wakes up.
HostPowerManagement,
// The MagicCombo plugin lets you use key combinations to trigger custom
// actions - a bit like Macros, but triggered by pressing multiple keys at the
// same time.
MagicCombo,
// The MagicCombo plugin lets you use key combinations to trigger custom
// actions - a bit like Macros, but triggered by pressing multiple keys at the
// same time.
MagicCombo,
// The USBQuirks plugin lets you do some things with USB that we aren't
// comfortable - or able - to do automatically, but can be useful
// nevertheless. Such as toggling the key report protocol between Boot (used
// by BIOSes) and Report (NKRO).
USBQuirks
);
// The USBQuirks plugin lets you do some things with USB that we aren't
// comfortable - or able - to do automatically, but can be useful
// nevertheless. Such as toggling the key report protocol between Boot (used
// by BIOSes) and Report (NKRO).
USBQuirks);
void setup() {
Kaleidoscope.setup();

@ -32,7 +32,7 @@
#define NUMPAD_KEYMAP 2
// clang-format off
#define GENERIC_FN2 KEYMAP_STACKED ( \
___, Key_F1, Key_F2, Key_F3, Key_F4, Key_F5, XXX, \
Key_Tab, Key_mouseBtnM, Key_mouseUp, ___, Key_mouseWarpNW, Key_mouseWarpNE, Consumer_ScanNextTrack, \
@ -49,9 +49,6 @@
___\
)
#define NUMPAD KEYMAP (\
___, ___, ___, ___, ___, ___, ___, ___, ___, Key_Keypad7, Key_Keypad8, Key_Keypad9, Key_KeypadSubtract, ___, \
___, ___, ___, ___, ___, ___, ___, ___, ___, Key_Keypad4, Key_Keypad5, Key_Keypad6, Key_KeypadAdd, ___, \
@ -75,7 +72,7 @@ KEYMAPS(
GENERIC_FN2,
NUMPAD
)
// clang-format on
static kaleidoscope::plugin::LEDSolidColor solidRed(60, 0, 0);
static kaleidoscope::plugin::LEDSolidColor solidOrange(60, 20, 0);
@ -89,10 +86,17 @@ const macro_t *macroAction(uint8_t macro_id, KeyEvent &event) {
if (macro_id == 1 && keyToggledOn(event.state)) {
Kaleidoscope.serialPort().print("Keyboard.IO keyboard driver v0.00");
return MACRO(I(25),
D(LeftShift), T(M), U(LeftShift), T(O), T(D), T(E), T(L),
D(LeftShift),
T(M),
U(LeftShift),
T(O),
T(D),
T(E),
T(L),
T(Spacebar),
W(100),
T(0), T(1));
T(0),
T(1));
}
return MACRO_NONE;
}
@ -108,16 +112,24 @@ static void enterHardwareTestMode(uint8_t combo_index) {
/** Magic combo list, a list of key combo and action pairs the firmware should
* recognise.
*/
USE_MAGIC_COMBOS({
.action = enterHardwareTestMode,
// Left Fn + Prog + LED
.keys = { R3C6, R0C0, R0C6 }
});
USE_MAGIC_COMBOS({.action = enterHardwareTestMode,
// Left Fn + Prog + LED
.keys = {R3C6, R0C0, R0C6}});
KALEIDOSCOPE_INIT_PLUGINS(HardwareTestMode,
LEDControl, LEDOff,
solidRed, solidOrange, solidYellow, solidGreen, solidBlue, solidIndigo, solidViolet,
LEDBreatheEffect, LEDRainbowEffect, LEDChaseEffect, NumPad,
LEDControl,
LEDOff,
solidRed,
solidOrange,
solidYellow,
solidGreen,
solidBlue,
solidIndigo,
solidViolet,
LEDBreatheEffect,
LEDRainbowEffect,
LEDChaseEffect,
NumPad,
Macros,
MouseKeys,
MagicCombo);

@ -88,10 +88,10 @@
* a macro key is pressed.
*/
enum { MACRO_VERSION_INFO,
MACRO_ANY
};
enum {
MACRO_VERSION_INFO,
MACRO_ANY,
};
/** The Model 100's key layouts are defined as 'keymaps'. By default, there are three
@ -142,7 +142,11 @@ enum { MACRO_VERSION_INFO,
*
*/
enum { PRIMARY, NUMPAD, FUNCTION }; // layers
enum {
PRIMARY,
NUMPAD,
FUNCTION,
}; // layers
/**
@ -164,11 +168,10 @@ enum { PRIMARY, NUMPAD, FUNCTION }; // layers
// #define PRIMARY_KEYMAP_CUSTOM
/* This comment temporarily turns off astyle's indent enforcement
* so we can make the keymaps actually resemble the physical key layout better
*/
// *INDENT-OFF*
// clang-format off
KEYMAPS(
@ -279,7 +282,7 @@ KEYMAPS(
) // KEYMAPS(
/* Re-enable astyle's indent enforcement */
// *INDENT-ON*
// clang-format on
/** versionInfoMacro handles the 'firmware version info' macro
* When a key bound to the macro is pressed, this macro
@ -336,7 +339,6 @@ const macro_t *macroAction(uint8_t macro_id, KeyEvent &event) {
}
// These 'solid' color effect definitions define a rainbow of
// LED color modes calibrated to draw 500mA or less on the
// Keyboardio Model 100.
@ -412,12 +414,10 @@ static void enterHardwareTestMode(uint8_t combo_index) {
*/
USE_MAGIC_COMBOS({.action = toggleKeyboardProtocol,
// Left Fn + Esc + Shift
.keys = { R3C6, R2C6, R3C7 }
}, {
.action = enterHardwareTestMode,
// Left Fn + Prog + LED
.keys = { R3C6, R0C0, R0C6 }
});
.keys = {R3C6, R2C6, R3C7}},
{.action = enterHardwareTestMode,
// Left Fn + Prog + LED
.keys = {R3C6, R0C0, R0C6}});
// First, tell Kaleidoscope which plugins you want to use.
// The order can be important. For example, LED effects are
@ -468,7 +468,13 @@ KALEIDOSCOPE_INIT_PLUGINS(
LEDChaseEffect,
// These static effects turn your keyboard's LEDs a variety of colors
solidRed, solidOrange, solidYellow, solidGreen, solidBlue, solidIndigo, solidViolet,
solidRed,
solidOrange,
solidYellow,
solidGreen,
solidBlue,
solidIndigo,
solidViolet,
// The breathe effect slowly pulses all of the LEDs on your keyboard
LEDBreatheEffect,
@ -510,8 +516,7 @@ KALEIDOSCOPE_INIT_PLUGINS(
// comfortable - or able - to do automatically, but can be useful
// nevertheless. Such as toggling the key report protocol between Boot (used
// by BIOSes) and Report (NKRO).
USBQuirks
);
USBQuirks);
/** The 'setup' function is one of the two standard Arduino sketch functions.
* It's called when your keyboard first powers up. This is where you set up

@ -20,17 +20,18 @@
#include "Kaleidoscope.h"
#include "Kaleidoscope-Macros.h"
enum { _QWERTY,
_COLEMAK,
_DVORAK,
_LOWER,
_RAISE,
_PLOVER,
_ADJUST
};
/* *INDENT-OFF* */
enum {
_QWERTY,
_COLEMAK,
_DVORAK,
_LOWER,
_RAISE,
_PLOVER,
_ADJUST
};
// clang-format off
KEYMAPS(
/* Qwerty
@ -161,7 +162,7 @@ KEYMAPS(
// ___, ___, ___, ___, ___, ___, ___, ___, ___, ___, ___, ___
//)
);
/* *INDENT-ON* */
// clang-format on
KALEIDOSCOPE_INIT_PLUGINS(Macros);

@ -24,7 +24,7 @@ enum {
_STENO,
};
/* *INDENT-OFF* */
// clang-format off
KEYMAPS(
/* Steno (GeminiPR)
@ -45,7 +45,7 @@ KEYMAPS(
,S(A) ,S(O) ,S(E) ,S(U)
)
);
/* *INDENT-ON* */
// clang-format on
KALEIDOSCOPE_INIT_PLUGINS(GeminiPR);

@ -30,14 +30,14 @@ enum {
};
#define Key_Exclamation LSHIFT(Key_1)
#define Key_At LSHIFT(Key_2)
#define Key_Hash LSHIFT(Key_3)
#define Key_Dollar LSHIFT(Key_4)
#define Key_And LSHIFT(Key_7)
#define Key_Star LSHIFT(Key_8)
#define Key_Plus LSHIFT(Key_Equals)
#define Key_At LSHIFT(Key_2)
#define Key_Hash LSHIFT(Key_3)
#define Key_Dollar LSHIFT(Key_4)
#define Key_And LSHIFT(Key_7)
#define Key_Star LSHIFT(Key_8)
#define Key_Plus LSHIFT(Key_Equals)
/* *INDENT-OFF* */
// clang-format off
KEYMAPS(
[QWERTY] = KEYMAP_STACKED
(
@ -78,7 +78,7 @@ KEYMAPS(
,___ ,___ ,M(QWERTY),Key_PrintScreen ,Key_ScrollLock ,Consumer_PlaySlashPause
)
)
/* *INDENT-ON* */
// clang-format on
KALEIDOSCOPE_INIT_PLUGINS(Macros);

@ -24,14 +24,14 @@ enum {
};
/* *INDENT-OFF* */
// clang-format off
KEYMAPS(
[_DEFAULT] = KEYMAP(
Key_Q, Key_W, Key_E, Key_R, Key_T, Key_Y, Key_U, Key_I, Key_O, Key_P,
Key_A, Key_S, Key_D, Key_F, Key_G, Key_H, Key_J, Key_K, Key_L, Key_Semicolon
)
);
/* *INDENT-ON* */
// clang-format on
void setup() {
Kaleidoscope.setup();

@ -24,13 +24,13 @@ enum {
};
/* *INDENT-OFF* */
// clang-format off
KEYMAPS(
[_DEFAULT] = KEYMAP(
Key_Q, Key_W, Key_E, Key_R, Key_T, Key_Y, Key_U, Key_I
)
);
/* *INDENT-ON* */
// clang-format on
void setup() {
Kaleidoscope.setup();

@ -22,7 +22,7 @@
#include "AppSwitcher.h"
/* *INDENT-OFF* */
// clang-format off
KEYMAPS(
[0] = KEYMAP_STACKED
(
@ -43,7 +43,7 @@ KEYMAPS(
AppSwitcher_Prev
),
)
/* *INDENT-ON* */
// clang-format on
KALEIDOSCOPE_INIT_PLUGINS(HostOS,
AppSwitcher);

@ -18,7 +18,7 @@
#include <Kaleidoscope.h>
#include <Kaleidoscope-CycleTimeReport.h>
// *INDENT-OFF*
// clang-format off
KEYMAPS(
[0] = KEYMAP_STACKED
(
@ -38,7 +38,7 @@ KEYMAPS(
Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl,
Key_skip),
)
// *INDENT-ON*
// clang-format on
KALEIDOSCOPE_INIT_PLUGINS(CycleTimeReport);

@ -21,7 +21,7 @@
#include <Kaleidoscope-DynamicMacros.h>
#include <Kaleidoscope-FocusSerial.h>
// *INDENT-OFF*
// clang-format off
KEYMAPS(
[0] = KEYMAP_STACKED
(Key_NoKey, Key_1, Key_2, Key_3, Key_4, Key_5, Key_NoKey,
@ -40,14 +40,13 @@ KEYMAPS(
Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl,
Key_skip),
)
// *INDENT-ON*
// clang-format on
KALEIDOSCOPE_INIT_PLUGINS(
EEPROMSettings,
EEPROMKeymap,
DynamicMacros,
Focus
);
Focus);
void setup() {
Kaleidoscope.setup();

@ -21,7 +21,7 @@
#include <Kaleidoscope-EEPROM-Keymap-Programmer.h>
#include <Kaleidoscope-Macros.h>
// *INDENT-OFF*
// clang-format off
KEYMAPS(
[0] = KEYMAP_STACKED
(M(0), Key_1, Key_2, Key_3, Key_4, Key_5, Key_NoKey,
@ -40,7 +40,7 @@ KEYMAPS(
Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl,
Key_NoKey),
)
// *INDENT-ON*
// clang-format on
const macro_t *macroAction(uint8_t macro_id, KeyEvent &event) {
if (macro_id == 0 && keyToggledOff(event.state)) {

@ -19,7 +19,7 @@
#include <Kaleidoscope-EEPROM-Keymap.h>
#include <Kaleidoscope-FocusSerial.h>
// *INDENT-OFF*
// clang-format off
KEYMAPS(
[0] = KEYMAP_STACKED
(Key_NoKey, Key_1, Key_2, Key_3, Key_4, Key_5, Key_NoKey,
@ -38,7 +38,7 @@ KEYMAPS(
Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl,
Key_skip),
)
// *INDENT-ON*
// clang-format on
KALEIDOSCOPE_INIT_PLUGINS(EEPROMKeymap, Focus);

@ -18,7 +18,7 @@
#include <Kaleidoscope.h>
#include <Kaleidoscope-EEPROM-Settings.h>
// *INDENT-OFF*
// clang-format off
KEYMAPS(
[0] = KEYMAP_STACKED
(Key_NoKey, Key_1, Key_2, Key_3, Key_4, Key_5, Key_NoKey,
@ -37,7 +37,7 @@ KEYMAPS(
Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl,
Key_skip),
)
// *INDENT-ON*
// clang-format on
KALEIDOSCOPE_INIT_PLUGINS(EEPROMSettings);

@ -18,7 +18,7 @@
#include <Kaleidoscope.h>
#include <Kaleidoscope-FocusSerial.h>
// *INDENT-OFF*
// clang-format off
KEYMAPS(
[0] = KEYMAP_STACKED
(Key_NoKey, Key_1, Key_2, Key_3, Key_4, Key_5, Key_NoKey,
@ -37,7 +37,7 @@ KEYMAPS(
Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl,
Key_skip),
)
// *INDENT-OFF*
// clang-format on
namespace kaleidoscope {
class FocusTestCommand : public Plugin {
@ -70,7 +70,7 @@ class FocusHelpCommand : public Plugin {
}
};
}
} // namespace kaleidoscope
kaleidoscope::FocusTestCommand FocusTestCommand;
kaleidoscope::FocusHelpCommand FocusHelpCommand;

@ -27,7 +27,7 @@
// will type out the letters from A to N, but the right palm key can be used to
// toggle the custom EventDropper plugin to suppress USB output.
// *INDENT-OFF*
// clang-format off
KEYMAPS(
[0] = KEYMAP_STACKED
(___, ___, ___, ___, ___, ___, ___,
@ -46,7 +46,7 @@ KEYMAPS(
___, ___, ___, ___,
M(1)),
)
// *INDENT-ON*
// clang-format on
namespace kaleidoscope {
namespace plugin {
@ -61,12 +61,13 @@ class EventDropper : public Plugin {
void toggle() {
active_ = !active_;
}
private:
bool active_ = false;
};
} // namespace plugin
} // namespace kaleidoscope
} // namespace plugin
} // namespace kaleidoscope
kaleidoscope::plugin::EventDropper EventDropper;
@ -95,8 +96,7 @@ static const kaleidoscope::plugin::GhostInTheFirmware::GhostKey ghost_keys[] PRO
{KeyAddr(3, 14), 200, 50},
{KeyAddr(3, 15), 200, 50},
{KeyAddr::none(), 0, 0}
};
{KeyAddr::none(), 0, 0}};
KALEIDOSCOPE_INIT_PLUGINS(GhostInTheFirmware,
LEDControl,
@ -107,7 +107,7 @@ KALEIDOSCOPE_INIT_PLUGINS(GhostInTheFirmware,
void setup() {
Kaleidoscope.setup();
StalkerEffect.variant = STALKER(BlazingTrail);
StalkerEffect.variant = STALKER(BlazingTrail);
GhostInTheFirmware.ghost_keys = ghost_keys;
}

@ -19,7 +19,7 @@
#include <Kaleidoscope-EEPROM-Settings.h>
#include <Kaleidoscope-HostOS.h>
// *INDENT-OFF*
// clang-format off
KEYMAPS(
[0] = KEYMAP_STACKED
(Key_NoKey, Key_1, Key_2, Key_3, Key_4, Key_5, Key_NoKey,
@ -38,7 +38,7 @@ KEYMAPS(
Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl,
Key_skip),
)
// *INDENT-ON*
// clang-format on
KALEIDOSCOPE_INIT_PLUGINS(EEPROMSettings, HostOS);

@ -20,7 +20,7 @@
#include <Kaleidoscope-LEDControl.h>
#include <Kaleidoscope-HostPowerManagement.h>
// *INDENT-OFF*
// clang-format off
KEYMAPS(
[0] = KEYMAP_STACKED
(
@ -41,7 +41,7 @@ KEYMAPS(
Key_NoKey
),
)
// *INDENT-ON*
// clang-format on
void hostPowerManagementEventHandler(kaleidoscope::plugin::HostPowerManagement::Event event) {
switch (event) {

@ -19,9 +19,13 @@
#include <Kaleidoscope-FocusSerial.h>
#include <Kaleidoscope-MouseKeys.h>
enum { PRIMARY, NUMPAD, FUNCTION }; // layers
enum {
PRIMARY,
NUMPAD,
FUNCTION,
}; // layers
// *INDENT-OFF*
// clang-format off
KEYMAPS(
[PRIMARY] = KEYMAP_STACKED
(___, Key_1, Key_2, Key_3, Key_4, Key_5, XXX,
@ -68,10 +72,10 @@ KEYMAPS(
___, ___, Key_Enter, ___,
___)
)
// *INDENT-OFF*
// clang-format on
namespace kaleidoscope {
class LayerDumper: public Plugin {
class LayerDumper : public Plugin {
public:
LayerDumper() {}
@ -89,7 +93,7 @@ class LayerDumper: public Plugin {
}
};
}
} // namespace kaleidoscope
kaleidoscope::LayerDumper LayerDumper;

@ -18,7 +18,7 @@
#include "Kaleidoscope.h"
#include "Kaleidoscope-Macros.h"
/* *INDENT-OFF* */
// clang-format off
KEYMAPS(
[0] = KEYMAP_STACKED
(
@ -39,7 +39,7 @@ KEYMAPS(
M(0)
),
)
/* *INDENT-ON* */
// clang-format on
namespace kaleidoscope {
namespace plugin {
@ -64,11 +64,10 @@ class ShiftBlocker : public Plugin {
private:
bool active_{false};
};
} // namespace plugin
} // namespace kaleidoscope
} // namespace plugin
} // namespace kaleidoscope
kaleidoscope::plugin::ShiftBlocker ShiftBlocker;

@ -20,7 +20,7 @@
#include <Kaleidoscope.h>
#include <Kaleidoscope-Steno.h>
// *INDENT-OFF*
// clang-format off
KEYMAPS(
[0] = KEYMAP_STACKED
(Key_NoKey, Key_1, Key_2, Key_3, Key_4, Key_5, Key_NoKey,
@ -56,7 +56,7 @@ KEYMAPS(
S(E), S(U), XXX, S(RE2),
___),
)
// *INDENT-ON*
// clang-format on
KALEIDOSCOPE_INIT_PLUGINS(GeminiPR);

@ -19,7 +19,7 @@
#include <Kaleidoscope-EEPROM-Settings.h>
#include <Kaleidoscope-TypingBreaks.h>
// *INDENT-OFF*
// clang-format off
KEYMAPS(
[0] = KEYMAP_STACKED
(
@ -39,7 +39,7 @@ KEYMAPS(
Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl,
Key_skip),
)
// *INDENT-ON*
// clang-format on
KALEIDOSCOPE_INIT_PLUGINS(EEPROMSettings, TypingBreaks);

@ -21,7 +21,7 @@
// This example demonstrates how a plugin can gather information about
// the keymap at compile time, e.g. to adapt its behavior, safe resources, ...
/* *INDENT-OFF* */
// clang-format off
KEYMAPS(
[0] = KEYMAP_STACKED
(
@ -42,9 +42,9 @@ KEYMAPS(
Key_NoKey
),
)
/* *INDENT-ON* */
// clang-format on
using namespace kaleidoscope::sketch_exploration; // NOLINT(build/namespaces)
using namespace kaleidoscope::sketch_exploration; // NOLINT(build/namespaces)
class BPlugin : public kaleidoscope::Plugin {};
class CPlugin : public kaleidoscope::Plugin {};
@ -54,7 +54,8 @@ class CPlugin : public kaleidoscope::Plugin {};
class APlugin : public kaleidoscope::Plugin {
public:
APlugin() : has_key_1_{false} {}
APlugin()
: has_key_1_{false} {}
template<typename _Sketch>
kaleidoscope::EventHandlerResult exploreSketch() {
@ -72,7 +73,7 @@ class APlugin : public kaleidoscope::Plugin {
constexpr bool has_key_1 = K::collect(HasKey{Key_1});
static_assert(has_key_1, "Error querying key existence");
has_key_1_ = has_key_1; // Assign the temporary that was computed
has_key_1_ = has_key_1; // Assign the temporary that was computed
// at compile time.
constexpr Key max_key = K::collect(MaxKeyRaw{});
@ -81,7 +82,7 @@ class APlugin : public kaleidoscope::Plugin {
static_assert(K::getKey(0 /*layer*/, KeyAddr{2, 3}) == Key_D,
"Key lookup failed");
constexpr auto n_layers = K::nLayers();
constexpr auto n_layers = K::nLayers();
constexpr auto layer_size = K::layerSize();
// Plugin exploration
@ -117,7 +118,6 @@ class APlugin : public kaleidoscope::Plugin {
}
private:
bool has_key_1_;
};
@ -127,8 +127,7 @@ BPlugin b_plugin;
KALEIDOSCOPE_INIT_PLUGINS(
a_plugin1,
b_plugin,
a_plugin2
)
a_plugin2)
void setup() {
Kaleidoscope.setup();

@ -12,7 +12,7 @@ enum {
TOGGLE_AUTOSHIFT,
};
// *INDENT-OFF*
// clang-format off
KEYMAPS(
[0] = KEYMAP_STACKED
(
@ -33,7 +33,7 @@ KEYMAPS(
XXX
),
)
// *INDENT-ON*
// clang-format on
// Defining a macro (on the "any" key: see above) to turn AutoShift on and off
const macro_t *macroAction(uint8_t macro_id, KeyEvent &event) {
@ -56,8 +56,8 @@ KALEIDOSCOPE_INIT_PLUGINS(
FocusEEPROMCommand, // for AutoShiftConfig
FocusSettingsCommand, // for AutoShiftConfig
AutoShift,
AutoShiftConfig, // for AutoShiftConfig
Macros // for toggle AutoShift Macro
AutoShiftConfig, // for AutoShiftConfig
Macros // for toggle AutoShift Macro
);
void setup() {

@ -4,7 +4,7 @@
#include <Kaleidoscope-CharShift.h>
// *INDENT-OFF*
// clang-format off
KEYMAPS(
[0] = KEYMAP_STACKED
(
@ -25,15 +25,15 @@ KEYMAPS(
XXX
),
)
// *INDENT-ON*
// clang-format on
KALEIDOSCOPE_INIT_PLUGINS(CharShift);
void setup() {
CS_KEYS(
kaleidoscope::plugin::CharShift::KeyPair(Key_Comma, Key_Semicolon), // CS(0)
kaleidoscope::plugin::CharShift::KeyPair(Key_Period, LSHIFT(Key_Semicolon)), // CS(1)
kaleidoscope::plugin::CharShift::KeyPair(LSHIFT(Key_Comma), LSHIFT(Key_Period)), // CS(2)
kaleidoscope::plugin::CharShift::KeyPair(Key_Comma, Key_Semicolon), // CS(0)
kaleidoscope::plugin::CharShift::KeyPair(Key_Period, LSHIFT(Key_Semicolon)), // CS(1)
kaleidoscope::plugin::CharShift::KeyPair(LSHIFT(Key_Comma), LSHIFT(Key_Period)), // CS(2)
);
Kaleidoscope.setup();
}

@ -18,7 +18,7 @@
#include <Kaleidoscope.h>
#include <Kaleidoscope-Cycle.h>
// *INDENT-OFF*
// clang-format off
KEYMAPS(
[0] = KEYMAP_STACKED
(Key_NoKey, Key_1, Key_2, Key_3, Key_4, Key_5, Key_NoKey,
@ -37,7 +37,7 @@ KEYMAPS(
Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl,
Key_Cycle),
)
// *INDENT-ON*
// clang-format on
void cycleAction(Key previous_key, uint8_t cycle_count) {
if (previous_key == Key_E) {

@ -22,7 +22,7 @@
#include <Kaleidoscope-TapDance.h>
#include <Kaleidoscope-DynamicTapDance.h>
// *INDENT-OFF*
// clang-format off
KEYMAPS(
[0] = KEYMAP_STACKED
(
@ -42,7 +42,7 @@ KEYMAPS(
Key_RightShift, Key_RightAlt, Key_Spacebar, TD(2),
TD(1)),
)
// *INDENT-ON*
// clang-format on
enum {
TD_TAB_ESC,

@ -21,7 +21,7 @@
#include <Kaleidoscope-Escape-OneShot.h>
#include <Kaleidoscope-FocusSerial.h>
// *INDENT-OFF*
// clang-format off
KEYMAPS(
[0] = KEYMAP_STACKED
(
@ -61,7 +61,7 @@ KEYMAPS(
___
),
)
// *INDENT-ON*
// clang-format on
KALEIDOSCOPE_INIT_PLUGINS(EEPROMSettings,
Focus,

@ -18,7 +18,7 @@
#include <Kaleidoscope.h>
#include <Kaleidoscope-Leader.h>
// *INDENT-OFF*
// clang-format off
KEYMAPS(
[0] = KEYMAP_STACKED
(Key_NoKey, Key_1, Key_2, Key_3, Key_4, Key_5, Key_NoKey,
@ -37,7 +37,7 @@ KEYMAPS(
Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl,
LEAD(0)),
)
// *INDENT-ON*
// clang-format on
auto &serial_port = Kaleidoscope.serialPort();
@ -50,8 +50,8 @@ static void leaderTestAA(uint8_t seq_index) {
}
static const kaleidoscope::plugin::Leader::dictionary_t leader_dictionary[] PROGMEM =
LEADER_DICT({LEADER_SEQ(LEAD(0), Key_A), leaderTestA},
{LEADER_SEQ(LEAD(0), Key_A, Key_A), leaderTestAA});
LEADER_DICT({LEADER_SEQ(LEAD(0), Key_A), leaderTestA},
{LEADER_SEQ(LEAD(0), Key_A, Key_A), leaderTestAA});
KALEIDOSCOPE_INIT_PLUGINS(Leader);

@ -24,7 +24,7 @@
#include "kaleidoscope/LiveKeys.h"
#include "kaleidoscope/plugin.h"
// *INDENT-OFF*
// clang-format off
KEYMAPS(
[0] = KEYMAP_STACKED
(Key_NoKey, Key_1, Key_2, Key_3, Key_4, Key_5, Key_NoKey,
@ -43,7 +43,7 @@ KEYMAPS(
Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl,
LEAD(0)),
)
// *INDENT-ON*
// clang-format on
namespace kaleidoscope {
namespace plugin {
@ -74,7 +74,7 @@ class LeaderPrefix : public Plugin {
if (keyToggledOn(event.state) && isLeaderKey(event.key)) {
// A Leader key toggled on, so we set our state to "active", and set the
// arg value to zero.
active_ = true;
active_ = true;
leader_arg_ = 0;
}
// Whether or not the plugin just became active, there's nothing more to
@ -122,8 +122,16 @@ class LeaderPrefix : public Plugin {
private:
// The "digit keys": these are the keys on the number row of the Model01.
KeyAddr digit_addrs_[10] = {
KeyAddr(0, 14), KeyAddr(0, 1), KeyAddr(0, 2), KeyAddr(0, 3), KeyAddr(0, 4),
KeyAddr(0, 5), KeyAddr(0, 10), KeyAddr(0, 11), KeyAddr(0, 12), KeyAddr(0, 13),
KeyAddr(0, 14),
KeyAddr(0, 1),
KeyAddr(0, 2),
KeyAddr(0, 3),
KeyAddr(0, 4),
KeyAddr(0, 5),
KeyAddr(0, 10),
KeyAddr(0, 11),
KeyAddr(0, 12),
KeyAddr(0, 13),
};
// This event tracker is necessary to prevent re-processing events. Any
@ -144,8 +152,8 @@ class LeaderPrefix : public Plugin {
}
};
} // namespace plugin
} // namespace kaleidoscope
} // namespace plugin
} // namespace kaleidoscope
// This creates our plugin object.
kaleidoscope::plugin::LeaderPrefix LeaderPrefix;
@ -172,9 +180,9 @@ void leaderTestPrefix(uint8_t seq_index) {
}
static const kaleidoscope::plugin::Leader::dictionary_t leader_dictionary[] PROGMEM =
LEADER_DICT({LEADER_SEQ(LEAD(0), Key_X), leaderTestX},
{LEADER_SEQ(LEAD(0), Key_X, Key_X), leaderTestXX},
{LEADER_SEQ(LEAD(0), Key_Z), leaderTestPrefix});
LEADER_DICT({LEADER_SEQ(LEAD(0), Key_X), leaderTestX},
{LEADER_SEQ(LEAD(0), Key_X, Key_X), leaderTestXX},
{LEADER_SEQ(LEAD(0), Key_Z), leaderTestPrefix});
// The order matters here; LeaderPrefix won't work unless it precedes Leader in
// this list. If there are other plugins in the list, these two should ideally

@ -24,7 +24,7 @@ enum {
TOGGLE_ONESHOT,
};
// *INDENT-OFF*
// clang-format off
KEYMAPS(
[0] = KEYMAP_STACKED
(___, M(1), M(2), M(3), M(4), M(5), ___,
@ -61,7 +61,7 @@ KEYMAPS(
___, ___, ___, ___,
___),
)
// *INDENT-ON*
// clang-format on
// Example macro for typing a string of characters.
void macroTypeString(KeyEvent &event) {
@ -71,7 +71,7 @@ void macroTypeString(KeyEvent &event) {
}
// Example macro for macro step sequence.
const macro_t* macroSteps(KeyEvent &event) {
const macro_t *macroSteps(KeyEvent &event) {
if (keyToggledOn(event.state)) {
// Note that the following sequence leaves two keys down (`Key_RightAlt` and
// `Key_C`). These virtual keys will remain in effect until the Macros key
@ -82,7 +82,7 @@ const macro_t* macroSteps(KeyEvent &event) {
}
// Example macro that sets `event.key`.
const macro_t* macroNewSentence1(KeyEvent &event) {
const macro_t *macroNewSentence1(KeyEvent &event) {
if (keyToggledOn(event.state)) {
event.key = OSM(LeftShift);
return MACRO(Tc(Period), Tc(Spacebar), Tc(Spacebar));
@ -114,7 +114,7 @@ void macroNewSentence3(KeyEvent &event) {
// Macro that auto-repeats?
const macro_t* macroAction(uint8_t macro_id, KeyEvent &event) {
const macro_t *macroAction(uint8_t macro_id, KeyEvent &event) {
switch (macro_id) {
case 0:

@ -29,7 +29,7 @@ void kindOfMagic(uint8_t combo_index) {
USE_MAGIC_COMBOS([KIND_OF_MAGIC] = {.action = kindOfMagic, .keys = {R3C6, R3C9}});
// *INDENT-OFF*
// clang-format off
KEYMAPS(
[0] = KEYMAP_STACKED
(
@ -49,7 +49,7 @@ KEYMAPS(
Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl,
Key_NoKey),
)
// *INDENT-ON*
// clang-format on
KALEIDOSCOPE_INIT_PLUGINS(MagicCombo, Macros);

@ -24,7 +24,7 @@ enum {
TOGGLE_ONESHOT,
};
// *INDENT-OFF*
// clang-format off
KEYMAPS(
[0] = KEYMAP_STACKED
(
@ -62,7 +62,7 @@ KEYMAPS(
___, ___, ___, ___,
___),
)
// *INDENT-ON*
// clang-format on
void macroToggleOneShot() {
OneShot.toggleAutoOneShot();

@ -25,7 +25,7 @@ enum {
TOGGLE_ONESHOT,
};
// *INDENT-OFF*
// clang-format off
KEYMAPS(
[0] = KEYMAP_STACKED
(
@ -63,7 +63,7 @@ KEYMAPS(
___, ___, ___, ___,
___),
)
// *INDENT-ON*
// clang-format on
void macroToggleOneShot() {
OneShot.toggleAutoOneShot();

@ -11,7 +11,7 @@ enum { MACRO_TOGGLE_QUKEYS };
// for the home row on the right side of the keymap (and one of the palm keys)
// below.
// *INDENT-OFF*
// clang-format off
KEYMAPS(
[0] = KEYMAP_STACKED
(
@ -51,7 +51,7 @@ KEYMAPS(
___
),
)
// *INDENT-ON*
// clang-format on
// Defining a macro (on the "any" key: see above) to toggle Qukeys on and off
const macro_t *macroAction(uint8_t macro_id, KeyEvent &event) {

@ -25,7 +25,7 @@ bool kaleidoscope::plugin::Redial::shouldRemember(Key mapped_key) {
return false;
}
// *INDENT-OFF*
// clang-format off
KEYMAPS(
[0] = KEYMAP_STACKED
(
@ -45,7 +45,7 @@ KEYMAPS(
Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl,
Key_Redial),
)
// *INDENT-ON*
// clang-format on
KALEIDOSCOPE_INIT_PLUGINS(Redial);

@ -18,7 +18,7 @@
#include <Kaleidoscope.h>
#include <Kaleidoscope-ShapeShifter.h>
// *INDENT-OFF*
// clang-format off
KEYMAPS(
[0] = KEYMAP_STACKED
(
@ -38,7 +38,7 @@ KEYMAPS(
Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl,
Key_NoKey),
)
// *INDENT-ON*
// clang-format on
static const kaleidoscope::plugin::ShapeShifter::dictionary_t shape_shift_dictionary[] PROGMEM = {
{Key_1, Key_2},

@ -18,7 +18,7 @@
#include <Kaleidoscope.h>
#include <Kaleidoscope-SpaceCadet.h>
// *INDENT-OFF*
// clang-format off
KEYMAPS(
[0] = KEYMAP_STACKED
(
@ -38,7 +38,7 @@ KEYMAPS(
Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl,
Key_skip),
)
// *INDENT-ON*
// clang-format on
KALEIDOSCOPE_INIT_PLUGINS(SpaceCadet);
@ -49,14 +49,14 @@ void setup() {
//Setting is {KeyThatWasPressed, AlternativeKeyToSend, TimeoutInMS}
//Note: must end with the SPACECADET_MAP_END delimiter
static kaleidoscope::plugin::SpaceCadet::KeyBinding spacecadetmap[] = {
{Key_LeftShift, Key_LeftParen, 250}
, {Key_RightShift, Key_RightParen, 250}
, {Key_LeftGui, Key_LeftCurlyBracket, 250}
, {Key_RightAlt, Key_RightCurlyBracket, 250}
, {Key_LeftAlt, Key_RightCurlyBracket, 250}
, {Key_LeftControl, Key_LeftBracket, 250}
, {Key_RightControl, Key_RightBracket, 250}
, SPACECADET_MAP_END
{Key_LeftShift, Key_LeftParen, 250},
{Key_RightShift, Key_RightParen, 250},
{Key_LeftGui, Key_LeftCurlyBracket, 250},
{Key_RightAlt, Key_RightCurlyBracket, 250},
{Key_LeftAlt, Key_RightCurlyBracket, 250},
{Key_LeftControl, Key_LeftBracket, 250},
{Key_RightControl, Key_RightBracket, 250},
SPACECADET_MAP_END,
};
//Set the map.
SpaceCadet.map = spacecadetmap;

@ -21,7 +21,7 @@
#include <Kaleidoscope-Syster.h>
#include <Kaleidoscope-Unicode.h>
// *INDENT-OFF*
// clang-format off
KEYMAPS(
[0] = KEYMAP_STACKED
(
@ -41,7 +41,7 @@ KEYMAPS(
Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl,
SYSTER),
)
// *INDENT-ON*
// clang-format on
void systerAction(kaleidoscope::plugin::Syster::action_t action, const char *symbol) {
switch (action) {

@ -18,7 +18,7 @@
#include <Kaleidoscope.h>
#include <Kaleidoscope-TapDance.h>
// *INDENT-OFF*
// clang-format off
KEYMAPS(
[0] = KEYMAP_STACKED
(
@ -38,7 +38,7 @@ KEYMAPS(
Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl,
TD(1)),
)
// *INDENT-ON*
// clang-format on
static void tapDanceEsc(uint8_t tap_dance_index, uint8_t tap_count, kaleidoscope::plugin::TapDance::ActionType tap_dance_action) {
tapDanceActionKeys(tap_count, tap_dance_action, Key_Escape, Key_Tab);

@ -18,7 +18,7 @@
#include <Kaleidoscope.h>
#include <Kaleidoscope-TopsyTurvy.h>
// *INDENT-OFF*
// clang-format off
KEYMAPS(
[0] = KEYMAP_STACKED
(
@ -38,7 +38,7 @@ KEYMAPS(
Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl,
Key_skip),
)
// *INDENT-ON*
// clang-format on
KALEIDOSCOPE_INIT_PLUGINS(TopsyTurvy);

@ -19,7 +19,7 @@
#include <Kaleidoscope-LEDControl.h>
#include <Kaleidoscope-Turbo.h>
// *INDENT-OFF*
// clang-format off
KEYMAPS(
[0] = KEYMAP_STACKED
(Key_NoKey, Key_1, Key_2, Key_3, Key_4, Key_5, Key_NoKey,
@ -38,7 +38,7 @@ KEYMAPS(
Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl,
Key_skip),
)
// *INDENT-ON*
// clang-format on
KALEIDOSCOPE_INIT_PLUGINS(LEDControl, Turbo);

@ -23,7 +23,7 @@
enum { MACRO_KEYBOARD_EMOJI };
// *INDENT-OFF*
// clang-format off
KEYMAPS(
[0] = KEYMAP_STACKED
@ -44,7 +44,7 @@ KEYMAPS(
Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl,
Key_skip),
)
// *INDENT-ON*
// clang-format on
static void unicode(uint32_t character, uint8_t keyState) {
if (keyToggledOn(keyState)) {

@ -28,11 +28,10 @@ void toggleWinKey(uint8_t index) {
}
USE_MAGIC_COMBOS([WINKEYTOGGLE] = {
.action = toggleWinKey,
.keys = {R3C6, R3C9}
});
.action = toggleWinKey,
.keys = {R3C6, R3C9}});
// *INDENT-OFF*
// clang-format off
KEYMAPS(
[0] = KEYMAP_STACKED
(
@ -52,7 +51,7 @@ KEYMAPS(
Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl,
Key_NoKey),
)
// *INDENT-ON*
// clang-format on
KALEIDOSCOPE_INIT_PLUGINS(MagicCombo, WinKeyToggle);

@ -22,7 +22,7 @@
#include <Kaleidoscope-LED-Palette-Theme.h>
#include <Kaleidoscope-LEDControl.h>
// *INDENT-OFF*
// clang-format off
KEYMAPS(
[0] = KEYMAP_STACKED
(Key_LEDEffectNext, Key_1, Key_2, Key_3, Key_4, Key_5, Key_LEDEffectNext,
@ -42,7 +42,7 @@ KEYMAPS(
Key_NoKey),
)
// *INDENT-ON*
// clang-format on
KALEIDOSCOPE_INIT_PLUGINS(EEPROMSettings,
LEDPaletteTheme,

@ -22,7 +22,7 @@
#include <Kaleidoscope-FingerPainter.h>
#include <Kaleidoscope-FocusSerial.h>
// *INDENT-OFF*
// clang-format off
KEYMAPS(
[0] = KEYMAP_STACKED
(Key_NoKey, Key_1, Key_2, Key_3, Key_4, Key_5, Key_LEDEffectNext,
@ -41,7 +41,7 @@ KEYMAPS(
Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl,
Key_skip),
)
// *INDENT-ON*
// clang-format on
KALEIDOSCOPE_INIT_PLUGINS(LEDControl,
LEDOff,

@ -20,7 +20,7 @@
#include <Kaleidoscope-LEDControl.h>
#include <Kaleidoscope-Heatmap.h>
// *INDENT-OFF*
// clang-format off
KEYMAPS(
[0] = KEYMAP_STACKED
(Key_LEDEffectNext, Key_1, Key_2, Key_3, Key_4, Key_5, Key_LEDEffectNext,
@ -39,7 +39,7 @@ KEYMAPS(
Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl,
Key_NoKey),
)
// *INDENT-ON*
// clang-format on
KALEIDOSCOPE_INIT_PLUGINS(LEDControl,
HeatmapEffect);

@ -22,7 +22,7 @@
#include <Kaleidoscope-FocusSerial.h>
#include <Kaleidoscope-IdleLEDs.h>
// *INDENT-OFF*
// clang-format off
KEYMAPS(
[0] = KEYMAP_STACKED
(
@ -42,7 +42,7 @@ KEYMAPS(
Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl,
Key_NoKey),
)
// *INDENT-ON*
// clang-format on
KALEIDOSCOPE_INIT_PLUGINS(LEDControl,
EEPROMSettings,
@ -56,7 +56,7 @@ void setup() {
Kaleidoscope.setup();
PersistentIdleLEDs.setIdleTimeoutSeconds(300); // 5 minutes
PersistentIdleLEDs.setIdleTimeoutSeconds(300); // 5 minutes
LEDRainbowWaveEffect.activate();
}

@ -19,7 +19,7 @@
#include <Kaleidoscope-LEDControl.h>
#include <Kaleidoscope-LED-ActiveLayerColor.h>
// *INDENT-OFF*
// clang-format off
KEYMAPS(
[0] = KEYMAP_STACKED
(
@ -58,7 +58,7 @@ KEYMAPS(
ShiftToLayer(0)
)
)
// *INDENT-ON*
// clang-format on
KALEIDOSCOPE_INIT_PLUGINS(LEDControl,
LEDActiveLayerColorEffect);
@ -66,8 +66,7 @@ KALEIDOSCOPE_INIT_PLUGINS(LEDControl,
void setup() {
static const cRGB layerColormap[] PROGMEM = {
CRGB(128, 0, 0),
CRGB(0, 128, 0)
};
CRGB(0, 128, 0)};
Kaleidoscope.setup();
LEDActiveLayerColorEffect.setColormap(layerColormap);

@ -20,7 +20,7 @@
#include <Kaleidoscope-LED-ActiveModColor.h>
#include <Kaleidoscope-OneShot.h>
// *INDENT-OFF*
// clang-format off
KEYMAPS(
[0] = KEYMAP_STACKED
(
@ -40,7 +40,7 @@ KEYMAPS(
OSM(RightShift), OSM(RightAlt), Key_Spacebar, OSM(RightControl),
Key_skip),
)
// *INDENT-ON*
// clang-format on
// OneShot is included to illustrate the different colors highlighting sticky
// and one-shot keys. LEDOff is included because we need an LED mode active to

@ -20,7 +20,7 @@
#include <Kaleidoscope-LED-AlphaSquare.h>
#include <Kaleidoscope-Macros.h>
// *INDENT-OFF*
// clang-format off
KEYMAPS(
[0] = KEYMAP_STACKED
(
@ -40,7 +40,7 @@ KEYMAPS(
Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl,
Key_skip),
)
// *INDENT-ON*
// clang-format on
const macro_t *macroAction(uint8_t macro_id, KeyEvent &event) {
if (!keyToggledOn(event.state))
@ -57,12 +57,12 @@ const macro_t *macroAction(uint8_t macro_id, KeyEvent &event) {
col = 10;
for (uint8_t step = 0; step <= 0xf0; step += 8) {
AlphaSquare.color = { step, step, step };
AlphaSquare.color = {step, step, step};
AlphaSquare.display({i, 0}, col);
delay(10);
}
for (uint8_t step = 0xff; step >= 8; step -= 8) {
AlphaSquare.color = { step, step, step };
AlphaSquare.color = {step, step, step};
AlphaSquare.display({i, 0}, col);
delay(10);
}
@ -74,14 +74,14 @@ const macro_t *macroAction(uint8_t macro_id, KeyEvent &event) {
delay(100);
for (uint8_t step = 0; step <= 0xf0; step += 8) {
AlphaSquare.color = { step, step, step };
AlphaSquare.color = {step, step, step};
AlphaSquare.display(kaleidoscope::plugin::alpha_square::symbols::Lambda, 2);
AlphaSquare.display(kaleidoscope::plugin::alpha_square::symbols::Lambda, 10);
delay(10);
}
for (uint8_t step = 0xff; step >= 8; step -= 8) {
AlphaSquare.color = { step, step, step };
AlphaSquare.color = {step, step, step};
AlphaSquare.display(kaleidoscope::plugin::alpha_square::symbols::Lambda, 2);
AlphaSquare.display(kaleidoscope::plugin::alpha_square::symbols::Lambda, 10);
delay(10);
@ -102,7 +102,7 @@ KALEIDOSCOPE_INIT_PLUGINS(LEDControl,
void setup() {
Kaleidoscope.setup();
AlphaSquare.color = { 0xcb, 0xc0, 0xff };
AlphaSquare.color = {0xcb, 0xc0, 0xff};
}
void loop() {

@ -20,7 +20,7 @@
#include <Kaleidoscope-LEDEffect-Rainbow.h>
#include <Kaleidoscope-Macros.h>
// *INDENT-OFF*
// clang-format off
KEYMAPS(
[0] = KEYMAP_STACKED
(
@ -40,7 +40,7 @@ KEYMAPS(
Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl,
M(1)),
)
// *INDENT-ON*
// clang-format on
KALEIDOSCOPE_INIT_PLUGINS(LEDControl,
Macros,

@ -39,13 +39,11 @@ class TestLEDMode : public kaleidoscope::plugin::LEDMode {
uint16_t TestLEDMode::map_base_;
void
TestLEDMode::setup() {
void TestLEDMode::setup() {
map_base_ = LEDPaletteTheme.reserveThemes(1);
}
void
TestLEDMode::update(void) {
void TestLEDMode::update(void) {
LEDPaletteTheme.updateHandler(map_base_, 0);
}
@ -54,11 +52,11 @@ TestLEDMode::onFocusEvent(const char *command) {
return LEDPaletteTheme.themeFocusEvent(command, PSTR("testLedMode.map"), map_base_, 1);
}
}
} // namespace example
example::TestLEDMode TestLEDMode;
// *INDENT-OFF*
// clang-format off
KEYMAPS(
[0] = KEYMAP_STACKED
(
@ -78,7 +76,7 @@ KEYMAPS(
Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl,
Key_NoKey),
)
// *INDENT-ON*
// clang-format on
KALEIDOSCOPE_INIT_PLUGINS(Focus, LEDPaletteTheme, TestLEDMode, EEPROMSettings);

@ -19,7 +19,7 @@
#include <Kaleidoscope-LEDControl.h>
#include <Kaleidoscope-LED-Stalker.h>
// *INDENT-OFF*
// clang-format off
KEYMAPS(
[0] = KEYMAP_STACKED
(
@ -39,7 +39,7 @@ KEYMAPS(
Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl,
Key_NoKey),
)
// *INDENT-ON*
// clang-format on
KALEIDOSCOPE_INIT_PLUGINS(LEDControl,
LEDOff,

@ -20,6 +20,7 @@
#include <Kaleidoscope-LEDControl.h>
#include <Kaleidoscope-LED-Wavepool.h>
// clang-format off
KEYMAPS(
[0] = KEYMAP_STACKED
(
@ -46,12 +47,13 @@ KALEIDOSCOPE_INIT_PLUGINS(
LEDOff,
WavepoolEffect
);
// clang-format on
void setup() {
Kaleidoscope.setup();
WavepoolEffect.idle_timeout = 5000; // 5 seconds
WavepoolEffect.ripple_hue = WavepoolEffect.rainbow_hue;
WavepoolEffect.ripple_hue = WavepoolEffect.rainbow_hue;
WavepoolEffect.activate();
}

@ -19,7 +19,7 @@
#include <Kaleidoscope-LEDControl.h>
#include <Kaleidoscope-LEDEffect-BootGreeting.h>
// *INDENT-OFF*
// clang-format off
KEYMAPS(
[0] = KEYMAP_STACKED
(
@ -39,7 +39,7 @@ KEYMAPS(
Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl,
Key_NoKey),
)
// *INDENT-ON*
// clang-format on
KALEIDOSCOPE_INIT_PLUGINS(LEDControl,
BootGreetingEffect,

@ -19,7 +19,7 @@
#include <Kaleidoscope-LEDControl.h>
#include <Kaleidoscope-LEDEffects.h>
// *INDENT-OFF*
// clang-format off
KEYMAPS(
[0] = KEYMAP_STACKED
(
@ -39,7 +39,7 @@ KEYMAPS(
Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl,
Key_NoKey),
)
// *INDENT-ON*
// clang-format on
KALEIDOSCOPE_INIT_PLUGINS(LEDControl,
LEDOff,

@ -24,7 +24,7 @@
#include <Kaleidoscope-LEDEffect-Chase.h>
#include <Kaleidoscope-PersistentLEDMode.h>
// *INDENT-OFF*
// clang-format off
KEYMAPS(
[0] = KEYMAP_STACKED
(
@ -44,7 +44,7 @@ KEYMAPS(
Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl,
Key_NoKey),
)
// *INDENT-ON*
// clang-format on
KALEIDOSCOPE_INIT_PLUGINS(LEDControl,
EEPROMSettings,

Loading…
Cancel
Save