keymap.c 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /*
  2. Copyright 2022 Jose Pablo Ramirez <jp.ramangulo@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. #include QMK_KEYBOARD_H
  15. #include "jpe230.h"
  16. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  17. [0] = LAYOUT_preonic_grid(
  18. //,-----------------------------------------------------------------------------------------------------------.
  19. KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_DEL,
  20. //|--------+--------+--------+--------+--------+--------|--------+--------+--------+--------+--------+--------|
  21. KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC,
  22. //|--------+--------+--------+--------+--------+--------|--------+--------+--------+--------+--------+--------|
  23. KC_LCTL, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT,
  24. //|--------+--------+--------+--------+--------+--------|--------+--------+--------+--------+--------+--------|
  25. KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ESC,
  26. //|--------+--------+--------+--------+--------+--------|--------+--------+--------+--------+--------+--------|
  27. KC_LBRC, KC_RBRC, KC_LGUI, MO(1), _______, KC_SPC, _______, KC_ENT, MO(2), KC_RALT, KC_MINS, KC_EQL
  28. //`-----------------------------------------------------------------------------------------------------------'
  29. ),
  30. [1] = LAYOUT_preonic_grid(
  31. //,-----------------------------------------------------------------------------------------------------------.
  32. KC_GRV, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_BSPC,
  33. //|--------+--------+--------+--------+--------+--------|--------+--------+--------+--------+--------+--------|
  34. KC_ESC, _______, _______, _______, _______, _______, _______, _______, _______, _______, CK_UP, AU_TOG,
  35. //|--------+--------+--------+--------+--------+--------|--------+--------+--------+--------+--------+--------|
  36. KC_CAPS, _______, _______, _______, _______, _______, _______, KC_UP, _______, _______, CK_DOWN, _______,
  37. //|--------+--------+--------+--------+--------+--------|--------+--------+--------+--------+--------+--------|
  38. KC_LSFT, _______, _______, _______, _______, _______, KC_LEFT, KC_DOWN,KC_RIGHT, _______, CK_RST, _______,
  39. //|--------+--------+--------+--------+--------+--------|--------+--------+--------+--------+--------+--------|
  40. _______, _______, _______, _______, _______, _______, _______, _______, MO(3), _______, _______, _______
  41. //`-----------------------------------------------------------------------------------------------------------'
  42. ),
  43. [2] = LAYOUT_preonic_grid(
  44. //,-----------------------------------------------------------------------------------------------------------.
  45. KC_GRV, KC_F11, KC_F12, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_BSPC,
  46. //|--------+--------+--------+--------+--------+--------|--------+--------+--------+--------+--------+--------|
  47. KC_ESC, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_BSPC,
  48. //|--------+--------+--------+--------+--------+--------|--------+--------+--------+--------+--------+--------|
  49. KC_CAPS, _______, KC_MS_U, _______, _______, _______, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSLS, KC_GRV,
  50. //|--------+--------+--------+--------+--------+--------|--------+--------+--------+--------+--------+--------|
  51. KC_LSFT, KC_MS_L, KC_MS_D, KC_MS_R, _______, _______, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE, KC_TILD,
  52. //|--------+--------+--------+--------+--------+--------|--------+--------+--------+--------+--------+--------|
  53. _______, _______, _______, MO(3), _______, KC_BTN1, _______, _______, _______, _______, _______, _______
  54. //`-----------------------------------------------------------------------------------------------------------'
  55. ),
  56. [3] = LAYOUT_preonic_grid(
  57. //,-----------------------------------------------------------------------------------------------------------.
  58. KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_DEL,
  59. //|--------+--------+--------+--------+--------+--------|--------+--------+--------+--------+--------+--------|
  60. KC_MUTE, KC_WBAK, KC_WFWD, KC_F7, KC_F8, KC_F9, _______, KC_7, KC_8, KC_9, _______, QK_BOOT,
  61. //|--------+--------+--------+--------+--------+--------|--------+--------+--------+--------+--------+--------|
  62. KC_VOLU, _______, KC_MNXT, KC_F6, KC_F5, KC_F6, _______, KC_6, KC_5, KC_4, _______, QK_MAKE,
  63. //|--------+--------+--------+--------+--------+--------|--------+--------+--------+--------+--------+--------|
  64. KC_VOLD, KC_MPRV, KC_MNXT, KC_F1, KC_F2, KC_F3, KC_LSRS, KC_1, KC_2, KC_3, _______, DB_TOGG,
  65. //|--------+--------+--------+--------+--------+--------|--------+--------+--------+--------+--------+--------|
  66. MU_TOG, MU_MOD, _______, _______, _______, KC_LSRE, _______, KC_LERS, _______, _______, _______, EE_CLR
  67. //`-----------------------------------------------------------------------------------------------------------'
  68. )
  69. };
  70. /*
  71. Logic to shift between the bars:
  72. KC_LSRE => Left Bar - Space... Right Bar - Enter
  73. KC_LERS => Left Bar - Enter... Right Bar - Space
  74. KC_LSRS => Left Bar - Space... Right Bar - Space
  75. Hack into dynamic_keymap_set_keycode and change the value of the keymap.
  76. (Just like VIA does, but instead it is done inside the keyboard so no need
  77. to open the app)
  78. Possible alternatives:
  79. - Create 3 layers but only change the KC_ENTER and KC_SPACE position between them
  80. - Create a custom keycode and use process_record_user to alter the behaviour
  81. */
  82. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  83. if (record->event.pressed) {
  84. switch (keycode) {
  85. case KC_LSRS:
  86. dynamic_keymap_set_keycode(LEFT_BAR, KC_SPC);
  87. dynamic_keymap_set_keycode(RIGHT_BAR, KC_SPC);
  88. PLAY_SONG(song_lsrs);
  89. return false;
  90. case KC_LERS:
  91. dynamic_keymap_set_keycode(LEFT_BAR, KC_ENT);
  92. dynamic_keymap_set_keycode(RIGHT_BAR, KC_SPC);
  93. PLAY_SONG(song_lers);
  94. return false;
  95. case KC_LSRE:
  96. dynamic_keymap_set_keycode(LEFT_BAR, KC_SPC);
  97. dynamic_keymap_set_keycode(RIGHT_BAR, KC_ENT);
  98. PLAY_SONG(song_lsre);
  99. return false;
  100. default:
  101. return true; // Process all other keycodes normally
  102. }
  103. }
  104. return true;
  105. }