Skip to content

Commit

Permalink
fix sentence case
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelromao committed Jul 24, 2023
1 parent 6c43ca6 commit 8dad668
Show file tree
Hide file tree
Showing 11 changed files with 289 additions and 191 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,17 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
____ACCENT_L4____ , XXXXXXX , XXXXXXX , ____ACCENT_R4____),
// |___________________________________________________________________________________________________|

[_FIXED_ACCENT] = LAYOUT_wrapper(
// |___________________________________________________________________________________________________|
___________________ACCENT_L1_________ , XXXXXXX , XXXXXXX , _________ACCENT_R1___________________ ,
// |---------+---------+---------+---------+---------+---------+---------+---------+---------+---------|
___________________ACCENT_L2___________________ , ___________________ACCENT_R2___________________ ,
// |---------+---------+---------+---------+---------+---------+---------+---------+---------+---------|
XXXXXXX , _________ACCENT_L3___________________ , ___________________ACCENT_R3_________ , XXXXXXX ,
// |---------+---------+---------+---------+---------+---------+---------+---------+---------+---------|
____ACCENT_L4____ , XXXXXXX , XXXXXXX , ____ACCENT_R4____),
// |___________________________________________________________________________________________________|

[_LOWER] = LAYOUT_wrapper(
// |___________________________________________________________________________________________________|
___________________LOWER_L1__________ , XXXXXXX , XXXXXXX , _________LOWER_R1____________________ ,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,17 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
____ACCENT_L4____ , ____ACCENT_R4____),
// |___________________________________________________________________________________________________|

[_FIXED_ACCENT] = LAYOUT_wrapper(
// |___________________________________________________________________________________________________|
___________________ACCENT_L1_________ , _________ACCENT_R1___________________ ,
// |---------+---------+---------+---------+---------+---------+---------+---------+---------+---------|
___________________ACCENT_L2___________________ , ___________________ACCENT_R2___________________ ,
// |---------+---------+---------+---------+---------+---------+---------+---------+---------+---------|
_________ACCENT_L3___________________ , ___________________ACCENT_R3_________ ,
// |---------+---------+---------+---------+---------+---------+---------+---------+---------+---------|
____ACCENT_L4____ , ____ACCENT_R4____),
// |___________________________________________________________________________________________________|

[_LOWER] = LAYOUT_wrapper(
// |___________________________________________________________________________________________________|
___________________LOWER_L1__________ , _________LOWER_R1____________________ ,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,17 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
____ACCENT_L4____ , ____ACCENT_R4____),
// |___________________________________________________________________________________________________|

[_FIXED_ACCENT] = LAYOUT_wrapper(
// |___________________________________________________________________________________________________|
___________________ACCENT_L1_________ , _________ACCENT_R1___________________ ,
// |---------+---------+---------+---------+---------+---------+---------+---------+---------+---------|
___________________ACCENT_L2___________________ , ___________________ACCENT_R2___________________ ,
// |---------+---------+---------+---------+---------+---------+---------+---------+---------+---------|
_________ACCENT_L3___________________ , ___________________ACCENT_R3_________ ,
// |---------+---------+---------+---------+---------+---------+---------+---------+---------+---------|
____ACCENT_L4____ , ____ACCENT_R4____),
// |___________________________________________________________________________________________________|

[_LOWER] = LAYOUT_wrapper(
// |___________________________________________________________________________________________________|
___________________LOWER_L1__________ , _________LOWER_R1____________________ ,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,17 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
XXXXXXX , XXXXXXX , XXXXXXX , ____ACCENT_L4____ , XXXXXXX , ____ACCENT_R4____ , XXXXXXX , XXXXXXX , XXXXXXX),
// |_______________________________________________________________________________________________________________________|

[_FIXED_ACCENT] = LAYOUT_wrapper(
// |_______________________________________________________________________________________________________________________|
___________________ACCENT_L1_________ , XXXXXXX , XXXXXXX , XXXXXXX , XXXXXXX , _________ACCENT_R1___________________ ,
// |---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------|
___________________ACCENT_L2___________________ , XXXXXXX , XXXXXXX , ___________________ACCENT_R2___________________ ,
// |---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------|
XXXXXXX , _________ACCENT_L3___________________ , XXXXXXX , XXXXXXX , ___________________ACCENT_R3_________ , XXXXXXX ,
// |---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------|
XXXXXXX , XXXXXXX , XXXXXXX , ____ACCENT_L4____ , XXXXXXX , ____ACCENT_R4____ , XXXXXXX , XXXXXXX , XXXXXXX),
// |_______________________________________________________________________________________________________________________|

