mirror of
https://github.com/qmk/qmk_userspace.git
synced 2025-11-03 10:20:07 -05:00
Shifted PG_ODK
This commit is contained in:
parent
711584e208
commit
af19532ac6
7 changed files with 32 additions and 88 deletions
|
|
@ -22,25 +22,11 @@
|
|||
void get_clever_keycode(uint16_t* next_keycode, keyrecord_t* record) {
|
||||
|
||||
uint16_t prev_keycode = recent[RECENT_SIZE - 1];
|
||||
//static bool is_shifted = false;
|
||||
|
||||
// Apostrophe
|
||||
if (is_followed_by_apos(*next_keycode, prev_keycode)) {
|
||||
set_last_keycode(PG_APOS);
|
||||
//apostrophe = true;
|
||||
}
|
||||
|
||||
//if (is_caps_lock_on()) {
|
||||
/* if (is_letter(*next_keycode) || is_send_string_macro(*next_keycode)) {
|
||||
if (recent[RECENT_SIZE - 3] == PG_E && recent[RECENT_SIZE - 2] == PG_T && prev_keycode == KC_SPC) {
|
||||
caps_word_on();
|
||||
}
|
||||
if (recent[RECENT_SIZE - 2] == PG_VIRG && prev_keycode == KC_SPC && is_letter(*next_keycode)) {
|
||||
caps_word_on();
|
||||
}
|
||||
} */
|
||||
//}
|
||||
|
||||
|
||||
switch (prev_keycode) {
|
||||
|
||||
|
|
@ -48,7 +34,9 @@ void get_clever_keycode(uint16_t* next_keycode, keyrecord_t* record) {
|
|||
switch (*next_keycode) {
|
||||
// Shift auto de la ponctuation après une espace fine insécable
|
||||
case PG_POIN:
|
||||
process_word((uint16_t[]) {KC_BSPC, SAGR(KC_SPC)}, 2, record);
|
||||
// uses less space than process_word
|
||||
tap_code(KC_BSPC);
|
||||
process_key(SAGR(KC_SPC), record);
|
||||
case PG_TIRE:
|
||||
case PG_VIRG:
|
||||
return replace_ongoing_key(S(*next_keycode), next_keycode, record);
|
||||
|
|
@ -64,7 +52,7 @@ void get_clever_keycode(uint16_t* next_keycode, keyrecord_t* record) {
|
|||
// Shift the letter at the beginning of sentences.
|
||||
if (is_letter(*next_keycode) || is_send_string_macro(*next_keycode)) {
|
||||
//if (!is_caps_lock_on()) { add_weak_mods(MOD_BIT(KC_LSFT)); }
|
||||
add_weak_mods(MOD_BIT(KC_LSFT));
|
||||
set_oneshot_mods(MOD_BIT(KC_LSFT)); // Don't use weak mods !
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
@ -119,15 +107,11 @@ void get_clever_keycode(uint16_t* next_keycode, keyrecord_t* record) {
|
|||
switch (prev_keycode) {
|
||||
case PG_O:
|
||||
// oui
|
||||
invoke_key(PG_U, record);
|
||||
process_key(PG_U, record);
|
||||
case PG_U:
|
||||
// ui SFB
|
||||
return replace_ongoing_key(PG_I, next_keycode, record);
|
||||
|
||||
/* case PG_L:
|
||||
// là
|
||||
return finish_word((uint16_t[]) {PG_ODK, PG_A}, 2, next_keycode, record); */
|
||||
|
||||
case PG_EACU:
|
||||
// éa SFB
|
||||
return replace_ongoing_key(PG_A, next_keycode, record);
|
||||
|
|
@ -154,19 +138,27 @@ void get_clever_keycode(uint16_t* next_keycode, keyrecord_t* record) {
|
|||
|
||||
case PG_Q:
|
||||
// qué scissor
|
||||
return finish_word((uint16_t[]) {PG_U, PG_EACU}, 2, next_keycode, record);
|
||||
//return finish_word((uint16_t[]) {PG_U, PG_EACU}, 2, next_keycode, record);
|
||||
process_key(PG_U,record);
|
||||
return replace_ongoing_key(PG_EACU, next_keycode, record);
|
||||
|
||||
case PG_Y:
|
||||
// you bad redirection
|
||||
return finish_word((uint16_t[]) {PG_O, PG_U}, 2, next_keycode, record);
|
||||
//return finish_word((uint16_t[]) {PG_O, PG_U}, 2, next_keycode, record);
|
||||
process_key(PG_O,record);
|
||||
return replace_ongoing_key(PG_U, next_keycode, record);
|
||||
|
||||
case PG_T:
|
||||
// "the"
|
||||
return finish_word((uint16_t[]) {PG_H, PG_E}, 2, next_keycode, record);
|
||||
|
||||
//return finish_word((uint16_t[]) {PG_H, PG_E}, 2, next_keycode, record);
|
||||
process_key(PG_H,record);
|
||||
return replace_ongoing_key(PG_E, next_keycode, record);
|
||||
|
||||
case PG_I:
|
||||
return finish_word((uint16_t[]) {PG_O, PG_N}, 2, next_keycode, record);
|
||||
|
||||
//return finish_word((uint16_t[]) {PG_O, PG_N}, 2, next_keycode, record);
|
||||
process_key(PG_O,record);
|
||||
return replace_ongoing_key(PG_N, next_keycode, record);
|
||||
|
||||
case PG_M:
|
||||
if (is_letter(recent[RECENT_SIZE - 2])) {
|
||||
// "ment"
|
||||
|
|
@ -187,11 +179,6 @@ void get_clever_keycode(uint16_t* next_keycode, keyrecord_t* record) {
|
|||
default:
|
||||
// "à"
|
||||
process_key(PG_ODK,record);
|
||||
|
||||
if (is_shifted) {
|
||||
is_shifted = false;
|
||||
add_weak_mods(MOD_BIT(KC_LSFT));
|
||||
}
|
||||
return replace_ongoing_key(PG_A, next_keycode, record);
|
||||
}
|
||||
|
||||
|
|
@ -231,26 +218,10 @@ void get_clever_keycode(uint16_t* next_keycode, keyrecord_t* record) {
|
|||
}
|
||||
break;
|
||||
|
||||
/* case PG_R:
|
||||
if (prev_keycode == PG_L) {
|
||||
// "lr" -> "l" + 1DK
|
||||
//bkspc_countdown = 0;
|
||||
return replace_ongoing_key(OS_ODK, next_keycode, record);
|
||||
}
|
||||
break; */
|
||||
|
||||
case OU_GRV:
|
||||
layer_off(_ODK);
|
||||
return finish_word((uint16_t[]) {PG_O, PG_ODK, PG_N}, 3, next_keycode, record);
|
||||
|
||||
/* case PG_BL:
|
||||
layer_off(_ODK);
|
||||
return finish_word((uint16_t[]) {PG_B, PG_L}, 2, next_keycode, record); */
|
||||
|
||||
/* case J_APOS:
|
||||
layer_off(_ODK);
|
||||
return finish_word((uint16_t[]) {PG_J, PG_APOS}, 2, next_keycode, record); */
|
||||
|
||||
case PG_APOS:
|
||||
if (is_apos_dr) { return replace_ongoing_key(PG_APOD, next_keycode, record); }
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -133,7 +133,6 @@ void process_key(uint16_t keycode, keyrecord_t* record) {
|
|||
|
||||
void invoke_key(uint16_t keycode, keyrecord_t* record) {
|
||||
process_key(keycode, record); // tap_code doesn't work with caps word.
|
||||
//record->keycode = keycode;
|
||||
bkspc_countdown = 1;
|
||||
}
|
||||
|
||||
|
|
@ -148,10 +147,15 @@ void process_word(uint16_t keycodes[], uint8_t num_keycodes, keyrecord_t* record
|
|||
for (int i = 0; i < num_keycodes; ++i) {
|
||||
process_key(keycodes[i], record); // tap_code doesn't work with caps word.
|
||||
}
|
||||
bkspc_countdown = num_keycodes;
|
||||
}
|
||||
|
||||
void finish_word(uint16_t keycodes[], uint8_t num_keycodes, uint16_t* ongoing_keycode, keyrecord_t* record) {
|
||||
process_word(keycodes, num_keycodes - 1, record);
|
||||
bkspc_countdown = num_keycodes - 1;
|
||||
replace_ongoing_key(keycodes[num_keycodes - 1], ongoing_keycode, record);
|
||||
}
|
||||
|
||||
void finish_magic(uint16_t keycodes[], uint8_t num_keycodes, uint16_t* ongoing_keycode, keyrecord_t* record) {
|
||||
process_word(keycodes, num_keycodes - 1, record);
|
||||
replace_ongoing_key(keycodes[num_keycodes - 1], ongoing_keycode, record);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ void invoke_key(uint16_t keycode, keyrecord_t* record);
|
|||
void replace_ongoing_key(uint16_t clever_keycode, uint16_t* ongoing_keycode, keyrecord_t* record);
|
||||
void process_word(uint16_t keycodes[], uint8_t num_keycodes, keyrecord_t* record);
|
||||
void finish_word(uint16_t keycodes[], uint8_t num_keycodes, uint16_t* ongoing_keycode, keyrecord_t* record);
|
||||
void finish_magic(uint16_t keycodes[], uint8_t num_keycodes, uint16_t* ongoing_keycode, keyrecord_t* record);
|
||||
|
||||
bool process_clever_keys(uint16_t keycode, keyrecord_t* record);
|
||||
void end_CK(keyrecord_t* record);
|
||||
|
|
|
|||
|
|
@ -19,8 +19,6 @@
|
|||
bool is_apos_dr = false;
|
||||
|
||||
bool process_macros(uint16_t keycode, keyrecord_t *record) {
|
||||
//const uint8_t mods = get_mods();
|
||||
//static bool is_shifted = false;
|
||||
|
||||
if (record->event.pressed) { // Handling of other macros (on press).
|
||||
switch (keycode) {
|
||||
|
|
@ -52,7 +50,7 @@ bool process_macros(uint16_t keycode, keyrecord_t *record) {
|
|||
|
||||
layer_clear();
|
||||
clear_oneshot_mods();
|
||||
clear_weak_mods();
|
||||
//clear_weak_mods();
|
||||
caps_word_off();
|
||||
disable_num_word();
|
||||
clear_recent_keys();
|
||||
|
|
@ -74,18 +72,7 @@ bool process_macros(uint16_t keycode, keyrecord_t *record) {
|
|||
return false;
|
||||
|
||||
case NUM_ODK:
|
||||
bool is_shifted = (get_mods() | get_weak_mods() | get_oneshot_mods()) & MOD_MASK_SHIFT;
|
||||
if (is_shifted) {
|
||||
del_weak_mods(MOD_MASK_SHIFT);
|
||||
del_oneshot_mods(MOD_MASK_SHIFT);
|
||||
unregister_mods(MOD_MASK_SHIFT);
|
||||
}
|
||||
tap_code(PG_ODK);
|
||||
|
||||
if (is_shifted) {
|
||||
is_shifted = false;
|
||||
set_oneshot_mods(MOD_BIT(KC_LSFT));
|
||||
}
|
||||
return true;
|
||||
|
||||
case PG_DEG:
|
||||
|
|
|
|||
|
|
@ -16,15 +16,12 @@
|
|||
|
||||
#include "odk_layer.h"
|
||||
|
||||
bool is_shifted = false;
|
||||
|
||||
bool process_odk_layer(uint16_t keycode, keyrecord_t *record) {
|
||||
|
||||
if (record->event.pressed) { // On press
|
||||
|
||||
const uint8_t mods = get_mods() | get_weak_mods() | get_oneshot_mods();
|
||||
//const uint8_t mods = get_mods() | get_oneshot_mods();
|
||||
//static bool is_shifted = false;
|
||||
|
||||
if (keycode == OS_ODK) {
|
||||
// Custom behaviour when alt-gr
|
||||
|
|
@ -36,13 +33,12 @@ bool process_odk_layer(uint16_t keycode, keyrecord_t *record) {
|
|||
} else if (keycode == PG_ODK) {
|
||||
// Special behaviour of PG_ODK when shifted
|
||||
// Shift must apply to the next keycode
|
||||
is_shifted = mods & MOD_MASK_SHIFT;
|
||||
if (is_shifted) {
|
||||
if (mods & MOD_MASK_SHIFT) {
|
||||
del_weak_mods(MOD_MASK_SHIFT);
|
||||
del_oneshot_mods(MOD_MASK_SHIFT);
|
||||
unregister_mods(MOD_MASK_SHIFT);
|
||||
tap_code(PG_ODK);
|
||||
add_weak_mods(MOD_BIT(KC_LSFT));
|
||||
set_oneshot_mods(MOD_BIT(KC_LSFT)); // Don't use weak mods !
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -61,23 +57,12 @@ bool process_odk_layer(uint16_t keycode, keyrecord_t *record) {
|
|||
break;
|
||||
|
||||
default:
|
||||
//tap_code(PG_ODK);
|
||||
// Don't use tap_code, it doesn't go through process_record.
|
||||
// therefore it doesn't trigger the special behaviour of PG_ODK described above
|
||||
invoke_key(PG_ODK, record);
|
||||
}
|
||||
}
|
||||
/* if (is_shifted) {
|
||||
is_shifted = false;
|
||||
//set_mods(mods);
|
||||
add_weak_mods(MOD_BIT(KC_LSFT));
|
||||
} */
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/* void odk_layer_exit_check(uint16_t keycode) {
|
||||
if (keycode == odk_keycode) {
|
||||
layer_off(_ODK);
|
||||
odk_keycode = KC_NO;
|
||||
}
|
||||
} */
|
||||
}
|
||||
|
|
@ -24,10 +24,7 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern bool is_shifted;
|
||||
|
||||
bool process_odk_layer(uint16_t keycode, keyrecord_t *record);
|
||||
//void odk_layer_exit_check(uint16_t keycode);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
|||
|
|
@ -299,6 +299,5 @@ uint16_t get_alt_repeat_key_keycode_user(uint16_t keycode, uint8_t mods) {
|
|||
if (recent[RECENT_SIZE - 1] != KC_NO) { return MAGIC; }
|
||||
if (get_last_keycode() == KC_NO) { return MAGIC; }
|
||||
|
||||
|
||||
return KC_TRNS; // Defer to default definitions.
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue