keymap.c 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. #include QMK_KEYBOARD_H
  2. #include "hvp.c"
  3. #ifdef SSD1306OLED
  4. # include "ssd1306.h"
  5. # include <string.h>
  6. #endif
  7. #ifdef RGBLIGHT_ENABLE
  8. //Following line allows macro to read current RGB settings
  9. extern rgblight_config_t rgblight_config;
  10. #endif
  11. // Each layer gets a name for readability, which is then used in the keymap matrix below.
  12. // The underscores don't mean anything - you can have a layer called STUFF or any other name.
  13. // Layer names don't all need to be of the same length, obviously, and you can also skip them
  14. // entirely and just use numbers.
  15. #define _QWERTY 0
  16. #define _LOWER 1
  17. #define _RAISE 2
  18. #define _ADJUST 3
  19. enum custom_keycodes {
  20. QWERTY = SAFE_RANGE,
  21. LOWER,
  22. RAISE,
  23. ADJUST
  24. };
  25. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  26. [_QWERTY] = LAYOUT_split_3x6_3(
  27. //,-----------------------------------------. ,-----------------------------------------.
  28. LT(_ADJUST,KC_TAB), KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P,KC_BSPC,
  29. //|------+------+------+------+------+------| |------+------+------+------+------+------|
  30. LSFT_T(KC_ESC), KC_A, KC_S, KC_D, LT(3,KC_F), KC_G, KC_H, KC_J, KC_K, KC_L,TD(TD1),TD(TD2),
  31. //|------+------+------+------+------+------| |------+------+------+------+------+------|
  32. KC_LCTL, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M,KC_COMM,KC_DOT,TD(TD3),SC_SENT,
  33. //|------+------+------+------+------+------+------| |------+------+------+------+------+------+------|
  34. KC_LGUI, LT(1,KC_SPC),MT(MOD_LSFT, KC_SPC), MT(MOD_LSFT,KC_ENT), LT(2,KC_SPC),KC_LALT
  35. //`--------------------' `--------------------'
  36. ),
  37. [_RAISE] = LAYOUT_split_3x6_3(
  38. //,-----------------------------------------. ,-----------------------------------------.
  39. KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0,KC_BSPC,
  40. //|------+------+------+------+------+------| |------+------+------+------+------+------|
  41. KC_DEL, _______, _______, _______, _______, _______, _______,KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSLS,
  42. //|------+------+------+------+------+------| |------+------+------+------+------+------|
  43. KC_LCTL, _______, _______, _______, _______, _______, _______, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE,
  44. //|------+------+------+------+------+------+------| |------+------+------+------+------+------+------|
  45. _______, _______, _______, _______, _______, _______
  46. //`--------------------' `--------------------'
  47. ),
  48. [_LOWER] = LAYOUT_split_3x6_3(
  49. //,-----------------------------------------. ,-----------------------------------------.
  50. KC_TAB,KC_EXLM,KC_AT,KC_HASH,KC_DLR,KC_PERC, KC_CIRC,KC_AMPR,KC_ASTR,KC_LPRN,KC_RPRN,KC_BSPC,
  51. //|------+------+------+------+------+------| |------+------+------+------+------+------|
  52. KC_DEL, _______, _______, _______, _______, _______, _______,KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_BSLS,
  53. //|------+------+------+------+------+------| |------+------+------+------+------+------|
  54. KC_LCTL, _______, _______, _______, _______, _______, _______, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_TILD,
  55. //|------+------+------+------+------+------+------| |------+------+------+------+------+------+------|
  56. _______, _______, _______, _______, _______, _______
  57. //`--------------------' `--------------------'
  58. ),
  59. [_ADJUST] = LAYOUT_split_3x6_3(
  60. //,-----------------------------------------. ,-----------------------------------------.
  61. _______,KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12,
  62. //|------+------+------+------+------+------| |------+------+------+------+------+------|
  63. KC_F1,_______,_______,D_NAVI,_______,_______, KC_LEFT, KC_DOWN, KC_UP, KC_RIGHT, _______, _______,
  64. //|------+------+------+------+------+------| |------+------+------+------+------+------|
  65. QK_BOOT,KC_PSCR,_______,_______,_______,_______, KC_HOME, KC_PGDN, KC_PGUP, KC_END, _______, _______,
  66. //|------+------+------+------+------+------+------| |------+------+------+------+------+------+------|
  67. _______, KC_VOLD,KC_MPLY, KC_MNXT, KC_VOLU,_______
  68. //`--------------------' `--------------------'
  69. )
  70. };
  71. int RGB_current_mode;
  72. // Setting ADJUST layer RGB back to default
  73. void update_tri_layer_RGB(uint8_t layer1, uint8_t layer2, uint8_t layer3) {
  74. if (IS_LAYER_ON(layer1) && IS_LAYER_ON(layer2)) {
  75. layer_on(layer3);
  76. } else {
  77. layer_off(layer3);
  78. }
  79. }
  80. void matrix_init_user(void) {
  81. #ifdef RGBLIGHT_ENABLE
  82. RGB_current_mode = rgblight_config.mode;
  83. #endif
  84. }
  85. #ifdef OLED_ENABLE
  86. // When add source files to SRC in rules.mk, you can use functions.
  87. const char *read_layer_state(void);
  88. const char *read_logo(void);
  89. void set_keylog(uint16_t keycode, keyrecord_t *record);
  90. const char *read_keylog(void);
  91. const char *read_keylogs(void);
  92. // const char *read_mode_icon(bool swap);
  93. // const char *read_host_led_state(void);
  94. // void set_timelog(void);
  95. // const char *read_timelog(void);
  96. bool oled_task_user(void) {
  97. if (is_keyboard_master()) {
  98. // If you want to change the display of OLED, you need to change here
  99. oled_write(read_layer_state(), false);
  100. oled_write(read_keylog(), false);
  101. //oled_write_ln(read_keylogs(), false);
  102. //oled_write_ln(read_mode_icon(keymap_config.swap_lalt_lgui), false);
  103. //oled_write_ln(read_host_led_state()), false;
  104. //oled_write_ln(read_timelog(), false);
  105. } else {
  106. oled_write(read_logo(), false);
  107. }
  108. return false;
  109. }
  110. #endif
  111. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  112. if (record->event.pressed) {
  113. #ifdef OLED_ENABLE
  114. set_keylog(keycode, record);
  115. #endif
  116. // set_timelog();
  117. }
  118. switch (keycode) {
  119. case LOWER:
  120. if (record->event.pressed) {
  121. layer_on(_LOWER);
  122. update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST);
  123. } else {
  124. layer_off(_LOWER);
  125. update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST);
  126. }
  127. return false;
  128. case RAISE:
  129. if (record->event.pressed) {
  130. layer_on(_RAISE);
  131. update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST);
  132. } else {
  133. layer_off(_RAISE);
  134. update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST);
  135. }
  136. return false;
  137. case ADJUST:
  138. if (record->event.pressed) {
  139. layer_on(_ADJUST);
  140. } else {
  141. layer_off(_ADJUST);
  142. }
  143. return false;
  144. break;
  145. }
  146. return true;
  147. }