From 1ba30c519c9772fc1af7a465f3ceec753e8a3665 Mon Sep 17 00:00:00 2001 From: Gliniak Date: Mon, 30 Dec 2024 15:01:55 +0100 Subject: [PATCH] [HID] Fixed issues with double input in specific config HID configuration. This was the case in hid set to "any" or to "winkey" and game that requires input from any user --- src/xenia/app/xenia_main.cc | 62 +++++++++++++++++++++++-------------- 1 file changed, 38 insertions(+), 24 deletions(-) diff --git a/src/xenia/app/xenia_main.cc b/src/xenia/app/xenia_main.cc index c1be293f6..d90246936 100644 --- a/src/xenia/app/xenia_main.cc +++ b/src/xenia/app/xenia_main.cc @@ -176,36 +176,50 @@ class EmulatorApp final : public xe::ui::WindowedApp { std::vector> CreateAll(const std::string_view name, Args... args) { std::vector> instances; - if (!name.empty() && name != "any") { - auto it = std::find_if( - creators_.cbegin(), creators_.cend(), - [&name](const auto& f) { return name.compare(f.name) == 0; }); - if (it != creators_.cend() && (*it).is_available()) { - auto instance = (*it).instantiate(std::forward(args)...); - if (instance) { - instances.emplace_back(std::move(instance)); - } - } -#if XE_PLATFORM_WIN32 - // Always add winkey for passthrough - it = std::find_if( - creators_.cbegin(), creators_.cend(), - [&name](const auto& f) { return f.name.compare("winkey") == 0; }); - if (it != creators_.cend() && (*it).is_available()) { - auto instance = (*it).instantiate(std::forward(args)...); - if (instance) { - instances.emplace_back(std::move(instance)); - } - } -#endif - } else { + + // "Any" path + if (name.empty() || name == "any") { for (const auto& creator : creators_) { - if (!creator.is_available()) continue; + if (!creator.is_available()) { + continue; + } + + // Skip xinput for "any" and use SDL + if (creator.name.compare("xinput") == 0) { + continue; + } + auto instance = creator.instantiate(std::forward(args)...); if (instance) { instances.emplace_back(std::move(instance)); } } + return instances; + } + + // "Specified" path. Winkey is always added on windows. + if (name != "winkey") { + auto it = std::find_if( + creators_.cbegin(), creators_.cend(), + [&name](const auto& f) { return name.compare(f.name) == 0; }); + + if (it != creators_.cend() && (*it).is_available()) { + auto instance = (*it).instantiate(std::forward(args)...); + if (instance) { + instances.emplace_back(std::move(instance)); + } + } + } + + // Always add winkey for passthrough. + auto it = std::find_if( + creators_.cbegin(), creators_.cend(), + [&name](const auto& f) { return f.name.compare("winkey") == 0; }); + if (it != creators_.cend() && (*it).is_available()) { + auto instance = (*it).instantiate(std::forward(args)...); + if (instance) { + instances.emplace_back(std::move(instance)); + } } return instances; }