diff --git a/quantum/momentum.c b/quantum/momentum.c index 8b2d8dc06d..662f71d51c 100644 --- a/quantum/momentum.c +++ b/quantum/momentum.c @@ -1,5 +1,7 @@ #include "momentum.h" #include "timer.h" +#include "eeconfig.h" +#include "eeprom.h" #ifndef MIN #define MIN(a,b) (((a)<(b))?(a):(b)) @@ -12,7 +14,14 @@ uint8_t typing_speed = 0; bool momentum_enabled() { - return true; + return eeprom_read_byte(EECONFIG_MOMENTUM) == 1; +} + +void momentum_toggle() { + if (momentum_enabled()) + eeprom_update_byte(EECONFIG_MOMENTUM, 0); + else + eeprom_update_byte(EECONFIG_MOMENTUM, 1); } void momentum_accelerate() { diff --git a/quantum/momentum.h b/quantum/momentum.h index d72c043d15..1fe4c58aea 100644 --- a/quantum/momentum.h +++ b/quantum/momentum.h @@ -5,6 +5,7 @@ #include bool momentum_enabled(void); +void momentum_toggle(void); void momentum_accelerate(void); void momentum_decay_task(void); uint8_t match_momentum(uint8_t minValue, uint8_t maxValue); diff --git a/quantum/quantum.c b/quantum/quantum.c index ae308fad2d..5301c8bd75 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -516,6 +516,11 @@ bool process_record_quantum(keyrecord_t *record) { rgblight_mode(35); } return false; + case MOM_TOG: + if (record->event.pressed) { + momentum_toggle(); + } + return false; #endif // defined(RGBLIGHT_ENABLE) || defined(RGB_MATRIX_ENABLE) #ifdef PROTOCOL_LUFA case OUT_AUTO: diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h index f2cdb8a3bf..2391122d9d 100644 --- a/quantum/quantum_keycodes.h +++ b/quantum/quantum_keycodes.h @@ -425,6 +425,9 @@ enum quantum_keycodes { RGB_MODE_GRADIENT, RGB_MODE_RGBTEST, + //Momentum matching toggle + MOM_TOG, + // Left shift, open paren KC_LSPO, diff --git a/tmk_core/common/eeconfig.c b/tmk_core/common/eeconfig.c index 3e5987ee3b..4d76cc0a69 100644 --- a/tmk_core/common/eeconfig.c +++ b/tmk_core/common/eeconfig.c @@ -22,6 +22,7 @@ void eeconfig_init(void) #endif #if defined(RGBLIGHT_ENABLE) || defined(RGB_MATRIX_ENABLE) eeprom_update_dword(EECONFIG_RGBLIGHT, 0); + eeprom_update_byte(EECONFIG_MOMENTUM, 0); #endif #ifdef STENO_ENABLE eeprom_update_byte(EECONFIG_STENOMODE, 0); diff --git a/tmk_core/common/eeconfig.h b/tmk_core/common/eeconfig.h index 1397a90c79..87cf9b485e 100644 --- a/tmk_core/common/eeconfig.h +++ b/tmk_core/common/eeconfig.h @@ -37,7 +37,7 @@ along with this program. If not, see . #define EECONFIG_STENOMODE (uint8_t *)13 // EEHANDS for two handed boards #define EECONFIG_HANDEDNESS (uint8_t *)14 - +#define EECONFIG_MOMENTUM (uint8_t *)15 /* debug bit */ #define EECONFIG_DEBUG_ENABLE (1<<0)