| 1677 | } |
| 1678 | |
| 1679 | bool Interactor::check_validity() |
| 1680 | { |
| 1681 | using namespace MAA_PROJECT_INTERFACE_NS; |
| 1682 | |
| 1683 | if (config_.configuration().controller.type == InterfaceData::Controller::Type::Win32 |
| 1684 | && config_.configuration().win32.hwnd == nullptr) { |
| 1685 | auto& name = config_.configuration().controller.name; |
| 1686 | auto controller_iter = std::ranges::find(config_.interface_data().controller, name, std::mem_fn(&InterfaceData::Controller::name)); |
| 1687 | |
| 1688 | if (controller_iter == config_.interface_data().controller.end()) { |
| 1689 | LogError << "Contorller not found" << VAR(name); |
| 1690 | return false; |
| 1691 | } |
| 1692 | |
| 1693 | return select_win32_hwnd(controller_iter->win32); |
| 1694 | } |
| 1695 | |
| 1696 | if (config_.configuration().controller.type == InterfaceData::Controller::Type::MacOS) { |
| 1697 | auto& mac = config_.configuration().macos; |
| 1698 | if (mac.window_id == 0 || mac.title.empty()) { |
| 1699 | auto& name = config_.configuration().controller.name; |
| 1700 | auto controller_iter = |
| 1701 | std::ranges::find(config_.interface_data().controller, name, std::mem_fn(&InterfaceData::Controller::name)); |
| 1702 | |
| 1703 | if (controller_iter == config_.interface_data().controller.end()) { |
| 1704 | LogError << "Controller not found" << VAR(name); |
| 1705 | return false; |
| 1706 | } |
| 1707 | |
| 1708 | select_macos(controller_iter->macos); |
| 1709 | return mac.window_id != 0; |
| 1710 | } |
| 1711 | } |
| 1712 | |
| 1713 | if (config_.configuration().controller.type == InterfaceData::Controller::Type::PlayCover) { |
| 1714 | if (!kPlayCoverSupported) { |
| 1715 | LogError << "PlayCover controller is only available on macOS"; |
| 1716 | return false; |
| 1717 | } |
| 1718 | |
| 1719 | auto& pc = config_.configuration().playcover; |
| 1720 | if (pc.address.empty()) { |
| 1721 | auto& name = config_.configuration().controller.name; |
| 1722 | auto controller_iter = |
| 1723 | std::ranges::find(config_.interface_data().controller, name, std::mem_fn(&InterfaceData::Controller::name)); |
| 1724 | |
| 1725 | if (controller_iter != config_.interface_data().controller.end()) { |
| 1726 | select_playcover(controller_iter->playcover); |
| 1727 | } |
| 1728 | } |
| 1729 | |
| 1730 | if (pc.address.empty()) { |
| 1731 | LogError << "PlayCover address is empty"; |
| 1732 | return false; |
| 1733 | } |
| 1734 | } |
| 1735 | |
| 1736 | if (config_.configuration().controller.type == InterfaceData::Controller::Type::Gamepad) { |