Browse Source

Toggles (#6)

* first commit (broken compile)

* initial working prototype

* added numpad rgb toggle

* minor update to toggles

* fixed double tap shift for caps toggle

* custom capslock tapdance; esc layer custom tapdance (broken)

* ESC double tap test

* cleanup obsolete code

* license notices and cosmetics

* Implemented Home/Del key swap toggle

* breakout custom double taps into separate H file.

* partial fix for custom ESC tap dance (misplaced ELSE)

* Add ability to view and print user configuration

* user_config cosmetics

* various fixes and cosmetics for user_config toggles

* Update readme.md

* RGB backlight timeout indicators completely moved to function key row

* added ability to toggle INS between Shift-DEL and Shift-BKSPC

* Final fix for custom Numpad engage/disengage
       - difference seems to be that return false; needs to be on the (!toggled) case only.
pull/17398/head
gourdo1 1 year ago
committed by GitHub
parent
commit
ec10f8a045
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 495 additions and 99 deletions
  1. +84
    -34
      keyboards/gmmk/pro/rev1/ansi/keymaps/gourdo1/keymap.c
  2. +22
    -8
      keyboards/gmmk/pro/rev1/ansi/keymaps/gourdo1/readme.md
  3. +2
    -2
      keyboards/gmmk/pro/rev1/ansi/keymaps/gourdo1/rgb_matrix_map.h
  4. +0
    -1
      keyboards/gmmk/pro/rev1/ansi/keymaps/gourdo1/rules.mk
  5. +73
    -0
      users/gourdo1/custom_double_taps.h
  6. +278
    -41
      users/gourdo1/gourdo1.c
  7. +36
    -13
      users/gourdo1/gourdo1.h

+ 84
- 34
keyboards/gmmk/pro/rev1/ansi/keymaps/gourdo1/keymap.c View File

@ -1,7 +1,7 @@
/* Copyright 2021 Glorious, LLC <salman@pcgamingrace.com>
Copyright 2021 Jonavin Eng @Jonavin
Copyright 2022 gourdo1 <gourdo1@outlook.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
@ -48,11 +48,11 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
*/
[_BASE] = LAYOUT(
KC_ESCLYR, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_HOME, KC_MUTE,
KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, KC_DEL,
KC_ESC, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, LEFTOFENC, ENCFUNC,
KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, BELOWENC,
KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, KC_PGUP,
TT(_NUMPADMOUSE), KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, KC_PGDN,
KC_LSFTCAPSWIN, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_UP, KC_END,
CAPSNUM, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, KC_PGDN,
LSFTCAPSWIN, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_UP, KC_END,
KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, MO(_FN1),KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT
),
@ -76,11 +76,11 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
#ifdef GAME_ENABLE
[_FN1] = LAYOUT(
EE_CLR, KC_MYCM, KC_WHOM, KC_CALC, KC_MSEL, KC_MPRV, KC_MNXT, KC_MPLY, KC_MSTP, KC_VOLD, KC_VOLU, KC_PSCR, KC_SLCK, KC_PAUS, KC_SLEP,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RGB_TOD, RGB_TOI, _______, RGB_TOG,
PRNCONF, TG_CAPS, TG_PAD, TG_ESC, TG_DEL, TG_TDCAP,TG_ENC, TG_INS, _______, _______, _______, RGB_TOD, RGB_TOI, _______, RGB_TOG,
_______, RGB_SAD, RGB_VAI, RGB_SAI, NK_TOGG, _______, YAHOO, _______, _______, OUTLOOK, TG(_GAME),SWAP_L, SWAP_R, RESET, KC_HOME,
KC_CAPS, RGB_HUD, RGB_VAD, RGB_HUI, _______, GMAIL, HOTMAIL, _______, _______, LOCKPC, _______, _______, _______, KC_END,
_______, RGB_NITE,_______, _______, _______, _______, KC_NLCK, _______, _______, DOTCOM, KC_CAD, _______, RGB_MOD, _______,
_______, KC_WINLCK, _______, _______, _______, _______, _______, RGB_SPD, RGB_RMOD, RGB_SPI
_______, WINLOCK, _______, _______, _______, _______, _______, RGB_SPD, RGB_RMOD, RGB_SPI
),
[_GAME] = LAYOUT(
@ -95,7 +95,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
#else
[_FN1] = LAYOUT(
EE_CLR, KC_MYCM, KC_WHOM, KC_CALC, KC_MSEL, KC_MPRV, KC_MNXT, KC_MPLY, KC_MSTP, KC_VOLD, KC_VOLU, KC_PSCR, KC_SLCK, KC_PAUS, KC_SLEP,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RGB_TOD, RGB_TOI, _______, RGB_TOG,
PRNCONF, TG_CAPS, TG_PAD, TG_ESC, TG_DEL, TG_TDCAP,TG_ENC, TG_INS, _______, _______, _______, RGB_TOD, RGB_TOI, _______, RGB_TOG,
_______, RGB_SAD, RGB_VAI, RGB_SAI, NK_TOGG, _______, YAHOO, _______, _______, OUTLOOK, KC_PAUS, SWAP_L, SWAP_R, RESET, KC_HOME,
KC_CAPS, RGB_HUD, RGB_VAD, RGB_HUI, _______, GMAIL, HOTMAIL, _______, _______, LOCKPC, _______, _______, _______, KC_END,
_______, RGB_NITE,_______, _______, _______, _______, KC_NLCK, _______, _______, DOTCOM, KC_CAD, _______, RGB_MOD, _______,
@ -140,8 +140,8 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
#ifdef COLEMAK_LAYER_ENABLE
[_COLEMAK] = LAYOUT(
_______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_DEL, KC_MUTE,
KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, KC_HOME,
_______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, _______, _______,
KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, _______, _______,
KC_TAB, KC_Q, KC_W, KC_F, KC_P, KC_G, KC_J, KC_L, KC_U, KC_Y, KC_SCLN, KC_LBRC, KC_RBRC, KC_BSLS, KC_PGUP,
_______, KC_A, KC_R, KC_S, KC_T, KC_D, KC_H, KC_N, KC_E, KC_I, KC_O, KC_QUOT, KC_ENT, KC_PGDN,
_______, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_K, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_UP, KC_END,
@ -274,12 +274,19 @@ void rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) {
// CapsLock RGB setup
if (IS_HOST_LED_ON(USB_LED_CAPS_LOCK)) {
for (uint8_t i = 0; i < ARRAYSIZE(LED_LIST_LETTERS); i++) {
rgb_matrix_set_color(LED_LIST_LETTERS[i], RGB_CHARTREUSE);
if (user_config.rgb_hilite_caps) {
for (uint8_t i = 0; i < ARRAYSIZE(LED_LIST_LETTERS); i++) {
rgb_matrix_set_color(LED_LIST_LETTERS[i], RGB_CHARTREUSE);
}
rgb_matrix_set_color(LED_L7, RGB_CHARTREUSE);
rgb_matrix_set_color(LED_L8, RGB_CHARTREUSE);
rgb_matrix_set_color(LED_LSFT, RGB_CHARTREUSE);
}
else {
rgb_matrix_set_color(LED_L7, RGB_CHARTREUSE);
rgb_matrix_set_color(LED_L8, RGB_CHARTREUSE);
rgb_matrix_set_color(LED_LSFT, RGB_CHARTREUSE);
}
rgb_matrix_set_color(LED_L7, RGB_CHARTREUSE);
rgb_matrix_set_color(LED_L8, RGB_CHARTREUSE);
rgb_matrix_set_color(LED_LSFT, RGB_CHARTREUSE);
}
// Winkey disabled (gaming) mode RGB setup
@ -347,36 +354,79 @@ void rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) {
rgb_matrix_set_color(LED_P, RGB_RED);
#endif // GAME_ENABLE
//Add RGB statuses for user.config toggles
if (user_config.rgb_hilite_caps) {
rgb_matrix_set_color(LED_1, RGB_GREEN);
} else {
rgb_matrix_set_color(LED_1, RGB_PURPLE);
}
if (user_config.rgb_hilite_numpad) {
rgb_matrix_set_color(LED_2, RGB_GREEN);
} else {
rgb_matrix_set_color(LED_2, RGB_PURPLE);
}
if (user_config.esc_double_tap_to_baselyr) {
rgb_matrix_set_color(LED_3, RGB_GREEN);
} else {
rgb_matrix_set_color(LED_3, RGB_PURPLE);
}
if (user_config.del_right_home_top) {
rgb_matrix_set_color(LED_4, RGB_GREEN);
} else {
rgb_matrix_set_color(LED_4, RGB_PURPLE);
}
if (user_config.double_tap_shift_for_capslock) {
rgb_matrix_set_color(LED_5, RGB_GREEN);
} else {
rgb_matrix_set_color(LED_5, RGB_PURPLE);
}
if (user_config.encoder_press_mute_or_media) {
rgb_matrix_set_color(LED_6, RGB_GREEN);
} else {
rgb_matrix_set_color(LED_6, RGB_PURPLE);
}
if (user_config.ins_on_shft_bkspc_or_del) {
rgb_matrix_set_color(LED_7, RGB_GREEN);
} else {
rgb_matrix_set_color(LED_7, RGB_PURPLE);
}
// Add RGB Timeout Indicator -- shows 0 to 139 using F row and num row; larger numbers using 16bit code
uint16_t timeout_threshold = get_timeout_threshold();
if (timeout_threshold <= 10) rgb_matrix_set_color(LED_LIST_FUNCROW[timeout_threshold], RGB_CYAN);
if (timeout_threshold <= 10) rgb_matrix_set_color(LED_LIST_FUNCROW[timeout_threshold], RGB_BLUE);
else if (timeout_threshold < 140) {
rgb_matrix_set_color(LED_LIST_FUNCROW[(timeout_threshold / 10)], RGB_CYAN);
rgb_matrix_set_color(LED_LIST_NUMROW[(timeout_threshold % 10)], RGB_CYAN);
rgb_matrix_set_color(LED_LIST_FUNCROW[(timeout_threshold % 10)], RGB_BLUE);
} else { // >= 140 minutes, just show these 3 lights
rgb_matrix_set_color(LED_LIST_NUMROW[10], RGB_CYAN);
rgb_matrix_set_color(LED_LIST_NUMROW[11], RGB_CYAN);
rgb_matrix_set_color(LED_LIST_NUMROW[12], RGB_CYAN);
rgb_matrix_set_color(LED_LIST_FUNCROW[10], RGB_CYAN);
rgb_matrix_set_color(LED_LIST_FUNCROW[11], RGB_CYAN);
rgb_matrix_set_color(LED_LIST_FUNCROW[12], RGB_CYAN);
}
break;
// Numpad & Mouse Keys overlay RGB
case _NUMPADMOUSE:
for (uint8_t i = 0; i < ARRAYSIZE(LED_LIST_NUMPAD); i++) {
rgb_matrix_set_color(LED_LIST_NUMPAD[i], RGB_OFFBLUE);
if (user_config.rgb_hilite_numpad) {
for (uint8_t i = 0; i < ARRAYSIZE(LED_LIST_NUMPAD); i++) {
rgb_matrix_set_color(LED_LIST_NUMPAD[i], RGB_OFFBLUE);
}
rgb_matrix_set_color(LED_L5, RGB_OFFBLUE);
rgb_matrix_set_color(LED_L6, RGB_OFFBLUE);
rgb_matrix_set_color(LED_CAPS, RGB_OFFBLUE);
rgb_matrix_set_color(LED_UP, RGB_CHARTREUSE);
rgb_matrix_set_color(LED_DOWN, RGB_CHARTREUSE);
rgb_matrix_set_color(LED_LEFT, RGB_CHARTREUSE);
rgb_matrix_set_color(LED_RIGHT, RGB_CHARTREUSE);
rgb_matrix_set_color(LED_RCTL, RGB_CHARTREUSE);
rgb_matrix_set_color(LED_RSFT, RGB_CHARTREUSE);
rgb_matrix_set_color(LED_END, RGB_CHARTREUSE);
rgb_matrix_set_color(LED_PGUP, RGB_CHARTREUSE);
rgb_matrix_set_color(LED_PGDN, RGB_CHARTREUSE);
} else {
rgb_matrix_set_color(LED_L5, RGB_OFFBLUE);
rgb_matrix_set_color(LED_L6, RGB_OFFBLUE);
rgb_matrix_set_color(LED_CAPS, RGB_OFFBLUE);
}
rgb_matrix_set_color(LED_L5, RGB_OFFBLUE);
rgb_matrix_set_color(LED_L6, RGB_OFFBLUE);
rgb_matrix_set_color(LED_CAPS, RGB_OFFBLUE);
rgb_matrix_set_color(LED_UP, RGB_CHARTREUSE);
rgb_matrix_set_color(LED_DOWN, RGB_CHARTREUSE);
rgb_matrix_set_color(LED_LEFT, RGB_CHARTREUSE);
rgb_matrix_set_color(LED_RIGHT, RGB_CHARTREUSE);
rgb_matrix_set_color(LED_RCTL, RGB_CHARTREUSE);
rgb_matrix_set_color(LED_RSFT, RGB_CHARTREUSE);
rgb_matrix_set_color(LED_END, RGB_CHARTREUSE);
rgb_matrix_set_color(LED_PGUP, RGB_CHARTREUSE);
rgb_matrix_set_color(LED_PGDN, RGB_CHARTREUSE);
break;
// MOUSEKEYS mode RGB


+ 22
- 8
keyboards/gmmk/pro/rev1/ansi/keymaps/gourdo1/readme.md View File

@ -1,6 +1,6 @@
# [gourdo1's](mailto:gourdo1@outlook.com) GMMK Pro ANSI layout
This Windows-centric ANSI layout is based on [Jonavin's](https://github.com/qmk/qmk_firmware/tree/master/keyboards/gmmk/pro/rev1/ansi/keymaps/jonavin) GMMK Pro layout with several additions, fixes, a tweaked keymap, updated layers, [Tomas Guinan's paddle game](https://github.com/qmk/qmk_firmware/tree/master/keyboards/gmmk/pro/rev1/ansi/keymaps/paddlegame) and expanded RGB controls.
This Windows-centric ANSI layout is based on [Jonavin's](https://github.com/qmk/qmk_firmware/tree/master/keyboards/gmmk/pro/rev1/ansi/keymaps/jonavin) GMMK Pro layout with many additions, fixes, a revamped keymap, persistent user customizations, updated layers, [Tomas Guinan's paddle game](https://github.com/qmk/qmk_firmware/tree/master/keyboards/gmmk/pro/rev1/ansi/keymaps/paddlegame) and expanded RGB effects and controls.
![image](https://raw.githubusercontent.com/gourdo1/media/main/susuwatari.jpg)
@ -8,14 +8,15 @@ This Windows-centric ANSI layout is based on [Jonavin's](https://github.com/qmk/
### Core Functionality
* Quick & Easy Customization: Toggle features without the need to modify firmware or access VIA. (added Jun 29, 2022)
* [VIA](https://www.caniusevia.com/) support enabled (added Mar 16, 2022)
* Most [default Glorious shortcuts](https://cdn.shopify.com/s/files/1/0549/2681/files/GMMK_Pro_User_Guide.pdf) enabled
* [N-key Rollover](https://en.wikipedia.org/wiki/Rollover_\(keyboard\)#n-key_rollover) (NKRO) -- toggled with Fn+R
* 1000Hz polling rate with 5ms debounce time for quick response in games
* Mouse Keys! Don't want to move your hands off the keyboard or you didn't bring it with you on the road? Use cursor keys to move the mouse.
* Mouse Keys! Don't want to move your hands off the keyboard or you didn't bring it with you? Use cursor keys to move the mouse
* Overlay numpad on 789-UIOP-JKL;-M,. & Space-bar mapped to Enter key for rapid number entry
* Gaming mode (Fn+Win-key) locks out Win-key as well as double-tap Shift Capslock; Also RGB highlights WSAD and nearby gaming related keys
* [Caps Word](https://getreuer.info/posts/keyboards/caps-word/index.html) enabled: To capitalize the next word only, press and release both left and right shift keys at the same time. (added Feb 25, 2022)
* Gaming mode (Fn+Win-key) locks out Win-key and double-tap Shift Capslock; Also RGB highlights WSAD and nearby gaming keys
* Caps Word enabled: To capitalize the next word only, press and release left and right shift at the same time. (added Feb 25, 2022)
* Multi-monitor app moving shortcuts: Fn+[,] (square brackets) to move current app window to next monitor (added Apr 11, 2022)
* Capslock toggled by double tap of Left Shift key or Fn + Capslock (RGB green highlighted)
* Paddle game accessible via Fn+P; Hit Fn+P again or double tap ESC to exit (added May 5, 2022)
@ -26,11 +27,24 @@ This Windows-centric ANSI layout is based on [Jonavin's](https://github.com/qmk/
* Home key on F13, Del key right of Backspace
* Insert accessible via Shift-Backspace (so shift delete still works in Windows Explorer)
* PrtScrn, Scroll Lock, Pause/Break are top right on the keyboard: Fn+F11, Fn+F12, Fn+F13
* [Colemak](https://colemak.com/) key layout support (Layer accessible via Left Shift + turn Encoder clockwise until side LEDs light up purple)
* [Colemak](https://colemak.com/) key layout support (Accessible via Left Shift + turn Encoder clockwise until side LEDs light up purple)
* Double tap ESC any time to revert to base layer (added Feb 26, 2022)
* RGB backlight effects expanded to include framebuffer effects and reactive keypress modes (updated May 24, 2022)
* RGB backlight now remembers last color & effect settings after power down (updated May 24, 2022)
### Quick & Easy Customization
* Below features can be toggled by holding [FN] and pressing the number corresponding to that feature. Changes are saved to EEPROM for persistence.
* Print all current settings by opening a text editor and pressing [FN]+[~] (CAUTION: verbose!)
* Quick view current settings by holding [FN] and viewing RGB under keys 1 through 6 (green means ON, violet means OFF)
#### Toggle-able Settings:
1. CapsLock RGB - highlight under alpha keys
2. Numpad RGB - highlight under numpad layer keys
3. ESC key - Double tap ESC key to go to base layer
4. Swap DEL and HOME - Default is DEL to the right of BKSPC & HOME is above BKSPC
5. Capslock function - Toggle between double tap LShift for CapsLock with Numpad on CapsLock key (default) and standard CapsLock
6. Encoder button - default mutes volume; alternate plays/pauses media
7. Insert function - Toggle between SHIFT-BKSPC and SHIFT-DEL
### Numpad + Mouse Keys (Capslock key)
* Overlay numpad + [Mouse Keys](https://github.com/qmk/qmk_firmware/blob/master/docs/feature_mouse_keys.md) are accessed through Capslock key hold (temp) or double press (locked) with RGB highlighting
@ -72,10 +86,10 @@ This Windows-centric ANSI layout is based on [Jonavin's](https://github.com/qmk/
* RGB backlight brightness: Fn+W/S
* RGB backlight saturation: Fn+Q/E (added Feb 4, 2022)
* RGB backlight night mode toggle: Fn+Z (indicators still work)
* RGB backlight timeout: Fn+Encoder or "-" and "=" (default 15 minutes) (updated Apr 7, 2022)
* indicators in Fn layer using RGB in F-key and number rows to show the current timeout in minutes
* RGB backlight timeout: Fn+Encoder or "-" and "=" (default 15 minutes) (updated June 28, 2022)
* F-key row indicator lights (cyan and blue) in Fn layer display the current backlight timeout in minutes
* Fn+Z to turn off RGB backlighting (indicator lights still work); press again to toggle
* RGB indicators on left side LEDs in order from top: System NumLock off (orange), Scroll Lock (red), Numpad (blue), Capslock (green).
* Left side RGB indicators in order from top: System NumLock off (orange), Scroll Lock (red), Numpad (blue), Capslock (green).
### Advanced Controls


+ 2
- 2
keyboards/gmmk/pro/rev1/ansi/keymaps/gourdo1/rgb_matrix_map.h View File

@ -199,7 +199,7 @@ const uint8_t LED_LIST_NUMROW[] = {
};
const uint8_t LED_LIST_LETTERS[] = {
LED_1,
/* LED_1,
LED_2,
LED_3,
LED_4,
@ -208,7 +208,7 @@ const uint8_t LED_LIST_LETTERS[] = {
LED_7,
LED_8,
LED_9,
LED_0,
LED_0, */
LED_Q,
LED_W,
LED_E,


+ 0
- 1
keyboards/gmmk/pro/rev1/ansi/keymaps/gourdo1/rules.mk View File

@ -8,7 +8,6 @@ TAP_DANCE_ENABLE = yes
BOOTMAGIC_ENABLE = yes # Enable Bootmagic Lite
CAPS_WORD_ENABLE = yes # Enable built-in Caps Word functionality
TD_LSFT_CAPSLOCK_ENABLE = yes
IDLE_TIMEOUT_ENABLE = yes
STARTUP_NUMLOCK_ON = yes
ENCODER_DEFAULTACTIONS_ENABLE = no


+ 73
- 0
users/gourdo1/custom_double_taps.h View File

@ -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;
}

+ 278
- 41
users/gourdo1/gourdo1.c View File

@ -19,13 +19,18 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "gourdo1.h"
#ifdef TD_LSFT_CAPSLOCK_ENABLE
// Tap once for shift, twice for Caps Lock but only if Win Key in not disabled
#include "custom_double_taps.h"
// 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_code16(KC_LSFT);
} else {
register_code(KC_CAPS);
}
} else {
register_code(KC_CAPS);
register_code16(KC_LSFT);
}
}
@ -37,16 +42,13 @@ void dance_LSFT_reset(qk_tap_dance_state_t * state, void * user_data) {
unregister_code16(KC_LSFT);
}
}
#endif // TD_LSFT_CAPSLOCK_ENABLE
// Tap Dance definitions
qk_tap_dance_action_t tap_dance_actions[] = {
#ifdef TD_LSFT_CAPSLOCK_ENABLE
// Tap once for shift, twice for Caps Lock
[TD_LSFT_CAPS_WIN] = ACTION_TAP_DANCE_FN_ADVANCED(dance_LSFT_each_tap, NULL, dance_LSFT_reset),
#endif // TD_LSFT_CAPSLOCK_ENABLE
// Tap once for Escape, twice to reset to base layer
[TD_ESC_BASELYR] = ACTION_TAP_DANCE_LAYER_MOVE(KC_ESC, _BASE)
//[TD_ESC_BASELYR] = ACTION_TAP_DANCE_LAYER_MOVE(KC_ESC, _BASE)
};
// RGB NIGHT MODE
@ -126,12 +128,228 @@ __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_record_keymap(keycode, record)) { return false; }
if (!process_capsnum(keycode, record)) { return false; }
if (!process_esc_to_base(keycode, record)) { return false; }
// Key macros ...
switch (keycode) {
// 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(SS_TAP(X_ENT)"GMMK Pro User Settings. Press [FN]+<number key> to toggle each."SS_TAP(X_ENT));
SEND_STRING("Config also visible by holding [FN] and viewing RGB under number keys."SS_TAP(X_ENT));
SEND_STRING("======================================================================"SS_TAP(X_ENT));
SEND_STRING("1. CapsLock RGB highlight alpha keys ");
if (user_config.rgb_hilite_caps) {
SEND_STRING("[ON]"SS_TAP(X_ENT));
} else {
SEND_STRING("[OFF]"SS_TAP(X_ENT));
}
SEND_STRING("2. Numpad RGB highlight layer keys ");
if (user_config.rgb_hilite_numpad) {
SEND_STRING("[ON]"SS_TAP(X_ENT));
} else {
SEND_STRING("[OFF]"SS_TAP(X_ENT));
}
SEND_STRING("3. Double tap ESC to revert to BASE layer ");
if (user_config.esc_double_tap_to_baselyr) {
SEND_STRING("[ON]"SS_TAP(X_ENT));
} else {
SEND_STRING("[OFF]"SS_TAP(X_ENT));
}
SEND_STRING("4. DEL & HOME key locations ");
if (user_config.del_right_home_top) {
SEND_STRING("[HOME on F13;DEL right of BKSPC]"SS_TAP(X_ENT));
} else {
SEND_STRING("[DEL on F13;HOME right of BKSPC]"SS_TAP(X_ENT));
}
SEND_STRING("5. Capslock: Double tap LShift / Numpad on CapsLock ");
if (user_config.double_tap_shift_for_capslock) {
SEND_STRING("[ON]"SS_TAP(X_ENT));
} else {
SEND_STRING("[OFF]"SS_TAP(X_ENT));
}
SEND_STRING("6. Encoder button function ");
if (user_config.encoder_press_mute_or_media) {
SEND_STRING("[MUTE]"SS_TAP(X_ENT));
} else {
SEND_STRING("[MEDIA PLAY/PAUSE]"SS_TAP(X_ENT));
}
SEND_STRING("7. Insert function accessed with ");
if (user_config.ins_on_shft_bkspc_or_del) {
SEND_STRING("[SHIFT]-[BKSPC]"SS_TAP(X_ENT));
} else {
SEND_STRING("[SHIFT]-[DEL]"SS_TAP(X_ENT));
}
}
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;
//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) {
@ -169,8 +387,8 @@ bool process_record_user(uint16_t keycode, keyrecord_t * record) {
}
break;
// WinKey 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);
@ -242,30 +460,32 @@ bool process_record_user(uint16_t keycode, keyrecord_t * record) {
}
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;
}
}
}
}
@ -361,7 +581,7 @@ bool caps_word_press_user(uint16_t keycode) {
case KC_DQT:
case KC_COLN:
case KC_RSFT:
case KC_LSFTCAPSWIN:
case LSFTCAPSWIN:
add_weak_mods(MOD_BIT(KC_LSFT)); // Apply shift to next key.
return true;
@ -388,14 +608,31 @@ 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 initial time for idle timeout
#endif
}
}
/* 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;
eeconfig_update_user(user_config.raw);
}

+ 36
- 13
users/gourdo1/gourdo1.h View File

@ -49,11 +49,24 @@ enum custom_user_layers {
// 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
//ESCLYR, // ESC layer 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
YAHOO, // yahoo.com
OUTLOOK, // outlook.com
@ -76,19 +89,29 @@ enum custom_user_keycodes {
// Tap Dance Definitions
enum custom_tapdance {
#ifdef TD_LSFT_CAPSLOCK_ENABLE
TD_LSFT_CAPS_WIN,
#endif // TD_LSFT_CAPSLOCK_ENABLE
TD_ESC_BASELYR
//TD_ESC_BASELYR
};
#ifdef TD_LSFT_CAPSLOCK_ENABLE
#define KC_LSFTCAPSWIN TD(TD_LSFT_CAPS_WIN)
#else // regular Shift
#define KC_LSFTCAPSWIN KC_LSFT
#endif // TD_LSFT_CAPSLOCK_ENABLE
#define KC_ESCLYR TD(TD_ESC_BASELYR)
// 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;
};
} user_config_t;
user_config_t user_config;
#define LSFTCAPSWIN TD(TD_LSFT_CAPS_WIN)
//#define ESCLYR TD(TD_ESC_BASELYR)
//#define CAPSNUM TD(TD_NUMPAD)
// ENCODER ACTIONS
#ifdef ENCODER_ENABLE


Loading…
Cancel
Save