diff options
author | gourdo1 <gourdo1@users.noreply.github.com> | 2022-04-19 04:05:13 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-19 21:05:13 +1000 |
commit | be7198ca49543a5e7b8d5ec38de7d7b6f2acc53d (patch) | |
tree | 767629508fdf22c8e398886407de675391777495 /users/gourdo1 | |
parent | ad31ea3f515630f922ccad54cc879e13a05020fa (diff) |
New custom keymap for Glorious GMMK Pro ANSI layout (#16199)
Co-authored-by: Drashna Jaelre <drashna@live.com>
Diffstat (limited to 'users/gourdo1')
-rw-r--r-- | users/gourdo1/gourdo1.c | 432 | ||||
-rw-r--r-- | users/gourdo1/gourdo1.h | 131 | ||||
-rw-r--r-- | users/gourdo1/gourdo1_encoder.c | 238 | ||||
-rw-r--r-- | users/gourdo1/rules.mk | 29 |
4 files changed, 830 insertions, 0 deletions
diff --git a/users/gourdo1/gourdo1.c b/users/gourdo1/gourdo1.c new file mode 100644 index 0000000000..b964729be9 --- /dev/null +++ b/users/gourdo1/gourdo1.c @@ -0,0 +1,432 @@ +/* Copyright 2021 Jonavin Eng @Jonavin + Copyright 2022 gourdo1 <jcblake@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 +(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 "gourdo1.h" + +#include "caps_word.h" + +#ifdef TD_LSFT_CAPSLOCK_ENABLE +// Tap once for shift, twice for Caps Lock but only if Win Key in not disabled +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); + } else { + register_code(KC_CAPS); + } +} + +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); + } else { + unregister_code(KC_CAPS); + unregister_code16(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), +}; +#endif // TD_LSFT_CAPSLOCK_ENABLE + +// RGB NIGHT MODE +#ifdef RGB_MATRIX_ENABLE +static bool rgb_nightmode = false; + +// Turn on/off NUM LOCK if current state is different +void activate_rgb_nightmode(bool turn_on) { + if (rgb_nightmode != turn_on) { + rgb_nightmode = !rgb_nightmode; + } +} + +bool get_rgb_nightmode(void) { + return rgb_nightmode; +} +#endif // RGB_MATRIX_ENABLE + +// TIMEOUTS +#ifdef IDLE_TIMEOUT_ENABLE +static uint16_t timeout_timer = 0; +static uint16_t timeout_counter = 0; //in minute intervals +static uint16_t timeout_threshold = TIMEOUT_THRESHOLD_DEFAULT; + +uint16_t get_timeout_threshold(void) { + return timeout_threshold; +} + +void timeout_reset_timer(void) { + timeout_timer = timer_read(); + timeout_counter = 0; +}; + +void timeout_update_threshold(bool increase) { + if (increase && timeout_threshold < TIMEOUT_THRESHOLD_MAX) timeout_threshold++; + if (!increase && timeout_threshold > 0) timeout_threshold--; +}; + +void timeout_tick_timer(void) { + if (timeout_threshold > 0) { + if (timer_elapsed(timeout_timer) >= 60000) { // 1 minute tick + timeout_counter++; + timeout_timer = timer_read(); + } + #ifdef RGB_MATRIX_ENABLE + if (timeout_threshold > 0 && timeout_counter >= timeout_threshold) { + rgb_matrix_disable_noeeprom(); + } + #endif + } // timeout_threshold = 0 will disable timeout +} + +#endif // IDLE_TIMEOUT_ENABLE + +#if defined(ALTTAB_SCROLL_ENABLE) || defined(IDLE_TIMEOUT_ENABLE) // timer features +__attribute__((weak)) void matrix_scan_keymap(void) {} + +void matrix_scan_user(void) { + #ifdef ALTTAB_SCROLL_ENABLE + encoder_tick_alttabscroll(); + #endif + #ifdef IDLE_TIMEOUT_ENABLE + timeout_tick_timer(); + #endif + matrix_scan_keymap(); +} +#endif // ALTTAB_SCROLL_ENABLE or IDLE_TIMEOUT_ENABLE + +// Initialize variable holding the binary representation of active modifiers. +uint8_t mod_state; + +// ============================================= PROCESS KEY CODES ============================================= + +__attribute__((weak)) bool process_record_keymap(uint16_t keycode, keyrecord_t * record) { + return true; +} + +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; + } + + // Your macros ... + switch (keycode) { + + // DotCom domain macros + case DOTCOM: + if (record -> event.pressed) { + SEND_STRING(".com"); + } else { + // when keycode is released + } + break; + case YAHOO: + if (record -> event.pressed) { + SEND_STRING("yahoo.com"); + } else { + // when keycode is released + } + break; + case OUTLOOK: + if (record -> event.pressed) { + SEND_STRING("outlook.com"); + } else { + // when keycode is released + } + break; + case GMAIL: + if (record -> event.pressed) { + SEND_STRING("gmail.com"); + } else { + // when keycode is released + } + break; + case HOTMAIL: + if (record -> event.pressed) { + 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: + if (record -> event.pressed) { + keymap_config.no_gui = !keymap_config.no_gui; //toggle status + } else unregister_code16(keycode); + break; + + // Double Zero + case KC_00: + if (record -> event.pressed) { + // when keycode KC_00 is pressed + 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; + } + } + } + break; + + // Add 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; + } + } + } + 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; + */ + + #ifdef IDLE_TIMEOUT_ENABLE + case RGB_TOI: + if (record -> event.pressed) { + timeout_update_threshold(true); + } else unregister_code16(keycode); + break; + case RGB_TOD: + if (record -> event.pressed) { + timeout_update_threshold(false); //decrease timeout + } else unregister_code16(keycode); + break; + #endif // IDLE_TIMEOUT_ENABLE + #ifdef RGB_MATRIX_ENABLE + case RGB_NITE: + if (record -> event.pressed) { + rgb_nightmode = !rgb_nightmode; + } else unregister_code16(keycode); + break; + #endif // RGB_MATRIX_ENABLE + + #ifdef EMOTICON_ENABLE + case EMO_SHRUG: + if (record -> event.pressed) SEND_STRING("`\\_(\"/)_/`"); + else unregister_code16(keycode); + break; + case EMO_CONFUSE: + if (record -> event.pressed) SEND_STRING("(*_*)"); + else unregister_code16(keycode); + break; + case EMO_TEARS: + if (record -> event.pressed) SEND_STRING("(T_T)"); + else unregister_code16(keycode); + break; + case EMO_NERVOUS: + if (record -> event.pressed) SEND_STRING("(~_~;)"); + else unregister_code16(keycode); + break; + case EMO_JOY: + if (record -> event.pressed) SEND_STRING("(^o^)"); + else unregister_code16(keycode); + break; + case EMO_SAD: + if (record -> event.pressed) SEND_STRING(":'-("); + else unregister_code16(keycode); + break; + #endif // EMOTICON_ENABLE + + #ifdef ALTTAB_SCROLL_ENABLE + case KC_TSTOG: + if (record -> event.pressed) encoder_toggle_alttabscroll(); + else unregister_code16(keycode); + break; + #endif // ALTTAB_SCROLL_ENABLE + + default: + if (record -> event.pressed) { + #ifdef RGB_MATRIX_ENABLE + rgb_matrix_enable(); + #endif + #ifdef IDLE_TIMEOUT_ENABLE + timeout_reset_timer(); //reset activity timer + #endif + } + break; + } + return true; +}; + +uint16_t get_tapping_term(uint16_t keycode, keyrecord_t * record) { + switch (keycode) { + case KC_SFTUP: + return 300; + case KC_RAISESPC: + case KC_LOWERSPC: + return 450; + default: + return TAPPING_TERM; + } +} + +// Turn on/off NUM LOCK if current state is different +void activate_numlock(bool turn_on) { + if (IS_HOST_LED_ON(USB_LED_NUM_LOCK) != turn_on) { + tap_code(KC_NUMLOCK); + } +} + +// INITIAL STARTUP + +__attribute__((weak)) void keyboard_post_init_keymap(void) {} + +void keyboard_post_init_user(void) { + 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 + #ifdef IDLE_TIMEOUT_ENABLE + timeout_timer = timer_read(); // set inital time for ide timeout + #endif +}
\ No newline at end of file diff --git a/users/gourdo1/gourdo1.h b/users/gourdo1/gourdo1.h new file mode 100644 index 0000000000..c6861ca0ca --- /dev/null +++ b/users/gourdo1/gourdo1.h @@ -0,0 +1,131 @@ +/* Copyright 2021 Jonavin Eng @Jonavin + Copyright 2022 gourdo1 <jcblake@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 +(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 MACROS +#define ARRAYSIZE(arr) sizeof(arr) / sizeof(arr[0]) + +// LAYERS +enum custom_user_layers { + _BASE, + _FN1, + _NUMPADMOUSE, + _MOUSEKEY, +}; + +#define KC_CAD LALT(LCTL(KC_DEL)) +#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 + +// KEYCODES +enum custom_user_keycodes { + KC_00 = SAFE_RANGE, + ENCFUNC, + KC_WINLCK, // Toggles Win 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 + + YAHOO, // yahoo.com + OUTLOOK, // outlook.com + GMAIL, // gmail.com + HOTMAIL, // hotmail.com + DOTCOM, // .com + + EMO_SHRUG, // `\_("/)_/` + EMO_CONFUSE, // (*_*) + EMO_SAD, // :'-( + EMO_NERVOUS, // (~_~;) + EMO_JOY, // (^o^) + EMO_TEARS, // (T_T) + + KC_TSTOG, // Tab Scroll Toggle + + 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 + +// ENCODER ACTIONS +#ifdef ENCODER_ENABLE +void encoder_action_volume(bool clockwise); +void encoder_action_mediatrack(bool clockwise); +void encoder_action_navword(bool clockwise); +void encoder_action_navpage(bool clockwise); + +uint8_t get_selected_layer(void); +void encoder_action_layerchange(bool clockwise); + +#if defined(RGB_MATRIX_ENABLE) || defined(RGBLIGHT_ENABLE) +void encoder_action_rgb_speed(bool clockwise); +void encoder_action_rgb_hue(bool clockwise); +void encoder_action_rgb_saturation(bool clockwise); +void encoder_action_rgb_brightness(bool clockwise); +void encoder_action_rgb_mode(bool clockwise); +#endif // RGB_MATRIX_ENABLE / RGBLIGHT_ENABLE + +#ifdef ALTTAB_SCROLL_ENABLE +void encoder_action_alttabscroll(bool clockwise); +void encoder_toggle_alttabscroll(void); +void encoder_tick_alttabscroll(void); +#endif // ALTTAB_SCROLL_ENABLE +#endif // ENCODER_ENABLE + +#ifdef RGB_MATRIX_ENABLE +void activate_rgb_nightmode(bool turn_on); +bool get_rgb_nightmode(void); +#endif + +// IDLE TIMEOUTS +#ifdef IDLE_TIMEOUT_ENABLE +#define TIMEOUT_THRESHOLD_DEFAULT 15 // default timeout minutes +#define TIMEOUT_THRESHOLD_MAX 140 // upper limits (2 hours and 10 minutes -- no rgb indicators above this value) + +//prototype functions +uint16_t get_timeout_threshold(void); +void timeout_reset_timer(void); +void timeout_update_threshold(bool increase); +void timeout_tick_timer(void); +#endif //IDLE_TIMEOUT_ENABLE + +// OTHER FUNCTION PROTOTYPE +void activate_numlock(bool turn_on);
\ No newline at end of file diff --git a/users/gourdo1/gourdo1_encoder.c b/users/gourdo1/gourdo1_encoder.c new file mode 100644 index 0000000000..72f8c3c354 --- /dev/null +++ b/users/gourdo1/gourdo1_encoder.c @@ -0,0 +1,238 @@ +/* Copyright 2021 Jonavin Eng @Jonavin + Copyright 2022 gourdo1 <jcblake@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 +(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 "gourdo1.h" + +#ifdef ENCODER_ENABLE + #ifndef DYNAMIC_KEYMAP_LAYER_COUNT + #define DYNAMIC_KEYMAP_LAYER_COUNT 4 //default in case this is not already defined elsewhere + #endif + #ifndef ENCODER_DEFAULTACTIONS_INDEX + #define ENCODER_DEFAULTACTIONS_INDEX 0 // can select encoder index if there are multiple encoders + #endif + + static uint16_t key_timer; + + void encoder_action_volume(bool clockwise) { + if (clockwise) { + tap_code(KC_VOLU); + if (timer_elapsed(key_timer) < 50) { + tap_code(KC_VOLU); // if less than 50ms have passed, hit vol up again. + key_timer = timer_read(); + } else { + key_timer = timer_read(); + // do nothing if 50ms or more have passed + } + } + else { + tap_code(KC_VOLD); + if (timer_elapsed(key_timer) < 100) { + tap_code(KC_VOLD); // if less than 100ms have passed, hit vol down twice. + tap_code(KC_VOLD); + key_timer = timer_read(); + } else { + key_timer = timer_read(); + // do nothing if 100ms or more have passed + } + } + } + + void encoder_action_mediatrack(bool clockwise) { + if (clockwise) + tap_code(KC_MEDIA_NEXT_TRACK); + else + tap_code(KC_MEDIA_PREV_TRACK); + } + + void encoder_action_navword(bool clockwise) { + if (clockwise) + tap_code16(LCTL(KC_RGHT)); + else + tap_code16(LCTL(KC_LEFT)); + } + + void encoder_action_navpage(bool clockwise) { + if (clockwise) + tap_code16(KC_PGUP); + else + tap_code16(KC_PGDN); + } + + // LAYER HANDLING + uint8_t selected_layer = 0; + + uint8_t get_selected_layer(void) { + return selected_layer; + } + + void encoder_action_layerchange(bool clockwise) { + if (clockwise) { + if(selected_layer < (DYNAMIC_KEYMAP_LAYER_COUNT - 1)) { + selected_layer ++; + layer_move(selected_layer); + } + } else { + if (selected_layer > 0) { + selected_layer --; + layer_move(selected_layer); + } + } + } + + #ifdef RGB_MATRIX_ENABLE + void encoder_action_rgb_speed(bool clockwise) { + if (clockwise) + rgb_matrix_increase_speed_noeeprom(); + else + rgb_matrix_decrease_speed_noeeprom(); + } + void encoder_action_rgb_hue(bool clockwise) { + if (clockwise) + rgb_matrix_increase_hue_noeeprom(); + else + rgb_matrix_decrease_hue_noeeprom(); + } + void encoder_action_rgb_saturation(bool clockwise) { + if (clockwise) + rgb_matrix_increase_sat_noeeprom(); + else + rgb_matrix_decrease_sat_noeeprom(); + } + void encoder_action_rgb_brightness(bool clockwise) { + if (clockwise) + rgb_matrix_increase_val_noeeprom(); + else + rgb_matrix_decrease_val_noeeprom(); + } + void encoder_action_rgb_mode(bool clockwise) { + if (clockwise) + rgb_matrix_step_noeeprom(); + else + rgb_matrix_step_reverse_noeeprom(); + } + #elif defined(RGBLIGHT_ENABLE) + void encoder_action_rgb_speed(bool clockwise) { + if (clockwise) + rgblight_increase_speed_noeeprom(); + else + rgblight_decrease_speed_noeeprom(); + } + void encoder_action_rgb_hue(bool clockwise) { + if (clockwise) + rgblight_increase_hue_noeeprom(); + else + rgblight_decrease_hue_noeeprom(); + } + void encoder_action_rgb_saturation(bool clockwise) { + if (clockwise) + rgblight_increase_sat_noeeprom(); + else + rgblight_decrease_sat_noeeprom(); + } + void encoder_action_rgb_brightness(bool clockwise) { + if (clockwise) + rgblight_increase_val_noeeprom(); + else + rgblight_decrease_val_noeeprom(); + } + void encoder_action_rgb_mode(bool clockwise) { + if (clockwise) + rgblight_step_noeeprom(); + else + rgblight_step_reverse_noeeprom(); + } + #endif // RGB_MATRIX_ENABLE || RGBLIGHT_ENABLE + + #ifdef ALTTAB_SCROLL_ENABLE + bool is_tab_scrolling = false; + bool is_alt_tab_active = false; + uint16_t alt_tab_timer = 0; + + + void encoder_toggle_alttabscroll(void) { + is_tab_scrolling = !is_tab_scrolling; + } + + void encoder_action_alttabscroll(bool clockwise) { + if (clockwise) { + if (!is_alt_tab_active) { + is_alt_tab_active = true; + register_mods(MOD_RALT); + } + tap_code16(KC_TAB); + } + else { + tap_code16(S(KC_TAB)); + } + alt_tab_timer = timer_read(); + } + + void encoder_tick_alttabscroll(void) { + if (is_alt_tab_active) { + if (timer_elapsed(alt_tab_timer) > 600) { + unregister_mods(MOD_RALT); + is_alt_tab_active = false; + } + } + } + #endif // ALTTAB_SCROLL_ENABLE +#endif // ENCODER_ENABLE + +#if defined(ENCODER_ENABLE) && defined(ENCODER_DEFAULTACTIONS_ENABLE) // Encoder Functionality + + __attribute__((weak)) bool encoder_update_keymap(uint8_t index, bool clockwise) { return true; } + + bool encoder_update_user(uint8_t index, bool clockwise) { + if (!encoder_update_keymap(index, clockwise)) { return false; } + if (index != ENCODER_DEFAULTACTIONS_INDEX) {return true;} // exit if the index doesn't match + uint8_t mods_state = get_mods(); + if (mods_state & MOD_BIT(KC_LSFT) ) { // If you are holding L shift, encoder changes layers + encoder_action_layerchange(clockwise); + } else if (mods_state & MOD_BIT(KC_RSFT) ) { // If you are holding R shift, Page up/dn + unregister_mods(MOD_BIT(KC_RSFT)); + encoder_action_navpage(clockwise); + register_mods(MOD_BIT(KC_RSFT)); + } else if (mods_state & MOD_BIT(KC_LCTL)) { // if holding Left Ctrl, navigate next/prev word + encoder_action_navword(clockwise); + } else if (mods_state & MOD_BIT(KC_LALT)) { // if holding Left Alt, change media next/prev track + encoder_action_mediatrack(clockwise); + } else { + switch(get_highest_layer(layer_state)) { + case _FN1: + #ifdef IDLE_TIMEOUT_ENABLE + timeout_update_threshold(clockwise); + #endif + break; + default: + #ifdef ALTTAB_SCROLL_ENABLE + if (is_tab_scrolling) + encoder_action_alttabscroll(clockwise); + else + encoder_action_volume(clockwise); // Otherwise it just changes volume + #else + encoder_action_volume(clockwise); // Otherwise it just changes volume + #endif // ALTTAB_SCROLL_ENABLE + break; + } + } + return false; + } +#endif // ENCODER_ENABLE + + diff --git a/users/gourdo1/rules.mk b/users/gourdo1/rules.mk new file mode 100644 index 0000000000..e02f9e8e08 --- /dev/null +++ b/users/gourdo1/rules.mk @@ -0,0 +1,29 @@ +SRC += gourdo1.c +ifdef ENCODER_ENABLE + # include encoder related code when enabled + ifeq ($(strip $(ENCODER_DEFAULTACTIONS_ENABLE)), yes) + OPT_DEFS += -DENCODER_DEFAULTACTIONS_ENABLE + endif + ifeq ($(strip $(ALTTAB_SCROLL_ENABLE)), yes) + OPT_DEFS += -DALTTAB_SCROLL_ENABLE + endif + SRC += gourdo1_encoder.c +endif +ifeq ($(strip $(TD_LSFT_CAPSLOCK_ENABLE)), yes) + OPT_DEFS += -DTD_LSFT_CAPSLOCK_ENABLE +endif +ifeq ($(strip $(IDLE_TIMEOUT_ENABLE)), yes) + OPT_DEFS += -DIDLE_TIMEOUT_ENABLE +endif +ifeq ($(strip $(STARTUP_NUMLOCK_ON)), yes) + OPT_DEFS += -DSTARTUP_NUMLOCK_ON +endif +ifeq ($(strip $(COLEMAK_LAYER_ENABLE)), yes) + OPT_DEFS += -DCOLEMAK_LAYER_ENABLE +endif +ifeq ($(strip $(EMOTICON_ENABLE)), yes) + OPT_DEFS += -DEMOTICON_ENABLE +endif +ifeq ($(strip $(INVERT_NUMLOCK_INDICATOR)), yes) + OPT_DEFS += -DINVERT_NUMLOCK_INDICATOR +endif |