logo

qmk_firmware

custom branch of QMK firmware git clone https://anongit.hacktivis.me/git/qmk_firmware.git

keymap.c (4301B)


  1. /* Copyright 2021 3araht
  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. // Defines names for use in layer keycodes and the keymap
  19. enum layer_names {
  20. _BASE,
  21. _RESERVE,
  22. _FN
  23. };
  24. // Defines the keycodes used by our macros in process_record_user
  25. enum custom_keycodes {
  26. L_BASE = SAFE_RANGE,
  27. L_RESERVE,
  28. VERSION
  29. };
  30. // Long press: go to _FN layer, tap: MUTE
  31. #define FN_MUTE LT(_FN, KC_MUTE)
  32. // Used to set octave to 0
  33. extern midi_config_t midi_config;
  34. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  35. /* Base */
  36. [_BASE] = LAYOUT(
  37. FN_MUTE, MI_SUST,
  38. MI_BNDU,
  39. MI_TRSD, MI_TRSU, MI_C2, MI_D2, MI_E2, MI_Fs2, MI_Ab2, MI_Bb2, MI_C3, MI_D3, MI_E3, MI_Fs3, MI_Ab3, MI_Bb3, MI_C4, MI_D4, MI_E4, MI_Fs4, MI_Ab4, MI_Bb4, MI_C5,
  40. MI_BNDD, MI_Db2, MI_Eb2, MI_F2, MI_G2, MI_A2, MI_B2, MI_Db3, MI_Eb3, MI_F3, MI_G3, MI_A3, MI_B3, MI_Db4, MI_Eb4, MI_F4, MI_G4, MI_A4, MI_B4
  41. ),
  42. /* RESERVE */
  43. [_RESERVE] = LAYOUT(
  44. _______, _______,
  45. _______,
  46. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
  47. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______
  48. ),
  49. [_FN] = LAYOUT(
  50. _______, XXXXXXX,
  51. MI_VELU,
  52. MI_OCTD, MI_OCTU, L_BASE, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, VERSION, XXXXXXX, XXXXXXX,
  53. MI_VELD, L_RESERVE, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, EE_CLR, XXXXXXX, XXXXXXX
  54. )
  55. };
  56. #if defined(ENCODER_MAP_ENABLE)
  57. const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][NUM_DIRECTIONS] = {
  58. [_BASE] = { ENCODER_CCW_CW(KC_VOLD, KC_VOLU) },
  59. [_RESERVE] = { ENCODER_CCW_CW(_______, _______) },
  60. [_FN] = { ENCODER_CCW_CW(_______, _______) },
  61. };
  62. #endif
  63. // commom codes called from eeconfig_init_user() and keyboard_post_init_user().
  64. void my_init(void){
  65. // Set octave to 0
  66. midi_config.octave = QK_MIDI_OCTAVE_0 - MIDI_OCTAVE_MIN;
  67. // avoid using 127 since it is used as a special number in some sound sources.
  68. midi_config.velocity = MIDI_INITIAL_VELOCITY;
  69. default_layer_set(1UL << _BASE);
  70. }
  71. void eeconfig_init_user(void) { // EEPROM is getting reset!
  72. midi_init();
  73. my_init(); // commom codes called from eeconfig_init_user() and keyboard_post_init_user().
  74. }
  75. void keyboard_post_init_user(void) {
  76. my_init(); // commom codes called from eeconfig_init_user() and keyboard_post_init_user().
  77. };
  78. void reset_scale_indicator(void) {
  79. // reset transpose value and scale_indicator_col to default.
  80. midi_config.transpose = 0;
  81. }
  82. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  83. switch (keycode) {
  84. case VERSION: // Output firmware info.
  85. if (record->event.pressed) {
  86. SEND_STRING(QMK_KEYBOARD ":" QMK_KEYMAP " @ " QMK_VERSION " | " QMK_BUILDDATE);
  87. }
  88. break;
  89. case L_BASE:
  90. reset_scale_indicator();
  91. default_layer_set(1UL << _BASE);
  92. break;
  93. case L_RESERVE:
  94. reset_scale_indicator();
  95. default_layer_set(1UL << _RESERVE);
  96. break;
  97. }
  98. return true;
  99. }