Skip to content

Commit

Permalink
AutoShiftConfig: Add a .disableAutoShiftIfUnconfigured() method
Browse files Browse the repository at this point in the history
The AutoShift plugin is enabled by default, but when using AutoShiftConfig, we
may want to have it disabled by default, so that we can include it in firmware
updates without turning optional, behaviour changing features on by default. The
new method helps us accomplish this, in a way similar to how SpaceCadet
accomplishes the same thing.

Signed-off-by: Gergely Nagy <algernon@keyboard.io>
  • Loading branch information
algernon committed Oct 30, 2022
1 parent ef460d4 commit a57abb6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ class AutoShiftConfig : public Plugin {
public:
EventHandlerResult onSetup();
EventHandlerResult onFocusEvent(const char *input);
void disableAutoShiftIfUnconfigured();

private:
// The base address in persistent storage for configuration data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ EventHandlerResult AutoShiftConfig::onSetup() {
return EventHandlerResult::OK;
}

void AutoShiftConfig::disableAutoShiftIfUnconfigured() {
if (Runtime.storage().isSliceUninitialized(settings_base_, sizeof(AutoShift::settings_)))
::AutoShift.disable();
}

EventHandlerResult AutoShiftConfig::onFocusEvent(const char *input) {
enum {
ENABLED,
Expand Down

0 comments on commit a57abb6

Please sign in to comment.