logo

qmk_firmware

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

keymap.c (5695B)


  1. /* Copyright 2020 tominabox1
  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. enum layers {
  18. _BASE,
  19. _NUM_SYM,
  20. _NAV
  21. };
  22. #define KC_NUM_SPC LT(_NUM_SYM, KC_SPC)
  23. #define KC_GA LGUI_T(KC_A)
  24. #define KC_AS LALT_T(KC_S)
  25. #define KC_CD LCTL_T(KC_D)
  26. #define KC_SF LSFT_T(KC_F)
  27. #define KC_SJ RSFT_T(KC_J)
  28. #define KC_CK RCTL_T(KC_K)
  29. #define KC_AL RALT_T(KC_L)
  30. #define KC_GSCLN RGUI_T(KC_SCLN)
  31. // clang-format off
  32. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  33. [_BASE] = LAYOUT(
  34. KC_Q, KC_W, KC_E, KC_R, KC_T, KC_MPLY, KC_Y, KC_U, KC_I, KC_O, KC_P,
  35. KC_GA, KC_AS, KC_CD, KC_SF, KC_G, KC_H, KC_SJ, KC_CK, KC_AL, KC_GSCLN,
  36. KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH,
  37. KC_LCTL, KC_ENT, KC_NUM_SPC, MO(_NAV)
  38. ),
  39. [_NUM_SYM] = LAYOUT(
  40. KC_1, KC_2, KC_3, KC_4, KC_5, KC_TRNS, KC_6, KC_7, KC_8, KC_9, KC_0,
  41. KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_EQUAL, KC_MINS,
  42. KC_BSLS,KC_LCBR, KC_LBRC, KC_LPRN, KC_UNDS, KC_RPRN, KC_RBRC, KC_RCBR, KC_DOT, KC_GRV,
  43. KC_CAPS, KC_TRNS, KC_TRNS, KC_TRNS
  44. ),
  45. [_NAV] = LAYOUT(
  46. QK_BOOT, _______, AG_NORM, AG_SWAP, DB_TOGG, KC_TRNS, KC_GRV, KC_PGDN, KC_UP, KC_PGUP, KC_SCLN,
  47. RM_TOGG, RM_HUEU, RM_SATU, RM_VALU, KC_NO, KC_HOME, KC_LEFT, KC_DOWN, KC_RGHT, KC_END,
  48. RM_NEXT, RM_HUED, RM_SATD, RM_VALD, KC_NO, KC_MINS, KC_INT1, KC_COMM, KC_DOT, KC_BSLS,
  49. KC_TRNS,KC_TRNS, KC_TRNS, KC_TRNS
  50. )
  51. };
  52. // clang-format on
  53. #if defined(ENCODER_MAP_ENABLE)
  54. const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][NUM_DIRECTIONS] = {
  55. [_BASE] = {ENCODER_CCW_CW(KC_MNXT, KC_MPRV) },
  56. [_NUM_SYM] = { ENCODER_CCW_CW(KC_WH_D, KC_WH_U) },
  57. [_NAV] = { ENCODER_CCW_CW(KC_PGDN, KC_PGUP) }
  58. };
  59. #endif
  60. #ifdef COMBO_ENABLE
  61. enum combo_events {
  62. COMBO_BSPC,
  63. COMBO_NUMBAK,
  64. COMBO_TAB,
  65. COMBO_ESC,
  66. COMBO_DEL,
  67. };
  68. const uint16_t PROGMEM combo_bspc[] = {KC_O, KC_P, COMBO_END};
  69. const uint16_t PROGMEM combo_numbak[] = {KC_0, KC_9, COMBO_END};
  70. const uint16_t PROGMEM combo_tab[] = {KC_Q, KC_W, COMBO_END};
  71. const uint16_t PROGMEM combo_esc[] = {KC_E, KC_W, COMBO_END};
  72. const uint16_t PROGMEM combo_del[] = {KC_MINS, KC_EQL, COMBO_END};
  73. combo_t key_combos[] = {
  74. [COMBO_BSPC] = COMBO(combo_bspc, KC_BSPC),
  75. [COMBO_NUMBAK] = COMBO(combo_numbak, KC_BSPC),
  76. [COMBO_TAB] = COMBO(combo_tab, KC_TAB),
  77. [COMBO_ESC] = COMBO(combo_esc, KC_ESC),
  78. [COMBO_DEL] = COMBO(combo_del, KC_DEL)
  79. };
  80. #endif
  81. #ifdef OLED_ENABLE
  82. // Add additional layer names here if desired. Only first 5 characters will be copied to display.
  83. const char PROGMEM layer_base[] = "BASE";
  84. const char PROGMEM layer_num_sym[] = " SYM";
  85. const char PROGMEM layer_nav[] = " NAV";
  86. // Add layer name variables to array here. Make sure these are in order.
  87. const char* const PROGMEM layer_names[] = {
  88. layer_base,
  89. layer_num_sym,
  90. layer_nav
  91. };
  92. static char oled_layer_buf[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
  93. static layer_state_t top_layer_cache;
  94. /* BEGIN STANDARD QMK FUNCTIONS */
  95. bool oled_task_user(void) {
  96. oled_write_raw_P(lechiffre_logo, sizeof(lechiffre_logo));
  97. // Renders the current keyboard state (layer, lock, caps, scroll, etc);
  98. oled_set_cursor(0, 3);
  99. oled_write_P(oled_section_break, false);
  100. render_layer_status(oled_layer_buf);
  101. oled_write_P(oled_section_break, false);
  102. render_mod_status(get_mods() | get_oneshot_mods());
  103. oled_write_P(oled_section_break, false);
  104. render_keylock_status(host_keyboard_led_state());
  105. oled_write_P(oled_section_break, false);
  106. render_keylogger_status();
  107. return false;
  108. }
  109. bool process_record_user(uint16_t keycode, keyrecord_t* record) {
  110. if (record->event.pressed) {
  111. add_keylog(keycode, record);
  112. }
  113. return true;
  114. }
  115. // If we don't force an update during initialization, the layer name buffer will start out blank.
  116. layer_state_t default_layer_state_set_user(layer_state_t state) {
  117. update_layer_namebuf(get_highest_layer(state), true);
  118. return state;
  119. }
  120. layer_state_t layer_state_set_user(layer_state_t state) {
  121. update_layer_namebuf(get_highest_layer(state | default_layer_state), false);
  122. return state;
  123. }
  124. /* END STANDARD QMK FUNCTIONS */
  125. /* BEGIN CUSTOM HELPER FUNCTION FOR OLED */
  126. // Avoid excessive copying by only updating the layer name buffer when the layer changes
  127. void update_layer_namebuf(layer_state_t layer, bool force_update) {
  128. if (force_update || layer != top_layer_cache) {
  129. top_layer_cache = layer;
  130. if (layer < ARRAY_SIZE(layer_names)) {
  131. memcpy_P(oled_layer_buf, pgm_read_ptr(&layer_names[layer]), ARRAY_SIZE(oled_layer_buf) - 1);
  132. } else {
  133. memcpy(oled_layer_buf, get_u8_str(layer, ' '), ARRAY_SIZE(oled_layer_buf) - 1);
  134. }
  135. }
  136. }
  137. #endif