keymap.c 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. /* Copyright 2020 nickolaij
  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. // wait DELAY ms before unregistering media keys
  18. #define MEDIA_KEY_DELAY 10
  19. // Defines names for use in layer keycodes and the keymap
  20. enum layer_names {
  21. _BASE,
  22. _UPPER,
  23. _LOWER
  24. };
  25. // Defines the keycodes used by our macros in process_record_user
  26. enum custom_keycodes {
  27. NICKURL = SAFE_RANGE,
  28. ALTTAB
  29. };
  30. enum unicode_names {
  31. LOVEEYES,
  32. THINK,
  33. UPSIDEDOWN,
  34. NOMOUTH,
  35. PARTY,
  36. HEART,
  37. EGGPLANT,
  38. PEACH,
  39. EMOJI100,
  40. EMOJIB
  41. };
  42. const uint32_t PROGMEM unicode_map[] = {
  43. [LOVEEYES] = 0x1f60d,
  44. [THINK] = 0x1f914,
  45. [UPSIDEDOWN] = 0x1f643,
  46. [NOMOUTH] = 0x1f636,
  47. [PARTY] = 0x1f973,
  48. [HEART] = 0x1f495,
  49. [EMOJI100] = 0x1f4af,
  50. [PEACH] = 0x1f351,
  51. [EGGPLANT] = 0x1f346,
  52. [EMOJIB] = 0x1f171
  53. };
  54. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  55. /* Base */
  56. [_BASE] = LAYOUT(
  57. KC_ESCAPE, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC,
  58. KC_TAB, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_BSLS,
  59. KC_LSHIFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMMA, KC_DOT, KC_UP, KC_DELETE,
  60. KC_LCTRL, KC_LGUI, MO(_UPPER), KC_SPACE, KC_ENTER, MO(_LOWER), KC_LEFT, KC_DOWN, KC_RIGHT
  61. ),
  62. [_UPPER] = LAYOUT(
  63. KC_GRAVE, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, _______,
  64. ALTTAB, _______, _______, _______, _______, _______, _______, _______, KC_LBRC, KC_RBRC, KC_QUOTE, KC_SLASH,
  65. _______, _______, _______, _______, _______, _______, _______, _______, KC_MINUS, KC_EQUAL, _______, _______,
  66. KC_LALT, _______, _______, _______, _______, _______, KC_HOME, _______, KC_END
  67. ),
  68. [_LOWER] = LAYOUT(
  69. NICKURL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, _______,
  70. _______, KC_F11, KC_F12, RGB_MODE_PLAIN, RGB_MODE_BREATHE, RGB_MODE_RAINBOW, RGB_MODE_SWIRL, RGB_MODE_SNAKE, RGB_MODE_KNIGHT, RGB_MODE_GRADIENT, XXXXXXX, RGB_TOG,
  71. _______, X(LOVEEYES), X(THINK), X(UPSIDEDOWN), X(NOMOUTH), X(PARTY), X(PEACH), X(HEART), X(EGGPLANT), X(EMOJI100), X(EMOJIB), RGB_HUI,
  72. KC_CAPS, _______, _______, _______, _______, _______, _______, _______, _______
  73. )
  74. };
  75. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  76. switch (keycode) {
  77. case NICKURL:
  78. if (record->event.pressed) {
  79. SEND_STRING("https://www.github.com/nickolaij");
  80. } else {
  81. tap_code(KC_ENTER);
  82. }
  83. return true;
  84. break;
  85. case ALTTAB:
  86. if (record->event.pressed) {
  87. tap_code16(A(KC_TAB));
  88. }
  89. return true;
  90. break;
  91. default:
  92. return true;
  93. }
  94. }
  95. bool dip_switch_update_user(uint8_t index, bool active) {
  96. switch (index) {
  97. case 0:
  98. if(active) {
  99. switch(get_highest_layer(layer_state)) {
  100. case _BASE:
  101. tap_code16(LCTL(KC_F));
  102. break;
  103. case _UPPER:
  104. tap_code(KC_MUTE);
  105. break;
  106. case _LOWER:
  107. tap_code(KC_MEDIA_PLAY_PAUSE);
  108. break;
  109. }
  110. }
  111. }
  112. return true;
  113. }
  114. void matrix_init_user(void) {
  115. set_unicode_input_mode(UC_WINC);
  116. }
  117. bool encoder_update_user(uint8_t index, bool clockwise) {
  118. switch(get_highest_layer(layer_state)) {
  119. case _BASE:
  120. clockwise ? tap_code(KC_PGDN) : tap_code(KC_PGUP);
  121. break;
  122. case _UPPER:
  123. clockwise ? tap_code(KC_VOLU) : tap_code(KC_VOLD);
  124. break;
  125. case _LOWER:
  126. clockwise ? tap_code(KC_MEDIA_NEXT_TRACK) : tap_code(KC_MEDIA_PREV_TRACK);
  127. break;
  128. }
  129. return true;
  130. }