diff options
Diffstat (limited to 'tmk_core/common/action_util.c')
| -rw-r--r-- | tmk_core/common/action_util.c | 58 |
1 files changed, 49 insertions, 9 deletions
diff --git a/tmk_core/common/action_util.c b/tmk_core/common/action_util.c index 000503b08..a57c8bf66 100644 --- a/tmk_core/common/action_util.c +++ b/tmk_core/common/action_util.c | |||
| @@ -147,12 +147,16 @@ void clear_oneshot_swaphands(void) { | |||
| 147 | * FIXME: needs doc | 147 | * FIXME: needs doc |
| 148 | */ | 148 | */ |
| 149 | void set_oneshot_layer(uint8_t layer, uint8_t state) { | 149 | void set_oneshot_layer(uint8_t layer, uint8_t state) { |
| 150 | oneshot_layer_data = layer << 3 | state; | 150 | if (!keymap_config.oneshot_disable) { |
| 151 | layer_on(layer); | 151 | oneshot_layer_data = layer << 3 | state; |
| 152 | layer_on(layer); | ||
| 152 | # if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0)) | 153 | # if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0)) |
| 153 | oneshot_layer_time = timer_read(); | 154 | oneshot_layer_time = timer_read(); |
| 154 | # endif | 155 | # endif |
| 155 | oneshot_layer_changed_kb(get_oneshot_layer()); | 156 | oneshot_layer_changed_kb(get_oneshot_layer()); |
| 157 | } else { | ||
| 158 | layer_on(layer); | ||
| 159 | } | ||
| 156 | } | 160 | } |
| 157 | /** \brief Reset oneshot layer | 161 | /** \brief Reset oneshot layer |
| 158 | * | 162 | * |
| @@ -172,7 +176,7 @@ void reset_oneshot_layer(void) { | |||
| 172 | void clear_oneshot_layer_state(oneshot_fullfillment_t state) { | 176 | void clear_oneshot_layer_state(oneshot_fullfillment_t state) { |
| 173 | uint8_t start_state = oneshot_layer_data; | 177 | uint8_t start_state = oneshot_layer_data; |
| 174 | oneshot_layer_data &= ~state; | 178 | oneshot_layer_data &= ~state; |
| 175 | if (!get_oneshot_layer_state() && start_state != oneshot_layer_data) { | 179 | if ((!get_oneshot_layer_state() && start_state != oneshot_layer_data) || keymap_config.oneshot_disable) { |
| 176 | layer_off(get_oneshot_layer()); | 180 | layer_off(get_oneshot_layer()); |
| 177 | reset_oneshot_layer(); | 181 | reset_oneshot_layer(); |
| 178 | } | 182 | } |
| @@ -182,6 +186,39 @@ void clear_oneshot_layer_state(oneshot_fullfillment_t state) { | |||
| 182 | * FIXME: needs doc | 186 | * FIXME: needs doc |
| 183 | */ | 187 | */ |
| 184 | bool is_oneshot_layer_active(void) { return get_oneshot_layer_state(); } | 188 | bool is_oneshot_layer_active(void) { return get_oneshot_layer_state(); } |
| 189 | |||
| 190 | /** \brief set oneshot | ||
| 191 | * | ||
| 192 | * FIXME: needs doc | ||
| 193 | */ | ||
| 194 | void oneshot_set(bool active) { | ||
| 195 | if (keymap_config.oneshot_disable != active) { | ||
| 196 | keymap_config.oneshot_disable = active; | ||
| 197 | eeconfig_update_keymap(keymap_config.raw); | ||
| 198 | dprintf("Oneshot: active: %d\n", active); | ||
| 199 | } | ||
| 200 | } | ||
| 201 | |||
| 202 | /** \brief toggle oneshot | ||
| 203 | * | ||
| 204 | * FIXME: needs doc | ||
| 205 | */ | ||
| 206 | void oneshot_toggle(void) { oneshot_set(!keymap_config.oneshot_disable); } | ||
| 207 | |||
| 208 | /** \brief enable oneshot | ||
| 209 | * | ||
| 210 | * FIXME: needs doc | ||
| 211 | */ | ||
| 212 | void oneshot_enable(void) { oneshot_set(true); } | ||
| 213 | |||
| 214 | /** \brief disable oneshot | ||
| 215 | * | ||
| 216 | * FIXME: needs doc | ||
| 217 | */ | ||
| 218 | void oneshot_disable(void) { oneshot_set(false); } | ||
| 219 | |||
| 220 | bool is_oneshot_enabled(void) { return keymap_config.oneshot_disable; } | ||
| 221 | |||
| 185 | #endif | 222 | #endif |
| 186 | 223 | ||
| 187 | /** \brief Send keyboard report | 224 | /** \brief Send keyboard report |
| @@ -321,14 +358,17 @@ void del_oneshot_mods(uint8_t mods) { | |||
| 321 | * FIXME: needs doc | 358 | * FIXME: needs doc |
| 322 | */ | 359 | */ |
| 323 | void set_oneshot_mods(uint8_t mods) { | 360 | void set_oneshot_mods(uint8_t mods) { |
| 324 | if (oneshot_mods != mods) { | 361 | if (!keymap_config.oneshot_disable) { |
| 362 | if (oneshot_mods != mods) { | ||
| 325 | # if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0)) | 363 | # if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0)) |
| 326 | oneshot_time = timer_read(); | 364 | oneshot_time = timer_read(); |
| 327 | # endif | 365 | # endif |
| 328 | oneshot_mods = mods; | 366 | oneshot_mods = mods; |
| 329 | oneshot_mods_changed_kb(mods); | 367 | oneshot_mods_changed_kb(mods); |
| 368 | } | ||
| 330 | } | 369 | } |
| 331 | } | 370 | } |
| 371 | |||
| 332 | /** \brief clear oneshot mods | 372 | /** \brief clear oneshot mods |
| 333 | * | 373 | * |
| 334 | * FIXME: needs doc | 374 | * FIXME: needs doc |
