summaryrefslogtreecommitdiffstats
path: root/users/drashna/keyrecords
diff options
context:
space:
mode:
Diffstat (limited to 'users/drashna/keyrecords')
-rw-r--r--users/drashna/keyrecords/autocorrection/autocorrection.c143
-rw-r--r--users/drashna/keyrecords/autocorrection/autocorrection.h10
-rwxr-xr-xusers/drashna/keyrecords/autocorrection/make_autocorrection_data.py273
-rw-r--r--users/drashna/keyrecords/caps_word.c69
-rw-r--r--users/drashna/keyrecords/caps_word.h8
-rw-r--r--users/drashna/keyrecords/process_records.c220
-rw-r--r--users/drashna/keyrecords/process_records.h142
-rw-r--r--users/drashna/keyrecords/tap_dances.c72
-rw-r--r--users/drashna/keyrecords/tap_dances.h44
-rw-r--r--users/drashna/keyrecords/unicode.c287
-rw-r--r--users/drashna/keyrecords/wrappers.h278
11 files changed, 1546 insertions, 0 deletions
diff --git a/users/drashna/keyrecords/autocorrection/autocorrection.c b/users/drashna/keyrecords/autocorrection/autocorrection.c
new file mode 100644
index 0000000000..7c8c28c674
--- /dev/null
+++ b/users/drashna/keyrecords/autocorrection/autocorrection.c
@@ -0,0 +1,143 @@
+// Copyright 2021 Google LLC
+// Copyright 2022 @filterpaper
+// SPDX-License-Identifier: Apache-2.0
+// Original source: https://getreuer.info/posts/keyboards/autocorrection
+
+#include "autocorrection.h"
+#include <string.h>
+
+#if __has_include("autocorrection_data.h")
+# include "autocorrection_data.h"
+# if AUTOCORRECTION_MIN_LENGTH < 4
+# error Minimum Length is too short and may cause overflows
+# endif
+
+bool process_autocorrection(uint16_t keycode, keyrecord_t* record) {
+ static uint8_t typo_buffer[AUTOCORRECTION_MAX_LENGTH] = {KC_SPC};
+ static uint8_t typo_buffer_size = 1;
+
+ if (keycode == AUTO_CTN) {
+ if (record->event.pressed) {
+ typo_buffer_size = 0;
+ userspace_config.autocorrection ^= 1;
+ eeconfig_update_user(userspace_config.raw);
+ }
+ return false;
+ }
+
+ if (!userspace_config.autocorrection) {
+ typo_buffer_size = 0;
+ return true;
+ }
+
+ switch (keycode) {
+ case KC_LSFT:
+ case KC_RSFT:
+ return true;
+# ifndef NO_ACTION_TAPPING
+ case QK_MOD_TAP ... QK_MOD_TAP_MAX:
+ if (((keycode >> 8) & 0xF) == MOD_LSFT) {
+ return true;
+ }
+# ifndef NO_ACTION_LAYER
+ case QK_LAYER_TAP ... QK_LAYER_TAP_MAX:
+# endif
+ if (record->event.pressed || !record->tap.count) {
+ return true;
+ }
+ keycode &= 0xFF;
+ break;
+# endif
+# ifndef NO_ACTION_ONESHOT
+ case QK_ONE_SHOT_MOD ... QK_ONE_SHOT_MOD_MAX:
+ if ((keycode & 0xF) == MOD_LSFT) {
+ return true;
+ }
+# endif
+ default:
+ if (!record->event.pressed) {
+ return true;
+ }
+ }
+
+ // Subtract buffer for Backspace key, reset for other non-alpha.
+ if (!(KC_A <= keycode && keycode <= KC_Z)) {
+ if (keycode == KC_BSPC) {
+ // Remove last character from the buffer.
+ if (typo_buffer_size > 0) {
+ --typo_buffer_size;
+ }
+ return true;
+ } else if (KC_1 <= keycode && keycode <= KC_SLSH && keycode != KC_ESC) {
+ // Set a word boundary if space, period, digit, etc. is pressed.
+ // Behave more conservatively for the enter key. Reset, so that enter
+ // can't be used on a word ending.
+ if (keycode == KC_ENT) {
+ typo_buffer_size = 0;
+ }
+ keycode = KC_SPC;
+ } else {
+ // Clear state if some other non-alpha key is pressed.
+ typo_buffer_size = 0;
+ return true;
+ }
+ }
+
+ // Rotate oldest character if buffer is full.
+ if (typo_buffer_size >= AUTOCORRECTION_MAX_LENGTH) {
+ memmove(typo_buffer, typo_buffer + 1, AUTOCORRECTION_MAX_LENGTH - 1);
+ typo_buffer_size = AUTOCORRECTION_MAX_LENGTH - 1;
+ }
+
+ // Append `keycode` to buffer.
+ typo_buffer[typo_buffer_size++] = keycode;
+ // Return if buffer is smaller than the shortest word.
+ if (typo_buffer_size < AUTOCORRECTION_MIN_LENGTH) {
+ return true;
+ }
+
+ // Check for typo in buffer using a trie stored in `autocorrection_data`.
+ uint16_t state = 0;
+ uint8_t code = pgm_read_byte(autocorrection_data + state);
+ for (uint8_t i = typo_buffer_size - 1; i >= 0; --i) {
+ uint8_t const key_i = typo_buffer[i];
+
+ if (code & 64) { // Check for match in node with multiple children.
+ code &= 63;
+ for (; code != key_i; code = pgm_read_byte(autocorrection_data + (state += 3))) {
+ if (!code) return true;
+ }
+ // Follow link to child node.
+ state = (pgm_read_byte(autocorrection_data + state + 1) | pgm_read_byte(autocorrection_data + state + 2) << 8);
+ // Check for match in node with single child.
+ } else if (code != key_i) {
+ return true;
+ } else if (!(code = pgm_read_byte(autocorrection_data + (++state)))) {
+ ++state;
+ }
+
+ code = pgm_read_byte(autocorrection_data + state);
+
+ if (code & 128) { // A typo was found! Apply autocorrection.
+ const uint8_t backspaces = code & 63;
+ for (uint8_t i = 0; i < backspaces; ++i) {
+ tap_code(KC_BSPC);
+ }
+ send_string_P((char const*)(autocorrection_data + state + 1));
+
+ if (keycode == KC_SPC) {
+ typo_buffer[0] = KC_SPC;
+ typo_buffer_size = 1;
+ return true;
+ } else {
+ typo_buffer_size = 0;
+ return false;
+ }
+ }
+ }
+ return true;
+}
+#else
+# pragma message "Warning!!! Autocorrect is not corretly setup!"
+bool process_autocorrection(uint16_t keycode, keyrecord_t* record) { return true; }
+#endif
diff --git a/users/drashna/keyrecords/autocorrection/autocorrection.h b/users/drashna/keyrecords/autocorrection/autocorrection.h
new file mode 100644
index 0000000000..57685eb4b5
--- /dev/null
+++ b/users/drashna/keyrecords/autocorrection/autocorrection.h
@@ -0,0 +1,10 @@
+// Copyright 2021 Google LLC
+// Copyright 2022 @filterpaper
+// SPDX-License-Identifier: Apache-2.0
+// Original source: https://getreuer.info/posts/keyboards/autocorrection
+
+#pragma once
+
+#include "drashna.h"
+
+bool process_autocorrection(uint16_t keycode, keyrecord_t* record);
diff --git a/users/drashna/keyrecords/autocorrection/make_autocorrection_data.py b/users/drashna/keyrecords/autocorrection/make_autocorrection_data.py
new file mode 100755
index 0000000000..27383b8955
--- /dev/null
+++ b/users/drashna/keyrecords/autocorrection/make_autocorrection_data.py
@@ -0,0 +1,273 @@
+# Copyright 2021 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+"""Python program to make autocorrection_data.h.
+
+This program reads "autocorrection_dict.txt" and generates a C source file
+"autocorrection_data.h" with a serialized trie embedded as an array. Run this
+program without arguments like
+
+$ python3 make_autocorrection_data.py
+
+Or to read from a different typo dict file, pass it as the first argument like
+
+$ python3 make_autocorrection_data.py dict.txt
+
+Each line of the dict file defines one typo and its correction with the syntax
+"typo -> correction". Blank lines or lines starting with '#' are ignored.
+Example:
+
+ :thier -> their
+ fitler -> filter
+ lenght -> length
+ ouput -> output
+ widht -> width
+
+See autocorrection_dict_extra.txt for a larger example.
+
+For full documentation, see
+https://getreuer.info/posts/keyboards/autocorrection
+"""
+
+import sys
+import textwrap
+from typing import Any, Dict, List, Tuple
+
+try:
+ from english_words import english_words_lower_alpha_set as CORRECT_WORDS
+except ImportError:
+ print('Autocorrection will falsely trigger when a typo is a substring of a '
+ 'correctly spelled word. To check for this, install the english_words '
+ 'package and rerun this script:\n\n pip install english_words\n')
+ # Use a minimal word list as a fallback.
+ CORRECT_WORDS = ('information', 'available', 'international', 'language',
+ 'loosest', 'reference', 'wealthier', 'entertainment',
+ 'association', 'provides', 'technology', 'statehood')
+
+KC_A = 4
+KC_SPC = 0x2c
+
+def parse_file(file_name: str) -> List[Tuple[str, str]]:
+ """Parses autocorrections dictionary file.
+
+ Each line of the file defines one typo and its correction with the syntax
+ "typo -> correction". Blank lines or lines starting with '#' are ignored. The
+ function validates that typos only have characters a-z and that typos are not
+ substrings of other typos, otherwise the longer typo would never trigger.
+
+ Args:
+ file_name: String, path of the autocorrections dictionary.
+ Returns:
+ List of (typo, correction) tuples.
+ """
+
+ autocorrections = []
+ typos = set()
+ line_number = 0
+ for line in open(file_name, 'rt'):
+ line_number += 1
+ line = line.strip()
+ if line and line[0] != '#':
+ # Parse syntax "typo -> correction", using strip to ignore indenting.
+ tokens = [token.strip() for token in line.split('->', 1)]
+ if len(tokens) != 2 or not tokens[0]:
+ print(f'Error:{line_number}: Invalid syntax: "{line}"')
+ sys.exit(1)
+
+ typo, correction = tokens
+ typo = typo.lower() # Force typos to lowercase.
+ typo = typo.replace(' ', ':')
+
+ if typo in typos:
+ print(f'Warning:{line_number}: Ignoring duplicate typo: "{typo}"')
+ continue
+
+ # Check that `typo` is valid.
+ if not(all([ord('a') <= ord(c) <= ord('z') or c == ':' for c in typo])):
+ print(f'Error:{line_number}: Typo "{typo}" has '
+ 'characters other than a-z and :.')
+ sys.exit(1)
+ for other_typo in typos:
+ if typo in other_typo or other_typo in typo:
+ print(f'Error:{line_number}: Typos may not be substrings of one '
+ f'another, otherwise the longer typo would never trigger: '
+ f'"{typo}" vs. "{other_typo}".')
+ sys.exit(1)
+ if len(typo) < 5:
+ print(f'Warning:{line_number}: It is suggested that typos are at '
+ f'least 5 characters long to avoid false triggers: "{typo}"')
+
+ if typo.startswith(':') and typo.endswith(':'):
+ if typo[1:-1] in CORRECT_WORDS:
+ print(f'Warning:{line_number}: Typo "{typo}" is a correctly spelled '
+ 'dictionary word.')
+ elif typo.startswith(':') and not typo.endswith(':'):
+ for word in CORRECT_WORDS:
+ if word.startswith(typo[1:]):
+ print(f'Warning:{line_number}: Typo "{typo}" would falsely trigger '
+ f'on correctly spelled word "{word}".')
+ elif not typo.startswith(':') and typo.endswith(':'):
+ for word in CORRECT_WORDS:
+ if word.endswith(typo[:-1]):
+ print(f'Warning:{line_number}: Typo "{typo}" would falsely trigger '
+ f'on correctly spelled word "{word}".')
+ elif not typo.startswith(':') and not typo.endswith(':'):
+ for word in CORRECT_WORDS:
+ if typo in word:
+ print(f'Warning:{line_number}: Typo "{typo}" would falsely trigger '
+ f'on correctly spelled word "{word}".')
+
+ autocorrections.append((typo, correction))
+ typos.add(typo)
+
+ return autocorrections
+
+
+def make_trie(autocorrections: List[Tuple[str, str]]) -> Dict[str, Any]:
+ """Makes a trie from the the typos, writing in reverse.
+
+ Args:
+ autocorrections: List of (typo, correction) tuples.
+ Returns:
+ Dict of dict, representing the trie.
+ """
+ trie = {}
+ for typo, correction in autocorrections:
+ node = trie
+ for letter in typo[::-1]:
+ node = node.setdefault(letter, {})
+ node['LEAF'] = (typo, correction)
+
+ return trie
+
+
+def serialize_trie(autocorrections: List[Tuple[str, str]],
+ trie: Dict[str, Any]) -> List[int]:
+ """Serializes trie and correction data in a form readable by the C code.
+
+ Args:
+ autocorrections: List of (typo, correction) tuples.
+ trie: Dict of dicts.
+ Returns:
+ List of ints in the range 0-255.
+ """
+ table = []
+
+ # Traverse trie in depth first order.
+ def traverse(trie_node):
+ if 'LEAF' in trie_node: # Handle a leaf trie node.
+ typo, correction = trie_node['LEAF']
+ word_boundary_ending = typo[-1] == ':'
+ typo = typo.strip(':')
+ i = 0 # Make the autocorrection data for this entry and serialize it.
+ while i < min(len(typo), len(correction)) and typo[i] == correction[i]:
+ i += 1
+ backspaces = len(typo) - i - 1 + word_boundary_ending
+ assert 0 <= backspaces <= 63
+ correction = correction[i:]
+ data = [backspaces + 128] + list(bytes(correction, 'ascii')) + [0]
+
+ entry = {'data': data, 'links': [], 'byte_offset': 0}
+ table.append(entry)
+ elif len(trie_node) == 1: # Handle trie node with a single child.
+ c, trie_node = next(iter(trie_node.items()))
+ entry = {'chars': c, 'byte_offset': 0}
+
+ # It's common for a trie to have long chains of single-child nodes. We
+ # find the whole chain so that we can serialize it more efficiently.
+ while len(trie_node) == 1 and 'LEAF' not in trie_node:
+ c, trie_node = next(iter(trie_node.items()))
+ entry['chars'] += c
+
+ table.append(entry)
+ entry['links'] = [traverse(trie_node)]
+ else: # Handle trie node with multiple children.
+ entry = {'chars': ''.join(sorted(trie_node.keys())), 'byte_offset': 0}
+ table.append(entry)
+ entry['links'] = [traverse(trie_node[c]) for c in entry['chars']]
+ return entry
+
+ traverse(trie)
+
+ def serialize(e):
+ def kc_code(c):
+ if ord('a') <= ord(c) <= ord('z'):
+ return ord(c) - ord('a') + KC_A
+ elif c == ':':
+ return KC_SPC
+ else:
+ raise ValueError(f'Invalid character: {c}')
+
+ encode_link = lambda link: [link['byte_offset'] & 255,
+ link['byte_offset'] >> 8]
+
+ if not e['links']: # Handle a leaf table entry.
+ return e['data']
+ elif len(e['links']) == 1: # Handle a chain table entry.
+ return list(map(kc_code, e['chars'])) + [0] #+ encode_link(e['links'][0]))
+ else: # Handle a branch table entry.
+ data = []
+ for c, link in zip(e['chars'], e['links']):
+ data += [kc_code(c) | (0 if data else 64)] + encode_link(link)
+ return data + [0]
+
+ byte_offset = 0
+ for e in table: # To encode links, first compute byte offset of each entry.
+ e['byte_offset'] = byte_offset
+ byte_offset += len(serialize(e))
+ assert 0 <= byte_offset <= 0xffff
+
+ return [b for e in table for b in serialize(e)] # Serialize final table.
+
+
+def write_generated_code(autocorrections: List[Tuple[str, str]],
+ data: List[int],
+ file_name: str) -> None:
+ """Writes autocorrection data as generated C code to `file_name`.
+
+ Args:
+ autocorrections: List of (typo, correction) tuples.
+ data: List of ints in 0-255, the serialized trie.
+ file_name: String, path of the output C file.
+ """
+ assert all(0 <= b <= 255 for b in data)
+ typo_len = lambda e: len(e[0])
+ min_typo = min(autocorrections, key=typo_len)[0]
+ max_typo = max(autocorrections, key=typo_len)[0]
+ generated_code = ''.join([
+ '// Generated code.\n\n',
+ f'// Autocorrection dictionary ({len(autocorrections)} entries):\n',
+ ''.join(sorted(f'// {typo:<{len(max_typo)}} -> {correction}\n'
+ for typo, correction in autocorrections)),
+ f'\n#define AUTOCORRECTION_MIN_LENGTH {len(min_typo)} // "{min_typo}"\n',
+ f'#define AUTOCORRECTION_MAX_LENGTH {len(max_typo)} // "{max_typo}"\n\n',
+ textwrap.fill('static const uint8_t autocorrection_data[%d] PROGMEM = {%s};' % (
+ len(data), ', '.join(map(str, data))), width=80, subsequent_indent=' '),
+ '\n\n'])
+
+ with open(file_name, 'wt') as f:
+ f.write(generated_code)
+
+
+def main(argv):
+ dict_file = argv[1] if len(argv) > 1 else 'autocorrection_dict.txt'
+ autocorrections = parse_file(dict_file)
+ trie = make_trie(autocorrections)
+ data = serialize_trie(autocorrections, trie)
+ print(f'Processed %d autocorrection entries to table with %d bytes.'
+ % (len(autocorrections), len(data)))
+ write_generated_code(autocorrections, data, 'autocorrection_data.h')
+
+if __name__ == '__main__':
+ main(sys.argv)
diff --git a/users/drashna/keyrecords/caps_word.c b/users/drashna/keyrecords/caps_word.c
new file mode 100644
index 0000000000..731568328a
--- /dev/null
+++ b/users/drashna/keyrecords/caps_word.c
@@ -0,0 +1,69 @@
+// Copyright 2021 Google LLC.
+// SPDX-License-Identifier: Apache-2.0
+
+#include "caps_word.h"
+
+bool caps_word_enabled = false;
+bool caps_word_shifted = false;
+
+bool process_caps_word(uint16_t keycode, keyrecord_t* record) {
+ if (!caps_word_enabled) {
+ // Pressing both shift keys at the same time enables caps word.
+ if (((get_mods() | get_oneshot_mods()) & MOD_MASK_SHIFT) == MOD_MASK_SHIFT) {
+ clear_mods();
+ clear_oneshot_mods();
+ caps_word_shifted = false;
+ caps_word_enabled = true;
+ return false;
+ }
+ return true;
+ }
+
+ if (!record->event.pressed) {
+ return true;
+ }
+
+ if (!((get_mods() | get_oneshot_mods()) & ~MOD_MASK_SHIFT)) {
+ switch (keycode) {
+ case QK_MOD_TAP ... QK_MOD_TAP_MAX:
+ case QK_LAYER_TAP ... QK_LAYER_TAP_MAX:
+ // Earlier return if this has not been considered tapped yet.
+ if (record->tap.count == 0) {
+ return true;
+ }
+ // Get the base tapping keycode of a mod- or layer-tap key.
+ keycode &= 0xff;
+ }
+
+ switch (keycode) {
+ // Letter keys should be shifted.
+ case KC_A ... KC_Z:
+ if (!caps_word_shifted) {
+ register_code(KC_LSFT);
+ }
+ caps_word_shifted = true;
+ return true;
+
+ // Keycodes that continue caps word but shouldn't get shifted.
+ case KC_1 ... KC_0:
+ case KC_BSPC:
+ case KC_MINS:
+ case KC_UNDS:
+ if (caps_word_shifted) {
+ unregister_code(KC_LSFT);
+ }
+ caps_word_shifted = false;
+ return true;
+
+ // Any other keycode disables caps word.
+ }
+ }
+
+ // Disable caps word.
+ caps_word_enabled = false;
+ if (caps_word_shifted) {
+ unregister_code(KC_LSFT);
+ }
+ caps_word_shifted = false;
+ return true;
+}
diff --git a/users/drashna/keyrecords/caps_word.h b/users/drashna/keyrecords/caps_word.h
new file mode 100644
index 0000000000..79e410ddda
--- /dev/null
+++ b/users/drashna/keyrecords/caps_word.h
@@ -0,0 +1,8 @@
+// Copyright 2021 Google LLC.
+// SPDX-License-Identifier: Apache-2.0
+
+#pragma once
+
+#include "drashna.h"
+
+bool process_caps_word(uint16_t keycode, keyrecord_t* record);
diff --git a/users/drashna/keyrecords/process_records.c b/users/drashna/keyrecords/process_records.c
new file mode 100644
index 0000000000..c7d4a925b0
--- /dev/null
+++ b/users/drashna/keyrecords/process_records.c
@@ -0,0 +1,220 @@
+/* Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
+ *
+ * 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, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * 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 "drashna.h"
+#include "version.h"
+#ifdef CAPS_WORD_ENABLE
+# include "caps_word.h"
+#endif
+#ifdef AUTOCORRECTION_ENABLE
+# include "autocorrection/autocorrection.h"
+#endif
+
+uint16_t copy_paste_timer;
+bool host_driver_disabled = false;
+// Defines actions tor my global custom keycodes. Defined in drashna.h file
+// Then runs the _keymap's record handier if not processed here
+
+__attribute__((weak)) bool process_record_keymap(uint16_t keycode, keyrecord_t *record) { return true; }
+__attribute__((weak)) bool process_record_secrets(uint16_t keycode, keyrecord_t *record) { return true; }
+bool process_record_user(uint16_t keycode, keyrecord_t *record) {
+ // If console is enabled, it will print the matrix position and status of each key pressed
+#ifdef KEYLOGGER_ENABLE
+ uprintf("KL: kc: 0x%04X, col: %2u, row: %2u, pressed: %b, time: %5u, int: %b, count: %u\n", keycode, record->event.key.col, record->event.key.row, record->event.pressed, record->event.time, record->tap.interrupted, record->tap.count);
+#endif // KEYLOGGER_ENABLE
+#ifdef OLED_ENABLE
+ process_record_user_oled(keycode, record);
+#endif // OLED
+
+ if (!(process_record_keymap(keycode, record) && process_record_secrets(keycode, record)
+#ifdef RGB_MATRIX_ENABLE
+ && process_record_user_rgb_matrix(keycode, record)
+#endif
+#ifdef RGBLIGHT_ENABLE
+ && process_record_user_rgb_light(keycode, record)
+#endif
+#ifdef CUSTOM_UNICODE_ENABLE
+ && process_record_unicode(keycode, record)
+#endif
+#if defined(POINTING_DEVICE_ENABLE)
+ && process_record_pointing(keycode, record)
+#endif
+#ifdef CAPS_WORD_ENABLE
+ && process_caps_word(keycode, record)
+#endif
+#ifdef AUTOCORRECTION_ENABLE
+ && process_autocorrection(keycode, record)
+#endif
+ && true)) {
+ return false;
+ }
+
+ switch (keycode) {
+ case FIRST_DEFAULT_LAYER_KEYCODE ... LAST_DEFAULT_LAYER_KEYCODE:
+ if (record->event.pressed) {
+ uint8_t mods = mod_config(get_mods() | get_oneshot_mods());
+ if (!mods) {
+ set_single_persistent_default_layer(keycode - FIRST_DEFAULT_LAYER_KEYCODE);
+#if LAST_DEFAULT_LAYER_KEYCODE > (FIRST_DEFAULT_LAYER_KEYCODE + 3)
+ } else if (mods & MOD_MASK_SHIFT) {
+ set_single_persistent_default_layer(keycode - FIRST_DEFAULT_LAYER_KEYCODE + 4);
+# if LAST_DEFAULT_LAYER_KEYCODE > (FIRST_DEFAULT_LAYER_KEYCODE + 7)
+
+ } else if (mods & MOD_MASK_CTRL) {
+ set_single_persistent_default_layer(keycode - FIRST_DEFAULT_LAYER_KEYCODE + 8);
+# endif
+#endif
+ }
+ }
+ break;
+
+ case KC_MAKE: // Compiles the firmware, and adds the flash command based on keyboard bootloader
+ if (!record->event.pressed) {
+#ifndef MAKE_BOOTLOADER
+ uint8_t temp_mod = mod_config(get_mods());
+ uint8_t temp_osm = mod_config(get_oneshot_mods());
+ clear_mods();
+ clear_oneshot_mods();
+#endif
+ send_string_with_delay_P(PSTR("qmk"), TAP_CODE_DELAY);
+#ifndef MAKE_BOOTLOADER
+ if ((temp_mod | temp_osm) & MOD_MASK_SHIFT)
+#endif
+ {
+ send_string_with_delay_P(PSTR(" flash "), TAP_CODE_DELAY);
+#ifndef MAKE_BOOTLOADER
+ } else {
+ send_string_with_delay_P(PSTR(" compile "), TAP_CODE_DELAY);
+#endif
+ }
+ send_string_with_delay_P(PSTR("-kb " QMK_KEYBOARD " -km " QMK_KEYMAP), TAP_CODE_DELAY);
+#ifdef CONVERT_TO_PROTON_C
+ send_string_with_delay_P(PSTR(" -e CTPC=yes"), TAP_CODE_DELAY);
+#endif
+ send_string_with_delay_P(PSTR(SS_TAP(X_ENTER)), TAP_CODE_DELAY);
+ }
+ break;
+
+ case VRSN: // Prints firmware version
+ if (record->event.pressed) {
+ send_string_with_delay_P(PSTR(QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION ", Built on: " QMK_BUILDDATE), TAP_CODE_DELAY);
+ }
+ break;
+
+ case KC_DIABLO_CLEAR: // reset all Diablo timers, disabling them
+#ifdef TAP_DANCE_ENABLE
+ if (record->event.pressed) {
+ for (uint8_t index = 0; index < 4; index++) {
+ diablo_timer[index].key_interval = 0;
+ }
+ }
+#endif // TAP_DANCE_ENABLE
+ break;
+
+ case KC_CCCV: // One key copy/paste
+ if (record->event.pressed) {
+ copy_paste_timer = timer_read();
+ } else {
+ if (timer_elapsed(copy_paste_timer) > TAPPING_TERM) { // Hold, copy
+ tap_code16(LCTL(KC_C));
+ } else { // Tap, paste
+ tap_code16(LCTL(KC_V));
+ }
+ }
+ break;
+ case KC_RGB_T: // This allows me to use underglow as layer indication, or as normal
+#if defined(RGBLIGHT_ENABLE) || defined(RGB_MATRIX_ENABLE)
+ if (record->event.pressed) {
+ userspace_config.rgb_layer_change ^= 1;
+ dprintf("rgblight layer change [EEPROM]: %u\n", userspace_config.rgb_layer_change);
+ eeconfig_update_user(userspace_config.raw);
+ if (userspace_config.rgb_layer_change) {
+# if defined(RGBLIGHT_ENABLE) && defined(RGB_MATRIX_ENABLE)
+ rgblight_enable_noeeprom();
+# endif
+ layer_state_set(layer_state); // This is needed to immediately set the layer color (looks better)
+# if defined(RGBLIGHT_ENABLE) && defined(RGB_MATRIX_ENABLE)
+ } else {
+ rgblight_disable_noeeprom();
+# endif
+ }
+ }
+#endif // RGBLIGHT_ENABLE
+ break;
+
+#if defined(RGBLIGHT_ENABLE) || defined(RGB_MATRIX_ENABLE)
+ case RGB_TOG:
+ // Split keyboards need to trigger on key-up for edge-case issue
+# ifndef SPLIT_KEYBOARD
+ if (record->event.pressed) {
+# else
+ if (!record->event.pressed) {
+# endif
+# if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES)
+ rgblight_toggle();
+# endif
+# if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES)
+ rgb_matrix_toggle();
+# endif
+ }
+ return false;
+ break;
+ case RGB_MODE_FORWARD ... RGB_MODE_GRADIENT: // quantum_keycodes.h L400 for definitions
+ if (record->event.pressed) {
+ bool is_eeprom_updated;
+# if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES)
+ // This disables layer indication, as it's assumed that if you're changing this ... you want that disabled
+ if (userspace_config.rgb_layer_change) {
+ userspace_config.rgb_layer_change = false;
+ dprintf("rgblight layer change [EEPROM]: %u\n", userspace_config.rgb_layer_change);
+ is_eeprom_updated = true;
+ }
+# endif
+# if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS)
+ if (userspace_config.rgb_matrix_idle_anim) {
+ userspace_config.rgb_matrix_idle_anim = false;
+ dprintf("RGB Matrix Idle Animation [EEPROM]: %u\n", userspace_config.rgb_matrix_idle_anim);
+ is_eeprom_updated = true;
+ }
+# endif
+ if (is_eeprom_updated) {
+ eeconfig_update_user(userspace_config.raw);
+ }
+ }
+ break;
+#endif
+ case KEYLOCK: {
+ static host_driver_t *host_driver = 0;
+
+ if (record->event.pressed) {
+ if (host_get_driver()) {
+ host_driver = host_get_driver();
+ clear_keyboard();
+ host_set_driver(0);
+ host_driver_disabled = true;
+ } else {
+ host_set_driver(host_driver);
+ host_driver_disabled = false;
+ }
+ }
+ break;
+ }
+ }
+ return true;
+}
+
+__attribute__((weak)) void post_process_record_keymap(uint16_t keycode, keyrecord_t *record) {}
+void post_process_record_user(uint16_t keycode, keyrecord_t *record) { post_process_record_keymap(keycode, record); }
diff --git a/users/drashna/keyrecords/process_records.h b/users/drashna/keyrecords/process_records.h
new file mode 100644
index 0000000000..df506b3647
--- /dev/null
+++ b/users/drashna/keyrecords/process_records.h
@@ -0,0 +1,142 @@
+/* Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
+ *
+ * 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, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * 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 "drashna.h"
+
+#if defined(KEYBOARD_handwired_tractyl_manuform)
+# define PLACEHOLDER_SAFE_RANGE KEYMAP_SAFE_RANGE
+#else
+# define PLACEHOLDER_SAFE_RANGE SAFE_RANGE
+#endif
+
+enum userspace_custom_keycodes {
+ VRSN = PLACEHOLDER_SAFE_RANGE, // Prints QMK Firmware and board info
+ KC_QWERTY, // Sets default layer to QWERTY
+ FIRST_DEFAULT_LAYER_KEYCODE = KC_QWERTY, // Sets default layer to QWERTY
+ KC_COLEMAK_DH, // Sets default layer to COLEMAK
+ KC_COLEMAK, // Sets default layer to COLEMAK
+ KC_DVORAK, // Sets default layer to DVORAK
+ LAST_DEFAULT_LAYER_KEYCODE = KC_DVORAK, // Sets default layer to WORKMAN
+ KC_DIABLO_CLEAR, // Clears all Diablo Timers
+ KC_MAKE, // Run keyboard's customized make command
+ KC_RGB_T, // Toggles RGB Layer Indication mode
+ RGB_IDL, // RGB Idling animations
+ KC_SECRET_1, // test1
+ KC_SECRET_2, // test2
+ KC_SECRET_3, // test3
+ KC_SECRET_4, // test4
+ KC_SECRET_5, // test5
+ KC_CCCV, // Hold to copy, tap to paste
+ KC_NUKE, // NUCLEAR LAUNCH DETECTED!!!
+ UC_FLIP, // (ಠ痊ಠ)┻━┻
+ UC_TABL, // ┬─┬ノ( º _ ºノ)
+ UC_SHRG, // ¯\_(ツ)_/¯
+ UC_DISA, // ಠ_ಠ
+ UC_IRNY,
+ UC_CLUE,
+ KEYLOCK, // Locks keyboard by unmounting driver
+ KC_NOMODE,
+ KC_WIDE,
+ KC_SCRIPT,
+ KC_BLOCKS,
+ KC_REGIONAL,
+ KC_AUSSIE,
+ KC_ZALGO,
+ KC_ACCEL,
+ AUTO_CTN, // Toggle Autocorrect status
+ NEW_SAFE_RANGE // use "NEWPLACEHOLDER for keymap specific codes
+};
+
+bool process_record_secrets(uint16_t keycode, keyrecord_t *record);
+bool process_record_keymap(uint16_t keycode, keyrecord_t *record);
+void post_process_record_keymap(uint16_t keycode, keyrecord_t *record);
+#ifdef CUSTOM_UNICODE_ENABLE
+bool process_record_unicode(uint16_t keycode, keyrecord_t *record);
+void matrix_init_unicode(void);
+#endif
+
+#define LOWER MO(_LOWER)
+#define RAISE MO(_RAISE)
+#define ADJUST MO(_ADJUST)
+#define TG_MODS OS_TOGG
+#define TG_GAME TG(_GAMEPAD)
+#define TG_DBLO TG(_DIABLO)
+#define OS_LWR OSL(_LOWER)
+#define OS_RSE OSL(_RAISE)
+
+#define KC_SEC1 KC_SECRET_1
+#define KC_SEC2 KC_SECRET_2
+#define KC_SEC3 KC_SECRET_3
+#define KC_SEC4 KC_SECRET_4
+#define KC_SEC5 KC_SECRET_5
+
+#define QWERTY KC_QWERTY
+#define DVORAK KC_DVORAK
+#define COLEMAK KC_COLEMAK
+#define COLEMAKDH KC_COLEMAK_DH
+
+#define DEFLYR1 FIRST_DEFAULT_LAYER_KEYCODE
+#define DEFLYR2 (FIRST_DEFAULT_LAYER_KEYCODE + 1)
+#define DEFLYR3 (FIRST_DEFAULT_LAYER_KEYCODE + 2)
+#define DEFLYR4 (FIRST_DEFAULT_LAYER_KEYCODE + 3)
+#if LAST_DEFAULT_LAYER_KEYCODE > (FIRST_DEFAULT_LAYER_KEYCODE + 3)
+# define DEFLYR5 (FIRST_DEFAULT_LAYER_KEYCODE + 4)
+# define DEFLYR6 (FIRST_DEFAULT_LAYER_KEYCODE + 5)
+# define DEFLYR7 (FIRST_DEFAULT_LAYER_KEYCODE + 6)
+# define DEFLYR8 (FIRST_DEFAULT_LAYER_KEYCODE + 7)
+# if LAST_DEFAULT_LAYER_KEYCODE > (FIRST_DEFAULT_LAYER_KEYCODE + 7)
+# define DEFLYR9 (FIRST_DEFAULT_LAYER_KEYCODE + 8)
+# define DEFLYR10 (FIRST_DEFAULT_LAYER_KEYCODE + 9)
+# define DEFLYR11 (FIRST_DEFAULT_LAYER_KEYCODE + 10)
+# define DEFLYR12 (FIRST_DEFAULT_LAYER_KEYCODE + 11)
+# endif
+#endif
+
+#define KC_RESET RESET
+#define KC_RST KC_RESET
+
+#ifdef SWAP_HANDS_ENABLE
+# define KC_C1R3 SH_T(KC_TAB)
+#elif defined(DRASHNA_LP)
+# define KC_C1R3 TG(_GAMEPAD)
+#else // SWAP_HANDS_ENABLE
+# define KC_C1R3 KC_TAB
+#endif // SWAP_HANDS_ENABLE
+
+#define BK_LWER LT(_LOWER, KC_BSPC)
+#define SP_LWER LT(_LOWER, KC_SPC)
+#define DL_RAIS LT(_RAISE, KC_DEL)
+#define ET_RAIS LT(_RAISE, KC_ENTER)
+
+/* OSM keycodes, to keep things clean and easy to change */
+#define KC_MLSF OSM(MOD_LSFT)
+#define KC_MRSF OSM(MOD_RSFT)