Skip to content

Commit

Permalink
Stricter conditions on add_oneshot_mods & del_oneshot_mods
Browse files Browse the repository at this point in the history
Prevent extending the one shot timer if the called add_oneshot_mods or del_oneshot_mods do not change anything to the current one shot mod state.

Co-authored-by: David Kosorin <david@kosorin.net>
  • Loading branch information
precondition and kosorin committed Nov 10, 2020
1 parent 6404c29 commit 87aa23d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tmk_core/common/action_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ void clear_macro_mods(void) { macro_mods = 0; }
uint8_t get_oneshot_mods(void) { return oneshot_mods; }

void add_oneshot_mods(uint8_t mods) {
if (oneshot_mods != mods) {
if ((oneshot_mods & mods) != mods) {
# if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0))
oneshot_time = timer_read();
# endif
Expand All @@ -307,7 +307,7 @@ void add_oneshot_mods(uint8_t mods) {
}

void del_oneshot_mods(uint8_t mods) {
if (oneshot_mods) {
if (oneshot_mods & mods) {
oneshot_mods &= ~mods;
# if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0))
oneshot_time = oneshot_mods ? timer_read() : 0;
Expand Down

0 comments on commit 87aa23d

Please sign in to comment.