20#include "gui/ui/keyboard/layout.h"
22namespace deluge::gui::ui::keyboard::layout {
24constexpr int32_t k_min_zoom_level = 0;
25constexpr int32_t k_max_zoom_level = 12;
28const int32_t zoom_arr[13][2] = {{1, 1}, {2, 1}, {3, 1}, {2, 2}, {3, 2}, {4, 2}, {5, 2},
29 {3, 4}, {4, 4}, {5, 4}, {8, 4}, {8, 8}, {16, 8}};
31class KeyboardLayoutVelocityDrums :
public KeyboardLayout {
33 KeyboardLayoutVelocityDrums() =
default;
34 ~KeyboardLayoutVelocityDrums()
override =
default;
40 bool encoderPressed =
false)
override;
42 void renderPads(
RGB image[][kDisplayWidth + kSideBarWidth])
override;
44 l10n::String name()
override {
return l10n::String::STRING_FOR_KEYBOARD_LAYOUT_VELOCITY_DRUMS; }
46 bool supportsKit()
override {
return true; }
49 inline uint8_t velocityFromCoords(int32_t x, int32_t y, uint32_t edge_size_x, uint32_t edge_size_y) {
50 uint32_t velocity = 0;
51 if (edge_size_x == 1) {
53 velocity = FlashStorage::defaultVelocity * 2;
56 bool odd_pad = (edge_size_x % 2 == 1);
57 uint32_t x_limit = kDisplayWidth - 2 - edge_size_x;
58 bool x_adjust = (odd_pad && x > x_limit);
59 uint32_t localX = x_adjust ? x - x_limit : x % (edge_size_x);
61 if (edge_size_y == 1) {
62 velocity = (localX + 1) * 200 / (edge_size_x + x_adjust);
65 if (edge_size_x % 2 == 1 && x > kDisplayWidth - 2 - edge_size_x)
67 uint32_t position = localX + 1;
68 position += ((y % edge_size_y) * (edge_size_x + x_adjust));
71 uint32_t stepSize = 0xFFFF / ((edge_size_x + x_adjust) * edge_size_y);
72 velocity = (position * stepSize) >> 8;
This class represents the colour format most used by the Deluge globally.
Definition rgb.h:14
bool supportsInstrument() override
This currently includes Synth, MIDI and CV.
Definition velocity_drums.h:45
void evaluatePads(PressedPad presses[kMaxNumKeyboardPadPresses]) override
Handle input pad presses.
Definition velocity_drums.cpp:26
void handleHorizontalEncoder(int32_t offset, bool shiftEnabled, PressedPad presses[kMaxNumKeyboardPadPresses], bool encoderPressed=false) override
Will be called with offset 0 to recalculate bounds on clip changes.
Definition velocity_drums.cpp:91
void renderPads(RGB image[][kDisplayWidth+kSideBarWidth]) override
Handle output.
Definition velocity_drums.cpp:132
void precalculate() override
This function is called on visibility change and if colour offset changes.
Definition velocity_drums.h:35
void handleVerticalEncoder(int32_t offset) override
Shift state not supplied since that function is already taken.
Definition velocity_drums.cpp:85
Definition notes_state.h:31