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.3 KiB

  1. /* Copyright 2021 moults31
  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 "moults31.h"
  17. bool moults31_tap_custom_code(uint16_t keycode) {
  18. keyrecord_t record = {
  19. .event = {
  20. .pressed = 1,
  21. },
  22. };
  23. return process_record_user(keycode, &record);
  24. }
  25. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  26. bool rv = true;
  27. switch (keycode) {
  28. case M_MST_CODEBLOCK:
  29. if (record->event.pressed) {
  30. SEND_STRING("```");
  31. }
  32. break;
  33. case M_VSC_TERMFOCUS:
  34. case M_VSC_SIDEBARFOCUS:
  35. case M_VSC_SIDEBARCLOSE:
  36. case M_VSC_FILECLOSE:
  37. case M_VSC_FILENXT:
  38. case M_VSC_FILEPRV:
  39. case M_VSC_DBGCNSLFOCUS:
  40. case M_VSC_MVEDTRNXTGRP:
  41. case M_VSC_MVEDTRPRVGRP:
  42. case M_VSC_EDGRPNXT:
  43. case M_VSC_EDGRPPRV:
  44. case M_VSC_VIEWSIZEINC:
  45. case M_VSC_VIEWSIZEDEC:
  46. rv = process_record_vsc(keycode, record);
  47. break;
  48. case M_GDB_PLAY:
  49. case M_GDB_PAUSE:
  50. case M_GDB_STEPOVER:
  51. case M_GDB_STEPIN:
  52. case M_GDB_STEPOUT:
  53. case M_GDB_RESTART:
  54. case M_GDB_STOP:
  55. rv = process_record_gdb(keycode, record);
  56. break;
  57. case M_OBS_BRB:
  58. case M_OBS_GAME:
  59. case M_OBS_JSTCHT:
  60. case M_OBS_DSKT_MUTE:
  61. case M_OBS_DSKT_UNMUTE:
  62. case M_OBS_VOICE_MUTE:
  63. case M_OBS_VOICE_UNMUTE:
  64. case M_OBS_MOOSIC_MUTE:
  65. case M_OBS_MOOSIC_UNMUTE:
  66. rv = process_record_obs(keycode, record);
  67. break;
  68. }
  69. return rv;
  70. };
  71. #ifdef ENCODER_ENABLE
  72. __attribute__((weak)) bool encoder_update_user(uint8_t index, bool clockwise) {
  73. const layer_state_t curr_layer = get_highest_layer(layer_state);
  74. if (index == 1) { /* Bottom encoder */
  75. if(curr_layer == 2 || curr_layer == 3) {
  76. if (clockwise) {
  77. moults31_tap_custom_code(M_VSC_FILENXT);
  78. } else {
  79. moults31_tap_custom_code(M_VSC_FILEPRV);
  80. }
  81. }
  82. else {
  83. if (clockwise) {
  84. tap_code(KC_VOLU);
  85. } else {
  86. tap_code(KC_VOLD);
  87. }
  88. }
  89. }
  90. if (index == 0) { /* Top encoder */
  91. if(curr_layer == 2 || curr_layer == 3) {
  92. if (clockwise) {
  93. moults31_tap_custom_code(M_VSC_VIEWSIZEINC);
  94. } else {
  95. moults31_tap_custom_code(M_VSC_VIEWSIZEDEC);
  96. }
  97. }
  98. else {
  99. if (clockwise) {
  100. tap_code(KC_MNXT);
  101. } else {
  102. tap_code(KC_MPRV);
  103. }
  104. }
  105. }
  106. return false;
  107. }
  108. #endif