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
This commit is contained in:
Victor 2024-07-02 23:29:06 -05:00
parent bd72a9b350
commit edf4c932f2
Failed to generate hash of commit
19 changed files with 172 additions and 129 deletions

View file

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

View file

@ -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:

View file

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

View file

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

View file

@ -1,8 +1,6 @@
#pragma once
#include "t4corun.h"
#if defined(OLED_DISPLAY_128X64)
# define OLED_LUNA_COL 15
# define OLED_LUNA_LINE 5

View file

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

View file

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

View file

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

View file

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