keymap.c 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. #ifdef KEYBOARD_zeal60
  2. #include "config.h"
  3. #include "zeal60.h"
  4. #include "zeal_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 zeal_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. zeal_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. BACKLIGHT_ALPHAS_MODS_ROW_0,
  36. BACKLIGHT_ALPHAS_MODS_ROW_1,
  37. BACKLIGHT_ALPHAS_MODS_ROW_2,
  38. BACKLIGHT_ALPHAS_MODS_ROW_3,
  39. BACKLIGHT_ALPHAS_MODS_ROW_4 }
  40. };
  41. memcpy(&g_config, &default_values, sizeof(zeal_backlight_config));
  42. backlight_config_save();
  43. solarized_t* S = &solarized;
  44. HSV alphas = S->base2;
  45. HSV custom_color_map[MATRIX_ROWS][MATRIX_COLS] = CM(
  46. S->red, alphas, alphas, alphas, alphas, alphas, alphas, alphas, alphas, alphas, alphas, alphas, alphas, alphas, S->red,
  47. S->orange, alphas, alphas, alphas, alphas, alphas, alphas, alphas, alphas, alphas, alphas, alphas, alphas, S->orange,
  48. S->green, alphas, alphas, alphas, alphas, alphas, alphas, alphas, alphas, alphas, alphas, alphas, S->green,
  49. S->blue, alphas, alphas, alphas, alphas, alphas, alphas, alphas, alphas, alphas, alphas, S->blue, S->blue,
  50. S->violet, S->magenta, S->yellow, alphas, S->yellow, S->magenta, S->violet, S->green
  51. );
  52. for (uint8_t row = 0; row < MATRIX_ROWS; ++row) {
  53. for (uint8_t col = 0; col < MATRIX_COLS; ++col) {
  54. backlight_set_key_color(row, col, custom_color_map[row][col]);
  55. }
  56. }
  57. }
  58. bool process_record_keymap(uint16_t keycode, keyrecord_t *record) {
  59. static uint8_t last_effect;
  60. switch (keycode) {
  61. case DFAULTS:
  62. if (IS_PRESSED(record->event)) set_backlight_defaults();
  63. return false;
  64. case BL_TOGG:
  65. if (IS_PRESSED(record->event)) {
  66. if (g_config.effect) {
  67. last_effect = g_config.effect;
  68. g_config.effect = 0;
  69. } else {
  70. g_config.effect = last_effect;
  71. }
  72. }
  73. return false;
  74. case EFFECT...EFFECT_END:
  75. if (IS_PRESSED(record->event)) {
  76. uint8_t effect = keycode - EFFECT;
  77. g_config.effect = effect;
  78. backlight_config_save();
  79. }
  80. return false;
  81. }
  82. return true;
  83. }
  84. #endif