mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-25 23:55:38 +00:00
Merge pull request #554 from psyke83/ps3_triggerfilter
Implement filterTrigger for PS3 controllers
This commit is contained in:
commit
fd04b153af
|
@ -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)
|
||||
|
|
|
@ -48,6 +48,7 @@ public:
|
|||
void deinit();
|
||||
|
||||
int getNumJoysticks();
|
||||
int getAxisCountByDevice(int deviceId);
|
||||
int getButtonCountByDevice(int deviceId);
|
||||
int getNumConfiguredDevices();
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ private:
|
|||
|
||||
bool assign(Input input, int inputId);
|
||||
void clearAssignment(int inputId);
|
||||
bool filterTrigger(Input input, InputConfig* config);
|
||||
|
||||
void rowDone();
|
||||
|
||||
|
|
Loading…
Reference in a new issue