Skip to content

Commit 95bdddf

Browse files
committed
Keymap: simplify combo definitions
1 parent 098f226 commit 95bdddf

File tree

1 file changed

+13
-29
lines changed

1 file changed

+13
-29
lines changed

keymap.c

Lines changed: 13 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ enum custom_keycodes {
5757
UPDIR = SAFE_RANGE,
5858
EXIT,
5959
SCOPE,
60+
END_SENTENCE,
6061
SELWORD,
6162
JOINLN,
6263
TMUXESC,
@@ -195,40 +196,18 @@ const custom_shift_key_t custom_shift_keys[] = {
195196
{KC_SLSH, KC_SLSH}, // Don't shift /
196197
};
197198
uint8_t NUM_CUSTOM_SHIFT_KEYS =
198-
sizeof(custom_shift_keys) / sizeof(custom_shift_key_t);
199-
200-
enum combo_events {
201-
// . and C => activate Caps Word.
202-
CAPS_COMBO,
203-
// , and . => types a period, space, and sets one-shot mod for shift.
204-
// This combo is useful to flow between sentences.
205-
END_SENTENCE_COMBO,
206-
COMBO_LENGTH
207-
};
208-
uint16_t COMBO_LEN = COMBO_LENGTH;
199+
sizeof(custom_shift_keys) / sizeof(*custom_shift_keys);
209200

210201
const uint16_t caps_combo[] PROGMEM = {KC_DOT, KC_C, COMBO_END};
211202
const uint16_t end_sentence_combo[] PROGMEM = {KC_COMM, KC_DOT, COMBO_END};
212-
213203
combo_t key_combos[] = {
214-
[CAPS_COMBO] = COMBO_ACTION(caps_combo),
215-
[END_SENTENCE_COMBO] = COMBO_ACTION(end_sentence_combo),
204+
// . and C => activate Caps Word.
205+
COMBO(caps_combo, CAPSWRD),
206+
// , and . => types a period, space, and sets one-shot mod for shift.
207+
// This combo is useful to flow between sentences.
208+
COMBO(end_sentence_combo, END_SENTENCE),
216209
};
217-
218-
void process_combo_event(uint16_t combo_index, bool pressed) {
219-
if (pressed) {
220-
switch(combo_index) {
221-
case CAPS_COMBO:
222-
caps_word_on();
223-
break;
224-
225-
case END_SENTENCE_COMBO:
226-
SEND_STRING(". ");
227-
add_oneshot_mods(MOD_BIT(KC_LSFT)); // Set one-shot mod for shift.
228-
break;
229-
}
230-
}
231-
}
210+
uint16_t COMBO_LEN = sizeof(key_combos) / sizeof(*key_combos);
232211

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

306+
case END_SENTENCE:
307+
SEND_STRING(". ");
308+
add_oneshot_mods(MOD_BIT(KC_LSFT)); // Set one-shot mod for shift.
309+
return false;
310+
327311
case SCOPE:
328312
SEND_STRING("::");
329313
return false;

0 commit comments

Comments
 (0)