diff options
author | QMK Bot <hello@qmk.fm> | 2022-04-22 08:17:09 +0000 |
---|---|---|
committer | QMK Bot <hello@qmk.fm> | 2022-04-22 08:17:09 +0000 |
commit | 7808ddac0a7f5dfea854147d15c4b591d9e828e5 (patch) | |
tree | 821aa471b13f19caca74c0e311da97e008809190 | |
parent | a727bd646336062c6167a8656ebdcc3f979f9058 (diff) | |
parent | 56b125ad77d3a06ad3f04e12113adbe7a969c54c (diff) |
Merge remote-tracking branch 'origin/master' into develop
12 files changed, 877 insertions, 10 deletions
diff --git a/keyboards/handwired/dactyl_manuform/3x5_3/3x5_3.c b/keyboards/handwired/dactyl_manuform/3x5_3/3x5_3.c new file mode 100644 index 0000000000..2bd1aefadb --- /dev/null +++ b/keyboards/handwired/dactyl_manuform/3x5_3/3x5_3.c @@ -0,0 +1,66 @@ +/* +Copyright 2021 @dlford + +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 "3x5_3.h" + +#ifdef RGB_MATRIX_ENABLE + +// LED Layout +// Columns +// 0 1 2 3 4 5 6 7 8 9 10 11 +// Physical (Center: 133) +// 20 41 61 81 102 122 143 163 183 204 224 244 +// Rows Physical (Center: 54) +// 17 12 11 06 05 23 24 29 30 35 0 21 +// 16 13 10 07 04 22 25 28 31 34 1 43 +// 15 14 09 08 03 21 26 27 32 33 2 64 +// 02 01 00 18 19 20 3 85 + +led_config_t g_led_config = { { + // Key matrix to LED index + // Left 1-18 + {17, 12, 11, 6, 5}, + {16, 13, 10, 7, 4}, + {15, 14, 9, 8, 3}, + {NO_LED, NO_LED, 2, 1, 0}, + // Right 1-18 + {23, 24, 29, 30, 35}, + {22, 25, 28, 31, 34}, + {21, 26, 27, 32, 33}, + {18, 19, 20, NO_LED, NO_LED}, +}, { + // LED index to physical position + // Left 1-18 + {122,85},{102,85},{81,85},{102,64},{102,43},{102,21}, + {81,21},{81,43},{81,64},{61,64},{61,43},{61,21}, + {41,21},{41,43},{41,64},{20,64},{20,43},{20,21}, + // Right 1-18 + {143,85},{163,85},{183,85},{163,64},{163,43},{163,21}, + {183,21},{183,43},{183,64},{204,64},{204,43},{204,21}, + {224,21},{224,43},{224,64},{244,64},{244,43},{244,21} +}, { + // LED index to flag + // Left 1-18 + 4,4,4,4,4,4, + 4,4,4,4,4,4, + 4,4,4,4,4,4, + // Right 1-18 + 4,4,4,4,4,4, + 4,4,4,4,4,4, + 4,4,4,4,4,4 +} }; + +#endif diff --git a/keyboards/handwired/dactyl_manuform/3x5_3/3x5_3.h b/keyboards/handwired/dactyl_manuform/3x5_3/3x5_3.h new file mode 100644 index 0000000000..f9a843d7d6 --- /dev/null +++ b/keyboards/handwired/dactyl_manuform/3x5_3/3x5_3.h @@ -0,0 +1,37 @@ +/* +Copyright 2021 @dlford + +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 "dactyl_manuform.h" + +#define LAYOUT_split_3x5_3(\ + L00, L01, L02, L03, L04, R00, R01, R02, R03, R04, \ + L10, L11, L12, L13, L14, R10, R11, R12, R13, R14, \ + L20, L21, L22, L23, L24, R20, R21, R22, R23, R24, \ + L32, L33, L34, R30, R31, R32 \ + ) \ + { \ + { L00, L01, L02, L03, L04 }, \ + { L10, L11, L12, L13, L14 }, \ + { L20, L21, L22, L23, L24 }, \ + { KC_NO, KC_NO, L32, L33, L34 }, \ + \ + { R00, R01, R02, R03, R04 }, \ + { R10, R11, R12, R13, R14 }, \ + { R20, R21, R22, R23, R24 }, \ + { R30, R31, R32, KC_NO, KC_NO }, \ +} diff --git a/keyboards/handwired/dactyl_manuform/3x5_3/config.h b/keyboards/handwired/dactyl_manuform/3x5_3/config.h new file mode 100644 index 0000000000..e417599a40 --- /dev/null +++ b/keyboards/handwired/dactyl_manuform/3x5_3/config.h @@ -0,0 +1,56 @@ +/* +Copyright 2012 Jun Wako <wakojun@gmail.com> +Copyright 2015 Jack Humbert +Copyright 2021 @dlford +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 "config_common.h" + +#define PRODUCT_ID 0x3536 +#define DEVICE_VER 0x0003 +#ifdef MANUFACTURER + #undef MANUFACTURER +#endif +#define MANUFACTURER DLFord +#define PRODUCT Dactyl Minidox (3x5+3) + +// Communication +// #define USE_I2C +#define USE_SERIAL + +/* key matrix size */ +// Rows are doubled-up +#define MATRIX_ROWS 8 +#define MATRIX_COLS 5 + +// wiring of each half +#define MATRIX_COL_PINS { C6, D7, E6, B4, B5 } +#define MATRIX_ROW_PINS { B1, B3, B2, B6 } + +#define DIODE_DIRECTION ROW2COL + +// WS2812 RGB LED strip input and number of LEDs +#define RGB_DI_PIN D3 +#define DRIVER_LED_TOTAL 36 +#define RGB_MATRIX_SPLIT { 18, 18 } +#define RGB_MATRIX_CENTER { 133, 54 } + +/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */ +#undef LOCKING_SUPPORT_ENABLE +/* Locking resynchronize hack */ +#undef LOCKING_RESYNC_ENABLE + +/* Enables This makes it easier for fast typists to use dual-function keys */ +#undef PERMISSIVE_HOLD diff --git a/keyboards/handwired/dactyl_manuform/3x5_3/info.json b/keyboards/handwired/dactyl_manuform/3x5_3/info.json new file mode 100644 index 0000000000..4764226221 --- /dev/null +++ b/keyboards/handwired/dactyl_manuform/3x5_3/info.json @@ -0,0 +1,48 @@ +{ + "keyboard_name": "Dactyl Manuform 3x5_3", + "url": "https://www.dlford.io/keyboard-build-guide-per-key-rgb-leds/", + "maintainer": "dlford", + "layouts": { + "LAYOUT": { + "layout": [ + { "x": 0, "y": 0 }, + { "x": 1, "y": 0 }, + { "x": 2, "y": 0 }, + { "x": 3, "y": 0 }, + { "x": 4, "y": 0 }, + { "x": 0, "y": 1 }, + { "x": 1, "y": 1 }, + { "x": 2, "y": 1 }, + { "x": 3, "y": 1 }, + { "x": 4, "y": 1 }, + { "x": 0, "y": 2 }, + { "x": 1, "y": 2 }, + { "x": 2, "y": 2 }, + { "x": 3, "y": 2 }, + { "x": 4, "y": 2 }, + { "x": 2, "y": 3 }, + { "x": 3, "y": 3 }, + { "x": 4, "y": 3 }, + + { "x": 10, "y": 0 }, + { "x": 11, "y": 0 }, + { "x": 12, "y": 0 }, + { "x": 13, "y": 0 }, + { "x": 14, "y": 0 }, + { "x": 10, "y": 1 }, + { "x": 11, "y": 1 }, + { "x": 12, "y": 1 }, + { "x": 13, "y": 1 }, + { "x": 14, "y": 1 }, + { "x": 10, "y": 2 }, + { "x": 11, "y": 2 }, + { "x": 12, "y": 2 }, + { "x": 13, "y": 2 }, + { "x": 14, "y": 2 }, + { "x": 10, "y": 3 }, + { "x": 11, "y": 3 }, + { "x": 12, "y": 3 } + ] + } + } +} diff --git a/keyboards/handwired/dactyl_manuform/3x5_3/keymaps/dlford/config.h b/keyboards/handwired/dactyl_manuform/3x5_3/keymaps/dlford/config.h new file mode 100644 index 0000000000..fac9353959 --- /dev/null +++ b/keyboards/handwired/dactyl_manuform/3x5_3/keymaps/dlford/config.h @@ -0,0 +1,106 @@ +/* +Copyright 2012 Jun Wako <wakojun@gmail.com> +Copyright 2021 @dlford +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 + +//#define USE_MATRIX_I2C + +/* Select hand configuration */ + +// #define MASTER_LEFT +// #define MASTER_RIGHT +#define EE_HANDS // ./util/docker_build.sh crkbd:dlford:dfu-split-[left|right] (or avrdude-split[left|right]) + +#define TAPPING_TOGGLE 2 // number of taps to toggle TT +#define TAPPING_TERM_PER_KEY // milliseconds from tap to hold for mod tap per key +#define IGNORE_MOD_TAP_INTERRUPT // ignore hold mod if another tap occurs within tapping term +#define PERMISSIVE_HOLD_PER_KEY // activate mod top hold earlier if another key is pressed AND released per key +#define TAPPING_FORCE_HOLD_PER_KEY // disable double tap hold key repeat per key +#undef MOUSEKEY_INTERVAL +#undef MOUSEKEY_DELAY +#undef MOUSEKEY_TIME_TO_MAX +#undef MOUSEKEY_MAX_SPEED +#undef MOUSEKEY_WHEEL_DELAY +#define MK_KINETIC_SPEED +#define MOUSEKEY_DELAY 100 +#define MOUSEKEY_INTERVAL 35 +#define MOUSEKEY_MOVE_DELTA 5 +#define MOUSEKEY_INITIAL_SPEED 1 +#define MOUSEKEY_DECELERATED_SPEED 10 +#define MOUSEKEY_BASE_SPEED 1200 +#define MOUSEKEY_ACCELERATED_SPEED 4800 + +#ifdef RGB_MATRIX_ENABLE +// # define RGB_DISABLE_TIMEOUT 300000 // number of milliseconds to wait until disabling effects +// # define RGB_DISABLE_WHEN_USB_SUSPENDED // turn off effects when suspended +# define RGB_MATRIX_LED_PROCESS_LIMIT (DRIVER_LED_TOTAL + 4) / 5 // limits the number of LEDs to process in an animation per task run (increases keyboard responsiveness) +# define RGB_MATRIX_LED_FLUSH_LIMIT 16 // limits in milliseconds how frequently an animation will update the LEDs. 16 (16ms) is equivalent to limiting to 60fps (increases keyboard responsiveness) +# define RGB_MATRIX_MAXIMUM_BRIGHTNESS 150 // limits maximum brightness of LEDs to 150 out of 255. Higher may cause the controller to crash. +# define RGB_MATRIX_HUE_STEP 8 +# define RGB_MATRIX_SAT_STEP 8 +# define RGB_MATRIX_VAL_STEP 8 +# define RGB_MATRIX_SPD_STEP 10 + +// Enable animations +// # define ENABLE_RGB_MATRIX_ALPHAS_MODS // Static dual hue speed is hue for secondary hue +// # define ENABLE_RGB_MATRIX_GRADIENT_UP_DOWN // Static gradient top to bottom speed controls how much gradient changes +// # define ENABLE_RGB_MATRIX_GRADIENT_LEFT_RIGHT // Static gradient left to right speed controls how much gradient changes +// # define ENABLE_RGB_MATRIX_BREATHING // Single hue brightness cycling animation +// # define ENABLE_RGB_MATRIX_BAND_SAT // Single hue band fading saturation scrolling left to right +// # define ENABLE_RGB_MATRIX_BAND_VAL // Single hue band fading brightness scrolling left to right +// # define ENABLE_RGB_MATRIX_BAND_PINWHEEL_SAT // Single hue 3 blade spinning pinwheel fades saturation +// # define ENABLE_RGB_MATRIX_BAND_PINWHEEL_VAL // Single hue 3 blade spinning pinwheel fades brightness +// # define ENABLE_RGB_MATRIX_BAND_SPIRAL_SAT // Single hue spinning spiral fades saturation +// # define ENABLE_RGB_MATRIX_BAND_SPIRAL_VAL // Single hue spinning spiral fades brightness +// # define ENABLE_RGB_MATRIX_CYCLE_ALL // Full keyboard solid hue cycling through full gradient +// # define ENABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT // Full gradient scrolling left to right +// # define ENABLE_RGB_MATRIX_CYCLE_UP_DOWN // Full gradient scrolling top to bottom +// # define ENABLE_RGB_MATRIX_CYCLE_OUT_IN // Full gradient scrolling out to in +// # define ENABLE_RGB_MATRIX_CYCLE_OUT_IN_DUAL // Full dual gradients scrolling out to in +// # define ENABLE_RGB_MATRIX_RAINBOW_MOVING_CHEVRON // Full gradent Chevron shapped scrolling left to right +// # define ENABLE_RGB_MATRIX_CYCLE_PINWHEEL // Full gradient spinning pinwheel around center of keyboard +# define ENABLE_RGB_MATRIX_CYCLE_SPIRAL // Full gradient spinning spiral around center of keyboard +// # define ENABLE_RGB_MATRIX_DUAL_BEACON // Full gradient spinning around center of keyboard +// # define ENABLE_RGB_MATRIX_RAINBOW_BEACON // Full tighter gradient spinning around center of keyboard +// # define ENABLE_RGB_MATRIX_RAINBOW_PINWHEELS // Full dual gradients spinning two halfs of keyboard +// # define ENABLE_RGB_MATRIX_RAINDROPS // Randomly changes a single key's hue +// # define ENABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS // Randomly changes a single key's hue and saturation +// # define ENABLE_RGB_MATRIX_HUE_BREATHING // Hue shifts up a slight ammount at the same time then shifts back +// # define ENABLE_RGB_MATRIX_HUE_PENDULUM // Hue shifts up a slight ammount in a wave to the right then back to the left +# define ENABLE_RGB_MATRIX_HUE_WAVE // Hue shifts up a slight ammount and then back down in a wave to the right +// # define RGB_MATRIX_FRAMEBUFFER_EFFECTS // Required for the following two effects +// # define ENABLE_RGB_MATRIX_TYPING_HEATMAP // How hot is your WPM! +// # define ENABLE_RGB_MATRIX_DIGITAL_RAIN // That famous computer simulation +// # define RGB_MATRIX_KEYPRESSES // reacts to keypresses, required for the remaining effects +// # define RGB_MATRIX_KEYRELEASES // reacts to keyreleases (instead of keypresses) +// # define ENABLE_RGB_MATRIX_SOLID_REACTIVE_SIMPLE // Pulses keys hit to hue & value then fades value out +// # define ENABLE_RGB_MATRIX_SOLID_REACTIVE // Static single hue pulses keys hit to shifted hue then fades to current hue +// # define ENABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE // Hue & value pulse near a single key hit then fades value out +// # define ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE // Hue & value pulse near multiple key hits then fades value out +// # define ENABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS // Hue & value pulse the same column and row of a single key hit then fades value out +// # define ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS // Hue & value pulse the same column and row of multiple key hits then fades value out +// # define ENABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS // Hue & value pulse away on the same column and row of a single key hit then fades value out +// # define ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS // Hue & value pulse away on the same column and row of multiple key hits then fades value out +// # define ENABLE_RGB_MATRIX_SPLASH // Full gradient & value pulse away from a single key hit then fades value out +// # define ENABLE_RGB_MATRIX_MULTISPLASH // Full gradient & value pulse away from multiple key hits then fades value out +// # define ENABLE_RGB_MATRIX_SOLID_SPLASH // Hue & value pulse away from a single key hit then fades value out +// # define ENABLE_RGB_MATRIX_SOLID_MULTISPLASH // Hue & value pulse away from multiple key hits then fades value out +#endif + +// Features I don't want, remove to save space +// #define NO_ACTION_ONESHOT // Used by caps word +#define NO_ACTION_FUNCTION +#define NO_ACTION_MACRO +#define NO_USB_STARTUP_CHECK diff --git a/keyboards/handwired/dactyl_manuform/3x5_3/keymaps/dlford/features/caps_word.c b/keyboards/handwired/dactyl_manuform/3x5_3/keymaps/dlford/features/caps_word.c new file mode 100644 index 0000000000..ee295c7305 --- /dev/null +++ b/keyboards/handwired/dactyl_manuform/3x5_3/keymaps/dlford/features/caps_word.c @@ -0,0 +1,76 @@ +// 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. +// +// +// For full documentation, see +// https://getreuer.info/posts/keyboards/caps-word + +#include "caps_word.h" +bool caps_word_enabled = false; + +bool process_caps_word(uint16_t keycode, keyrecord_t* record) { + static bool shifted = false; + + 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(); + 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 (!shifted) { register_code(KC_LSFT); } + 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 (shifted) { unregister_code(KC_LSFT); } + shifted = false; + return true; + + // Any other keycode disables caps word. + } + } + + // Disable caps word. + caps_word_enabled = false; + if (shifted) { unregister_code(KC_LSFT); } + shifted = false; + return true; +} + diff --git a/keyboards/handwired/dactyl_manuform/3x5_3/keymaps/dlford/features/caps_word.h b/keyboards/handwired/dactyl_manuform/3x5_3/keymaps/dlford/features/caps_word.h new file mode 100644 index 0000000000..a609a32544 --- /dev/null +++ b/keyboards/handwired/dactyl_manuform/3x5_3/keymaps/dlford/features/caps_word.h @@ -0,0 +1,36 @@ +// 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. +// +// +// Caps Word, activated by pressing both shift keys at the same time. +// +// This library implements "Caps Word", which is like conventional Caps Lock, +// but automatically disables itself at the end of the word. This is useful for +// typing all-caps identifiers like `MOD_MASK_ALT`. +// +// Caps Word is activated by pressing the left and right shift keys at the same +// time. This way you don't need a dedicated key for using Caps Word. I've +// tested that this works as expected with one-shot mods and Space Cadet Shift. +// If your shift keys are mod-taps, activate Caps Word by holding both shift +// mod-tap keys until the tapping term, release them, then begin typing. +// +// For full documentation, see +// https://getreuer.info/posts/keyboards/caps-word + +#pragma once + +#include QMK_KEYBOARD_H + +bool process_caps_word(uint16_t keycode, keyrecord_t* record); +extern bool caps_word_enabled; diff --git a/keyboards/handwired/dactyl_manuform/3x5_3/keymaps/dlford/keymap.c b/keyboards/handwired/dactyl_manuform/3x5_3/keymaps/dlford/keymap.c new file mode 100644 index 0000000000..b403c2ce3b --- /dev/null +++ b/keyboards/handwired/dactyl_manuform/3x5_3/keymaps/dlford/keymap.c @@ -0,0 +1,385 @@ +/* +Copyright 2019 @foostan +Copyright 2020 Drashna Jaelre <@drashna> +Copyright 2021 @dlford + +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 QMK_KEYBOARD_H +#include "features/caps_word.h" + +// Layers +enum layers { + _QWERTY = 0, + _COLEMAK, + _NAVIGATION, + _SPECIAL, + _MOUSE, +}; + +static uint16_t default_animation = RGB_MATRIX_CYCLE_SPIRAL; +static int default_speed = 50; +static uint16_t secondary_animation = RGB_MATRIX_HUE_WAVE; +static int secondary_speed = 150; +static bool is_macro_recording = false; + +// Init +void keyboard_post_init_user(void) { + rgb_matrix_sethsv_noeeprom(HSV_PURPLE); + rgb_matrix_mode_noeeprom(default_animation); + rgb_matrix_set_speed_noeeprom(default_speed); +} + +// Permissive hold per key +bool get_permissive_hold(uint16_t keycode, keyrecord_t *record) { + switch (keycode) { + case LT(3, KC_SPC): + return true; // Enable permissive hold + case LT(2, KC_TAB): + return true; + default: + return false; // Disable permissive hold + } +} + +// Tapping force hold per key +bool get_tapping_force_hold(uint16_t keycode, keyrecord_t *record) { + switch (keycode) { + case LT(3, KC_SPC): + return true; // Enable force hold + case LT(2, KC_TAB): + return true; + default: + return false; // Disable force hold + } +} + +// Tapping term per key +uint16_t get_tapping_term(uint16_t keycode, keyrecord_t *record) { + switch (keycode) { + case C_S_T(KC_E): + case C_S_T(KC_I): + return 215; + default: + return 190; + } +} + +// RGB timeout +#define RGB_CUSTOM_TIMEOUT 5 // in minutes +static uint16_t idle_timer = 0; +static uint8_t halfmin_counter = 0; +static bool led_on = true; +void matrix_scan_user(void) { + if (is_keyboard_master()) { + // idle_timer needs to be set one time + if (idle_timer == 0) idle_timer = timer_read(); + + if (led_on && timer_elapsed(idle_timer) > 30000) { + halfmin_counter++; + idle_timer = timer_read(); + } + + if (led_on && halfmin_counter >= RGB_CUSTOM_TIMEOUT * 2) { + rgb_matrix_disable_noeeprom(); + led_on = false; + halfmin_counter = 0; + } + } +} + +// Macros +enum macro_events { + M_KEYMAP = SAFE_RANGE, + M_COMM, + M_DOT, +}; + +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + // RGB resume + if (is_keyboard_master()) { + if (record->event.pressed) { + if (led_on == false) { + rgb_matrix_enable_noeeprom(); + led_on = true; + } + idle_timer = timer_read(); + halfmin_counter = 0; + } + } + + // Caps word + if (!process_caps_word(keycode, record)) { return false; } + + // Macros + const uint8_t mods = get_mods(); + static uint8_t backstepCounter = 0; + static bool keyDown = false; + switch (keycode) { + case M_KEYMAP: + if (record->event.pressed) { + SEND_STRING("https://raw.githubusercontent.com/dlford/qmk_firmware/master/keyboards/crkbd/keymaps/dlford/legends.svg"); + } + return false; + case M_COMM: + if (record->event.pressed) { + if ((mods & MOD_BIT(KC_LCTL)) && (mods & MOD_BIT(KC_LSFT) && (mods & MOD_BIT(KC_LALT)))) { + backstepCounter = 1; + clear_mods(); + SEND_STRING("<>"); + } else if ((mods & MOD_BIT(KC_LCTL)) && (mods & MOD_BIT(KC_LALT))) { + backstepCounter = 1; + clear_mods(); + SEND_STRING("()"); + } else if ((mods & MOD_BIT(KC_LCTL)) && (mods & MOD_BIT(KC_LSFT))) { + backstepCounter = 2; + clear_mods(); + SEND_STRING("{};"); + } else if (mods & MOD_BIT(KC_LCTL)) { + backstepCounter = 1; + clear_mods(); + SEND_STRING("{}"); + } else if ((mods & MOD_BIT(KC_LALT)) && (mods & MOD_BIT(KC_LSFT))) { + backstepCounter = 2; + clear_mods(); + SEND_STRING("[];"); + } else if (mods & MOD_BIT(KC_LALT)) { + backstepCounter = 1; + clear_mods(); + SEND_STRING("[]"); + } else { + keyDown = true; + register_code(KC_COMM); + return true; + } + if (backstepCounter) { + while (backstepCounter > 0) { + tap_code(KC_LEFT); + backstepCounter--; + } + set_mods(mods); + } + } else { + if (keyDown) { + unregister_code(KC_COMM); + keyDown = false; + return true; + } + } + return false; + case M_DOT: + if (record->event.pressed) { + if (mods & MOD_BIT(KC_LCTL)) { + clear_mods(); + SEND_STRING("=>"); + } else if (mods & MOD_BIT(KC_LALT)) { + clear_mods(); + SEND_STRING("->"); + } else { + keyDown = true; + register_code(KC_DOT); + return true; + } + } else { + if (keyDown) { + unregister_code(KC_DOT); + keyDown = false; + return true; + } + } + set_mods(mods); + return false; + } + + return true; +} + +// RGB Layers (Enable animations in config.h) +layer_state_t layer_state_set_user(layer_state_t state) { + switch (get_highest_layer(state)) { + case _SPECIAL: + rgb_matrix_sethsv_noeeprom(HSV_ORANGE); + rgb_matrix_set_speed_noeeprom(secondary_speed); + rgb_matrix_mode_noeeprom(secondary_animation); + break; + case _NAVIGATION: + rgb_matrix_sethsv_noeeprom(HSV_BLUE); + rgb_matrix_set_speed_noeeprom(secondary_speed); + rgb_matrix_mode_noeeprom(secondary_animation); + break; + case _MOUSE: + rgb_matrix_sethsv_noeeprom(HSV_GREEN); + rgb_matrix_set_speed_noeeprom(secondary_speed); + rgb_matrix_mode_noeeprom(secondary_animation); + break; + default: + rgb_matrix_sethsv_noeeprom(HSV_PURPLE); + rgb_matrix_set_speed_noeeprom(default_speed); + rgb_matrix_mode_noeeprom(default_animation); + break; + } + return state; +} + +// Dynamic Macro Recording Backlight +void dynamic_macro_record_start_user(void) { + is_macro_recording = true; +} + +void dynamic_macro_record_end_user(int8_t direction) { + is_macro_recording = false; +} + +// Indicators +void rgb_matrix_indicators_user(void) { + if (host_keyboard_led_state().caps_lock || caps_word_enabled) { + // Left master + rgb_matrix_set_color(3, RGB_RED); + // Right master + rgb_matrix_set_color(21, RGB_RED); + } + if (is_macro_recording) { + // Left master + rgb_matrix_set_color(4, RGB_ORANGE); + // Right master + rgb_matrix_set_color(22, RGB_ORANGE); + } + if (default_layer_state - 1 == _COLEMAK) { + // Left master + rgb_matrix_set_color(5, RGB_GREEN); + // Right master + rgb_matrix_set_color(23, RGB_GREEN); + } +} + +// Quantum keys / Abbreviations +enum custom_keycodes { + VVV = KC_TRNS, + XXX = KC_NO, + CSA_Q = MEH_T(KC_Q), + CSA_F1 = MEH_T(KC_F1), + CSA_1 = MEH_T(KC_1), + CA_W = LCA_T(KC_W), + CA_F2 = LCA_T(KC_F2), + CA_2 = LCA_T(KC_2), + CS_E = C_S_T(KC_E), + CS_F = C_S_T(KC_F), + CS_I = C_S_T(KC_I), + CS_U = C_S_T(KC_U), + CS_F3 = C_S_T(KC_F3), + CS_3 = C_S_T(KC_3), + CS_F8 = C_S_T(KC_F8), + CS_8 = C_S_T(KC_8), + CA_O = LCA_T(KC_O), + CA_Y = LCA_T(KC_Y), + CA_F9 = LCA_T(KC_F9), + CA_9 = LCA_T(KC_9), + CSA_P = MEH_T(KC_P), + CSA_SCLN = MEH_T(KC_SCLN), + CSA_F10 = MEH_T(KC_F10), + CSA_0 = MEH_T(KC_0), + LGUI_A = LGUI_T(KC_A), + LGUI_FIND = LGUI_T(KC_FIND), + LGUI_GRV = LGUI_T(KC_GRV), + LALT_S = LALT_T(KC_S), + LALT_R = LALT_T(KC_R), + LALT_HOME = LALT_T(KC_HOME), + LCTL_D = LCTL_T(KC_D), + LCTL_S = LCTL_T(KC_S), + LCTL_PGUP = LCTL_T(KC_PGUP), + LCTL_LBRC = LCTL_T(KC_LBRC), + LSFT_F = LSFT_T(KC_F), + _LSFT_T = LSFT_T(KC_T), + LSFT_PGDN = LSFT_T(KC_PGDN), + LSFT_RBRC = LSFT_T(KC_RBRC), + RSFT_J = RSFT_T(KC_J), + RSFT_N = RSFT_T(KC_N), + RSFT_DOWN = RSFT_T(KC_DOWN), + RSFT_MINS = RSFT_T(KC_MINS), + RCTL_K = RCTL_T(KC_K), + RCTL_E = RCTL_T(KC_E), + RCTL_UP = RCTL_T(KC_UP), + RCTL_EQL = RCTL_T(KC_EQL), + RALT_L = RALT_T(KC_L), + RALT_I = RALT_T(KC_I), + RALT_RGHT = RALT_T(KC_RGHT), + RALT_BSLS = RALT_T(KC_BSLS), + RGUI_SCLN = RGUI_T(KC_SCLN), + RGUI_O = RGUI_T(KC_O), + RGUI_F11 = RGUI_T(KC_F11), + RGUI_QUOT = RGUI_T(KC_QUOT), + LT3_SPC = LT(3,KC_SPC), + LT2_TAB = LT(2,KC_TAB), + DF_QWERTY = DF(0), + DF_COLEMAK = DF(1), +}; + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + [_QWERTY] = LAYOUT_split_3x5_3( + //|--------------------------------------------| |--------------------------------------------| + CSA_Q, CA_W, CS_E, KC_R, KC_T, KC_Y, KC_U, CS_I, CA_O, CSA_P, + //|--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------| + LGUI_A, LALT_S, LCTL_D, LSFT_F, KC_G, KC_H, RSFT_J, RCTL_K, RALT_L, RGUI_SCLN, + //|--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------| + KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, M_COMM, M_DOT, KC_SLSH, + //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------| + KC_ESC, LT3_SPC, KC_BSPC, KC_DEL, LT2_TAB, KC_ENT + // |--------+--------+--------| |--------+--------+--------| + ), + [_COLEMAK] = LAYOUT_split_3x5_3( + //|--------------------------------------------| |--------------------------------------------| + CSA_Q, CA_W, CS_F, KC_P, KC_G, KC_J, KC_L, CS_U, CA_Y, CSA_SCLN, + //|--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------| + LGUI_A, LALT_R, LCTL_S, _LSFT_T, KC_D, KC_H, RSFT_N, RCTL_E, RALT_I, RGUI_O, + //|--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------| + KC_Z, KC_X, KC_C, KC_V, KC_B, KC_K, KC_M, M_COMM, M_DOT, KC_SLSH, + //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------| + KC_ESC, LT3_SPC, KC_BSPC, KC_DEL, LT2_TAB, KC_ENT + // |--------+--------+--------| |--------+--------+--------| + ), + [_NAVIGATION] = LAYOUT_split_3x5_3( + //|--------------------------------------------| |--------------------------------------------| + CSA_F1, CA_F2, CS_F3, KC_F4, KC_F5, KC_F6, KC_F7, CS_F8, CA_F9, CSA_F10, + //|--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------| + LGUI_FIND,LALT_HOME,LCTL_PGUP,LSFT_PGDN,KC_END, KC_LEFT,RSFT_DOWN,RCTL_UP,RALT_RGHT,RGUI_F11, + //|--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------| + DF_QWERTY,DF_COLEMAK,KC_VOLD, KC_VOLU, RESET, KC_MUTE, KC_MPLY, KC_MPRV, KC_MNXT, KC_F12, + //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------| + VVV, TG(4), VVV, VVV, VVV, VVV + // |--------+--------+--------| |--------+--------+--------| + ), + [_SPECIAL] = LAYOUT_split_3x5_3( + //|--------------------------------------------| |--------------------------------------------| |