keymap.c 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. _NUMROW
  22. };
  23. #define KC_I3 LM(_NUMROW, MOD_LALT)
  24. #define KC_NR MO(_NUMROW)
  25. #define NR_L3 SAFE_RANGE
  26. #define FUN MO(_FUNC)
  27. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  28. /* Qwertz
  29. * ,-----------------------------------------------------------------------------------.
  30. * | Esc | Q | W | E | R | T | Z | U | I | O | P | Bksp |
  31. * |------+------+------+------+------+-------------+------+------+------+------+------|
  32. * | Tab | A | S | D | F | G | H | J | K | L | +* ~ | Enter|
  33. * |------+------+------+------+------+------|------+------+------+------+------+------|
  34. * | Shift| Y | X | C | V | B | N | M | , | . | Up | Shift|
  35. * |------+------+------+------+------+------+------+------+------+------+------+------|
  36. * | Ctrl | Sup | Alt | i3 | NumR | Space | Spec | Fun | Left | Down | Right|
  37. * `-----------------------------------------------------------------------------------'
  38. */
  39. [_QWERTZ] = {
  40. {KC_GESC, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC},
  41. {KC_TAB, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, DE_PLUS, KC_ENT },
  42. {KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_UP, KC_RSFT},
  43. {KC_LCTL, KC_LGUI, KC_LALT, KC_I3, KC_NR, KC_SPC, KC_SPC, NR_L3, FUN, KC_LEFT, KC_DOWN, KC_RGHT}
  44. },
  45. /* Function layer
  46. * ,-----------------------------------------------------------------------------------.
  47. * | | | | | | | | Ü | | Ö | | Del |
  48. * |------+------+------+------+------+-------------+------+------+------+------+------|
  49. * | Lock | Ä | ß | | | | | RGBS | RGBB | RGBS | | |
  50. * |------+------+------+------+------+------|------+------+------+------+------+------|
  51. * | | | | | | | | RGBH-| RGBT | RGBH+| PgUp | |
  52. * |------+------+------+------+------+------+------+------+------+------+------+------|
  53. * | | | | ---- | ---- | | | ---- | ---- | Home | PgDn | End |
  54. * `-----------------------------------------------------------------------------------'
  55. */
  56. [_FUNC] = {
  57. {_______, _______, _______, _______, _______, _______, _______, DE_UE, _______, DE_OE, _______, KC_DEL },
  58. {KC_LOCK, DE_AE, DE_SS, _______, _______, _______, _______, RGB_M_P, RGB_M_B, RGB_M_SW,_______, _______},
  59. {_______, _______, _______, _______, _______, _______, _______, RGB_HUD, RGB_TOG, RGB_HUI, KC_PGUP, _______},
  60. {_______, _______, _______, XXXXXXX, XXXXXXX, _______, _______, XXXXXXX, XXXXXXX, KC_HOME, KC_PGDN, KC_END }
  61. },
  62. /* Numrow layer (special characters with Shift and ISO_L3_Shift)
  63. * ,-----------------------------------------------------------------------------------.
  64. * | | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | ß |
  65. * |------+------+------+------+------+-------------+------+------+------+------+------|
  66. * | | | | | | | | | | | #' | |
  67. * |------+------+------+------+------+------|------+------+------+------+------+------|
  68. * | | <> | | | | | | | | | | -_ | |
  69. * |------+------+------+------+------+------+------+------+------+------+------+------|
  70. * | | | | ---- | ---- | | | ---- | ---- | | | |
  71. * `-----------------------------------------------------------------------------------'
  72. */
  73. [_NUMROW] = {
  74. {_______, DE_1, DE_2, DE_3, DE_4, DE_5, DE_6, DE_7, DE_8, DE_9, DE_0, DE_SS },
  75. {_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, DE_HASH, _______},
  76. {_______, DE_LESS, _______, _______, _______, _______, _______, _______, _______, _______, DE_MINS, _______},
  77. {_______, _______, _______, XXXXXXX, XXXXXXX, _______, _______, XXXXXXX, XXXXXXX, _______, _______, _______}
  78. }
  79. };
  80. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  81. if (keycode == NR_L3) {
  82. if (record->event.pressed) {
  83. register_code(DE_ALGR);
  84. layer_on(_NUMROW);
  85. } else {
  86. layer_off(_NUMROW);
  87. unregister_code(DE_ALGR);
  88. }
  89. return false;
  90. }
  91. return true;
  92. }
  93. void led_set_user(uint8_t usb_led) {
  94. // Force-enable Numlock
  95. if (!(usb_led & (1<<USB_LED_NUM_LOCK))) {
  96. register_code(KC_NUMLOCK);
  97. unregister_code(KC_NUMLOCK);
  98. }
  99. }