| 554 | } |
| 555 | |
| 556 | void Scene_Settings::UpdateButtonAdd() { |
| 557 | const Input::KeyStatus* keys = &Input::GetAllRawPressed(); |
| 558 | |
| 559 | auto& frame = options_window->GetFrame(); |
| 560 | int& started = frame.scratch; |
| 561 | int& cancel_timer = frame.scratch2; |
| 562 | |
| 563 | if (cancel_timer == Game_Clock::GetTargetGameFps() * 3) { |
| 564 | options_window->Pop(); |
| 565 | input_window->Refresh(); |
| 566 | return; |
| 567 | } |
| 568 | ++cancel_timer; |
| 569 | |
| 570 | // Delay button reading on startup until 0 keys are pressed |
| 571 | // Prevents that CONFIRM is directly detected as pressed key |
| 572 | // on some platforms |
| 573 | if (started == 0) { |
| 574 | keys = &Input::GetAllRawPressed(); |
| 575 | if (keys->count() != 0) { |
| 576 | return; |
| 577 | } |
| 578 | started = 1; |
| 579 | } |
| 580 | |
| 581 | for (size_t i = 0; i < keys->size(); ++i) { |
| 582 | if ((*keys)[i]) { |
| 583 | auto button = static_cast<Input::InputButton>(frame.arg); |
| 584 | auto& mappings = Input::GetInputSource()->GetButtonMappings(); |
| 585 | mappings.Add({button, static_cast<Input::Keys::InputKey>(i) }); |
| 586 | options_window->Pop(); |
| 587 | input_window->Refresh(); |
| 588 | break; |
| 589 | } |
| 590 | } |
| 591 | } |
| 592 | |
| 593 | void Scene_Settings::UpdateButtonRemove() { |
| 594 | if (Input::IsTriggered(Input::DECISION)) { |