diff --git a/plugins/Kaleidoscope-Escape-OneShot/README.md b/plugins/Kaleidoscope-Escape-OneShot/README.md index ce223255..0a0c164c 100644 --- a/plugins/Kaleidoscope-Escape-OneShot/README.md +++ b/plugins/Kaleidoscope-Escape-OneShot/README.md @@ -70,23 +70,9 @@ configuration methods: > Returns the `Key` value that will trigger deactivation of one-shot (including > sticky) keys. -### `.enable()`, `.disable()`, `.toggle()`, and `.isEnabled()` - -> Enables, disables, toggles, and returns the enabled state of the plugin, -> respectively. -> -> By default, the plugin starts enabled. - ## Focus commands -The plugin provides two Focus commands: `escape_oneshot.enabled`, and -`escape_oneshot.cancel_key`. - -### `escape_oneshot.enabled [0|1]` - -> Without arguments, returns whether the plugin is enabled or not. -> -> With an argument, enables or disables it. +The plugin provides a single Focus command: `escape_oneshot.cancel_key`. ### `escape_oneshot.cancel_key [keycode]` diff --git a/plugins/Kaleidoscope-Escape-OneShot/src/kaleidoscope/plugin/Escape-OneShot-Config.cpp b/plugins/Kaleidoscope-Escape-OneShot/src/kaleidoscope/plugin/Escape-OneShot-Config.cpp index 422a9b2f..6c81f12d 100644 --- a/plugins/Kaleidoscope-Escape-OneShot/src/kaleidoscope/plugin/Escape-OneShot-Config.cpp +++ b/plugins/Kaleidoscope-Escape-OneShot/src/kaleidoscope/plugin/Escape-OneShot-Config.cpp @@ -29,15 +29,12 @@ uint16_t EscapeOneShotConfig::settings_base_; EventHandlerResult EscapeOneShotConfig::onSetup() { settings_base_ = ::EEPROMSettings.requestSlice(sizeof(EscapeOneShot::settings_)); - struct { - uint8_t b; - uint16_t w; - } checker; + uint16_t checker; Runtime.storage().get(settings_base_, checker); // Check if we have an empty eeprom... - if (checker.b == 0xff && checker.w == 0xffff) { + if (checker == 0xffff) { // ...if the eeprom was empty, store the default settings. Runtime.storage().put(settings_base_, EscapeOneShot::settings_); Runtime.storage().commit(); @@ -52,48 +49,18 @@ EventHandlerResult EscapeOneShotConfig::onNameQuery() { } EventHandlerResult EscapeOneShotConfig::onFocusEvent(const char *command) { - enum { - ENABLED, - CANCEL_KEY - } subCommand; - - if (::Focus.handleHelp(command, PSTR("escape_oneshot.enabled\n" - "escape_oneshot.cancel_key"))) + if (::Focus.handleHelp(command, PSTR("escape_oneshot.cancel_key"))) return EventHandlerResult::OK; - if (strncmp_P(command, PSTR("escape_oneshot."), 15) != 0) - return EventHandlerResult::OK; - if (strcmp_P(command + 15, PSTR("enabled")) == 0) - subCommand = ENABLED; - else if (strcmp_P(command + 15, PSTR("cancel_key")) == 0) - subCommand = CANCEL_KEY; - else + if (strcmp_P(command, PSTR("escape_oneshot.cancel_key")) != 0) return EventHandlerResult::OK; - switch (subCommand) { - case ENABLED: - if (::Focus.isEOL()) { - ::Focus.send(::EscapeOneShot.isEnabled()); - } else { - uint8_t v; - ::Focus.read(v); - if (v != 0) { - ::EscapeOneShot.enable(); - } else { - ::EscapeOneShot.disable(); - } - } - break; - - case CANCEL_KEY: - if (::Focus.isEOL()) { - ::Focus.send(::EscapeOneShot.getCancelKey()); - } else { - Key k; - ::Focus.read(k); - ::EscapeOneShot.setCancelKey(k); - } - break; + if (::Focus.isEOL()) { + ::Focus.send(::EscapeOneShot.getCancelKey()); + } else { + Key k; + ::Focus.read(k); + ::EscapeOneShot.setCancelKey(k); } Runtime.storage().put(settings_base_, EscapeOneShot::settings_); diff --git a/plugins/Kaleidoscope-Escape-OneShot/src/kaleidoscope/plugin/Escape-OneShot.cpp b/plugins/Kaleidoscope-Escape-OneShot/src/kaleidoscope/plugin/Escape-OneShot.cpp index 832664d3..6d71348d 100644 --- a/plugins/Kaleidoscope-Escape-OneShot/src/kaleidoscope/plugin/Escape-OneShot.cpp +++ b/plugins/Kaleidoscope-Escape-OneShot/src/kaleidoscope/plugin/Escape-OneShot.cpp @@ -25,15 +25,10 @@ namespace kaleidoscope { namespace plugin { EscapeOneShot::Settings EscapeOneShot::settings_ = { - .disabled = false, .cancel_oneshot_key = Key_Escape }; EventHandlerResult EscapeOneShot::onKeyEvent(KeyEvent &event) { - // If we're disabled, just pass through. - if (settings_.disabled) - return EventHandlerResult::OK; - // We only act on an escape key (or `cancel_oneshot_key_`, if that has been // set) that has just been pressed, and not generated by some other // plugin. Also, only if at least one OneShot key is active and/or diff --git a/plugins/Kaleidoscope-Escape-OneShot/src/kaleidoscope/plugin/Escape-OneShot.h b/plugins/Kaleidoscope-Escape-OneShot/src/kaleidoscope/plugin/Escape-OneShot.h index b39c436c..c1091367 100644 --- a/plugins/Kaleidoscope-Escape-OneShot/src/kaleidoscope/plugin/Escape-OneShot.h +++ b/plugins/Kaleidoscope-Escape-OneShot/src/kaleidoscope/plugin/Escape-OneShot.h @@ -40,24 +40,11 @@ class EscapeOneShot : public kaleidoscope::Plugin { static Key getCancelKey() { return settings_.cancel_oneshot_key; } - static void enable() { - settings_.disabled = false; - } - static void disable() { - settings_.disabled = true; - } - static void toggle() { - settings_.disabled = !settings_.disabled; - } - static bool isEnabled() { - return !settings_.disabled; - } friend class EscapeOneShotConfig; private: struct Settings { - bool disabled; Key cancel_oneshot_key; }; static Settings settings_; @@ -69,7 +56,6 @@ class EscapeOneShotConfig : public Plugin { EventHandlerResult onFocusEvent(const char *command); EventHandlerResult onNameQuery(); - private: static uint16_t settings_base_; };