keymap.c 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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 QMK_KEYBOARD_H
  17. extern keymap_config_t keymap_config;
  18. enum planck_layers {
  19. DVORAK,
  20. OVL_L, // Left overlay
  21. OVL_R, // Right overlay
  22. OVL_C, // Corner overlay
  23. OVL_N, // Number overlay
  24. OVL_F, // F-key overlay
  25. };
  26. enum planck_keycodes {
  27. UMLT_A = SAFE_RANGE,
  28. UMLT_O,
  29. UMLT_U,
  30. };
  31. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  32. [DVORAK] = LAYOUT_planck_grid(
  33. KC_TAB, KC_QUOT, KC_COMM, KC_DOT, KC_P, KC_Y, KC_F, KC_G, KC_C, KC_R, KC_L, OSL(OVL_C),
  34. KC_ESC, KC_A, KC_O, KC_E, KC_U, KC_I, KC_D, KC_H, KC_T, KC_N, KC_S, KC_ENT ,
  35. KC_LSFT, KC_SCLN, KC_Q, KC_J, KC_K, KC_X, KC_B, KC_M, KC_W, KC_V, KC_Z, KC_RSFT ,
  36. KC_LGUI, MO(OVL_N), KC_LCTL, KC_RCTL, KC_BSPC, MO(OVL_L), MO(OVL_R), KC_SPC, KC_LALT, MO(OVL_F), KC_RALT, KC_RGUI
  37. ),
  38. [OVL_L] = LAYOUT_planck_grid(
  39. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_RGHT, _______,
  40. _______, KC_UNDS, KC_MINS, KC_BSLS, KC_SLSH, KC_PLUS, KC_DLR, KC_LEFT, KC_EQL, KC_LCBR, KC_RCBR, _______,
  41. _______, KC_SCLN, _______, _______, _______, _______, _______, _______, KC_GRV, KC_HASH, KC_PIPE, _______,
  42. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______
  43. ),
  44. [OVL_R] = LAYOUT_planck_grid(
  45. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
  46. _______, KC_LBRC, KC_RBRC, KC_LPRN, KC_RPRN, KC_EXLM, KC_CIRC, KC_QUES, KC_PERC, KC_AMPR, KC_ASTR, _______,
  47. _______, KC_TILD, KC_AT, KC_DOWN, KC_UP, _______, _______, _______, _______, _______, _______, _______,
  48. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______
  49. ),
  50. [OVL_C] = LAYOUT_planck_grid(
  51. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_END, _______,
  52. _______, UMLT_A, UMLT_O, _______, UMLT_U, _______, _______, KC_HOME, _______, _______, _______, _______,
  53. _______, _______, _______, KC_PGDN, KC_PGUP, _______, _______, _______, _______, _______, _______, _______,
  54. _______, _______, _______, _______, KC_DEL, _______, _______, KC_INS, _______, _______, _______, _______
  55. ),
  56. [OVL_N] = LAYOUT_planck_grid(
  57. _______, _______, _______, _______, _______, _______, _______, KC_7, KC_8, KC_9, _______, _______,
  58. _______, KC_PLUS, KC_UNDS, KC_LPRN, KC_RPRN, _______, _______, KC_4, KC_5, KC_6, _______, _______,
  59. _______, KC_ASTR, KC_SLSH, _______, _______, _______, _______, KC_1, KC_2, KC_3, KC_EQL, _______,
  60. _______, _______, _______, _______, _______, _______, _______, KC_0, _______, _______, _______, _______
  61. ),
  62. [OVL_F] = LAYOUT_planck_grid(
  63. _______, _______, _______, _______, _______, _______, _______, KC_F7, KC_F8, KC_F9, _______, _______,
  64. _______, _______, _______, _______, _______, _______, _______, KC_F4, KC_F5, KC_F6, _______, _______,
  65. _______, _______, _______, _______, _______, _______, _______, KC_F1, KC_F2, KC_F3, _______, _______,
  66. _______, _______, _______, _______, _______, _______, _______, KC_F10, KC_F11, KC_F12, _______, _______
  67. )
  68. };
  69. static bool is_left_shift_pressed = false;
  70. static bool is_right_shift_pressed = false;
  71. // This will only work on linux with xkbmap option "compose:prsc"
  72. void press_umlaut_of(uint16_t keycode) {
  73. bool is_shift_pressed = (is_left_shift_pressed || is_right_shift_pressed);
  74. register_code(KC_PSCREEN);
  75. unregister_code(KC_PSCREEN);
  76. if (!is_shift_pressed) {
  77. register_code(KC_LSFT);
  78. }
  79. register_code(KC_QUOT);
  80. unregister_code(KC_QUOT);
  81. if (!is_shift_pressed) {
  82. unregister_code(KC_LSFT);
  83. }
  84. register_code(keycode);
  85. unregister_code(keycode);
  86. }
  87. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  88. switch (keycode) {
  89. case KC_LSFT:
  90. is_left_shift_pressed = record->event.pressed;
  91. break;
  92. case KC_RSFT:
  93. is_right_shift_pressed = record->event.pressed;
  94. break;
  95. case UMLT_A:
  96. if (record->event.pressed) {
  97. press_umlaut_of(KC_A);
  98. }
  99. break;
  100. case UMLT_O:
  101. if (record->event.pressed) {
  102. press_umlaut_of(KC_O);
  103. }
  104. break;
  105. case UMLT_U:
  106. if (record->event.pressed) {
  107. press_umlaut_of(KC_U);
  108. }
  109. break;
  110. }
  111. return true;
  112. }