Skip to content

Commit

Permalink
Keymap: simplify combo definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
getreuer committed Aug 21, 2022
1 parent 098f226 commit 95bdddf
Showing 1 changed file with 13 additions and 29 deletions.
42 changes: 13 additions & 29 deletions keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ enum custom_keycodes {
UPDIR = SAFE_RANGE,
EXIT,
SCOPE,
END_SENTENCE,
SELWORD,
JOINLN,
TMUXESC,
Expand Down Expand Up @@ -195,40 +196,18 @@ const custom_shift_key_t custom_shift_keys[] = {
{KC_SLSH, KC_SLSH}, // Don't shift /
};
uint8_t NUM_CUSTOM_SHIFT_KEYS =
sizeof(custom_shift_keys) / sizeof(custom_shift_key_t);

enum combo_events {
// . and C => activate Caps Word.
CAPS_COMBO,
// , and . => types a period, space, and sets one-shot mod for shift.
// This combo is useful to flow between sentences.
END_SENTENCE_COMBO,
COMBO_LENGTH
};
uint16_t COMBO_LEN = COMBO_LENGTH;
sizeof(custom_shift_keys) / sizeof(*custom_shift_keys);

const uint16_t caps_combo[] PROGMEM = {KC_DOT, KC_C, COMBO_END};
const uint16_t end_sentence_combo[] PROGMEM = {KC_COMM, KC_DOT, COMBO_END};

combo_t key_combos[] = {
[CAPS_COMBO] = COMBO_ACTION(caps_combo),
[END_SENTENCE_COMBO] = COMBO_ACTION(end_sentence_combo),
// . and C => activate Caps Word.
COMBO(caps_combo, CAPSWRD),
// , and . => types a period, space, and sets one-shot mod for shift.
// This combo is useful to flow between sentences.
COMBO(end_sentence_combo, END_SENTENCE),
};

void process_combo_event(uint16_t combo_index, bool pressed) {
if (pressed) {
switch(combo_index) {
case CAPS_COMBO:
caps_word_on();
break;

case END_SENTENCE_COMBO:
SEND_STRING(". ");
add_oneshot_mods(MOD_BIT(KC_LSFT)); // Set one-shot mod for shift.
break;
}
}
}
uint16_t COMBO_LEN = sizeof(key_combos) / sizeof(*key_combos);

bool get_tapping_force_hold(uint16_t keycode, keyrecord_t* record) {
// If you quickly hold a tap-hold key after tapping it, the tap action is
Expand Down Expand Up @@ -324,6 +303,11 @@ bool process_record_user(uint16_t keycode, keyrecord_t* record) {
layer_off(ADJUST);
return false;

case END_SENTENCE:
SEND_STRING(". ");
add_oneshot_mods(MOD_BIT(KC_LSFT)); // Set one-shot mod for shift.
return false;

case SCOPE:
SEND_STRING("::");
return false;
Expand Down

0 comments on commit 95bdddf

Please sign in to comment.