From 4f75dc06b9fa36b9b97a8467aa0a27b6fec5d959 Mon Sep 17 00:00:00 2001 From: Megamouse Date: Thu, 9 Feb 2023 00:01:26 +0100 Subject: [PATCH] evdev: optimize get_next_button_press pad id check --- rpcs3/Input/evdev_joystick_handler.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/rpcs3/Input/evdev_joystick_handler.cpp b/rpcs3/Input/evdev_joystick_handler.cpp index e465377fc2..7a0d7d1091 100644 --- a/rpcs3/Input/evdev_joystick_handler.cpp +++ b/rpcs3/Input/evdev_joystick_handler.cpp @@ -366,14 +366,17 @@ PadHandlerBase::connection evdev_joystick_handler::get_next_button_press(const s std::string name; } pressed_button{}; + const bool is_xbox_360_controller = padId.find("Xbox 360") != umax; + const bool is_sony_controller = !is_xbox_360_controller && padId.find("Sony") != umax; + for (const auto& [code, name] : button_list) { // Handle annoying useless buttons if (code == NO_BUTTON) continue; - if (padId.find("Xbox 360") != umax && code >= BTN_TRIGGER_HAPPY) + if (is_xbox_360_controller && code >= BTN_TRIGGER_HAPPY) continue; - if (padId.find("Sony") != umax && (code == BTN_TL2 || code == BTN_TR2)) + if (is_sony_controller && (code == BTN_TL2 || code == BTN_TR2)) continue; if (!get_blacklist && std::find(m_blacklist.begin(), m_blacklist.end(), name) != m_blacklist.end())