diff options
Diffstat (limited to 'src/keymaps/soispha/keymap.c')
-rw-r--r-- | src/keymaps/soispha/keymap.c | 390 |
1 files changed, 390 insertions, 0 deletions
diff --git a/src/keymaps/soispha/keymap.c b/src/keymaps/soispha/keymap.c new file mode 100644 index 0000000..9391212 --- /dev/null +++ b/src/keymaps/soispha/keymap.c @@ -0,0 +1,390 @@ +/* + * Moonlander Layout + * + * Copyright (C) 2024 Benedikt Peetz <benedikt.peetz@b-peetz.de> + * SPDX-License-Identifier: AGPL-3.0-or-later + * + * This file is part of Moonlander Layout. + * + * You should have received a copy of the License along with this program. + * If not, see <https://www.gnu.org/licenses/agpl.txt>. + */ + +#include "layout/layout.h" +#include "macros.h" +#include "version.h" + +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + switch (keycode) { + case VERSION_NUMBER: + if (record->event.pressed) { + SEND_STRING(QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION + " (rev: " QMK_GIT_HASH ")"); + } + break; + case ST_MACRO_0: + if (record->event.pressed) { + SEND_STRING(SS_TAP(X_CAPS) SS_DELAY(100) SS_LSFT(SS_TAP(X_QUOTE)) + SS_DELAY(100) SS_TAP(X_A)); + } + break; + case ST_MACRO_1: + if (record->event.pressed) { + SEND_STRING(SS_TAP(X_CAPS) SS_DELAY(100) SS_LSFT(SS_TAP(X_QUOTE)) + SS_DELAY(100) SS_TAP(X_O)); + } + break; + case ST_MACRO_2: + if (record->event.pressed) { + SEND_STRING(SS_TAP(X_CAPS) SS_DELAY(100) SS_LSFT(SS_TAP(X_QUOTE)) + SS_DELAY(100) SS_TAP(X_U)); + } + break; + case ST_MACRO_3: + if (record->event.pressed) { + SEND_STRING(SS_TAP(X_CAPS) SS_DELAY(100) SS_LSFT(SS_TAP(X_QUOTE)) + SS_DELAY(100) SS_LSFT(SS_TAP(X_U))); + } + break; + case ST_MACRO_4: + if (record->event.pressed) { + SEND_STRING(SS_TAP(X_CAPS) SS_DELAY(100) SS_LSFT(SS_TAP(X_QUOTE)) + SS_DELAY(100) SS_LSFT(SS_TAP(X_O))); + } + break; + case ST_MACRO_5: + if (record->event.pressed) { + SEND_STRING(SS_TAP(X_CAPS) SS_DELAY(100) SS_LSFT(SS_TAP(X_QUOTE)) + SS_DELAY(100) SS_LSFT(SS_TAP(X_A))); + } + break; + case ST_MACRO_6: + if (record->event.pressed) { + SEND_STRING(SS_TAP(X_CAPS) SS_DELAY(100) SS_TAP(X_O) SS_DELAY(100) + SS_TAP(X_A)); + } + break; + case ST_MACRO_7: + if (record->event.pressed) { + SEND_STRING(SS_TAP(X_CAPS) SS_DELAY(100) SS_TAP(X_O) SS_DELAY(100) + SS_LSFT(SS_TAP(X_A))); + } + break; + + case RGB_SLD: + if (record->event.pressed) { + rgblight_mode(1); + } + return false; + } + return true; +} + +typedef struct { + bool is_press_action; + uint8_t step; +} tap; + +enum { + SINGLE_TAP = 1, + SINGLE_HOLD, + DOUBLE_TAP, + DOUBLE_HOLD, + DOUBLE_SINGLE_TAP, + MORE_TAPS +}; + +static tap dance_state[5]; + +uint8_t dance_step(tap_dance_state_t *state); + +uint8_t dance_step(tap_dance_state_t *state) { + if (state->count == 1) { + if (state->interrupted || !state->pressed) + return SINGLE_TAP; + else + return SINGLE_HOLD; + } else if (state->count == 2) { + if (state->interrupted) + return DOUBLE_SINGLE_TAP; + else if (state->pressed) + return DOUBLE_HOLD; + else + return DOUBLE_TAP; + } + return MORE_TAPS; +} + +void on_dance_0(tap_dance_state_t *state, void *user_data); +void dance_0_finished(tap_dance_state_t *state, void *user_data); +void dance_0_reset(tap_dance_state_t *state, void *user_data); + +void on_dance_0(tap_dance_state_t *state, void *user_data) { + if (state->count == 3) { + tap_code16(KC_SCLN); + tap_code16(KC_SCLN); + tap_code16(KC_SCLN); + } + if (state->count > 3) { + tap_code16(KC_SCLN); + } +} + +void dance_0_finished(tap_dance_state_t *state, void *user_data) { + dance_state[0].step = dance_step(state); + switch (dance_state[0].step) { + case SINGLE_TAP: + register_code16(KC_SCLN); + break; + case SINGLE_HOLD: + register_code16(KC_COLN); + break; + case DOUBLE_TAP: + register_code16(KC_SCLN); + register_code16(KC_SCLN); + break; + case DOUBLE_SINGLE_TAP: + tap_code16(KC_SCLN); + register_code16(KC_SCLN); + } +} + +void dance_0_reset(tap_dance_state_t *state, void *user_data) { + wait_ms(10); + switch (dance_state[0].step) { + case SINGLE_TAP: + unregister_code16(KC_SCLN); + break; + case SINGLE_HOLD: + unregister_code16(KC_COLN); + break; + case DOUBLE_TAP: + unregister_code16(KC_SCLN); + break; + case DOUBLE_SINGLE_TAP: + unregister_code16(KC_SCLN); + break; + } + dance_state[0].step = 0; +} +void on_dance_1(tap_dance_state_t *state, void *user_data); +void dance_1_finished(tap_dance_state_t *state, void *user_data); +void dance_1_reset(tap_dance_state_t *state, void *user_data); + +void on_dance_1(tap_dance_state_t *state, void *user_data) { + if (state->count == 3) { + tap_code16(KC_SLASH); + tap_code16(KC_SLASH); + tap_code16(KC_SLASH); + } + if (state->count > 3) { + tap_code16(KC_SLASH); + } +} + +void dance_1_finished(tap_dance_state_t *state, void *user_data) { + dance_state[1].step = dance_step(state); + switch (dance_state[1].step) { + case SINGLE_TAP: + register_code16(KC_SLASH); + break; + case SINGLE_HOLD: + register_code16(KC_BSLS); + break; + case DOUBLE_TAP: + register_code16(KC_SLASH); + register_code16(KC_SLASH); + break; + case DOUBLE_SINGLE_TAP: + tap_code16(KC_SLASH); + register_code16(KC_SLASH); + } +} + +void dance_1_reset(tap_dance_state_t *state, void *user_data) { + wait_ms(10); + switch (dance_state[1].step) { + case SINGLE_TAP: + unregister_code16(KC_SLASH); + break; + case SINGLE_HOLD: + unregister_code16(KC_BSLS); + break; + case DOUBLE_TAP: + unregister_code16(KC_SLASH); + break; + case DOUBLE_SINGLE_TAP: + unregister_code16(KC_SLASH); + break; + } + dance_state[1].step = 0; +} +void on_dance_2(tap_dance_state_t *state, void *user_data); +void dance_2_finished(tap_dance_state_t *state, void *user_data); +void dance_2_reset(tap_dance_state_t *state, void *user_data); + +void on_dance_2(tap_dance_state_t *state, void *user_data) { + if (state->count == 3) { + tap_code16(KC_MINUS); + tap_code16(KC_MINUS); + tap_code16(KC_MINUS); + } + if (state->count > 3) { + tap_code16(KC_MINUS); + } +} + +void dance_2_finished(tap_dance_state_t *state, void *user_data) { + dance_state[2].step = dance_step(state); + switch (dance_state[2].step) { + case SINGLE_TAP: + register_code16(KC_MINUS); + break; + case SINGLE_HOLD: + register_code16(KC_UNDS); + break; + case DOUBLE_TAP: + register_code16(KC_MINUS); + register_code16(KC_MINUS); + break; + case DOUBLE_SINGLE_TAP: + tap_code16(KC_MINUS); + register_code16(KC_MINUS); + } +} + +void dance_2_reset(tap_dance_state_t *state, void *user_data) { + wait_ms(10); + switch (dance_state[2].step) { + case SINGLE_TAP: + unregister_code16(KC_MINUS); + break; + case SINGLE_HOLD: + unregister_code16(KC_UNDS); + break; + case DOUBLE_TAP: + unregister_code16(KC_MINUS); + break; + case DOUBLE_SINGLE_TAP: + unregister_code16(KC_MINUS); + break; + } + dance_state[2].step = 0; +} +void on_dance_3(tap_dance_state_t *state, void *user_data); +void dance_3_finished(tap_dance_state_t *state, void *user_data); +void dance_3_reset(tap_dance_state_t *state, void *user_data); + +void on_dance_3(tap_dance_state_t *state, void *user_data) { + if (state->count == 3) { + tap_code16(KC_QUOTE); + tap_code16(KC_QUOTE); + tap_code16(KC_QUOTE); + } + if (state->count > 3) { + tap_code16(KC_QUOTE); + } +} + +void dance_3_finished(tap_dance_state_t *state, void *user_data) { + dance_state[3].step = dance_step(state); + switch (dance_state[3].step) { + case SINGLE_TAP: + register_code16(KC_QUOTE); + break; + case SINGLE_HOLD: + register_code16(KC_DQUO); + break; + case DOUBLE_TAP: + register_code16(KC_QUOTE); + register_code16(KC_QUOTE); + break; + case DOUBLE_SINGLE_TAP: + tap_code16(KC_QUOTE); + register_code16(KC_QUOTE); + } +} + +void dance_3_reset(tap_dance_state_t *state, void *user_data) { + wait_ms(10); + switch (dance_state[3].step) { + case SINGLE_TAP: + unregister_code16(KC_QUOTE); + break; + case SINGLE_HOLD: + unregister_code16(KC_DQUO); + break; + case DOUBLE_TAP: + unregister_code16(KC_QUOTE); + break; + case DOUBLE_SINGLE_TAP: + unregister_code16(KC_QUOTE); + break; + } + dance_state[3].step = 0; +} +void on_dance_4(tap_dance_state_t *state, void *user_data); +void dance_4_finished(tap_dance_state_t *state, void *user_data); +void dance_4_reset(tap_dance_state_t *state, void *user_data); + +void on_dance_4(tap_dance_state_t *state, void *user_data) { + if (state->count == 3) { + tap_code16(KC_EQUAL); + tap_code16(KC_EQUAL); + tap_code16(KC_EQUAL); + } + if (state->count > 3) { + tap_code16(KC_EQUAL); + } +} + +void dance_4_finished(tap_dance_state_t *state, void *user_data) { + dance_state[4].step = dance_step(state); + switch (dance_state[4].step) { + case SINGLE_TAP: + register_code16(KC_EQUAL); + break; + case SINGLE_HOLD: + register_code16(KC_PLUS); + break; + case DOUBLE_TAP: + register_code16(KC_EQUAL); + register_code16(KC_EQUAL); + break; + case DOUBLE_SINGLE_TAP: + tap_code16(KC_EQUAL); + register_code16(KC_EQUAL); + } +} + +void dance_4_reset(tap_dance_state_t *state, void *user_data) { + wait_ms(10); + switch (dance_state[4].step) { + case SINGLE_TAP: + unregister_code16(KC_EQUAL); + break; + case SINGLE_HOLD: + unregister_code16(KC_PLUS); + break; + case DOUBLE_TAP: + unregister_code16(KC_EQUAL); + break; + case DOUBLE_SINGLE_TAP: + unregister_code16(KC_EQUAL); + break; + } + dance_state[4].step = 0; +} + +tap_dance_action_t tap_dance_actions[] = { + [DANCE_0] = ACTION_TAP_DANCE_FN_ADVANCED(on_dance_0, dance_0_finished, + dance_0_reset), + [DANCE_1] = ACTION_TAP_DANCE_FN_ADVANCED(on_dance_1, dance_1_finished, + dance_1_reset), + [DANCE_2] = ACTION_TAP_DANCE_FN_ADVANCED(on_dance_2, dance_2_finished, + dance_2_reset), + [DANCE_3] = ACTION_TAP_DANCE_FN_ADVANCED(on_dance_3, dance_3_finished, + dance_3_reset), + [DANCE_4] = ACTION_TAP_DANCE_FN_ADVANCED(on_dance_4, dance_4_finished, + dance_4_reset), +}; |