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.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

keymap_lite.c 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /*
  2. Copyright 2015 Kai Ryu <[email protected]>
  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 <avr/pgmspace.h>
  15. #include "keycode.h"
  16. #include "action.h"
  17. #include "keymap_common.h"
  18. #include "rgb.h"
  19. // Default
  20. #ifdef KEYMAP_SECTION_ENABLE
  21. const uint8_t keymaps[KEYMAPS_COUNT][MATRIX_ROWS][MATRIX_COLS] __attribute__ ((section (".keymap.keymaps"))) = {
  22. #else
  23. const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = {
  24. #endif
  25. /* Keymap 0
  26. * ,-----------.
  27. * | |Up |Fn0|
  28. * |---+---+---|
  29. * |Lef|Dow|Rig|
  30. * `-----------'
  31. */
  32. KEYMAP( UP, FN0, LEFT,DOWN,RGHT ),
  33. /* Keymap 1
  34. * ,-----------.
  35. * | |PgU|Fn1|
  36. * |---+---+---|
  37. * |Hom|PgD|End|
  38. * `-----------'
  39. */
  40. KEYMAP( PGUP,FN1, HOME,PGDN,END ),
  41. /* Keymap 2
  42. * ,-----------.
  43. * | |Sel|Fn2|
  44. * |---+---+---|
  45. * |Pre|Pla|Nex|
  46. * `-----------'
  47. */
  48. KEYMAP( MSEL,FN2, MPRV,MPLY,MNXT ),
  49. /* Keymap 3
  50. * ,-----------.
  51. * | |Fn5|Fn3|
  52. * |---+---+---|
  53. * |Fn6|Fn4|Fn7|
  54. * `-----------'
  55. */
  56. KEYMAP( FN5, FN3, FN6, FN4, FN7 ),
  57. };
  58. enum function_id {
  59. AF_RGB_TOGGLE = 0,
  60. AF_RGB_DECREASE,
  61. AF_RGB_INCREASE,
  62. AF_RGB_STEP
  63. };
  64. /*
  65. * Fn action definition
  66. */
  67. #ifdef KEYMAP_SECTION_ENABLE
  68. const uint16_t fn_actions[FN_ACTIONS_COUNT] __attribute__ ((section (".keymap.fn_actions"))) = {
  69. #else
  70. const uint16_t fn_actions[] PROGMEM = {
  71. [0] = ACTION_DEFAULT_LAYER_SET(1),
  72. [1] = ACTION_DEFAULT_LAYER_SET(2),
  73. [2] = ACTION_DEFAULT_LAYER_SET(3),
  74. [3] = ACTION_DEFAULT_LAYER_SET(0),
  75. [4] = ACTION_BACKLIGHT_DECREASE(),
  76. [5] = ACTION_BACKLIGHT_INCREASE(),
  77. [6] = ACTION_FUNCTION(AF_RGB_DECREASE),
  78. [7] = ACTION_FUNCTION(AF_RGB_INCREASE)
  79. #endif
  80. };
  81. #ifdef KEYMAP_IN_EEPROM_ENABLE
  82. uint16_t keys_count(void) {
  83. return sizeof(keymaps) / sizeof(keymaps[0]) * MATRIX_ROWS * MATRIX_COLS;
  84. }
  85. uint16_t fn_actions_count(void) {
  86. return sizeof(fn_actions) / sizeof(fn_actions[0]);
  87. }
  88. #endif
  89. void action_function(keyrecord_t *record, uint8_t id, uint8_t opt)
  90. {
  91. if (record->event.pressed) {
  92. switch (id) {
  93. case AF_RGB_TOGGLE:
  94. rgb_toggle();
  95. break;
  96. case AF_RGB_DECREASE:
  97. rgb_decrease();
  98. break;
  99. case AF_RGB_INCREASE:
  100. rgb_increase();
  101. break;
  102. case AF_RGB_STEP:
  103. rgb_step();
  104. break;
  105. }
  106. }
  107. }