keymap.c 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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. _FUNC,
  21. _NUMPAD,
  22. _NUMROW
  23. };
  24. #define FUN MO(_FUNC)
  25. #define NPK TT(_NUMPAD)
  26. //#define SPEC_S LM(_NUMROW, (KC_LSFT))
  27. //#define SPEC_L3 LM(_NUMROW, (DE_ALGR))
  28. enum custom_keycodes {
  29. SPEC_S = SAFE_RANGE,
  30. SPEC_L3
  31. };
  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 | NumP | Spec | Space | Sp_A | 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, NPK, SPEC_S, KC_SPC, KC_SPC, SPEC_L3, FUN, KC_LEFT, KC_DOWN, KC_RGHT}
  49. },
  50. /* Function layer
  51. * ,-----------------------------------------------------------------------------------.
  52. * | | | | | | | | Ü | | Ö | | Del |
  53. * |------+------+------+------+------+-------------+------+------+------+------+------|
  54. * | Lock | Ä | | | | | | RGBS | RGBB | RGBS | | |
  55. * |------+------+------+------+------+------|------+------+------+------+------+------|
  56. * | | | | | | | | RGBH-| RGBT | RGBH+| PgUp | |
  57. * |------+------+------+------+------+------+------+------+------+------+------+------|
  58. * | | | | ---- | ---- | | | ---- | ---- | Home | PgDn | End |
  59. * `-----------------------------------------------------------------------------------'
  60. */
  61. [_FUNC] = {
  62. {_______, _______, _______, _______, _______, _______, _______, DE_UE, _______, DE_OE, _______, KC_DEL },
  63. {KC_LOCK, DE_AE, _______, _______, _______, _______, _______, 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. [_NUMROW] = {
  79. {_______, DE_1, DE_2, DE_3, DE_4, DE_5, DE_6, DE_7, DE_8, DE_9, DE_0, DE_SS },
  80. {_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______},
  81. {_______, DE_LESS, _______, _______, _______, _______, _______, _______, _______, _______, DE_MINS, _______},
  82. {_______, _______, _______, XXXXXXX, XXXXXXX, _______, _______, XXXXXXX, XXXXXXX, _______, _______, _______}
  83. },
  84. /* Numpad layer
  85. * ,-----------------------------------------------------------------------------------.
  86. * | | + | 7 | 8 | 9 | | | | | | | |
  87. * |------+------+------+------+------+-------------+------+------+------+------+------|
  88. * | | - | 4 | 5 | 6 | | | | | | | |
  89. * |------+------+------+------+------+------|------+------+------+------+------+------|
  90. * | | * | 1 | 2 | 3 | | | | | | | |
  91. * |------+------+------+------+------+------+------+------+------+------+------+------|
  92. * | | / | 0 | ---- | ---- | | | ---- | ---- | | | |
  93. * `-----------------------------------------------------------------------------------'
  94. */
  95. [_NUMPAD] = {
  96. {DEBUG, KC_PPLS, KC_P7, KC_P8, KC_P9, _______, _______, _______, _______, _______, _______, _______},
  97. {_______, KC_PMNS, KC_P4, KC_P5, KC_P6, _______, _______, _______, _______, _______, _______, _______},
  98. {_______, KC_PAST, KC_P1, KC_P2, KC_P3, _______, _______, _______, _______, _______, _______, _______},
  99. {_______, KC_PSLS, KC_P0, _______, XXXXXXX, _______, _______, XXXXXXX, XXXXXXX, _______, _______, _______}
  100. }
  101. };
  102. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  103. switch (keycode) {
  104. case SPEC_S:
  105. if (record->event.pressed) {
  106. register_code(KC_LSFT);
  107. layer_on(_NUMROW);
  108. } else {
  109. layer_off(_NUMROW);
  110. unregister_code(KC_LSFT);
  111. }
  112. return false;
  113. case SPEC_L3:
  114. if (record->event.pressed) {
  115. register_code(DE_ALGR);
  116. layer_on(_NUMROW);
  117. } else {
  118. layer_off(_NUMROW);
  119. unregister_code(DE_ALGR);
  120. }
  121. return false;
  122. default:
  123. return true;
  124. }
  125. }
  126. void led_set_user(uint8_t usb_led) {
  127. // Force-enable Numlock
  128. if (!(usb_led & (1<<USB_LED_NUM_LOCK))) {
  129. register_code(KC_NUMLOCK);
  130. unregister_code(KC_NUMLOCK);
  131. }
  132. }