Skip to content

Commit

Permalink
implement magic-h in QMK
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelromao committed May 25, 2024
1 parent 078a64d commit 1b29d0d
Show file tree
Hide file tree
Showing 11 changed files with 82 additions and 267 deletions.
7 changes: 6 additions & 1 deletion src/qmk/users/rafaelromao/definitions/keycodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,9 @@ bool is_shift_macro_keycode(uint16_t keycode) {

bool is_accent_macro_keycode(uint16_t keycode) {
return keycode > ACCENT_MACRO_START && keycode < ACCENT_MACRO_END;
}
}

bool is_shifted(void) {
return get_mods() & MOD_MASK_SHIFT || get_oneshot_mods() & MOD_MASK_SHIFT ||
get_oneshot_locked_mods() & MOD_MASK_SHIFT;
}
11 changes: 6 additions & 5 deletions src/qmk/users/rafaelromao/definitions/keycodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ enum {
// Begin macros used to write text
STR_MACRO_START,

MC_NG, MC_EY, MC_HY, MC_OU, MC_COM, MC_AO, MC_ES, MC_OES, MC_FIX_I,
MC_BTIC, MC_DQUO, MC_SQUO, MC_CIRC, MC_TILD, MC_ORDO, MC_ORDA,
MC_EUR, MC_LTE, MC_GTE, MC_DDS, MC_ENT, MC_TAB, MC_ESC, MC_ESCC,
TG_NUMC, MC_EXLM, MC_QUES, MC_ESAV, MC_SENT, MC_DEG, MC_DELW, MC_LY,
Expand All @@ -122,7 +121,7 @@ enum {
// Start macros for accented letters
ACCENT_MACRO_START,

MC_GV_A, MC_CR_A, MC_SQ_A, MC_QU,
MC_GV_A, MC_CR_A, MC_SQ_A, MC_QU, MC_AH,
MC_SQ_U, MC_CR_O, MC_SQ_O, MC_SQ_I,
MC_CR_E, MC_SQ_C, MC_SQ_E, MC_TL_A, MC_TL_O,

Expand Down Expand Up @@ -161,9 +160,10 @@ enum {
#define RCTLT_A RCTL_T(KC_A)

#define LALTT_P LALT_T(KC_P)
#define RALTT_H RALT_T(KC_H)
#define RALTT_F RALT_T(KC_F)

#define ALT_MAG RALT_T(KC_H)

#define LGUIT_T LGUI_T(KC_T)
#define RGUIT_R RGUI_T(KC_R)

Expand All @@ -178,8 +178,8 @@ enum {

#define NAV_F12 LT(_NAVIGATION, KC_F12)
#define NAV_AT LT(_NAVIGATION, KC_AT)
#define NAV_STI LT(_NAVIGATION, MC_STIN) // Hold behavior is implemented in intercepted code
#define NAV_MAG LT(_NAVIGATION, MAGIC)
#define NAV_STI LT(_NAVIGATION, MC_STIN) // Tap behavior is implemented in intercepted code
#define NAV_Q LT(_NAVIGATION, KC_Q)
#define NAV_REP LT(_NAVIGATION, REPEAT)
#define FNA_REP LT(_FIXED_NAV, REPEAT)

Expand Down Expand Up @@ -216,5 +216,6 @@ uint16_t extract_tapping_keycode(uint16_t keycode);
bool is_string_macro_keycode(uint16_t keycode);
bool is_shift_macro_keycode(uint16_t keycode);
bool is_accent_macro_keycode(uint16_t keycode);
bool is_shifted(void);

// clang-format on
6 changes: 3 additions & 3 deletions src/qmk/users/rafaelromao/definitions/keymap_blocks.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

#define ________ALPHA1_R1____________________ KC_L , KC_O , KC_U , KC_Y
#define __________________ALPHA1_R2____________________ KC_Z , RGUIT_R , RCTLT_A , RSFTT_E , SHO_KCI
#define __________________ALPHA1_R3__________ KC_J , RALTT_H , TD_COMM , TD_DOT
#define __________________ALPHA1_R3__________ KC_J , ALT_MAG , TD_COMM , TD_DOT
#define ___ALPHA1_R4_____ RAI_A2 , MED_CAS

#define ___________________LOWER_L1__________ XXXXXXX , TD_LCBR , TD_RCBR , TD_BSLS
Expand Down Expand Up @@ -75,10 +75,10 @@
#define ___________________NOMOD_R3__________ KC_J , KC_H , KC_COMM , KC_DOT
#define ____NOMOD_R4_____ OSL_A2 , OS_LSFT

#define ___________________ALPHA2_L1_________ XXXXXXX , KC_Q , MC_QU , KC_K
#define ___________________ALPHA2_L1_________ XXXXXXX , KC_H , MC_QU , KC_K
#define ___________________ALPHA2_L2___________________ KC_Y , KC_Z , KC_X , KC_W , XXXXXXX
#define _________ALPHA2_L3___________________ KC_J , MC_SQ_C , KC_V , XXXXXXX
#define ____ALPHA2_L4____ NAV_MAG , OS_SYM
#define ____ALPHA2_L4____ NAV_Q , OS_SYM

#define _________ALPHA2_R1___________________ MC_CR_O , MC_CR_E , MC_CR_A , XXXXXXX
#define ___________________ALPHA2_R2___________________ XXXXXXX , MC_TL_A , MC_SQ_E , MC_SQ_A , MC_SQ_I
Expand Down
42 changes: 2 additions & 40 deletions src/qmk/users/rafaelromao/features/accents.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,47 +85,9 @@ process_record_result_t process_ngrams(uint16_t keycode, bool isShifted) {
tap_code(KC_Q);
tap_code(KC_U);
return PROCESS_RECORD_RETURN_FALSE;
case MC_ES:
tap_code(KC_E);
tap_code(KC_S);
return PROCESS_RECORD_RETURN_FALSE;
case MC_AO:
process_accents(MC_TL_A, NULL);
tap_code(KC_O);
return PROCESS_RECORD_RETURN_FALSE;
case MC_OES:
process_accents(MC_TL_O, NULL);
tap_code(KC_E);
tap_code(KC_S);
return PROCESS_RECORD_RETURN_FALSE;
case MC_NG:
tap_code(KC_N);
tap_code(KC_G);
return PROCESS_RECORD_RETURN_FALSE;
case MC_LY:
tap_code(KC_L);
tap_code(KC_Y);
return PROCESS_RECORD_RETURN_FALSE;
case MC_EY:
tap_code(KC_E);
tap_code(KC_Y);
return PROCESS_RECORD_RETURN_FALSE;
case MC_HY:
case MC_AH:
tap_code(KC_A);
tap_code(KC_H);
tap_code(KC_Y);
return PROCESS_RECORD_RETURN_FALSE;
case MC_OU:
tap_code(KC_O);
tap_code(KC_U);
return PROCESS_RECORD_RETURN_FALSE;
case MC_COM:
tap_code(KC_C);
tap_code(KC_O);
tap_code(KC_M);
return PROCESS_RECORD_RETURN_FALSE;
case MC_FIX_I:
tap_code(KC_BSPC);
SEND_STRING("I' ");
return PROCESS_RECORD_RETURN_FALSE;
}

Expand Down
8 changes: 4 additions & 4 deletions src/qmk/users/rafaelromao/features/combos.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,20 @@ const uint16_t PROGMEM l_rom_tab_combo[] = {RALTT_F, LEA_KCC, LALTT_P, COMBO_END

const uint16_t PROGMEM r_rom_x_combo[] = {KC_L, KC_O, COMBO_END};
const uint16_t PROGMEM r_rom_z_combo[] = {RGUIT_R, RCTLT_A, COMBO_END};
const uint16_t PROGMEM r_rom_j_combo[] = {RALTT_H, TD_COMM, COMBO_END};
const uint16_t PROGMEM r_rom_j_combo[] = {ALT_MAG, TD_COMM, COMBO_END};
const uint16_t PROGMEM r_rom_y_combo[] = {RCTLT_A, RSFTT_E, COMBO_END};
const uint16_t PROGMEM r_rom_d_combo[] = {KC_L, KC_O, KC_U, COMBO_END};
const uint16_t PROGMEM r_rom_p_combo[] = {RGUIT_R, RCTLT_A, RSFTT_E, COMBO_END};
const uint16_t PROGMEM r_rom_cop_combo[] = {RAI_A2, RGUIT_R, RCTLT_A, COMBO_END};
const uint16_t PROGMEM r_rom_pas_combo[] = {RAI_A2, RALTT_H, TD_COMM, COMBO_END};
const uint16_t PROGMEM r_rom_pas_combo[] = {RAI_A2, ALT_MAG, TD_COMM, COMBO_END};
const uint16_t PROGMEM r_rom_sal_combo[] = {RAI_A2, TD_COMM, TD_DOT, COMBO_END};
const uint16_t PROGMEM r_rom_scp_combo[] = {RAI_A2, RGUIT_R, RCTLT_A, RSFTT_E, COMBO_END};
const uint16_t PROGMEM r_rom_spa_combo[] = {RAI_A2, RALTT_H, TD_COMM, TD_DOT, COMBO_END};
const uint16_t PROGMEM r_rom_spa_combo[] = {RAI_A2, ALT_MAG, TD_COMM, TD_DOT, COMBO_END};
const uint16_t PROGMEM r_rom_ent_combo[] = {RAI_A2, RCTLT_A, RSFTT_E, COMBO_END};
const uint16_t PROGMEM r_rom_bsp_combo[] = {KC_O, KC_U, COMBO_END};
const uint16_t PROGMEM r_rom_tab_combo[] = {RAI_A2, KC_O, KC_U, COMBO_END};
const uint16_t PROGMEM r_rom_sco_combo[] = {TD_COMM, TD_DOT, COMBO_END};
const uint16_t PROGMEM r_rom_sent_combo[] = {RALTT_H, TD_COMM, TD_DOT, COMBO_END};
const uint16_t PROGMEM r_rom_sent_combo[] = {ALT_MAG, TD_COMM, TD_DOT, COMBO_END};

// Alpha 2

Expand Down
5 changes: 3 additions & 2 deletions src/qmk/users/rafaelromao/features/sentence_case.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@ process_record_result_t process_sentence_case(uint16_t keycode, keyrecord_t *rec
// Process macros
switch (keycode) {
// Skip dot and comma
case TD_DOT:
case TD_COMM:
case TD_DOT:
sentence_case.state = SENTENCE_CASE_NONE;
return PROCESS_RECORD_CONTINUE;
// Process alpha macros
case MC_AH:
case MC_QU:
add_oneshot_mods(MOD_LSFT);
sentence_case.state = SENTENCE_CASE_NONE;
Expand Down Expand Up @@ -61,11 +62,11 @@ process_record_result_t process_sentence_case(uint16_t keycode, keyrecord_t *rec
switch (keycode) {
// Continue to Alpha2 layer
case RAI_A2:
case OSL_A2:
return PROCESS_RECORD_CONTINUE;
// Cancel
case NAV_REP:
case FNA_REP:
case NAV_MAG:
case QK_REP:
if (sentence_case.state != SENTENCE_CASE_NONE) {
clear_shift();
Expand Down
5 changes: 3 additions & 2 deletions src/qmk/users/rafaelromao/features/smart_case.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,11 @@ process_record_result_t process_smart_case(uint16_t keycode, keyrecord_t *record
}
// Extend, process or break case
switch (keycode) {
case OSL_A2:
case RAI_A2:
case NAV_REP:
case FNA_REP:
case NAV_MAG:
case ALT_MAG:
case MED_CAS:
start_smart_case_timer();
return PROCESS_RECORD_CONTINUE;
Expand Down Expand Up @@ -244,12 +245,12 @@ process_record_result_t process_smart_case(uint16_t keycode, keyrecord_t *record
break;
}
default:
disable_smart_case();
if (is_shift_macro_keycode(key)) {
process_macros(key, NULL);
} else if (is_accent_macro_keycode(key)) {
process_accents(key, NULL);
} else {
disable_smart_case();
tap_code16(key);
}
return PROCESS_RECORD_RETURN_FALSE;
Expand Down
Loading

0 comments on commit 1b29d0d

Please sign in to comment.