mirror of
https://github.com/qmk/qmk_userspace.git
synced 2026-03-10 02:10:25 -04:00
ODK layer
This commit is contained in:
parent
984cab17e8
commit
a15227486a
12 changed files with 96 additions and 96 deletions
|
|
@ -22,35 +22,39 @@
|
|||
bool clever_key_finder(uint16_t next_keycode, keyrecord_t* record) {
|
||||
|
||||
uint16_t prev_keycode = recent[RECENT_SIZE - 1];
|
||||
//const uint8_t mods = get_mods();
|
||||
//const bool isCaps = is_caps_lock_on() || is_caps_word_on();
|
||||
|
||||
if (isLetter(next_keycode) || next_keycode == E_CIRC) {
|
||||
switch (prev_keycode) {
|
||||
case FG_EXLM:
|
||||
case FG_QUES:
|
||||
//case FG_3PTS:
|
||||
case FG_2PTS:
|
||||
// Add space between punctuation and letters.
|
||||
invoke_key(KC_SPC, record);
|
||||
//if (next_keycode == FG_J) { layer_on(_TYPO); }
|
||||
if (isLetter(next_keycode) || isSendStringMacro(next_keycode)) {
|
||||
switch (prev_keycode) {
|
||||
case FG_EXLM:
|
||||
case FG_QUES:
|
||||
case FG_3PTS:
|
||||
case FG_2PTS:
|
||||
// Add space between punctuation and letters.
|
||||
invoke_key(KC_SPC, record);
|
||||
set_last_keycode(next_keycode);
|
||||
|
||||
case KC_SPC:
|
||||
switch (recent[RECENT_SIZE - 2]) {
|
||||
case FG_EXLM:
|
||||
case FG_QUES:
|
||||
//case FG_3PTS:
|
||||
case FG_POIN:
|
||||
// Add OS shift at the beginning of sentences.
|
||||
if (!is_caps_lock_on()) { set_oneshot_mods(MOD_BIT(KC_LSFT)); }
|
||||
break;
|
||||
}
|
||||
case KC_SPC:
|
||||
switch (recent[RECENT_SIZE - 2]) {
|
||||
case FG_EXLM:
|
||||
case FG_QUES:
|
||||
case FG_3PTS:
|
||||
case FG_POIN:
|
||||
// Add OS shift at the beginning of sentences.
|
||||
if (!is_caps_lock_on()) { set_oneshot_mods(MOD_BIT(KC_LSFT)); }
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
switch (prev_keycode) {
|
||||
|
||||
/* case FG_C:
|
||||
if (next_keycode == FG_A) {
|
||||
invoke_key(FG_U,record);
|
||||
break;
|
||||
} */
|
||||
|
||||
case FG_Q:
|
||||
switch (next_keycode) {
|
||||
|
||||
|
|
@ -60,7 +64,6 @@ bool clever_key_finder(uint16_t next_keycode, keyrecord_t* record) {
|
|||
case FG_A:
|
||||
case FG_O:
|
||||
case FG_EACU:
|
||||
case E_CIRC:
|
||||
case FG_APOS:
|
||||
invoke_key(FG_U, record);
|
||||
break;
|
||||
|
|
@ -117,24 +120,11 @@ bool clever_key_finder(uint16_t next_keycode, keyrecord_t* record) {
|
|||
// On ajoute un espace insécable s'il n'a pas été entré avant le point d'exclamation.
|
||||
// Il ne faut pas tester cette fonctionnalité avec Word, qui ajoute cet espace automatiquement.
|
||||
if (isLetter(recent[RECENT_SIZE - 1])) {
|
||||
|
||||
/* if ((mods | get_oneshot_mods() | get_weak_mods()) & MOD_MASK_SHIFT) {
|
||||
del_weak_mods(MOD_MASK_SHIFT);
|
||||
del_oneshot_mods(MOD_MASK_SHIFT);
|
||||
unregister_mods(MOD_MASK_SHIFT);
|
||||
} */
|
||||
invoke_key(KC_SPC, record);
|
||||
//set_mods(mods);
|
||||
return replace_next_key(next_keycode, record);
|
||||
}
|
||||
break;
|
||||
|
||||
/* case KC_SPC:
|
||||
if (get_last_keycode() == FG_TYPO) {
|
||||
invoke_key(FG_A, record);
|
||||
}
|
||||
break; */
|
||||
|
||||
case MAGIC:
|
||||
switch (prev_keycode) {
|
||||
|
||||
|
|
@ -255,23 +245,11 @@ bool clever_key_finder(uint16_t next_keycode, keyrecord_t* record) {
|
|||
}
|
||||
break;
|
||||
|
||||
/* case CA_CED:
|
||||
//layer_off(_TYPO);
|
||||
return finish_word((uint16_t[]) {FG_C, FG_A}, 2, record); */
|
||||
|
||||
case OU_GRV:
|
||||
layer_off(_TYPO);
|
||||
return finish_word((uint16_t[]) {FG_O, FG_TYPO, FG_T}, 3, record);
|
||||
|
||||
case AGRV_SPC:
|
||||
/* const 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);
|
||||
}
|
||||
invoke_key(FG_TYPO, record);
|
||||
if (is_shifted) { set_oneshot_mods(MOD_BIT(KC_LSFT)); } */
|
||||
layer_off(_TYPO);
|
||||
return finish_word((uint16_t[]) {FG_AGR, KC_SPC}, 2, record);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -72,15 +72,20 @@ uint16_t get_next_keycode(uint16_t keycode, keyrecord_t* record) {
|
|||
}
|
||||
|
||||
// Handles custom keycodes.
|
||||
if IS_QK_USER(keycode) { return keycode; }
|
||||
if (isSendStringMacro(keycode)) { return keycode; }
|
||||
//if (keycode == FG_CCED) { return FG_CCED; }
|
||||
if (IS_LAYER_ON(_TYPO)) {
|
||||
switch (keycode) {
|
||||
case FG_K:
|
||||
case FG_J:
|
||||
case FG_AROB:
|
||||
case FG_ECIR:
|
||||
case FG_CCED:
|
||||
break;
|
||||
case FG_3PTS:
|
||||
case KC_SPC: // In order to uppercase J after '?' for ex.
|
||||
return keycode;
|
||||
/* case FG_C:
|
||||
return FG_CCED; */
|
||||
default:
|
||||
return KC_NO;
|
||||
}
|
||||
|
|
@ -163,7 +168,7 @@ bool finish_word(uint16_t keycodes[], uint8_t num_keycodes, keyrecord_t* record)
|
|||
}
|
||||
|
||||
bool finish_magic(uint16_t keycodes[], uint8_t num_keycodes, keyrecord_t* record) {
|
||||
// Setting the key to be repeated to match the key buffer.
|
||||
// Set the keycode to be repeated to match the key buffer.
|
||||
set_last_keycode(keycodes[num_keycodes - 1]);
|
||||
return finish_word(keycodes, num_keycodes, record);
|
||||
}
|
||||
|
|
@ -179,17 +184,3 @@ bool process_clever_keys(uint16_t keycode, keyrecord_t* record) {
|
|||
}
|
||||
return true; // If no clever key was found, process keycode normally.
|
||||
}
|
||||
|
||||
bool process_accent(uint16_t accent, uint16_t letter, keyrecord_t* record) {
|
||||
const bool is_shifted = (get_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_code16(accent);
|
||||
//set_mods(mods);
|
||||
if (is_shifted) { set_oneshot_mods(MOD_BIT(KC_LSFT)); }
|
||||
invoke_key(letter, record);
|
||||
return true;
|
||||
}
|
||||
|
|
@ -44,7 +44,7 @@ bool finish_magic(uint16_t keycodes[], uint8_t num_keycodes, keyrecord_t* record
|
|||
|
||||
bool process_clever_keys(uint16_t keycode, keyrecord_t* record);
|
||||
|
||||
bool process_accent(uint16_t accent, uint16_t letter, keyrecord_t* record);
|
||||
//bool process_accent(uint16_t accent, uint16_t letter, keyrecord_t* record);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
typedef enum {
|
||||
os_up_unqueued,
|
||||
os_up_queued,
|
||||
//os_up_queued_used,
|
||||
os_down_unused,
|
||||
os_down_used,
|
||||
} oneshot_state;
|
||||
|
|
|
|||
|
|
@ -78,12 +78,10 @@ bool update_oneshot_typo(oneshot_state *state, uint16_t keycode, keyrecord_t *re
|
|||
return true; */
|
||||
case os_up_queued:
|
||||
*state = os_up_queued_used;
|
||||
dprintf("key down, layer: %d, os_up_queued -> os_up_queued_used\n", _TYPO);
|
||||
return true;
|
||||
case os_up_queued_used:
|
||||
*state = os_up_unqueued;
|
||||
layer_off(_TYPO);
|
||||
dprintf("key down (off), layer: %d, os_up_queued_used -> os_up_unqueued\n", _TYPO);
|
||||
//return false;
|
||||
default:
|
||||
break;
|
||||
|
|
@ -99,12 +97,10 @@ bool update_oneshot_typo(oneshot_state *state, uint16_t keycode, keyrecord_t *re
|
|||
case os_up_queued:
|
||||
*state = os_up_unqueued;
|
||||
layer_off(_TYPO);
|
||||
dprintf("key up (off), layer: %d, os_up_queued -> os_up_unqueued\n", _TYPO);
|
||||
return true;
|
||||
case os_up_queued_used:
|
||||
*state = os_up_unqueued;
|
||||
layer_off(_TYPO);
|
||||
dprintf("key up (off), layer: %d, os_up_queued_used -> os_up_unqueued\n", _TYPO);
|
||||
return true;
|
||||
default:
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -16,8 +16,8 @@
|
|||
|
||||
#include "typo_layer.h"
|
||||
|
||||
|
||||
bool exit_typo = false;
|
||||
static uint16_t typo_keycode = KC_NO;
|
||||
//bool exit_typo = false;
|
||||
|
||||
bool process_typo_layer(uint16_t keycode, keyrecord_t *record) {
|
||||
|
||||
|
|
@ -41,6 +41,7 @@ bool process_typo_layer(uint16_t keycode, keyrecord_t *record) {
|
|||
unregister_mods(MOD_MASK_SHIFT);
|
||||
}
|
||||
layer_on(_TYPO);
|
||||
typo_keycode = KC_NO;
|
||||
return false;
|
||||
|
||||
} else if (keycode == FG_TYPO) {
|
||||
|
|
@ -56,13 +57,19 @@ bool process_typo_layer(uint16_t keycode, keyrecord_t *record) {
|
|||
return true;
|
||||
|
||||
} else if (IS_LAYER_ON(_TYPO)) {
|
||||
if (typo_keycode == KC_NO) { typo_keycode = keycode; }
|
||||
//if (!IS_QK_USER(keycode)) { typo_keycode = keycode; }
|
||||
|
||||
switch (keycode) {
|
||||
case FG_AROB:
|
||||
case FG_K:
|
||||
case FG_J:
|
||||
case FG_ECIR:
|
||||
case OU_GRV:
|
||||
case FG_CCED:
|
||||
case AGRV_SPC:
|
||||
case KC_SPC: // When space is added by Clever Keys
|
||||
case FG_3PTS:
|
||||
case CNL_TYPO:
|
||||
break;
|
||||
|
||||
|
|
@ -87,21 +94,29 @@ bool process_typo_layer(uint16_t keycode, keyrecord_t *record) {
|
|||
set_oneshot_mods(MOD_BIT(KC_LSFT));
|
||||
is_shifted = false;
|
||||
}
|
||||
exit_typo = true;
|
||||
//exit_typo = true;
|
||||
} else {
|
||||
typo_keycode = KC_NO;
|
||||
}
|
||||
/* } else { // On release
|
||||
} else { // On release
|
||||
switch (keycode) {
|
||||
case OS_TYPO:
|
||||
case FG_TYPO:
|
||||
break;
|
||||
default:
|
||||
if (exit_typo) { typo_layer_off(); }
|
||||
} */
|
||||
//if (exit_typo) { typo_layer_off(); }
|
||||
if (keycode == typo_keycode) {
|
||||
layer_off(_TYPO);
|
||||
typo_keycode = KC_NO;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void typo_layer_off(void) {
|
||||
layer_off(_TYPO);
|
||||
exit_typo = false;
|
||||
void typo_layer_off(uint16_t keycode) {
|
||||
if (keycode == typo_keycode) {
|
||||
layer_off(_TYPO);
|
||||
typo_keycode = KC_NO;
|
||||
}
|
||||
}
|
||||
|
|
@ -26,7 +26,7 @@ extern "C" {
|
|||
|
||||
extern bool exit_typo;
|
||||
|
||||
void typo_layer_off(void);
|
||||
void typo_layer_off(uint16_t keycode);
|
||||
|
||||
//bool update_oneshot_typo(oneshot_state *state, uint16_t keycode, keyrecord_t *record);
|
||||
bool process_typo_layer(uint16_t keycode, keyrecord_t *record);
|
||||
|
|
|
|||
|
|
@ -25,6 +25,8 @@ bool isLetter(uint16_t keycode) {
|
|||
case KC_X ... KC_Z:
|
||||
case FG_U:
|
||||
case FG_E:
|
||||
case FG_AGR:
|
||||
case FG_ECIR:
|
||||
case KC_GRV ... KC_DOT:
|
||||
return true;
|
||||
|
||||
|
|
@ -33,6 +35,18 @@ bool isLetter(uint16_t keycode) {
|
|||
}
|
||||
}
|
||||
|
||||
bool isSendStringMacro(uint16_t keycode) {
|
||||
switch (keycode) {
|
||||
case AGRV_SPC:
|
||||
case OU_GRV:
|
||||
case MAGIC:
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// This function extracts the base keycode of MT and LT,
|
||||
// even if the tap/hold key is a custom one, with non-basic tap keycode.
|
||||
uint16_t tap_hold_extractor(uint16_t keycode) {
|
||||
|
|
@ -47,9 +61,9 @@ uint16_t tap_hold_extractor(uint16_t keycode) {
|
|||
|
||||
bool caps_word_press_user(uint16_t keycode) {
|
||||
|
||||
// Caps Word shouldn’t be applied with Alt-gr
|
||||
// Managing underscore on alt gr + E.
|
||||
// Underscore must continue Caps Word, without shifting.
|
||||
// Caps Word shouldn't be applied with Alt-gr
|
||||
// Managing underscore on alt gr + E/T.
|
||||
// Underscore and slash must continue Caps Word, without shifting.
|
||||
if ((get_mods() & MOD_BIT(KC_ALGR))) {
|
||||
switch (keycode) {
|
||||
case FG_E:
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
#include "keymap.h"
|
||||
|
||||
bool isLetter(uint16_t keycode);
|
||||
bool isSendStringMacro(uint16_t keycode);
|
||||
bool is_caps_lock_on(void);
|
||||
uint16_t tap_hold_extractor(uint16_t keycode);
|
||||
|
||||
|
|
|
|||
|
|
@ -97,12 +97,12 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
|||
// Custom tap-hold keys
|
||||
if (!process_custom_tap_hold(keycode, record)) { return false; }
|
||||
|
||||
// Custom behaviour of the typo dead-key
|
||||
if (!process_typo_layer(keycode, record)) { return false; }
|
||||
|
||||
// Macros
|
||||
if (!process_macros(keycode, record)) { return false; }
|
||||
|
||||
// Custom behaviour of the typo dead-key
|
||||
if (!process_typo_layer(keycode, record)) { return false; }
|
||||
|
||||
// Clever keys
|
||||
if (!process_clever_keys(keycode, record)) { return false; }
|
||||
|
||||
|
|
@ -111,11 +111,10 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
|||
}
|
||||
|
||||
void post_process_record_user(uint16_t keycode, keyrecord_t* record) {
|
||||
//
|
||||
|
||||
if (os4a_layer != 0 && exit_os4a_layer) { os4a_layer_off(os4a_layer); }
|
||||
if (exit_num_word) { disable_num_word(); }
|
||||
//if (exit_typo && keycode != FG_TYPO) { typo_layer_off(); }
|
||||
if (exit_typo) { typo_layer_off(); }
|
||||
typo_layer_off(keycode);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -245,9 +244,9 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
|||
*/
|
||||
[_TYPO] = LAYOUT(
|
||||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
|
||||
_______, OU_GRV, _______, _______, FG_U, _______, _______, FG_J, FG_D, FG_AROB, _______, _______,
|
||||
_______, OU_GRV, _______, _______, FG_3PTS, _______, _______, FG_J, FG_D, FG_AROB, _______, _______,
|
||||
_______, _______, _______, _______, FG_F, _______, _______, _______, _______, _______, _______, FG_CCED, _______, FG_K, CNL_TYPO, _______,
|
||||
_______, _______, _______, _______, FG_O, _______, AGRV_SPC, _______, _______, _______
|
||||
_______, _______, _______, _______, FG_ECIR, _______, AGRV_SPC, _______, _______, _______
|
||||
),
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ enum custom_keycodes {
|
|||
CAPSWORD,
|
||||
AGRV_SPC,
|
||||
OU_GRV,
|
||||
E_CIRC,
|
||||
//E_CIRC,
|
||||
/* I_CIRC,
|
||||
A_CIRC,
|
||||
O_CIRC,
|
||||
|
|
@ -82,6 +82,7 @@ enum custom_keycodes {
|
|||
#define TG_APOD TG(_APOS_DR)
|
||||
#define MT_SLSH SFT_T(FG_SLSH)
|
||||
#define MT_1 SFT_T(KC_1)
|
||||
#define E_CIRC S(FG_0)
|
||||
//#define OS_TYPO OSL(_TYPO)
|
||||
|
||||
// One shot mods
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@
|
|||
|
||||
/* Shifted symbols
|
||||
* ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐
|
||||
* │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
|
||||
* │ │ │ │ │ │ │ │ │ │ │ … │ │ │ │
|
||||
* ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤
|
||||
* │ │ │ ! │ │ │ │ │ │ │ ? │ : │ ≠ │ │ │
|
||||
* ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┐ │
|
||||
|
|
@ -106,12 +106,17 @@
|
|||
* │ │ │ │ │ │ │ │ │
|
||||
* └────┴────┴────┴────────────────────────┴────┴────┴────┴────┘
|
||||
*/
|
||||
|
||||
// Row 3
|
||||
#define FG_3PTS S(FG_0) // …
|
||||
|
||||
// Row 2
|
||||
#define FG_EXLM S(FG_VIRG) // !
|
||||
#define FG_QUES S(FG_APOS) // ?
|
||||
#define FG_2PTS S(FG_POIN) // :
|
||||
#define FG_DIFF S(FG_EGAL) // ≠
|
||||
|
||||
|
||||
// Row 4
|
||||
//#define FG_PVIR S(FG_TYPO)
|
||||
|
||||
|
|
@ -122,7 +127,7 @@
|
|||
|
||||
/* AltGr symbols
|
||||
* ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐
|
||||
* │ │ ₁ │ ₂ │ ₃ │ ₄ │ ₅ │ ₆ │ ₇ │ ₈ │ ₉ │ ₀ │ à │ │ │
|
||||
* │ │ ₁ │ ₂ │ ₃ │ ₄ │ ₅ │ ₆ │ ₇ │ ₈ │ ₉ │ ₀ │ à │ ê │ │
|
||||
* ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤
|
||||
* │ │ ^ │ ! │ = │ $ │ % │ # │ ; │ ' │ ? │ : │ │ │ │
|
||||
* ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┐ │
|
||||
|
|
@ -137,6 +142,7 @@
|
|||
|
||||
// Row 1
|
||||
#define FG_AGR ALGR(FG_SLSH)
|
||||
#define FG_ECIR ALGR(FG_ASTX)
|
||||
|
||||
// Row 2
|
||||
#define FG_ACIR ALGR(FG_X) // ^
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue