Merge pull request #585 from Fighter19/master

Add an option to fix the axis problem
This commit is contained in:
Kyzentun
2015-05-09 08:27:46 -06:00
11 changed files with 42 additions and 5 deletions
+1
View File
@@ -775,6 +775,7 @@ static void InitializeConfOptions()
ADD( ConfOption( "ThreeKeyNavigation", MovePref<bool>, "Five Key Menu", "Three Key Menu" ) );
ADD( ConfOption( "MusicWheelSwitchSpeed", MusicWheelSwitchSpeed, "Slow","Normal","Fast","Really Fast" ) );
ADD( ConfOption( "InputDebounceTime", InputDebounceTime, "0ms", "10ms", "20ms", "30ms", "40ms", "50ms", "60ms", "70ms", "80ms", "90ms", "100ms") );
ADD( ConfOption( "AxisFix", MovePref<bool>, "Off","On" ) );
// Gameplay options
ADD( ConfOption( "Center1Player", MovePref<bool>, "Off","On" ) );
@@ -10,11 +10,13 @@
#include "archutils/Win32/RegistryAccess.h"
#include "InputFilter.h"
#include "PrefsManager.h"
#include "GamePreferences.h" //needed for Axis Fix
#include "Foreach.h"
#include "InputHandler_DirectInputHelper.h"
REGISTER_INPUT_HANDLER_CLASS2( DirectInput, DInput );
static Preference<bool> g_bAxisFix( "AxisFix", false );
static vector<DIDevice> Devices;
@@ -587,8 +589,17 @@ void InputHandler_DInput::UpdateBuffered( DIDevice &device, const RageTimer &tm
device.m_sName.c_str(), in.ofs );
float l = SCALE( int(evtbuf[i].dwData), 0.0f, 100.0f, 0.0f, 1.0f );
ButtonPressed( DeviceInput(dev, up, max(-l,0), tm) );
ButtonPressed( DeviceInput(dev, down, max(+l,0), tm) );
if(g_bAxisFix)
{
ButtonPressed( DeviceInput(dev, up, (l == 0) || (l == -1), tm) );
ButtonPressed( DeviceInput(dev, down,(l == 0) || (l == 1), tm) );
}
else
{
ButtonPressed( DeviceInput(dev, up, max(-l,0), tm) );
ButtonPressed( DeviceInput(dev, down, max(+l,0), tm) );
}
}
break;
}
@@ -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;
}
}