blob: fe2e2485a9e5e4f279396fa5e943c2920a979313 (
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
/*
* Copyright 2023 jacqueline <me@jacqueline.id.au>
*
* SPDX-License-Identifier: GPL-3.0-only
*/
#include "input/device_factory.hpp"
#include <memory>
#include "input/feedback_haptics.hpp"
#include "input/feedback_tts.hpp"
#include "input/input_device.hpp"
#include "input/input_hard_reset.hpp"
#include "input/input_nav_buttons.hpp"
#include "input/input_touch_dpad.hpp"
#include "input/input_touch_wheel.hpp"
#include "input/input_volume_buttons.hpp"
namespace input {
DeviceFactory::DeviceFactory(
std::shared_ptr<system_fsm::ServiceLocator> services)
: services_(services) {
if (services->touchwheel()) {
wheel_ =
std::make_shared<TouchWheel>(services->nvs(), **services->touchwheel());
}
}
auto DeviceFactory::createInputs(drivers::NvsStorage::InputModes mode)
-> std::vector<std::shared_ptr<IInputDevice>> {
std::vector<std::shared_ptr<IInputDevice>> ret;
switch (mode) {
case drivers::NvsStorage::InputModes::kButtonsOnly:
ret.push_back(std::make_shared<NavButtons>(services_->gpios()));
break;
case drivers::NvsStorage::InputModes::kDirectionalWheel:
ret.push_back(std::make_shared<VolumeButtons>(services_->gpios()));
if (services_->touchwheel()) {
ret.push_back(std::make_shared<TouchDPad>(**services_->touchwheel()));
}
break;
case drivers::NvsStorage::InputModes::kRotatingWheel:
default: // Don't break input over a bad enum value.
ret.push_back(std::make_shared<VolumeButtons>(services_->gpios()));
if (wheel_) {
ret.push_back(wheel_);
}
break;
}
ret.push_back(std::make_shared<HardReset>(services_->gpios()));
return ret;
}
auto DeviceFactory::createFeedbacks()
-> std::vector<std::shared_ptr<IFeedbackDevice>> {
return {
std::make_shared<Haptics>(services_->haptics(), services_),
std::make_shared<TextToSpeech>(services_->tts()),
};
}
} // namespace input
|