logo

qmk_firmware

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

keymap.c (15995B)


  1. /* Copyright 2020 marksard
  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. #include "../common/oled_helper.h"
  18. // Each layer gets a name for readability, which is then used in the keymap matrix below.
  19. // The underscores don't mean anything - you can have a layer called STUFF or any other name.
  20. // Layer names don't all need to be of the same length, obviously, and you can also skip them
  21. // entirely and just use numbers.
  22. enum layer_number {
  23. _BASE = 0,
  24. _BASES,
  25. _LOWER,
  26. _LOWRS,
  27. _RAISE,
  28. _ADJUST,
  29. };
  30. enum custom_keycodes {
  31. BASE = SAFE_RANGE,
  32. BASES,
  33. LOWER,
  34. LOWRS,
  35. RAISE,
  36. ADJUST,
  37. KANJI,
  38. RGBRST
  39. };
  40. #define KC_TBSF LSFT_T(KC_TAB)
  41. #define KC_ALAP LALT_T(KC_APP)
  42. #define KC_JEQL LSFT(KC_MINS)
  43. #define KC_SFUC LSFT(KC_INT1)
  44. #define KC_RSBR LSFT(KC_8)
  45. #define KC_REBR LSFT(KC_9)
  46. #define KC_ZSFT LSFT_T(KC_Z)
  47. #define KC_ESCT LCTL_T(KC_ESC)
  48. #define KC_TBAL LALT_T(KC_TAB)
  49. #define KC_11SF LSFT_T(KC_F11)
  50. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  51. [_BASE] = LAYOUT_rs(
  52. // Treadstone48 Rhymestone
  53. //,--------------------------------------------------------------------------------------------------------------------. --------------------------------------------.
  54. KC_ESC, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC, KC_P7, KC_P8, KC_P9, KC_PSLS, KC_NUM,
  55. //|--------+--------+--------+--------+--------+--------|--------+--------+--------+--------+--------+-----------------| --------+--------+--------+--------+--------|
  56. KC_TBSF, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_ENT, KC_P4, KC_P5, KC_P6, KC_PAST, KC_TAB,
  57. //|--------+--------+--------+--------+--------+--------|--------+--------+--------+--------+--------+--------+--------| --------+--------+--------+--------+--------|
  58. KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_UP, KC_P1, KC_P2, KC_P3, KC_PMNS, KC_PENT,
  59. //|--------+--------+--------+--------+--------+--------|--------+--------+--------+--------+--------+--------+--------| --------+--------+--------+--------+--------|
  60. KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_BSPC, KC_SPC, RAISE, KC_ALAP, KC_LEFT, KC_DOWN, KC_RGHT, LOWER, KC_P0, KC_PDOT, KC_PPLS, KC_BSPC,
  61. //`--------------------------------------------------------------------------------------------------------------------' --------------------------------------------'
  62. KC_DEL
  63. // ExtraKey: This key is an extra key. REV1 is a split back space. REV2 is to the right of the arrow-up key.
  64. ),
  65. [_LOWER] = LAYOUT_rs(
  66. // Treadstone48 Rhymestone
  67. //,--------------------------------------------------------------------------------------------------------------------. --------------------------------------------.
  68. _______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_MINS, KC_EQL, KC_INT3, KC_LBRC, KC_RBRC, KC_DEL, KC_A, KC_B, KC_C, KC_INT3, KC_HASH,
  69. //|--------+--------+--------+--------+--------+--------|--------+--------+--------+--------+--------+-----------------| --------+--------+--------+--------+--------|
  70. _______, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, XXXXXXX, XXXXXXX, KC_SCLN, KC_QUOT, KC_BSLS, _______, KC_D, KC_E, KC_F, KC_PERC, KC_SFUC,
  71. //|--------+--------+--------+--------+--------+--------|--------+--------+--------+--------+--------+--------+--------| --------+--------+--------+--------+--------|
  72. _______, KC_F11, KC_F12, BASES, KANJI, KC_ENT, XXXXXXX, KC_COMM, KC_DOT, KC_SLSH, KC_INT1, KC_PGUP, KC_RSBR, KC_REBR, KC_RBRC, KC_QUOT, _______,
  73. //|--------+--------+--------+--------+--------+--------|--------+--------+--------+--------+--------+--------+--------| --------+--------+--------+--------+--------|
  74. _______, _______, _______, _______, KC_DEL, _______, _______, XXXXXXX, KC_HOME, KC_PGDN, KC_END, _______, XXXXXXX, KC_COMM, KC_JEQL, KC_DEL,
  75. //`--------------------------------------------------------------------------------------------------------------------' --------------------------------------------'
  76. _______
  77. // ExtraKey: This key is an extra key. REV1 is a split back space. REV2 is to the right of the arrow-up key.
  78. ),
  79. [_BASES] = LAYOUT_rs(
  80. // Treadstone48 Rhymestone
  81. //,--------------------------------------------------------------------------------------------------------------------. --------------------------------------------.
  82. KC_ESC, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_MINS, KC_Q, KC_W, KC_E, KC_R, KC_T,
  83. //|--------+--------+--------+--------+--------+--------|--------+--------+--------+--------+--------+-----------------| --------+--------+--------+--------+--------|
  84. KC_TBSF, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_ENT, KC_A, KC_S, KC_D, KC_F, KC_G,
  85. //|--------+--------+--------+--------+--------+--------|--------+--------+--------+--------+--------+--------+--------| --------+--------+--------+--------+--------|
  86. KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_UP, KC_ZSFT, KC_X, KC_C, KC_V, KC_B,
  87. //|--------+--------+--------+--------+--------+--------|--------+--------+--------+--------+--------+--------+--------| --------+--------+--------+--------+--------|
  88. KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_BSPC, KC_SPC, RAISE, KC_ALAP, KC_LEFT, KC_DOWN, KC_RGHT, KC_ESCT, KC_TBAL, KC_LGUI, LOWRS, KC_BSPC,
  89. //`--------------------------------------------------------------------------------------------------------------------' --------------------------------------------'
  90. KC_DEL
  91. // ExtraKey: This key is an extra key. REV1 is a split back space. REV2 is to the right of the arrow-up key.
  92. ),
  93. [_LOWRS] = LAYOUT_rs(
  94. // Treadstone48 Rhymestone
  95. //,--------------------------------------------------------------------------------------------------------------------. --------------------------------------------.
  96. _______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_MINS, KC_EQL, KC_INT3, KC_LBRC, KC_RBRC, KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5,
  97. //|--------+--------+--------+--------+--------+--------|--------+--------+--------+--------+--------+-----------------| --------+--------+--------+--------+--------|
  98. _______, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, XXXXXXX, XXXXXXX, KC_SCLN, KC_QUOT, KC_BSLS, _______, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10,
  99. //|--------+--------+--------+--------+--------+--------|--------+--------+--------+--------+--------+--------+--------| --------+--------+--------+--------+--------|
  100. _______, KC_F11, KC_F12, BASE, KANJI, KC_ENT, XXXXXXX, KC_COMM, KC_DOT, KC_SLSH, KC_INT1, KC_PGUP, KC_11SF, KC_F12, BASE, KANJI, KC_ENT,
  101. //|--------+--------+--------+--------+--------+--------|--------+--------+--------+--------+--------+--------+--------| --------+--------+--------+--------+--------|
  102. _______, _______, _______, _______, KC_DEL, _______, _______, XXXXXXX, KC_HOME, KC_PGDN, KC_END, _______, _______, _______, _______, KC_DEL,
  103. //`--------------------------------------------------------------------------------------------------------------------' --------------------------------------------'
  104. _______
  105. // ExtraKey: This key is an extra key. REV1 is a split back space. REV2 is to the right of the arrow-up key.
  106. ),
  107. [_RAISE] = LAYOUT_rs(
  108. // Treadstone48 Rhymestone
  109. //,--------------------------------------------------------------------------------------------------------------------. --------------------------------------------.
  110. _______, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
  111. //|--------+--------+--------+--------+--------+--------|--------+--------+--------+--------+--------+-----------------| --------+--------+--------+--------+--------|
  112. _______, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_4, KC_5, KC_6, KC_QUOT, _______, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
  113. //|--------+--------+--------+--------+--------+--------|--------+--------+--------+--------+--------+--------+--------| --------+--------+--------+--------+--------|
  114. _______, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_1, KC_2, KC_3, KC_INT1, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
  115. //|--------+--------+--------+--------+--------+--------|--------+--------+--------+--------+--------+--------+--------| --------+--------+--------+--------+--------|
  116. _______, _______, _______, _______, _______, _______, _______, KC_0, KC_DOT, KC_COMM, KC_SLSH, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
  117. //`--------------------------------------------------------------------------------------------------------------------' --------------------------------------------'
  118. _______
  119. // ExtraKey: This key is an extra key. REV1 is a split back space. REV2 is to the right of the arrow-up key.
  120. ),
  121. [_ADJUST] = LAYOUT_rs(
  122. // Treadstone48 Rhymestone
  123. //,--------------------------------------------------------------------------------------------------------------------. --------------------------------------------.
  124. XXXXXXX, QK_BOOT, RGBRST, AG_NORM, AG_SWAP, XXXXXXX, XXXXXXX, KC_WH_L, KC_WH_U, KC_HOME, KC_PGUP, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
  125. //|--------+--------+--------+--------+--------+--------|--------+--------+--------+--------+--------+-----------------| --------+--------+--------+--------+--------|
  126. XXXXXXX, UG_TOGG, UG_HUEU, UG_SATU, UG_VALU, XXXXXXX, XXXXXXX, KC_WH_R, KC_WH_D, KC_END, KC_PGDN, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
  127. //|--------+--------+--------+--------+--------+--------|--------+--------+--------+--------+--------+--------+--------| --------+--------+--------+--------+--------|
  128. _______, UG_NEXT, UG_HUED, UG_SATD, UG_VALD, XXXXXXX, XXXXXXX, XXXXXXX, KC_BTN1, KC_BTN2, XXXXXXX, KC_MS_U, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
  129. //|--------+--------+--------+--------+--------+--------|--------+--------+--------+--------+--------+--------+--------| --------+--------+--------+--------+--------|
  130. _______, _______, _______, _______, XXXXXXX, XXXXXXX, _______, XXXXXXX, KC_MS_L, KC_MS_D, KC_MS_R, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
  131. //`--------------------------------------------------------------------------------------------------------------------' --------------------------------------------'
  132. _______
  133. // ExtraKey: This key is an extra key. REV1 is a split back space. REV2 is to the right of the arrow-up key.
  134. )
  135. };
  136. #define L_BASE _BASE
  137. #define L_BASES (1<<_BASES)
  138. #define L_LOWER (1<<_LOWER)
  139. #define L_LOWRS (1<<_LOWRS)
  140. #define L_RAISE (1<<_RAISE)
  141. #define L_ADJUST (1<<_ADJUST)
  142. #define L_ADJUST_TRI (L_ADJUST|L_RAISE|L_LOWER)
  143. #ifdef OLED_ENABLE
  144. #include <stdio.h>
  145. #include <string.h>
  146. typedef struct {
  147. uint8_t state;
  148. char name[8];
  149. }LAYER_DISPLAY_NAME;
  150. #define LAYER_DISPLAY_MAX 7
  151. const LAYER_DISPLAY_NAME layer_display_name[LAYER_DISPLAY_MAX] = {
  152. {L_BASE, "Base"},
  153. {L_BASE + 1, "Base"},
  154. {L_BASES, "BaseSpl"},
  155. {L_LOWER, "Lower"},
  156. {L_LOWRS, "LowrSpl"},
  157. {L_RAISE, "Raise"},
  158. {L_ADJUST_TRI, "Adjust"}
  159. };
  160. static inline const char* get_leyer_status(void) {
  161. for (uint8_t i = 0; i < LAYER_DISPLAY_MAX; ++i) {
  162. if (layer_state == 0 && layer_display_name[i].state == default_layer_state) {
  163. return layer_display_name[i].name;
  164. } else if (layer_state != 0 && layer_display_name[i].state == layer_state) {
  165. return layer_display_name[i].name;
  166. }
  167. }
  168. return "?";
  169. }
  170. static char layer_status_buf[24] = "Layer state ready.\n";
  171. static inline void update_keymap_status(void) {
  172. snprintf(layer_status_buf, sizeof(layer_status_buf) - 1, "OS:%s Layer:%s\n",
  173. keymap_config.swap_lalt_lgui? "win" : "mac", get_leyer_status());
  174. }
  175. static inline void render_keymap_status(void) {
  176. oled_write(layer_status_buf, false);
  177. }
  178. #define UPDATE_KEYMAP_STATUS() update_keymap_status()
  179. static inline void render_status(void) {
  180. UPDATE_LED_STATUS();
  181. RENDER_LED_STATUS();
  182. render_keymap_status();
  183. UPDATE_LOCK_STATUS();
  184. RENDER_LOCK_STATUS();
  185. RENDER_KEY_STATUS();
  186. }
  187. oled_rotation_t oled_init_user(oled_rotation_t rotation) {
  188. // if (is_keyboard_master())
  189. // return OLED_ROTATION_180; // flips the display 180 degrees if offhand
  190. return rotation;
  191. }
  192. bool oled_task_user(void) {
  193. if (is_keyboard_master()) {
  194. render_status();
  195. } else {
  196. render_logo();
  197. }
  198. return false;
  199. }
  200. #else
  201. #define UPDATE_KEYMAP_STATUS()
  202. #endif
  203. void update_change_layer(bool pressed, uint8_t layer1, uint8_t layer2, uint8_t layer3) {
  204. pressed ? layer_on(layer1) : layer_off(layer1);
  205. IS_LAYER_ON(layer1) && IS_LAYER_ON(layer2) ? layer_on(layer3) : layer_off(layer3);
  206. }
  207. int RGB_current_mode;
  208. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  209. UPDATE_KEY_STATUS(keycode, record);
  210. bool result = false;
  211. switch (keycode) {
  212. case LOWER:
  213. update_change_layer(record->event.pressed, _LOWER, _RAISE, _ADJUST);
  214. break;
  215. case RAISE:
  216. update_change_layer(record->event.pressed, _RAISE, _LOWER, _ADJUST);
  217. break;
  218. case BASE:
  219. if (record->event.pressed) {
  220. default_layer_set(L_BASE);
  221. }
  222. break;
  223. case BASES:
  224. if (record->event.pressed) {
  225. default_layer_set(L_BASES);
  226. }
  227. break;
  228. case LOWRS:
  229. update_change_layer(record->event.pressed, _LOWRS, _RAISE, _ADJUST);
  230. break;
  231. case KANJI:
  232. if (record->event.pressed) {
  233. if (keymap_config.swap_lalt_lgui == false) {
  234. register_code(KC_LNG2);
  235. } else {
  236. SEND_STRING(SS_LALT("`"));
  237. }
  238. } else {
  239. unregister_code(KC_LNG2);
  240. }
  241. break;
  242. #ifdef RGBLIGHT_ENABLE
  243. case RGBRST:
  244. if (record->event.pressed) {
  245. eeconfig_update_rgblight_default();
  246. rgblight_enable();
  247. }
  248. break;
  249. #endif
  250. default:
  251. result = true;
  252. break;
  253. }
  254. UPDATE_KEYMAP_STATUS();
  255. return result;
  256. }