extended_keymap_common.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. /*
  2. Copyright 2012,2013 Jun Wako <wakojun@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. #ifndef KEYMAP_H
  15. #define KEYMAP_H
  16. #include <stdint.h>
  17. #include <stdbool.h>
  18. #include "action.h"
  19. #include <avr/pgmspace.h>
  20. #include "keycode.h"
  21. #include "keymap.h"
  22. #include "action_macro.h"
  23. #include "report.h"
  24. #include "host.h"
  25. // #include "print.h"
  26. #include "debug.h"
  27. #ifdef BOOTMAGIC_ENABLE
  28. /* NOTE: Not portable. Bit field order depends on implementation */
  29. typedef union {
  30. uint16_t raw;
  31. struct {
  32. bool swap_control_capslock:1;
  33. bool capslock_to_control:1;
  34. bool swap_lalt_lgui:1;
  35. bool swap_ralt_rgui:1;
  36. bool no_gui:1;
  37. bool swap_grave_esc:1;
  38. bool swap_backslash_backspace:1;
  39. bool nkro:1;
  40. };
  41. } keymap_config_t;
  42. keymap_config_t keymap_config;
  43. #endif
  44. /* translates key to keycode */
  45. uint16_t keymap_key_to_keycode(uint8_t layer, keypos_t key);
  46. /* translates Fn keycode to action */
  47. action_t keymap_fn_to_action(uint16_t keycode);
  48. /* translates Fn keycode to action */
  49. action_t keymap_func_to_action(uint16_t keycode);
  50. extern const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS];
  51. extern const uint16_t fn_actions[];
  52. // Ability to use mods in layouts
  53. #define LCTL(kc) kc | 0x0100
  54. #define LSFT(kc) kc | 0x0200
  55. #define LALT(kc) kc | 0x0400
  56. #define LGUI(kc) kc | 0x0800
  57. #define RCTL(kc) kc | 0x1100
  58. #define RSFT(kc) kc | 0x1200
  59. #define RALT(kc) kc | 0x1400
  60. #define RGUI(kc) kc | 0x1800
  61. // Alias for function layers than expand past FN31
  62. #define FUNC(kc) kc | 0x2000
  63. // Aliases
  64. #define S(kc) LSFT(kc)
  65. #define F(kc) FUNC(kc)
  66. // For software implementation of colemak
  67. #define CM_Q KC_Q
  68. #define CM_W KC_W
  69. #define CM_F KC_E
  70. #define CM_P KC_R
  71. #define CM_G KC_T
  72. #define CM_J KC_Y
  73. #define CM_L KC_U
  74. #define CM_U KC_I
  75. #define CM_Y KC_O
  76. #define CM_SCLN KC_P
  77. #define CM_A KC_A
  78. #define CM_R KC_S
  79. #define CM_S KC_D
  80. #define CM_T KC_F
  81. #define CM_D KC_G
  82. #define CM_H KC_H
  83. #define CM_N KC_J
  84. #define CM_E KC_K
  85. #define CM_I KC_L
  86. #define CM_O KC_SCLN
  87. #define CM_Z KC_Z
  88. #define CM_X KC_X
  89. #define CM_C KC_C
  90. #define CM_V KC_V
  91. #define CM_B KC_B
  92. #define CM_K KC_N
  93. #define CM_M KC_M
  94. #define CM_COMM KC_COMM
  95. #define CM_DOT KC_DOT
  96. #define CM_SLSH KC_SLSH
  97. // Make it easy to support these in macros
  98. #define KC_CM_Q CM_Q
  99. #define KC_CM_W CM_W
  100. #define KC_CM_F CM_F
  101. #define KC_CM_P CM_P
  102. #define KC_CM_G CM_G
  103. #define KC_CM_J CM_J
  104. #define KC_CM_L CM_L
  105. #define KC_CM_U CM_U
  106. #define KC_CM_Y CM_Y
  107. #define KC_CM_SCLN CM_SCLN
  108. #define KC_CM_A CM_A
  109. #define KC_CM_R CM_R
  110. #define KC_CM_S CM_S
  111. #define KC_CM_T CM_T
  112. #define KC_CM_D CM_D
  113. #define KC_CM_H CM_H
  114. #define KC_CM_N CM_N
  115. #define KC_CM_E CM_E
  116. #define KC_CM_I CM_I
  117. #define KC_CM_O CM_O
  118. #define KC_CM_Z CM_Z
  119. #define KC_CM_X CM_X
  120. #define KC_CM_C CM_C
  121. #define KC_CM_V CM_V
  122. #define KC_CM_B CM_B
  123. #define KC_CM_K CM_K
  124. #define KC_CM_M CM_M
  125. #define KC_CM_COMM CM_COMM
  126. #define KC_CM_DOT CM_DOT
  127. #define KC_CM_SLSH CM_SLSH
  128. #define M(kc) kc | 0x3000
  129. #define MACRODOWN(...) (record->event.pressed ? MACRO(__VA_ARGS__) : MACRO_NONE)
  130. #define BL_ON 0x4009
  131. #define BL_OFF 0x4000
  132. #define BL_0 0x4000
  133. #define BL_1 0x4001
  134. #define BL_2 0x4002
  135. #define BL_3 0x4003
  136. #define BL_4 0x4004
  137. #define BL_5 0x4005
  138. #define BL_6 0x4006
  139. #define BL_7 0x4007
  140. #define BL_8 0x4008
  141. #define BL_9 0x4009
  142. #define BL_10 0x400A
  143. #define BL_11 0x400B
  144. #define BL_12 0x400C
  145. #define BL_13 0x400D
  146. #define BL_14 0x400E
  147. #define BL_15 0x400F
  148. #define BL_DEC 0x4010
  149. #define BL_INC 0x4011
  150. #define BL_TOGG 0x4012
  151. #define BL_STEP 0x4013
  152. #define RESET 0x5000
  153. #define DEBUG 0x5001
  154. #define MIDI(n) n | 0x6000
  155. #endif