Skip to content

Commit a57abb6

Browse files
committed
AutoShiftConfig: Add a .disableAutoShiftIfUnconfigured() method
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 <[email protected]>
1 parent ef460d4 commit a57abb6

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

plugins/Kaleidoscope-AutoShift/src/kaleidoscope/plugin/AutoShift.h

+1
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,7 @@ class AutoShiftConfig : public Plugin {
276276
public:
277277
EventHandlerResult onSetup();
278278
EventHandlerResult onFocusEvent(const char *input);
279+
void disableAutoShiftIfUnconfigured();
279280

280281
private:
281282
// The base address in persistent storage for configuration data

plugins/Kaleidoscope-AutoShift/src/kaleidoscope/plugin/AutoShiftConfig.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ EventHandlerResult AutoShiftConfig::onSetup() {
4545
return EventHandlerResult::OK;
4646
}
4747

48+
void AutoShiftConfig::disableAutoShiftIfUnconfigured() {
49+
if (Runtime.storage().isSliceUninitialized(settings_base_, sizeof(AutoShift::settings_)))
50+
::AutoShift.disable();
51+
}
52+
4853
EventHandlerResult AutoShiftConfig::onFocusEvent(const char *input) {
4954
enum {
5055
ENABLED,

0 commit comments

Comments
 (0)