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.

125 lines
3.5 KiB

  1. /* Copyright 2017 @TurboMech /u/TurboMech <discord> @A9entOran9e#6134
  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. //**!! Currently after reboot the set rgb mode does not persist after reboot. Need to find a way to "save" the rgb mode. Color remains after reboot though.
  17. #include "turbomech.h"
  18. #include "quantum.h"
  19. #include "action_layer.h"
  20. #include "action.h"
  21. #include "rgblight.h"
  22. //#include "process_unicode.h"
  23. extern keymap_config_t keymap_config;
  24. extern rgblight_config_t rgblight_config;
  25. bool RGB_INIT = false;
  26. bool TOG_STATUS = false;
  27. bool caps_is_active = false;
  28. int RGB_current_mode;
  29. void matirx_scan_kb (void) {
  30. if (RGB_INIT) {}
  31. else {
  32. RGB_current_mode = rgblight_config.mode;
  33. RGB_INIT = true;
  34. }
  35. rgblight_mode(RGB_current_mode); // revert RGB to initial mode prior to RGB mode change
  36. TOG_STATUS = false;
  37. }
  38. void persistent_default_layer_set(uint16_t default_layer) {
  39. eeconfig_update_default_layer(default_layer);
  40. default_layer_set(default_layer);
  41. }
  42. /*void update_tri_layer_RGB(uint8_t layer1, uint8_t layer2, uint8_t layer3) {
  43. if (IS_LAYER_ON(layer1) && IS_LAYER_ON(layer2)) {
  44. rgblight_mode(RGB_current_mode);
  45. layer_on(layer3);
  46. } else {
  47. layer_off(layer3);
  48. }
  49. }*/
  50. __attribute__ ((weak))
  51. bool process_record_keymap(uint16_t keycode, keyrecord_t *record) {
  52. return true;
  53. }
  54. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  55. switch (keycode) {
  56. case KC_CAPS:
  57. if (record->event.pressed) {
  58. register_code(KC_CAPS);
  59. caps_is_active = !caps_is_active;
  60. if (caps_is_active) {
  61. rgblight_mode(14);
  62. }
  63. else if (!caps_is_active) {
  64. unregister_code(KC_CAPS);
  65. rgblight_mode(RGB_current_mode);
  66. }
  67. }
  68. return false;
  69. break;
  70. case RGB_MOD:
  71. //led operations - RGB mode change now updates the RGB_current_mode to allow the right RGB mode to be set after reactive keys are released
  72. if (record->event.pressed) {
  73. rgblight_mode(RGB_current_mode);
  74. rgblight_step();
  75. RGB_current_mode = rgblight_config.mode;
  76. // rgblight_set();
  77. }
  78. return false;
  79. break;
  80. case KC_RESET:
  81. if (record->event.pressed) {
  82. rgblight_enable();
  83. rgblight_mode(1);
  84. rgblight_setrgb(255, 255, 255);
  85. //_delay_ms(2000);
  86. reset_keyboard();
  87. }
  88. return false;
  89. break;
  90. /*case _FLIP: //(╯°□°)╯︵ ┻━┻
  91. if (record->event.pressed) {
  92. register_code(KC_LPRN);
  93. unregister_code(KC_LPRN);
  94. register_code(X(0x00B0));
  95. unregister_code(X(0x00B0));
  96. UC(0x256F);
  97. PROCESS_UNICODE(UC(0x00B0));
  98. SEND_TAP(UC(0x25A1));
  99. SEND_TAP(UC(0x00B0));
  100. SEND_STRING(")");
  101. SEND_TAP(UC(0x256F));
  102. SEND_TAP(UC(0xFE35));
  103. SEND_TAP(UC(0x253B));
  104. SEND_TAP(UC(0x2501));
  105. SEND_TAP(UC(0x253B));
  106. }
  107. return false;
  108. break;*/
  109. return true;
  110. break;
  111. }
  112. return process_record_keymap(keycode, record);
  113. }