From 93fdfaa9c2815edd34ed79883d5a983eefde17d1 Mon Sep 17 00:00:00 2001 From: Conn O'Griofa Date: Thu, 11 Apr 2019 02:52:21 +0100 Subject: [PATCH] filterTrigger: generalize for more controllers * Filter axes 2/5 for all devices, but only if LeftTrigger or RightTrigger is being configured. This should fix compatibility with XBox 360 and other generic controllers that use these axes for triggers, but won't affect other controllers using these axes for analog sticks, etc. * Improve third-party PS3 detection (some Shanwan controllers have a grave accent in place of 'm' for 'Gamepad'). --- es-core/src/guis/GuiInputConfig.cpp | 22 +++++++++++++--------- es-core/src/guis/GuiInputConfig.h | 3 ++- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/es-core/src/guis/GuiInputConfig.cpp b/es-core/src/guis/GuiInputConfig.cpp index 3ec21f101..29111a484 100755 --- a/es-core/src/guis/GuiInputConfig.cpp +++ b/es-core/src/guis/GuiInputConfig.cpp @@ -133,9 +133,8 @@ GuiInputConfig::GuiInputConfig(Window* window, InputConfig* target, bool reconfi return false; } - - // filter for input quirks specific to Sony DualShock 3 - if(filterTrigger(input, config)) + // apply filtering for quirks related to trigger mapping + if(filterTrigger(input, config, i)) return false; // we are configuring @@ -337,21 +336,26 @@ void GuiInputConfig::clearAssignment(int inputId) mTargetConfig->unmapInput(GUI_INPUT_CONFIG_LIST[inputId].name); } -bool GuiInputConfig::filterTrigger(Input input, InputConfig* config) +bool GuiInputConfig::filterTrigger(Input input, InputConfig* config, int inputId) { #if defined(__linux__) // match PlayStation joystick with 6 axes only if((strstr(config->getDeviceName().c_str(), "PLAYSTATION") != NULL \ - || strstr(config->getDeviceName().c_str(), "PS3 Game") != NULL \ - || strstr(config->getDeviceName().c_str(), "PS(R) Game") != NULL) \ + || strstr(config->getDeviceName().c_str(), "PS3 Ga") != NULL \ + || strstr(config->getDeviceName().c_str(), "PS(R) Ga") != NULL) \ && InputManager::getInstance()->getAxisCountByDevice(config->getDeviceId()) == 6) { // digital triggers are unwanted if (input.type == TYPE_BUTTON && (input.id == 6 || input.id == 7)) return true; - // ignore analog values < 0 - if (input.type == TYPE_AXIS && (input.id == 2 || input.id == 5) && input.value < 0) - return true; + } + + // ignore negative pole for axes 2/5 only when triggers are being configured + if((mSkipAxis || strstr(GUI_INPUT_CONFIG_LIST[inputId].name, "Trigger") != NULL) \ + && input.type == TYPE_AXIS && (input.id == 2 || input.id == 5) && input.value < 0) + { + mSkipAxis = true; + return true; } #endif diff --git a/es-core/src/guis/GuiInputConfig.h b/es-core/src/guis/GuiInputConfig.h index bef5f03ea..d33a8fad7 100644 --- a/es-core/src/guis/GuiInputConfig.h +++ b/es-core/src/guis/GuiInputConfig.h @@ -28,7 +28,7 @@ private: bool assign(Input input, int inputId); void clearAssignment(int inputId); - bool filterTrigger(Input input, InputConfig* config); + bool filterTrigger(Input input, InputConfig* config, int inputId); void rowDone(); @@ -50,6 +50,7 @@ private: Input mHeldInput; int mHeldTime; int mHeldInputId; + bool mSkipAxis; BusyComponent mBusyAnim; };