keymap.c 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. #include QMK_KEYBOARD_H
  2. #include "debug.h"
  3. #include "action_layer.h"
  4. #include "version.h"
  5. #define BASE 0 // default layer
  6. #define SYMB 1 // symbols
  7. #define MDIA 2 // media keys
  8. enum custom_keycodes {
  9. PLACEHOLDER = SAFE_RANGE, // can always be here
  10. EPRM,
  11. VRSN,
  12. RGB_SLD
  13. };
  14. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  15. /* Keymap 0: Basic layer
  16. *
  17. * ,--------------------------------------------------. ,--------------------------------------------------.
  18. * | = | 1 | 2 | 3 | 4 | 5 | LEFT | | RIGHT| 6 | 7 | 8 | 9 | 0 | - |
  19. * |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------|
  20. * | Del | Q | W | E | R | T | L1 | | L1 | Y | U | I | O | P | \ |
  21. * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
  22. * | BkSp | A | S | D | F | G |------| |------| H | J | K | L |; / L2|' / Cmd |
  23. * |--------+------+------+------+------+------| Hyper| | Meh |------+------+------+------+------+--------|
  24. * | LShift |Z/Ctrl| X | C | V | B | | | | N | M | , | . |//Ctrl| RShift |
  25. * `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------'
  26. * |Grv/L1| '" |AltShf| Left | Right| | Up | Down | [ | ] | ~L1 |
  27. * `----------------------------------' `----------------------------------'
  28. * ,-------------. ,-------------.
  29. * | App | LGui | | Alt |Ctrl/Esc|
  30. * ,------|------|------| |------+--------+------.
  31. * | | | Home | | PgUp | | |
  32. * | Space|Backsp|------| |------| Tab |Enter |
  33. * | |ace | End | | PgDn | | |
  34. * `--------------------' `----------------------'
  35. */
  36. // If it accepts an argument (i.e, is a function), it doesn't need KC_.
  37. // Otherwise, it needs KC_*
  38. [BASE] = LAYOUT_ergodox( // layer 0 : default
  39. // left hand
  40. EPRM, EPRM, EPRM, EPRM, EPRM, EPRM, EPRM,
  41. EPRM, EPRM, EPRM, EPRM, EPRM, EPRM, EPRM,
  42. EPRM, EPRM, EPRM, EPRM, EPRM, EPRM,
  43. EPRM, EPRM, EPRM, EPRM, EPRM, EPRM, EPRM,
  44. EPRM, EPRM, EPRM, EPRM,EPRM,
  45. EPRM, EPRM,
  46. EPRM,
  47. EPRM,EPRM,EPRM,
  48. // right hand
  49. EPRM, EPRM, EPRM, EPRM, EPRM, EPRM, EPRM,
  50. EPRM, EPRM, EPRM, EPRM, EPRM, EPRM, EPRM,
  51. EPRM, EPRM, EPRM, EPRM, EPRM,EPRM,
  52. EPRM,EPRM, EPRM, EPRM,EPRM, EPRM, EPRM,
  53. EPRM, EPRM,EPRM,EPRM, EPRM,
  54. EPRM, EPRM,
  55. EPRM,
  56. EPRM,EPRM, EPRM
  57. )
  58. };
  59. const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
  60. {
  61. // MACRODOWN only works in this function
  62. switch(id) {
  63. case 0:
  64. if (record->event.pressed) {
  65. SEND_STRING (QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION);
  66. }
  67. break;
  68. case 1:
  69. if (record->event.pressed) { // For resetting EEPROM
  70. eeconfig_init();
  71. }
  72. break;
  73. }
  74. return MACRO_NONE;
  75. };
  76. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  77. switch (keycode) {
  78. // dynamically generate these.
  79. case EPRM:
  80. if (record->event.pressed) {
  81. eeconfig_init();
  82. }
  83. return false;
  84. break;
  85. case VRSN:
  86. if (record->event.pressed) {
  87. SEND_STRING (QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION);
  88. }
  89. return false;
  90. break;
  91. case RGB_SLD:
  92. if (record->event.pressed) {
  93. #ifdef RGBLIGHT_ENABLE
  94. rgblight_mode(1);
  95. #endif
  96. }
  97. return false;
  98. break;
  99. }
  100. return true;
  101. }
  102. // Runs just one time when the keyboard initializes.
  103. void matrix_init_user(void) {
  104. eeconfig_init();
  105. };
  106. // Runs constantly in the background, in a loop.
  107. void matrix_scan_user(void) {
  108. uint8_t layer = biton32(layer_state);
  109. ergodox_board_led_off();
  110. ergodox_right_led_1_off();
  111. ergodox_right_led_2_off();
  112. ergodox_right_led_3_off();
  113. switch (layer) {
  114. // TODO: Make this relevant to the ErgoDox EZ.
  115. case 1:
  116. ergodox_right_led_1_on();
  117. break;
  118. case 2:
  119. ergodox_right_led_2_on();
  120. break;
  121. default:
  122. // none
  123. break;
  124. }
  125. };