keymap.c 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. /* Copyright 2021 Kyle McCreery
  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. // Defines names for use in layer keycodes and the keymap
  18. enum layer_names {
  19. _BASE,
  20. _FN1,
  21. _FN2,
  22. _FN3
  23. };
  24. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  25. /* Base */
  26. [_BASE] = LAYOUT(
  27. KC_F1, KC_F2, KC_F3, KC_F4,
  28. KC_NLCK, KC_PSLS, KC_PAST, KC_PMNS,
  29. KC_P7, KC_P8, KC_P9, KC_PPLS,
  30. KC_MUTE, KC_P4, KC_P5, KC_P6, _______,
  31. MO(_FN1), KC_P1, KC_P2, KC_P3, KC_PENT,
  32. KC_BSPC, KC_P0, _______, KC_PDOT, _______,
  33. KC_F5, KC_F6, KC_F7
  34. ),
  35. [_FN1] = LAYOUT(
  36. _______, _______, _______, _______,
  37. _______, _______, _______, _______,
  38. RGB_HUD, RGB_SPI, RGB_HUI, _______,
  39. _______, RGB_RMOD, RGB_TOG, RGB_MOD, _______,
  40. _______, RGB_VAD, RGB_SPD, RGB_VAI, _______,
  41. _______, RGB_SAD, _______, RGB_SAI, _______,
  42. _______, _______, _______
  43. ),
  44. [_FN2] = LAYOUT(
  45. _______, _______, _______, _______,
  46. _______, _______, _______, _______,
  47. _______, _______, _______, _______,
  48. _______, _______, _______, _______, _______,
  49. _______, _______, _______, _______, _______,
  50. _______, _______, _______, _______, _______,
  51. _______, _______, _______
  52. ),
  53. [_FN3] = LAYOUT(
  54. _______, _______, _______, _______,
  55. _______, _______, _______, _______,
  56. _______, _______, _______, _______,
  57. _______, _______, _______, _______, _______,
  58. _______, _______, _______, _______, _______,
  59. _______, _______, _______, _______, _______,
  60. _______, _______, _______
  61. )
  62. };
  63. #ifdef ENCODER_ENABLE
  64. bool encoder_update_user(uint8_t index, bool clockwise) {
  65. switch (index) {
  66. case 0:
  67. if (clockwise) {
  68. tap_code(KC_VOLU);
  69. } else {
  70. tap_code(KC_VOLD);
  71. }
  72. break;
  73. case 1:
  74. if (clockwise) {
  75. tap_code(KC_BRIU);
  76. } else {
  77. tap_code(KC_BRID);
  78. }
  79. break;
  80. }
  81. return true;
  82. }
  83. #endif
  84. #ifdef OLED_ENABLE
  85. oled_rotation_t oled_init_user(oled_rotation_t rotation) {
  86. return OLED_ROTATION_270; // flips the display 270 degrees
  87. }
  88. static void render_logo(void) { // Render MechWild "MW" Logo
  89. static const char PROGMEM logo_1[] = {0x8A, 0x8B, 0x8C, 0x8D, 0x00};
  90. static const char PROGMEM logo_2[] = {0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0x00};
  91. static const char PROGMEM logo_3[] = {0xCA, 0xCB, 0xCC, 0xCD, 0x00};
  92. static const char PROGMEM logo_4[] = {0x20, 0x8E, 0x8F, 0x90, 0x00};
  93. oled_set_cursor(0,0);
  94. oled_write_P(logo_1, false);
  95. oled_set_cursor(0,1);
  96. oled_write_P(logo_2, false);
  97. oled_set_cursor(0,2);
  98. oled_write_P(logo_3, false);
  99. oled_set_cursor(0,3);
  100. oled_write_P(logo_4, false);
  101. }
  102. void oled_task_user(void) {
  103. render_logo();
  104. oled_set_cursor(0,6);
  105. oled_write_ln_P(PSTR("Layer"), false);
  106. switch (get_highest_layer(layer_state)) {
  107. case _BASE:
  108. oled_write_ln_P(PSTR("Base"), false);
  109. break;
  110. case _FN1:
  111. oled_write_ln_P(PSTR("FN 1"), false);
  112. break;
  113. case _FN2:
  114. oled_write_ln_P(PSTR("FN 2"), false);
  115. break;
  116. case _FN3:
  117. oled_write_ln_P(PSTR("FN 3"), false);
  118. break;
  119. default:
  120. oled_write_ln_P(PSTR("Undef"), false);
  121. }
  122. oled_write_ln_P(PSTR(""), false);
  123. // Host Keyboard LED Status
  124. led_t led_state = host_keyboard_led_state();
  125. oled_write_ln_P(led_state.num_lock ? PSTR("NUM ") : PSTR(" "), false);
  126. oled_write_ln_P(led_state.caps_lock ? PSTR("CAP ") : PSTR(" "), false);
  127. oled_write_ln_P(led_state.scroll_lock ? PSTR("SCR ") : PSTR(" "), false);
  128. }
  129. #endif