mirror of
https://github.com/qmk/qmk_userspace.git
synced 2025-11-08 04:29:58 -05:00
custom layers exit check
This commit is contained in:
parent
a9c2963cf6
commit
c092211848
7 changed files with 28 additions and 21 deletions
|
|
@ -19,7 +19,7 @@
|
|||
//static uint16_t num_word_timer = 0;
|
||||
//static bool is_num_word_on = false;
|
||||
bool is_num_word_on = false;
|
||||
bool exit_num_word = false;
|
||||
static bool exit_num_word = false;
|
||||
|
||||
bool is_num_word_enabled(void) {
|
||||
return is_num_word_on;
|
||||
|
|
@ -47,7 +47,7 @@ void toggle_num_word(void) {
|
|||
}
|
||||
}
|
||||
|
||||
bool should_terminate_num_word(uint16_t keycode, const keyrecord_t *record) {
|
||||
bool should_exit_num_word(uint16_t keycode, const keyrecord_t *record) {
|
||||
|
||||
switch (keycode) {
|
||||
// Keycodes which should not disable num word mode.
|
||||
|
|
@ -66,7 +66,7 @@ bool should_terminate_num_word(uint16_t keycode, const keyrecord_t *record) {
|
|||
|
||||
// Misc
|
||||
case KC_BSPC:
|
||||
case FG_ODK: // Not to exit Numword when chording it with Typo
|
||||
case FG_ODK: // Not to exit Numword when chording it with ODK
|
||||
case NUMWORD: // For the combo NUMWORD to work
|
||||
|
||||
/*
|
||||
|
|
@ -111,6 +111,10 @@ bool process_numword(uint16_t keycode, const keyrecord_t *record) {
|
|||
break; */
|
||||
}
|
||||
|
||||
exit_num_word = should_terminate_num_word(keycode, record);
|
||||
exit_num_word = should_exit_num_word(keycode, record);
|
||||
return true;
|
||||
}
|
||||
|
||||
void numword_exit_check(void) {
|
||||
if (exit_num_word) { disable_num_word(); }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,11 +19,12 @@
|
|||
#include "keymap.h"
|
||||
|
||||
bool is_num_word_enabled(void);
|
||||
extern bool exit_num_word;
|
||||
//extern bool exit_num_word;
|
||||
extern bool is_num_word_on;
|
||||
|
||||
void enable_num_word(void);
|
||||
extern void disable_num_word(void);
|
||||
void toggle_num_word(void);
|
||||
|
||||
bool process_numword(uint16_t keycode, const keyrecord_t *record);
|
||||
bool process_numword(uint16_t keycode, const keyrecord_t *record);
|
||||
void numword_exit_check(void);
|
||||
|
|
@ -17,7 +17,6 @@
|
|||
#include "odk_layer.h"
|
||||
|
||||
static uint16_t odk_keycode = KC_NO;
|
||||
//bool exit_odk = false;
|
||||
|
||||
bool process_odk_layer(uint16_t keycode, keyrecord_t *record) {
|
||||
|
||||
|
|
@ -104,7 +103,7 @@ bool process_odk_layer(uint16_t keycode, keyrecord_t *record) {
|
|||
case FG_ODK:
|
||||
break;
|
||||
default:
|
||||
//if (exit_odk) { odk_layer_off(); }
|
||||
//if (exit_odk) { odk_layer_exit_check(); }
|
||||
if (keycode == odk_keycode) {
|
||||
layer_off(_ODK);
|
||||
odk_keycode = KC_NO;
|
||||
|
|
@ -114,7 +113,7 @@ bool process_odk_layer(uint16_t keycode, keyrecord_t *record) {
|
|||
return true;
|
||||
}
|
||||
|
||||
void odk_layer_off(uint16_t keycode) {
|
||||
void odk_layer_exit_check(uint16_t keycode) {
|
||||
if (keycode == odk_keycode) {
|
||||
layer_off(_ODK);
|
||||
odk_keycode = KC_NO;
|
||||
|
|
|
|||
|
|
@ -24,12 +24,8 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern bool exit_odk;
|
||||
|
||||
void odk_layer_off(uint16_t keycode);
|
||||
|
||||
//bool update_oneshot_odk(oneshot_state *state, uint16_t keycode, keyrecord_t *record);
|
||||
bool process_odk_layer(uint16_t keycode, keyrecord_t *record);
|
||||
void odk_layer_exit_check(uint16_t keycode);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,8 +24,8 @@ oneshot_state os_altgr_state = os_up_unqueued;
|
|||
oneshot_state os_win_state = os_up_unqueued;
|
||||
|
||||
uint8_t os4a_layer = 0;
|
||||
bool exit_os4a_layer = false;
|
||||
bool pending_OSL = false;
|
||||
static bool exit_os4a_layer = false;
|
||||
static bool pending_OSL = false;
|
||||
|
||||
void os4a_layer_on(uint8_t layer) {
|
||||
layer_on(layer);
|
||||
|
|
@ -108,3 +108,7 @@ bool process_mods(uint16_t keycode, keyrecord_t *record) {
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
void os4a_layer_exit_check(void) {
|
||||
if (os4a_layer != 0 && exit_os4a_layer) { os4a_layer_off(os4a_layer); }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,8 +25,8 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
extern uint8_t os4a_layer;
|
||||
extern bool exit_os4a_layer;
|
||||
extern bool pending_OSL;
|
||||
//extern bool exit_os4a_layer;
|
||||
//extern bool pending_OSL;
|
||||
|
||||
void os4a_layer_off(uint8_t layer);
|
||||
void os4a_layer_on(uint8_t layer);
|
||||
|
|
@ -43,6 +43,8 @@ void mouse_mods_key_up(uint16_t keycode, keyrecord_t *record);
|
|||
|
||||
bool process_mods(uint16_t keycode, keyrecord_t *record);
|
||||
|
||||
void os4a_layer_exit_check(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -112,9 +112,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(); }
|
||||
odk_layer_off(keycode);
|
||||
//if (os4a_layer != 0 && exit_os4a_layer) { os4a_layer_off(os4a_layer); }
|
||||
os4a_layer_exit_check();
|
||||
numword_exit_check();
|
||||
odk_layer_exit_check(keycode);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue