summaryrefslogtreecommitdiff
path: root/users/danielo515/alt_tab.c
diff options
context:
space:
mode:
authorDaniel Rodríguez Rivero <rdanielo@gmail.com>2020-03-12 03:50:19 +0100
committerGitHub <noreply@github.com>2020-03-12 02:50:19 +0000
commit32d03eef902a1ac9cec53804dcb72ace5c585960 (patch)
tree579d91a2063fd5f6e64c1fc0de7ab5a0b7d34e0b /users/danielo515/alt_tab.c
parentf2f2afe13ba3ae1da8a546ad85eb9e69ddc70a8a (diff)
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/danielo515/alt_tab.c')
-rw-r--r--users/danielo515/alt_tab.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/users/danielo515/alt_tab.c b/users/danielo515/alt_tab.c
new file mode 100644
index 0000000000..1602ee6fb2
--- /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;
+};