Merge pull request from psyke83/triggerfilter_generalize

filterTrigger: generalize for more controllers
This commit is contained in:
Jools Wills 2019-05-14 02:11:06 +01:00 committed by GitHub
commit 3fdaa2aafb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 10 deletions

View file

@ -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,20 +336,25 @@ 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)
}
// 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

View file

@ -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;
};