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.

97 lines
3.6 KiB

[Keymap] Cleanup and updating of drashna keymap code (#11516) * Update other keyboards for rgb matrix changes * Remove customized bootmagic code * Fix corne layout compilation error * Fix compiler errors with all keymaps * Add Simple Visualizer for ergodox infinity * Fix compile issue with Corne * Fix keymap stuff * Add alias for mouse layer * Add Halmak Keyboard layout * Updates for Kyria * Add support for oled interval * Change RGB stuff [CHANGE] Fix coexistence issues * Fix rgb_stuff * Add custom ploopyco mouse keymap * Decrease default dwell time * Updates based on last breaking changes update * Disable command on dactyl * Update ergodox to use proper commands for rgb matrix indicators * Update all rgb matrix indicator functions * Update rules for dactyl-manuform * Reduce wait time for mouse layer off event * Add more info to logger * Add wrappers for get_tapping term * Move version.h include into only file that actually needs it * Update rgb sleep stuff * Update key print function * Change DM keymap settings * Change pin for DM Manuform * Add Proton C stuff for Corne keymap * more arm corne tinkering * Even more arm stuff for corne * Cleanup corne stuff * redirect default keymap to drashna because I am a very bad man * change corne rgb priority * Update tractyl manuform to not conflict * Add more secret stuff * more dactyl tweaks * Add more options to split transport * Changes of oled support * Change split settings * Improve keylogger formatting more * tweak oled stuff * Oled and such tweaks * Reduce brightness due to leds * Decrease brightness more * Only run layer code if master
3 years ago
  1. /* Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
  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 "drashna.h"
  17. #include "rgb_matrix.h"
  18. #include "lib/lib8tion/lib8tion.h"
  19. extern led_config_t g_led_config;
  20. static uint32_t hypno_timer;
  21. void rgb_matrix_layer_helper(uint8_t hue, uint8_t sat, uint8_t val, uint8_t mode, uint8_t speed, uint8_t led_type, uint8_t led_min, uint8_t led_max) {
  22. HSV hsv = {hue, sat, val};
  23. if (hsv.v > rgb_matrix_get_val()) {
  24. hsv.v = rgb_matrix_get_val();
  25. }
  26. switch (mode) {
  27. case 1: // breathing
  28. {
  29. uint16_t time = scale16by8(g_rgb_timer, speed / 8);
  30. hsv.v = scale8(abs8(sin8(time) - 128) * 2, hsv.v);
  31. RGB rgb = hsv_to_rgb(hsv);
  32. for (uint8_t i = 0; i < DRIVER_LED_TOTAL; i++) {
  33. if (HAS_FLAGS(g_led_config.flags[i], led_type)) {
  34. RGB_MATRIX_INDICATOR_SET_COLOR(i, rgb.r, rgb.g, rgb.b);
  35. }
  36. }
  37. break;
  38. }
  39. default: // Solid Color
  40. {
  41. RGB rgb = hsv_to_rgb(hsv);
  42. for (uint8_t i = 0; i < DRIVER_LED_TOTAL; i++) {
  43. if (HAS_FLAGS(g_led_config.flags[i], led_type)) {
  44. RGB_MATRIX_INDICATOR_SET_COLOR(i, rgb.r, rgb.g, rgb.b);
  45. }
  46. }
  47. break;
  48. }
  49. }
  50. }
  51. __attribute__((weak)) void rgb_matrix_indicator_keymap(void) {}
  52. void matrix_scan_rgb_matrix(void) {
  53. #if defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS)
  54. if (userspace_config.rgb_matrix_idle_anim && rgb_matrix_get_mode() == RGB_MATRIX_TYPING_HEATMAP && sync_timer_elapsed32(hypno_timer) > 15000) {
  55. rgb_matrix_mode_noeeprom(RGB_MATRIX_REST_MODE);
  56. }
  57. #endif
  58. rgb_matrix_indicator_keymap();
  59. }
  60. void keyboard_post_init_rgb_matrix(void) {
  61. #if defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS)
  62. if (userspace_config.rgb_matrix_idle_anim) {
  63. rgb_matrix_mode_noeeprom(RGB_MATRIX_REST_MODE);
  64. }
  65. #endif
  66. }
  67. bool process_record_user_rgb_matrix(uint16_t keycode, keyrecord_t *record) {
  68. #if defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS)
  69. hypno_timer = sync_timer_read32();
  70. if (userspace_config.rgb_matrix_idle_anim && rgb_matrix_get_mode() == RGB_MATRIX_REST_MODE) {
  71. rgb_matrix_mode_noeeprom(RGB_MATRIX_TYPING_HEATMAP);
  72. }
  73. #endif
  74. switch (keycode) {
  75. case RGB_IDL: // This allows me to use underglow as layer indication, or as normal
  76. #if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS)
  77. if (record->event.pressed) {
  78. userspace_config.rgb_matrix_idle_anim ^= 1;
  79. dprintf("RGB Matrix Idle Animation [EEPROM]: %u\n", userspace_config.rgb_matrix_idle_anim);
  80. eeconfig_update_user(userspace_config.raw);
  81. if (userspace_config.rgb_matrix_idle_anim) {
  82. rgb_matrix_mode_noeeprom(RGB_MATRIX_TYPING_HEATMAP);
  83. }
  84. }
  85. #endif
  86. break;
  87. }
  88. return true;
  89. }