-
-
Notifications
You must be signed in to change notification settings - Fork 39.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add timestamps to test messages and log keypress duration
- Loading branch information
Showing
20 changed files
with
1,009 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
"""Used by the make system to generate a keycode lookup table from keycodes_{version}.json | ||
""" | ||
from milc import cli | ||
|
||
from qmk.constants import GPL2_HEADER_C_LIKE, GENERATED_HEADER_C_LIKE | ||
from qmk.commands import dump_lines | ||
from qmk.path import normpath | ||
from qmk.keycodes import load_spec | ||
|
||
|
||
def _generate_defines(lines, keycodes): | ||
lines.append('') | ||
lines.append('std::map<uint16_t, std::string> KEYCODE_ID_TABLE = {') | ||
for key, value in keycodes["keycodes"].items(): | ||
lines.append(f' {{{value.get("key")}, "{value.get("key")}"}},') | ||
lines.append('};') | ||
|
||
|
||
@cli.argument('-v', '--version', arg_only=True, required=True, help='Version of keycodes to generate.') | ||
@cli.argument('-o', '--output', arg_only=True, type=normpath, help='File to write to') | ||
@cli.argument('-q', '--quiet', arg_only=True, action='store_true', help="Quiet mode, only output error messages") | ||
@cli.subcommand('Used by the make system to generate a keycode lookup table from keycodes_{version}.json', hidden=True) | ||
def generate_keycodes_tests(cli): | ||
"""Generates a keycode to identifier lookup table for unit test output. | ||
""" | ||
|
||
# Build the keycodes.h file. | ||
keycodes_h_lines = [GPL2_HEADER_C_LIKE, GENERATED_HEADER_C_LIKE, '// clang-format off'] | ||
keycodes_h_lines.append('extern "C" {\n#include <keycode.h>\n}') | ||
keycodes_h_lines.append('#include <map>') | ||
keycodes_h_lines.append('#include <string>') | ||
keycodes_h_lines.append('#include <cstdint>') | ||
|
||
keycodes = load_spec(cli.args.version) | ||
|
||
_generate_defines(keycodes_h_lines, keycodes) | ||
|
||
# Show the results | ||
dump_lines(cli.args.output, keycodes_h_lines, cli.args.quiet) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Copyright 2022 Stefan Kerkmann | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
|
||
#include "test_common.hpp" | ||
|
||
class KeycodeToIdentifierSuite : public ::testing::TestWithParam<std::pair<std::uint16_t, std::string>> {}; | ||
|
||
TEST_P(KeycodeToIdentifierSuite, ConversionTests) { | ||
ASSERT_EQ(get_keycode_identifier_or_default(GetParam().first), GetParam().second); | ||
} | ||
|
||
INSTANTIATE_TEST_CASE_P(ConversionTestsP, KeycodeToIdentifierSuite, | ||
// clang-format off | ||
::testing::Values( | ||
// Goto layer | ||
std::make_pair(TO(0), "TO(0)"), | ||
std::make_pair(TO(0x1F), "TO(31)"), | ||
// Momentary switch layer | ||
std::make_pair(MO(0), "MO(0)"), | ||
std::make_pair(MO(0x1F), "MO(31)"), | ||
// Set default layer | ||
std::make_pair(DF(0), "DF(0)"), | ||
std::make_pair(DF(0x1F), "DF(31)"), | ||
// Toggle layer | ||
std::make_pair(TG(0), "TG(0)"), | ||
std::make_pair(TG(0x1F), "TG(31)"), | ||
// One-shot layer | ||
std::make_pair(OSL(0), "OSL(0)"), | ||
std::make_pair(OSL(0x1F), "OSL(31)"), | ||
// One-shot mod | ||
std::make_pair(OSM(MOD_LSFT), "OSM(MOD_LSFT)"), | ||
std::make_pair(OSM(MOD_LSFT | MOD_LCTL), "OSM(MOD_LCTL | MOD_LSFT)"), | ||
// Layer Mod | ||
std::make_pair(LM(0, MOD_LSFT), "LM(0, MOD_LSFT)"), | ||
std::make_pair(LM(0xF, MOD_LSFT), "LM(15, MOD_LSFT)"), | ||
std::make_pair(LM(0xF, MOD_LSFT | MOD_LCTL), "LM(15, MOD_LCTL | MOD_LSFT)"), | ||
// Layer tap toggle | ||
std::make_pair(TT(0), "TT(0)"), | ||
std::make_pair(TT(0x1F), "TT(31)"), | ||
// Layer tap | ||
std::make_pair(LT(0, KC_A), "LT(0, KC_A)"), | ||
std::make_pair(LT(0xF, KC_SPACE), "LT(15, KC_SPACE)"), | ||
std::make_pair(LT(1, KC_SPC), "LT(1, KC_SPACE)"), | ||
// Mod tap | ||
std::make_pair(MT(MOD_LCTL, KC_A), "MT(MOD_LCTL, KC_A)"), | ||
std::make_pair(MT(MOD_LCTL | MOD_LSFT, KC_A), "MT(MOD_LCTL | MOD_LSFT, KC_A)"), | ||
std::make_pair(ALT_T(KC_TAB), "MT(MOD_LALT, KC_TAB)"), | ||
// Mods | ||
std::make_pair(LCTL(KC_A), "QK_MODS(KC_A, QK_LCTL)"), | ||
std::make_pair(HYPR(KC_SPACE), "QK_MODS(KC_SPACE, QK_LCTL | QK_LSFT | QK_LALT | QK_LGUI)") | ||
)); | ||
// clang-format on |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.