diff options
author | James Young <18669334+noroadsleft@users.noreply.github.com> | 2021-08-19 11:32:23 -0700 |
---|---|---|
committer | James Young <18669334+noroadsleft@users.noreply.github.com> | 2021-08-19 11:32:23 -0700 |
commit | 4279b14adffe081a3dfb17fa0f04ed21513e5eda (patch) | |
tree | 770bd82b05595b686ad8cfdce79ea7f8439bda83 /users/jonavin | |
parent | 9d1c98c891bb8e1e98dc618e0693a7efff23a22e (diff) | |
parent | f4f679779e1404d9dc34c64823b9eb993bfa7ab3 (diff) |
Merge remote-tracking branch 'upstream/master' into develop
Conflicts:
keyboards/gmmk/pro/ansi/keymaps/jonavin/rules.mk
keyboards/space_space/rules.mk
Diffstat (limited to 'users/jonavin')
-rw-r--r-- | users/jonavin/config.h | 30 | ||||
-rw-r--r-- | users/jonavin/jonavin.c | 231 | ||||
-rw-r--r-- | users/jonavin/jonavin.h | 82 | ||||
-rw-r--r-- | users/jonavin/readme.md | 76 | ||||
-rw-r--r-- | users/jonavin/rules.mk | 13 |
5 files changed, 432 insertions, 0 deletions
diff --git a/users/jonavin/config.h b/users/jonavin/config.h new file mode 100644 index 0000000000..4f4568f700 --- /dev/null +++ b/users/jonavin/config.h @@ -0,0 +1,30 @@ +/* Copyright 2021 Jonavin Eng + * + * 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 TAPPING_TOGGLE 2 // TT () set to two taps + +/* Handle GRAVESC combo keys */ +#define GRAVE_ESC_ALT_OVERRIDE // Always send Escape if Alt is pressed +#define GRAVE_ESC_CTRL_OVERRIDE // Always send Escape if Control is pressed + +#define TAPPING_TERM 180 + +#ifdef RGB_MATRIX_ENABLE + #define RGB_MATRIX_STARTUP_MODE RGB_MATRIX_SOLID_COLOR + #define RGB_DISABLE_WHEN_USB_SUSPENDED true +#endif diff --git a/users/jonavin/jonavin.c b/users/jonavin/jonavin.c new file mode 100644 index 0000000000..d5fdb2a1eb --- /dev/null +++ b/users/jonavin/jonavin.c @@ -0,0 +1,231 @@ + +/* Copyright 2021 Jonavin Eng @Jonavin + +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 "jonavin.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_finished(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); + } + } + + 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(NULL, dance_LSFT_finished, dance_LSFT_reset), + }; +#endif // TD_LSFT_CAPSLOCK_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 + } + + __attribute__((weak)) void matrix_scan_keymap(void) {} + + void matrix_scan_user(void) { + timeout_tick_timer(); + matrix_scan_keymap(); + } +#endif // IDLE_TIMEOUT_ENABLE + + +#if defined(ENCODER_ENABLE) && defined(ENCODER_DEFAULTACTIONS_ENABLE) // Encoder Functionality + #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 + +uint8_t selected_layer = 0; + +__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 + if ( clockwise ) { + if (keyboard_report->mods & MOD_BIT(KC_LSFT) ) { // If you are holding L shift, encoder changes layers + if(selected_layer < (DYNAMIC_KEYMAP_LAYER_COUNT - 1)) { + selected_layer ++; + layer_move(selected_layer); + } + } else if (keyboard_report->mods & MOD_BIT(KC_RSFT) ) { // If you are holding R shift, Page up + unregister_mods(MOD_BIT(KC_RSFT)); + register_code(KC_PGDN); + register_mods(MOD_BIT(KC_RSFT)); + } else if (keyboard_report->mods & MOD_BIT(KC_LCTL)) { // if holding Left Ctrl, navigate next word + tap_code16(LCTL(KC_RGHT)); + } else if (keyboard_report->mods & MOD_BIT(KC_LALT)) { // if holding Left Alt, change media next track + tap_code(KC_MEDIA_NEXT_TRACK); + } else { + switch (selected_layer) { + case _FN1: + #ifdef IDLE_TIMEOUT_ENABLE + timeout_update_threshold(true); + #endif + break; + default: + tap_code(KC_VOLU); // Otherwise it just changes volume + break; + } + } + } else { + if (keyboard_report->mods & MOD_BIT(KC_LSFT) ) { + if (selected_layer > 0) { + selected_layer --; + layer_move(selected_layer); + } + } else if (keyboard_report->mods & MOD_BIT(KC_RSFT) ) { + unregister_mods(MOD_BIT(KC_RSFT)); + register_code(KC_PGUP); + register_mods(MOD_BIT(KC_RSFT)); + } else if (keyboard_report->mods & MOD_BIT(KC_LCTL)) { // if holding Left Ctrl, navigate previous word + tap_code16(LCTL(KC_LEFT)); + } else if (keyboard_report->mods & MOD_BIT(KC_LALT)) { // if holding Left Alt, change media previous track + tap_code(KC_MEDIA_PREV_TRACK); + } else { + switch (selected_layer) { + case _FN1: + #ifdef IDLE_TIMEOUT_ENABLE + timeout_update_threshold(false); + #endif + break; + default: + tap_code(KC_VOLD); + break; + } + } + } + + return true; + } +#endif // ENCODER_ENABLE + + +// 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) { + if (!process_record_keymap(keycode, record)) { return false; } + switch (keycode) { + case KC_00: + if (record->event.pressed) { + // when keycode KC_00 is pressed + SEND_STRING("00"); + } else unregister_code16(keycode); + break; + case KC_WINLCK: + if (record->event.pressed) { + keymap_config.no_gui = !keymap_config.no_gui; //toggle status + } else unregister_code16(keycode); + 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 + + 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; +}; + + +// 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 +} diff --git a/users/jonavin/jonavin.h b/users/jonavin/jonavin.h new file mode 100644 index 0000000000..894feddfd9 --- /dev/null +++ b/users/jonavin/jonavin.h @@ -0,0 +1,82 @@ + +/* Copyright 2021 Jonavin Eng @Jonavin + +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, + _LOWER, + _RAISE, +}; + +// 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 +}; + +#define KC_CAD LALT(LCTL(KC_DEL)) +#define KC_AF4 LALT(KC_F4) +#define KC_TASK LCTL(LSFT(KC_ESC)) + + +#ifdef TD_LSFT_CAPSLOCK_ENABLE + // Tap Dance Definitions + enum custom_tapdance { + TD_LSFT_CAPSLOCK, + TD_LSFT_CAPS_WIN + }; + + #define KC_LSFTCAPS TD(TD_LSFT_CAPSLOCK) + #define KC_LSFTCAPSWIN TD(TD_LSFT_CAPS_WIN) +#else // regular Shift + #define KC_LSFTCAPS KC_LSFT +#endif // TD_LSFT_CAPSLOCK_ENABLE + + + +#ifdef RGB_MATRIX_ENABLE +//RGB custom colours + #define RGB_GODSPEED 0x00, 0xE4, 0xFF // colour for matching keycaps + #define RGB_NAUTILUS 0x00, 0xA4, 0xA9 // Nautilus Font colours +#endif + + +// IDLE TIMEOUTS +#ifdef IDLE_TIMEOUT_ENABLE + #define TIMEOUT_THRESHOLD_DEFAULT 5 // 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); diff --git a/users/jonavin/readme.md b/users/jonavin/readme.md new file mode 100644 index 0000000000..97fff6520c --- /dev/null +++ b/users/jonavin/readme.md @@ -0,0 +1,76 @@ +Copyright 2021 Jonavin Eng @Jonavin + +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/>. + +LAYERS: + 0 = _BASE + 1 = _FN1 + 2 = _LOWER + 3 = _RAISE + +KEYCODES: + KC_CAD Ctrl-Alt-Del + KC_AF4 Alt-F4 + KC_TASK Windows Task Manager (Ctrl-Shift-Esc) + LSFT_CAPSLOCK When LSFT_CAPSLOCK_ENABLE is defined, hold for Shift double tap for CAPSLOCK; otherwise, just Shift + KC_00 double zero "00" + KC_WINLCK toggles LGui/Win key lock + RGB_TOI Increase Timeout idle time threshold + RGB_TOD Decrease Timeout idle time threshold + +ENABLE FEATURES your keymap rules.mk + +STARTUP_NUMLOCK_ON = yes + turns on NUMLOCK by default + +ENCODER_DEFAULTACTIONS_ENABLE = yes + Enabled default encoder funtions + When enabled, use this in the keymap for an additional encoder processing + bool encoder_update_keymap(uint8_t index, bool clockwise) + + OPTION: set ENCODER_DEFAULTACTIONS_INDEX to the encoder number if the encoder is not index 0 + +TD_LSFT_CAPSLOCK_ENABLE = yes + This will enable double tap on Left Shift to toggle CAPSLOCK + KC_LSFTCAPS to bind to left Shift to enable feature + KC_LSFTCAPSWIN does the same thing but will not turn on CAPS when Win Lkey is disabled + +IDLE_TIMEOUT_ENABLE = yes + Enables Timer functionality; for RGB idle timeouts that can be changed dynamically + When enabled, use this in the keymap for an additional matrix processing + void matrix_scan_keymap(void) + + Functions: + u16int_t get_timeout_threshold(void) // returns the current timeout threshold + void timeout_update_threshold(bool increase) // change threshold: true = increase, false = decrease + void timeout_reset_timer(void) // resets timer (put in process_record_user if you override it) + void timeout_tick_timer(void) // registers time ticks (put in maxtrix_scan_user if you override it) + +Other Functions: + - activate_numlock(bool turn_on) // true = turn on NUM LOCK, false = off + +KEYMAP LEVEL ADDITIONAL PROCESSING FUNCTIONS + bool process_record_keymap(uint16_t keycode, keyrecord_t *record) + void keyboard_post_init_keymap(void) + +LIST OF COMPATIBLE KEYMAPS + - gmmk/pro + - gmmk/pro/ansi + - keebio/quefrency/rev3 + - mechwild/mercutio + - mechwild/murphpad (*) + - mechwild/OBE (*) + - nopunin10did/kastenwagen (*) + + (*) coming soon diff --git a/users/jonavin/rules.mk b/users/jonavin/rules.mk new file mode 100644 index 0000000000..4e9ee08ff7 --- /dev/null +++ b/users/jonavin/rules.mk @@ -0,0 +1,13 @@ +SRC += jonavin.c +ifeq ($(strip $(ENCODER_DEFAULTACTIONS_ENABLE)), yes) + OPT_DEFS += -DENCODER_DEFAULTACTIONS_ENABLE +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 |