Deluge Firmware 1.3.0
Build date: 2026.09.19
Loading...
Searching...
No Matches
runtime_feature_settings.h
1/*
2 * Copyright © 2015-2023 Synthstrom Audible Limited
3 *
4 * This file is part of The Synthstrom Audible Deluge Firmware.
5 *
6 * The Synthstrom Audible Deluge Firmware is free software: you can redistribute it and/or modify it under the
7 * terms of the GNU General Public License as published by the Free Software Foundation,
8 * either version 3 of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
11 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 * See the GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License along with this program.
15 * If not, see <https://www.gnu.org/licenses/>.
16 */
17
18#pragma once
19
20#include "gui/l10n/strings.h"
21#include "util/container/array/resizeable_array.h"
22#include "util/containers.h"
23#include "util/d_string.h"
24#include <array>
25#include <cstdint>
26#include <string_view>
27#include <vector>
28
29namespace deluge::gui::menu_item::runtime_feature {
30class Setting;
31class Settings;
32class DevSysexSetting;
33
34} // namespace deluge::gui::menu_item::runtime_feature
35
36// State declarations
37enum RuntimeFeatureStateToggle : uint32_t { Off = 0, On = 1 };
38
39// Declare additional enums for specific multi state settings (e.g. like RuntimeFeatureStateTrackLaunchStyle)
40enum RuntimeFeatureStateSyncScalingAction : uint32_t { SyncScaling = 0, Fill = 1 };
41
42enum RuntimeFeatureStateEmulatedDisplay : uint32_t { Hardware = 0, Toggle = 1, OnBoot = 2 };
43
45enum RuntimeFeatureSettingType : uint32_t {
46 DrumRandomizer,
47 Quantize,
48 FineTempoKnob,
49 CatchNotes,
50 DeleteUnusedKitRows,
51 AltGoldenKnobDelayParams,
52 DevSysexAllowed,
53 SyncScalingAction,
54 HighlightIncomingNotes,
55 DisplayNornsLayout,
56 ShiftIsSticky,
57 LightShiftLed,
58 EnableDX7Engine,
59 EmulatedDisplay,
60 EnableKeyboardViewSidebarMenuExit,
61 EnableLaunchEventPlayhead,
62 DisplayChordKeyboard,
63 AlternativePlaybackStartBehaviour,
64 EnableGridViewLoopPads,
65 AlternativeTapTempoBehaviour,
66 HorizontalMenus,
67 TrimFromStartOfAudioClip,
68 ShowBatteryLevel,
69 RoundedCorners,
70 ShortcutOverlay,
71 MaxElement // Keep as boundary
72};
73
76 std::string_view displayName;
77 uint32_t value; // Value to be defined as typed Enum above
78};
79
82 deluge::l10n::String displayName;
83 std::string_view xmlName;
84 uint32_t value;
85 // Limited to safe memory
86 deluge::vector<RuntimeFeatureSettingOption> options;
87};
88
89class Serializer;
90class Deserializer;
91
93class RuntimeFeatureSettings {
94public:
95 RuntimeFeatureSettings();
96
97 // Traded type safety for option values for code simplicity and size, use enum from above to compare
98 inline uint32_t get(RuntimeFeatureSettingType type) { return settings[type].value; };
99 inline bool isOn(RuntimeFeatureSettingType type) { return get(type) == RuntimeFeatureStateToggle::On; }
100
106 inline void set(RuntimeFeatureSettingType type, uint32_t value) { settings[type].value = value; }
107
108 inline const char* getStartupSong() { return startupSong.get(); }
109 void init();
110 void factoryReset(bool showPopup = true);
111 void readSettingsFromFile();
112 void writeSettingsToFile();
113
114protected:
115 std::array<RuntimeFeatureSetting, RuntimeFeatureSettingType::MaxElement> settings = {};
116 String startupSong;
117
118private:
119 ResizeableArray unknownSettings;
120
121public:
122 friend class deluge::gui::menu_item::runtime_feature::Setting;
123 friend class deluge::gui::menu_item::runtime_feature::Settings;
124 friend class deluge::gui::menu_item::runtime_feature::DevSysexSetting;
125};
126
128extern RuntimeFeatureSettings runtimeFeatureSettings;
Definition storage_manager.h:185
Encapsulating class.
Definition runtime_feature_settings.h:93
void set(RuntimeFeatureSettingType type, uint32_t value)
Definition runtime_feature_settings.h:106
Definition storage_manager.h:119
Definition for selectable options.
Definition runtime_feature_settings.h:75
Every setting keeps its metadata and value in here.
Definition runtime_feature_settings.h:81