| 1 | // Copyright 2024 Dolphin Emulator Project |
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | |
| 4 | #include "InputCommon/ControllerEmu/ControlGroup/IRPassthrough.h" |
| 5 | |
| 6 | #include <algorithm> |
| 7 | #include <string> |
| 8 | |
| 9 | #include "Common/Common.h" |
| 10 | |
| 11 | #include "InputCommon/ControllerEmu/Control/Control.h" |
| 12 | |
| 13 | namespace ControllerEmu |
| 14 | { |
| 15 | IRPassthrough::IRPassthrough(std::string name_, std::string ui_name_) |
| 16 | : ControlGroup(std::move(name_), std::move(ui_name_), GroupType::IRPassthrough, |
| 17 | ControlGroup::DefaultValue::Disabled) |
| 18 | { |
| 19 | AddInput(Translatability::Translate, _trans("Object 1 X")); |
| 20 | AddInput(Translatability::Translate, _trans("Object 1 Y")); |
| 21 | AddInput(Translatability::Translate, _trans("Object 1 Size")); |
| 22 | AddInput(Translatability::Translate, _trans("Object 2 X")); |
| 23 | AddInput(Translatability::Translate, _trans("Object 2 Y")); |
| 24 | AddInput(Translatability::Translate, _trans("Object 2 Size")); |
| 25 | AddInput(Translatability::Translate, _trans("Object 3 X")); |
| 26 | AddInput(Translatability::Translate, _trans("Object 3 Y")); |
| 27 | AddInput(Translatability::Translate, _trans("Object 3 Size")); |
| 28 | AddInput(Translatability::Translate, _trans("Object 4 X")); |
| 29 | AddInput(Translatability::Translate, _trans("Object 4 Y")); |
| 30 | AddInput(Translatability::Translate, _trans("Object 4 Size")); |
| 31 | } |
| 32 | |
| 33 | ControlState IRPassthrough::GetObjectPositionX(size_t object_index) const |
| 34 | { |
| 35 | return controls[object_index * 3 + 0]->GetState(); |
| 36 | } |
| 37 | |
| 38 | ControlState IRPassthrough::GetObjectPositionY(size_t object_index) const |
| 39 | { |
| 40 | return controls[object_index * 3 + 1]->GetState(); |
| 41 | } |
| 42 | |
| 43 | ControlState IRPassthrough::GetObjectSize(size_t object_index) const |
| 44 | { |
| 45 | return controls[object_index * 3 + 2]->GetState(); |
| 46 | } |
| 47 | |
| 48 | bool IRPassthrough::AreInputsBound() const |
| 49 | { |
| 50 | return std::ranges::any_of( |
| 51 | controls, [](const auto& control) { return control->control_ref->BoundCount() > 0; }); |
| 52 | } |
| 53 | |
| 54 | } // namespace ControllerEmu |