keymap.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. #include "cluepad.h"
  2. #include "backlight.h"
  3. #include "rgblight.h"
  4. // Each layer gets a name for readability, which is then used in the keymap matrix below.
  5. // The underscores don't mean anything - you can have a layer called STUFF or any other name.
  6. // Layer names don't all need to be of the same length, obviously, and you can also skip them
  7. // entirely and just use numbers.
  8. #define _BL 0
  9. #define _FL 1
  10. #define _RS 2
  11. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  12. /* Keymap _BL: (Base Layer) Default Layer
  13. * .-------------------.
  14. * |NL F| /| *| -|
  15. * |-------------------|
  16. * | 7| 8| 9| |
  17. * |--------------| |
  18. * | 4| 5| 6| +|
  19. * |-------------------|
  20. * | 1| 2| 3| |
  21. * |--------------| |
  22. * | 0| .| Ent|
  23. * '-------------------'
  24. */
  25. [_BL] = KEYMAP(
  26. LT(_FL, KC_NLCK), KC_PSLS, KC_PAST, KC_PMNS, \
  27. KC_P7, KC_P8, KC_P9, KC_PPLS, \
  28. KC_P4, KC_P5, KC_P6, \
  29. KC_P1, KC_P2, KC_P3, KC_PENT, \
  30. KC_P0, KC_PDOT),
  31. /* Keymap _FL: Function Layer
  32. * .-------------------.
  33. * |NL F| | | Fn0|
  34. * |-------------------|
  35. * | | Fn4| | |
  36. * |--------------| |
  37. * | Fn3|BL_S| Fn2| Fn6|
  38. * |-------------------|
  39. * | | Fn5| | |
  40. * |--------------| |
  41. * | Fn1| | Fn7|
  42. * '-------------------'
  43. */
  44. [_FL] = KEYMAP(
  45. LT(_FL, KC_NLCK), KC_TRNS, KC_TRNS, F(0), \
  46. KC_TRNS, F(4), KC_TRNS, F(6), \
  47. F(3), BL_STEP, F(2), \
  48. KC_TRNS, F(5), KC_TRNS, F(7), \
  49. F(1), KC_TRNS)
  50. };
  51. enum function_id {
  52. RGBLED_TOGGLE,
  53. RGBLED_STEP_MODE,
  54. RGBLED_INCREASE_HUE,
  55. RGBLED_DECREASE_HUE,
  56. RGBLED_INCREASE_SAT,
  57. RGBLED_DECREASE_SAT,
  58. RGBLED_INCREASE_VAL,
  59. RGBLED_DECREASE_VAL,
  60. };
  61. const uint16_t PROGMEM fn_actions[] = {
  62. [0] = ACTION_FUNCTION(RGBLED_TOGGLE),
  63. [1] = ACTION_FUNCTION(RGBLED_STEP_MODE),
  64. [2] = ACTION_FUNCTION(RGBLED_INCREASE_HUE),
  65. [3] = ACTION_FUNCTION(RGBLED_DECREASE_HUE),
  66. [4] = ACTION_FUNCTION(RGBLED_INCREASE_SAT),
  67. [5] = ACTION_FUNCTION(RGBLED_DECREASE_SAT),
  68. [6] = ACTION_FUNCTION(RGBLED_INCREASE_VAL),
  69. [7] = ACTION_FUNCTION(RGBLED_DECREASE_VAL),
  70. };
  71. void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) {
  72. switch (id) {
  73. case RGBLED_TOGGLE:
  74. if (record->event.pressed) {
  75. rgblight_toggle();
  76. }
  77. break;
  78. case RGBLED_INCREASE_HUE:
  79. if (record->event.pressed) {
  80. rgblight_increase_hue();
  81. }
  82. break;
  83. case RGBLED_DECREASE_HUE:
  84. if (record->event.pressed) {
  85. rgblight_decrease_hue();
  86. }
  87. break;
  88. case RGBLED_INCREASE_SAT:
  89. if (record->event.pressed) {
  90. rgblight_increase_sat();
  91. }
  92. break;
  93. case RGBLED_DECREASE_SAT:
  94. if (record->event.pressed) {
  95. rgblight_decrease_sat();
  96. }
  97. break;
  98. case RGBLED_INCREASE_VAL:
  99. if (record->event.pressed) {
  100. rgblight_increase_val();
  101. }
  102. break;
  103. case RGBLED_DECREASE_VAL:
  104. if (record->event.pressed) {
  105. rgblight_decrease_val();
  106. }
  107. break;
  108. case RGBLED_STEP_MODE:
  109. if (record->event.pressed) {
  110. rgblight_step();
  111. }
  112. break;
  113. }
  114. }