keymap.c 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. /* Copyright 2021 Benjamin Chausse
  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. #include "version.h"
  18. enum layer_names {
  19. BASE, // default layer
  20. FUNC, // functions keys, numbpad, and arrows
  21. };
  22. enum custom_keycodes {
  23. VRSN = SAFE_RANGE,
  24. RGB_SLD
  25. };
  26. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  27. /* Keymap 0: default layer
  28. *
  29. * ,--------------------------------------------------. ,--------------------------------------------------.
  30. * | ` | 1 | 2 | 3 | 4 | 5 | 6 | | 7 | 8 | 9 | 0 | - | = | BkSp |
  31. * |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------|
  32. * | Tab | Q | W | E | R | T | { | | } | Y | U | I | O | P | \ |
  33. * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
  34. * | TUX | A | S | D | F | G |------| |------| H | J | K | L | ; | '/TUX |
  35. * |--------+------+------+------+------+------| ^ | | & |------+------+------+------+------+--------|
  36. * | Shft/( | Z | X | C | V | B | | | | N | M | , | . | / | Shft/) |
  37. * `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------'
  38. * | Ctrl | Alt | Caps | MP1 | FUNC | | MR1 | MS1 | [ | ] | TFUNC |
  39. * `----------------------------------' `----------------------------------'
  40. * ,-------------. ,---------------.
  41. * | | Prnt | | INS | HOME |
  42. * ,------|------|------| |------+--------+------.
  43. * | | | Vol+ | | PgUp | | |
  44. * | Space|Backsp|------| |------| Enter | : |
  45. * | |ace | Vol- | | PgDn | | |
  46. * `--------------------' `----------------------'
  47. *
  48. * MR1: Record macro 1 Prnt: Print Screen
  49. * MS1: Stop recording macro 1 INS: INSERT
  50. * MP1: Play macro 1 TFUNC: Goto FUNC only while pressed
  51. * FUNC: Set FUNC as default layer
  52. *
  53. *
  54. */
  55. /* If it accepts an argument (i.e, is a function), it doesn't need KC_. */
  56. /* Otherwise, it needs KC_* */
  57. [BASE] = LAYOUT_ergodox( /* layer 0: default */
  58. /* Left hand */
  59. KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6,
  60. KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, LSFT(KC_LBRC),
  61. MT(MOD_LGUI, KC_ESC), KC_A, KC_S, KC_D, KC_F, KC_G,
  62. SC_LSPO, KC_Z, KC_X, KC_C, KC_V, KC_B, LSFT(KC_6),
  63. KC_LCTL, KC_LALT, KC_CAPS, DM_PLY1, DF(1),
  64. KC_NO, KC_PSCR,
  65. KC_VOLU,
  66. KC_SPC, KC_BSPC, KC_VOLD,
  67. /* right hand */
  68. KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC,
  69. RSFT(KC_RBRC), KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSLS,
  70. KC_H, KC_J, KC_K, KC_L, KC_SCLN, MT(MOD_RGUI, KC_QUOT),
  71. RSFT(KC_7), KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, SC_RSPC,
  72. DM_REC1, DM_RSTP, KC_LBRC, KC_RBRC, MO(1),
  73. KC_INS, KC_HOME,
  74. KC_PGUP,
  75. KC_PGDN, KC_ENT, RSFT(KC_SCLN)),
  76. /* Keymap 1: function keys, numpad, and arrows
  77. *
  78. * ,--------------------------------------------------. ,--------------------------------------------------.
  79. * | | F1 | F2 | F3 | F4 | F5 | F6 | | F7 | F8 | F9 | F10 | F11 | F12 | |
  80. * |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------|
  81. * | | | | UP | | | | | | / | 7 | 8 | 9 | - | \ |
  82. * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
  83. * | | | LEFT | DOWN |RIGHT | |------| |------| * | 4 | 5 | 6 | + | |
  84. * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
  85. * | | | | | | | | | | % | 1 | 2 | 3 | , | Shft/) |
  86. * `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------'
  87. * | Ctrl | Alt | Caps | | MAIN | | 0 | . | [ | ] | |
  88. * `----------------------------------' `----------------------------------'
  89. * ,-------------. ,---------------.
  90. * | | Prnt | | Ins | Home |
  91. * ,------|------|------| |------+--------+------.
  92. * | | | Vol+ | | PgUp | | |
  93. * | Space|Backsp|------| |------| Enter | Equal|
  94. * | |ace | Vol- | | PgDn | | |
  95. * `--------------------' `----------------------'
  96. */
  97. [FUNC] = LAYOUT_ergodox( /* layer 1: func */
  98. /* left hand */
  99. KC_NO, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6,
  100. KC_NO, KC_NO, KC_NO, KC_UP, KC_NO, KC_NO, KC_NO,
  101. KC_NO, KC_NO, KC_LEFT, KC_DOWN, KC_RGHT, KC_NO,
  102. KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO,
  103. KC_LCTL, KC_LALT, KC_CAPS, KC_NO, DF(0),
  104. KC_NO, KC_PSCR,
  105. KC_VOLU,
  106. KC_SPC, KC_BSPC, KC_VOLD,
  107. /* right hand */
  108. KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_NO,
  109. KC_NO, KC_PSLS, KC_P7, KC_P8, KC_P9, KC_PMNS, KC_BSLS,
  110. KC_PAST, KC_P4, KC_P5, KC_P6, KC_PPLS, KC_NO,
  111. KC_NO, LSFT(KC_5), KC_P1, KC_P2, KC_P3, KC_PCMM, SC_RSPC,
  112. KC_P0, KC_PDOT, KC_LBRC, KC_RBRC, KC_NO,
  113. KC_INS, KC_HOME,
  114. KC_PGUP,
  115. KC_PGDN, KC_ENT, KC_PEQL)
  116. };
  117. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  118. switch (keycode) {
  119. // dynamically generate these.
  120. case VRSN:
  121. if (record->event.pressed) {
  122. SEND_STRING (QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION);
  123. }
  124. return false;
  125. break;
  126. case RGB_SLD:
  127. if (record->event.pressed) {
  128. #ifdef RGBLIGHT_ENABLE
  129. rgblight_mode(1);
  130. #endif
  131. }
  132. return false;
  133. break;
  134. }
  135. return true;
  136. }
  137. // Runs constantly in the background, in a loop.
  138. void matrix_scan_user(void) {
  139. uint8_t layer = get_highest_layer(layer_state);
  140. ergodox_right_led_1_off();
  141. ergodox_right_led_2_off();
  142. ergodox_right_led_3_off();
  143. switch (layer) {
  144. // TODO: Make this relevant to the ErgoDox EZ.
  145. case 1:
  146. ergodox_right_led_1_on();
  147. break;
  148. case 2:
  149. ergodox_right_led_2_on();
  150. break;
  151. default:
  152. // none
  153. break;
  154. }
  155. };