Skip to content

Commit 382a355

Browse files
committed
Fixed problems when using a controller with more than 7 axes
1 parent 0a4e51a commit 382a355

File tree

1 file changed

+24
-16
lines changed

1 file changed

+24
-16
lines changed

Client/core/CJoystickManager.cpp

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -363,36 +363,44 @@ BOOL CJoystickManager::DoEnumObjectsCallback(const DIDEVICEOBJECTINSTANCE* pdido
363363
int axisIndex = -1;
364364

365365
if (pdidoi->guidType == GUID_XAxis)
366-
axisIndex = 0;
366+
axisIndex = eJoyX;
367367
if (pdidoi->guidType == GUID_YAxis)
368-
axisIndex = 1;
368+
axisIndex = eJoyY;
369369
if (pdidoi->guidType == GUID_ZAxis)
370-
axisIndex = 2;
370+
axisIndex = eJoyZ;
371371
if (pdidoi->guidType == GUID_RxAxis)
372-
axisIndex = 3;
372+
axisIndex = eJoyRx;
373373
if (pdidoi->guidType == GUID_RyAxis)
374-
axisIndex = 4;
374+
axisIndex = eJoyRy;
375375
if (pdidoi->guidType == GUID_RzAxis)
376-
axisIndex = 5;
376+
axisIndex = eJoyRz;
377377
if (pdidoi->guidType == GUID_Slider)
378-
axisIndex = 6;
378+
axisIndex = eJoyS1;
379379

380+
SString strStatus;
380381
// Save the range and the axis index
381382
if (axisIndex >= 0 && axisIndex < NUMELMS(m_DevInfo.axis) && range.lMin < range.lMax)
382383
{
383-
m_DevInfo.axis[axisIndex].lMin = range.lMin;
384-
m_DevInfo.axis[axisIndex].lMax = range.lMax;
385-
m_DevInfo.axis[axisIndex].bEnabled = true;
386-
m_DevInfo.axis[axisIndex].dwType = pdidoi->dwType;
387-
388-
m_DevInfo.iAxisCount++;
389-
WriteDebugEvent(
390-
SString(" Added axis index %d. lMin:%d lMax:%d (iAxisCount:%d)", axisIndex, range.lMin, range.lMax, m_DevInfo.iAxisCount));
384+
if (!m_DevInfo.axis[axisIndex].bEnabled)
385+
{
386+
m_DevInfo.axis[axisIndex].lMin = range.lMin;
387+
m_DevInfo.axis[axisIndex].lMax = range.lMax;
388+
m_DevInfo.axis[axisIndex].bEnabled = true;
389+
m_DevInfo.axis[axisIndex].dwType = pdidoi->dwType;
390+
391+
m_DevInfo.iAxisCount++;
392+
strStatus = SString("Added axis index %d. lMin:%d lMax:%d (iAxisCount:%d)", axisIndex, range.lMin, range.lMax, m_DevInfo.iAxisCount);
393+
}
394+
else
395+
{
396+
strStatus = SString("Ignoring duplicate axis index %d", axisIndex);
397+
}
391398
}
392399
else
393400
{
394-
WriteDebugEvent(SStringX(" Failed to recognise axis"));
401+
strStatus = "Failed to recognise axis";
395402
}
403+
WriteDebugEvent(" " + strStatus);
396404

397405
#ifdef MTA_DEBUG
398406
#if 0

0 commit comments

Comments
 (0)