summaryrefslogtreecommitdiff
path: root/quantum/action_util.c
diff options
context:
space:
mode:
authorDrashna Jaelre <drashna@live.com>2022-03-13 18:11:42 -0700
committerGitHub <noreply@github.com>2022-03-14 01:11:42 +0000
commitb8574efcd67a394c423ac29ce280ee09517a1aee (patch)
tree1b8b4e6250fbcac53dff50acadb403a7d2199e1f /quantum/action_util.c
parent42d084d1c0816366a68b8614b395062fc6e47ec0 (diff)
Fix oneshot toggle logic (#16630)
* Fix oneshot toggle logic * Enable oneshots by default * Decrement eeconfig magic number due to eeconfig changes
Diffstat (limited to 'quantum/action_util.c')
-rw-r--r--quantum/action_util.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/quantum/action_util.c b/quantum/action_util.c
index cf81370d4a..738410a4ac 100644
--- a/quantum/action_util.c
+++ b/quantum/action_util.c
@@ -155,7 +155,7 @@ void clear_oneshot_swaphands(void) {
155 * FIXME: needs doc 155 * FIXME: needs doc
156 */ 156 */
157void set_oneshot_layer(uint8_t layer, uint8_t state) { 157void set_oneshot_layer(uint8_t layer, uint8_t state) {
158 if (!keymap_config.oneshot_disable) { 158 if (keymap_config.oneshot_enable) {
159 oneshot_layer_data = layer << 3 | state; 159 oneshot_layer_data = layer << 3 | state;
160 layer_on(layer); 160 layer_on(layer);
161# if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0)) 161# if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0))
@@ -184,7 +184,7 @@ void reset_oneshot_layer(void) {
184void clear_oneshot_layer_state(oneshot_fullfillment_t state) { 184void clear_oneshot_layer_state(oneshot_fullfillment_t state) {
185 uint8_t start_state = oneshot_layer_data; 185 uint8_t start_state = oneshot_layer_data;
186 oneshot_layer_data &= ~state; 186 oneshot_layer_data &= ~state;
187 if ((!get_oneshot_layer_state() && start_state != oneshot_layer_data) && !keymap_config.oneshot_disable) { 187 if ((!get_oneshot_layer_state() && start_state != oneshot_layer_data) && keymap_config.oneshot_enable) {
188 layer_off(get_oneshot_layer()); 188 layer_off(get_oneshot_layer());
189 reset_oneshot_layer(); 189 reset_oneshot_layer();
190 } 190 }
@@ -202,9 +202,8 @@ bool is_oneshot_layer_active(void) {
202 * FIXME: needs doc 202 * FIXME: needs doc
203 */ 203 */
204void oneshot_set(bool active) { 204void oneshot_set(bool active) {
205 const bool disable = !active; 205 if (keymap_config.oneshot_enable != active) {
206 if (keymap_config.oneshot_disable != disable) { 206 keymap_config.oneshot_enable = active;
207 keymap_config.oneshot_disable = disable;
208 eeconfig_update_keymap(keymap_config.raw); 207 eeconfig_update_keymap(keymap_config.raw);
209 clear_oneshot_layer_state(ONESHOT_OTHER_KEY_PRESSED); 208 clear_oneshot_layer_state(ONESHOT_OTHER_KEY_PRESSED);
210 dprintf("Oneshot: active: %d\n", active); 209 dprintf("Oneshot: active: %d\n", active);
@@ -216,7 +215,7 @@ void oneshot_set(bool active) {
216 * FIXME: needs doc 215 * FIXME: needs doc
217 */ 216 */
218void oneshot_toggle(void) { 217void oneshot_toggle(void) {
219 oneshot_set(!keymap_config.oneshot_disable); 218 oneshot_set(!keymap_config.oneshot_enable);
220} 219}
221 220
222/** \brief enable oneshot 221/** \brief enable oneshot
@@ -236,7 +235,7 @@ void oneshot_disable(void) {
236} 235}
237 236
238bool is_oneshot_enabled(void) { 237bool is_oneshot_enabled(void) {
239 return !keymap_config.oneshot_disable; 238 return keymap_config.oneshot_enable;
240} 239}
241 240
242#endif 241#endif
@@ -414,7 +413,7 @@ void del_oneshot_mods(uint8_t mods) {
414 * FIXME: needs doc 413 * FIXME: needs doc
415 */ 414 */
416void set_oneshot_mods(uint8_t mods) { 415void set_oneshot_mods(uint8_t mods) {
417 if (!keymap_config.oneshot_disable) { 416 if (keymap_config.oneshot_enable) {
418 if (oneshot_mods != mods) { 417 if (oneshot_mods != mods) {
419# if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0)) 418# if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0))
420 oneshot_time = timer_read(); 419 oneshot_time = timer_read();