Skip to content

Commit

Permalink
Version of alttab using deferred exec
Browse files Browse the repository at this point in the history
  • Loading branch information
plodah committed Nov 8, 2024
1 parent fe50f01 commit 37e2942
Show file tree
Hide file tree
Showing 11 changed files with 63 additions and 14 deletions.
6 changes: 6 additions & 0 deletions keyboards/keychron/q1v1/iso_encoder/keymaps/plodahc/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@
// #define PLODAH_TYPINGINDICATOR_HSV 240, 84, 255
// #define PLODAH_TYPINGINDICATOR_DURATION 600

#define PLODAH_MSJIGGLER_ENABLED
// #define PLODAH_MSJIGGLER_PATTERN 1
// #define PLODAH_MSJIGGLER_AUTOSTOP
#define PLODAH_MSJIGGLER_INDICATOR_RGBINDEX 43
#define PLODAH_MSJIGGLER_INDICATOR_HSV 0x0B, 0xFF, 0xFF

#define BOOTMAGIC_ROW 0
#define BOOTMAGIC_COLUMN 0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ BOOTMAGIC_ENABLE = yes
CAPS_WORD_ENABLE = yes
COMBO_ENABLE = yes
CONSOLE_ENABLE = no
DEFERRED_EXEC_ENABLE = no
DEFERRED_EXEC_ENABLE = yes
DYNAMIC_MACRO_ENABLE = no
DYNAMIC_TAPPING_TERM_ENABLE = no
ENCODER_MAP_ENABLE = yes
Expand Down
1 change: 1 addition & 0 deletions keyboards/winry/winry315/keymaps/plodah/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// #define KC_PL_QLYR
#define KC_PL_QRGB
#define KC_PL_QVER
#define PLODAH_ALTTAB_ENHANCEMENTS_D_ENABLE

// #define PLODAH_CAPS_INDIC_HSV HSV_MAGENTA
// #define PLODAH_LAYER_INDIC_INDEX1 6
Expand Down
2 changes: 1 addition & 1 deletion users/plodah/configs/ploopy-common.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

#define IS_MOUSE
#define PLODAH_ALTTAB_ENHANCEMENTS_ENABLE
#define PLODAH_ALTTAB_ENHANCEMENTS_D_ENABLE
#define PLODAH_MSJIGGLER_ENABLED
#define PLODAH_MSJIGGLER_AUTOSTOP

Expand Down
2 changes: 1 addition & 1 deletion users/plodah/functions/alttab_enhancements.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ uint16_t alt_tab_timer = 0;
#define PLODAH_ALT_TAB_DELAY 1000
#endif //PLODAH_ALT_TAB_DELAY

