logo

qmk_firmware

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

trailmix.c (2728B)


  1. /*
  2. Copyright 2023 Alberto Pavano "ATron789" <albertopavano@gmail.com>
  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. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. */
  14. #include "quantum.h"
  15. enum layers { _BASE, _LOWER, _RAISE, _ADJUST };
  16. #ifdef ENCODER_ENABLE
  17. bool encoder_update_kb(uint8_t index, bool clockwise) {
  18. if (!encoder_update_user(index, clockwise)) {
  19. return false;
  20. }
  21. switch (get_highest_layer(layer_state)) {
  22. case _BASE:
  23. if (index == 0) {
  24. if (clockwise) {
  25. tap_code(KC_VOLU);
  26. } else {
  27. tap_code(KC_VOLD);
  28. }
  29. } else if (index == 1) {
  30. if (clockwise) {
  31. tap_code(KC_MS_WH_DOWN);
  32. } else {
  33. tap_code(KC_MS_WH_UP);
  34. }
  35. }
  36. break;
  37. case _RAISE:
  38. if (index == 0) {
  39. if (clockwise) {
  40. tap_code(KC_MNXT);
  41. } else {
  42. tap_code(KC_MPRV);
  43. }
  44. } else if (index == 1) {
  45. if (clockwise) {
  46. tap_code(KC_WH_R);
  47. } else {
  48. tap_code(KC_WH_L);
  49. }
  50. }
  51. break;
  52. case _LOWER:
  53. if (index == 0) {
  54. if (clockwise) {
  55. tap_code(KC_PGUP);
  56. } else {
  57. tap_code(KC_PGDN);
  58. }
  59. } else if (index == 1) {
  60. if (clockwise) {
  61. tap_code(KC_END);
  62. } else {
  63. tap_code(KC_HOME);
  64. }
  65. }
  66. break;
  67. case _ADJUST:
  68. if (index == 0) {
  69. if (clockwise) {
  70. tap_code(KC_MS_RIGHT);
  71. } else {
  72. tap_code(KC_MS_LEFT);
  73. }
  74. } else if (index == 1) {
  75. if (clockwise) {
  76. tap_code(KC_MS_DOWN);
  77. } else {
  78. tap_code(KC_MS_UP);
  79. }
  80. }
  81. break;
  82. }
  83. return true;
  84. }
  85. #endif