Deluge Firmware 1.3.0
Build date: 2026.11.28
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
44// Keep the former On value as MenuOnly to preserve existing settings.
45enum class RuntimeFeatureStateShortcutOverlay : uint32_t { Off = 0, MenuOnly = 1, MenuAndClip = 2 };
46
48enum RuntimeFeatureSettingType : uint32_t {
49 DrumRandomizer,
50 Quantize,
51 FineTempoKnob,
52 CatchNotes,
53 DeleteUnusedKitRows,
54 AltGoldenKnobDelayParams,
55 DevSysexAllowed,
56 SyncScalingAction,
57 HighlightIncomingNotes,
58 DisplayNornsLayout,
59 ShiftIsSticky,
60 LightShiftLed,
61 EnableDX7Engine,
62 EmulatedDisplay,
63 EnableKeyboardViewSidebarMenuExit,
64 EnableLaunchEventPlayhead,
65 DisplayChordKeyboard,
66 AlternativePlaybackStartBehaviour,
67 EnableGridViewLoopPads,
68 AlternativeTapTempoBehaviour,
69 HorizontalMenus,
70 TrimFromStartOfAudioClip,
71 ShowBatteryLevel,
72 RoundedCorners,
73 ShortcutOverlay,
74 MaxElement // Keep as boundary
75};
76
79 std::string_view displayName;
80 uint32_t value; // Value to be defined as typed Enum above
81};
82
85 deluge::l10n::String displayName;
86 std::string_view xmlName;
87 uint32_t value;
88 // Limited to safe memory
89 deluge::vector<RuntimeFeatureSettingOption> options;
90};
91
92class Serializer;
93class Deserializer;
94
96class RuntimeFeatureSettings {
97public:
98 RuntimeFeatureSettings();
99
100 // Traded type safety for option values for code simplicity and size, use enum from above to compare
101 inline uint32_t get(RuntimeFeatureSettingType type) { return settings[type].value; };
102 inline bool isOn(RuntimeFeatureSettingType type) { return get(type) == RuntimeFeatureStateToggle::On; }
103
109 inline void set(RuntimeFeatureSettingType type, uint32_t value) { settings[type].value = value; }
110
111 inline const char* getStartupSong() { return startupSong.get(); }
112 void init();
113 void factoryReset(bool showPopup = true);
114 void readSettingsFromFile();
115 void writeSettingsToFile();
116
117protected:
118 std::array<RuntimeFeatureSetting, RuntimeFeatureSettingType::MaxElement> settings = {};
119 String startupSong;
120
121private:
122 ResizeableArray unknownSettings;
123
124public:
125 friend class deluge::gui::menu_item::runtime_feature::Setting;
126 friend class deluge::gui::menu_item::runtime_feature::Settings;
127 friend class deluge::gui::menu_item::runtime_feature::DevSysexSetting;
128};
129
131extern RuntimeFeatureSettings runtimeFeatureSettings;
Definition storage_manager.h:190
Encapsulating class.
Definition runtime_feature_settings.h:96
void set(RuntimeFeatureSettingType type, uint32_t value)
Definition runtime_feature_settings.h:109
Definition storage_manager.h:124
Definition for selectable options.
Definition runtime_feature_settings.h:78
Every setting keeps its metadata and value in here.
Definition runtime_feature_settings.h:84