logo

qmk_firmware

custom branch of QMK firmware git clone https://anongit.hacktivis.me/git/qmk_firmware.git

keymap.c (4882B)


  1. /* Copyright 2021 ivndbt
  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. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  18. /*
  19. LAYER 0 - MUSIC
  20. /-----------------------------`
  21. | TO(1) | stop | mute | L ENC: prev/next song
  22. |---------|---------|---------|
  23. | prev | play | next | R ENC: vol up/down
  24. \-----------------------------'
  25. */
  26. [0] = LAYOUT(
  27. TO(1), KC_MSTP, KC_MUTE,
  28. KC_MPRV, KC_MPLY, KC_MNXT
  29. ),
  30. /*
  31. LAYER 1 - MOVEMENT IN WINDOWS
  32. /---------------------------------------`
  33. | TO(2) | maximize | show desktop | L ENC: change desktop
  34. |-------------|----------|--------------|
  35. | move window | minimize | move window | R ENC: change browser tab + change explorer window
  36. \---------------------------------------'
  37. */
  38. [1] = LAYOUT(
  39. TO(2), LGUI(KC_UP), LGUI(KC_D),
  40. LGUI(KC_LEFT), LGUI(KC_DOWN), LGUI(KC_RIGHT)
  41. ),
  42. /*
  43. LAYER 2 - SHORTCUT
  44. /------------------------------`
  45. | TO(3) | esc | task man | L ENC: redo/undo
  46. |---------|---------|----------|
  47. | cut | copy | paste | R ENC: mouse wheel up/down
  48. \------------------------------'
  49. */
  50. [2] = LAYOUT(
  51. TO(3), KC_ESC, LCTL(LSFT(KC_ESC)),
  52. LCTL(KC_X), LCTL(KC_C), LCTL(KC_V)
  53. ),
  54. /*
  55. LAYER 3 - AUDACITY
  56. /-----------------------------`
  57. | TO(0) | REC | canc | L ENC: pan right/left
  58. |---------|---------|---------|
  59. | ctrl | play | pause | R ENC: mouse wheel up/down
  60. \-----------------------------'
  61. */
  62. [3] = LAYOUT(
  63. TO(0), LSFT(KC_R), KC_DEL,
  64. KC_LCTL, KC_SPC, KC_P
  65. ),
  66. };
  67. bool encoder_update_user(uint8_t index, bool clockwise) {
  68. if (index == 0) { /* LEFT ENCODER */
  69. switch (get_highest_layer(layer_state)) {
  70. case 0:
  71. // layer 0 - next song (CW) and previous (CCW)
  72. if (clockwise) {
  73. tap_code(KC_MNXT);
  74. } else {
  75. tap_code(KC_MPRV);
  76. }
  77. break;
  78. case 1:
  79. // layer 1 - change desktop right (CW) and left (CCW)
  80. if (clockwise) {
  81. tap_code16(LCTL(LGUI(KC_RIGHT)));
  82. } else {
  83. tap_code16(LCTL(LGUI(KC_LEFT)));
  84. }
  85. break;
  86. case 2:
  87. // layer 2 - redo (CW) and undo (CCW)
  88. if (clockwise) {
  89. tap_code16(LCTL(KC_Y));
  90. } else {
  91. tap_code16(LCTL(KC_Z));
  92. }
  93. break;
  94. case 3:
  95. // layer 3 - pan right (CW) and left (CCW)
  96. if (clockwise) {
  97. tap_code(KC_WH_R);
  98. } else {
  99. tap_code(KC_WH_L);
  100. }
  101. break;
  102. }
  103. } else if (index == 1) { /* RIGHT ENCODER */
  104. switch (get_highest_layer(layer_state)) {
  105. case 0:
  106. // layer 0 - volume up (CW) and down (CCW)
  107. if (clockwise) {
  108. tap_code(KC_VOLU);
  109. } else {
  110. tap_code(KC_VOLD);
  111. }
  112. break;
  113. case 1:
  114. // layer 1 - change browser tab (CW) and change explorer window (CCW)
  115. if (clockwise) {
  116. tap_code16(LCTL(KC_TAB));
  117. } else {
  118. tap_code16(LALT(LSFT(KC_TAB)));
  119. }
  120. break;
  121. case 2:
  122. // layer 2 - wheel up (CW) and down (CCW)
  123. if (clockwise) {
  124. tap_code(KC_WH_U);
  125. } else {
  126. tap_code(KC_WH_D);
  127. }
  128. break;
  129. case 3:
  130. // layer 3 - wheel up (CW) and down (CCW)
  131. if (clockwise) {
  132. tap_code(KC_WH_U);
  133. } else {
  134. tap_code(KC_WH_D);
  135. }
  136. break;
  137. }
  138. }
  139. return true;
  140. }