| 295 | } |
| 296 | |
| 297 | void ClientApplication::processInput(InputEvent const& event) { |
| 298 | if (auto keyDown = event.ptr<KeyDownEvent>()) { |
| 299 | m_heldKeyEvents.append(*keyDown); |
| 300 | m_edgeKeyEvents.append(*keyDown); |
| 301 | } else if (auto keyUp = event.ptr<KeyUpEvent>()) { |
| 302 | eraseWhere(m_heldKeyEvents, [&](auto& keyEvent) { |
| 303 | return keyEvent.key == keyUp->key; |
| 304 | }); |
| 305 | |
| 306 | Maybe<KeyMod> modKey = KeyModNames.maybeLeft(KeyNames.getRight(keyUp->key)); |
| 307 | if (modKey) |
| 308 | m_heldKeyEvents.transform([&](auto& keyEvent) { |
| 309 | return KeyDownEvent{keyEvent.key, keyEvent.mods & ~*modKey}; |
| 310 | }); |
| 311 | } |
| 312 | else if (auto cAxis = event.ptr<ControllerAxisEvent>()) { |
| 313 | if (cAxis->controllerAxis == ControllerAxis::LeftX) |
| 314 | m_controllerLeftStick[0] = cAxis->controllerAxisValue; |
| 315 | else if (cAxis->controllerAxis == ControllerAxis::LeftY) |
| 316 | m_controllerLeftStick[1] = cAxis->controllerAxisValue; |
| 317 | else if (cAxis->controllerAxis == ControllerAxis::RightX) |
| 318 | m_controllerRightStick[0] = cAxis->controllerAxisValue; |
| 319 | else if (cAxis->controllerAxis == ControllerAxis::RightY) |
| 320 | m_controllerRightStick[1] = cAxis->controllerAxisValue; |
| 321 | } |
| 322 | |
| 323 | bool processed = !m_errorScreen->accepted() && m_errorScreen->handleInputEvent(event); |
| 324 | |
| 325 | if (!processed) { |
| 326 | if (m_state == MainAppState::Splash) { |
| 327 | processed = m_cinematicOverlay->handleInputEvent(event); |
| 328 | } else if (m_state == MainAppState::Title) { |
| 329 | if (!(processed = m_cinematicOverlay->handleInputEvent(event))) |
| 330 | processed = m_titleScreen->handleInputEvent(event); |
| 331 | |
| 332 | } else if (m_state == MainAppState::SinglePlayer || m_state == MainAppState::MultiPlayer) { |
| 333 | if (!(processed = m_cinematicOverlay->handleInputEvent(event))) |
| 334 | processed = m_mainInterface->handleInputEvent(event); |
| 335 | } |
| 336 | } |
| 337 | |
| 338 | m_input->handleInput(event, processed); |
| 339 | } |
| 340 | |
| 341 | void ClientApplication::update() { |
| 342 | float dt = GlobalTimestep * GlobalTimescale; |
nothing calls this directly
no test coverage detected