mirror of
https://github.com/openstenoproject/qmk
synced 2024-11-09 10:13:29 +00:00
Fix oneshot toggle logic (#16630)
* Fix oneshot toggle logic * Enable oneshots by default * Decrement eeconfig magic number due to eeconfig changes
This commit is contained in:
parent
42d084d1c0
commit
b8574efcd6
5 changed files with 15 additions and 16 deletions
|
@ -101,7 +101,7 @@ void action_exec(keyevent_t event) {
|
|||
keyrecord_t record = {.event = event};
|
||||
|
||||
#ifndef NO_ACTION_ONESHOT
|
||||
if (!keymap_config.oneshot_disable) {
|
||||
if (keymap_config.oneshot_enable) {
|
||||
# if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0))
|
||||
if (has_oneshot_layer_timed_out()) {
|
||||
clear_oneshot_layer_state(ONESHOT_OTHER_KEY_PRESSED);
|
||||
|
@ -258,7 +258,7 @@ void process_record(keyrecord_t *record) {
|
|||
|
||||
if (!process_record_quantum(record)) {
|
||||
#ifndef NO_ACTION_ONESHOT
|
||||
if (is_oneshot_layer_active() && record->event.pressed && !keymap_config.oneshot_disable) {
|
||||
if (is_oneshot_layer_active() && record->event.pressed && keymap_config.oneshot_enable) {
|
||||
clear_oneshot_layer_state(ONESHOT_OTHER_KEY_PRESSED);
|
||||
}
|
||||
#endif
|
||||
|
@ -323,7 +323,7 @@ void process_action(keyrecord_t *record, action_t action) {
|
|||
# ifdef SWAP_HANDS_ENABLE
|
||||
&& !(action.kind.id == ACT_SWAP_HANDS && action.swap.code == OP_SH_ONESHOT)
|
||||
# endif
|
||||
&& !keymap_config.oneshot_disable) {
|
||||
&& keymap_config.oneshot_enable) {
|
||||
clear_oneshot_layer_state(ONESHOT_OTHER_KEY_PRESSED);
|
||||
do_release_oneshot = !is_oneshot_layer_active();
|
||||
}
|
||||
|
@ -367,7 +367,7 @@ void process_action(keyrecord_t *record, action_t action) {
|
|||
# ifndef NO_ACTION_ONESHOT
|
||||
case MODS_ONESHOT:
|
||||
// Oneshot modifier
|
||||
if (keymap_config.oneshot_disable) {
|
||||
if (!keymap_config.oneshot_enable) {
|
||||
if (event.pressed) {
|
||||
if (mods) {
|
||||
if (IS_MOD(action.key.code) || action.key.code == KC_NO) {
|
||||
|
@ -613,7 +613,7 @@ void process_action(keyrecord_t *record, action_t action) {
|
|||
# ifndef NO_ACTION_ONESHOT
|
||||
case OP_ONESHOT:
|
||||
// Oneshot modifier
|
||||
if (keymap_config.oneshot_disable) {
|
||||
if (!keymap_config.oneshot_enable) {
|
||||
if (event.pressed) {
|
||||
layer_on(action.layer_tap.val);
|
||||
} else {
|
||||
|
|
|
@ -155,7 +155,7 @@ void clear_oneshot_swaphands(void) {
|
|||
* FIXME: needs doc
|
||||
*/
|
||||
void set_oneshot_layer(uint8_t layer, uint8_t state) {
|
||||
if (!keymap_config.oneshot_disable) {
|
||||
if (keymap_config.oneshot_enable) {
|
||||
oneshot_layer_data = layer << 3 | state;
|
||||
layer_on(layer);
|
||||
# if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0))
|
||||
|
@ -184,7 +184,7 @@ void reset_oneshot_layer(void) {
|
|||
void clear_oneshot_layer_state(oneshot_fullfillment_t state) {
|
||||
uint8_t start_state = oneshot_layer_data;
|
||||
oneshot_layer_data &= ~state;
|
||||
if ((!get_oneshot_layer_state() && start_state != oneshot_layer_data) && !keymap_config.oneshot_disable) {
|
||||
if ((!get_oneshot_layer_state() && start_state != oneshot_layer_data) && keymap_config.oneshot_enable) {
|
||||
layer_off(get_oneshot_layer());
|
||||
reset_oneshot_layer();
|
||||
}
|
||||
|
@ -202,9 +202,8 @@ bool is_oneshot_layer_active(void) {
|
|||
* FIXME: needs doc
|
||||
*/
|
||||
void oneshot_set(bool active) {
|
||||
const bool disable = !active;
|
||||
if (keymap_config.oneshot_disable != disable) {
|
||||
keymap_config.oneshot_disable = disable;
|
||||
if (keymap_config.oneshot_enable != active) {
|
||||
keymap_config.oneshot_enable = active;
|
||||
eeconfig_update_keymap(keymap_config.raw);
|
||||
clear_oneshot_layer_state(ONESHOT_OTHER_KEY_PRESSED);
|
||||
dprintf("Oneshot: active: %d\n", active);
|
||||
|
@ -216,7 +215,7 @@ void oneshot_set(bool active) {
|
|||
* FIXME: needs doc
|
||||
*/
|
||||
void oneshot_toggle(void) {
|
||||
oneshot_set(!keymap_config.oneshot_disable);
|
||||
oneshot_set(!keymap_config.oneshot_enable);
|
||||
}
|
||||
|
||||
/** \brief enable oneshot
|
||||
|
@ -236,7 +235,7 @@ void oneshot_disable(void) {
|
|||
}
|
||||
|
||||
bool is_oneshot_enabled(void) {
|
||||
return !keymap_config.oneshot_disable;
|
||||
return keymap_config.oneshot_enable;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -414,7 +413,7 @@ void del_oneshot_mods(uint8_t mods) {
|
|||
* FIXME: needs doc
|
||||
*/
|
||||
void set_oneshot_mods(uint8_t mods) {
|
||||
if (!keymap_config.oneshot_disable) {
|
||||
if (keymap_config.oneshot_enable) {
|
||||
if (oneshot_mods != mods) {
|
||||
# if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0))
|
||||
oneshot_time = timer_read();
|
||||
|
|
|
@ -46,7 +46,7 @@ void eeconfig_init_quantum(void) {
|
|||
eeprom_update_byte(EECONFIG_DEFAULT_LAYER, 0);
|
||||
default_layer_state = 0;
|
||||
eeprom_update_byte(EECONFIG_KEYMAP_LOWER_BYTE, 0);
|
||||
eeprom_update_byte(EECONFIG_KEYMAP_UPPER_BYTE, 0);
|
||||
eeprom_update_byte(EECONFIG_KEYMAP_UPPER_BYTE, 0x4);
|
||||
eeprom_update_byte(EECONFIG_MOUSEKEY_ACCEL, 0);
|
||||
eeprom_update_byte(EECONFIG_BACKLIGHT, 0);
|
||||
eeprom_update_byte(EECONFIG_AUDIO, 0xFF); // On by default
|
||||
|
|
|
@ -21,7 +21,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#include <stdbool.h>
|
||||
|
||||
#ifndef EECONFIG_MAGIC_NUMBER
|
||||
# define EECONFIG_MAGIC_NUMBER (uint16_t)0xFEE9 // When changing, decrement this value to avoid future re-init issues
|
||||
# define EECONFIG_MAGIC_NUMBER (uint16_t)0xFEE8 // When changing, decrement this value to avoid future re-init issues
|
||||
#endif
|
||||
#define EECONFIG_MAGIC_NUMBER_OFF (uint16_t)0xFFFF
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ typedef union {
|
|||
bool nkro : 1;
|
||||
bool swap_lctl_lgui : 1;
|
||||
bool swap_rctl_rgui : 1;
|
||||
bool oneshot_disable : 1;
|
||||
bool oneshot_enable : 1;
|
||||
};
|
||||
} keymap_config_t;
|
||||
|
||||
|
|
Loading…
Reference in a new issue