| 563 | } // namespace |
| 564 | |
| 565 | void Input::ProcessController(int controller_id, float timestep) { |
| 566 | PlayerInput& control = player_inputs_[controller_id]; |
| 567 | |
| 568 | // Early out if we're remote controlled via network. |
| 569 | if (control.remote_controlled) { |
| 570 | return; |
| 571 | } |
| 572 | |
| 573 | // Early out if we're disabled. |
| 574 | if (control.enabled == false) { |
| 575 | return; |
| 576 | } |
| 577 | |
| 578 | // Set all keydown counts to negative |
| 579 | PlayerInput::KeyDownMap& kd = control.key_down; |
| 580 | for (auto& iter : kd) { |
| 581 | iter.second.count *= -1; |
| 582 | iter.second.depth = 0.0f; |
| 583 | } |
| 584 | std::set<std::string> active_buttons; |
| 585 | // If any bound controller button is pressed more than halfway in |
| 586 | // (disregarding sensitivity settings), controller input is accepted until |
| 587 | // any mouse/keyboard bind is pressed. |
| 588 | // This is to avoid misconfigured deadzone settings to spook around |
| 589 | if (!use_controller_input_) { |
| 590 | bool run = true; |
| 591 | for (JoystickMap::iterator iter = open_joysticks_.begin(); run && iter != open_joysticks_.end(); ++iter) { |
| 592 | const RC_JoystickStruct js = iter->second; |
| 593 | if (js.GetConst().player_input != controller_id) { |
| 594 | continue; |
| 595 | } |
| 596 | const Joystick& joystick = js.GetConst().joystick; |
| 597 | const Joystick::ButtonMap& bm = joystick.buttons_down_; |
| 598 | for (const auto& iter2 : bm) { |
| 599 | if (iter2.second) { |
| 600 | float depth = iter2.second; |
| 601 | if (depth > 0.5f) { |
| 602 | use_controller_input_ = true; |
| 603 | run = false; |
| 604 | break; |
| 605 | } |
| 606 | } |
| 607 | } |
| 608 | } |
| 609 | } |
| 610 | // Joystick input |
| 611 | if (allow_controller_input_ && use_controller_input_) { |
| 612 | for (auto& open_joystick : open_joysticks_) { |
| 613 | const RC_JoystickStruct js = open_joystick.second; |
| 614 | if (js.GetConst().player_input != controller_id) { |
| 615 | continue; |
| 616 | } |
| 617 | const Joystick& joystick = js.GetConst().joystick; |
| 618 | const Joystick::ButtonMap& bm = joystick.buttons_down_; |
| 619 | for (const auto& iter2 : bm) { |
| 620 | if (iter2.second) { |
| 621 | float sensitivity = 1.0f; |
| 622 | if (memcmp(iter2.first.c_str(), "look", 4) == 0) { |
nothing calls this directly
no test coverage detected