keymap.c 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*
  2. Copyright 2017 Luiz Ribeiro <luizribeiro@gmail.com>
  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. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. */
  14. #include "ps2avrGB.h"
  15. #include "action_layer.h"
  16. #include "rgblight.h"
  17. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  18. KC_KEYMAP(
  19. ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,HOME,END,
  20. GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, DEL,
  21. TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS, INS,
  22. CAPS,A, S, D, F, G, H, J, K, L, SCLN,QUOT,ENT, PGUP,
  23. LSFT,Z, X, C, V, B, N, M, COMM,DOT, SLSH,RSFT, UP, PGDN,
  24. LCTL,LALT,LGUI, SPC, RGUI,RALT,RCTL,LEFT,DOWN,RGHT
  25. )
  26. };
  27. enum function_id {
  28. RGBLED_TOGGLE,
  29. RGBLED_STEP_MODE,
  30. RGBLED_INCREASE_HUE,
  31. RGBLED_DECREASE_HUE,
  32. RGBLED_INCREASE_SAT,
  33. RGBLED_DECREASE_SAT,
  34. RGBLED_INCREASE_VAL,
  35. RGBLED_DECREASE_VAL,
  36. };
  37. const uint16_t PROGMEM fn_actions[] = {
  38. [0] = ACTION_FUNCTION(RGBLED_TOGGLE),
  39. [1] = ACTION_FUNCTION(RGBLED_STEP_MODE),
  40. [2] = ACTION_FUNCTION(RGBLED_INCREASE_HUE),
  41. [3] = ACTION_FUNCTION(RGBLED_DECREASE_HUE),
  42. [4] = ACTION_FUNCTION(RGBLED_INCREASE_SAT),
  43. [5] = ACTION_FUNCTION(RGBLED_DECREASE_SAT),
  44. [6] = ACTION_FUNCTION(RGBLED_INCREASE_VAL),
  45. [7] = ACTION_FUNCTION(RGBLED_DECREASE_VAL),
  46. };
  47. void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) {
  48. switch (id) {
  49. case RGBLED_TOGGLE:
  50. if (record->event.pressed) {
  51. rgblight_toggle();
  52. }
  53. break;
  54. case RGBLED_STEP_MODE:
  55. if (record->event.pressed) {
  56. rgblight_step();
  57. }
  58. break;
  59. case RGBLED_INCREASE_HUE:
  60. if (record->event.pressed) {
  61. rgblight_increase_hue();
  62. }
  63. break;
  64. case RGBLED_DECREASE_HUE:
  65. if (record->event.pressed) {
  66. rgblight_decrease_hue();
  67. }
  68. break;
  69. case RGBLED_INCREASE_SAT:
  70. if (record->event.pressed) {
  71. rgblight_increase_sat();
  72. }
  73. break;
  74. case RGBLED_DECREASE_SAT:
  75. if (record->event.pressed) {
  76. rgblight_decrease_sat();
  77. }
  78. break;
  79. case RGBLED_INCREASE_VAL:
  80. if (record->event.pressed) {
  81. rgblight_increase_val();
  82. }
  83. break;
  84. case RGBLED_DECREASE_VAL:
  85. if (record->event.pressed) {
  86. rgblight_decrease_val();
  87. }
  88. break;
  89. }
  90. };