keymap.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. #include QMK_KEYBOARD_H
  2. extern keymap_config_t keymap_config;
  3. // Layers
  4. #define BASE 0 // Base layer
  5. #define SYMB 1 // Symbols
  6. #define SYSH 2 // Symbols, shifted
  7. #define NUMP 4 // Numpad
  8. #define FCTN 8 // Functions
  9. // Tap Dancing
  10. void dance_lock (qk_tap_dance_state_t *state, void *user_data) {
  11. switch (state->count){
  12. case 1: // Press once for LGUI
  13. tap_code(KC_LGUI);
  14. break;
  15. case 2: // Press twice for NUMLOCK
  16. tap_code(KC_NLCK);
  17. break;
  18. case 3: // Press thrice for CAPSLOCK
  19. tap_code(KC_CAPS);
  20. break;
  21. case 4: // Press four times for SCROLLOCK
  22. tap_code(KC_SLCK);
  23. break;
  24. default:
  25. break;
  26. }
  27. };
  28. void dance_layer (qk_tap_dance_state_t *state, void *user_data) {
  29. switch (state -> count) {
  30. case 1: // Press once for MENU
  31. tap_code(KC_APP);
  32. break;
  33. case 2: // Press twice for NUMPAD
  34. layer_invert(NUMP);
  35. break;
  36. case 3: // Press thrice for SYMBOLS
  37. layer_invert(SYMB);
  38. break;
  39. case 4: // Press four times for SYMBOLS, SHIFTED
  40. layer_invert(SYSH);
  41. break;
  42. default:
  43. break;
  44. }
  45. };
  46. enum tap_dances {LOCKS = 0, LAYERS = 1};
  47. qk_tap_dance_action_t tap_dance_actions[] = {
  48. [LOCKS] = ACTION_TAP_DANCE_FN(dance_lock),
  49. [LAYERS] = ACTION_TAP_DANCE_FN(dance_layer)
  50. };
  51. // Make layering more clear
  52. #define CC_ESC LCTL_T(KC_ESC)
  53. #define CC_QUOT RCTL_T(KC_QUOT)
  54. #define AC_SLSH LALT_T(KC_SLSH)
  55. #define AC_EQL RALT_T(KC_EQL)
  56. #define FC_BSLS LT(FCTN, KC_BSLS)
  57. #define FC_MINS LT(FCTN, KC_MINS)
  58. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  59. [BASE] = LAYOUT(
  60. // ┌──────────┬──────────┬──────────┬──────────┬──────────┬──────────┐ ┌──────────┬──────────┬──────────┬──────────┬──────────┬──────────┐
  61. KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC,
  62. // ├──────────┼──────────┼──────────┼──────────┼──────────┼──────────┤ ├──────────┼──────────┼──────────┼──────────┼──────────┼──────────┤
  63. KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_DEL,
  64. // ├──────────┼──────────┼──────────┼──────────┼──────────┼──────────┤ ├──────────┼──────────┼──────────┼──────────┼──────────┼──────────┤
  65. CC_ESC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, CC_QUOT,
  66. // ├──────────┼──────────┼──────────┼──────────┼──────────┼──────────┼──────────┐ ┌──────────┼──────────┼──────────┼──────────┼──────────┼──────────┼──────────┤
  67. KC_LSPO, KC_Z, KC_X, KC_C, KC_V, KC_B, TD(LOCKS), TD(LAYERS),KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSPC,
  68. // └──────────┴──────────┴──────────┴────┬─────┴────┬─────┴────┬─────┴────┬─────┘ └────┬─────┴────┬─────┴────┬─────┴────┬─────┴──────────┴──────────┴──────────┘
  69. AC_SLSH, FC_BSLS, KC_SPC, KC_ENT, FC_MINS, AC_EQL
  70. // └──────────┴──────────┴──────────┘ └──────────┴──────────┴──────────┘
  71. ),
  72. [SYMB] = LAYOUT(
  73. // ┌──────────┬──────────┬──────────┬──────────┬──────────┬──────────┐ ┌──────────┬──────────┬──────────┬──────────┬──────────┬──────────┐
  74. UC(0x00EF),UC(0x00A1),UC(0x00B2),UC(0x00B3),UC(0x00A4),UC(0x20AC), UC(0x00BC),UC(0x00BD),UC(0x00BE),UC(0x2018),UC(0x2019),_______,
  75. // ├──────────┼──────────┼──────────┼──────────┼──────────┼──────────┤ ├──────────┼──────────┼──────────┼──────────┼──────────┼──────────┤
  76. _______, UC(0x00E4),UC(0x00E5),UC(0x00E9),UC(0x00AE),UC(0x00FE), UC(0x00FC),UC(0x00FA),UC(0x00ED),UC(0x00F3),UC(0x00F6),_______,
  77. // ├──────────┼──────────┼──────────┼──────────┼──────────┼──────────┤ ├──────────┼──────────┼──────────┼──────────┼──────────┼──────────┤
  78. _______, UC(0x00E1),UC(0x00DF),UC(0x00F0),UC(0x00EC),UC(0x00ED), UC(0x00EE),UC(0x00E0),UC(0x00E2),UC(0x00F8),UC(0x00B6),UC(0x00B4),
  79. // ├──────────┼──────────┼──────────┼──────────┼──────────┼──────────┼──────────┐ ┌──────────┼──────────┼──────────┼──────────┼──────────┼──────────┼──────────┤
  80. _______, UC(0x00E6),UC(0x00E8),UC(0x00A9),UC(0x00EA),UC(0x00EB),_______, _______, UC(0x00F1),UC(0x00FD),UC(0x00E7),UC(0x00F4),UC(0x00BF),_______,
  81. // └──────────┴──────────┴──────────┴────┬─────┴────┬─────┴────┬─────┴────┬─────┘ └────┬─────┴────┬─────┴────┬─────┴────┬─────┴──────────┴──────────┴──────────┘
  82. UC(0x00BF),UC(0x00AC),_______, _______, UC(0x00B1),UC(0x00D7)
  83. // └──────────┴──────────┴──────────┘ └──────────┴──────────┴──────────┘
  84. ),
  85. [SYSH] = LAYOUT(
  86. // ┌──────────┬──────────┬──────────┬──────────┬──────────┬──────────┐ ┌──────────┬──────────┬──────────┬──────────┬──────────┬──────────┐
  87. UC(0x00CF),UC(0x00B9),UC(0x2200),UC(0x2201),UC(0x00A3),UC(0x00A5), UC(0x00B5),UC(0x00AB),UC(0x00BB),UC(0x201C),UC(0x201D),_______,
  88. // ├──────────┼──────────┼──────────┼──────────┼──────────┼──────────┤ ├──────────┼──────────┼──────────┼──────────┼──────────┼──────────┤
  89. _______, UC(0x00C4),UC(0x00C5),UC(0x00C9),UC(0x2122),UC(0x00DE), UC(0x00DC),UC(0x00DA),UC(0x00CD),UC(0x00D3),UC(0x00D6),_______,
  90. // ├──────────┼──────────┼──────────┼──────────┼──────────┼──────────┤ ├──────────┼──────────┼──────────┼──────────┼──────────┼──────────┤
  91. _______, UC(0x00C1),UC(0x00A7),UC(0x00D0),UC(0x00CC),UC(0x00CD), UC(0x00CE),UC(0x00C1),UC(0x00C2),UC(0x00D8),UC(0x00B0),UC(0x00A8),
  92. // ├──────────┼──────────┼──────────┼──────────┼──────────┼──────────┼──────────┐ ┌──────────┼──────────┼──────────┼──────────┼──────────┼──────────┼──────────┤
  93. _______, UC(0x00C6),UC(0x00C8),UC(0x00A2),UC(0x00CA),UC(0x00CB),_______, _______, UC(0x00D1),UC(0x00DD),UC(0x00C7),UC(0x00D4),UC(0x203D),_______,
  94. // └──────────┴──────────┴──────────┴────┬─────┴────┬─────┴────┬─────┴────┬─────┘ └────┬─────┴────┬─────┴────┬─────┴────┬─────┴──────────┴──────────┴──────────┘
  95. UC(0x203D),UC(0x00A6),_______, _______, UC(0x00AA),UC(0x00F7)
  96. // └──────────┴──────────┴──────────┘ └──────────┴──────────┴──────────┘
  97. ),
  98. [NUMP] = LAYOUT(
  99. // ┌──────────┬──────────┬──────────┬──────────┬──────────┬──────────┐ ┌──────────┬──────────┬──────────┬──────────┬──────────┬──────────┐
  100. _______, _______, KC_P7, KC_P8, KC_P9, KC_PSLS, _______, KC_P7, KC_P8, KC_P9, KC_PSLS, _______,
  101. // ├──────────┼──────────┼──────────┼──────────┼──────────┼──────────┤ ├──────────┼──────────┼──────────┼──────────┼──────────┼──────────┤
  102. _______, _______, KC_P4, KC_P5, KC_P6, KC_PAST, _______, KC_P4, KC_P5, KC_P6, KC_PAST, _______,
  103. // ├──────────┼──────────┼──────────┼──────────┼──────────┼──────────┤ ├──────────┼──────────┼──────────┼──────────┼──────────┼──────────┤
  104. _______, _______, KC_P1, KC_P2, KC_P3, KC_PMNS, _______, KC_P1, KC_P2, KC_P3, KC_PMNS, _______,
  105. // ├──────────┼──────────┼──────────┼──────────┼──────────┼──────────┼──────────┐ ┌──────────┼──────────┼──────────┼──────────┼──────────┼──────────┼──────────┤
  106. _______, _______, KC_P0, KC_PCMM, KC_PDOT, KC_PPLS, _______, _______, _______, KC_P0, KC_PCMM, KC_PDOT, KC_PPLS, _______,
  107. // └──────────┴──────────┴──────────┴────┬─────┴────┬─────┴────┬─────┴────┬─────┘ └────┬─────┴────┬─────┴────┬─────┴────┬─────┴──────────┴──────────┴──────────┘
  108. _______, _______, _______, KC_PENT, _______, _______
  109. // └──────────┴──────────┴──────────┘ └──────────┴──────────┴──────────┘
  110. ),
  111. [FCTN] = LAYOUT(
  112. // ┌──────────┬──────────┬──────────┬──────────┬──────────┬──────────┐ ┌──────────┬──────────┬──────────┬──────────┬──────────┬──────────┐
  113. KC_ESC, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_SYSREQ,
  114. // ├──────────┼──────────┼──────────┼──────────┼──────────┼──────────┤ ├──────────┼──────────┼──────────┼──────────┼──────────┼──────────┤
  115. KC_PSCR, UC_MOD, KC_HOME, KC_UP, KC_END, KC_PGUP, UC(0x2014),KC_LBRC, KC_RBRC, S(KC_LBRC),S(KC_RBRC),KC_INS,
  116. // ├──────────┼──────────┼──────────┼──────────┼──────────┼──────────┤ ├──────────┼──────────┼──────────┼──────────┼──────────┼──────────┤
  117. KC_PAUS, RGB_TOG, KC_LEFT, KC_DOWN, KC_RGHT, KC_PGDN, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, KC_BRIU, KC_CLR,
  118. // ├──────────┼──────────┼──────────┼──────────┼──────────┼──────────┼──────────┐ ┌──────────┼──────────┼──────────┼──────────┼──────────┼──────────┼──────────┤
  119. _______, KC_MPRV, KC_MRWD, KC_MPLY, KC_MFFD, KC_MNXT, KC_F11, KC_F12, KC_MSTP, KC_MUTE, KC_VOLD, KC_VOLU, KC_BRID, _______,
  120. // └──────────┴──────────┴──────────┴────┬─────┴────┬─────┴────┬─────┴────┬─────┘ └────┬─────┴────┬─────┴────┬─────┴────┬─────┴──────────┴──────────┴──────────┘
  121. _______, _______, _______, _______, _______, _______
  122. // └──────────┴──────────┴──────────┘ └──────────┴──────────┴──────────┘
  123. )
  124. };
  125. // Initialize rgblight
  126. void keyboard_post_init_user(void) {
  127. rgblight_enable_noeeprom();
  128. for (int i = 360; i > 0; i--) {
  129. rgblight_sethsv_noeeprom(i, 255, 255);
  130. }
  131. layer_state_set_user(layer_state);
  132. };
  133. // Turn on RGB underglow according to active layer
  134. uint32_t layer_state_set_user(uint32_t state) {
  135. switch (biton32(state)) {
  136. case FCTN:
  137. rgblight_sethsv_noeeprom(136, 255, 255);
  138. break;
  139. case NUMP:
  140. rgblight_sethsv_noeeprom(228, 255, 255);
  141. break;
  142. case SYMB:
  143. case SYSH:
  144. rgblight_sethsv_noeeprom(320, 255, 255);
  145. break;
  146. default: // for any other layers, or the default layer
  147. rgblight_sethsv_noeeprom(19, 255, 255);
  148. break;
  149. }
  150. return state;
  151. };