You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
1.2 KiB

  1. #include "danielo515.h"
  2. #include "alt_tab.h"
  3. bool altPressed = false;
  4. __attribute__((weak)) void alt_tab_activated(void){};
  5. __attribute__((weak)) void alt_tab_deactivated(void){};
  6. extern bool onMac;
  7. // =============== ALT_TAB single key handling
  8. bool process_alt_tab(uint16_t keycode, keyrecord_t *record) {
  9. switch (keycode) {
  10. case ALT_TAB:
  11. if (!record->event.pressed) {
  12. return false;
  13. }
  14. if (altPressed) {
  15. tap_code(KC_TAB);
  16. } else {
  17. altPressed = true;
  18. onMac ? register_code(KC_LGUI) : register_code(KC_LALT);
  19. tap_code(KC_TAB);
  20. alt_tab_activated();
  21. }
  22. // avoid alt releasing if the key is of movement
  23. case KC_RIGHT ... KC_UP:
  24. if (altPressed) {
  25. return true; // yes QMK, do your stuff
  26. }
  27. }
  28. // Reset sticky alt tab when any other key is pressed
  29. if (altPressed) {
  30. onMac ? unregister_code(KC_LGUI) : unregister_code(KC_LALT);
  31. altPressed = false;
  32. alt_tab_deactivated();
  33. return false;
  34. }
  35. return true;
  36. };