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.

114 lines
3.7 KiB

  1. /* Copyright 2020 Sergi Meseguer <zigotica@gmail.com>
  2. This program is free software: you can redistribute it and/or modify
  3. it under the terms of the GNU General Public License as published by
  4. the Free Software Foundation, either version 2 of the License, or
  5. (at your option) any later version.
  6. This program is distributed in the hope that it will be useful,
  7. but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  9. GNU General Public License for more details.
  10. You should have received a copy of the GNU General Public License
  11. along with this program. If not, see <http://www.gnu.org/licenses/>.
  12. */
  13. #include "zigotica.h"
  14. bool encoder_update_user(uint8_t index, bool clockwise) {
  15. switch(get_highest_layer(layer_state)){
  16. case _VIM:
  17. if (index == 0) { // LEFT
  18. // Cycle through buffers
  19. if (clockwise) {
  20. register_code(KC_ESC);
  21. SEND_STRING(":bprevious");
  22. register_code(KC_ENT);
  23. unregister_code(KC_ESC);
  24. unregister_code(KC_ENT);
  25. } else {
  26. register_code(KC_ESC);
  27. SEND_STRING(":bnext");
  28. register_code(KC_ENT);
  29. unregister_code(KC_ESC);
  30. unregister_code(KC_ENT);
  31. }
  32. } else { // RIGHT
  33. // Scroll
  34. if (clockwise) {
  35. tap_code(KC_PGDN);
  36. } else {
  37. tap_code(KC_PGUP);
  38. }
  39. }
  40. break;
  41. case _BROWSER:
  42. if (index == 0) { // LEFT
  43. // Cycle through Tabs
  44. if (clockwise) {
  45. tap_code16(C(KC_TAB));
  46. /* register_code16(G(KC_RCBR)); */
  47. /* unregister_code16(G(KC_RCBR)); */
  48. } else {
  49. tap_code16(S(C(KC_TAB)));
  50. /* register_code16(G(KC_LCBR)); */
  51. /* unregister_code16(G(KC_LCBR)); */
  52. }
  53. } else { // RIGHT
  54. // Scroll up/down
  55. if (clockwise) {
  56. register_code(KC_WH_U);
  57. unregister_code(KC_WH_U);
  58. } else {
  59. register_code(KC_WH_D);
  60. unregister_code(KC_WH_D);
  61. }
  62. }
  63. break;
  64. case _FIGMA:
  65. if (index == 0) { // LEFT
  66. // Volume control.
  67. if (clockwise) {
  68. tap_code(KC_VOLU);
  69. } else {
  70. tap_code(KC_VOLD);
  71. }
  72. } else { // RIGHT
  73. // Zoom in/out
  74. if (clockwise) {
  75. register_code(KC_LGUI);
  76. register_code(KC_WH_D);
  77. unregister_code(KC_WH_D);
  78. unregister_code(KC_LGUI);
  79. } else {
  80. register_code(KC_LGUI);
  81. register_code(KC_WH_U);
  82. unregister_code(KC_WH_U);
  83. unregister_code(KC_LGUI);
  84. }
  85. }
  86. break;
  87. case _TERMINAL:
  88. default:
  89. if (index == 0) { // LEFT
  90. // Volume control.
  91. if (clockwise) {
  92. tap_code(KC_VOLU);
  93. } else {
  94. tap_code(KC_VOLD);
  95. }
  96. } else { // RIGHT
  97. // Scroll
  98. if (clockwise) {
  99. tap_code(KC_PGDN);
  100. } else {
  101. tap_code(KC_PGUP);
  102. }
  103. }
  104. break;
  105. }
  106. return false;
  107. }