keymap.c 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #ifdef KEYBOARD_zeal60
  2. #include "config.h"
  3. #include "zeal60.h"
  4. #include "rgb_backlight.h"
  5. #include "action_layer.h"
  6. #include "solarized.h"
  7. #include "talljoe.h"
  8. // from zeal_backlight.c
  9. // we want to be able to set indicators for the spacebar stabs
  10. // but they are not represented by a row/index.
  11. extern backlight_config g_config;
  12. void map_row_column_to_led( uint8_t row, uint8_t column, uint8_t *led );
  13. void set_backlight_defaults(void) {
  14. uint8_t space;
  15. uint8_t caps_lock;
  16. map_row_column_to_led(3, 12, &caps_lock);
  17. map_row_column_to_led(4, 7, &space);
  18. backlight_config default_values = {
  19. .use_split_backspace = USE_SPLIT_BACKSPACE,
  20. .use_split_left_shift = USE_SPLIT_LEFT_SHIFT,
  21. .use_split_right_shift = USE_SPLIT_RIGHT_SHIFT,
  22. .use_7u_spacebar = USE_7U_SPACEBAR,
  23. .use_iso_enter = USE_ISO_ENTER,
  24. .disable_when_usb_suspended = 1,
  25. .disable_after_timeout = 0,
  26. .brightness = 255,
  27. .effect = 10,
  28. .color_1 = solarized.base2,
  29. .color_2 = solarized.base02,
  30. .caps_lock_indicator = { .index = caps_lock, .color = solarized.red },
  31. .layer_1_indicator = { .index = space, .color = solarized.blue },
  32. .layer_2_indicator = { .index = space, .color = solarized.yellow },
  33. .layer_3_indicator = { .index = 254, .color = solarized.red },
  34. .alphas_mods = {
  35. RGB_BACKLIGHT_ALPHAS_MODS_ROW_0,
  36. RGB_BACKLIGHT_ALPHAS_MODS_ROW_1,
  37. RGB_BACKLIGHT_ALPHAS_MODS_ROW_2,
  38. RGB_BACKLIGHT_ALPHAS_MODS_ROW_3,
  39. RGB_BACKLIGHT_ALPHAS_MODS_ROW_4 }
  40. };
  41. memcpy(&g_config, &default_values, sizeof(backlight_config));
  42. backlight_config_save();
  43. #undef CUSTOM_RGB_LAYOUTS
  44. #ifdef CUSTOM_RGB_LAYOUTS
  45. solarized_t* S = &solarized;
  46. HSV alphas = S->base2;
  47. HSV custom_color_map[MATRIX_ROWS][MATRIX_COLS] = CM(
  48. S->red, alphas, alphas, alphas, alphas, alphas, alphas, alphas, alphas, alphas, alphas, alphas, alphas, alphas, S->red,
  49. S->orange, alphas, alphas, alphas, alphas, alphas, alphas, alphas, alphas, alphas, alphas, alphas, alphas, S->orange,
  50. S->green, alphas, alphas, alphas, alphas, alphas, alphas, alphas, alphas, alphas, alphas, alphas, S->green,
  51. S->blue, alphas, alphas, alphas, alphas, alphas, alphas, alphas, alphas, alphas, alphas, S->blue, S->blue,
  52. S->violet, S->magenta, S->yellow, alphas, S->yellow, S->magenta, S->violet, S->green
  53. );
  54. for (uint8_t row = 0; row < MATRIX_ROWS; ++row) {
  55. for (uint8_t col = 0; col < MATRIX_COLS; ++col) {
  56. uint8_t index;
  57. map_row_column_to_led( row, col, &index );
  58. set_key_color(index, custom_color_map[row][col]);
  59. }
  60. }
  61. #endif // CUSTOM_RGB_LAYOUTS
  62. }
  63. bool process_record_keymap(uint16_t keycode, keyrecord_t *record) {
  64. static uint8_t last_effect;
  65. switch (keycode) {
  66. case DFAULTS:
  67. if (IS_PRESSED(record->event)) set_backlight_defaults();
  68. return false;
  69. case BL_TOGG:
  70. if (IS_PRESSED(record->event)) {
  71. if (g_config.effect) {
  72. last_effect = g_config.effect;
  73. g_config.effect = 0;
  74. } else {
  75. g_config.effect = last_effect;
  76. }
  77. }
  78. return false;
  79. case EFFECT...EFFECT_END:
  80. if (IS_PRESSED(record->event)) {
  81. uint8_t effect = keycode - EFFECT;
  82. g_config.effect = effect;
  83. backlight_config_save();
  84. }
  85. return false;
  86. }
  87. return true;
  88. }
  89. #endif