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.

52 lines
1.5 KiB

  1. /* Copyright 2021 Joshua T.
  2. *
  3. * This program is free software: you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License as published by
  5. * the Free Software Foundation, either version 2 of the License, or
  6. * (at your option) any later version.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #include "super_alt_tab.h"
  17. // https://docs.qmk.fm/#/feature_macros?id=super-alt%E2%86%AFtab
  18. bool is_alt_tab_active = false;
  19. uint16_t alt_tab_timer = 0;
  20. void matrix_scan_super_alt_tab(void) {
  21. if (is_alt_tab_active) {
  22. if (timer_elapsed(alt_tab_timer) > USER_SUPER_ALT_TAB_TIMEOUT) {
  23. unregister_code(KC_LALT);
  24. is_alt_tab_active = false;
  25. }
  26. }
  27. }
  28. bool process_record_super_alt_tab(uint16_t keycode, const keyrecord_t *record) {
  29. if (keycode != SALTTAB) {
  30. return true;
  31. }
  32. if (record->event.pressed) {
  33. if (!is_alt_tab_active) {
  34. is_alt_tab_active = true;
  35. register_code(KC_LALT);
  36. }
  37. alt_tab_timer = timer_read();
  38. register_code(KC_TAB);
  39. }
  40. else {
  41. unregister_code(KC_TAB);
  42. }
  43. return false;
  44. }