diff options
| author | ailurux <ailuruxx@gmail.com> | 2024-05-10 13:06:20 +1000 |
|---|---|---|
| committer | ailurux <ailuruxx@gmail.com> | 2024-05-10 13:06:20 +1000 |
| commit | 3f177cdb8880abf199f4445f1398cd69fb813892 (patch) | |
| tree | e20de4949b1344c826e5af41ab701f3db75b21bc /src/input/include | |
| parent | 8019c7691889cde4c3d40bbd78d485a92d713bbf (diff) | |
| parent | e4ce7c4ac23402e09be8d6a52e0f739c0dff4ff0 (diff) | |
| download | tangara-fw-3f177cdb8880abf199f4445f1398cd69fb813892.tar.gz | |
Merge branch 'main' into file-browser
Diffstat (limited to 'src/input/include')
| -rw-r--r-- | src/input/include/device_factory.hpp | 39 | ||||
| -rw-r--r-- | src/input/include/feedback_device.hpp | 32 | ||||
| -rw-r--r-- | src/input/include/feedback_haptics.hpp | 26 | ||||
| -rw-r--r-- | src/input/include/input_device.hpp | 35 | ||||
| -rw-r--r-- | src/input/include/input_hook.hpp | 65 | ||||
| -rw-r--r-- | src/input/include/input_hook_actions.hpp | 31 | ||||
| -rw-r--r-- | src/input/include/input_nav_buttons.hpp | 38 | ||||
| -rw-r--r-- | src/input/include/input_touch_dpad.hpp | 40 | ||||
| -rw-r--r-- | src/input/include/input_touch_wheel.hpp | 56 | ||||
| -rw-r--r-- | src/input/include/input_trigger.hpp | 37 | ||||
| -rw-r--r-- | src/input/include/input_volume_buttons.hpp | 37 | ||||
| -rw-r--r-- | src/input/include/lvgl_input_driver.hpp | 60 |
12 files changed, 0 insertions, 496 deletions
diff --git a/src/input/include/device_factory.hpp b/src/input/include/device_factory.hpp deleted file mode 100644 index dd9c7133..00000000 --- a/src/input/include/device_factory.hpp +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2023 jacqueline <me@jacqueline.id.au> - * - * SPDX-License-Identifier: GPL-3.0-only - */ - -#pragma once - -#include <cstdint> -#include <memory> - -#include "feedback_device.hpp" -#include "input_device.hpp" -#include "input_touch_wheel.hpp" -#include "nvs.hpp" -#include "service_locator.hpp" - -namespace input { - -class DeviceFactory { - public: - DeviceFactory(std::shared_ptr<system_fsm::ServiceLocator>); - - auto createInputs(drivers::NvsStorage::InputModes mode) - -> std::vector<std::shared_ptr<IInputDevice>>; - - auto createFeedbacks() -> std::vector<std::shared_ptr<IFeedbackDevice>>; - - auto touch_wheel() -> std::shared_ptr<TouchWheel> { return wheel_; } - - private: - std::shared_ptr<system_fsm::ServiceLocator> services_; - - // HACK: the touchwheel is current a special case, since it's the only input - // device that has some kind of setting/configuration; scroll sensitivity. - std::shared_ptr<TouchWheel> wheel_; -}; - -} // namespace input diff --git a/src/input/include/feedback_device.hpp b/src/input/include/feedback_device.hpp deleted file mode 100644 index 4faeeafd..00000000 --- a/src/input/include/feedback_device.hpp +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2024 jacqueline <me@jacqueline.id.au> - * - * SPDX-License-Identifier: GPL-3.0-only - */ - -#pragma once - -#include <cstdint> - -namespace input { - -/* - * Interface for providing non-visual feedback to the user as a result of LVGL - * events. 'Feedback Devices' are able to observe all events that are generated - * by LVGL as a result of Input Devices. - * - * Implementations of this interface are a mix of hardware features (e.g. a - * haptic motor buzzing when your selection changes) and firmware features - * (e.g. playing audio feedback that describes the selected element). - */ -class IFeedbackDevice { - public: - virtual ~IFeedbackDevice() {} - - virtual auto feedback(uint8_t event_type) -> void = 0; - - // TODO: Add configuration; likely the same shape of interface that - // IInputDevice uses. -}; - -} // namespace input diff --git a/src/input/include/feedback_haptics.hpp b/src/input/include/feedback_haptics.hpp deleted file mode 100644 index a307a429..00000000 --- a/src/input/include/feedback_haptics.hpp +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright 2024 jacqueline <me@jacqueline.id.au> - * - * SPDX-License-Identifier: GPL-3.0-only - */ - -#pragma once - -#include <cstdint> - -#include "feedback_device.hpp" -#include "haptics.hpp" - -namespace input { - -class Haptics : public IFeedbackDevice { - public: - Haptics(drivers::Haptics& haptics_); - - auto feedback(uint8_t event_type) -> void override; - - private: - drivers::Haptics& haptics_; -}; - -} // namespace input diff --git a/src/input/include/input_device.hpp b/src/input/include/input_device.hpp deleted file mode 100644 index 59456351..00000000 --- a/src/input/include/input_device.hpp +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2024 jacqueline <me@jacqueline.id.au> - * - * SPDX-License-Identifier: GPL-3.0-only - */ - -#pragma once - -#include <functional> -#include <string> -#include <vector> - -#include "hal/lv_hal_indev.h" -#include "input_hook.hpp" -#include "property.hpp" - -namespace input { - -/* - * Interface for all device input methods. Each 'Input Device' is polled by - * LVGL at regular intervals, and can effect the device either via LVGL's input - * device driver API, or by emitting events for other parts of the system to - * react to (e.g. issuing a play/pause event, or altering the volume). - */ -class IInputDevice { - public: - virtual ~IInputDevice() {} - - virtual auto read(lv_indev_data_t* data) -> void = 0; - - virtual auto name() -> std::string = 0; - virtual auto hooks() -> std::vector<TriggerHooks> { return {}; } -}; - -} // namespace input diff --git a/src/input/include/input_hook.hpp b/src/input/include/input_hook.hpp deleted file mode 100644 index 81eb80d9..00000000 --- a/src/input/include/input_hook.hpp +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright 2024 jacqueline <me@jacqueline.id.au> - * - * SPDX-License-Identifier: GPL-3.0-only - */ - -#pragma once - -#include <functional> -#include <optional> -#include <string> - -#include "hal/lv_hal_indev.h" -#include "lua.hpp" - -#include "input_trigger.hpp" - -namespace input { - -struct HookCallback { - std::string name; - std::function<void(lv_indev_data_t*)> fn; -}; - -class Hook { - public: - Hook(std::string name, std::optional<HookCallback> cb); - - auto invoke(lv_indev_data_t*) -> void; - auto override(std::optional<HookCallback>) -> void; - - auto name() const -> const std::string& { return name_; } - auto callback() -> std::optional<HookCallback>; - - private: - std::string name_; - std::optional<HookCallback> default_; - std::optional<HookCallback> override_; -}; - -class TriggerHooks { - public: - TriggerHooks(std::string name, std::optional<HookCallback> cb) - : TriggerHooks(name, cb, cb, cb) {} - TriggerHooks(std::string name, - std::optional<HookCallback> click, - std::optional<HookCallback> long_press, - std::optional<HookCallback> repeat); - - auto update(bool, lv_indev_data_t*) -> void; - auto override(Trigger::State, std::optional<HookCallback>) -> void; - - auto name() const -> const std::string&; - auto pushHooks(lua_State*) -> void; - - private: - std::string name_; - Trigger trigger_; - - Hook click_; - Hook long_press_; - Hook repeat_; -}; - -} // namespace input diff --git a/src/input/include/input_hook_actions.hpp b/src/input/include/input_hook_actions.hpp deleted file mode 100644 index 105bd10d..00000000 --- a/src/input/include/input_hook_actions.hpp +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2024 jacqueline <me@jacqueline.id.au> - * - * SPDX-License-Identifier: GPL-3.0-only - */ - -#pragma once - -#include "hal/lv_hal_indev.h" -#include "input_hook.hpp" - -namespace input { -namespace actions { - -auto select() -> HookCallback; - -auto scrollUp() -> HookCallback; -auto scrollDown() -> HookCallback; - -auto scrollToTop() -> HookCallback; -auto scrollToBottom() -> HookCallback; - -auto goBack() -> HookCallback; - -auto volumeUp() -> HookCallback; -auto volumeDown() -> HookCallback; - -auto allActions() -> std::vector<HookCallback>; - -} // namespace actions -} // namespace input diff --git a/src/input/include/input_nav_buttons.hpp b/src/input/include/input_nav_buttons.hpp deleted file mode 100644 index 4e4952c9..00000000 --- a/src/input/include/input_nav_buttons.hpp +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2024 jacqueline <me@jacqueline.id.au> - * - * SPDX-License-Identifier: GPL-3.0-only - */ - -#pragma once - -#include <cstdint> - -#include "gpios.hpp" -#include "hal/lv_hal_indev.h" - -#include "haptics.hpp" -#include "input_device.hpp" -#include "input_hook.hpp" -#include "input_trigger.hpp" -#include "touchwheel.hpp" - -namespace input { - -class NavButtons : public IInputDevice { - public: - NavButtons(drivers::IGpios&); - - auto read(lv_indev_data_t* data) -> void override; - - auto name() -> std::string override; - auto hooks() -> std::vector<TriggerHooks> override; - - private: - drivers::IGpios& gpios_; - - TriggerHooks up_; - TriggerHooks down_; -}; - -} // namespace input diff --git a/src/input/include/input_touch_dpad.hpp b/src/input/include/input_touch_dpad.hpp deleted file mode 100644 index 691e3243..00000000 --- a/src/input/include/input_touch_dpad.hpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2024 jacqueline <me@jacqueline.id.au> - * - * SPDX-License-Identifier: GPL-3.0-only - */ - -#pragma once - -#include <cstdint> - -#include "hal/lv_hal_indev.h" - -#include "haptics.hpp" -#include "input_device.hpp" -#include "input_hook.hpp" -#include "input_trigger.hpp" -#include "touchwheel.hpp" - -namespace input { - -class TouchDPad : public IInputDevice { - public: - TouchDPad(drivers::TouchWheel&); - - auto read(lv_indev_data_t* data) -> void override; - - auto name() -> std::string override; - auto hooks() -> std::vector<TriggerHooks> override; - - private: - drivers::TouchWheel& wheel_; - - TriggerHooks centre_; - TriggerHooks up_; - TriggerHooks right_; - TriggerHooks down_; - TriggerHooks left_; -}; - -} // namespace input diff --git a/src/input/include/input_touch_wheel.hpp b/src/input/include/input_touch_wheel.hpp deleted file mode 100644 index 1f116da9..00000000 --- a/src/input/include/input_touch_wheel.hpp +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright 2024 jacqueline <me@jacqueline.id.au> - * - * SPDX-License-Identifier: GPL-3.0-only - */ - -#pragma once - -#include <sys/_stdint.h> -#include <cstdint> - -#include "hal/lv_hal_indev.h" - -#include "haptics.hpp" -#include "input_device.hpp" -#include "input_hook.hpp" -#include "input_trigger.hpp" -#include "nvs.hpp" -#include "property.hpp" -#include "touchwheel.hpp" - -namespace input { - -class TouchWheel : public IInputDevice { - public: - TouchWheel(drivers::NvsStorage&, drivers::TouchWheel&); - - auto read(lv_indev_data_t* data) -> void override; - - auto name() -> std::string override; - auto hooks() -> std::vector<TriggerHooks> override; - - auto sensitivity() -> lua::Property&; - - private: - auto calculateTicks(const drivers::TouchWheelData& data) -> int8_t; - auto calculateThreshold(uint8_t sensitivity) -> uint8_t; - - drivers::NvsStorage& nvs_; - drivers::TouchWheel& wheel_; - - lua::Property sensitivity_; - - TriggerHooks centre_; - TriggerHooks up_; - TriggerHooks right_; - TriggerHooks down_; - TriggerHooks left_; - - bool is_scrolling_; - uint8_t threshold_; - bool is_first_read_; - uint8_t last_angle_; -}; - -} // namespace input diff --git a/src/input/include/input_trigger.hpp b/src/input/include/input_trigger.hpp deleted file mode 100644 index 599b796b..00000000 --- a/src/input/include/input_trigger.hpp +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2024 jacqueline <me@jacqueline.id.au> - * - * SPDX-License-Identifier: GPL-3.0-only - */ - -#pragma once - -#include <cstdint> -#include <optional> - -#include "hal/lv_hal_indev.h" - -namespace input { - -const uint16_t kLongPressDelayMs = LV_INDEV_DEF_LONG_PRESS_TIME; -const uint16_t kRepeatDelayMs = LV_INDEV_DEF_LONG_PRESS_REP_TIME; - -class Trigger { - public: - enum class State { - kNone, - kClick, - kLongPress, - kRepeatPress, - }; - - Trigger(); - - auto update(bool is_pressed) -> State; - - private: - std::optional<uint64_t> touch_time_ms_; - uint16_t times_fired_; -}; - -} // namespace input diff --git a/src/input/include/input_volume_buttons.hpp b/src/input/include/input_volume_buttons.hpp deleted file mode 100644 index a684aa48..00000000 --- a/src/input/include/input_volume_buttons.hpp +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2024 jacqueline <me@jacqueline.id.au> - * - * SPDX-License-Identifier: GPL-3.0-only - */ - -#pragma once - -#include <cstdint> - -#include "gpios.hpp" -#include "hal/lv_hal_indev.h" - -#include "haptics.hpp" -#include "input_device.hpp" -#include "input_hook.hpp" -#include "touchwheel.hpp" - -namespace input { - -class VolumeButtons : public IInputDevice { - public: - VolumeButtons(drivers::IGpios&); - - auto read(lv_indev_data_t* data) -> void override; - - auto name() -> std::string override; - auto hooks() -> std::vector<TriggerHooks> override; - - private: - drivers::IGpios& gpios_; - - TriggerHooks up_; - TriggerHooks down_; -}; - -} // namespace input diff --git a/src/input/include/lvgl_input_driver.hpp b/src/input/include/lvgl_input_driver.hpp deleted file mode 100644 index 9f43d27f..00000000 --- a/src/input/include/lvgl_input_driver.hpp +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright 2023 jacqueline <me@jacqueline.id.au> - * - * SPDX-License-Identifier: GPL-3.0-only - */ - -#pragma once - -#include <cstdint> -#include <deque> -#include <memory> -#include <set> - -#include "core/lv_group.h" -#include "device_factory.hpp" -#include "feedback_device.hpp" -#include "gpios.hpp" -#include "hal/lv_hal_indev.h" - -#include "input_device.hpp" -#include "nvs.hpp" -#include "property.hpp" -#include "touchwheel.hpp" - -namespace input { - -/* - * Implementation of an LVGL input device. This class composes multiple - * IInputDevice and IFeedbackDevice instances together into a single LVGL - * device. - */ -class LvglInputDriver { - public: - LvglInputDriver(drivers::NvsStorage& nvs, DeviceFactory&); - - auto mode() -> lua::Property& { return mode_; } - - auto read(lv_indev_data_t* data) -> void; - auto feedback(uint8_t) -> void; - - auto registration() -> lv_indev_t* { return registration_; } - auto lock(bool l) -> void { is_locked_ = l; } - - auto pushHooks(lua_State* L) -> int; - - private: - drivers::NvsStorage& nvs_; - DeviceFactory& factory_; - - lua::Property mode_; - lv_indev_drv_t driver_; - lv_indev_t* registration_; - - std::vector<std::shared_ptr<IInputDevice>> inputs_; - std::vector<std::shared_ptr<IFeedbackDevice>> feedbacks_; - - bool is_locked_; -}; - -} // namespace input |
