From 6732d6190f27f5512caa3c188cd11399090f0593 Mon Sep 17 00:00:00 2001 From: antosha417 Date: Fri, 24 Dec 2021 17:34:00 +0200 Subject: [PATCH 01/13] corne keyboard initial --- keyboards/crkbd/keymaps/antosha417/config.h | 29 ++ keyboards/crkbd/keymaps/antosha417/keymap.c | 429 ++++++++++++++++++ .../crkbd/keymaps/antosha417/mod_tap_keys.h | 12 + keyboards/crkbd/keymaps/antosha417/rules.mk | 6 + keyboards/crkbd/keymaps/antosha417/todo.md | 13 + 5 files changed, 489 insertions(+) create mode 100644 keyboards/crkbd/keymaps/antosha417/config.h create mode 100644 keyboards/crkbd/keymaps/antosha417/keymap.c create mode 100644 keyboards/crkbd/keymaps/antosha417/mod_tap_keys.h create mode 100644 keyboards/crkbd/keymaps/antosha417/rules.mk create mode 100644 keyboards/crkbd/keymaps/antosha417/todo.md diff --git a/keyboards/crkbd/keymaps/antosha417/config.h b/keyboards/crkbd/keymaps/antosha417/config.h new file mode 100644 index 000000000000..2254d34b1213 --- /dev/null +++ b/keyboards/crkbd/keymaps/antosha417/config.h @@ -0,0 +1,29 @@ +#pragma once + +//#define USE_MATRIX_I2C + +/* Select hand configuration */ + +//#define MASTER_LEFT +// #define MASTER_RIGHT +#define EE_HANDS + +#define USE_SERIAL_PD2 + +#define TAPPING_FORCE_HOLD + +#ifdef RGBLIGHT_ENABLE + #undef RGBLED_NUM + #define RGBLIGHT_ANIMATIONS + #define RGBLED_NUM 27 + #define RGBLIGHT_LIMIT_VAL 120 + #define RGBLIGHT_HUE_STEP 10 + #define RGBLIGHT_SAT_STEP 17 + #define RGBLIGHT_VAL_STEP 17 +#endif + +#define OLED_FONT_H "keyboards/crkbd/lib/glcdfont.c" +#define TAPPING_TERM 200 +#define IGNORE_MOD_TAP_INTERRUPT +#define COMBO_TERM 30 + diff --git a/keyboards/crkbd/keymaps/antosha417/keymap.c b/keyboards/crkbd/keymaps/antosha417/keymap.c new file mode 100644 index 000000000000..cf9c6d9ed205 --- /dev/null +++ b/keyboards/crkbd/keymaps/antosha417/keymap.c @@ -0,0 +1,429 @@ +#include QMK_KEYBOARD_H +#include +#include + +typedef union { + uint32_t raw; + struct { + bool is_macos :1; + }; +} user_config; + +user_config config; + +enum layers { + _QWERTY, + _DVORAK, + _LOWER, + _RAISE, + _TOP, + _BOTTOM, +}; + +enum keycodes { + QWERTY = SAFE_RANGE, + + RUS_LANG, + EN_LANG, + HEB_LANG, + + VIM_SAVE, + + CHNGE_OS, + DELETE_WORD, + +#define MOD_TAP_KEY(keycode, tap_action, mod_on_action, mod_off_action) \ + keycode, +#include "mod_tap_keys.h" +#undef MOD_TAP_KEY +}; + + +#define LOWER MO(_LOWER) +#define RAISE MO(_RAISE) +#define TOP MO(_TOP) +#define BOTTOM MO(_BOTTOM) +#define LANG TG(_DVORAK) +#define KC_CAD LALT(LCTL(KC_DEL)) +#define KC_CAH LALT(LCTL(KC_HOME)) + +#define E_SFT LSFT_T(KC_E) +#define D_SFT LSFT_T(KC_D) +#define A_ALT LALT_T(KC_A) +#define O_GUI LGUI_T(KC_O) +#define U_CTRL LCTL_T(KC_U) + +#define T_SFT RSFT_T(KC_T) +#define K_SFT RSFT_T(KC_K) +#define S_ALT RALT_T(KC_S) +#define N_GUI RGUI_T(KC_N) +#define H_CTRL RCTL_T(KC_H) + + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + +[_QWERTY] = LAYOUT_split_3x6_3( +//,-----------------------------------------------------. ,-----------------------------------------------------. + KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC, +//|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------| + KC_ESC, A_ALTQ, S_GUIQ, D_SFT, F_CTLQ, KC_G, KC_H, J_CTLQ, K_SFT, L_GUIQ, SCLN_Q, KC_QUOT, +//|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------| + KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT, +//|--------+--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------+--------| + BOTTOM, KC_SPC, LOWER, RAISE, KC_SPC, TOP + //`--------------------------' `--------------------------' +), + +[_DVORAK] = LAYOUT_split_3x6_3( +//,-----------------------------------------------------. ,-----------------------------------------------------. + KC_TAB, KC_QUOT, KC_COMM, KC_DOT, KC_P, KC_Y, KC_F, KC_G, KC_C, KC_R, KC_L, KC_BSPC, +//|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------| + KC_LCTL, A_ALT, O_GUI, E_SFT, U_CTRL, KC_I, KC_D, H_CTRL, T_SFT, N_GUI, S_ALT, KC_QUOT, +//|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------| + KC_LSFT, KC_SCLN, KC_Q, KC_J, KC_K, KC_X, KC_B, KC_M, KC_W, KC_V, KC_Z, KC_ESC, +//|--------+--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------+--------| + _______, _______, _______, _______, _______, _______ + //`--------------------------' `--------------------------' +), + +[_LOWER] = LAYOUT_split_3x6_3( +//,-----------------------------------------------------. ,-----------------------------------------------------. + KC_F11, KC_UNDS, KC_MINS, KC_TILD, KC_PERC, KC_QUOT, _______, KC_CIRC, KC_GRV, KC_BSLS, KC_PIPE, KC_MINS, +//|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------| + KC_DEL, KC_LBRC, KC_LCBR, KC_PLUS, KC_LPRN, KC_EQL, KC_ASTR, KC_RPRN, KC_EXLM, KC_RCBR, KC_RBRC, KC_BSPC, +//|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------| + _______, KC_CAD, KC_CAH, _______, LANG, _______, _______,HEB_LANG, EN_LANG,RUS_LANG, _______, _______, +//|--------+--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------+--------| + _______, _______, _______, _______, _______, _______ + //`--------------------------' `--------------------------' + //^^^^^^^ +), + + +[_RAISE] = LAYOUT_split_3x6_3( +//,-----------------------------------------------------. ,-----------------------------------------------------. + KC_F11, _______, _______, KC_DLR, KC_AMPR, _______, KC_COLON, KC_QUES, KC_AT, KC_HASH, KC_SLSH, KC_F12, +//|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------| + _______, KC_7, KC_5, KC_3, KC_1, KC_9, KC_0, KC_2, KC_4, KC_6, KC_8, KC_BSPC, +//|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------| + _______, KC_F7, KC_F5, KC_F3, KC_F1, KC_F9, KC_F10, KC_F2, KC_F4, KC_F6, KC_F8, _______, +//|--------+--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------+--------| + _______, _______, _______, _______, _______, _______ + //`--------------------------' `--------------------------' + //^^^^^^^ +), + +[_TOP] = LAYOUT_split_3x6_3( +//,-----------------------------------------------------. ,-----------------------------------------------------. + _______,CHNGE_OS, RGB_TOG, RGB_MOD, RGB_HUI, RGB_HUD, RGB_SAI, RGB_SAD, RGB_VAI, RGB_VAD, _______, _______, +//|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------| + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, +//|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------| + _______, _______, _______, KC_DOWN, KC_UP, _______, _______, _______, _______, _______, _______, _______, +//|--------+--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------+--------| + _______, _______, _______, _______, _______, _______ + //`--------------------------' `--------------------------' + //^^^^^^^ +), + +[_BOTTOM] = LAYOUT_split_3x6_3( +//,-----------------------------------------------------. ,-----------------------------------------------------. + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_RGHT, _______, +//|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------| + _______, _______, _______, _______, _______, _______, _______, KC_LEFT, _______, _______, _______, _______, +//|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------| + _______, _______, _______, _______, _______, _______, _______, KC_VOLD, KC_VOLU, _______, _______, _______, +//|--------+--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------+--------| + _______, _______, _______, _______, _______, _______ + //`--------------------------' `--------------------------' + //^^^^^^^ +) + +}; + +enum combo_events { + // combos for dvorak layer + RU_COMBO, + EN_COMBO, + HEB_COMBO, + ESC_COMBO, + TAB_COMBO, + ENT_COMBO, + DEL_COMBO, + SAVE_COMBO, + BSPC_COMBO, + BSPCW_COMBO, + + // combos for qwerty layer + RUQ_COMBO, + ENQ_COMBO, + HEBQ_COMBO, + ESCQ_COMBO, + TABQ_COMBO, + ENTQ_COMBO, + DELQ_COMBO, + SAVEQ_COMBO, + BSPCQ_COMBO, + BSPCWQ_COMBO, + + COMBO_LENGTH +}; +uint16_t COMBO_LEN = COMBO_LENGTH; + +const uint16_t PROGMEM ru_combo[] = {KC_R, U_CTRL, COMBO_END}; +const uint16_t PROGMEM en_combo[] = {U_CTRL, S_ALT, COMBO_END}; +const uint16_t PROGMEM heb_combo[] = {KC_I, KC_V, COMBO_END}; +const uint16_t PROGMEM esc_combo[] = {H_CTRL, U_CTRL, COMBO_END}; +const uint16_t PROGMEM tab_combo[] = {T_SFT, A_ALT, COMBO_END}; +const uint16_t PROGMEM ent_combo[]= {E_SFT, N_GUI, COMBO_END}; +const uint16_t PROGMEM del_combo[] = {KC_D, E_SFT, COMBO_END}; +const uint16_t PROGMEM bspc_combo[] = {KC_C, H_CTRL, COMBO_END}; +const uint16_t PROGMEM bspcw_combo[] = {N_GUI, U_CTRL, COMBO_END}; +const uint16_t PROGMEM save_combo[] = {O_GUI, H_CTRL, COMBO_END}; + +const uint16_t PROGMEM ruq_combo[] = {KC_O, F_CTLQ, COMBO_END}; +const uint16_t PROGMEM enq_combo[] = {F_CTLQ, SCLN_Q, COMBO_END}; +const uint16_t PROGMEM hebq_combo[] = {KC_G, KC_DOT, COMBO_END}; +const uint16_t PROGMEM escq_combo[] = {F_CTLQ, J_CTLQ, COMBO_END}; +const uint16_t PROGMEM tabq_combo[] = {K_SFT, A_ALTQ, COMBO_END}; +const uint16_t PROGMEM entq_combo[] = {D_SFT, L_GUIQ, COMBO_END}; +const uint16_t PROGMEM delq_combo[] = {KC_H, D_SFT, COMBO_END}; +const uint16_t PROGMEM bspcq_combo[] = {KC_I, J_CTLQ, COMBO_END}; +const uint16_t PROGMEM bspcwq_combo[] = {L_GUIQ, F_CTLQ, COMBO_END}; +const uint16_t PROGMEM saveq_combo[] = {S_GUIQ, J_CTLQ, COMBO_END}; + +combo_t key_combos[] = { + [RU_COMBO] = COMBO(ru_combo, RUS_LANG), + [EN_COMBO] = COMBO(en_combo, EN_LANG), + [HEB_COMBO] = COMBO(heb_combo, HEB_LANG), + [ESC_COMBO] = COMBO(esc_combo, KC_ESC), + [TAB_COMBO] = COMBO(tab_combo, KC_TAB), + [ENT_COMBO] = COMBO(ent_combo, KC_ENT), + [DEL_COMBO] = COMBO(del_combo, KC_DEL), + [BSPC_COMBO] = COMBO(bspc_combo, KC_BSPC), + [SAVE_COMBO] = COMBO(save_combo, VIM_SAVE), + [BSPCW_COMBO] = COMBO(bspcw_combo, DELETE_WORD), + + [RUQ_COMBO] = COMBO(ruq_combo, RUS_LANG), + [ENQ_COMBO] = COMBO(enq_combo, EN_LANG), + [HEBQ_COMBO] = COMBO(hebq_combo, HEB_LANG), + [ESCQ_COMBO] = COMBO(escq_combo, KC_ESC), + [TABQ_COMBO] = COMBO(tabq_combo, KC_TAB), + [ENTQ_COMBO] = COMBO(entq_combo, KC_ENT), + [DELQ_COMBO] = COMBO(delq_combo, KC_DEL), + [BSPCQ_COMBO] = COMBO(bspcq_combo, KC_BSPC), + [SAVEQ_COMBO] = COMBO(saveq_combo, VIM_SAVE), + [BSPCWQ_COMBO] = COMBO(bspcwq_combo, DELETE_WORD), +}; + + +#ifdef OLED_ENABLE +oled_rotation_t oled_init_user(oled_rotation_t rotation) { + if (!is_keyboard_master()) { + return OLED_ROTATION_180; // flips the display 180 degrees if offhand + } + return rotation; +} + +#define L_QWERTY 2 +#define L_DVORAK 4 +#define L_LOWER 8 +#define L_RAISE 16 +#define L_TOP 32 +#define L_BOTTOM 64 + +void oled_render_layer_state(void) { + oled_write_P(PSTR("layer: "), false); + if (layer_state < L_QWERTY) { + oled_write_ln_P(PSTR("qwerty"), false); + } else if (layer_state < L_DVORAK) { + oled_write_ln_P(PSTR("dvorak"), false); + } else if (layer_state < L_LOWER) { + oled_write_ln_P(PSTR("lower"), false); + } else if (layer_state < L_RAISE) { + oled_write_ln_P(PSTR("raise"), false); + } else if (layer_state < L_TOP) { + oled_write_ln_P(PSTR("top"), false); + } else if (layer_state < L_BOTTOM) { + oled_write_ln_P(PSTR("bottom"), false); + } else { + oled_write_ln_P(PSTR("unknown"), false); + } +} + + +char keylog_str[24] = {}; + +const char code_to_name[60] = { + ' ', ' ', ' ', ' ', 'a', 'b', 'c', 'd', 'e', 'f', + 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', + 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', + '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', + 'R', 'E', 'B', 'T', '_', '-', '=', '[', ']', '\\', + '#', ';', '\'', '`', ',', '.', '/', ' ', ' ', ' '}; + +void set_keylog(uint16_t keycode, keyrecord_t *record) { + char name = ' '; + if ((keycode >= QK_MOD_TAP && keycode <= QK_MOD_TAP_MAX) || + (keycode >= QK_LAYER_TAP && keycode <= QK_LAYER_TAP_MAX)) { keycode = keycode & 0xFF; } + if (keycode < 60) { + name = code_to_name[keycode]; + } + + // update keylog + snprintf(keylog_str, sizeof(keylog_str), "%dx%d, k%2d : %c", + record->event.key.row, record->event.key.col, + keycode, name); +} + +void oled_render_keylog(void) { + oled_write(keylog_str, false); +} + +void render_bootmagic_status(bool status) { + /* Show Ctrl-Gui Swap options */ + static const char PROGMEM logo[][2][3] = { + {{0x97, 0x98, 0}, {0xb7, 0xb8, 0}}, + {{0x95, 0x96, 0}, {0xb5, 0xb6, 0}}, + }; + if (status) { + oled_write_ln_P(logo[0][0], false); + oled_write_ln_P(logo[0][1], false); + } else { + oled_write_ln_P(logo[1][0], false); + oled_write_ln_P(logo[1][1], false); + } +} + +void oled_render_logo(void) { + static const char PROGMEM crkbd_logo[] = { + 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 0x90, 0x91, 0x92, 0x93, 0x94, + 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, + 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, + 0}; + oled_write_P(crkbd_logo, false); +} + +bool oled_task_user(void) { + if (is_keyboard_master()) { + oled_write_ln_P(PSTR("nice cock"), false); + oled_render_layer_state(); + // oled_render_keylog(); + } else { + oled_render_logo(); + } + return false; +} + +#endif // OLED_ENABLE + +void keyboard_post_init_user(void) { + config.raw = eeconfig_read_user(); + layer_on(_DVORAK); +} + +void set_english_language(void) { + layer_on(_DVORAK); + tap_code16(LSFT(LCTL(LGUI(KC_1)))); // the same as SEND_STRING(SS_LSFT(SS_LCTL(SS_LGUI(SS_TAP(X_1))))); +} + +void set_russian_language(void) { + layer_off(_DVORAK); + tap_code16(LSFT(LCTL(LGUI(KC_2)))); +} + +void set_hebrew_language(void) { + layer_off(_DVORAK); + tap_code16(LSFT(LCTL(LGUI(KC_3)))); +} + +void delete_word(void) { + if (config.is_macos) { + tap_code16(A(KC_BSPC)); + } else { + tap_code16(C(KC_BSPC)); + } +} + +#define CASE(keycode, key_pressed_action, key_released_action) \ + case (keycode): \ + if (record->event.pressed) { \ + key_pressed_action; \ + } else { \ + key_released_action; \ + } \ + return false; \ + break; + +#define CASE_PRESSED(keycode, key_pressed_action) CASE(keycode, key_pressed_action, {}); + +#define CASE_MOD_TAP_KEY(keycode, tap_action, mod_off_action) \ + CASE(keycode, { \ + keycode ## _TIMER = timer_read(); \ + IS_ ## keycode ## _ACTIVE = true; \ + }, { \ + if(IS_ ## keycode ## _MOD_ACTIVE) { \ + mod_off_action; \ + } else if (IS_ ## keycode ## _ACTIVE) { \ + tap_action; \ + } \ + IS_ ## keycode ## _MOD_ACTIVE = false; \ + IS_ ## keycode ## _ACTIVE = false; \ + }); + +#define MOD_TAP_KEY(keycode, tap_action, mod_on_action, mod_off_action) \ +uint16_t keycode ## _TIMER = 0; \ +bool IS_ ## keycode ## _ACTIVE = false; \ +bool IS_ ## keycode ## _MOD_ACTIVE = false; +#include "mod_tap_keys.h" +#undef MOD_TAP_KEY + +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + + #ifdef OLED_ENABLE + if (record->event.pressed) { + set_keylog(keycode, record); + } +#endif //OLED_ENABLE + + switch (keycode) { + CASE_PRESSED(EN_LANG, set_english_language()); + CASE_PRESSED(RUS_LANG, set_russian_language()); + CASE_PRESSED(HEB_LANG, set_hebrew_language()); + + CASE_PRESSED(VIM_SAVE, {set_english_language(); SEND_STRING(SS_TAP(X_ESC)SS_LSFT(SS_TAP(X_SCLN))SS_TAP(X_W)SS_TAP(X_ENT));}); + + CASE_PRESSED(CHNGE_OS, {config.is_macos ^= 1; eeconfig_update_user(config.raw);}); + CASE_PRESSED(DELETE_WORD, delete_word()); + + #define MOD_TAP_KEY(keycode, tap_action, mod_on_action, mod_off_action) \ + CASE_MOD_TAP_KEY(keycode, tap_action, mod_off_action); + #include "mod_tap_keys.h" + #undef MOD_TAP_KEY + } + + #define MOD_TAP_KEY(keycode, tap_action, mod_on_action, mod_off_action) \ + if (IS_ ## keycode ## _ACTIVE && !IS_ ## keycode ## _MOD_ACTIVE) { \ + if (timer_elapsed(keycode ## _TIMER) <= TAPPING_TERM) { \ + tap_action; \ + IS_ ## keycode ## _ACTIVE = false; \ + } \ + } + #include "mod_tap_keys.h" + #undef MOD_TAP_KEY + + return true; +} + +void matrix_scan_user(void) { + #define MOD_TAP_KEY(keycode, tap_action, mod_on_action, mod_off_action) \ + if (IS_ ## keycode ## _ACTIVE) { \ + if (timer_elapsed(keycode ## _TIMER) > TAPPING_TERM) { \ + mod_on_action; \ + IS_ ## keycode ## _MOD_ACTIVE = true; \ + } \ + } + #include "mod_tap_keys.h" + #undef MOD_TAP_KEY +} + diff --git a/keyboards/crkbd/keymaps/antosha417/mod_tap_keys.h b/keyboards/crkbd/keymaps/antosha417/mod_tap_keys.h new file mode 100644 index 000000000000..4526995976e5 --- /dev/null +++ b/keyboards/crkbd/keymaps/antosha417/mod_tap_keys.h @@ -0,0 +1,12 @@ +// MOD_TAP_KEY(key, tap_action, mod_on_action, mod_off_action) + +MOD_TAP_KEY(S_GUIQ, tap_code(KC_S), {layer_on(_DVORAK); register_code(KC_LGUI);}, {layer_off(_DVORAK); unregister_code(KC_LGUI);}) +MOD_TAP_KEY(L_GUIQ, tap_code(KC_L), {layer_on(_DVORAK); register_code(KC_RGUI);}, {layer_off(_DVORAK); unregister_code(KC_RGUI);}) + +MOD_TAP_KEY(F_CTLQ, tap_code(KC_F), {layer_on(_DVORAK); register_code(KC_LCTL);}, {layer_off(_DVORAK); unregister_code(KC_LCTL);}) +MOD_TAP_KEY(J_CTLQ, tap_code(KC_J), {layer_on(_DVORAK); register_code(KC_RCTL);}, {layer_off(_DVORAK); unregister_code(KC_RCTL);}) + +MOD_TAP_KEY(A_ALTQ, tap_code(KC_A), {layer_on(_DVORAK); register_code(KC_LALT);}, {layer_off(_DVORAK); unregister_code(KC_LALT);}) +MOD_TAP_KEY(SCLN_Q, tap_code(KC_SCLN), {layer_on(_DVORAK); register_code(KC_RALT);},{layer_off(_DVORAK); unregister_code(KC_RALT);}) + + diff --git a/keyboards/crkbd/keymaps/antosha417/rules.mk b/keyboards/crkbd/keymaps/antosha417/rules.mk new file mode 100644 index 000000000000..97bea1ab28fc --- /dev/null +++ b/keyboards/crkbd/keymaps/antosha417/rules.mk @@ -0,0 +1,6 @@ +OLED_ENABLE = yes +OLED_DRIVER = SSD1306 +COMBO_ENABLE = yes + +LTO_ENABLE = yes #enable link time optimization to reduce binary size + diff --git a/keyboards/crkbd/keymaps/antosha417/todo.md b/keyboards/crkbd/keymaps/antosha417/todo.md new file mode 100644 index 000000000000..4ee83af65dec --- /dev/null +++ b/keyboards/crkbd/keymaps/antosha417/todo.md @@ -0,0 +1,13 @@ +# Notes: + * to flush firmware to keyboard use: + ``` + $ make crkbd/rev1:antosha417:avrdude-split-right + $ make crkbd/rev1:antosha417:avrdude-split-left + ``` + +# Todo: + [ ] do something with displayig symbols on oled screen + [ ] count wpm + [ ] load images + [X] figure out how to delete word on linux + [X] fix oled layer names From 46af9dadc8583445861535fbded4bc2aea433068 Mon Sep 17 00:00:00 2001 From: antosha417 Date: Fri, 24 Dec 2021 18:44:56 +0200 Subject: [PATCH 02/13] planck keymap --- keyboards/planck/keymaps/antosha417/config.h | 38 ++ keyboards/planck/keymaps/antosha417/keymap.c | 451 ++++++++++++++++++ .../planck/keymaps/antosha417/mod_tap_keys.h | 11 + keyboards/planck/keymaps/antosha417/readme.md | 11 + keyboards/planck/keymaps/antosha417/rules.mk | 4 + 5 files changed, 515 insertions(+) create mode 100644 keyboards/planck/keymaps/antosha417/config.h create mode 100644 keyboards/planck/keymaps/antosha417/keymap.c create mode 100644 keyboards/planck/keymaps/antosha417/mod_tap_keys.h create mode 100644 keyboards/planck/keymaps/antosha417/readme.md create mode 100644 keyboards/planck/keymaps/antosha417/rules.mk diff --git a/keyboards/planck/keymaps/antosha417/config.h b/keyboards/planck/keymaps/antosha417/config.h new file mode 100644 index 000000000000..7691f7bfefa1 --- /dev/null +++ b/keyboards/planck/keymaps/antosha417/config.h @@ -0,0 +1,38 @@ +#pragma once + +#ifdef AUDIO_ENABLE + #define STARTUP_SONG SONG(PLANCK_SOUND) + // #define STARTUP_SONG SONG(NO_SOUND) +#endif + +/* + * MIDI options + */ + +/* Prevent use of disabled MIDI features in the keymap */ +//#define MIDI_ENABLE_STRICT 1 + +/* enable basic MIDI features: + - MIDI notes can be sent when in Music mode is on +*/ + +#define MIDI_BASIC + +/* enable advanced MIDI features: + - MIDI notes can be added to the keymap + - Octave shift and transpose + - Virtual sustain, portamento, and modulation wheel + - etc. +*/ +//#define MIDI_ADVANCED + +/* override number of MIDI tone keycodes (each octave adds 12 keycodes and allocates 12 bytes) */ +//#define MIDI_TONE_KEYCODE_OCTAVES 2 + +// Most tactile encoders have detents every 4 stages +#define ENCODER_RESOLUTION 4 + +#define TAPPING_TERM 200 +#define IGNORE_MOD_TAP_INTERRUPT +#define COMBO_TERM 30 + diff --git a/keyboards/planck/keymaps/antosha417/keymap.c b/keyboards/planck/keymaps/antosha417/keymap.c new file mode 100644 index 000000000000..08f742e52cc9 --- /dev/null +++ b/keyboards/planck/keymaps/antosha417/keymap.c @@ -0,0 +1,451 @@ +#include QMK_KEYBOARD_H +#include +#include "muse.h" + +extern keymap_config_t keymap_config; + +enum layers { + _QWERTY, + _DVORAK, + _LOWER, + _RAISE, + _TOP, + _BOTTOM, + _ADJUST +}; + +float USSR_SONG[][2] = SONG(B__NOTE(_G6), + B__NOTE(_C7), W__NOTE(_G6), H__NOTE(_A6), + B__NOTE(_B6), W__NOTE(_E6), W__NOTE(_E6), + B__NOTE(_A6), W__NOTE(_G6), H__NOTE(_F6), + B__NOTE(_G6), W__NOTE(_C6), W__NOTE(_C6), + B__NOTE(_D6), W__NOTE(_D6), W__NOTE(_E6), + B__NOTE(_D6), W__NOTE(_D6), W__NOTE(_G6), + B__NOTE(_F6), W__NOTE(_G6), W__NOTE(_A6), + B__NOTE(_B6), + ); + +enum keycodes { + QWERTY = SAFE_RANGE, + + RUS_LANG, + EN_LANG, + HEB_LANG, + + BRUDERSCHAFT, + VIM_SAVE, + +#define MOD_TAP_KEY(keycode, tap_action, mod_on_action, mod_off_action) \ + keycode, +#include "mod_tap_keys.h" +#undef MOD_TAP_KEY +}; + +#define LOWER MO(_LOWER) +#define RAISE MO(_RAISE) +#define TOP MO(_TOP) +#define BOTTOM MO(_BOTTOM) +#define LANG TG(_DVORAK) +#define KC_CAD LALT(LCTL(KC_DEL)) +#define KC_CAH LALT(LCTL(KC_HOME)) + +#define E_SFT LSFT_T(KC_E) +#define D_SFT LSFT_T(KC_D) +#define A_ALT LALT_T(KC_A) +#define O_GUI LGUI_T(KC_O) +#define U_CTRL LCTL_T(KC_U) + +#define T_SFT RSFT_T(KC_T) +#define K_SFT RSFT_T(KC_K) +#define S_ALT RALT_T(KC_S) +#define N_GUI RGUI_T(KC_N) +#define H_CTRL RCTL_T(KC_H) + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + +/* Qwerty + * ,-----------------------------------------------------------------------------------. + * | | Q | W | E | R | T | Y | U | I | O | P | | + * |------+------+------+------+------+------+------+------+------+------+------+------| + * | | A | S | D | F | G | H | J | K | L | ; | | + * |------+------+------+------+------+------+------+------+------+------+------+------| + * | | Z | X | C | V | B | N | M | , | . | / | | + * |------+------+------+------+------+------+------+------+------+------+------+------| + * | | | |Bottom| SPC |Lower |Raise | SPC | TOP | | | | + * `-----------------------------------------------------------------------------------' + */ +[_QWERTY] = LAYOUT_planck_grid( + _______, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, _______, + _______, A_ALTQ, S_GUIQ, D_SFT, F_CTLQ, KC_G, KC_H, J_CTLQ, K_SFT, L_GUIQ, SCLN_Q, _______, + _______, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, _______, + _______, _______, _______, BOTTOM, KC_SPC, LOWER, RAISE, KC_SPC, TOP, _______, _______, _______ +), + +/* Dvorak + * ,-----------------------------------------------------------------------------------. + * | | ' | , | . | P | Y | F | G | C | R | L | | + * |------+------+------+------+------+-------------+------+------+------+------+------| + * | | A | O | E | U | I | D | H | T | N | S | | + * |------+------+------+------+------+------+------+------+------+------+------+------| + * | | ; | Q | J | K | X | B | M | W | V | Z | | + * |------+------+------+------+------+------+------+------+------+------+------+------| + * | | | | | | | | | | | | | + * `-----------------------------------------------------------------------------------' + */ +[_DVORAK] = LAYOUT_planck_grid( + _______, KC_QUOT, KC_COMM, KC_DOT, KC_P, KC_Y, KC_F, KC_G, KC_C, KC_R, KC_L, _______, + _______, A_ALT, O_GUI, E_SFT, U_CTRL, KC_I, KC_D, H_CTRL, T_SFT, N_GUI, S_ALT, _______, + _______, KC_SCLN, KC_Q, KC_J, KC_K, KC_X, KC_B, KC_M, KC_W, KC_V, KC_Z, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ +), + + +/* Lower + * ,-----------------------------------------------------------------------------------. + * | F11 | _ | - | ~ | % | ' | | ^ | ` | \ | | | - | + * |------+------+------+------+------+-------------+------+------+------+------+------| + * | Del | [ | { | + | ( | = | * | ) | ! | } | ] | Bksp | + * |------+------+------+------+------+------+------+------+------+------+------+------| + * | | CAD | CAH | | LANG | | | EN | HEB | RUS | | | + * |------+------+------+------+------+------+------+------+------+------+------+------| + * | | RCTL | | | | [{}] | | | PSCR | PGDN | PGUP | | + * `-----------------------------------------------------------------------------------' + */ +[_LOWER] = LAYOUT_planck_grid( + KC_F11, KC_UNDS, KC_MINS, KC_TILD, KC_PERC, KC_QUOT, _______, KC_CIRC, KC_GRV, KC_BSLS, KC_PIPE, KC_MINS, + KC_DEL, KC_LBRC, KC_LCBR, KC_PLUS, KC_LPRN, KC_EQL, KC_ASTR, KC_RPRN, KC_EXLM, KC_RCBR, KC_RBRC, KC_BSPC, + _______, KC_CAD, KC_CAH, _______, LANG, _______, _______, HEB_LANG, EN_LANG, RUS_LANG, _______, _______, + _______, KC_RCTL, _______, _______, _______, _______, _______, _______, KC_PSCR, KC_PGDN, KC_PGUP, _______ +), + +/* Raise + * ,-----------------------------------------------------------------------------------. + * | F11 | | | $ | & | | : | ? | @ | # | / | F12 | + * |------+------+------+------+------+-------------+------+------+------+------+------| + * | | 7 | 5 | 3 | 1 | 9 | 0 | 2 | 4 | 6 | 8 | Bksp | + * |------+------+------+------+------+------+------+------+------+------+------+------| + * | | F7 | F5 | F3 | F1 | F9 | F10 | F2 | F4 | F6 | F8 | | + * |------+------+------+------+------+------+------+------+------+------+------+------| + * | | | | | | | [{}] | | Vol- | End | Home | Vol+ | + * `-----------------------------------------------------------------------------------' + */ +[_RAISE] = LAYOUT_planck_grid( + KC_F11, _______, _______, KC_DLR, KC_AMPR, _______, KC_COLON, KC_QUES, KC_AT, KC_HASH, KC_SLSH, KC_F12, + _______, KC_7, KC_5, KC_3, KC_1, KC_9, KC_0, KC_2, KC_4, KC_6, KC_8, KC_BSPC, + _______, KC_F7, KC_F5, KC_F3, KC_F1, KC_F9, KC_F10, KC_F2, KC_F4, KC_F6, KC_F8, _______, + _______, _______, _______, _______, _______, _______, _______, _______, KC_VOLD, KC_END, KC_HOME, KC_VOLU +), + +/* TOP + * ,----------------------------------------------------------------------------------- + * | | | | | | | | | | | | | + * |------+------+------+------+------+------+------+------+------+------+------+------| + * | | | | | | | | | | | | | + * |------+------+------+------+------+------+------+------+------+------+------+------| + * | | | | Down | Up | | | | | | | | + * |------+------+------+------+------+------+------+------+------+------+------+------| + * | | | | | | | | | [{}] | | | | + * `-----------------------------------------------------------------------------------' + */ +[_TOP] = LAYOUT_planck_grid( + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, KC_DOWN, KC_UP, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ +), + +/* BOTTOM + * ,----------------------------------------------------------------------------------- + * | | | | | | | | | | | -> | | + * |------+------+------+------+------+------+------+------+------+------+------+------| + * | | | | | | | | <- | | | | | + * |------+------+------+------+------+------+------+------+------+------+------+------| + * | | | | | | | | vold | volu | | | | + * |------+------+------+------+------+------+------+------+------+------+------+------| + * | | | | [{}] | | | | | | | | | + * `-----------------------------------------------------------------------------------' + */ +[_BOTTOM] = LAYOUT_planck_grid( + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_RGHT, _______, + _______, _______, _______, _______, _______, _______, _______, KC_LEFT, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, KC_VOLD, KC_VOLU, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ +), + +/* Adjust (Lower + Raise) + * v------------------------RGB CONTROL--------------------v + * ,----------------------------------------------------------------------------------- + * | | Reset|Debug | RGB |RGBMOD| HUE+ | HUE- | SAT+ | SAT- |BRGTH+|BRGTH-| Del | + * |------+------+------+------+------+------+------+------+------+------+------+------| + * | |Aud on|Audoff| | | | | | |Dvorak| | | + * |------+------+------+------+------+------+------+------+------+------+------+------| + * | |Mus on|Musoff| | | | | | | | | USSR | + * |------+------+------+------+------+------+------+------+------+------+------+------| + * | | | | | | [{}] | [{}] | | | | | | + * `-----------------------------------------------------------------------------------' + */ +[_ADJUST] = LAYOUT_planck_grid( + _______, RESET, DEBUG, RGB_TOG, RGB_MOD, RGB_HUI, RGB_HUD, RGB_SAI, RGB_SAD, RGB_VAI, RGB_VAD, KC_DEL , + _______, AU_ON, AU_OFF, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, MU_ON, MU_OFF, _______, _______, _______, _______, _______, _______, _______, _______, BRUDERSCHAFT, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ +) + +}; + +void keyboard_post_init_user(void) { + layer_on(_DVORAK); +} + +void set_english_language(void) { + layer_on(_DVORAK); + SEND_STRING(SS_LSFT(SS_LCTL(SS_LGUI(SS_TAP(X_1))))); +} + +void set_russian_language(void) { + layer_off(_DVORAK); + SEND_STRING(SS_LSFT(SS_LCTL(SS_LGUI(SS_TAP(X_2))))); +} + +void set_hebrew_language(void) { + layer_off(_DVORAK); + SEND_STRING(SS_LSFT(SS_LCTL(SS_LGUI(SS_TAP(X_3))))); +} + + +#define CASE(keycode, key_pressed_action, key_released_action) \ + case (keycode): \ + if (record->event.pressed) { \ + key_pressed_action; \ + } else { \ + key_released_action; \ + } \ + return false; \ + break; + +#define CASE_PRESSED(keycode, key_pressed_action) CASE(keycode, key_pressed_action, {}); + +#define CASE_MOD_TAP_KEY(keycode, tap_action, mod_off_action) \ + CASE(keycode, { \ + keycode ## _TIMER = timer_read(); \ + IS_ ## keycode ## _ACTIVE = true; \ + }, { \ + if(IS_ ## keycode ## _MOD_ACTIVE) { \ + mod_off_action; \ + } else if (IS_ ## keycode ## _ACTIVE) { \ + tap_action; \ + } \ + IS_ ## keycode ## _MOD_ACTIVE = false; \ + IS_ ## keycode ## _ACTIVE = false; \ + }); + +#define MOD_TAP_KEY(keycode, tap_action, mod_on_action, mod_off_action) \ +uint16_t keycode ## _TIMER = 0; \ +bool IS_ ## keycode ## _ACTIVE = false; \ +bool IS_ ## keycode ## _MOD_ACTIVE = false; +#include "mod_tap_keys.h" +#undef MOD_TAP_KEY + +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + switch (keycode) { + CASE_PRESSED(BRUDERSCHAFT, PLAY_SONG(USSR_SONG)); + + CASE_PRESSED(EN_LANG, set_english_language()); + CASE_PRESSED(RUS_LANG, set_russian_language()); + CASE_PRESSED(HEB_LANG, set_hebrew_language()); + + CASE_PRESSED(VIM_SAVE, {set_english_language(); SEND_STRING(SS_TAP(X_ESC)SS_LSFT(SS_TAP(X_SCLN))SS_TAP(X_W)SS_TAP(X_ENT));}); + + #define MOD_TAP_KEY(keycode, tap_action, mod_on_action, mod_off_action) \ + CASE_MOD_TAP_KEY(keycode, tap_action, mod_off_action); + #include "mod_tap_keys.h" + #undef MOD_TAP_KEY + } + + #define MOD_TAP_KEY(keycode, tap_action, mod_on_action, mod_off_action) \ + if (IS_ ## keycode ## _ACTIVE && !IS_ ## keycode ## _MOD_ACTIVE) { \ + if (timer_elapsed(keycode ## _TIMER) <= TAPPING_TERM) { \ + tap_action; \ + IS_ ## keycode ## _ACTIVE = false; \ + } \ + } + #include "mod_tap_keys.h" + #undef MOD_TAP_KEY + + return true; +} + +bool muse_mode = false; +uint8_t last_muse_note = 0; +uint16_t muse_counter = 0; +uint8_t muse_offset = 70; +uint16_t muse_tempo = 50; + +void encoder_update(bool clockwise) { + if (muse_mode) { + if (IS_LAYER_ON(_RAISE)) { + if (clockwise) { + muse_offset++; + } else { + muse_offset--; + } + } else { + if (clockwise) { + muse_tempo+=1; + } else { + muse_tempo-=1; + } + } + } else { + if (clockwise) { + #ifdef MOUSEKEY_ENABLE + tap_code(KC_MS_WH_DOWN); + #else + tap_code(KC_PGDN); + #endif + } else { + #ifdef MOUSEKEY_ENABLE + tap_code(KC_MS_WH_UP); + #else + tap_code(KC_PGUP); + #endif + } + } +} + +bool dip_switch_update_user(uint8_t index, bool active) { + switch (index) { + case 0: + if (active) { + layer_off(_ADJUST); + } + break; + case 1: + if (active) { + muse_mode = true; + } else { + muse_mode = false; + #ifdef AUDIO_ENABLE + stop_all_notes(); + #endif + } + } + return true; +} + +void matrix_scan_user(void) { + #define MOD_TAP_KEY(keycode, tap_action, mod_on_action, mod_off_action) \ + if (IS_ ## keycode ## _ACTIVE) { \ + if (timer_elapsed(keycode ## _TIMER) > TAPPING_TERM) { \ + mod_on_action; \ + IS_ ## keycode ## _MOD_ACTIVE = true; \ + } \ + } + #include "mod_tap_keys.h" + #undef MOD_TAP_KEY + + #ifdef AUDIO_ENABLE + if (muse_mode) { + if (muse_counter == 0) { + uint8_t muse_note = muse_offset + SCALE[muse_clock_pulse()]; + if (muse_note != last_muse_note) { + stop_note(compute_freq_for_midi_note(last_muse_note)); + play_note(compute_freq_for_midi_note(muse_note), 0xF); + last_muse_note = muse_note; + } + } + muse_counter = (muse_counter + 1) % muse_tempo; + } + #endif +} + +bool music_mask_user(uint16_t keycode) { + switch (keycode) { + case RAISE: + case LOWER: + return false; + default: + return true; + } +} + +layer_state_t layer_state_set_user(layer_state_t state) { + return update_tri_layer_state(state, _LOWER, _RAISE, _ADJUST); +} + +enum combo_events { + // combos for dvorak layer + RU_COMBO, + EN_COMBO, + HEB_COMBO, + ESC_COMBO, + TAB_COMBO, + ENT_COMBO, + DEL_COMBO, + SAVE_COMBO, + BSPC_COMBO, + BSPCW_COMBO, + + // combos for qwerty layer + RUQ_COMBO, + ENQ_COMBO, + HEBQ_COMBO, + ESCQ_COMBO, + TABQ_COMBO, + ENTQ_COMBO, + DELQ_COMBO, + SAVEQ_COMBO, + BSPCQ_COMBO, + BSPCWQ_COMBO, + + COMBO_LENGTH +}; +uint16_t COMBO_LEN = COMBO_LENGTH; + +const uint16_t PROGMEM ru_combo[] = {KC_R, U_CTRL, COMBO_END}; +const uint16_t PROGMEM en_combo[] = {U_CTRL, S_ALT, COMBO_END}; +const uint16_t PROGMEM heb_combo[] = {KC_I, KC_V, COMBO_END}; +const uint16_t PROGMEM esc_combo[] = {H_CTRL, U_CTRL, COMBO_END}; +const uint16_t PROGMEM tab_combo[] = {T_SFT, A_ALT, COMBO_END}; +const uint16_t PROGMEM ent_combo[] = {E_SFT, N_GUI, COMBO_END}; +const uint16_t PROGMEM del_combo[] = {KC_D, E_SFT, COMBO_END}; +const uint16_t PROGMEM bspc_combo[] = {KC_C, H_CTRL, COMBO_END}; +const uint16_t PROGMEM bspcw_combo[] = {N_GUI, U_CTRL, COMBO_END}; +const uint16_t PROGMEM save_combo[] = {O_GUI, H_CTRL, COMBO_END}; + +const uint16_t PROGMEM ruq_combo[] = {KC_O, F_CTLQ, COMBO_END}; +const uint16_t PROGMEM enq_combo[] = {F_CTLQ, SCLN_Q, COMBO_END}; +const uint16_t PROGMEM hebq_combo[] = {KC_G, KC_DOT, COMBO_END}; +const uint16_t PROGMEM escq_combo[] = {F_CTLQ, J_CTLQ, COMBO_END}; +const uint16_t PROGMEM tabq_combo[] = {K_SFT, A_ALTQ, COMBO_END}; +const uint16_t PROGMEM entq_combo[] = {D_SFT, L_GUIQ, COMBO_END}; +const uint16_t PROGMEM delq_combo[] = {KC_H, D_SFT, COMBO_END}; +const uint16_t PROGMEM bspcq_combo[] = {KC_I, J_CTLQ, COMBO_END}; +const uint16_t PROGMEM bspcwq_combo[] = {L_GUIQ, F_CTLQ, COMBO_END}; +const uint16_t PROGMEM saveq_combo[] = {S_GUIQ, J_CTLQ, COMBO_END}; + +combo_t key_combos[] = { + [RU_COMBO] = COMBO(ru_combo, RUS_LANG), + [EN_COMBO] = COMBO(en_combo, EN_LANG), + [HEB_COMBO] = COMBO(heb_combo, HEB_LANG), + [ESC_COMBO] = COMBO(esc_combo, KC_ESC), + [TAB_COMBO] = COMBO(tab_combo, KC_TAB), + [ENT_COMBO] = COMBO(ent_combo, KC_ENT), + [DEL_COMBO] = COMBO(del_combo, KC_DEL), + [BSPC_COMBO] = COMBO(bspc_combo, KC_BSPC), + [SAVE_COMBO] = COMBO(save_combo, VIM_SAVE), + [BSPCW_COMBO] = COMBO(bspcw_combo, A(KC_BSPC)), + + [RUQ_COMBO] = COMBO(ruq_combo, RUS_LANG), + [ENQ_COMBO] = COMBO(enq_combo, EN_LANG), + [HEBQ_COMBO] = COMBO(hebq_combo, HEB_LANG), + [ESCQ_COMBO] = COMBO(escq_combo, KC_ESC), + [TABQ_COMBO] = COMBO(tabq_combo, KC_TAB), + [ENTQ_COMBO] = COMBO(entq_combo, KC_ENT), + [DELQ_COMBO] = COMBO(delq_combo, KC_DEL), + [BSPCQ_COMBO] = COMBO(bspcq_combo, KC_BSPC), + [SAVEQ_COMBO] = COMBO(saveq_combo, VIM_SAVE), + [BSPCWQ_COMBO] = COMBO(bspcwq_combo, A(KC_BSPC)), +}; + + diff --git a/keyboards/planck/keymaps/antosha417/mod_tap_keys.h b/keyboards/planck/keymaps/antosha417/mod_tap_keys.h new file mode 100644 index 000000000000..b91c246cbd63 --- /dev/null +++ b/keyboards/planck/keymaps/antosha417/mod_tap_keys.h @@ -0,0 +1,11 @@ +// MOD_TAP_KEY(key, tap_action, mod_on_action, mod_off_action) + +MOD_TAP_KEY(S_GUIQ, tap_code(KC_S), {layer_on(_DVORAK); register_code(KC_LGUI);}, {layer_off(_DVORAK); unregister_code(KC_LGUI);}) +MOD_TAP_KEY(L_GUIQ, tap_code(KC_L), {layer_on(_DVORAK); register_code(KC_RGUI);}, {layer_off(_DVORAK); unregister_code(KC_RGUI);}) + +MOD_TAP_KEY(F_CTLQ, tap_code(KC_F), {layer_on(_DVORAK); register_code(KC_LCTL);}, {layer_off(_DVORAK); unregister_code(KC_LCTL);}) +MOD_TAP_KEY(J_CTLQ, tap_code(KC_J), {layer_on(_DVORAK); register_code(KC_RCTL);}, {layer_off(_DVORAK); unregister_code(KC_RCTL);}) + +MOD_TAP_KEY(A_ALTQ, tap_code(KC_A), {layer_on(_DVORAK); register_code(KC_LALT);}, {layer_off(_DVORAK); unregister_code(KC_LALT);}) +MOD_TAP_KEY(SCLN_Q, tap_code(KC_SCLN), {layer_on(_DVORAK); register_code(KC_RALT);}, {layer_off(_DVORAK); unregister_code(KC_RALT);}) + diff --git a/keyboards/planck/keymaps/antosha417/readme.md b/keyboards/planck/keymaps/antosha417/readme.md new file mode 100644 index 000000000000..3c6f7077edc5 --- /dev/null +++ b/keyboards/planck/keymaps/antosha417/readme.md @@ -0,0 +1,11 @@ +# How to install: + ```console + $ make planck/rev6:antosha417:dfu-util + ``` +# Useful: + * [keycodes](https://docs.qmk.fm/#/keycodes) + * [string keycodes](https://github.com/qmk/qmk_firmware/blob/master/quantum/send_string_keycodes.h) + +# Todo: + [ ] sync with corne + diff --git a/keyboards/planck/keymaps/antosha417/rules.mk b/keyboards/planck/keymaps/antosha417/rules.mk new file mode 100644 index 000000000000..469769525216 --- /dev/null +++ b/keyboards/planck/keymaps/antosha417/rules.mk @@ -0,0 +1,4 @@ +SRC += muse.c +AUDIO_ENABLE = yes +COMBO_ENABLE = yes + From 4c8a616acf88697ba7a18ebf79fc2d1201234e4a Mon Sep 17 00:00:00 2001 From: antosha417 Date: Fri, 14 Jan 2022 19:54:55 +0200 Subject: [PATCH 03/13] add copyright. fix review --- keyboards/crkbd/keymaps/antosha417/config.h | 13 +++- keyboards/crkbd/keymaps/antosha417/keymap.c | 73 +++++++------------ .../crkbd/keymaps/antosha417/mod_tap_keys.h | 3 + keyboards/crkbd/keymaps/antosha417/rules.mk | 1 - keyboards/planck/keymaps/antosha417/config.h | 2 + keyboards/planck/keymaps/antosha417/keymap.c | 7 +- .../planck/keymaps/antosha417/mod_tap_keys.h | 3 + 7 files changed, 50 insertions(+), 52 deletions(-) diff --git a/keyboards/crkbd/keymaps/antosha417/config.h b/keyboards/crkbd/keymaps/antosha417/config.h index 2254d34b1213..c82134d609a0 100644 --- a/keyboards/crkbd/keymaps/antosha417/config.h +++ b/keyboards/crkbd/keymaps/antosha417/config.h @@ -1,3 +1,5 @@ +// Copyright 2021 Anton Kavalkou (@antosha417) +// SPDX-License-Identifier: GPL-2.0-or-later #pragma once //#define USE_MATRIX_I2C @@ -14,7 +16,16 @@ #ifdef RGBLIGHT_ENABLE #undef RGBLED_NUM - #define RGBLIGHT_ANIMATIONS + #define RGBLIGHT_EFFECT_BREATHING + #define RGBLIGHT_EFFECT_RAINBOW_MOOD + #define RGBLIGHT_EFFECT_RAINBOW_SWIRL + #define RGBLIGHT_EFFECT_SNAKE + #define RGBLIGHT_EFFECT_KNIGHT + #define RGBLIGHT_EFFECT_CHRISTMAS + #define RGBLIGHT_EFFECT_STATIC_GRADIENT + #define RGBLIGHT_EFFECT_RGB_TEST + #define RGBLIGHT_EFFECT_ALTERNATING + #define RGBLIGHT_EFFECT_TWINKLE #define RGBLED_NUM 27 #define RGBLIGHT_LIMIT_VAL 120 #define RGBLIGHT_HUE_STEP 10 diff --git a/keyboards/crkbd/keymaps/antosha417/keymap.c b/keyboards/crkbd/keymaps/antosha417/keymap.c index cf9c6d9ed205..db3a0b059ab5 100644 --- a/keyboards/crkbd/keymaps/antosha417/keymap.c +++ b/keyboards/crkbd/keymaps/antosha417/keymap.c @@ -1,6 +1,7 @@ +// Copyright 2021 Anton Kavalkou (@antosha417) +// SPDX-License-Identifier: GPL-2.0-or-later #include QMK_KEYBOARD_H #include -#include typedef union { uint32_t raw; @@ -234,52 +235,31 @@ oled_rotation_t oled_init_user(oled_rotation_t rotation) { void oled_render_layer_state(void) { oled_write_P(PSTR("layer: "), false); - if (layer_state < L_QWERTY) { - oled_write_ln_P(PSTR("qwerty"), false); - } else if (layer_state < L_DVORAK) { - oled_write_ln_P(PSTR("dvorak"), false); - } else if (layer_state < L_LOWER) { - oled_write_ln_P(PSTR("lower"), false); - } else if (layer_state < L_RAISE) { - oled_write_ln_P(PSTR("raise"), false); - } else if (layer_state < L_TOP) { - oled_write_ln_P(PSTR("top"), false); - } else if (layer_state < L_BOTTOM) { - oled_write_ln_P(PSTR("bottom"), false); - } else { - oled_write_ln_P(PSTR("unknown"), false); + switch (get_highest_layer(layer_state|default_layer_state)) { + case _QWERTY: + oled_write_ln_P(PSTR("qwerty"), false); + break + case _DVORAK: + oled_write_ln_P(PSTR("dvorak"), false); + break; + case _LOWER: + oled_write_ln_P(PSTR("lower"), false); + break; + case_RAISE: + oled_write_ln_P(PSTR("raise"), false); + break; + case _TOP: + oled_write_ln_P(PSTR("top"), false); + break; + case _BOTTOM: + oled_write_ln_P(PSTR("bottom"), false); + break; + default: + oled_write_ln_P(PSTR("unknown"), false); + break; } } - -char keylog_str[24] = {}; - -const char code_to_name[60] = { - ' ', ' ', ' ', ' ', 'a', 'b', 'c', 'd', 'e', 'f', - 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', - 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', - '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', - 'R', 'E', 'B', 'T', '_', '-', '=', '[', ']', '\\', - '#', ';', '\'', '`', ',', '.', '/', ' ', ' ', ' '}; - -void set_keylog(uint16_t keycode, keyrecord_t *record) { - char name = ' '; - if ((keycode >= QK_MOD_TAP && keycode <= QK_MOD_TAP_MAX) || - (keycode >= QK_LAYER_TAP && keycode <= QK_LAYER_TAP_MAX)) { keycode = keycode & 0xFF; } - if (keycode < 60) { - name = code_to_name[keycode]; - } - - // update keylog - snprintf(keylog_str, sizeof(keylog_str), "%dx%d, k%2d : %c", - record->event.key.row, record->event.key.col, - keycode, name); -} - -void oled_render_keylog(void) { - oled_write(keylog_str, false); -} - void render_bootmagic_status(bool status) { /* Show Ctrl-Gui Swap options */ static const char PROGMEM logo[][2][3] = { @@ -306,9 +286,8 @@ void oled_render_logo(void) { bool oled_task_user(void) { if (is_keyboard_master()) { - oled_write_ln_P(PSTR("nice cock"), false); + oled_write_ln_P(PSTR("nice cock"), false); oled_render_layer_state(); - // oled_render_keylog(); } else { oled_render_logo(); } @@ -324,7 +303,7 @@ void keyboard_post_init_user(void) { void set_english_language(void) { layer_on(_DVORAK); - tap_code16(LSFT(LCTL(LGUI(KC_1)))); // the same as SEND_STRING(SS_LSFT(SS_LCTL(SS_LGUI(SS_TAP(X_1))))); + tap_code16(LSFT(LCTL(LGUI(KC_1)))); } void set_russian_language(void) { diff --git a/keyboards/crkbd/keymaps/antosha417/mod_tap_keys.h b/keyboards/crkbd/keymaps/antosha417/mod_tap_keys.h index 4526995976e5..0d7a86b69131 100644 --- a/keyboards/crkbd/keymaps/antosha417/mod_tap_keys.h +++ b/keyboards/crkbd/keymaps/antosha417/mod_tap_keys.h @@ -1,3 +1,6 @@ +// Copyright 2021 Anton Kavalkou (@antosha417) +// SPDX-License-Identifier: GPL-2.0-or-later + // MOD_TAP_KEY(key, tap_action, mod_on_action, mod_off_action) MOD_TAP_KEY(S_GUIQ, tap_code(KC_S), {layer_on(_DVORAK); register_code(KC_LGUI);}, {layer_off(_DVORAK); unregister_code(KC_LGUI);}) diff --git a/keyboards/crkbd/keymaps/antosha417/rules.mk b/keyboards/crkbd/keymaps/antosha417/rules.mk index 97bea1ab28fc..63a3a16616f4 100644 --- a/keyboards/crkbd/keymaps/antosha417/rules.mk +++ b/keyboards/crkbd/keymaps/antosha417/rules.mk @@ -1,5 +1,4 @@ OLED_ENABLE = yes -OLED_DRIVER = SSD1306 COMBO_ENABLE = yes LTO_ENABLE = yes #enable link time optimization to reduce binary size diff --git a/keyboards/planck/keymaps/antosha417/config.h b/keyboards/planck/keymaps/antosha417/config.h index 7691f7bfefa1..c9b85348b721 100644 --- a/keyboards/planck/keymaps/antosha417/config.h +++ b/keyboards/planck/keymaps/antosha417/config.h @@ -1,3 +1,5 @@ +// Copyright 2021 Anton Kavalkou (@antosha417) +// SPDX-License-Identifier: GPL-2.0-or-later #pragma once #ifdef AUDIO_ENABLE diff --git a/keyboards/planck/keymaps/antosha417/keymap.c b/keyboards/planck/keymaps/antosha417/keymap.c index 08f742e52cc9..b2b944e30c71 100644 --- a/keyboards/planck/keymaps/antosha417/keymap.c +++ b/keyboards/planck/keymaps/antosha417/keymap.c @@ -1,9 +1,9 @@ +// Copyright 2021 Anton Kavalkou (@antosha417) +// SPDX-License-Identifier: GPL-2.0-or-later #include QMK_KEYBOARD_H #include #include "muse.h" -extern keymap_config_t keymap_config; - enum layers { _QWERTY, _DVORAK, @@ -281,7 +281,7 @@ uint16_t muse_counter = 0; uint8_t muse_offset = 70; uint16_t muse_tempo = 50; -void encoder_update(bool clockwise) { +bool encoder_update_user(uint8_t index, bool clockwise) { if (muse_mode) { if (IS_LAYER_ON(_RAISE)) { if (clockwise) { @@ -311,6 +311,7 @@ void encoder_update(bool clockwise) { #endif } } + return false; } bool dip_switch_update_user(uint8_t index, bool active) { diff --git a/keyboards/planck/keymaps/antosha417/mod_tap_keys.h b/keyboards/planck/keymaps/antosha417/mod_tap_keys.h index b91c246cbd63..aa82f9692cc0 100644 --- a/keyboards/planck/keymaps/antosha417/mod_tap_keys.h +++ b/keyboards/planck/keymaps/antosha417/mod_tap_keys.h @@ -1,3 +1,6 @@ +// Copyright 2021 Anton Kavalkou (@antosha417) +// SPDX-License-Identifier: GPL-2.0-or-later + // MOD_TAP_KEY(key, tap_action, mod_on_action, mod_off_action) MOD_TAP_KEY(S_GUIQ, tap_code(KC_S), {layer_on(_DVORAK); register_code(KC_LGUI);}, {layer_off(_DVORAK); unregister_code(KC_LGUI);}) From df1be4a3bf9f157dee0e880e010a4b58d96acef7 Mon Sep 17 00:00:00 2001 From: antosha417 Date: Fri, 14 Jan 2022 20:09:25 +0200 Subject: [PATCH 04/13] remode unused define statements --- keyboards/crkbd/keymaps/antosha417/keymap.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/keyboards/crkbd/keymaps/antosha417/keymap.c b/keyboards/crkbd/keymaps/antosha417/keymap.c index db3a0b059ab5..20b05d424502 100644 --- a/keyboards/crkbd/keymaps/antosha417/keymap.c +++ b/keyboards/crkbd/keymaps/antosha417/keymap.c @@ -226,13 +226,6 @@ oled_rotation_t oled_init_user(oled_rotation_t rotation) { return rotation; } -#define L_QWERTY 2 -#define L_DVORAK 4 -#define L_LOWER 8 -#define L_RAISE 16 -#define L_TOP 32 -#define L_BOTTOM 64 - void oled_render_layer_state(void) { oled_write_P(PSTR("layer: "), false); switch (get_highest_layer(layer_state|default_layer_state)) { From eca16cfa591c24843cc225bfe62cb0ad3517f094 Mon Sep 17 00:00:00 2001 From: Anton <14187674+antosha417@users.noreply.github.com> Date: Sat, 22 Jan 2022 18:53:49 +0200 Subject: [PATCH 05/13] Update keyboards/crkbd/keymaps/antosha417/config.h Co-authored-by: Drashna Jaelre --- keyboards/crkbd/keymaps/antosha417/config.h | 1 - 1 file changed, 1 deletion(-) diff --git a/keyboards/crkbd/keymaps/antosha417/config.h b/keyboards/crkbd/keymaps/antosha417/config.h index c82134d609a0..effa93a375bc 100644 --- a/keyboards/crkbd/keymaps/antosha417/config.h +++ b/keyboards/crkbd/keymaps/antosha417/config.h @@ -2,7 +2,6 @@ // SPDX-License-Identifier: GPL-2.0-or-later #pragma once -//#define USE_MATRIX_I2C /* Select hand configuration */ From f6b8851fab0e3af417b799c23618db053823a742 Mon Sep 17 00:00:00 2001 From: Anton <14187674+antosha417@users.noreply.github.com> Date: Sat, 22 Jan 2022 18:53:59 +0200 Subject: [PATCH 06/13] Update keyboards/crkbd/keymaps/antosha417/config.h Co-authored-by: Drashna Jaelre --- keyboards/crkbd/keymaps/antosha417/config.h | 1 - 1 file changed, 1 deletion(-) diff --git a/keyboards/crkbd/keymaps/antosha417/config.h b/keyboards/crkbd/keymaps/antosha417/config.h index effa93a375bc..8f4c20613eac 100644 --- a/keyboards/crkbd/keymaps/antosha417/config.h +++ b/keyboards/crkbd/keymaps/antosha417/config.h @@ -9,7 +9,6 @@ // #define MASTER_RIGHT #define EE_HANDS -#define USE_SERIAL_PD2 #define TAPPING_FORCE_HOLD From 81d96ea8ae517685471ddfc9fb59ba58cb8979c6 Mon Sep 17 00:00:00 2001 From: Anton <14187674+antosha417@users.noreply.github.com> Date: Sun, 23 Jan 2022 10:19:01 +0200 Subject: [PATCH 07/13] Update keyboards/planck/keymaps/antosha417/config.h Co-authored-by: Ryan --- keyboards/planck/keymaps/antosha417/config.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/keyboards/planck/keymaps/antosha417/config.h b/keyboards/planck/keymaps/antosha417/config.h index c9b85348b721..92fe152663ea 100644 --- a/keyboards/planck/keymaps/antosha417/config.h +++ b/keyboards/planck/keymaps/antosha417/config.h @@ -11,9 +11,6 @@ * MIDI options */ -/* Prevent use of disabled MIDI features in the keymap */ -//#define MIDI_ENABLE_STRICT 1 - /* enable basic MIDI features: - MIDI notes can be sent when in Music mode is on */ From a7cfaa51c94a21267c930432d5081b1ea9336495 Mon Sep 17 00:00:00 2001 From: Anton <14187674+antosha417@users.noreply.github.com> Date: Sun, 23 Jan 2022 10:19:12 +0200 Subject: [PATCH 08/13] Update keyboards/planck/keymaps/antosha417/config.h Co-authored-by: Ryan --- keyboards/planck/keymaps/antosha417/config.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/keyboards/planck/keymaps/antosha417/config.h b/keyboards/planck/keymaps/antosha417/config.h index 92fe152663ea..9bbb1192c7d7 100644 --- a/keyboards/planck/keymaps/antosha417/config.h +++ b/keyboards/planck/keymaps/antosha417/config.h @@ -25,9 +25,6 @@ */ //#define MIDI_ADVANCED -/* override number of MIDI tone keycodes (each octave adds 12 keycodes and allocates 12 bytes) */ -//#define MIDI_TONE_KEYCODE_OCTAVES 2 - // Most tactile encoders have detents every 4 stages #define ENCODER_RESOLUTION 4 From 1c355fc7ccd0761db69e4cd910f5f9ee43c9c6bb Mon Sep 17 00:00:00 2001 From: Anton <14187674+antosha417@users.noreply.github.com> Date: Sun, 23 Jan 2022 10:19:50 +0200 Subject: [PATCH 09/13] Update keyboards/crkbd/keymaps/antosha417/config.h Co-authored-by: Drashna Jaelre --- keyboards/crkbd/keymaps/antosha417/config.h | 1 - 1 file changed, 1 deletion(-) diff --git a/keyboards/crkbd/keymaps/antosha417/config.h b/keyboards/crkbd/keymaps/antosha417/config.h index 8f4c20613eac..4b6e86fd6ba0 100644 --- a/keyboards/crkbd/keymaps/antosha417/config.h +++ b/keyboards/crkbd/keymaps/antosha417/config.h @@ -31,7 +31,6 @@ #define RGBLIGHT_VAL_STEP 17 #endif -#define OLED_FONT_H "keyboards/crkbd/lib/glcdfont.c" #define TAPPING_TERM 200 #define IGNORE_MOD_TAP_INTERRUPT #define COMBO_TERM 30 From d9931ddfa165fa8975de198b7b13e02133b45b87 Mon Sep 17 00:00:00 2001 From: Anton <14187674+antosha417@users.noreply.github.com> Date: Thu, 27 Jan 2022 15:10:53 +0200 Subject: [PATCH 10/13] Update keyboards/planck/keymaps/antosha417/readme.md Co-authored-by: Ryan --- keyboards/planck/keymaps/antosha417/readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/keyboards/planck/keymaps/antosha417/readme.md b/keyboards/planck/keymaps/antosha417/readme.md index 3c6f7077edc5..89443b2619b8 100644 --- a/keyboards/planck/keymaps/antosha417/readme.md +++ b/keyboards/planck/keymaps/antosha417/readme.md @@ -1,6 +1,6 @@ # How to install: ```console - $ make planck/rev6:antosha417:dfu-util + $ make planck/rev6:antosha417:flash ``` # Useful: * [keycodes](https://docs.qmk.fm/#/keycodes) From 4994c949e09bdbdcd1140d9aba667e840479d32c Mon Sep 17 00:00:00 2001 From: Anton <14187674+antosha417@users.noreply.github.com> Date: Thu, 27 Jan 2022 18:03:14 +0200 Subject: [PATCH 11/13] Update keyboards/planck/keymaps/antosha417/keymap.c Co-authored-by: Ryan --- keyboards/planck/keymaps/antosha417/keymap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/keyboards/planck/keymaps/antosha417/keymap.c b/keyboards/planck/keymaps/antosha417/keymap.c index b2b944e30c71..a3d46c231173 100644 --- a/keyboards/planck/keymaps/antosha417/keymap.c +++ b/keyboards/planck/keymaps/antosha417/keymap.c @@ -1,7 +1,7 @@ // Copyright 2021 Anton Kavalkou (@antosha417) // SPDX-License-Identifier: GPL-2.0-or-later #include QMK_KEYBOARD_H -#include +#include "sendstring_dvorak.h" #include "muse.h" enum layers { From a810e50bdd82d708815cbb9976d69926a8eedae2 Mon Sep 17 00:00:00 2001 From: Anton <14187674+antosha417@users.noreply.github.com> Date: Thu, 27 Jan 2022 18:03:21 +0200 Subject: [PATCH 12/13] Update keyboards/crkbd/keymaps/antosha417/keymap.c Co-authored-by: Ryan --- keyboards/crkbd/keymaps/antosha417/keymap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/keyboards/crkbd/keymaps/antosha417/keymap.c b/keyboards/crkbd/keymaps/antosha417/keymap.c index 20b05d424502..bdee14848587 100644 --- a/keyboards/crkbd/keymaps/antosha417/keymap.c +++ b/keyboards/crkbd/keymaps/antosha417/keymap.c @@ -1,7 +1,7 @@ // Copyright 2021 Anton Kavalkou (@antosha417) // SPDX-License-Identifier: GPL-2.0-or-later #include QMK_KEYBOARD_H -#include +#include "sendstring_dvorak.h" typedef union { uint32_t raw; From 4764c2a239a45eca2232c3d1db60a518e12f293e Mon Sep 17 00:00:00 2001 From: Anton <14187674+antosha417@users.noreply.github.com> Date: Thu, 27 Jan 2022 18:03:33 +0200 Subject: [PATCH 13/13] Update keyboards/planck/keymaps/antosha417/readme.md Co-authored-by: Ryan --- keyboards/planck/keymaps/antosha417/readme.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/keyboards/planck/keymaps/antosha417/readme.md b/keyboards/planck/keymaps/antosha417/readme.md index 89443b2619b8..a7adbf74bbf3 100644 --- a/keyboards/planck/keymaps/antosha417/readme.md +++ b/keyboards/planck/keymaps/antosha417/readme.md @@ -1,7 +1,7 @@ # How to install: - ```console - $ make planck/rev6:antosha417:flash - ``` + + make planck/rev6:antosha417:flash + # Useful: * [keycodes](https://docs.qmk.fm/#/keycodes) * [string keycodes](https://github.com/qmk/qmk_firmware/blob/master/quantum/send_string_keycodes.h)