Deluge Firmware 1.3.0
Build date: 2025.04.16
Loading...
Searching...
No Matches
keyboard_screen.h
1/*
2 * Copyright © 2016-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 "definitions_cxx.hpp"
21#include "gui/ui/keyboard/notes_state.h"
22#include "gui/ui/root_ui.h"
23#include "gui/ui/ui.h"
24#include "hid/button.h"
25#include "model/clip/instrument_clip_minder.h"
26#include "model/instrument/instrument.h"
27
28class ModelStack;
29class Instrument;
30
31namespace deluge::gui::ui::keyboard {
32
33constexpr int32_t kMaxNumKeyboardPadPresses = 10;
34
35class KeyboardScreen final : public RootUI, public InstrumentClipMinder {
36public:
37 KeyboardScreen();
38
39 ActionResult padAction(int32_t x, int32_t y, int32_t velocity) override;
40 ActionResult buttonAction(deluge::hid::Button b, bool on, bool inCardRoutine) override;
41 ActionResult verticalEncoderAction(int32_t offset, bool inCardRoutine) override;
42 ActionResult horizontalEncoderAction(int32_t offset) override;
43 void selectEncoderAction(int8_t offset) override;
44
45 bool renderMainPads(uint32_t whichRows, RGB image[][kDisplayWidth + kSideBarWidth],
46 uint8_t occupancyMask[][kDisplayWidth + kSideBarWidth],
47 bool drawUndefinedArea = false) override;
48 bool renderSidebar(uint32_t whichRows, RGB image[][kDisplayWidth + kSideBarWidth],
49 uint8_t occupancyMask[][kDisplayWidth + kSideBarWidth]) override;
50
51 void flashDefaultRootNote();
52 void openedInBackground();
53 void exitAuditionMode();
54
55 uint8_t highlightedNotes[kHighestKeyboardNote] = {0};
56 uint8_t nornsNotes[kHighestKeyboardNote] = {0};
57
58 inline void requestRendering() { uiNeedsRendering(this, 0xFFFFFFFF, 0xFFFFFFFF); }
59
60 void killColumnSwitchKey(int32_t column);
61
62 // ui
63 UIType getUIType() override { return UIType::KEYBOARD_SCREEN; }
64 void checkNewInstrument(Instrument* newInstrument);
65
66private:
67 bool opened() override;
68 void focusRegained() override;
69 void displayOrLanguageChanged() final;
70
71 void evaluateActiveNotes();
72 void updateActiveNotes();
73
74 void noteOff(ModelStack& modelStack, Instrument& activeInstrument, bool clipIsActiveOnInstrument, int32_t note);
75
76 ClipMinder* toClipMinder() override { return this; }
77 void setLedStates();
78 void graphicsRoutine() override;
79 bool getAffectEntire() override;
80
81 void unscrolledPadAudition(int32_t velocity, int32_t note, bool shiftButtonDown);
82
83 void renderOLED(deluge::hid::display::oled_canvas::Canvas& canvas) override {
84 InstrumentClipMinder::renderOLED(canvas);
85 }
86
87 void selectLayout(int8_t offset);
88 void enterScaleMode(int32_t selectedRootNote = kDefaultCalculateRootNote);
89 void exitScaleMode();
90 void drawNoteCode(int32_t noteCode);
91
92 PressedPad pressedPads[kMaxNumKeyboardPadPresses];
93 NotesState lastNotesState;
94 NotesState currentNotesState;
95
96 bool keyboardButtonActive = false;
97 bool keyboardButtonUsed = false;
98 bool yEncoderActive = false;
99 bool xEncoderActive = false;
100};
101}; // namespace deluge::gui::ui::keyboard
102
103// TODO: should get moved into namespace once project namespacing is complete
Definition clip_minder.h:23
Definition instrument.h:45
Definition model_stack.h:123
This class represents the colour format most used by the Deluge globally.
Definition rgb.h:14
Definition keyboard_screen.h:35
ClipMinder * toClipMinder() override
Definition keyboard_screen.h:76