| 101 | } |
| 102 | |
| 103 | bool InputAgent::init() |
| 104 | { |
| 105 | LogFunc; |
| 106 | |
| 107 | if (active_unit_) { |
| 108 | LogError << "already initialized" << VAR(active_unit_); |
| 109 | return false; |
| 110 | } |
| 111 | |
| 112 | for (auto& unit : units_ | std::views::values) { |
| 113 | if (!unit->init()) { |
| 114 | continue; |
| 115 | } |
| 116 | active_unit_ = std::move(unit); |
| 117 | break; |
| 118 | } |
| 119 | |
| 120 | if (!active_unit_) { |
| 121 | LogError << "No available input method"; |
| 122 | return false; |
| 123 | } |
| 124 | |
| 125 | units_.clear(); |
| 126 | return true; |
| 127 | } |
| 128 | |
| 129 | MaaControllerFeature InputAgent::get_features() const |
| 130 | { |