summaryrefslogtreecommitdiff
path: root/src/tangara/input/input_device.hpp
blob: 7b8d993dee4a8bc2e75f8261cce7ba6db80ef491 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*
 * Copyright 2024 jacqueline <me@jacqueline.id.au>
 *
 * SPDX-License-Identifier: GPL-3.0-only
 */

#pragma once

#include <functional>
#include <string>
#include <vector>

#include "drivers/nvs.hpp"
#include "indev/lv_indev.h"
#include "input/input_events.hpp"
#include "input/input_hook.hpp"
#include "lua/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, std::vector<InputEvent>& events) -> void = 0;

  virtual auto name() -> std::string = 0;
  virtual auto triggers() -> std::vector<std::reference_wrapper<TriggerHooks>> {
    return {};
  }

  /* Called by the LVGL driver when controls are being locked. */
  virtual auto onLock(drivers::NvsStorage::LockedInputModes) -> void {}
  /* Called by the LVGL driver when controls are being unlocked. */
  virtual auto onUnlock() -> void {}
};

}  // namespace input