Skip to content

Commit f205f34

Browse files
committed
Added full axis option to joystick bindings
1 parent 382a355 commit f205f34

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

Client/core/CJoystickManager.cpp

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ enum eDir
6262
{
6363
eDirNeg,
6464
eDirPos,
65+
eDirNegToPos,
6566
eDirMax
6667
};
6768

@@ -79,7 +80,7 @@ enum eStick
7980
struct SMappingLine
8081
{
8182
eJoy SourceAxisIndex; // 0 - 7
82-
eDir SourceAxisDir; // 0 - 1
83+
eDir SourceAxisDir; // 0 - 2
8384
eStick OutputAxisIndex; // 0/1 2/3 4 5
8485
eDir OutputAxisDir; // 0 - 1
8586
bool bEnabled;
@@ -652,6 +653,7 @@ void CJoystickManager::DoPulse(void)
652653
// See if any axes have changed to over 0.75
653654
for (int i = 0; i < NUMELMS(m_JoystickState.rgfAxis); i++)
654655
{
656+
// Half axis movement (0 to 1)
655657
if (fabs(m_JoystickState.rgfAxis[i]) > 0.75f)
656658
if (fabs(m_PreBindJoystickState.rgfAxis[i]) < 0.75f)
657659
{
@@ -662,6 +664,18 @@ void CJoystickManager::DoPulse(void)
662664
m_currentMapping[m_iCaptureOutputIndex].SourceAxisDir = m_JoystickState.rgfAxis[i] < 0.f ? eDirNeg : eDirPos;
663665
m_SettingsRevision++;
664666
}
667+
668+
// Full axis movement (-1 to 1)
669+
if (m_JoystickState.rgfAxis[i] > 0.75f)
670+
if (m_PreBindJoystickState.rgfAxis[i] < -0.75f)
671+
{
672+
m_bCaptureAxis = false;
673+
// Save the mapping
674+
m_currentMapping[m_iCaptureOutputIndex].bEnabled = true;
675+
m_currentMapping[m_iCaptureOutputIndex].SourceAxisIndex = (eJoy)i;
676+
m_currentMapping[m_iCaptureOutputIndex].SourceAxisDir = eDirNegToPos;
677+
m_SettingsRevision++;
678+
}
665679
}
666680
}
667681
}
@@ -1037,7 +1051,11 @@ void CJoystickManager::ApplyAxes(CControllerState& cs, bool bInVehicle)
10371051
if (line.SourceAxisDir == eDirPos)
10381052
value = std::max(0.f, value);
10391053
else
1054+
if (line.SourceAxisDir == eDirNeg)
10401055
value = -std::min(0.f, value);
1056+
else
1057+
if (line.SourceAxisDir == eDirNegToPos)
1058+
value = value * 0.5f + 0.5f;
10411059

10421060
if (line.OutputAxisDir == eDirNeg)
10431061
value = -value;
@@ -1575,6 +1593,8 @@ static string ToString(eDir value)
15751593
return "-";
15761594
if (value == eDirPos)
15771595
return "+";
1596+
if (value == eDirNegToPos)
1597+
return " ";
15781598
return "unknown";
15791599
}
15801600

0 commit comments

Comments
 (0)