| 65 | } |
| 66 | |
| 67 | void InputManager::update() |
| 68 | { |
| 69 | if (m_enabled) |
| 70 | { |
| 71 | auto actionBuffer = m_currentActions; |
| 72 | for (auto action : actionBuffer) |
| 73 | { |
| 74 | |
| 75 | action->update(); |
| 76 | } |
| 77 | if (m_refresh) |
| 78 | { |
| 79 | bool noRefresh = true; |
| 80 | for (auto& [_, input] : m_inputs) |
| 81 | { |
| 82 | |
| 83 | if (input->isPressed()) |
| 84 | { |
| 85 | |
| 86 | noRefresh = false; |
| 87 | break; |
| 88 | } |
| 89 | } |
| 90 | for (const auto& monitorPtr : m_monitors) |
| 91 | { |
| 92 | if (const auto& monitor = monitorPtr.lock()) |
| 93 | { |
| 94 | if (monitor->getButton().isPressed()) |
| 95 | { |
| 96 | noRefresh = false; |
| 97 | break; |
| 98 | } |
| 99 | } |
| 100 | } |
| 101 | m_refresh = !noRefresh; |
| 102 | m_monitors.erase( |
| 103 | std::remove_if(m_monitors.begin(), m_monitors.end(), |
| 104 | [this](const std::weak_ptr<InputButtonMonitor>& element) { |
| 105 | return updateOrCleanMonitor(t_inputs, element); |
| 106 | }), |
| 107 | m_monitors.end()); |
| 108 | } |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | bool InputManager::actionExists(const std::string& actionId) |
| 113 | { |
no test coverage detected