keymap.c 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. /* Copyright 2022 Efthimis Iosifidis <iosifidise@gmail.com>
  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. _BASIC,
  19. _BRACKETS,
  20. _SELECTORS,
  21. _FN,
  22. };
  23. #define KC_X0 LT(_FN, KC_ESC)
  24. static char current_alpha_oled [12] = "None";
  25. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  26. /* _BASIC Layer
  27. * ,-------------------------------------.
  28. * | Toggle | Toggle | | |
  29. * | Block | Line | Undo | Search |
  30. * | Comment | Comment | | |
  31. * |---------+---------+--------+---------+
  32. * | | | | TO |
  33. * | Cut | Copy | Paste | _BASIC |
  34. * | | | | |
  35. * `-------------------------------------'
  36. */
  37. [_BASIC] = LAYOUT_ortho_2x4(
  38. RCS(KC_A), LCTL(KC_SLASH), LCTL(KC_Z), LCTL(KC_F),
  39. LCTL(KC_X), LCTL(KC_C), LCTL(KC_V), TO(_BRACKETS)
  40. ),
  41. /* _BRACKETS Layer
  42. * ,-----------------------------------------.
  43. * | | | | |
  44. * | ( | [ | { | Bksp |
  45. * | | | | |
  46. * |---------+---------+--------+------------+
  47. * | | | | TO |
  48. * | Del | Copy | Paste | _SELECTORS |
  49. * | | | | |
  50. * `----------------------------------------'
  51. */
  52. [_BRACKETS] = LAYOUT_ortho_2x4(
  53. S(KC_9), KC_LBRC, S(KC_LBRC), KC_BACKSPACE,
  54. KC_DEL, C(KC_C), C(KC_V), TO(_SELECTORS)
  55. ),
  56. /* _SELECTORS Layer
  57. * ,-------------------------------------.
  58. * | | | | |
  59. * | Select | Save | Undo | Bksp |
  60. * | All | | | |
  61. * |---------+---------+--------+---------+
  62. * | | | | TO |
  63. * | Cut | Copy | Paste | _FN |
  64. * | | | | |
  65. * `-------------------------------------'
  66. */
  67. [_SELECTORS] = LAYOUT_ortho_2x4(
  68. C(KC_A), C(KC_S), C(KC_Z), KC_BACKSPACE,
  69. C(KC_X), C(KC_C), C(KC_V), TO(_FN)
  70. ),
  71. /* _FN Layer
  72. * ,--------------------------------------------.
  73. * | RGB | RGB | RGB | RGB |
  74. * | Toggle | Mode | Mode | Snake |
  75. * | | Forward | Reverse | Mode |
  76. * |-----------+-----------+-----------+---------+
  77. * | | Cycle | Toggle | TO |
  78. * | BackLight | BackLight | BackLight | _BASIC |
  79. * | Toggle | Levels | Breathing | |
  80. * `--------------------------------------------'
  81. */
  82. [_FN] = LAYOUT_ortho_2x4(
  83. RGB_TOG, RGB_MOD, RGB_M_R, RGB_M_SN,
  84. BL_TOGG, BL_STEP, BL_BRTG, TO(_BASIC)
  85. )
  86. };
  87. #ifdef OLED_ENABLE
  88. oled_rotation_t oled_init_user(oled_rotation_t rotation) {
  89. return OLED_ROTATION_180; // flips the display 180 degrees if offhand
  90. }
  91. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  92. if (record->event.pressed) {
  93. char string [33];
  94. switch(keycode)
  95. {
  96. //First Layer with Basic Keys
  97. case LCTL(KC_X):
  98. strncpy(current_alpha_oled, "Cut", sizeof(current_alpha_oled));
  99. break;
  100. case LCTL(KC_F):
  101. strncpy(current_alpha_oled, "Search", sizeof(current_alpha_oled));
  102. break;
  103. case LCTL(KC_Z):
  104. strncpy(current_alpha_oled, "Undo", sizeof(current_alpha_oled));
  105. break;
  106. case LCTL(KC_C):
  107. strncpy(current_alpha_oled, "Copy", sizeof(current_alpha_oled));
  108. break;
  109. case LCTL(KC_V):
  110. strncpy(current_alpha_oled, "Paste", sizeof(current_alpha_oled));
  111. break;
  112. case RCS(KC_A):
  113. strncpy(current_alpha_oled, "Block cmt.", sizeof(current_alpha_oled));
  114. break;
  115. case LCTL(KC_SLASH):
  116. strncpy(current_alpha_oled, "Line cmt.", sizeof(current_alpha_oled));
  117. break;
  118. //Second Layer with Brackets
  119. case S(KC_9):
  120. strncpy(current_alpha_oled, "()", sizeof(current_alpha_oled));
  121. break;
  122. case KC_LBRC:
  123. strncpy(current_alpha_oled, "[]", sizeof(current_alpha_oled));
  124. break;
  125. case S(KC_LBRC):
  126. strncpy(current_alpha_oled, "{}", sizeof(current_alpha_oled));
  127. break;
  128. case KC_BACKSPACE:
  129. strncpy(current_alpha_oled, "Backspace", sizeof(current_alpha_oled));
  130. break;
  131. case KC_DEL:
  132. strncpy(current_alpha_oled, "Del", sizeof(current_alpha_oled));
  133. break;
  134. // Selector Layer keys
  135. case C(KC_A):
  136. strncpy(current_alpha_oled, "Select All", sizeof(current_alpha_oled));
  137. break;
  138. case C(KC_S):
  139. strncpy(current_alpha_oled, "Save", sizeof(current_alpha_oled));
  140. break;
  141. // FN Layer keys
  142. case RGB_TOG:
  143. strncpy(current_alpha_oled, "RGB Toggle", sizeof(current_alpha_oled));
  144. break;
  145. case RGB_MOD:
  146. strncpy(current_alpha_oled, "RGB Fwd", sizeof(current_alpha_oled));
  147. break;
  148. case RGB_M_R:
  149. strncpy(current_alpha_oled, "RGB Rev", sizeof(current_alpha_oled));
  150. break;
  151. case RGB_MODE_SNAKE:
  152. strncpy(current_alpha_oled, "RGB Snk", sizeof(current_alpha_oled));
  153. break;
  154. case BL_TOGG:
  155. strncpy(current_alpha_oled, "BkLgt Tog", sizeof(current_alpha_oled));
  156. break;
  157. case BL_STEP:
  158. strncpy(current_alpha_oled, "BkLgt Lvl", sizeof(current_alpha_oled));
  159. break;
  160. case BL_BRTG:
  161. strncpy(current_alpha_oled, "BkLgt Brth", sizeof(current_alpha_oled));
  162. break;
  163. //FN Key keycodes
  164. case TO(_BASIC) ... TO(_FN):
  165. strncpy(current_alpha_oled, "Switcher", sizeof(current_alpha_oled));
  166. break;
  167. default:
  168. strncpy(current_alpha_oled, itoa(keycode, string, 10), sizeof(current_alpha_oled));
  169. break;
  170. }
  171. }
  172. return true;
  173. }
  174. bool oled_task_user(void) {
  175. // Host Keyboard Layer Status
  176. oled_write_ln_P(PSTR("ANAVI Macro Pad 8"), false);
  177. oled_write_P(PSTR("Active layer: "), false);
  178. switch (get_highest_layer(layer_state)) {
  179. case _BASIC:
  180. oled_write_ln_P(PSTR("Basic"), false);
  181. break;
  182. case _BRACKETS:
  183. oled_write_ln_P(PSTR("Brkts"), false);
  184. break;
  185. case _SELECTORS:
  186. oled_write_ln_P(PSTR("Selct"), false);
  187. break;
  188. case _FN:
  189. oled_write_ln_P(PSTR("FN"), false);
  190. break;
  191. default:
  192. // Or use the write_ln shortcut over adding '\n' to the end of your string
  193. oled_write_ln_P(PSTR("N/A"), false);
  194. }
  195. // Host Keyboard LED Status
  196. led_t led_state = host_keyboard_led_state();
  197. oled_write_P(PSTR("Num Lock: "), false);
  198. oled_write_ln_P(led_state.num_lock ? PSTR("On") : PSTR("Off"), false);
  199. oled_write_P(PSTR("Caps Lock: "), false);
  200. oled_write_ln_P(led_state.caps_lock ? PSTR("On") : PSTR("Off"), false);
  201. oled_write_P(PSTR("Backlit: "), false);
  202. oled_write_ln_P(is_backlight_enabled() ? PSTR("On") : PSTR("Off"), false);
  203. oled_write_P(PSTR("Last Key: "), false);
  204. oled_write_ln(current_alpha_oled, false);
  205. #ifdef RGBLIGHT_ENABLE
  206. static char rgbStatusLine1[26] = {0};
  207. snprintf(rgbStatusLine1, sizeof(rgbStatusLine1), "RGB Mode: %d", rgblight_get_mode());
  208. oled_write_ln(rgbStatusLine1, false);
  209. static char rgbStatusLine2[26] = {0};
  210. snprintf(rgbStatusLine2, sizeof(rgbStatusLine2), "h:%d s:%d v:%d", rgblight_get_hue(), rgblight_get_sat(), rgblight_get_val());
  211. oled_write_ln(rgbStatusLine2, false);
  212. #endif
  213. return false;
  214. }
  215. #endif