keymap.c 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. /* Copyright 2015-2017 Jack Humbert
  2. *
  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. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #include "contra.h"
  17. #include "keymap_german.h"
  18. enum contra_layers {
  19. _QWERTZ,
  20. _FN,
  21. _NR,
  22. _NR_L3,
  23. _FX,
  24. _GAMING
  25. };
  26. #define KC_I3 LM(_NR, MOD_LALT)
  27. #define KC_NR SAFE_RANGE
  28. #define KC_N3 (SAFE_RANGE + 1)
  29. #define KC_FN MO(_FN)
  30. #define G_1 TO(_GAMING)
  31. #define G_0 TG(_GAMING)
  32. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  33. /* Qwertz
  34. * ,-----------------------------------------------------------------------------------.
  35. * | Esc | Q | W | E | R | T | Z | U | I | O | P | Bksp |
  36. * |------+------+------+------+------+-------------+------+------+------+------+------|
  37. * | Tab | A | S | D | F | G | H | J | K | L | +* ~ | Enter|
  38. * |------+------+------+------+------+------|------+------+------+------+------+------|
  39. * | Shift| Y | X | C | V | B | N | M | , | . | Up | Shift|
  40. * |------+------+------+------+------+------+------+------+------+------+------+------|
  41. * | Ctrl | Sup | Alt | i3 | NumR | Space | Spec | Fun | Left | Down | Right|
  42. * `-----------------------------------------------------------------------------------'
  43. */
  44. [_QWERTZ] = {
  45. {KC_GESC, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC},
  46. {KC_TAB, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, DE_PLUS, KC_ENT },
  47. {KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_UP, KC_RSFT},
  48. {KC_LCTL, KC_LGUI, KC_LALT, KC_I3, KC_NR, KC_SPC, KC_SPC, KC_N3, KC_FN, KC_LEFT, KC_DOWN, KC_RGHT}
  49. },
  50. /* Function layer
  51. * ,-----------------------------------------------------------------------------------.
  52. * | | | | | | | | Ü | | Ö | | Del |
  53. * |------+------+------+------+------+-------------+------+------+------+------+------|
  54. * | Lock | Ä | ß | | | GAME | | RGBS | RGBB | RGBS | | |
  55. * |------+------+------+------+------+------|------+------+------+------+------+------|
  56. * | | | | | | | | RGBH-| RGBT | RGBH+| PgUp | |
  57. * |------+------+------+------+------+------+------+------+------+------+------+------|
  58. * | | | | ---- | ---- | | ---- | ---- | Home | PgDn | End |
  59. * `-----------------------------------------------------------------------------------'
  60. */
  61. [_FN] = {
  62. {_______, _______, _______, _______, _______, _______, _______, DE_UE, _______, DE_OE, _______, KC_DEL },
  63. {KC_LOCK, DE_AE, DE_SS, _______, _______, G_1, _______, RGB_M_P, RGB_M_B, RGB_M_SW,_______, _______},
  64. {_______, _______, _______, _______, _______, _______, _______, RGB_HUD, RGB_TOG, RGB_HUI, KC_PGUP, _______},
  65. {_______, _______, _______, XXXXXXX, XXXXXXX, _______, _______, XXXXXXX, XXXXXXX, KC_HOME, KC_PGDN, KC_END }
  66. },
  67. /* Numrow layer (special characters with Shift and ISO_L3_Shift)
  68. * ,-----------------------------------------------------------------------------------.
  69. * | | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | \ |
  70. * |------+------+------+------+------+-------------+------+------+------+------+------|
  71. * | | | | | | | | | | | #' | |
  72. * |------+------+------+------+------+------|------+------+------+------+------+------|
  73. * | | <> | | | | | | | | | | -_ | |
  74. * |------+------+------+------+------+------+------+------+------+------+------+------|
  75. * | | | | ---- | ---- | | ---- | ---- | | | |
  76. * `-----------------------------------------------------------------------------------'
  77. */
  78. [_NR] = {
  79. {_______, DE_1, DE_2, DE_3, DE_4, DE_5, DE_6, DE_7, DE_8, DE_9, DE_0, _______},
  80. {_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, DE_HASH, _______},
  81. {_______, DE_LESS, _______, _______, _______, _______, _______, _______, _______, _______, DE_MINS, _______},
  82. {_______, _______, _______, XXXXXXX, _______, _______, _______, _______, XXXXXXX, _______, _______, _______}
  83. },
  84. [_NR_L3] = {
  85. {_______, DE_1, DE_2, DE_3, DE_4, DE_5, DE_6, DE_7, DE_8, DE_9, DE_0, DE_SS },
  86. {_______, DE_Q, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______},
  87. {_______, DE_LESS, _______, _______, _______, _______, _______, _______, _______, _______, DE_MINS, _______},
  88. {_______, _______, _______, XXXXXXX, _______, _______, _______, _______, XXXXXXX, _______, _______, _______}
  89. },
  90. /* Function keys
  91. * ,-----------------------------------------------------------------------------------.
  92. * | F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | F11 | F12 |
  93. * |------+------+------+------+------+-------------+------+------+------+------+------|
  94. * | | | | | | | | | | | | |
  95. * |------+------+------+------+------+------|------+------+------+------+------+------|
  96. * | | | | | | | | | | | | |
  97. * |------+------+------+------+------+------+------+------+------+------+------+------|
  98. * | | | | | | | | | | | |
  99. * `-----------------------------------------------------------------------------------'
  100. */
  101. [_FX] = {
  102. {KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12 },
  103. {_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______},
  104. {_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______},
  105. {_______, _______, _______, XXXXXXX, _______, _______, _______, _______, XXXXXXX, _______, _______, _______}
  106. },
  107. /* Gaming
  108. * ,-----------------------------------------------------------------------------------.
  109. * | | | | | | | | | | | | |
  110. * |------+------+------+------+------+-------------+------+------+------+------+------|
  111. * | | | | | | | | | | | | |
  112. * |------+------+------+------+------+------|------+------+------+------+------+------|
  113. * | | | | | | | | | | | | |
  114. * |------+------+------+------+------+------+------+------+------+------+------+------|
  115. * | Space| | | | | | | Leave| | | |
  116. * `-----------------------------------------------------------------------------------'
  117. */
  118. [_GAMING] = {
  119. {_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______},
  120. {_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______},
  121. {_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______},
  122. {KC_SPC, XXXXXXX, _______, _______, _______, KC_LCTL, KC_LCTL, _______, G_0, _______, _______, _______}
  123. }
  124. };
  125. void update_tri_layer_user(void);
  126. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  127. switch(keycode) {
  128. case KC_BSPC:
  129. if (record->event.pressed) {
  130. if (get_mods() & (MOD_BIT(KC_LSFT) | MOD_BIT(KC_RSFT))) {
  131. register_code(DE_SS);
  132. return false;
  133. }
  134. } else {
  135. unregister_code(DE_SS);
  136. }
  137. return true;
  138. case KC_NR:
  139. if (record->event.pressed) {
  140. layer_on(_NR);
  141. } else {
  142. layer_off(_NR);
  143. }
  144. update_tri_layer_user();
  145. return false;
  146. case KC_N3:
  147. if (record->event.pressed) {
  148. layer_on(_NR_L3);
  149. } else {
  150. layer_off(_NR_L3);
  151. }
  152. update_tri_layer_user();
  153. return false;
  154. default:
  155. return true;
  156. }
  157. }
  158. void update_tri_layer_user(void) {
  159. update_tri_layer(_NR, _NR_L3, _FX);
  160. if (layer_state_is(_NR_L3) && !layer_state_is(_FX)) {
  161. register_code(KC_ALGR);
  162. } else {
  163. unregister_code(KC_ALGR);
  164. }
  165. }
  166. void led_set_user(uint8_t usb_led) {
  167. // Force-enable Numlock
  168. if (!(usb_led & (1<<USB_LED_NUM_LOCK))) {
  169. register_code(KC_NUMLOCK);
  170. unregister_code(KC_NUMLOCK);
  171. }
  172. }