Adds option for an Axis Fix for some (PS2) adapters which map the D-Pad to Axis

This commit is contained in:
Fighter19
2015-05-06 10:04:55 +02:00
parent 9d1ba50c23
commit 73ee19b7cf
11 changed files with 42 additions and 5 deletions
@@ -3,6 +3,7 @@
#include "RageLog.h"
#include "RageUtil.h"
#include "LinuxInputManager.h"
#include "GamePreferences.h" //needed for Axis Fix
#include <unistd.h>
#include <fcntl.h>
@@ -13,6 +14,7 @@
#include <linux/input.h>
REGISTER_INPUT_HANDLER_CLASS2( LinuxEvent, Linux_Event );
static Preference<bool> g_bAxisFix( "AxisFix", false );
static RString BustypeToString( int iBus )
{
@@ -409,8 +411,16 @@ void InputHandler_Linux_Event::InputThread()
DeviceButton pos = g_apEventDevices[i]->aiAbsMappingHigh[event.code];
float l = SCALE( int(event.value), (float) g_apEventDevices[i]->aiAbsMin[event.code], (float) g_apEventDevices[i]->aiAbsMax[event.code], -1.0f, 1.0f );
ButtonPressed( DeviceInput(g_apEventDevices[i]->m_Dev, neg, max(-l,0), now) );
ButtonPressed( DeviceInput(g_apEventDevices[i]->m_Dev, pos, max(+l,0), now) );
if (g_bAxisFix)
{
ButtonPressed( DeviceInput(g_apEventDevices[i]->m_Dev, neg, (l < -0.5)||((l > 0.0001)&&(l < 0.5)), now) ); //Up if between 0.0001 and 0.5 or if less than -0.5
ButtonPressed( DeviceInput(g_apEventDevices[i]->m_Dev, pos, (l > 0.5)||((l > 0.0001)&&(l < 0.5)) , now) ); //Down if between 0.0001 and 0.5 or if more than 0.5
}
else
{
ButtonPressed( DeviceInput(g_apEventDevices[i]->m_Dev, neg, max(-l,0), now) );
ButtonPressed( DeviceInput(g_apEventDevices[i]->m_Dev, pos, max(+l,0), now) );
}
break;
}
}