From 97dfdcb2bd5013259f8500bcd31aaaa4826145c6 Mon Sep 17 00:00:00 2001 From: gourdo1 Date: Sat, 2 Jul 2022 07:11:26 -0700 Subject: [keymap] Update gourdo1 keymap for Q2 changes (#17398) --- users/gourdo1/custom_double_taps.h | 73 +++++ users/gourdo1/gourdo1.c | 568 +++++++++++++++++++++++++------------ users/gourdo1/gourdo1.h | 68 +++-- users/gourdo1/gourdo1_encoder.c | 4 +- 4 files changed, 503 insertions(+), 210 deletions(-) create mode 100644 users/gourdo1/custom_double_taps.h (limited to 'users/gourdo1') diff --git a/users/gourdo1/custom_double_taps.h b/users/gourdo1/custom_double_taps.h new file mode 100644 index 0000000000..4f551e1fa1 --- /dev/null +++ b/users/gourdo1/custom_double_taps.h @@ -0,0 +1,73 @@ +// Copyright 2022 Google LLC +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include "gourdo1.h" + +static bool process_capsnum(uint16_t keycode, keyrecord_t * record) { + static bool toggled = false; + static bool tapped = false; + static uint16_t tap_timer = 0; + + if (keycode == CAPSNUM) { + if (user_config.double_tap_shift_for_capslock) { + // Act as TT(_NUMPADMOUSE) + if (record -> event.pressed) { // CAPSNUM key was pressed + // Check whether the key was recently tapped + if (tapped && !timer_expired(record -> event.time, tap_timer)) { + // This is a double tap (or possibly a triple tap or more) + // Toggle the layer on. + toggled = true; + } else if (toggled) { + // Otherwise if currently toggled, turn it off + toggled = false; + tapped = false; + layer_off(_NUMPADMOUSE); + } + // Set that the first tap occurred in a potential double tap + tapped = true; + tap_timer = record -> event.time + TAPPING_TERM; + layer_on(_NUMPADMOUSE); + } else if (!toggled) { + // If not currently toggled, turn off on key release + layer_off(_NUMPADMOUSE); + return false; + } + } else { // When double_tap_shift_for_capslock == false + // Act as KC_CAPS + if (record -> event.pressed) { + register_code(KC_CAPS); + } else { + unregister_code(KC_CAPS); + } + } + return false; + } else { + // On an event with any other key, reset the double tap state + tapped = false; + } + return true; +} + +static bool process_esc_to_base(uint16_t keycode, keyrecord_t * record) { + static bool tapped = false; + static uint16_t tap_timer = 0; + + if (keycode == KC_ESC) { + if (user_config.esc_double_tap_to_baselyr) { + if (record -> event.pressed) { + if (tapped && !timer_expired(record -> event.time, tap_timer)) { + // The key was double tapped. + layer_clear(); + } + tapped = true; + tap_timer = record -> event.time + TAPPING_TERM; + } + } + } else { + // On an event with any other key, reset the double tap state. + tapped = false; + } + return true; +} diff --git a/users/gourdo1/gourdo1.c b/users/gourdo1/gourdo1.c index b964729be9..9062a452ff 100644 --- a/users/gourdo1/gourdo1.c +++ b/users/gourdo1/gourdo1.c @@ -1,6 +1,6 @@ /* Copyright 2021 Jonavin Eng @Jonavin - Copyright 2022 gourdo1 - + Copyright 2022 gourdo1 + 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 @@ -19,35 +19,35 @@ along with this program. If not, see . #include "gourdo1.h" -#include "caps_word.h" +#include "custom_double_taps.h" -#ifdef TD_LSFT_CAPSLOCK_ENABLE -// Tap once for shift, twice for Caps Lock but only if Win Key in not disabled +// Tap once for shift, twice for Caps Lock but only if Win Key is not disabled (also disabled by user.config variable) void dance_LSFT_each_tap(qk_tap_dance_state_t * state, void * user_data) { - if (state -> count == 1 || keymap_config.no_gui) { - register_code16(KC_LSFT); + if (user_config.double_tap_shift_for_capslock) { + if (state -> count == 1 || keymap_config.no_gui) { + register_code(KC_LSFT); + } else { + register_code(KC_CAPS); + } } else { - register_code(KC_CAPS); + register_code(KC_LSFT); } } void dance_LSFT_reset(qk_tap_dance_state_t * state, void * user_data) { if (state -> count == 1 || keymap_config.no_gui) { - unregister_code16(KC_LSFT); + unregister_code(KC_LSFT); } else { unregister_code(KC_CAPS); - unregister_code16(KC_LSFT); + unregister_code(KC_LSFT); } } + // Tap Dance definitions qk_tap_dance_action_t tap_dance_actions[] = { // Tap once for shift, twice for Caps Lock - [TD_LSFT_CAPSLOCK] = ACTION_TAP_DANCE_DOUBLE(KC_LSFT, KC_CAPS), - [TD_LSFT_CAPS_WIN] = ACTION_TAP_DANCE_FN_ADVANCED(dance_LSFT_each_tap, NULL, dance_LSFT_reset), - // Tap once for Escape, twice to reset to base layer - [TD_ESC_BASELYR] = ACTION_TAP_DANCE_DUAL_ROLE(KC_ESC, _BASE), + [TD_LSFT_CAPS_WIN] = ACTION_TAP_DANCE_FN_ADVANCED(dance_LSFT_each_tap, NULL, dance_LSFT_reset) }; -#endif // TD_LSFT_CAPSLOCK_ENABLE // RGB NIGHT MODE #ifdef RGB_MATRIX_ENABLE @@ -126,209 +126,373 @@ __attribute__((weak)) bool process_record_keymap(uint16_t keycode, keyrecord_t * bool process_record_user(uint16_t keycode, keyrecord_t * record) { mod_state = get_mods(); - if (!process_record_keymap(keycode, record)) { - return false; - } - - if (!process_caps_word(keycode, record)) { - return false; - } + if (!process_record_keymap(keycode, record)) { return false; } + if (!process_capsnum(keycode, record)) { return false; } + if (!process_esc_to_base(keycode, record)) { return false; } - // Your macros ... + // Key macros ... switch (keycode) { - // DotCom domain macros + // User configuration toggles + case PRNCONF: // Print verbose status of all user_config toggles (open a text editor before engaging!!) + if (record->event.pressed) { + //send_string("Left bracket with alt numcodes "SS_LALT(SS_TAP(X_KP_0) SS_TAP(X_KP_0) SS_TAP(X_KP_9) SS_TAP(X_KP_1))"\n"); + send_string("\n\x2D\x2D\x2D\x2D\x2D\x2D\x2D\x2D\x2D\x3C\x3C\x3C\x3C\x3C\x3C\x3C\x3C\x3C"); + send_string(" gourdo1\x27s GMMK Pro User Settings "); + send_string("\x3E\x3E\x3E\x3E\x3E\x3E\x3E\x3E\x3E\x2D\x2D\x2D\x2D\x2D\x2D\x2D\x2D\x2D\n"); + send_string("Hold \x5B \bFn\x5D and the number corresponding to a setting below to toggle.\n"); + send_string("Re-print this screen with \x5B \bFn\x5D \x5B`\x5D to see your changes reflected.\n"); + send_string("Config also visible as RGB under number keys by holding \x5B \bFn\x5D.\n"); + send_string("\x3d\x3d\x3d\x3d\x3d\x3d\x3d\x3d\x3d\x3d\x3d\x3d\x3d\x3d\x3d\x3d\x3d\x3d\x3d\x3d"); + send_string("\x3d\x3d\x3d\x3d\x3d\x3d\x3d\x3d\x3d\x3d\x3d\x3d\x3d\x3d\x3d\x3d\x3d\x3d\x3d\x3d"); + send_string("\x3d\x3d\x3d\x3d\x3d\x3d\x3d\x3d\x3d\x3d\x3d\x3d\x3d\x3d\x3d\x3d\x3d\x3d\x3d\x3d"); + send_string("\x3d\x3d\x3d\x3d\x3d\x3d\x3d\x3d\x3d\x3d\n"); + send_string("1. CapsLock RGB highlight alpha keys................ "); + if (user_config.rgb_hilite_caps) { + send_string("\x5BON\x5D\n"); + } else { + send_string("\x5BOFF\x5D\n"); + } + send_string("2. Numpad RGB highlight layer keys.................. "); + if (user_config.rgb_hilite_numpad) { + send_string("\x5BON\x5D\n"); + } else { + send_string("\x5BOFF\x5D\n"); + } + send_string("3. Double tap ESC to revert to BASE layer........... "); + if (user_config.esc_double_tap_to_baselyr) { + send_string("\x5BON\x5D\n"); + } else { + send_string("\x5BOFF\x5D\n"); + } + send_string("4. DEL \x26 HOME key locations......................... "); + if (user_config.del_right_home_top) { + send_string("\x5BHOME on F13\x3B DEL right of BKSPC\x5D\n"); + } else { + send_string("\x5B \bDEL on F13\x3B HOME right of BKSPC\x5D\n"); + } + send_string("5. Numpad on CapsLock\x3B double tap LSHIFT for Caps... "); + if (user_config.double_tap_shift_for_capslock) { + send_string("\x5BON\x5D\n"); + } else { + send_string("\x5BOFF\x5D\n"); + } + send_string("6. Encoder button function.......................... "); + if (user_config.encoder_press_mute_or_media) { + send_string("\x5BMUTE\x5D\n"); + } else { + send_string("\x5BMEDIA PLAY\x2FPAUSE\x5D\n"); + } + send_string("7. Insert function accessed with.................... "); + if (user_config.ins_on_shft_bkspc_or_del) { + send_string("\x5BSHIFT\x2D \bBKSPC\x5D\n"); + } else { + send_string("\x5BSHIFT\x2D \bDEL\x5D\n"); + } + send_string("8. Force SHIFT \x26 CTRL\x2DSPACE to function like SPACE.. "); + if (user_config.disable_space_mods) { + send_string("\x5BON\x5D\n"); + } else { + send_string("\x5BOFF\x5D\n"); + } + send_string("\nThe latest firmware updates are always here\x3a https\x3a\x2F\x2Fgithub.com\x2Fgourdo1\x2Fgmmkpro\x2Dmedia\n"); + } + break; + + case TG_CAPS: // Toggle RGB highlighting of Capslock state + if (record->event.pressed) { + user_config.rgb_hilite_caps ^= 1; // Toggles the status + eeconfig_update_user(user_config.raw); // Writes the new status to EEPROM + } + break; + case TG_PAD: // Toggle RGB highlighting of Numpad state + if (record->event.pressed) { + user_config.rgb_hilite_numpad ^= 1; // Toggles the status + eeconfig_update_user(user_config.raw); // Writes the new status to EEPROM + } + break; + case TG_ESC: // Toggle alternate ESC functionality + if (record->event.pressed) { + user_config.esc_double_tap_to_baselyr ^= 1; // Toggles the status + eeconfig_update_user(user_config.raw); // Writes the new status to EEPROM + } + break; + case TG_DEL: // Toggle alternate placement of DEL and HOME keys + if (record->event.pressed) { + user_config.del_right_home_top ^= 1; // Toggles the status + eeconfig_update_user(user_config.raw); // Writes the new status to EEPROM + } + break; + case TG_TDCAP: // Toggle alternate Capslock/Numpad functionality + if (record->event.pressed) { + user_config.double_tap_shift_for_capslock ^= 1; // Toggles the status + eeconfig_update_user(user_config.raw); // Writes the new status to EEPROM + } + break; + case TG_ENC: // Toggle Encoder function + if (record->event.pressed) { + user_config.encoder_press_mute_or_media ^= 1; // Toggles the status + eeconfig_update_user(user_config.raw); // Writes the new status to EEPROM + } + break; + case TG_INS: // Toggle Encoder function + if (record->event.pressed) { + user_config.ins_on_shft_bkspc_or_del ^= 1; // Toggles the status + eeconfig_update_user(user_config.raw); // Writes the new status to EEPROM + } + break; + case TG_SPCMOD: // Toggle forcing SHIFT&CTRL-SPACE to function like SPACE + if (record->event.pressed) { + user_config.disable_space_mods ^= 1; // Toggles the status + eeconfig_update_user(user_config.raw); // Writes the new status to EEPROM + } + break; + //return false; + + // Key to the left of encoder function (default HOME) + case LEFTOFENC: + if (!(user_config.del_right_home_top)) { + if (!(user_config.ins_on_shft_bkspc_or_del)) { + static bool inskey_registered; + if (record -> event.pressed) { + // Detect the activation of either shift keys + if (mod_state & MOD_MASK_SHIFT) { + // First temporarily canceling both shifts so that + // shift isn't applied to the KC_INS keycode + del_mods(MOD_MASK_SHIFT); + register_code(KC_INS); + // Update the boolean variable to reflect the status of KC_INS + inskey_registered = true; + // Reapplying modifier state so that the held shift key(s) + // still work even after having tapped the key. + set_mods(mod_state); + return false; + } else { + register_code(KC_DEL); + return false; + } + } else { // on release of KC_DEL + // In case KC_INS is still being sent even after the release of KC_DEL + if (inskey_registered) { + unregister_code(KC_INS); + inskey_registered = false; + return false; + } else { + unregister_code(KC_DEL); + return false; + } + } + } else { + if (record -> event.pressed) { + register_code(KC_DEL); + return false; + } else { + unregister_code(KC_DEL); + return false; + } + } + } else { + if (record -> event.pressed) { + register_code(KC_HOME); + return false; + } else { + unregister_code(KC_HOME); + return false; + } + } + break; + + // Key below encoder function (default DEL) + case BELOWENC: + if (user_config.del_right_home_top) { + if (!(user_config.ins_on_shft_bkspc_or_del)) { + static bool inskey_registered; + if (record -> event.pressed) { + // Detect the activation of either shift keys + if (mod_state & MOD_MASK_SHIFT) { + // First temporarily canceling both shifts so that + // shift isn't applied to the KC_INS keycode + del_mods(MOD_MASK_SHIFT); + register_code(KC_INS); + // Update the boolean variable to reflect the status of KC_INS + inskey_registered = true; + // Reapplying modifier state so that the held shift key(s) + // still work even after having tapped the key. + set_mods(mod_state); + return false; + } else { + register_code(KC_DEL); + return false; + } + } else { // on release of KC_DEL + // In case KC_INS is still being sent even after the release of KC_DEL + if (inskey_registered) { + unregister_code(KC_INS); + inskey_registered = false; + return false; + } else { + unregister_code(KC_DEL); + return false; + } + } + } else { + if (record -> event.pressed) { + register_code(KC_DEL); + return false; + } else { + unregister_code(KC_DEL); + return false; + } + } + } else { + if (record -> event.pressed) { + register_code(KC_HOME); + return false; + } else { + unregister_code(KC_HOME); + return false; + } + } + break; + + // Encoder button function + case ENCFUNC: + if (user_config.encoder_press_mute_or_media) { + if (record -> event.pressed) { + register_code(KC_MUTE); + } else unregister_code16(keycode); + } + else { + if (record -> event.pressed) { + register_code(KC_MPLY); + } else unregister_code16(keycode); + } + break; + + // DotCom domain macros case DOTCOM: if (record -> event.pressed) { - SEND_STRING(".com"); + send_string(".com"); } else { // when keycode is released } break; case YAHOO: if (record -> event.pressed) { - SEND_STRING("yahoo.com"); + send_string("yahoo.com"); } else { // when keycode is released } break; case OUTLOOK: if (record -> event.pressed) { - SEND_STRING("outlook.com"); + send_string("outlook.com"); } else { // when keycode is released } break; case GMAIL: if (record -> event.pressed) { - SEND_STRING("gmail.com"); + send_string("gmail.com"); } else { // when keycode is released } break; case HOTMAIL: if (record -> event.pressed) { - SEND_STRING("hotmail.com"); + send_string("hotmail.com"); } else { // when keycode is released } break; - -/* - case YAHOO: - if (record -> event.pressed) SEND_STRING("yahoo.com"); - else unregister_code16(keycode); - break; - case OUTLOOK: - if (record -> event.pressed) SEND_STRING("outlook.com"); - else unregister_code16(keycode); - break; - case GMAIL: - if (record -> event.pressed) SEND_STRING("gmail.com"); - else unregister_code16(keycode); - break; - case HOTMAIL: - if (record -> event.pressed) { - SEND_STRING("hotmail.com"); - } else unregister_code16(keycode); - break; - case DOTCOM: - if (record -> event.pressed) SEND_STRING(".com"); - else unregister_code16(keycode); - break; -*/ - // Windows key lock - case KC_WINLCK: + // Windows Key lockout + case WINLOCK: if (record -> event.pressed) { keymap_config.no_gui = !keymap_config.no_gui; //toggle status } else unregister_code16(keycode); break; - // Double Zero + // Double Zero case KC_00: if (record -> event.pressed) { // when keycode KC_00 is pressed - SEND_STRING("00"); + send_string("00"); } else unregister_code16(keycode); break; - // Treat Control+Space as if regular Space - case KC_SPC: { - // Initialize a boolean variable that keeps track of the space key status: registered or not? - static bool spckey_registered; - if (record -> event.pressed) { - // Detect the activation of either ctrl keys - if (mod_state & MOD_MASK_CTRL) { - // First temporarily canceling both ctrls so that - // ctrl isn't applied to the KC_SPC keycode - del_mods(MOD_MASK_CTRL); - register_code(KC_SPC); - // Update the boolean variable to reflect the status of KC_SPC - spckey_registered = true; - // Reapplying modifier state so that the held ctrl key(s) - // still work even after having tapped the Space key. - set_mods(mod_state); - return false; - } - } else { // on release of KC_SPC - // In case KC_SPC is still being sent even after the release of KC_SPC - if (spckey_registered) { - unregister_code(KC_SPC); - spckey_registered = false; - return false; - } - } - } - break; - - // Treat Shift+Space as if regular Space - case KC_SHIFTSPC: { - // Initialize a boolean variable that keeps track of the space key status: registered or not? - static bool spc2key_registered; - if (record -> event.pressed) { - // Detect the activation of either shift keys - if (mod_state & MOD_MASK_SHIFT) { - // First temporarily canceling both shifts so that - // shift isn't applied to the KC_SPC keycode - del_mods(MOD_MASK_SHIFT); - register_code(KC_SPC); - // Update the boolean variable to reflect the status of KC_SPC - spc2key_registered = true; - // Reapplying modifier state so that the held shift key(s) - // still work even after having tapped the Space key. - set_mods(mod_state); - return false; - } - } else { // on release of KC_SPC - // In case KC_SPC is still being sent even after the release of KC_SPC - if (spc2key_registered) { - unregister_code(KC_SPC); - spc2key_registered = false; - return false; + // Treat Control & Shift-Space as if regular Space + case KC_SPC: + if (user_config.disable_space_mods) { + // Initialize a boolean variable that keeps track of the space key status: registered or not? + static bool spckey_registered; + if (record -> event.pressed) { + // Detect the activation of either ctrl keys + if (mod_state & MOD_MASK_CTRL) { + // First temporarily canceling both ctrls so that + // ctrl isn't applied to the KC_SPC keycode + del_mods(MOD_MASK_CTRL); + register_code(KC_SPC); + // Update the boolean variable to reflect the status of KC_SPC + spckey_registered = true; + // Reapplying modifier state so that the held ctrl key(s) + // still work even after having tapped the Space key. + set_mods(mod_state); + return false; + } + else if (mod_state & MOD_MASK_SHIFT) { + // First temporarily canceling both shifts so that + // shift isn't applied to the KC_SPC keycode + del_mods(MOD_MASK_SHIFT); + register_code(KC_SPC); + // Update the boolean variable to reflect the status of KC_SPC + spckey_registered = true; + // Reapplying modifier state so that the held shift key(s) + // still work even after having tapped the Space key. + set_mods(mod_state); + return false; + } + } else { // on release of KC_SPC + // In case KC_SPC is still being sent even after the release of KC_SPC + if (spckey_registered) { + unregister_code(KC_SPC); + spckey_registered = false; + return false; + } } } - } break; - // Add INS as SHIFT-modified BackSpace key + // INS as SHIFT-modified BackSpace key case KC_BSPC: { - // Initialize a boolean variable that keeps track of the delete key status: registered or not? - static bool inskey_registered; - if (record -> event.pressed) { - // Detect the activation of either shift keys - if (mod_state & MOD_MASK_SHIFT) { - // First temporarily canceling both shifts so that - // shift isn't applied to the KC_INS keycode - del_mods(MOD_MASK_SHIFT); - register_code(KC_INS); - // Update the boolean variable to reflect the status of KC_INS - inskey_registered = true; - // Reapplying modifier state so that the held shift key(s) - // still work even after having tapped the Delete/Insert key. - set_mods(mod_state); - return false; - } - } else { // on release of KC_BSPC - // In case KC_INS is still being sent even after the release of KC_BSPC - if (inskey_registered) { - unregister_code(KC_INS); - inskey_registered = false; - return false; + if (user_config.ins_on_shft_bkspc_or_del) { + // Initialize a boolean variable that keeps track of the ins key status: registered or not? + static bool inskey_registered; + if (record -> event.pressed) { + // Detect the activation of either shift keys + if (mod_state & MOD_MASK_SHIFT) { + // First temporarily canceling both shifts so that + // shift isn't applied to the KC_INS keycode + del_mods(MOD_MASK_SHIFT); + register_code(KC_INS); + // Update the boolean variable to reflect the status of KC_INS + inskey_registered = true; + // Reapplying modifier state so that the held shift key(s) + // still work even after having tapped the key. + set_mods(mod_state); + return false; + } + } else { // on release of KC_BSPC + // In case KC_INS is still being sent even after the release of KC_BSPC + if (inskey_registered) { + unregister_code(KC_INS); + inskey_registered = false; + return false; + } } } - } - break; - - /* Add INS as SHIFT-modified DEL key - case KC_DEL: { - // Initialize a boolean variable that keeps track of the delete key status: registered or not? - static bool inskey_registered; - if (record->event.pressed) { - // Detect the activation of either shift keys - if (mod_state & MOD_MASK_SHIFT) { - // First temporarily canceling both shifts so that - // shift isn't applied to the KC_INS keycode - del_mods(MOD_MASK_SHIFT); - register_code(KC_INS); - // Update the boolean variable to reflect the status of KC_INS - inskey_registered = true; - // Reapplying modifier state so that the held shift key(s) - // still work even after having tapped the Delete/Insert key. - set_mods(mod_state); - return false; - } - } else { // on release of KC_DEL - // In case KC_INS is still being sent even after the release of KC_DEL - if (inskey_registered) { - unregister_code(KC_INS); - inskey_registered = false; - return false; - } - } - } - break; - */ + } + break; #ifdef IDLE_TIMEOUT_ENABLE case RGB_TOI: @@ -352,27 +516,27 @@ bool process_record_user(uint16_t keycode, keyrecord_t * record) { #ifdef EMOTICON_ENABLE case EMO_SHRUG: - if (record -> event.pressed) SEND_STRING("`\\_(\"/)_/`"); + if (record -> event.pressed) send_string("`\\_(\"/)_/`"); else unregister_code16(keycode); break; case EMO_CONFUSE: - if (record -> event.pressed) SEND_STRING("(*_*)"); + if (record -> event.pressed) send_string("(*_*)"); else unregister_code16(keycode); break; case EMO_TEARS: - if (record -> event.pressed) SEND_STRING("(T_T)"); + if (record -> event.pressed) send_string("(T_T)"); else unregister_code16(keycode); break; case EMO_NERVOUS: - if (record -> event.pressed) SEND_STRING("(~_~;)"); + if (record -> event.pressed) send_string("(~_~;)"); else unregister_code16(keycode); break; case EMO_JOY: - if (record -> event.pressed) SEND_STRING("(^o^)"); + if (record -> event.pressed) send_string("(^o^)"); else unregister_code16(keycode); break; case EMO_SAD: - if (record -> event.pressed) SEND_STRING(":'-("); + if (record -> event.pressed) send_string(":'-("); else unregister_code16(keycode); break; #endif // EMOTICON_ENABLE @@ -398,15 +562,32 @@ bool process_record_user(uint16_t keycode, keyrecord_t * record) { return true; }; -uint16_t get_tapping_term(uint16_t keycode, keyrecord_t * record) { +// Define custom Caps Word continuity characters +bool caps_word_press_user(uint16_t keycode) { switch (keycode) { - case KC_SFTUP: - return 300; - case KC_RAISESPC: - case KC_LOWERSPC: - return 450; - default: - return TAPPING_TERM; + // Keycodes that continue Caps Word, with shift applied. + case KC_A ... KC_Z: + case KC_TILD: + case KC_UNDS: + case KC_DQT: + case KC_COLN: + case KC_RSFT: + case LSFTCAPSWIN: + add_weak_mods(MOD_BIT(KC_LSFT)); // Apply shift to next key. + return true; + + // Keycodes that continue Caps Word, without shifting. + case KC_1 ... KC_0: + case KC_GRV: + case KC_MINS: + case KC_QUOT: + case KC_SCLN: + case KC_BSPC: + case KC_DEL: + return true; + + default: + return false; // Deactivate Caps Word. } } @@ -418,15 +599,32 @@ void activate_numlock(bool turn_on) { } // INITIAL STARTUP - -__attribute__((weak)) void keyboard_post_init_keymap(void) {} +__attribute__((weak)) void keyboard_post_init_keymap(void) { +} void keyboard_post_init_user(void) { + // Read the user config from EEPROM + user_config.raw = eeconfig_read_user(); keyboard_post_init_keymap(); #ifdef STARTUP_NUMLOCK_ON activate_numlock(true); // turn on Num lock by default so that the numpad layer always has predictable results - #endif // STARTUP_NUMLOC_ON + #endif // STARTUP_NUMLOCK_ON #ifdef IDLE_TIMEOUT_ENABLE - timeout_timer = timer_read(); // set inital time for ide timeout + timeout_timer = timer_read(); // set initial time for idle timeout #endif -} \ No newline at end of file +} + +/* Set defaults for EEPROM user configuration variables */ +void eeconfig_init_user(void) { + user_config.raw = 0; + user_config.rgb_hilite_caps = true; + user_config.rgb_hilite_numpad = true; + user_config.double_tap_shift_for_capslock = true; + user_config.del_right_home_top = true; + user_config.encoder_press_mute_or_media = true; + user_config.esc_double_tap_to_baselyr = true; + user_config.ins_on_shft_bkspc_or_del = true; + user_config.disable_space_mods = true; + + eeconfig_update_user(user_config.raw); +} diff --git a/users/gourdo1/gourdo1.h b/users/gourdo1/gourdo1.h index c6861ca0ca..aa91a192d2 100644 --- a/users/gourdo1/gourdo1.h +++ b/users/gourdo1/gourdo1.h @@ -1,5 +1,5 @@ /* Copyright 2021 Jonavin Eng @Jonavin - Copyright 2022 gourdo1 + Copyright 2022 gourdo1 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 @@ -20,36 +20,49 @@ along with this program. If not, see . // DEFINE MACROS #define ARRAYSIZE(arr) sizeof(arr) / sizeof(arr[0]) -// LAYERS +// LAYERS -- Note: to avoid compile problems, make sure total layers matches DYNAMIC_KEYMAP_LAYER_COUNT defined in config.h (where _COLEMAK layer is defined) enum custom_user_layers { _BASE, _FN1, _NUMPADMOUSE, _MOUSEKEY, + #ifdef GAME_ENABLE + _GAME + #endif //GAME_ENABLE }; #define KC_CAD LALT(LCTL(KC_DEL)) +#define LOCKPC LGUI(KC_L) #define KC_AF4 LALT(KC_F4) #define KC_TASK LCTL(LSFT(KC_ESC)) #define CT_PGUP RCTL(KC_PGUP) #define CT_PGDN RCTL(KC_PGDN) #define CT_HOME RCTL(KC_HOME) #define CT_END RCTL(KC_END) -#define KC_SFTUP RSFT_T(KC_UP) // Shift when held, Up arrow when tapped -#define KC_RAISESPC LT(_MOUSEKEY, KC_SPC) // _MOUSEKEY layer mod when held, space when tapped -#define KC_LOWERSPC LT(_NUMPADMOUSE, KC_SPC) // _NUMPAD-MOUSE layer mod when held, space when tapped -#define KC_SHIFTSPC LSFT(KC_SPC) -#define SWAP_L SGUI(KC_LEFT) // Swap application to left display -#define SWAP_R SGUI(KC_RGHT) // Swap application to right display +#define SWAP_L SGUI(KC_LEFT) // Swap application to left display +#define SWAP_R SGUI(KC_RGHT) // Swap application to right display // KEYCODES enum custom_user_keycodes { KC_00 = SAFE_RANGE, - ENCFUNC, - KC_WINLCK, // Toggles Win key on and off + ENCFUNC, // Encoder function + CAPSNUM, // Capslock key function + LEFTOFENC, // Key to the left of the encoder (i.e. F13) + BELOWENC, // Key below encoder + PRNCONF, // Print verbose statuses of all user_config toggles + WINLOCK, // Toggles Windows key on and off RGB_TOI, // Timeout idle time up RGB_TOD, // Timeout idle time down - RGB_NITE, // Turns off all rgb but allow rgb indicators to work + RGB_NITE, // Disables RGB backlighting effects but allows RGB indicators to still work + + TG_CAPS, // Toggles RGB highlighting of alphas during capslock + TG_PAD, // Toggles RGB highlighting of keys on numpad+mousekeys layer + TG_TDCAP, // Toggles double tap shift (tapdance) for CapsLock + TG_DEL, // Swaps DEL and HOME key locations + TG_ENC, // Toggle Encoder functionality + TG_ESC, // Toggle ESC tapdance for _BASE layer + TG_INS, // Toggle location of INS + TG_SPCMOD, // Toggle disabling of modded-SPACE functions YAHOO, // yahoo.com OUTLOOK, // outlook.com @@ -66,24 +79,33 @@ enum custom_user_keycodes { KC_TSTOG, // Tab Scroll Toggle - NEW_SAFE_RANGE // new safe range for keymap level custom keycodes + NEW_SAFE_RANGE // New safe range for keymap level custom keycodes }; -#ifdef TD_LSFT_CAPSLOCK_ENABLE + // Tap Dance Definitions enum custom_tapdance { - TD_LSFT_CAPSLOCK, TD_LSFT_CAPS_WIN, - TD_ESC_BASELYR }; -#define KC_LSFTCAPS TD(TD_LSFT_CAPSLOCK) -#define KC_LSFTCAPSWIN TD(TD_LSFT_CAPS_WIN) -#define KC_ESCLYR TD(TD_ESC_BASELYR) -#else // regular Shift -#define KC_LSFTCAPS KC_LSFT -// regular Escape -#define KC_ESCLYR KC_ESC -#endif // TD_LSFT_CAPSLOCK_ENABLE + +// Set up boolean variables to track user customizable configuration options +typedef union { + uint32_t raw; + struct { + bool rgb_hilite_caps :1; + bool rgb_hilite_numpad :1; + bool esc_double_tap_to_baselyr :1; + bool del_right_home_top :1; + bool double_tap_shift_for_capslock :1; + bool encoder_press_mute_or_media :1; + bool ins_on_shft_bkspc_or_del :1; + bool disable_space_mods :1; + }; +} user_config_t; + +user_config_t user_config; + +#define LSFTCAPSWIN TD(TD_LSFT_CAPS_WIN) // ENCODER ACTIONS #ifdef ENCODER_ENABLE diff --git a/users/gourdo1/gourdo1_encoder.c b/users/gourdo1/gourdo1_encoder.c index 72f8c3c354..5a19b63c6e 100644 --- a/users/gourdo1/gourdo1_encoder.c +++ b/users/gourdo1/gourdo1_encoder.c @@ -1,5 +1,5 @@ /* Copyright 2021 Jonavin Eng @Jonavin - Copyright 2022 gourdo1 + Copyright 2022 gourdo1 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 @@ -15,8 +15,8 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ - #include QMK_KEYBOARD_H + #include "gourdo1.h" #ifdef ENCODER_ENABLE -- cgit v1.2.1