mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-02-02 09:35:20 -05:00
Show on_encoder delta in Buttons Test app (#1903)
This commit is contained in:
parent
b5ac792853
commit
24605777a6
@ -323,6 +323,11 @@ bool ControlsSwitchesWidget::on_key(const KeyEvent key) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ControlsSwitchesWidget::on_encoder(const EncoderEvent delta) {
|
||||||
|
last_delta = delta;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void ControlsSwitchesWidget::paint(Painter& painter) {
|
void ControlsSwitchesWidget::paint(Painter& painter) {
|
||||||
const auto pos = screen_pos();
|
const auto pos = screen_pos();
|
||||||
|
|
||||||
@ -405,6 +410,8 @@ void ControlsSwitchesWidget::paint(Painter& painter) {
|
|||||||
|
|
||||||
switches_event >>= 1;
|
switches_event >>= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
painter.draw_string({5 * 8, 12 * 16}, Styles::light_grey, to_string_dec_int(last_delta, 3));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ControlsSwitchesWidget::on_frame_sync() {
|
void ControlsSwitchesWidget::on_frame_sync() {
|
||||||
|
@ -252,18 +252,21 @@ class ControlsSwitchesWidget : public Widget {
|
|||||||
Rect parent_rect)
|
Rect parent_rect)
|
||||||
: Widget{parent_rect},
|
: Widget{parent_rect},
|
||||||
key_event_mask(0),
|
key_event_mask(0),
|
||||||
long_press_key_event_mask{0} {
|
long_press_key_event_mask{0},
|
||||||
|
last_delta{0} {
|
||||||
set_focusable(true);
|
set_focusable(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void on_show() override;
|
void on_show() override;
|
||||||
bool on_key(const KeyEvent key) override;
|
bool on_key(const KeyEvent key) override;
|
||||||
|
bool on_encoder(const EncoderEvent delta) override;
|
||||||
|
|
||||||
void paint(Painter& painter) override;
|
void paint(Painter& painter) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint8_t key_event_mask;
|
uint8_t key_event_mask;
|
||||||
uint8_t long_press_key_event_mask;
|
uint8_t long_press_key_event_mask;
|
||||||
|
EncoderEvent last_delta;
|
||||||
|
|
||||||
MessageHandlerRegistration message_handler_frame_sync{
|
MessageHandlerRegistration message_handler_frame_sync{
|
||||||
Message::ID::DisplayFrameSync,
|
Message::ID::DisplayFrameSync,
|
||||||
@ -285,6 +288,7 @@ class DebugControlsView : public View {
|
|||||||
private:
|
private:
|
||||||
Labels labels{
|
Labels labels{
|
||||||
{{8 * 8, 1 * 16}, "Controls State", Color::white()},
|
{{8 * 8, 1 * 16}, "Controls State", Color::white()},
|
||||||
|
{{0 * 8, 11 * 16}, "Dial:", Color::grey()},
|
||||||
{{0 * 8, 14 * 16}, "Long-Press Mode:", Color::grey()}};
|
{{0 * 8, 14 * 16}, "Long-Press Mode:", Color::grey()}};
|
||||||
|
|
||||||
ControlsSwitchesWidget switches_widget{
|
ControlsSwitchesWidget switches_widget{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user