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_default.c 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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. * | |MsU|Fn3|
  52. * |---+---+---|
  53. * |MsL|MsD|MsR|
  54. * `-----------'
  55. */
  56. KEYMAP( MS_U,FN3, MS_L,MS_D,MS_R ),
  57. /* Keymap 4
  58. * ,-----------.
  59. * | |Fn6|Fn4|
  60. * |---+---+---|
  61. * |Fn7|Fn5|Fn8|
  62. * `-----------'
  63. */
  64. KEYMAP( FN6, FN4, FN7, FN5, FN8 ),
  65. };
  66. enum function_id {
  67. AF_RGB_TOGGLE = 0,
  68. AF_RGB_DECREASE,
  69. AF_RGB_INCREASE,
  70. AF_RGB_STEP
  71. };
  72. /*
  73. * Fn action definition
  74. */
  75. #ifdef KEYMAP_SECTION_ENABLE
  76. const uint16_t fn_actions[FN_ACTIONS_COUNT] __attribute__ ((section (".keymap.fn_actions"))) = {
  77. #else
  78. const uint16_t fn_actions[] PROGMEM = {
  79. [0] = ACTION_DEFAULT_LAYER_SET(1),
  80. [1] = ACTION_DEFAULT_LAYER_SET(2),
  81. [2] = ACTION_DEFAULT_LAYER_SET(3),
  82. [3] = ACTION_DEFAULT_LAYER_SET(4),
  83. [4] = ACTION_DEFAULT_LAYER_SET(0),
  84. [5] = ACTION_BACKLIGHT_DECREASE(),
  85. [6] = ACTION_BACKLIGHT_INCREASE(),
  86. [7] = ACTION_FUNCTION(AF_RGB_DECREASE),
  87. [8] = ACTION_FUNCTION(AF_RGB_INCREASE)
  88. #endif
  89. };
  90. #ifdef KEYMAP_IN_EEPROM_ENABLE
  91. uint16_t keys_count(void) {
  92. return sizeof(keymaps) / sizeof(keymaps[0]) * MATRIX_ROWS * MATRIX_COLS;
  93. }
  94. uint16_t fn_actions_count(void) {
  95. return sizeof(fn_actions) / sizeof(fn_actions[0]);
  96. }
  97. #endif
  98. void action_function(keyrecord_t *record, uint8_t id, uint8_t opt)
  99. {
  100. if (record->event.pressed) {
  101. switch (id) {
  102. case AF_RGB_TOGGLE:
  103. rgb_toggle();
  104. break;
  105. case AF_RGB_DECREASE:
  106. rgb_decrease();
  107. break;
  108. case AF_RGB_INCREASE:
  109. rgb_increase();
  110. break;
  111. case AF_RGB_STEP:
  112. rgb_step();
  113. break;
  114. }
  115. }
  116. }