void plodah_alt_tab(bool back) {
void plodah_alttab_start(bool back) {
if (!is_alt_tab_active) {
#if ! defined(IS_MOUSE)
if (!alt_pressed){
Expand Down
35 changes: 35 additions & 0 deletions users/plodah/functions/alttab_enhancements_d.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
static deferred_token altTabToken = INVALID_DEFERRED_TOKEN;

#ifndef PLODAH_ALT_TAB_DELAY
#define PLODAH_ALT_TAB_DELAY 1000
#endif //PLODAH_ALT_TAB_DELAY

uint32_t plodah_alttab_reset(uint32_t trigger_time, void *cb_arg) {
unregister_code(KC_LALT);
altTabToken = INVALID_DEFERRED_TOKEN;
// cancel_deferred_exec(altTabToken);
return 0;
}

void plodah_alttab_start(bool back) {
if (altTabToken != INVALID_DEFERRED_TOKEN) {
extend_deferred_exec(altTabToken, PLODAH_ALT_TAB_DELAY);
//altTabToken = defer_exec(PLODAH_ALT_TAB_DELAY, plodah_alttab_reset, NULL);
}
else{
#if ! defined(IS_MOUSE)
if (!alt_pressed){
#endif // ! defined(IS_MOUSE)
altTabToken = defer_exec(PLODAH_ALT_TAB_DELAY, plodah_alttab_reset, NULL);
register_code(KC_LALT);
#if ! defined(IS_MOUSE)
}
#endif // ! defined(IS_MOUSE)
}
if(back){
tap_code16(S(KC_TAB));
}
else{
tap_code16(KC_TAB);
}
}
2 changes: 1 addition & 1 deletion users/plodah/functions/combos.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
COMBO(pl_combo_xc, C(KC_C)),
COMBO(pl_combo_cv, C(KC_V)),
COMBO(pl_combo_xcv, C(S(KC_V))),
#if defined(PLODAH_ALTTAB_ENHANCEMENTS_ENABLE)
#if defined(PLODAH_ALTTAB_ENHANCEMENTS_ENABLE) || defined(PLODAH_ALTTAB_ENHANCEMENTS_ENABLE)
COMBO(pl_combo_tabq, PL_ALTSTAB),
COMBO(pl_combo_tabw, PL_ALTTAB),
#endif // PLODAH_ALTTAB_ENHANCEMENTS_ENABLE
Expand Down
4 changes: 2 additions & 2 deletions users/plodah/functions/encoder_actions.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,10 @@ void enc_act(int keycode, bool ctl_pressed, bool gui_pressed, bool alt_pressed,
//A
switch (keycode) {
case PL_ENC_CCW & 0xff:
plodah_alt_tab(true);
plodah_alttab_start(true);
break;
case PL_ENC_CW & 0xff:
plodah_alt_tab(false);
plodah_alttab_start(false);
break;
case PL_ENC_PRS & 0xff:
default:
Expand Down
6 changes: 3 additions & 3 deletions users/plodah/functions/process_record_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
return false;
#endif // defined(KC_PL_QVER)

#if defined(PLODAH_ALTTAB_ENHANCEMENTS_ENABLE)
#if defined(PLODAH_ALTTAB_ENHANCEMENTS_ENABLE) || defined(PLODAH_ALTTAB_ENHANCEMENTS_D_ENABLE)
case PL_ALTTAB:
if (record->event.pressed) {
plodah_alt_tab(false);
plodah_alttab_start(false);
}
return false;
case PL_ALTSTAB:
if (record->event.pressed) {
plodah_alt_tab(true);
plodah_alttab_start(true);
}
return false;
#endif // defined(PLODAH_ALTTAB_ENHANCEMENTS_ENABLE)
Expand Down
15 changes: 11 additions & 4 deletions users/plodah/plodah.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#if defined(PLODAH_KNOB_ENHANCEMENTS_ENABLE) || defined(PLODAH_MODS_INDIC_LGUI_INDEX) || defined(PLODAH_MODS_INDIC_RGUI_INDEX)
bool gui_pressed = false;
#endif // PLODAH_KNOB_ENHANCEMENTS_ENABLE // GUI
#if defined(PLODAH_KNOB_ENHANCEMENTS_ENABLE) || defined(PLODAH_MODS_INDIC_LALT_INDEX) || defined(PLODAH_MODS_INDIC_RALT_INDEX)
#if defined(PLODAH_KNOB_ENHANCEMENTS_ENABLE) || defined(PLODAH_ALTTAB_ENHANCEMENTS_ENABLE) || defined(PLODAH_ALTTAB_ENHANCEMENTS_D_ENABLE) || defined(PLODAH_MODS_INDIC_LALT_INDEX) || defined(PLODAH_MODS_INDIC_RALT_INDEX)
bool alt_pressed = false;
#endif // PLODAH_KNOB_ENHANCEMENTS_ENABLE // ALT
#if defined(PLODAH_KNOB_ENHANCEMENTS_ENABLE) || defined(PLODAH_MODS_INDIC_LSHIFT_INDEX) || defined(PLODAH_MODS_INDIC_RSHIFT_INDEX)
Expand Down Expand Up @@ -42,13 +42,20 @@
//===================//
// ALT TAB //
//===================//
#if (defined(PLODAH_KNOB_ENHANCEMENTS_ENABLE) || defined(PL_ALTTAB) || defined(PL_ALTSTAB) ) && (! defined(PLODAH_ALTTAB_ENHANCEMENTS_ENABLE))
#define PLODAH_ALTTAB_ENHANCEMENTS_ENABLE
#if (defined(PLODAH_KNOB_ENHANCEMENTS_ENABLE) || defined(PL_ALTTAB) || defined(PL_ALTSTAB) ) && (! defined(PLODAH_ALTTAB_ENHANCEMENTS_ENABLE)) && (! defined(PLODAH_ALTTAB_ENHANCEMENTS_D_ENABLE))
#if defined(DEFERRED_EXEC_ENABLE)
#define PLODAH_ALTTAB_ENHANCEMENTS_D_ENABLE
#else // defined(DEFERRED_EXEC_ENABLE)
#define PLODAH_ALTTAB_ENHANCEMENTS_ENABLE
#endif // defined(DEFERRED_EXEC_ENABLE)
#endif // PLODAH_ALTTAB_ENHANCEMENTS_ENABLE
#if defined(PLODAH_ALTTAB_ENHANCEMENTS_ENABLE)
#include "functions/alttab_enhancements.c"
#endif // PLODAH_ALTTAB_ENHANCEMENTS_ENABLE
#if defined PLODAH_KNOB_ENHANCEMENTS_ENABLE
#if defined(PLODAH_ALTTAB_ENHANCEMENTS_D_ENABLE)
#include "functions/alttab_enhancements_d.c"
#endif // PLODAH_ALTTAB_ENHANCEMENTS_D_ENABLE
#if defined(PLODAH_KNOB_ENHANCEMENTS_ENABLE)
#include "functions/encoder_actions.c"
#endif // PLODAH_KNOB_ENHANCEMENTS_ENABLE

Expand Down
2 changes: 1 addition & 1 deletion users/plodah/plodah.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#define PLODAH_LAYEROFFSET 0
#endif // PLODAH_LAYEROFFSET

#if defined(PLODAH_ALTTAB_ENHANCEMENTS_ENABLE) && (! defined(PLODAH_ALT_TAB_DELAY))
#if (defined(PLODAH_ALTTAB_ENHANCEMENTS_ENABLE) || defined(PLODAH_ALTTAB_ENHANCEMENTS_D_ENABLE)) && (! defined(PLODAH_ALT_TAB_DELAY))
#define PLODAH_ALT_TAB_DELAY 750
#endif // PLODAH_ALTTAB_ENHANCEMENTS_ENABLE

Expand Down

0 comments on commit 37e2942

Please sign in to comment.