diff --git a/es-core/src/InputManager.cpp b/es-core/src/InputManager.cpp index 86f283d93..d074367eb 100644 --- a/es-core/src/InputManager.cpp +++ b/es-core/src/InputManager.cpp @@ -172,6 +172,12 @@ void InputManager::deinit() } int InputManager::getNumJoysticks() { return (int)mJoysticks.size(); } + +int InputManager::getAxisCountByDevice(SDL_JoystickID id) +{ + return SDL_JoystickNumAxes(mJoysticks[id]); +} + int InputManager::getButtonCountByDevice(SDL_JoystickID id) { if(id == DEVICE_KEYBOARD) diff --git a/es-core/src/InputManager.h b/es-core/src/InputManager.h index fde96f092..77ff0a16c 100644 --- a/es-core/src/InputManager.h +++ b/es-core/src/InputManager.h @@ -48,6 +48,7 @@ public: void deinit(); int getNumJoysticks(); + int getAxisCountByDevice(int deviceId); int getButtonCountByDevice(int deviceId); int getNumConfiguredDevices(); diff --git a/es-core/src/guis/GuiInputConfig.cpp b/es-core/src/guis/GuiInputConfig.cpp index fe3b95e9d..3ec21f101 100755 --- a/es-core/src/guis/GuiInputConfig.cpp +++ b/es-core/src/guis/GuiInputConfig.cpp @@ -133,6 +133,11 @@ GuiInputConfig::GuiInputConfig(Window* window, InputConfig* target, bool reconfi return false; } + + // filter for input quirks specific to Sony DualShock 3 + if(filterTrigger(input, config)) + return false; + // we are configuring if(input.value != 0) { @@ -331,3 +336,24 @@ void GuiInputConfig::clearAssignment(int inputId) { mTargetConfig->unmapInput(GUI_INPUT_CONFIG_LIST[inputId].name); } + +bool GuiInputConfig::filterTrigger(Input input, InputConfig* config) +{ +#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) \ + && 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; + } +#endif + + return false; +} diff --git a/es-core/src/guis/GuiInputConfig.h b/es-core/src/guis/GuiInputConfig.h index 134ad3903..bef5f03ea 100644 --- a/es-core/src/guis/GuiInputConfig.h +++ b/es-core/src/guis/GuiInputConfig.h @@ -28,6 +28,7 @@ private: bool assign(Input input, int inputId); void clearAssignment(int inputId); + bool filterTrigger(Input input, InputConfig* config); void rowDone();