[_LOWER] = LAYOUT_wrapper(
// |_______________________________________________________________________________________________________________________|
___________________LOWER_L1__________ , XXXXXXX , XXXXXXX , XXXXXXX , XXXXXXX , _________LOWER_R1____________________ ,
Expand Down
6 changes: 3 additions & 3 deletions src/qmk/users/rafaelromao/definitions/keycodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -193,20 +193,20 @@ enum {
#define QBT_RST LT(_MAINTENANCE, QK_BOOT) // Both Tap and Hold behaviors will be intercepted

#define NMO_SPC LT(_NOMOD, KC_SPC)
#define ACT_SPC LT(_ACCENT, KC_SPC)
#define ACT_SPC LT(_FIXED_ACCENT, KC_SPC)
#define LOW_SPC LT(_LOWER, KC_SPC)
#define LOW_NSE LT(_LOWER, MC_NSEN)
#define RAI_TAC LT(_RAISE, TG_ACNT)
#define RAI_SPC LT(_RAISE, KC_SPC)
#define RAI_ACT OSL(_ACCENT) // Hold behavior is implemented in intercepted code
#define MED_OSF OSM(MOD_LSFT) // Hold behavior is implemented in intercepted code
#define MED_OSF LT(_MEDIA, OS_LSFT) // Hold and tap behaviors are implemented in intercepted code

#define MAC_KCD LT(_MACROS, KC_D)
#define MAC_KCI LT(_MACROS, KC_I)
#define MAC_DOT LT(_MACROS, KC_DOT)

// Layer transitions
#define MO_ACT MO(_ACCENT)
#define MO_ACT MO(_FIXED_ACCENT)
#define MO_MED MO(_MEDIA)
#define TO_ROM TO(_ROMAK)
#define TG_NUM TG(_NUMPAD)
Expand Down
1 change: 1 addition & 0 deletions src/qmk/users/rafaelromao/definitions/layers.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ typedef enum {
_MACROS,
_NOMOD,
_ACCENT,
_FIXED_ACCENT,
_LOWER,
_RAISE,
_SEN_CASE,
Expand Down
17 changes: 13 additions & 4 deletions src/qmk/users/rafaelromao/features/sentence_case.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
#include "sentence_case.h"

process_record_result_t process_sentence_case(uint16_t keycode, keyrecord_t *record) {
bool isOneShotLockedShift = get_oneshot_locked_mods() & MOD_MASK_SHIFT;
bool isOneShotShift = isOneShotLockedShift || get_oneshot_mods() & MOD_MASK_SHIFT;

switch (keycode) {
case NAV_CAN:
if (record->tap.count == 0) {
Expand All @@ -16,10 +19,9 @@ process_record_result_t process_sentence_case(uint16_t keycode, keyrecord_t *rec
if (record->event.pressed) {
disable_smart_case();
clear_shift();
return PROCESS_RECORD_RETURN_FALSE;
}
}
break;
return PROCESS_RECORD_RETURN_FALSE;

case LOW_NSE:
if (record->tap.count == 0) {
Expand All @@ -46,9 +48,16 @@ process_record_result_t process_sentence_case(uint16_t keycode, keyrecord_t *rec
} else {
layer_off(_MEDIA);
}
return PROCESS_RECORD_RETURN_FALSE;
} else {
if (record->event.pressed) {
set_oneshot_layer(_SEN_CASE, ONESHOT_START);
reset_oneshot_timer();
if (!isOneShotShift) {
add_oneshot_mods(MOD_LSFT);
}
}
}
break;
return PROCESS_RECORD_RETURN_FALSE;
}

return PROCESS_RECORD_CONTINUE;
Expand Down
12 changes: 7 additions & 5 deletions src/zmk/config/definitions/config.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@
#define LOWER 8
#define RAISE 9
#define SEN_CASE 10
#define NAV_F 11
#define MEDIA 12
#define NAV 13
#define LOCK_KB 14
#define MAINT 15
#define SEN_E1 11
#define SEN_E2 12
#define NAV_F 13
#define MEDIA 14
#define NAV 15
#define LOCK_KB 16
#define MAINT 17

#define TAPPING_TERM 175
#define TD_TAPPING_TERM 225
Expand Down
20 changes: 19 additions & 1 deletion src/zmk/config/definitions/keymap.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,25 @@
&trans &trans &trans &trans &trans &trans &trans &trans &trans &trans
&trans &trans &trans &trans &trans &trans &trans &trans &trans &trans
&trans &trans &trans &trans &trans &trans &trans &trans &trans &trans
&trans &th_cancel NAV 0 &th_nsen LOWER 0 &trans &msk MEDIA LSHFT &trans
&trans &th_cancel NAV 0 &th_sp_ns LOWER 0 &trans &th_nsen MEDIA 0 &trans
>;
};
sentence_case_ext1_layer {
label = "SEN_CS_EXT1";
bindings = <
&trans &kp LS(B) &kp LS(M) &kp LS(G) &kp LS(K) &kp LS(X) &kp LS(L) &kp LS(O) &kp LS(U) &trans
&lt MACROS LS(D) &mt LSHFT LS(N) &mt LCTRL LS(S) &mt LGUI LS(T) &kp LS(W) &kp LS(Z) &mt RGUI LS(R) &mt RCTRL LS(A) &mt RSHFT LS(E) &lt MACROS LS(I)
&kp LS(Q) &mt RALT LS(F) &kp LS(C) &mt LALT LS(P) &kp LS(V) &kp LS(J) &mt LALT LS(H) &th_comma 0 0 &th_dot 0 0 &kp LS(Y)
&trans &th_cancel NAV 0 &th_sp_ns LOWER 0 &msl RAISE SEN_E2 &th_nsen MEDIA 0 &trans
>;
};
sentence_case_ext2_layer {
label = "SEN_CS_EXT2";
bindings = <
&trans &kp LS(J) &kp LS(V) &kp LS(W) &none &none &ac_agrv_c &ac_oacu_c &ac_uacu_c &trans
&kp LS(Y) &kp LS(Z) &kp LS(X) &kp LS(K) &kp SQT &kp CARET &ac_atil_c &ac_aacu_c &ac_eacu_c &ac_iacu_c
&none &kp LS(Q) &mc_ced_c &mc_qu_c &kp GRAVE &kp TILDE &ac_acir_c &ac_ocir_c &ac_ecir_c &none
&trans &th_cancel NAV 0 &th_sp_ns LOWER 0 &none &th_nsen MEDIA 0 &trans
>;
};
fixed_navigation_layer {
Expand Down
Loading

0 comments on commit 8dad668

Please sign in to comment.