From 0e984b6e7e216a62df0b5d53f6a8f0d4bc13dca3 Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Mon, 1 Mar 2021 08:57:02 -0800 Subject: Add ability to toggle One Shot functionality (#4198) Co-authored-by: Nick Brassel Co-authored-by: Ryan --- quantum/keycode_config.h | 1 + quantum/quantum.c | 11 +++++++++++ quantum/quantum_keycodes.h | 9 +++++++++ 3 files changed, 21 insertions(+) (limited to 'quantum') diff --git a/quantum/keycode_config.h b/quantum/keycode_config.h index f878168c5f..d7e334fdc8 100644 --- a/quantum/keycode_config.h +++ b/quantum/keycode_config.h @@ -37,6 +37,7 @@ typedef union { bool nkro : 1; bool swap_lctl_lgui : 1; bool swap_rctl_rgui : 1; + bool oneshot_disable : 1; }; } keymap_config_t; diff --git a/quantum/quantum.c b/quantum/quantum.c index ef751a2331..78601ce6bf 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -318,6 +318,17 @@ bool process_record_quantum(keyrecord_t *record) { case OUT_BT: set_output(OUTPUT_BLUETOOTH); return false; +#endif +#ifndef NO_ACTION_ONESHOT + case ONESHOT_TOGGLE: + oneshot_toggle(); + break; + case ONESHOT_ENABLE: + oneshot_enable(); + break; + case ONESHOT_DISABLE: + oneshot_disable(); + break; #endif } } diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h index e0f5dbc61e..63945a17ca 100644 --- a/quantum/quantum_keycodes.h +++ b/quantum/quantum_keycodes.h @@ -578,6 +578,10 @@ enum quantum_keycodes { #endif + ONESHOT_ENABLE, + ONESHOT_DISABLE, + ONESHOT_TOGGLE, + // always leave at the end SAFE_RANGE }; @@ -885,3 +889,8 @@ enum quantum_keycodes { #define DM_RSTP DYN_REC_STOP #define DM_PLY1 DYN_MACRO_PLAY1 #define DM_PLY2 DYN_MACRO_PLAY2 + +// One Shot toggle +#define OS_TOGG ONESHOT_TOGGLE +#define OS_ON ONESHOT_ENABLE +#define OS_OFF ONESHOT_DISABLE -- cgit v1.2.3