diff options
| author | jacqueline <me@jacqueline.id.au> | 2024-04-15 14:18:20 +1000 |
|---|---|---|
| committer | jacqueline <me@jacqueline.id.au> | 2024-04-15 14:18:20 +1000 |
| commit | 1baaa6dadcea5b8a85f1629e31119f4edba91b75 (patch) | |
| tree | feae0c19f1a6744b60f3e59a5d9b8df1c28c6ebf /src/input/input_hook_actions.cpp | |
| parent | c24dfa6846929e8a7659c4aa2633b82494ac7fe1 (diff) | |
| download | tangara-fw-1baaa6dadcea5b8a85f1629e31119f4edba91b75.tar.gz | |
Use more generic 'hooks' for each input device's actions
Diffstat (limited to 'src/input/input_hook_actions.cpp')
| -rw-r--r-- | src/input/input_hook_actions.cpp | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/input/input_hook_actions.cpp b/src/input/input_hook_actions.cpp new file mode 100644 index 00000000..0694cccf --- /dev/null +++ b/src/input/input_hook_actions.cpp @@ -0,0 +1,52 @@ +/* + * Copyright 2024 jacqueline <me@jacqueline.id.au> + * + * SPDX-License-Identifier: GPL-3.0-only + */ + +#include "input_hook_actions.hpp" + +#include <cstdint> + +#include "hal/lv_hal_indev.h" + +#include "event_queue.hpp" +#include "ui_events.hpp" + +namespace input { +namespace actions { + +auto select(lv_indev_data_t* d) -> void { + d->state = LV_INDEV_STATE_PRESSED; +} + +auto scrollUp(lv_indev_data_t* d) -> void { + d->enc_diff = -1; +} + +auto scrollDown(lv_indev_data_t* d) -> void { + d->enc_diff = 1; +} + +auto scrollToTop(lv_indev_data_t* d) -> void { + d->enc_diff = INT16_MIN; +} + +auto scrollToBottom(lv_indev_data_t* d) -> void { + d->enc_diff = INT16_MAX; +} + +auto goBack(lv_indev_data_t* d) -> void { + events::Ui().Dispatch(ui::internal::BackPressed{}); +} + +auto volumeUp(lv_indev_data_t* d) -> void { + events::Audio().Dispatch(audio::StepUpVolume{}); +} + +auto volumeDown(lv_indev_data_t* d) -> void { + events::Audio().Dispatch(audio::StepDownVolume{}); +} + +} // namespace actions +} // namespace input |
