From edf4c932f2117b611712fb65cc7bcbb5d5e738dd Mon Sep 17 00:00:00 2001 From: Victor Date: Tue, 2 Jul 2024 23:29:06 -0500 Subject: [PATCH] Added super alt-tab - going to remove it though so I can hold different mods for chrome and windows. Wanted to save the code since I spent time working on it - General code cleanup - introduced klor and rollow keyboard.json - set encoder resolution to 4 for alt tab to work right --- .../rollow/{info.json => keyboard.json} | 0 .../rollow/keymaps/t4corun/keymap.c | 16 ++-- .../bluebell/swoop/keymaps/t4corun/config.h | 6 ++ .../bluebell/swoop/keymaps/t4corun/keymap.c | 16 ++-- .../klor/{info.json => 2040/keyboard.json} | 4 +- keyboards/klor/keymaps/t4corun/config.h | 8 +- keyboards/klor/keymaps/t4corun/keymap.c | 16 ++-- users/t4corun/features/capsword.c | 8 +- users/t4corun/features/combo.c | 6 +- users/t4corun/features/combo.h | 1 - users/t4corun/features/luna.c | 12 +-- users/t4corun/features/luna.h | 2 - users/t4corun/features/oled.c | 79 +++++++++---------- users/t4corun/features/oled.h | 18 ++--- users/t4corun/features/taphold.c | 19 +---- users/t4corun/features/taphold.h | 8 +- users/t4corun/rules.mk | 4 +- users/t4corun/t4corun.c | 49 +++++++++++- users/t4corun/t4corun.h | 29 ++++--- 19 files changed, 172 insertions(+), 129 deletions(-) rename keyboards/barbellboards/rollow/{info.json => keyboard.json} (100%) rename keyboards/klor/{info.json => 2040/keyboard.json} (99%) diff --git a/keyboards/barbellboards/rollow/info.json b/keyboards/barbellboards/rollow/keyboard.json similarity index 100% rename from keyboards/barbellboards/rollow/info.json rename to keyboards/barbellboards/rollow/keyboard.json diff --git a/keyboards/barbellboards/rollow/keymaps/t4corun/keymap.c b/keyboards/barbellboards/rollow/keymaps/t4corun/keymap.c index f3f955d5..701ac066 100644 --- a/keyboards/barbellboards/rollow/keymaps/t4corun/keymap.c +++ b/keyboards/barbellboards/rollow/keymaps/t4corun/keymap.c @@ -36,14 +36,14 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { /* These are horizontal encoders. Found I have to make it opposite the rotary encoders for it to feel intuitive*/ const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][NUM_DIRECTIONS] = { - [_QWERTY] = { ENCODER_CCW_CW(KC_WH_D, KC_WH_U), ENCODER_CCW_CW(KC_VOLU, KC_VOLD) }, - [_COLEMAK_DH] = { ENCODER_CCW_CW(KC_WH_D, KC_WH_U), ENCODER_CCW_CW(KC_VOLU, KC_VOLD) }, - [_GAME] = { ENCODER_CCW_CW(KC_WH_D, KC_WH_U), ENCODER_CCW_CW(KC_VOLU, KC_VOLD) }, - [_NAVIGATION] = { ENCODER_CCW_CW(ZOOMIN, ZOOMOUT), ENCODER_CCW_CW(___x___, ___x___) }, - [_NUMBER] = { ENCODER_CCW_CW(___x___, ___x___), ENCODER_CCW_CW(KC_RGHT, KC_LEFT) }, - [_SYMBOL] = { ENCODER_CCW_CW(___x___, ___x___), ENCODER_CCW_CW(___x___, ___x___) }, - [_MOUSE_FUNC] = { ENCODER_CCW_CW(KC_WH_D, KC_WH_U), ENCODER_CCW_CW(KC_VOLU, KC_VOLD) }, - [_CONFIG] = { ENCODER_CCW_CW(BASELYR, RBSELYR), ENCODER_CCW_CW(RGB_MOD, RGB_RMOD) } + [_QWERTY] = { ENCODER_CCW_CW(KC_WH_D, KC_WH_U), ENCODER_CCW_CW(KC_VOLU, KC_VOLD) }, + [_COLEMAK_DH] = { ENCODER_CCW_CW(KC_WH_D, KC_WH_U), ENCODER_CCW_CW(KC_VOLU, KC_VOLD) }, + [_GAME] = { ENCODER_CCW_CW(KC_WH_D, KC_WH_U), ENCODER_CCW_CW(KC_VOLU, KC_VOLD) }, + [_NAVIGATION] = { ENCODER_CCW_CW(___x___, ___x___), ENCODER_CCW_CW(___x___, ___x___) }, + [_NUMBER] = { ENCODER_CCW_CW(___x___, ___x___), ENCODER_CCW_CW(ALT_TAB, RALT_TB) }, + [_SYMBOL] = { ENCODER_CCW_CW(___x___, ___x___), ENCODER_CCW_CW(___x___, ___x___) }, + [_MOUSE_FUNC] = { ENCODER_CCW_CW(KC_WH_D, KC_WH_U), ENCODER_CCW_CW(ZOOMIN, ZOOMOUT) }, + [_CONFIG] = { ENCODER_CCW_CW(BASELYR, RBSELYR), ENCODER_CCW_CW(BASELYR, RBSELYR) } }; diff --git a/keyboards/bluebell/swoop/keymaps/t4corun/config.h b/keyboards/bluebell/swoop/keymaps/t4corun/config.h index e6813ab9..fd166ed9 100644 --- a/keyboards/bluebell/swoop/keymaps/t4corun/config.h +++ b/keyboards/bluebell/swoop/keymaps/t4corun/config.h @@ -18,3 +18,9 @@ along with this program. If not, see . #define RGB_MATRIX_LED_COUNT 36 #define RGB_MATRIX_SPLIT { 18, 18 } + +#undef ENCODER_RESOLUTION +#undef ENCODER_RESOLUTION_RIGHT + +#define ENCODER_RESOLUTION 4 +#define ENCODER_RESOLUTION_RIGHT 4 \ No newline at end of file diff --git a/keyboards/bluebell/swoop/keymaps/t4corun/keymap.c b/keyboards/bluebell/swoop/keymaps/t4corun/keymap.c index 662286c5..de876dca 100644 --- a/keyboards/bluebell/swoop/keymaps/t4corun/keymap.c +++ b/keyboards/bluebell/swoop/keymaps/t4corun/keymap.c @@ -52,14 +52,14 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { /* The encoder presses are handled in the keymap */ const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][NUM_DIRECTIONS] = { - [_QWERTY] = { ENCODER_CCW_CW(KC_WH_U, KC_WH_D), ENCODER_CCW_CW(KC_VOLD, KC_VOLU) }, - [_COLEMAK_DH] = { ENCODER_CCW_CW(KC_WH_U, KC_WH_D), ENCODER_CCW_CW(KC_VOLD, KC_VOLU) }, - [_GAME] = { ENCODER_CCW_CW(KC_WH_U, KC_WH_D), ENCODER_CCW_CW(KC_VOLD, KC_VOLU) }, - [_NAVIGATION] = { ENCODER_CCW_CW(___x___, ___x___), ENCODER_CCW_CW(___x___, ___x___) }, - [_NUMBER] = { ENCODER_CCW_CW(___x___, ___x___), ENCODER_CCW_CW(KC_LEFT, KC_RGHT) }, - [_SYMBOL] = { ENCODER_CCW_CW(___x___, ___x___), ENCODER_CCW_CW(___x___, ___x___) }, - [_MOUSE_FUNC] = { ENCODER_CCW_CW(KC_WH_U, KC_WH_D), ENCODER_CCW_CW(KC_VOLD, KC_VOLU) }, - [_CONFIG] = { ENCODER_CCW_CW(RBSELYR, BASELYR), ENCODER_CCW_CW(RBSELYR, BASELYR) } + [_QWERTY] = { ENCODER_CCW_CW(KC_WH_U, KC_WH_D), ENCODER_CCW_CW(KC_VOLD, KC_VOLU) }, + [_COLEMAK_DH] = { ENCODER_CCW_CW(KC_WH_U, KC_WH_D), ENCODER_CCW_CW(KC_VOLD, KC_VOLU) }, + [_GAME] = { ENCODER_CCW_CW(KC_WH_U, KC_WH_D), ENCODER_CCW_CW(KC_VOLD, KC_VOLU) }, + [_NAVIGATION] = { ENCODER_CCW_CW(___x___, ___x___), ENCODER_CCW_CW(___x___, ___x___) }, + [_NUMBER] = { ENCODER_CCW_CW(___x___, ___x___), ENCODER_CCW_CW(RALT_TB, ALT_TAB) }, + [_SYMBOL] = { ENCODER_CCW_CW(___x___, ___x___), ENCODER_CCW_CW(___x___, ___x___) }, + [_MOUSE_FUNC] = { ENCODER_CCW_CW(KC_WH_U, KC_WH_D), ENCODER_CCW_CW(ZOOMOUT, ZOOMIN) }, + [_CONFIG] = { ENCODER_CCW_CW(RGB_RMOD, RGB_MOD), ENCODER_CCW_CW(RBSELYR, BASELYR) } }; diff --git a/keyboards/klor/info.json b/keyboards/klor/2040/keyboard.json similarity index 99% rename from keyboards/klor/info.json rename to keyboards/klor/2040/keyboard.json index b08bc555..d757309f 100644 --- a/keyboards/klor/info.json +++ b/keyboards/klor/2040/keyboard.json @@ -187,7 +187,7 @@ }, "LAYOUT_saegewerk": { "layout": [ - {"label": "L01", "matrix": [0, 1], "x": 1, "y": 0.9}, + {"label": "L01", "matrix": [0, 1], "x": 1, "y": 0}, {"label": "L02", "matrix": [0, 2], "x": 0.5, "y": 2}, {"label": "L03", "matrix": [0, 3], "x": 0, "y": 3}, {"label": "L04", "matrix": [0, 4], "x": 0.5, "y": 4}, @@ -229,7 +229,7 @@ }, "LAYOUT_yubitsume": { "layout": [ - {"label": "L01", "matrix": [0, 1], "x": 1, "y": 0.9}, + {"label": "L01", "matrix": [0, 1], "x": 1, "y": 0}, {"label": "L02", "matrix": [0, 2], "x": 0.5, "y": 2}, {"label": "L03", "matrix": [0, 3], "x": 0, "y": 3}, {"label": "L04", "matrix": [0, 4], "x": 0.5, "y": 4}, diff --git a/keyboards/klor/keymaps/t4corun/config.h b/keyboards/klor/keymaps/t4corun/config.h index 21481545..37975ca2 100644 --- a/keyboards/klor/keymaps/t4corun/config.h +++ b/keyboards/klor/keymaps/t4corun/config.h @@ -1 +1,7 @@ -# pragma once \ No newline at end of file +#pragma once + +#undef ENCODER_RESOLUTION +#undef ENCODER_RESOLUTION_RIGHT + +#define ENCODER_RESOLUTION 4 +#define ENCODER_RESOLUTION_RIGHT 4 \ No newline at end of file diff --git a/keyboards/klor/keymaps/t4corun/keymap.c b/keyboards/klor/keymaps/t4corun/keymap.c index 0132d1bb..93e5dee0 100644 --- a/keyboards/klor/keymaps/t4corun/keymap.c +++ b/keyboards/klor/keymaps/t4corun/keymap.c @@ -35,14 +35,14 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][NUM_DIRECTIONS] = { - [_QWERTY] = { ENCODER_CCW_CW(KC_WH_U, KC_WH_D), ENCODER_CCW_CW(KC_VOLD, KC_VOLU) }, - [_COLEMAK_DH] = { ENCODER_CCW_CW(KC_WH_U, KC_WH_D), ENCODER_CCW_CW(KC_VOLD, KC_VOLU) }, - [_GAME] = { ENCODER_CCW_CW(KC_WH_U, KC_WH_D), ENCODER_CCW_CW(KC_VOLD, KC_VOLU) }, - [_NAVIGATION] = { ENCODER_CCW_CW(ZOOMOUT, ZOOMIN), ENCODER_CCW_CW(___x___, ___x___) }, - [_NUMBER] = { ENCODER_CCW_CW(___x___, ___x___), ENCODER_CCW_CW(KC_LEFT, KC_RGHT) }, - [_SYMBOL] = { ENCODER_CCW_CW(___x___, ___x___), ENCODER_CCW_CW(___x___, ___x___) }, - [_MOUSE_FUNC] = { ENCODER_CCW_CW(KC_WH_U, KC_WH_D), ENCODER_CCW_CW(KC_VOLD, KC_VOLU) }, - [_CONFIG] = { ENCODER_CCW_CW(RBSELYR, BASELYR), ENCODER_CCW_CW(RGB_RMOD, RGB_MOD) } + [_QWERTY] = { ENCODER_CCW_CW(KC_WH_U, KC_WH_D), ENCODER_CCW_CW(KC_VOLD, KC_VOLU) }, + [_COLEMAK_DH] = { ENCODER_CCW_CW(KC_WH_U, KC_WH_D), ENCODER_CCW_CW(KC_VOLD, KC_VOLU) }, + [_GAME] = { ENCODER_CCW_CW(KC_WH_U, KC_WH_D), ENCODER_CCW_CW(KC_VOLD, KC_VOLU) }, + [_NAVIGATION] = { ENCODER_CCW_CW(ZOOMOUT, ZOOMIN), ENCODER_CCW_CW(___x___, ___x___) }, + [_NUMBER] = { ENCODER_CCW_CW(___x___, ___x___), ENCODER_CCW_CW(RALT_TB, ALT_TAB) }, + [_SYMBOL] = { ENCODER_CCW_CW(___x___, ___x___), ENCODER_CCW_CW(___x___, ___x___) }, + [_MOUSE_FUNC] = { ENCODER_CCW_CW(KC_WH_U, KC_WH_D), ENCODER_CCW_CW(ZOOMOUT, ZOOMIN) }, + [_CONFIG] = { ENCODER_CCW_CW(RGB_RMOD, RGB_MOD), ENCODER_CCW_CW(RBSELYR, BASELYR) } }; diff --git a/users/t4corun/features/capsword.c b/users/t4corun/features/capsword.c index e15035a5..296caf9e 100644 --- a/users/t4corun/features/capsword.c +++ b/users/t4corun/features/capsword.c @@ -1,11 +1,7 @@ #include "capsword.h" -//static bool caps_word_state = false; - -bool caps_word_press_user(uint16_t keycode) { - +bool caps_word_press_user (uint16_t keycode) { switch (keycode) { - // Keycodes that continue Caps Word, with shift applied. case KC_A ... KC_Z: @@ -22,7 +18,5 @@ bool caps_word_press_user(uint16_t keycode) { default: return false; // Deactivate Caps Word. - } - } \ No newline at end of file diff --git a/users/t4corun/features/combo.c b/users/t4corun/features/combo.c index 8115938c..03f8f523 100644 --- a/users/t4corun/features/combo.c +++ b/users/t4corun/features/combo.c @@ -1,8 +1,10 @@ #include "combo.h" -bool combo_should_trigger(uint16_t combo_index, combo_t *combo, uint16_t keycode, keyrecord_t *record) { +bool combo_should_trigger (uint16_t combo_index, combo_t *combo, uint16_t keycode, keyrecord_t *record) { // disable all combos on config layer - if ( get_highest_layer(layer_state | default_layer_state) == _CONFIG ) return false; + if (get_highest_layer(layer_state | default_layer_state) == _CONFIG) { + return false; + } switch (combo_index) { case MOUSE_BUTTON2: diff --git a/users/t4corun/features/combo.h b/users/t4corun/features/combo.h index f1dc1449..1a8c870d 100644 --- a/users/t4corun/features/combo.h +++ b/users/t4corun/features/combo.h @@ -1,7 +1,6 @@ #pragma once #include "t4corun.h" - const uint16_t PROGMEM mou_btn2_combo[] = { KC_C, KC_V, COMBO_END }; const uint16_t PROGMEM mou_drg_combo[] = { KC_X, KC_V, COMBO_END }; diff --git a/users/t4corun/features/luna.c b/users/t4corun/features/luna.c index e0caa726..26951881 100644 --- a/users/t4corun/features/luna.c +++ b/users/t4corun/features/luna.c @@ -3,8 +3,7 @@ static uint32_t luna_anim_timer = 0; static uint8_t luna_current_frame = 0; -void render_luna(void) { - +void render_luna (void) { #if OLED_TIMEOUT > 0 // the animation prevents the normal timeout from occuring if (last_input_activity_elapsed() > OLED_TIMEOUT && last_led_activity_elapsed() > OLED_TIMEOUT) { @@ -19,13 +18,10 @@ void render_luna(void) { luna_anim_timer = timer_read32(); animate_luna(OLED_LUNA_COL, OLED_LUNA_LINE); } - } -void animate_luna(uint8_t col, uint8_t line) { - - uint8_t current_mod = get_mods(); - uint8_t current_osm = get_oneshot_mods(); +void animate_luna (uint8_t col, uint8_t line) { + uint8_t current_mods = get_mods() | get_oneshot_mods(); // Make Luna Jump when spacebar is pressed // Only works when Luna is rendered on Master Slide @@ -48,7 +44,7 @@ void animate_luna(uint8_t col, uint8_t line) { // Animate based on status if (host_keyboard_led_state().caps_lock || is_caps_word_on()) { oled_write_raw_P(bark[luna_current_frame], OLED_LUNA_ANIM_SIZE); - } else if ((current_mod | current_osm) & MOD_MASK_CTRL) { + } else if (current_mods & MOD_MASK_CTRL) { oled_write_raw_P(sneak[luna_current_frame], OLED_LUNA_ANIM_SIZE); } else if (get_current_wpm() <= OLED_LUNA_MIN_WALK_SPEED) { oled_write_raw_P(sit[luna_current_frame], OLED_LUNA_ANIM_SIZE); diff --git a/users/t4corun/features/luna.h b/users/t4corun/features/luna.h index 7e85c35e..bad02668 100644 --- a/users/t4corun/features/luna.h +++ b/users/t4corun/features/luna.h @@ -1,8 +1,6 @@ #pragma once - #include "t4corun.h" - #if defined(OLED_DISPLAY_128X64) # define OLED_LUNA_COL 15 # define OLED_LUNA_LINE 5 diff --git a/users/t4corun/features/oled.c b/users/t4corun/features/oled.c index 638e7ee1..64f39b9a 100644 --- a/users/t4corun/features/oled.c +++ b/users/t4corun/features/oled.c @@ -6,7 +6,7 @@ // Shows the currently enabled Layer name -void render_default_layer_state(uint8_t col, uint8_t line, bool moveCursor) { +void render_default_layer_state (uint8_t col, uint8_t line, bool moveCursor) { if(moveCursor) { oled_set_cursor(col, line); } @@ -27,7 +27,7 @@ void render_default_layer_state(uint8_t col, uint8_t line, bool moveCursor) { // Shows the currently enabled Layer name // This only shows the name that is enabled -void render_layer_state(uint8_t col, uint8_t line, bool moveCursor) { +void render_layer_state (uint8_t col, uint8_t line, bool moveCursor) { if(moveCursor) { oled_set_cursor(col, line); } @@ -57,22 +57,24 @@ void render_layer_state(uint8_t col, uint8_t line, bool moveCursor) { // Shows the currently enabled Layer name // Renders a list of all the layers and highlights the active one -void render_layer_state_list(uint8_t col, uint8_t line, bool moveCursor) { +void render_layer_state_list (uint8_t col, uint8_t line, bool moveCursor) { if(moveCursor) { oled_set_cursor(col, line); } - oled_write_P(PSTR(OLED_RENDER_LAYER_2), get_highest_layer(layer_state) == _NAVIGATION); - oled_write_P(PSTR(OLED_RENDER_LAYER_3), get_highest_layer(layer_state) == _NUMBER); - oled_write_P(PSTR(OLED_RENDER_LAYER_4), get_highest_layer(layer_state) == _SYMBOL); - oled_write_P(PSTR(OLED_RENDER_LAYER_5), get_highest_layer(layer_state) == _MOUSE_FUNC); - oled_write_P(PSTR(OLED_RENDER_LAYER_6), get_highest_layer(layer_state) == _CONFIG); + uint8_t current_layer = get_highest_layer(layer_state); + + oled_write_P(PSTR(OLED_RENDER_LAYER_2), current_layer == _NAVIGATION); + oled_write_P(PSTR(OLED_RENDER_LAYER_3), current_layer == _NUMBER); + oled_write_P(PSTR(OLED_RENDER_LAYER_4), current_layer == _SYMBOL); + oled_write_P(PSTR(OLED_RENDER_LAYER_5), current_layer == _MOUSE_FUNC); + oled_write_P(PSTR(OLED_RENDER_LAYER_6), current_layer == _CONFIG); } // Shows the Host LED State (Num lock, caps lock , scroll lock) -void render_lock_status(uint8_t col, uint8_t line) { +void render_lock_status (uint8_t col, uint8_t line) { oled_set_cursor(col, line); host_keyboard_led_state().num_lock ? oled_write_P(num_on, false ) : oled_write_P(num_off, false ); host_keyboard_led_state().caps_lock || is_caps_word_on() ? oled_write_P(caps_on, false ) : oled_write_P(caps_off, false ); @@ -81,59 +83,57 @@ void render_lock_status(uint8_t col, uint8_t line) { // Indicates which modifies are enabled -void render_mod_status(uint8_t col, uint8_t line) { - uint8_t current_mod = get_mods(); - uint8_t current_osm = get_oneshot_mods(); +void render_mod_status (uint8_t col, uint8_t line) { + uint8_t current_mods = get_mods() | get_oneshot_mods(); // draw the top line oled_set_cursor(col, line); - (current_mod | current_osm) & MOD_MASK_SHIFT ? oled_write_P(shift_on_upper, false) : oled_write_P(shift_off_upper, false ); + current_mods & MOD_MASK_SHIFT ? oled_write_P(shift_on_upper, false) : oled_write_P(shift_off_upper, false ); oled_write_P(mod_sep, false); - (current_mod | current_osm) & MOD_MASK_CTRL ? oled_write_P(ctrl_on_upper, false ) : oled_write_P(ctrl_off_upper, false ); + current_mods & MOD_MASK_CTRL ? oled_write_P(ctrl_on_upper, false ) : oled_write_P(ctrl_off_upper, false ); oled_write_P(mod_sep, false); - (current_mod | current_osm) & MOD_MASK_ALT ? oled_write_P(alt_on_upper, false ) : oled_write_P(alt_off_upper, false ); + current_mods & MOD_MASK_ALT ? oled_write_P(alt_on_upper, false ) : oled_write_P(alt_off_upper, false ); oled_write_P(mod_sep, false); - (current_mod | current_osm) & MOD_MASK_GUI ? oled_write_P(gui_on_upper, false ) : oled_write_P(gui_off_upper, false ); + current_mods & MOD_MASK_GUI ? oled_write_P(gui_on_upper, false ) : oled_write_P(gui_off_upper, false ); // draw the lower line oled_set_cursor(col, line + 1); - (current_mod | current_osm) & MOD_MASK_SHIFT ? oled_write_P(shift_on_lower, false) : oled_write_P(shift_off_lower, false ); + current_mods & MOD_MASK_SHIFT ? oled_write_P(shift_on_lower, false) : oled_write_P(shift_off_lower, false ); oled_write_P(mod_sep, false); - (current_mod | current_osm) & MOD_MASK_CTRL ? oled_write_P(ctrl_on_lower, false ) : oled_write_P(ctrl_off_lower, false ); + current_mods & MOD_MASK_CTRL ? oled_write_P(ctrl_on_lower, false ) : oled_write_P(ctrl_off_lower, false ); oled_write_P(mod_sep, false); - (current_mod | current_osm) & MOD_MASK_ALT ? oled_write_P(alt_on_lower, false ) : oled_write_P(alt_off_lower, false ); + current_mods & MOD_MASK_ALT ? oled_write_P(alt_on_lower, false ) : oled_write_P(alt_off_lower, false ); oled_write_P(mod_sep, false); - (current_mod | current_osm) & MOD_MASK_GUI ? oled_write_P(gui_on_lower, false ) : oled_write_P(gui_off_lower, false ); + current_mods & MOD_MASK_GUI ? oled_write_P(gui_on_lower, false ) : oled_write_P(gui_off_lower, false ); } // Indicates which modifies are enabled -void render_mod_status_vertical(uint8_t col, uint8_t line) { - uint8_t current_mod = get_mods(); - uint8_t current_osm = get_oneshot_mods(); +void render_mod_status_vertical (uint8_t col, uint8_t line) { + uint8_t current_mods = get_mods() | get_oneshot_mods(); oled_set_cursor(col,line); - (current_mod | current_osm) & MOD_MASK_SHIFT ? oled_write_P(shift_on_upper, false) : oled_write_P(shift_off_upper, false ); + current_mods & MOD_MASK_SHIFT ? oled_write_P(shift_on_upper, false) : oled_write_P(shift_off_upper, false ); oled_set_cursor(col,line+1); - (current_mod | current_osm) & MOD_MASK_SHIFT ? oled_write_P(shift_on_lower, false) : oled_write_P(shift_off_lower, false ); + current_mods & MOD_MASK_SHIFT ? oled_write_P(shift_on_lower, false) : oled_write_P(shift_off_lower, false ); oled_set_cursor(col,line+3); - (current_mod | current_osm) & MOD_MASK_CTRL ? oled_write_P(ctrl_on_upper, false ) : oled_write_P(ctrl_off_upper, false ); + current_mods & MOD_MASK_CTRL ? oled_write_P(ctrl_on_upper, false ) : oled_write_P(ctrl_off_upper, false ); oled_set_cursor(col,line+4); - (current_mod | current_osm) & MOD_MASK_CTRL ? oled_write_P(ctrl_on_lower, false ) : oled_write_P(ctrl_off_lower, false ); + current_mods & MOD_MASK_CTRL ? oled_write_P(ctrl_on_lower, false ) : oled_write_P(ctrl_off_lower, false ); oled_set_cursor(col,line+6); - (current_mod | current_osm) & MOD_MASK_ALT ? oled_write_P(alt_on_upper, false ) : oled_write_P(alt_off_upper, false ); + current_mods & MOD_MASK_ALT ? oled_write_P(alt_on_upper, false ) : oled_write_P(alt_off_upper, false ); oled_set_cursor(col,line+7); - (current_mod | current_osm) & MOD_MASK_ALT ? oled_write_P(alt_on_lower, false ) : oled_write_P(alt_off_lower, false ); + current_mods & MOD_MASK_ALT ? oled_write_P(alt_on_lower, false ) : oled_write_P(alt_off_lower, false ); oled_set_cursor(col,line+9); - (current_mod | current_osm) & MOD_MASK_GUI ? oled_write_P(gui_on_upper, false ) : oled_write_P(gui_off_upper, false ); + current_mods & MOD_MASK_GUI ? oled_write_P(gui_on_upper, false ) : oled_write_P(gui_off_upper, false ); oled_set_cursor(col,line+10); - (current_mod | current_osm) & MOD_MASK_GUI ? oled_write_P(gui_on_lower, false ) : oled_write_P(gui_off_lower, false ); + current_mods & MOD_MASK_GUI ? oled_write_P(gui_on_lower, false ) : oled_write_P(gui_off_lower, false ); } -void render_feature_status(uint8_t col, uint8_t line) { +void render_feature_status (uint8_t col, uint8_t line) { oled_set_cursor(col,line); #if defined(RGB_MATRIX_ENABLE) rgb_matrix_is_enabled() ? oled_write_P(rgb_matrix_on, false) : oled_write_P(rgb_matrix_off, false); @@ -156,18 +156,15 @@ void render_feature_status(uint8_t col, uint8_t line) { #endif //HAPTIC_ENABLE } -void render_klor_face_small(uint8_t col, uint8_t line) { - +void render_klor_face_small (uint8_t col, uint8_t line) { oled_set_cursor(col,line); oled_write_P(klor_small_face_1, false); oled_set_cursor(col,line+1); oled_write_P(klor_small_face_2, false); - } -void render_oled_32x128(void) { - +void render_oled_32x128 (void) { //process_record_user is only processed on master side //split side OLED does not respond to key presses custom behaviors if (is_keyboard_master()) { @@ -184,7 +181,7 @@ void render_oled_32x128(void) { // 21 x 8 -void render_oled_128x64(void) { +void render_oled_128x64 (void) { if (is_keyboard_master()) { /* @@ -197,7 +194,6 @@ base lyr: current lyr -------------- xxxxx NCS xx xx xx xxxxx */ - render_default_layer_state(0,0, true); render_layer_state(0,0, false); @@ -219,9 +215,8 @@ base lyr: current lyr } - // Coordinate the OLED rendering -bool oled_task_user(void) { +bool oled_task_user (void) { #if defined(OLED_DISPLAY_128X64) render_oled_128x64(); #else @@ -230,7 +225,7 @@ bool oled_task_user(void) { return false; } -oled_rotation_t oled_init_user(oled_rotation_t rotation) { +oled_rotation_t oled_init_user (oled_rotation_t rotation) { #if defined(OLED_DISPLAY_128X64) //OLED_ROTATION_180 for KLOR return OLED_ROTATION_180; diff --git a/users/t4corun/features/oled.h b/users/t4corun/features/oled.h index 4c19c468..cb7f3dfc 100644 --- a/users/t4corun/features/oled.h +++ b/users/t4corun/features/oled.h @@ -27,18 +27,18 @@ # define OLED_RENDER_LAYER_6 " Cfg " #endif -void render_oled_128x64(void); -void render_oled_32x128(void); +void render_oled_128x64 (void); +void render_oled_32x128 (void); -void render_default_layer_state(uint8_t col, uint8_t line, bool moveCursor); -void render_layer_state(uint8_t col, uint8_t line, bool moveCursor); -void render_layer_state_list(uint8_t col, uint8_t line, bool moveCursor); +void render_default_layer_state (uint8_t col, uint8_t line, bool moveCursor); +void render_layer_state (uint8_t col, uint8_t line, bool moveCursor); +void render_layer_state_list (uint8_t col, uint8_t line, bool moveCursor); -void render_mod_status(uint8_t col, uint8_t line); -void render_mod_status_vertical(uint8_t col, uint8_t line); -void render_keylock_status(uint8_t col, uint8_t line); +void render_mod_status (uint8_t col, uint8_t line); +void render_mod_status_vertical (uint8_t col, uint8_t line); +void render_keylock_status (uint8_t col, uint8_t line); -void render_klor_face_small(uint8_t col, uint8_t line); +void render_klor_face_small (uint8_t col, uint8_t line); static const char PROGMEM scroll_off[] = {0xC0, 0}; static const char PROGMEM scroll_on[] = {0xC1, 0}; diff --git a/users/t4corun/features/taphold.c b/users/t4corun/features/taphold.c index b33eeff7..48a0acaa 100644 --- a/users/t4corun/features/taphold.c +++ b/users/t4corun/features/taphold.c @@ -1,35 +1,26 @@ #include "taphold.h" -void double_tap(uint16_t key, uint32_t ms) { - +void double_tap( uint16_t key, uint32_t ms) { tap_code16(key); wait_ms(ms); tap_code16(key); - } -void insert_brackets(uint16_t left, uint16_t right, uint32_t ms) { - +void insert_brackets (uint16_t left, uint16_t right, uint32_t ms) { tap_code16(left); wait_ms(ms); tap_code16(right); wait_ms(ms); tap_code16(KC_LEFT); - } -bool process_tap_hold_key(keyrecord_t* record, uint16_t tap_keycode, uint16_t hold_keycode, int mode) { - +bool process_tap_hold_key (keyrecord_t* record, uint16_t tap_keycode, uint16_t hold_keycode, int mode) { if (record->tap.count > 0) { // Key is being tapped - // register on press, unregister on release record->event.pressed ? register_code16(tap_keycode) : unregister_code16(tap_keycode); - - } else { // Key is being held - + } else { // Key is being hel switch (mode) { - case HOLD_BRACKETS: record->event.pressed ? insert_brackets(tap_keycode, hold_keycode, TAP_CODE_DELAY) : 0; break; @@ -42,8 +33,6 @@ bool process_tap_hold_key(keyrecord_t* record, uint16_t tap_keycode, uint16_t ho record->event.pressed ? register_code16(hold_keycode) : unregister_code16(hold_keycode); break; } - } - return false; } diff --git a/users/t4corun/features/taphold.h b/users/t4corun/features/taphold.h index c71a70cc..eec8c920 100644 --- a/users/t4corun/features/taphold.h +++ b/users/t4corun/features/taphold.h @@ -6,7 +6,7 @@ #define HOLD_DOUBLETP 1 #define HOLD_BRACKETS 2 -void single_tap(uint16_t key); -void double_tap(uint16_t key, uint32_t ms); -void insert_brackets(uint16_t left, uint16_t right, uint32_t ms); -bool process_tap_hold_key(keyrecord_t* record, uint16_t tap_keycode, uint16_t hold_keycode, int mode); \ No newline at end of file +void single_tap (uint16_t key); +void double_tap (uint16_t key, uint32_t ms); +void insert_brackets (uint16_t left, uint16_t right, uint32_t ms); +bool process_tap_hold_key (keyrecord_t* record, uint16_t tap_keycode, uint16_t hold_keycode, int mode); \ No newline at end of file diff --git a/users/t4corun/rules.mk b/users/t4corun/rules.mk index 1f1c7ed1..dc9fdad9 100644 --- a/users/t4corun/rules.mk +++ b/users/t4corun/rules.mk @@ -31,9 +31,9 @@ AUDIO_ENABLE ?= no WPM_ENABLE ?= yes # qmk features we will force as these are critical for my workflow -EXTRAKEY_ENABLE ?= yes -CAPS_WORD_ENABLE ?= yes +EXTRAKEY_ENABLE = yes MOUSEKEY_ENABLE = yes +CAPS_WORD_ENABLE ?= yes COMBO_ENABLE ?= yes diff --git a/users/t4corun/t4corun.c b/users/t4corun/t4corun.c index 1a9b9e5d..57918b9d 100644 --- a/users/t4corun/t4corun.c +++ b/users/t4corun/t4corun.c @@ -8,6 +8,12 @@ static uint8_t current_base_layer = FIRST_DEFAULT_LAYER; // keep track of current mods to override existing keys static uint8_t current_mods; +// enables alt tab for the encoder +static bool is_alt_tab_active = false; +static bool is_alt_shift_tab_active = false; +static uint16_t alt_tab_timer = 0; + +#if defined(WPM_ENABLE) // Luna Pet Variables static bool isJumping = false; static bool showedJump = true; @@ -18,7 +24,7 @@ bool isJumpShown(void) { return showedJump; } // Allows the OLED code to clear the space bar status when render is complete void setLunaJumped(void) { showedJump = true;} - +#endif // WPM_ENABLE // Hold Navigation and Number to get Symbol @@ -26,6 +32,7 @@ layer_state_t layer_state_set_user(layer_state_t state) { return update_tri_layer_state(state, _NAVIGATION, _NUMBER, _SYMBOL); } + // Customize behavior for existing keycodes or create new ones bool process_record_user(uint16_t keycode, keyrecord_t *record) { @@ -96,6 +103,34 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { } return false; + case ALT_TAB: + if (record->event.pressed) { + if (!is_alt_tab_active || (current_mods & MOD_MASK_SHIFT)) { + is_alt_tab_active = true; + register_code(KC_LALT); + unregister_code(KC_LSFT); + } + alt_tab_timer = timer_read(); + register_code(KC_TAB); + } else { + unregister_code(KC_TAB); + } + return false; + + case RALT_TB: + if (record->event.pressed) { + if (!is_alt_shift_tab_active || !(current_mods & MOD_MASK_SHIFT)) { + is_alt_shift_tab_active = true; + register_code(KC_LALT); + register_code(KC_LSFT); + } + alt_tab_timer = timer_read(); + register_code(KC_TAB); + } else { + unregister_code(KC_TAB); + } + return false; + #if defined(HAPTIC_ENABLE) case TR_HNXT: if (record->event.pressed) { @@ -170,4 +205,16 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { // let QMK process the normal behavior if not handled above return true; +} + +void matrix_scan_user(void) { + // timer for the super alt-tab + if (is_alt_tab_active || is_alt_shift_tab_active) { + if (timer_elapsed(alt_tab_timer) > ALT_TAB_TIMEOUT) { + unregister_code(KC_LALT); + unregister_code(KC_LSFT); + is_alt_tab_active = false; + is_alt_shift_tab_active = false; + } + } } \ No newline at end of file diff --git a/users/t4corun/t4corun.h b/users/t4corun/t4corun.h index ae9b749b..a8922da1 100644 --- a/users/t4corun/t4corun.h +++ b/users/t4corun/t4corun.h @@ -2,9 +2,13 @@ #include QMK_KEYBOARD_H #include "features/taphold.h" +#if defined(WPM_ENABLE) bool isLunaJumping(void); bool isJumpShown(void); void setLunaJumped(void); +#endif // WPM_ENABLE + +#define ALT_TAB_TIMEOUT 1000 // put the default base layers first enum layers { @@ -52,6 +56,9 @@ enum keycodes { TR_HNXT, // HF_NEXT or HF_PREV when shift is held TR_CKUP, // CK_UP or CK_DOWN when shift is held + ALT_TAB, + RALT_TB, + BASELYR, RBSELYR }; @@ -73,6 +80,12 @@ enum keycodes { #define SC_REDO LCTL(KC_Y) #define SC_SNIP LGUI(LSFT(KC_S)) #define SC_FILE LGUI(KC_E) +#define SC_WIN LGUI(KC_TAB) + +// Zoom for encoders +#define ZOOMIN LCTL(KC_PLUS) +#define ZOOMOUT LCTL(KC_MINS) +#define ZOOMRST LCTL(KC_0) /* - Any keycodes with prefix TR has behavior dependent on if the feature is enabled. @@ -170,25 +183,24 @@ enum keycodes { #define LAYER_NUMBER \ - KC_ESC, SC_SNIP, SC_FILE, MOU_FUN, TR_GRV, KC_ENT, KC_7, KC_8, KC_9, KC_COMM, \ - _GACS_MODS________________________, TR_SCLN, KC_BSPC, KC_4, KC_5, KC_6, KC_DOT, \ - _UCCPR_L___________________________________, KC_0, KC_1, KC_2, KC_3, KC_MINS, \ - _LAYER_TRANS_____________, _BASE_R4_________________ + KC_ESC, SC_SNIP, SC_FILE, MOU_FUN, KC_ENT, ___x___, KC_7, KC_8, KC_9, KC_COMM, \ + _GACS_MODS________________________, KC_TAB, KC_BSPC, KC_4, KC_5, KC_6, KC_DOT, \ + _UCCPR_L___________________________________, KC_DEL, KC_1, KC_2, KC_3, KC_MINS, \ + _LAYER_TRANS_____________, KC_0, NAV, SC_WIN #define LAYER_SYMBOL \ KC_ESC, ___x___, KC_AT, KC_DLR, TR_GRV, TR_EQL, KC_HASH, KC_ASTR, ___x___, TR_DQUO, \ - KC_AMPR, TR_LCBR, KC_RCBR, KC_EXLM, TR_SCLN, KC_BSPC, KC_QUES, TR_LBRC, KC_RBRC, TR_SQUO, \ - TR_PERC, TR_LABK, KC_RABK, TR_BSLS, TR_PIPE, KC_DEL, TR_SLSH, TR_LPRN, KC_RPRN, TR_MINS, \ + KC_AMPR, TR_LCBR, KC_RCBR, TR_PIPE, TR_SCLN, KC_BSPC, KC_QUES, TR_LBRC, KC_RBRC, TR_SQUO, \ + TR_PERC, TR_LABK, KC_RABK, TR_BSLS, KC_EXLM, KC_DEL, TR_SLSH, TR_LPRN, KC_RPRN, TR_MINS, \ _LAYER_TRANS_____________, _LAYER_TRANS_____________ - #define LAYER_MOUSE_FUNC \ MOU_FUN, KC_MPRV, KC_MNXT, KC_MPLY, ___x___, ___x___, KC_F7, KC_F8, KC_F9, KC_F10, \ _GACS_MODS________________________, TR_DRGS, KC_CAPS, KC_F4, KC_F5, KC_F6, KC_F11, \ _______, ___x___, KC_BTN5, KC_BTN4, TR_SNIP, ___x___, KC_F1, KC_F2, KC_F3, KC_F12, \ - KC_BTN1, KC_BTN3, KC_BTN2, TR_PDPI, TR_SDPI, ___x___ + KC_BTN1, KC_BTN3, KC_BTN2, TR_PDPI, TR_SDPI, ZOOMRST #define LAYER_CONFIG \ @@ -196,4 +208,3 @@ enum keycodes { RGB_MOD, CK_RST, TR_CKUP, CK_TOGG, AU_TOGG, ___x___, TR_LSFT, ___x___, ___x___, ___x___, \ RGB_HUI, RGB_SAI, RGB_VAI, RGB_SPI, RGB_TOG, ___x___, ___x___, ___x___, ___x___, ___x___, \ ___x___, DM_REC1, DM_PLY1, ___x___, ___x___, ___x___ -