diff options
author | Daniel Rodríguez Rivero <rdanielo@gmail.com> | 2020-03-12 03:50:19 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-12 02:50:19 +0000 |
commit | 32d03eef902a1ac9cec53804dcb72ace5c585960 (patch) | |
tree | 579d91a2063fd5f6e64c1fc0de7ab5a0b7d34e0b /users | |
parent | f2f2afe13ba3ae1da8a546ad85eb9e69ddc70a8a (diff) | |
download | firmware-32d03eef902a1ac9cec53804dcb72ace5c585960.tar.gz firmware-32d03eef902a1ac9cec53804dcb72ace5c585960.tar.bz2 firmware-32d03eef902a1ac9cec53804dcb72ace5c585960.zip |
Danielo515/redox (#8232)
* feat(build): added script for compiling with docker easily
* chore: bring my own build with docker to master
* chore: delete a file that does not make sense anymore
* feat: first redox for danielo
* chore: basic compatibility between redox and my space
* refactor: removed some old stuff
* feat: added go coding symbols
* feat: name control_k and alt_j
* chore: reduce combo term
* feat: improved first layer of redox
* feat: add configurations to the redox
* feat: make alt tab more portable
* feat: small improvements to redox layout
* feat: added leader
* refactor: move leader defs to my userspace config
* chore: movement modified
* feat: more predefined keys and a a new combo
* feat: redox alt tab functionality
* refactor: move alt_tab processing to a separate file
* refactor: early return
* refactor: move process record to a separate file
* format leader function
* chore: backspace on digits layer
* feat: add extra combo
* feat: added more combos
* implement guard proposed by @drashna
Co-Authored-By: Drashna Jaelre <drashna@live.com>
* chore: include @drashna placeholder suggestion
Co-Authored-By: Drashna Jaelre <drashna@live.com>
Co-authored-by: Drashna Jaelre <drashna@live.com>
Diffstat (limited to 'users')
-rw-r--r-- | users/danielo515/alt_tab.c | 38 | ||||
-rw-r--r-- | users/danielo515/alt_tab.h | 4 | ||||
-rw-r--r-- | users/danielo515/combo.c | 35 | ||||
-rw-r--r-- | users/danielo515/config.h | 8 | ||||
-rw-r--r-- | users/danielo515/danielo515.c | 436 | ||||
-rw-r--r-- | users/danielo515/danielo515.h | 100 | ||||
-rw-r--r-- | users/danielo515/process_records.c | 167 | ||||
-rw-r--r-- | users/danielo515/process_records.h | 104 | ||||
-rw-r--r-- | users/danielo515/rules.mk | 4 | ||||
-rw-r--r-- | users/danielo515/tap_dance.h | 1 |
10 files changed, 424 insertions, 473 deletions
diff --git a/users/danielo515/alt_tab.c b/users/danielo515/alt_tab.c new file mode 100644 index 000000000..1602ee6fb --- /dev/null +++ b/users/danielo515/alt_tab.c @@ -0,0 +1,38 @@ +#include "danielo515.h" +#include "alt_tab.h" + +bool altPressed = false; +__attribute__((weak)) void alt_tab_activated(void){}; +__attribute__((weak)) void alt_tab_deactivated(void){}; +extern bool onMac; + +// =============== ALT_TAB single key handling +bool process_alt_tab(uint16_t keycode, keyrecord_t *record) { + switch (keycode) { + case ALT_TAB: + if (!record->event.pressed) { + return false; + } + if (altPressed) { + tap_code(KC_TAB); + } else { + altPressed = true; + onMac ? register_code(KC_LGUI) : register_code(KC_LALT); + tap_code(KC_TAB); + alt_tab_activated(); + } + // avoid alt releasing if the key is of movement + case KC_RIGHT ... KC_UP: + if (altPressed) { + return true; // yes QMK, do your stuff + } + } + // Reset sticky alt tab when any other key is pressed + if (altPressed) { + onMac ? unregister_code(KC_LGUI) : unregister_code(KC_LALT); + altPressed = false; + alt_tab_deactivated(); + return false; + } + return true; +}; diff --git a/users/danielo515/alt_tab.h b/users/danielo515/alt_tab.h new file mode 100644 index 000000000..f84350c29 --- /dev/null +++ b/users/danielo515/alt_tab.h @@ -0,0 +1,4 @@ +#pragma once +#include "quantum.h" + +bool process_alt_tab(uint16_t keycode, keyrecord_t *record); diff --git a/users/danielo515/combo.c b/users/danielo515/combo.c index bf7d5f9a8..1c8414377 100644 --- a/users/danielo515/combo.c +++ b/users/danielo515/combo.c @@ -1,21 +1,36 @@ #include "combo.h" + enum combos { - JK_ESC, - YU_COM, - UI_COM, - IO_COM, - OP_COM, - QW_COM + JK_ESC, + YU_COM, + UI_COM, + IO_COM, + QW_COM, + COM_SLS, + COM_DOT, + M_COMM, + N_M, + OP_COM, }; const uint16_t PROGMEM ui_combo[] = {KC_U, KC_I, COMBO_END}; const uint16_t PROGMEM jk_combo[] = {KC_J, KC_K, COMBO_END}; const uint16_t PROGMEM yu_combo[] = {KC_Y, KC_U, COMBO_END}; const uint16_t PROGMEM io_combo[] = {KC_I, KC_O, COMBO_END}; +const uint16_t PROGMEM qw_combo[] = {KC_Q, KC_W, COMBO_END}; +const uint16_t PROGMEM com_sls[] = {KC_COMMA, KC_SLSH, COMBO_END}; +const uint16_t PROGMEM com_dot[] = {KC_COMMA, KC_DOT, COMBO_END}; +const uint16_t PROGMEM m_comm[] = {KC_M,KC_COMMA, COMBO_END}; +const uint16_t PROGMEM n_m[] = {KC_N, KC_M,COMBO_END}; combo_t key_combos[COMBO_COUNT] = { - [JK_ESC] = COMBO(jk_combo, KC_ESC), - [YU_COM] = COMBO(yu_combo, KC_CIRC), - [UI_COM] = COMBO(ui_combo, KC_ESC), - [IO_COM] = COMBO(io_combo, KC_TILD) + [JK_ESC] = COMBO(jk_combo, KC_ESC), + [YU_COM] = COMBO(yu_combo, KC_CIRC), + [UI_COM] = COMBO(ui_combo, KC_DLR), + [IO_COM] = COMBO(io_combo, KC_TILD), + [QW_COM] = COMBO(qw_combo, KC_AT), + [COM_SLS] = COMBO(com_sls, KC_QUES), + [COM_DOT] = COMBO(com_dot, KC_QUES), + [M_COMM] = COMBO(m_comm, KC_ESC), + [N_M] = COMBO(n_m, KC_DLR), }; diff --git a/users/danielo515/config.h b/users/danielo515/config.h index 65654388d..fb2472645 100644 --- a/users/danielo515/config.h +++ b/users/danielo515/config.h @@ -1,6 +1,10 @@ #pragma once #if defined(COMBO_ENABLE) - #define COMBO_COUNT 4 - #define COMBO_TERM 50 + #define COMBO_COUNT 9 + #define COMBO_TERM 40 #endif // !COMBO_ENABLE +// Timeout settings for leader key +#undef LEADER_TIMEOUT +#define LEADER_TIMEOUT 350 +#define LEADER_PER_KEY_TIMING diff --git a/users/danielo515/danielo515.c b/users/danielo515/danielo515.c index f37eebb37..f08365027 100644 --- a/users/danielo515/danielo515.c +++ b/users/danielo515/danielo515.c @@ -1,373 +1,87 @@ #include "danielo515.h" bool onMac = true; -// Send control or GUI depending if we are on windows or mac -bool CMD(uint16_t kc) { - if(onMac){ tap_code16(LGUI(kc)); } else { tap_code16(LCTL(kc)); } - return false; -} - -//**************** Handle keys function *********************// -bool altPressed = false; - -bool process_record_user(uint16_t keycode, keyrecord_t *record) -{ - bool pressed = record->event.pressed; - if(pressed){ - refresh_incremental_macros(keycode); - if(process_incremental_macro(keycode)){ - return false; - } - if(is_macro(keycode)){ - return handle_macro(keycode); - } - switch (keycode) { - case MAC_TGL: - onMac = !onMac; - onMac ? SEND_STRING("On mac") : SEND_STRING("Not on MAC"); - return false; - } - } - switch (keycode) - { - case QWERTY: - if (record->event.pressed) { - #ifdef AUDIO_ENABLE - PLAY_SONG(tone_qwerty); - #endif - layer_on(_QWERTY); +//**************** LEADER *********************// +#ifdef LEADER_ENABLE +LEADER_EXTERNS(); +# ifdef RGBLIGHT_ENABLE + +void leader_start() { rgblight_setrgb_range(5, 100, 199, 10, 15); }; + +void leader_end() { rgblight_setrgb_range(200, 200, 255, 10, 15); }; +# endif + +void matrix_scan_user(void) { + if (leading && leader_sequence_size > 0 && timer_elapsed(leader_time) > LEADER_TIMEOUT) { + leading = false; + SEQ_ONE_KEY(KC_T) { SEND_STRING("``" SS_TAP(X_LEFT)); } + // Triple ticks + SEQ_TWO_KEYS(KC_T, KC_T) { SEND_STRING("```" SS_TAP(X_ENTER) SS_TAP(X_ENTER) "```" SS_TAP(X_UP)); } + // ==== International spanish accent vowels ==== + SEQ_ONE_KEY(KC_A) { SEND_STRING(SS_LALT("e") "a"); } + SEQ_ONE_KEY(KC_E) { SEND_STRING(SS_LALT("e") "e"); } + SEQ_ONE_KEY(KC_I) { SEND_STRING(SS_LALT("e") "i"); } + SEQ_ONE_KEY(KC_O) { SEND_STRING(SS_LALT("e") "o"); } + SEQ_ONE_KEY(KC_U) { SEND_STRING(SS_LALT("e") "u"); } + SEQ_ONE_KEY(KC_N) { SEND_STRING(SS_LALT("n") "n"); } + // ==== MACROS === + SEQ_ONE_KEY(KC_G) { SEND_STRING(" | grep "); } + SEQ_ONE_KEY(KC_K) { onMac ? SEND_STRING(SS_LCTRL(" ")) : SEND_STRING(SS_LCTRL("f")); } + // vim delete all + SEQ_TWO_KEYS(KC_D, KC_G) { + if (onMac) { + SEND_STRING(SS_LGUI("a") SS_TAP(X_D)); + } else { + SEND_STRING(SS_LCTRL("a") SS_TAP(X_D)); + } } - return false; - case LOWER: - if (record->event.pressed) { - layer_on(_LOWER); - update_tri_layer(_LOWER, _RAISE, _ADJUST); - } else { - layer_off(_LOWER); - update_tri_layer(_LOWER, _RAISE, _ADJUST); + // tripe delete! + SEQ_ONE_KEY(KC_BSPACE) { SEND_STRING(SS_TAP(X_BSPACE) SS_TAP(X_BSPACE) SS_TAP(X_BSPACE)); } + SEQ_TWO_KEYS(KC_P, KC_G) { SEND_STRING("ps -ef | grep "); } + SEQ_TWO_KEYS(KC_J, KC_A) { SEND_STRING("() => {}" SS_TAP(X_LEFT) SS_TAP(X_LEFT) SS_TAP(X_LEFT) SS_TAP(X_LEFT) SS_TAP(X_LEFT) SS_TAP(X_LEFT) SS_TAP(X_LEFT)); } + // this is a pain to type + SEQ_TWO_KEYS(KC_S, KC_S) { SEND_STRING("~/.ssh/ "); } + SEQ_TWO_KEYS(KC_F, KC_T) { SEND_STRING("feat():" SS_TAP(X_LEFT) SS_TAP(X_LEFT)); } + // ### LAYER CHANGE + SEQ_ONE_KEY(KC_1) { layer_on(1); } + // control enter, because yes + SEQ_ONE_KEY(KC_H) { SEND_STRING(SS_DOWN(X_LCTRL) SS_TAP(X_ENTER) SS_UP(X_LCTRL)); } + // paste all + SEQ_ONE_KEY(KC_P) { + if (onMac) { + SEND_STRING(SS_LGUI("a") SS_LGUI("v")); + } else { + SEND_STRING(SS_LCTRL("a") SS_LCTRL("v")); + } } - return false; - case RAISE: - if (record->event.pressed) { - layer_on(_RAISE); - update_tri_layer(_LOWER, _RAISE, _ADJUST); - } else { - layer_off(_RAISE); - update_tri_layer(_LOWER, _RAISE, _ADJUST); + SEQ_THREE_KEYS(KC_M, KC_A, KC_C) { + onMac = true; +# ifdef RGBLIGHT_ENABLE + rgblight_setrgb(255, 255, 255); +# endif } - return false; - case ADJUST: - if (record->event.pressed) { - layer_on(_ADJUST); - } else { - layer_off(_ADJUST); + SEQ_THREE_KEYS(KC_W, KC_I, KC_N) { + onMac = false; +# ifdef RGBLIGHT_ENABLE + rgblight_setrgb(255, 255, 0); +# endif } - return false; - // == Macros START === - case ARROW: - if (record->event.pressed) SEND_STRING("->"); - return false; - case F_ARROW: - if (record->event.pressed) SEND_STRING("=>"); - return false; - case GREP: - if (record->event.pressed) SEND_STRING(" | grep "); return false; - // == Macros END === - // == Multi Os START === - case KC_HOME:// make the home behave the same on OSX - if (record->event.pressed && onMac) { - SEND_STRING(SS_LCTRL("a")); - return false; - } - case KC_END:// make the end behave the same on OSX - if (record->event.pressed && onMac) { - tap_code16(C(KC_E)); - return false; - } - case AC_A:// Accent á - if (record->event.pressed) SEND_STRING(SS_LALT("e") "a"); return false; - case AC_E:// Accent é - if (record->event.pressed) SEND_STRING(SS_LALT("e") "e"); return false; - case AC_I:// Accent í - if (record->event.pressed) SEND_STRING(SS_LALT("e") "i"); return false; - case AC_O:// Accent ó - if (record->event.pressed) SEND_STRING(SS_LALT("e") "o"); return false; - case CUT: if (record->event.pressed) return CMD(KC_X); - case COPY: - if (record->event.pressed) { - onMac ? SEND_STRING(SS_LGUI("c")) : SEND_STRING(SS_LCTRL("c")); - } - return false; - case PASTE: - if (record->event.pressed) { - onMac ? SEND_STRING(SS_LGUI("v")) : SEND_STRING(SS_LCTRL("v")); - } - return false; - case SAVE: - if (record->event.pressed) { - onMac ? SEND_STRING(SS_LGUI("s")) : SEND_STRING(SS_LCTRL("s")); - } - return false; - case UNDO: - if (record->event.pressed) { - onMac ? SEND_STRING(SS_LGUI("z")) : SEND_STRING(SS_LCTRL("z")); - } - return false; - case FIND: - if (record->event.pressed) { - onMac ? SEND_STRING(SS_LGUI("f")) : SEND_STRING(SS_LCTRL("f")); - } - return false; - case CHG_LAYOUT: - if (record->event.pressed) { - onMac ? SEND_STRING(SS_LCTRL(" ")) : SEND_STRING(SS_LCTRL("f")); - } - return false; - // == Multi Os END === -#ifdef RGBLIGHT_ENABLE - case RGB_SLD: - if (record->event.pressed) { rgblight_mode(1); } - return false; - break; - //First time alt + tab, and alt stays sticky. Next press we just send tab. Any other key releases the alt -#endif - case ALT_TAB: - if (record->event.pressed) - { - if (altPressed) - { - tap_code(KC_TAB); - } - else - { - altPressed = true; - layer_on(7); // go to movement layer - onMac ? register_code(KC_LGUI) : register_code(KC_LALT); - tap_code(KC_TAB); - } - } - return false; - // avoid alt releasing if the key is of movement - case KC_RIGHT ... KC_UP: - if (altPressed) - { - return true; // yes QMK, do your stuff - } - } - // Reset sticky alt tab - if (altPressed) - { - onMac ? unregister_code(KC_LGUI) : unregister_code(KC_LALT); - altPressed = false; - layer_off(7); - return false; - } - return true; -}; - -//**************** LEADER *********************// -#ifdef LEADER_ENABLE -LEADER_EXTERNS(); -#ifdef RGBLIGHT_ENABLE - -void leader_start() { - rgblight_setrgb_range(5, 100, 199, 10,15); -}; - -void leader_end(){ - rgblight_setrgb_range(200, 200, 255, 10,15); -}; -#endif - -void matrix_scan_user(void) -{ - if (leading && leader_sequence_size > 0 && timer_elapsed(leader_time) > LEADER_TIMEOUT) - { - leading = false; - SEQ_ONE_KEY(KC_T) { - SEND_STRING("``" SS_TAP(X_LEFT)); - } - // Triple ticks - SEQ_TWO_KEYS(KC_T, KC_T) { - SEND_STRING("```" SS_TAP(X_ENTER) SS_TAP(X_ENTER) "```" SS_TAP(X_UP)); - } - // ==== International spanish accent vowels ==== - SEQ_ONE_KEY(KC_A) { - SEND_STRING(SS_LALT("e") "a"); - } - SEQ_ONE_KEY(KC_E) { - SEND_STRING(SS_LALT("e") "e"); - } - SEQ_ONE_KEY(KC_I) { - SEND_STRING(SS_LALT("e") "i"); - } - SEQ_ONE_KEY(KC_O) { - SEND_STRING(SS_LALT("e") "o"); - } - SEQ_ONE_KEY(KC_U) { - SEND_STRING(SS_LALT("e") "u"); - } - SEQ_ONE_KEY(KC_N) { // ñ - SEND_STRING(SS_LALT("n") "n"); - } - // ==== MACROS === - SEQ_ONE_KEY(KC_G) { // grep - SEND_STRING(" | grep "); - } - SEQ_ONE_KEY(KC_K) { - onMac ? SEND_STRING(SS_LCTRL(" ")) : SEND_STRING(SS_LCTRL("f")); - } - SEQ_TWO_KEYS(KC_D, KC_G) { // vim delete all - if(onMac){ - SEND_STRING(SS_LGUI("a") SS_TAP(X_D)); - } else { - SEND_STRING(SS_LCTRL("a") SS_TAP(X_D)); - } - } - SEQ_ONE_KEY(KC_BSPACE) { // tripe delete! - SEND_STRING(SS_TAP(X_BSPACE) SS_TAP(X_BSPACE) SS_TAP(X_BSPACE)); - } - SEQ_TWO_KEYS(KC_P, KC_G) { - SEND_STRING("ps -ef | grep "); - } - SEQ_TWO_KEYS(KC_J, KC_A) { - SEND_STRING("() => {}"SS_TAP(X_LEFT) SS_TAP(X_LEFT)SS_TAP(X_LEFT) SS_TAP(X_LEFT)SS_TAP(X_LEFT) SS_TAP(X_LEFT)SS_TAP(X_LEFT)); - } - SEQ_TWO_KEYS(KC_S, KC_S) { - SEND_STRING("~/.ssh/ "); // this is a pain to type - } - SEQ_TWO_KEYS(KC_F, KC_T) { - SEND_STRING("feat():" SS_TAP(X_LEFT) SS_TAP(X_LEFT)); - } - // ### LAYER CHANGE - SEQ_ONE_KEY(KC_1) { - layer_on(1); - } - SEQ_ONE_KEY(KC_H) { // control enter, because yes - SEND_STRING(SS_DOWN(X_LCTRL) SS_TAP(X_ENTER) SS_UP(X_LCTRL)); - } - // paste all - SEQ_ONE_KEY(KC_P) { - if(onMac){ - SEND_STRING(SS_LGUI("a") SS_LGUI("v")); - } else { - SEND_STRING(SS_LCTRL("a") SS_LCTRL("v")); - } - } - SEQ_THREE_KEYS(KC_M, KC_A, KC_C) { - onMac = true; - #ifdef RGBLIGHT_ENABLE - rgblight_setrgb(255, 255, 255); - #endif - } - SEQ_THREE_KEYS(KC_W, KC_I, KC_N) { - onMac = false; - #ifdef RGBLIGHT_ENABLE - rgblight_setrgb(255, 255, 0); - #endif - } - /* Copy all */ - SEQ_ONE_KEY(KC_Y) { - if(onMac){ - SEND_STRING(SS_LGUI("a") SS_LGUI("c")); - } else { - SEND_STRING(SS_LCTRL("a") SS_LCTRL("c")); - } - } - //emoji bar - SEQ_TWO_KEYS(KC_E, KC_E) { - SEND_STRING(SS_DOWN(X_LGUI) SS_LCTRL(" ") SS_UP(X_LGUI)); - } - - SEQ_TWO_KEYS(KC_F, KC_F) { - SEND_STRING("ps -ef | grep "); - } - SEQ_TWO_KEYS(KC_H, KC_T) { - SEND_STRING("https://"); - } - - leader_end(); - } -} -#endif // LEADER - -// ======== INCREMENTAL MACROS STUFF ============= - -#define MAX_INCREMENTAL_MACRO 20 -#define TAP_ROTATION_TIMEOUT 400 - -uint16_t latest_kc = 0; -uint16_t latest_rotation = 0; -int key_count = 0; - -const char incremental_macros[][MAX_INCREMENTAL_MACRO] = { "String1"SS_TAP(X_HOME)"X-", "String2"SS_TAP(X_HOME) }; - -bool process_incremental_macro (uint16_t kc) { - - if( kc < INC_MACROS_START || kc > INC_MACROS_END ){ - return false; - } - int macro_idx = (int) (kc - INC_MACROS_START) - 1; - char tempstring[3] = {0}; - tempstring[0] = incremental_macros[macro_idx][key_count]; - // Special cases of SS_TAP SS_UP and SS_DOWN, they require two characters so get both once and skip on next iteration - if( tempstring[0] == '\1' || tempstring[0] == '\2' || tempstring[0] == '\3'){ - tempstring[1] = incremental_macros[macro_idx][++key_count]; - } - if( tempstring[0] == '\0'){ - key_count = 0; - } - send_string(tempstring); + /* Copy all */ + SEQ_ONE_KEY(KC_Y) { + if (onMac) { + SEND_STRING(SS_LGUI("a") SS_LGUI("c")); + } else { + SEND_STRING(SS_LCTRL("a") SS_LCTRL("c")); + } + } + // emoji bar + SEQ_TWO_KEYS(KC_E, KC_E) { SEND_STRING(SS_DOWN(X_LGUI) SS_LCTRL(" ") SS_UP(X_LGUI)); } - return true; -}; + SEQ_TWO_KEYS(KC_F, KC_F) { SEND_STRING("ps -ef | grep "); } + SEQ_TWO_KEYS(KC_H, KC_T) { SEND_STRING("https://"); } -void refresh_incremental_macros (uint16_t kc) { - if (kc == latest_kc) - { - if ( (timer_elapsed(latest_rotation) > TAP_ROTATION_TIMEOUT) || (key_count >= MAX_INCREMENTAL_MACRO) ) key_count = 0; - else key_count++; - } else { - key_count = 0; - latest_kc = kc; + leader_end(); } - - latest_rotation = timer_read(); } - - -// ======== VISUAL STUDIO CODE SHORTCUTS STUFF - -bool is_macro (uint16_t kc){ - return kc > MACRO_START && kc < MACRO_END; -}; - -bool command_shift_p (bool isMac) { - isMac - ? SEND_STRING(SS_DOWN(X_LSHIFT)SS_LGUI("p")SS_UP(X_LSHIFT)) - : SEND_STRING(SS_DOWN(X_LSHIFT)SS_LCTRL("p")SS_UP(X_LSHIFT)); - return false; -}; - -bool VSCommand(bool isMac, char *cmd) -{ - command_shift_p (isMac); - send_string(cmd); - SEND_STRING(SS_TAP(X_ENTER)); - return false; -}; - -bool handle_macro(uint16_t kc) -{ - switch (kc) - { - case T_TERM: return VSCommand(onMac, "toit"); - case FIX_ALL: return VSCommand(onMac, "faap"); - case BLK_CMNT: return VSCommand(onMac, "tbc"); - case LN_CMNT: return VSCommand(onMac, "tlic"); - case CMD_S_P: return command_shift_p(onMac); - case TRI_TICKS: SEND_STRING("[[[ "); break; - } - return false; -}; +#endif // LEADER diff --git a/users/danielo515/danielo515.h b/users/danielo515/danielo515.h index 95c01b6e8..715e8132f 100644 --- a/users/danielo515/danielo515.h +++ b/users/danielo515/danielo515.h @@ -1,104 +1,6 @@ #pragma once - #include "quantum.h" - - -bool handle_macro(uint16_t kc); -bool is_macro (uint16_t kc); -bool process_incremental_macro (uint16_t); -void refresh_incremental_macros (uint16_t); -//**************** KEYCODES *********************// - -enum custom_keycodes -{ - PLACEHOLDER = SAFE_RANGE, // can always be here - EPRM, - RGB_SLD, - ALT_TAB, - // Macros - ARROW, - F_ARROW, - QWERTY, - GREP, - // Accented characters - AC_A, - AC_E, - AC_I, - AC_O, - // Custom multi-os key-codes - CUT, - COPY, - PASTE, - SAVE, - UNDO, - CHG_LAYOUT, - FIND, - // OTHER OLD STUFF - LOWER, - RAISE, - ADJUST, - MAC_TGL, - MACRO_START, // START OF VSC DECLARATIONS - T_TERM, - FIX_ALL, - BLK_CMNT, - LN_CMNT, - CMD_S_P, - TRI_TICKS, - MACRO_END, // END OF VSC DECLARATIONS - INC_MACROS_START, - INC_MACROS_END, -}; - - -enum layers { - _QWERTY, - _LOWER, - _RAISE, - _F, - _D, - _A, - _S, - _J, - _K, - _MACROS, - _ADJUST, - _SAFE_LAYER -}; - -// Function letters -#define FN_F LT(_F,KC_F) -#define FN_D LT(_D,KC_D) -#define FN_S LT(_S,KC_S) -#define FN_A LT(_A,KC_A) -#define FN_K LT(_K,KC_K) -#define FN_J LT(_J,KC_J) -#define KC_FN_D FN_D -#define KC_FN_S FN_S -#define KC_FN_F FN_F - -#define KC_MACROS OSL(_MACROS) - - -#define KC_E_COLN LSFT(KC_DOT) -#define KC_E_EQL ES_EQL -#define KC_GUI OSM(MOD_RGUI) -#define KC_R_NUB S(KC_NUBS) -#define KC_E_LT KC_NUBS -#define KC_E_GT S(KC_NUBS) -#define KC_E_TILD ES_TILD -#define KC_E_MINS ES_MINS -#define KC_S_SPC SFT_T(KC_SPC) // Tap for Space, hold for Shift -#define KC_E_OVRR ES_OVRR -#define KC_E_APOS ES_APOS -#define KC_E_IEXL ES_IEXL -// Short hand for complex key combinations -# define WIN_LEFT_HALF LALT(LGUI(KC_LEFT)) -# define WIN_RIGHT_HALF LALT(LGUI(KC_RIGHT)) -# define WIN_TO_LEFT LALT(LSFT( LGUI(KC_LEFT) )) -# define WIN_TO_RIGHT LALT(LSFT( LGUI(KC_RIGHT) )) - -// Ready to use Tap dance definitions, just put them on your layout +#include "process_records.h" #ifdef TAP_DANCE_ENABLE #include "tap_dance.h" diff --git a/users/danielo515/process_records.c b/users/danielo515/process_records.c new file mode 100644 index 000000000..b1a8b9255 --- /dev/null +++ b/users/danielo515/process_records.c @@ -0,0 +1,167 @@ +#include "process_records.h" +#include "alt_tab.h" +extern bool onMac; +// ======== INCREMENTAL MACROS STUFF ============= +#define MAX_INCREMENTAL_MACRO 20 +#define TAP_ROTATION_TIMEOUT 400 +uint16_t latest_kc = 0; +uint16_t latest_rotation = 0; +int key_count = 0; + +const char incremental_macros[][MAX_INCREMENTAL_MACRO] = { "String1"SS_TAP(X_HOME)"X-", "String2"SS_TAP(X_HOME) }; + +bool process_incremental_macro(uint16_t kc) { + if (kc < INC_MACROS_START || kc > INC_MACROS_END) { + return false; + } + int macro_idx = (int)(kc - INC_MACROS_START) - 1; + char tempstring[3] = {0}; + tempstring[0] = incremental_macros[macro_idx][key_count]; + // Special cases of SS_TAP SS_UP and SS_DOWN, they require two characters so get both once and skip on next iteration + if (tempstring[0] == '\1' || tempstring[0] == '\2' || tempstring[0] == '\3') { + tempstring[1] = incremental_macros[macro_idx][++key_count]; + } + if (tempstring[0] == '\0') { + key_count = 0; + } + send_string(tempstring); + + return true; +}; + +void refresh_incremental_macros(uint16_t kc) { + if (kc == latest_kc) { + if ((timer_elapsed(latest_rotation) > TAP_ROTATION_TIMEOUT) || (key_count >= MAX_INCREMENTAL_MACRO)) + key_count = 0; + else + key_count++; + } else { + key_count = 0; + latest_kc = kc; + } + + latest_rotation = timer_read(); +} +// Send control or GUI depending if we are on windows or mac +bool CMD(uint16_t kc) { + if(onMac){ tap_code16(LGUI(kc)); } else { tap_code16(LCTL(kc)); } + return false; +} + +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + bool pressed = record->event.pressed; + if(pressed){ + refresh_incremental_macros(keycode); + if(process_incremental_macro(keycode)){ + return false; + } + switch (keycode) { + case MAC_TGL: + onMac = !onMac; + onMac ? SEND_STRING("On mac") : SEND_STRING("Not on MAC"); + return false; + } + } + + switch (keycode) { + case QWERTY: + if (record->event.pressed) { + #ifdef AUDIO_ENABLE + PLAY_SONG(tone_qwerty); + #endif + layer_on(_QWERTY); + } + return false; + case LOWER: + if (record->event.pressed) { + layer_on(_LOWER); + } else { + layer_off(_LOWER); + } + return false; + case RAISE: + if (record->event.pressed) { + layer_on(_RAISE); + } else { + layer_off(_RAISE); + } + return false; + case ADJUST: + if (record->event.pressed) { + layer_on(_ADJUST); + } else { + layer_off(_ADJUST); + } + return false; + // == Macros START === + case IARROW: if (record->event.pressed) SEND_STRING("<-"); return false; + case ARROW: if (record->event.pressed) SEND_STRING("->"); return false; + case F_ARROW: if (record->event.pressed) SEND_STRING("=>"); return false; + case GREP: if (record->event.pressed) SEND_STRING(" | grep "); return false; + case CLN_EQ: if (record->event.pressed) SEND_STRING(":="); return false; + // == Macros END === + // == Multi Os START === + case KC_HOME:// make the home behave the same on OSX + if (record->event.pressed && onMac) { + SEND_STRING(SS_LCTRL("a")); + return false; + } + case KC_END:// make the end behave the same on OSX + if (record->event.pressed && onMac) { + tap_code16(C(KC_E)); + return false; + } + case AC_A:// Accent á + if (record->event.pressed) SEND_STRING(SS_LALT("e") "a"); return false; + case AC_E:// Accent é + if (record->event.pressed) SEND_STRING(SS_LALT("e") "e"); return false; + case AC_I:// Accent í + if (record->event.pressed) SEND_STRING(SS_LALT("e") "i"); return false; + case AC_O:// Accent ó + if (record->event.pressed) SEND_STRING(SS_LALT("e") "o"); return false; + case CUT: if (record->event.pressed) return CMD(KC_X); + case COPY: + if (record->event.pressed) { + onMac ? SEND_STRING(SS_LGUI("c")) : SEND_STRING(SS_LCTRL("c")); + } + return false; + case PASTE: + if (record->event.pressed) { + onMac ? SEND_STRING(SS_LGUI("v")) : SEND_STRING(SS_LCTRL("v")); + } + return false; + case SAVE: + if (record->event.pressed) { + onMac ? SEND_STRING(SS_LGUI("s")) : SEND_STRING(SS_LCTRL("s")); + } + return false; + case UNDO: + if (record->event.pressed) { + onMac ? SEND_STRING(SS_LGUI("z")) : SEND_STRING(SS_LCTRL("z")); + } + return false; + case FIND: + if (record->event.pressed) { + onMac ? SEND_STRING(SS_LGUI("f")) : SEND_STRING(SS_LCTRL("f")); + } + return false; + case CHG_LAYOUT: + if (record->event.pressed) { + onMac ? SEND_STRING(SS_LCTRL(" ")) : SEND_STRING(SS_LCTRL("f")); + } + return false; + // == Multi Os END === +#ifdef RGBLIGHT_ENABLE + case RGB_SLD: + if (record->event.pressed) { rgblight_mode(1); } + return false; + break; + //First time alt + tab, and alt stays sticky. Next press we just send tab. Any other key releases the alt +#endif + } +// =============== ALT_TAB single key handling + return process_alt_tab(keycode, record); +}; + + + diff --git a/users/danielo515/process_records.h b/users/danielo515/process_records.h new file mode 100644 index 000000000..c994511a5 --- /dev/null +++ b/users/danielo515/process_records.h @@ -0,0 +1,104 @@ +#pragma once +#include "quantum.h" + +enum custom_keycodes +{ + EPRM = SAFE_RANGE, + RGB_SLD, + ALT_TAB, + QWERTY, + SYM, + NAV, + ADJUST, +// Macros + ARROW, + IARROW, + CLN_EQ, + F_ARROW, + GREP, +// Accented characters + AC_A, + AC_E, + AC_I, + AC_O, +// Custom multi-os key-codes + CUT, + COPY, + PASTE, + SAVE, + UNDO, + CHG_LAYOUT, + FIND, +// OTHER OLD STUFF + LOWER, + RAISE, + MAC_TGL, + INC_MACROS_START, + INC_MACROS_END, +}; + +//**************** KEYCODES *********************// +enum layers { + _QWERTY, + _SYMB, + _NAV, + _ADJUST, + _F, + _D, + _S, + _A, + _J, + _K, + // iris specific - TBD + _LOWER, + _RAISE, + _MACROS, + _SAFE_LAYER +}; + +//===== Function letters +# define FN_F LT(_F,KC_F) +# define FN_D LT(_D,KC_D) +# define FN_S LT(_S,KC_S) +# define FN_A LT(_A,KC_A) +# define FN_K LT(_K,KC_K) +# define FN_J LT(_J,KC_J) +# define KC_FN_D FN_D +# define KC_FN_S FN_S +# define KC_FN_F FN_F + +# define KC_MACROS OSL(_MACROS) + + +# define KC_E_COLN LSFT(KC_DOT) +# define KC_E_EQL ES_EQL +# define KC_GUI OSM(MOD_RGUI) +# define KC_R_NUB S(KC_NUBS) +# define KC_E_LT KC_NUBS +# define KC_E_GT S(KC_NUBS) +# define KC_E_TILD ES_TILD +# define KC_E_MINS ES_MINS +# define KC_E_OVRR ES_OVRR +# define KC_E_APOS ES_APOS +# define KC_E_IEXL ES_IEXL +//========== Short hand for complex key combinations +# define WIN_LEFT_HALF LALT(LGUI(KC_LEFT)) +# define WIN_RIGHT_HALF LALT(LGUI(KC_RIGHT)) +# define WIN_TO_LEFT LALT(LSFT( LGUI(KC_LEFT) )) +# define WIN_TO_RIGHT LALT(LSFT( LGUI(KC_RIGHT) )) +# define ALL_WIN LCTL(KC_DOWN) +# define EXPOSE LGUI(KC_DOWN) +// ========== Modifiers!! +# define SHIFT OSM(MOD_LSFT) +//=============== tap for key hold for mod +# define HYPR_H HYPR_T(KC_H) +# define CTL_K RCTL_T(KC_K) +# define ALT_J ALT_T(KC_J) +# define SFT_MINS LSFT_T(KC_MINS) // tap - hold shift +# define CMD_QUOT GUI_T(KC_QUOTE) // tap ' hold cmd +//=============== Movement modified +# define CTL_LEFT LCTL(KC_LEFT) +# define CTL_RIGHT LCTL(KC_RIGHT) + +# define SFT_LEFT LSFT(KC_LEFT) +# define SFT_RIGHT LSFT(KC_RIGHT) diff --git a/users/danielo515/rules.mk b/users/danielo515/rules.mk index 091baf20c..c77e2f015 100644 --- a/users/danielo515/rules.mk +++ b/users/danielo515/rules.mk @@ -1,4 +1,6 @@ -SRC += danielo515.c +SRC += danielo515.c \ + alt_tab.c \ + process_records.c ifeq ($(strip $(COMBO_ENABLE)), yes) SRC += combo.c diff --git a/users/danielo515/tap_dance.h b/users/danielo515/tap_dance.h index 6ec4fe13c..880ad525e 100644 --- a/users/danielo515/tap_dance.h +++ b/users/danielo515/tap_dance.h @@ -57,6 +57,7 @@ void dance_cut (qk_tap_dance_state_t *state, void *user_data); void dance_copy (qk_tap_dance_state_t *state, void *user_data); void dance_paste (qk_tap_dance_state_t *state, void *user_data); +// Ready to use Tap dance definitions, just put them on your layout #define TD_COPY TD(_TD_COPY) #define TD_CUT TD(_TD_CUT) #define KC_TD_COPY TD(_TD_COPY) // Declarations for macros that add KC_ |