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.

112 lines
3.0 KiB

  1. /* Copyright 2020 Guillaume Gérard
  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 "greatwizard.h"
  17. void eeconfig_init_user(void) {
  18. user_config_t user_config;
  19. user_config.raw = 0;
  20. #ifdef RGBLIGHT_ENABLE
  21. user_config.rgb_layer_change = true;
  22. #endif
  23. eeconfig_update_user(user_config.raw);
  24. keyboard_init();
  25. }
  26. void keyboard_post_init_user(void) {
  27. #ifdef RGBLIGHT_ENABLE
  28. keyboard_post_init_rgb();
  29. #endif
  30. }
  31. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  32. #ifdef RGBLIGHT_ENABLE
  33. process_record_rgb(keycode, record);
  34. #endif
  35. #ifdef LAYER_GAME
  36. process_record_game(keycode, record);
  37. #endif
  38. #ifdef LAYER_GIT
  39. process_record_git(keycode, record);
  40. #endif
  41. #ifdef LAYERS_PROGRAMMER
  42. process_record_pg(keycode, record);
  43. #endif
  44. switch (keycode) {
  45. case QWERTY:
  46. if (record->event.pressed) {
  47. set_single_persistent_default_layer(_QWERTY);
  48. }
  49. return false;
  50. case WORKMAN:
  51. if (record->event.pressed) {
  52. set_single_persistent_default_layer(_WORKMAN);
  53. }
  54. return false;
  55. case COLEMAK:
  56. if (record->event.pressed) {
  57. set_single_persistent_default_layer(_COLEMAK);
  58. }
  59. return false;
  60. case DVORAK:
  61. if (record->event.pressed) {
  62. set_single_persistent_default_layer(_DVORAK);
  63. }
  64. return false;
  65. }
  66. return true;
  67. }
  68. #ifdef ENCODER_ENABLE
  69. void encoder_update_user(uint8_t index, bool clockwise) {
  70. switch (get_highest_layer(layer_state)) {
  71. case _QWERTY:
  72. #ifdef LAYERS_PROGRAMMER
  73. case _PROGRAMMER_SHIFTED:
  74. #endif
  75. if (clockwise) {
  76. tap_code(KC_AUDIO_VOL_UP);
  77. } else {
  78. tap_code(KC_AUDIO_VOL_DOWN);
  79. }
  80. break;
  81. default:
  82. if (clockwise) {
  83. tap_code(KC_MEDIA_NEXT_TRACK);
  84. } else {
  85. tap_code(KC_MEDIA_PREV_TRACK);
  86. }
  87. break;
  88. }
  89. }
  90. #endif
  91. layer_state_t layer_state_set_user(layer_state_t state) {
  92. state = update_tri_layer_state(state, _RAISE, _LOWER, _ADJUST);
  93. #ifdef RGBLIGHT_ENABLE
  94. state = layer_state_set_rgb(state);
  95. #endif
  96. #ifdef LAYERS_ORTHO
  97. state = layer_state_set_ortho(state);
  98. #endif
  99. return state;
  100. }
  101. bool led_update_user(led_t led_state) {
  102. #ifdef RGBLIGHT_ENABLE
  103. led_update_rgb(led_state);
  104. #endif
  105. return true;
  106. }