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.

106 lines
2.6 KiB

  1. /* Copyright 2021 Ananya Kirti
  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 QMK_KEYBOARD_H
  17. bool is_alt_tab_active = false;
  18. uint16_t alt_tab_timer = 0;
  19. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  20. [0] = LAYOUT_ortho_2x3(
  21. KC_MEDIA_STOP, KC_MEDIA_PLAY_PAUSE, KC_MUTE,
  22. KC_MEDIA_REWIND, KC_MEDIA_FAST_FORWARD, KC_PGDN
  23. ),
  24. [1] = LAYOUT_ortho_2x3(
  25. _______, _______, _______,
  26. _______, _______, _______
  27. ),
  28. [2] = LAYOUT_ortho_2x3(
  29. _______, _______, _______,
  30. _______, _______, _______
  31. ),
  32. [3] = LAYOUT_ortho_2x3(
  33. _______, _______, _______,
  34. _______, _______, _______
  35. ),
  36. };
  37. // D4 D0
  38. // C6 E6 D7
  39. void matrix_scan_user(void) {
  40. writePin(C6, layer_state_is(1));
  41. writePin(E6, layer_state_is(2));
  42. writePin(D7, layer_state_is(3));
  43. writePin(D4, layer_state_is(4));
  44. writePin(D0, layer_state_is(5));
  45. if (is_alt_tab_active) {
  46. if (timer_elapsed(alt_tab_timer) > 1000) {
  47. unregister_code(KC_LWIN);
  48. is_alt_tab_active = false;
  49. }
  50. }
  51. }
  52. bool led_update_user(led_t led_state) {
  53. return false;
  54. };
  55. bool encoder_update_user(uint8_t index, bool clockwise) {
  56. if(IS_LAYER_ON(1)) { // on 1st layer
  57. if (clockwise) {
  58. if (!is_alt_tab_active) {
  59. is_alt_tab_active = true;
  60. register_code(KC_LWIN);
  61. }
  62. alt_tab_timer = timer_read();
  63. tap_code16(KC_TAB);
  64. } else {
  65. alt_tab_timer = timer_read();
  66. tap_code16(S(KC_TAB));
  67. }
  68. }
  69. // 2nd layer
  70. else if(IS_LAYER_ON(2)) {
  71. if (clockwise) {
  72. tap_code(KC_DOWN);
  73. } else {
  74. tap_code(KC_UP);
  75. }
  76. }
  77. else if(IS_LAYER_ON(3)) {
  78. if (clockwise) {
  79. tap_code(KC_BRIU);
  80. } else {
  81. tap_code(KC_BRID);
  82. }
  83. }
  84. // default layer
  85. else if(IS_LAYER_ON(0)) {
  86. if (clockwise) {
  87. tap_code(KC_VOLU);
  88. } else {
  89. tap_code(KC_VOLD);
  90. }
  91. }
  92. return false;
  93. }