You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

333 lines
18 KiB

  1. /*
  2. Copyright 2019 @foostan
  3. Copyright 2020 Drashna Jaelre <@drashna>
  4. This program is free software: you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation, either version 2 of the License, or
  7. (at your option) any later version.
  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. You should have received a copy of the GNU General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. #include QMK_KEYBOARD_H
  16. #include "keymap_german.h"
  17. enum custom_keycodes {
  18. QWERTZ = SAFE_RANGE,
  19. ADNW,
  20. };
  21. enum tapdance_codes {
  22. TD_GREET = 0,
  23. };
  24. enum {_B_QWER, _B_ADNW, _NUM_R, _FUN_R, _MOUS_L, _NAV_L, _PUNC_R, _PUNC_L};
  25. // For QWERTZ base layer
  26. #define _GUI_A LGUI_T(DE_A)
  27. #define _ALT_S LALT_T(DE_S)
  28. #define _CTL_D LCTL_T(DE_D)
  29. #define _SFT_F LSFT_T(DE_F)
  30. #define _ALGR_X ALGR_T(DE_X)
  31. #define _GUI_OE LGUI_T(DE_ODIA)
  32. #define _ALT_L LALT_T(DE_L)
  33. #define _CTL_K LCTL_T(DE_K)
  34. #define _SFT_J LSFT_T(DE_J)
  35. #define _ALGR_DT ALGR_T(DE_DOT)
  36. // For ADNW base layer
  37. #define _GUI_H LGUI_T(DE_H)
  38. #define _ALT_A LALT_T(DE_A)
  39. #define _CTL_E LCTL_T(DE_E)
  40. #define _SFT_I LSFT_T(DE_I)
  41. #define _ALGR_Q ALGR_T(DE_Q)
  42. #define _GUI_S LGUI_T(DE_S)
  43. #define _ALT_N LALT_T(DE_N)
  44. #define _CTL_R LCTL_T(DE_R)
  45. #define _SFT_T LSFT_T(DE_T)
  46. #define _ALGR_V ALGR_T(DE_V)
  47. #define _ALGR_M ALGR_T(DE_M)
  48. // Layer mods
  49. #define _FUN_ESC LT(_FUN_R, KC_ESC)
  50. #define _SYM_SPC LT(_PUNC_R, KC_SPC)
  51. #define _NUM_TAB LT(_NUM_R, KC_TAB)
  52. #define _NAV_ENT LT(_NAV_L, KC_ENT)
  53. #define _SYM_BSP LT(_PUNC_L, KC_BSPC)
  54. #define _MS_DEL LT(_MOUS_L, KC_DEL)
  55. #define _LSKIP C(KC_LEFT)
  56. #define _RSKIP C(KC_RIGHT)
  57. #define _CUT C(DE_X)
  58. #define _COPY C(DE_C)
  59. #define _PASTE C(DE_V)
  60. #define _UNDO C(DE_Z)
  61. #define _REDO C(DE_Y)
  62. const uint16_t PROGMEM both_shift_is_caps[] = {_SFT_F, _SFT_J, COMBO_END};
  63. const uint16_t PROGMEM thumb_mods_lock_mouse[] = {_FUN_ESC, _MS_DEL, COMBO_END};
  64. combo_t key_combos[COMBO_COUNT] = {
  65. COMBO(both_shift_is_caps, KC_CAPS),
  66. COMBO(thumb_mods_lock_mouse, TG(_MOUS_L))
  67. };
  68. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  69. [_B_QWER] = LAYOUT_split_3x6_3(
  70. //,-----------------------------------------------------. ,-----------------------------------------------------.
  71. TD(TD_GREET), DE_Q, DE_W, DE_E, DE_R, DE_T, DE_Z, DE_U, DE_I, DE_O, DE_P, DE_SS,
  72. //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
  73. DM_PLY1, _GUI_A, _ALT_S, _CTL_D, _SFT_F, DE_G, DE_H, _SFT_J, _CTL_K, _ALT_L, _GUI_OE, DE_ADIA,
  74. //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
  75. DM_PLY2, DE_Y, _ALGR_X, DE_C, DE_V, DE_B, DE_N, DE_M, DE_COMM,_ALGR_DT, DE_MINS, DE_UDIA,
  76. //|--------+--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------+--------|
  77. _FUN_ESC, _SYM_SPC, _NUM_TAB, _NAV_ENT, _SYM_BSP, _MS_DEL
  78. //`--------------------------' `--------------------------'
  79. ),
  80. /*
  81. // My custom layout named "KoyKay"
  82. [_B_ADNW] = LAYOUT_split_3x6_3(
  83. //,-----------------------------------------------------. ,-----------------------------------------------------.
  84. TD(TD_GREET), DE_K, DE_DOT, DE_O, DE_COMM, DE_Y, DE_P, DE_D, DE_L, DE_M, DE_J, DE_SS,
  85. //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
  86. DM_PLY1, _GUI_H, _ALT_A, _CTL_E, _SFT_I, DE_U, DE_G, _SFT_T, _CTL_R, _ALT_N, _GUI_S, DE_F,
  87. //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
  88. DM_PLY2, DE_Z, _ALGR_Q, DE_ADIA, DE_UDIA, DE_ODIA, DE_B, DE_C, DE_W, _ALGR_V, DE_X, DE_MINS,
  89. //|--------+--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------+--------|
  90. _FUN_ESC, _SYM_SPC, _NUM_TAB, _NAV_ENT, _SYM_BSP, _MS_DEL
  91. //`--------------------------' `--------------------------'
  92. ),
  93. */
  94. // Generic KOY layout by ADNW - but "ß" and "Z" switched compared to original:
  95. // K.O,Y VGCLßZ
  96. // HAEIU DTRNSF
  97. // XQÄÜÖ BPWMJ
  98. [_B_ADNW] = LAYOUT_split_3x6_3(
  99. //,-----------------------------------------------------. ,-----------------------------------------------------.
  100. TD(TD_GREET), DE_K, DE_DOT, DE_O, DE_COMM, DE_Y, DE_V, DE_G, DE_C, DE_L, DE_Z, DE_SS,
  101. //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
  102. DM_PLY1, _GUI_H, _ALT_A, _CTL_E, _SFT_I, DE_U, DE_D, _SFT_T, _CTL_R, _ALT_N, _GUI_S, DE_F,
  103. //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
  104. DM_PLY2, DE_X, _ALGR_Q, DE_ADIA, DE_UDIA, DE_ODIA, DE_B, DE_P, DE_W, _ALGR_M, DE_J, DE_MINS,
  105. //|--------+--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------+--------|
  106. _FUN_ESC, _SYM_SPC, _NUM_TAB, _NAV_ENT, _SYM_BSP, _MS_DEL
  107. //`--------------------------' `--------------------------'
  108. ),
  109. [_NUM_R] = LAYOUT_split_3x6_3(
  110. //,-----------------------------------------------------. ,-----------------------------------------------------.
  111. XXXXXXX,XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, DE_DOT, DE_7, DE_8, DE_9, DE_LPRN, DE_RPRN,
  112. //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
  113. XXXXXXX,KC_LGUI, KC_LALT, KC_LCTL, KC_LSFT, XXXXXXX, DE_COMM, DE_4, DE_5, DE_6, DE_PLUS, DE_ASTR,
  114. //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
  115. XXXXXXX,XXXXXXX, KC_ALGR, XXXXXXX, XXXXXXX, XXXXXXX, DE_0, DE_1, DE_2, DE_3, DE_MINS, DE_SLSH,
  116. //|--------+--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------+--------|
  117. XXXXXXX, XXXXXXX, XXXXXXX, KC_ENT, KC_BSPC, KC_DEL
  118. //`--------------------------' `--------------------------'
  119. ),
  120. [_FUN_R] = LAYOUT_split_3x6_3(
  121. //,-----------------------------------------------------. ,-----------------------------------------------------.
  122. QK_BOOT, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_PSCR, KC_F7, KC_F8, KC_F9, KC_F12, XXXXXXX,
  123. //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
  124. DF(_B_QWER), KC_LGUI, KC_LALT, KC_LCTL, KC_LSFT, XXXXXXX, KC_APP, KC_F4, KC_F5, KC_F6, KC_F11, XXXXXXX,
  125. //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
  126. DF(_B_ADNW), XXXXXXX, KC_ALGR, XXXXXXX, XXXXXXX, XXXXXXX, KC_PAUS, KC_F1, KC_F2, KC_F3, KC_F10, XXXXXXX,
  127. //|--------+--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------+--------|
  128. XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX
  129. //`--------------------------' `--------------------------'
  130. ),
  131. [_PUNC_R] = LAYOUT_split_3x6_3(
  132. //,-----------------------------------------------------. ,-----------------------------------------------------.
  133. XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, DE_ASTR, DE_LABK, DE_RABK, DE_SLSH, DE_BSLS, DE_SECT,
  134. //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
  135. XXXXXXX,KC_LGUI, KC_LALT, KC_LCTL, KC_LSFT, XXXXXXX, DE_PLUS, DE_EXLM, DE_QUES, DE_DQUO, DE_QUOT, DE_SCLN,
  136. //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
  137. XXXXXXX, XXXXXXX,KC_ALGR, XXXXXXX, XXXXXXX, XXXXXXX, DE_EQL, DE_GRV, DE_ACUT, XXXXXXX, DE_DEG, DE_COLN,
  138. //|--------+--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------+--------|
  139. XXXXXXX, XXXXXXX, XXXXXXX, KC_ENT, KC_BSPC, KC_DEL
  140. //`--------------------------' `--------------------------'
  141. ),
  142. [_PUNC_L] = LAYOUT_split_3x6_3(
  143. //,-----------------------------------------------------. ,-----------------------------------------------------.
  144. DE_MICR, DE_AT, DE_EURO, DE_LCBR, DE_RCBR, DE_DLR, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
  145. //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
  146. DE_MINS, DE_PIPE, DE_AMPR, DE_LPRN, DE_RPRN, DE_HASH, XXXXXXX, KC_RSFT, KC_RCTL, KC_RALT, KC_RGUI, XXXXXXX,
  147. //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
  148. DE_UNDS, DE_CIRC, DE_TILD, DE_LBRC, DE_RBRC, DE_PERC, XXXXXXX, XXXXXXX, XXXXXXX, KC_ALGR, XXXXXXX, XXXXXXX,
  149. //|--------+--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------+--------|
  150. KC_ESC, KC_SPC, KC_TAB, XXXXXXX, XXXXXXX, XXXXXXX
  151. //`--------------------------' `--------------------------'
  152. ),
  153. [_MOUS_L] = LAYOUT_split_3x6_3(
  154. //,-----------------------------------------------------. ,-----------------------------------------------------.
  155. DM_RSTP, KC_WH_L, KC_WH_U, KC_MS_U, KC_WH_D, KC_WH_R, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, QK_BOOT,
  156. //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
  157. DM_REC1, KC_WBAK, KC_MS_L, KC_MS_D, KC_MS_R, KC_WFWD, XXXXXXX, KC_RSFT, KC_RCTL, KC_RALT, KC_RGUI, XXXXXXX,
  158. //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
  159. DM_REC2, XXXXXXX, KC_WH_L, KC_WREF, KC_WH_R, XXXXXXX, XXXXXXX, XXXXXXX, KC_ACL0, KC_ALGR, KC_ACL2, XXXXXXX,
  160. //|--------+--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------+--------|
  161. _______, KC_BTN1, KC_BTN2, XXXXXXX, XXXXXXX, _______
  162. //`--------------------------' `--------------------------'
  163. ),
  164. [_NAV_L] = LAYOUT_split_3x6_3(
  165. //,-----------------------------------------------------. ,-----------------------------------------------------.
  166. XXXXXXX, KC_PGUP, KC_HOME, KC_UP, KC_END, KC_PGDN, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
  167. //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
  168. XXXXXXX, _LSKIP, KC_LEFT, KC_DOWN, KC_RGHT, _RSKIP, XXXXXXX, KC_RSFT, KC_RCTL, KC_RALT, KC_RGUI, XXXXXXX,
  169. //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
  170. XXXXXXX, _REDO, _CUT, _COPY, _PASTE, _UNDO, XXXXXXX, XXXXXXX, XXXXXXX, KC_ALGR, XXXXXXX, XXXXXXX,
  171. //|--------+--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------+--------|
  172. KC_ESC, KC_SPC, KC_TAB, XXXXXXX, XXXXXXX, XXXXXXX
  173. //`--------------------------' `--------------------------'
  174. )
  175. };
  176. bool _macro_is_recording = false;
  177. void dynamic_macro_record_start_user(int8_t direction) {
  178. _macro_is_recording = true;
  179. }
  180. void dynamic_macro_record_end_user(int8_t direction) {
  181. _macro_is_recording = false;
  182. }
  183. #ifdef OLED_ENABLE
  184. oled_rotation_t oled_init_user(oled_rotation_t rotation) {
  185. if (!is_keyboard_master()) {
  186. return OLED_ROTATION_180; // flips the display 180 degrees if offhand
  187. }
  188. return rotation;
  189. }
  190. void oled_render_layer_state(void) {
  191. oled_write_P(PSTR("Layer: "), false);
  192. switch (get_highest_layer(layer_state)) {
  193. case _B_QWER:
  194. case _B_ADNW:
  195. if (get_highest_layer(default_layer_state) == _B_QWER) {
  196. oled_write_ln_P(PSTR("QWERTZ"), false);
  197. } else {
  198. oled_write_ln_P(PSTR("ADNW-ish"), false);
  199. }
  200. break;
  201. case _PUNC_L:
  202. case _PUNC_R:
  203. oled_write_ln_P(PSTR("Symbols"), false);
  204. break;
  205. case _NUM_R:
  206. oled_write_ln_P(PSTR("Numbers"), false);
  207. break;
  208. case _FUN_R:
  209. oled_write_ln_P(PSTR("F-Keys"), false);
  210. break;
  211. case _MOUS_L:
  212. oled_write_ln_P(PSTR("Mouse"), false);
  213. break;
  214. case _NAV_L:
  215. oled_write_ln_P(PSTR("Navigate"), false);
  216. break;
  217. }
  218. }
  219. void oled_render_empty_line(void) {
  220. oled_write_ln_P(PSTR(""), false);
  221. }
  222. void render_keylock_status(uint8_t led_usb_state) {
  223. led_t led_state = host_keyboard_led_state();
  224. oled_write_P(PSTR("Lock: "), false);
  225. oled_write_P(PSTR("N"), led_state.num_lock);
  226. oled_write_P(PSTR(" "), false);
  227. oled_write_P(PSTR("C"), led_state.caps_lock);
  228. oled_write_P(PSTR(" "), false);
  229. oled_write_ln_P(PSTR("S"), led_state.scroll_lock);
  230. }
  231. void render_bootmagic_status(bool status) {
  232. /* Show Ctrl-Gui Swap options */
  233. static const char PROGMEM logo[][2][3] = {
  234. {{0x97, 0x98, 0}, {0xb7, 0xb8, 0}},
  235. {{0x95, 0x96, 0}, {0xb5, 0xb6, 0}},
  236. };
  237. if (status) {
  238. oled_write_ln_P(logo[0][0], false);
  239. oled_write_ln_P(logo[0][1], false);
  240. } else {
  241. oled_write_ln_P(logo[1][0], false);
  242. oled_write_ln_P(logo[1][1], false);
  243. }
  244. }
  245. void render_dyn_macro_is_recording(void) {
  246. oled_write_P(PSTR("Macro rec: "), false);
  247. if (_macro_is_recording) {
  248. oled_write_ln_P(PSTR("ON "), false);
  249. } else {
  250. oled_write_ln_P(PSTR("OFF"), false);
  251. }
  252. }
  253. void oled_render_logo(void) {
  254. static const char PROGMEM cherry_logo[] = {
  255. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,128,112,112,224, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  256. 0, 0,224,248,252,252, 62, 30, 30, 30, 30, 30, 30, 30, 0, 0, 0,254,254,254,254,192,192,192,192,192,192,192,254,254,254,254, 0, 0, 0,254,254,254,254,142,142,142,142,142,142,142, 14, 14, 14, 0, 0, 0,254,254,254,254, 14, 14, 14, 14, 14, 14,158,254,252,252,240, 0, 0, 0,254,254,254,254, 14, 14, 14, 14, 14, 14,158,254,254,252,248, 0, 6, 14, 62,254,254,252,240,192,128,192,240,252,254,254, 62, 14, 6, 0, 0, 0, 0,224,240,248,248,252,252,252,255,249,240,206, 31,254,240,230,190,252,252,240,128, 0,
  257. 0, 0, 15, 63,127,127,248,240,240,240,240,240,240,240, 0, 0, 0,255,255,255,255, 3, 3, 3, 3, 3, 3, 3,255,255,255,255, 0, 0, 0,255,255,255,255,227,227,227,227,227,227,227,224,224,224, 0, 0, 0,255,255,255,255, 15, 15, 15, 15, 15, 15, 63,255,255,243,193, 0, 0, 0,255,255,255,255, 15, 15, 15, 15, 15, 15, 63,255,255,243,193, 0, 0, 0, 0, 0, 1, 7,255,255,255,255,255, 7, 3, 0, 0, 0, 0, 0, 0, 0, 0, 7, 15, 31, 31, 31,159,223,223,207,231,243,248,243,247,231,207, 31, 31, 31, 63, 0,
  258. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 7, 15, 15, 31, 31, 31, 15, 15, 7, 1, 0, 0, 0, 0, 0,
  259. };
  260. oled_write_raw_P(cherry_logo, sizeof(cherry_logo));
  261. }
  262. bool oled_task_user(void) {
  263. if (is_keyboard_master()) {
  264. oled_render_layer_state();
  265. oled_render_empty_line();
  266. render_keylock_status(host_keyboard_leds());
  267. oled_set_cursor(0, 3);
  268. render_dyn_macro_is_recording();
  269. } else {
  270. oled_render_logo();
  271. }
  272. return false;
  273. }
  274. void print_greeting (tap_dance_state_t *state, void *user_data) {
  275. if (state->count == 1) {
  276. SEND_STRING("Viele Gr");
  277. tap_code(DE_UDIA);
  278. tap_code(DE_SS);
  279. SEND_STRING("e\nMax");
  280. reset_tap_dance(state);
  281. }
  282. else if (state->count == 2) {
  283. SEND_STRING("Best regards\n");
  284. SEND_STRING("Max");
  285. reset_tap_dance(state);
  286. }
  287. }
  288. tap_dance_action_t tap_dance_actions[] = {
  289. [TD_GREET] = ACTION_TAP_DANCE_FN(print_greeting),
  290. };
  291. #endif // OLED_DRIVER_ENABLE