mirror of
https://github.com/RetroDECK/Supermodel.git
synced 2025-04-10 19:15:14 +00:00
Changes to input system:
- altered PrintSettings to output all settings for attached controls, even if no different to defaults - added option on calibration screen to detect an axis simply by moving the axis
This commit is contained in:
parent
c0dc0b83b6
commit
0528a4f0c6
|
@ -1037,24 +1037,10 @@ CInputSource *CInputSystem::ParseSingleSource(string str)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CInputSystem::PrintKeySettings(KeySettings *settings)
|
void CInputSystem::PrintKeySettings(int kbdNum, KeySettings *settings)
|
||||||
{
|
{
|
||||||
// Get common key settings and print header
|
printf(" Sensitivity = %d %%\n", settings->sensitivity);
|
||||||
KeySettings *common;
|
printf(" Decay Speed = %d %%\n", settings->decaySpeed);
|
||||||
if (settings->kbdNum == ANY_KEYBOARD)
|
|
||||||
{
|
|
||||||
puts("Common Keyboard Settings:");
|
|
||||||
common = NULL;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
printf("Keyboard %d Settings:\n", settings->kbdNum + 1);
|
|
||||||
common = GetKeySettings(ANY_KEYBOARD, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Print all common settings and any settings that are different to common settings
|
|
||||||
if (common == NULL || settings->sensitivity != common->sensitivity) printf(" Sensitivity = %d %%\n", settings->sensitivity);
|
|
||||||
if (common == NULL || settings->decaySpeed != common->decaySpeed) printf(" Decay Speed = %d %%\n", settings->decaySpeed);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
KeySettings *CInputSystem::ReadKeySettings(CINIFile *ini, const char *section, int kbdNum)
|
KeySettings *CInputSystem::ReadKeySettings(CINIFile *ini, const char *section, int kbdNum)
|
||||||
|
@ -1090,27 +1076,12 @@ void CInputSystem::WriteKeySettings(CINIFile *ini, const char *section, KeySetti
|
||||||
if (settings->decaySpeed != common->decaySpeed) ini->Set(section, baseKey + "DecaySpeed", settings->decaySpeed);
|
if (settings->decaySpeed != common->decaySpeed) ini->Set(section, baseKey + "DecaySpeed", settings->decaySpeed);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CInputSystem::PrintMouseSettings(MouseSettings *settings)
|
void CInputSystem::PrintMouseSettings(int mseNum, MouseSettings *settings)
|
||||||
{
|
{
|
||||||
// Get common mouse settings and print header
|
|
||||||
MouseSettings *common;
|
|
||||||
if (settings->mseNum == ANY_MOUSE)
|
|
||||||
{
|
|
||||||
puts("Common Mouse Settings:");
|
|
||||||
common = NULL;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
printf("Mouse %d Settings:\n", settings->mseNum + 1);
|
|
||||||
common = GetMouseSettings(ANY_MOUSE, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Print all common settings and any settings that are different to common/default settings
|
|
||||||
for (int axisNum = 0; axisNum < NUM_MOUSE_AXES; axisNum++)
|
for (int axisNum = 0; axisNum < NUM_MOUSE_AXES; axisNum++)
|
||||||
{
|
{
|
||||||
const char *axisName = s_axisNames[axisNum];
|
const char *axisName = s_axisNames[axisNum];
|
||||||
if (common == NULL || settings->deadZones[axisNum] != common->deadZones[axisNum])
|
printf(" %s-Axis Dead Zone = %d %%\n", axisName, settings->deadZones[axisNum]);
|
||||||
printf(" %s-Axis Dead Zone = %d %%\n", axisName, settings->deadZones[axisNum]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1154,35 +1125,19 @@ void CInputSystem::WriteMouseSettings(CINIFile *ini, const char *section, MouseS
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CInputSystem::PrintJoySettings(JoySettings *settings)
|
void CInputSystem::PrintJoySettings(int joyNum, JoySettings *settings)
|
||||||
{
|
{
|
||||||
// Get common mouse settings and print header
|
const JoyDetails *joyDetails = (joyNum != ANY_JOYSTICK ? GetJoyDetails(joyNum) : NULL);
|
||||||
JoySettings *common;
|
|
||||||
if (settings->joyNum == ANY_JOYSTICK)
|
|
||||||
{
|
|
||||||
puts("Common Joystick Settings:");
|
|
||||||
common = NULL;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
printf("Joystick %d Settings:\n", settings->joyNum + 1);
|
|
||||||
common = GetJoySettings(ANY_JOYSTICK, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Print all common settings and any settings that are different to common/default settings
|
|
||||||
for (int axisNum = 0; axisNum < NUM_JOY_AXES; axisNum++)
|
for (int axisNum = 0; axisNum < NUM_JOY_AXES; axisNum++)
|
||||||
{
|
{
|
||||||
|
if (joyDetails && !joyDetails->hasAxis[axisNum])
|
||||||
|
continue;
|
||||||
const char *axisName = s_axisNames[axisNum];
|
const char *axisName = s_axisNames[axisNum];
|
||||||
if (common == NULL || settings->axisMinVals[axisNum] != common->axisMinVals[axisNum])
|
printf(" %-2s-Axis Min Value = %d\n", axisName, settings->axisMinVals[axisNum]);
|
||||||
printf(" %-2s-Axis Min Value = %d\n", axisName, settings->axisMinVals[axisNum]);
|
printf(" %-2s-Axis Center/Off Value = %d\n", axisName, settings->axisOffVals[axisNum]);
|
||||||
if (common == NULL || settings->axisOffVals[axisNum] != common->axisOffVals[axisNum])
|
printf(" %-2s-Axis Max Value = %d\n", axisName, settings->axisMaxVals[axisNum]);
|
||||||
printf(" %-2s-Axis Center/Off Value = %d\n", axisName, settings->axisOffVals[axisNum]);
|
printf(" %-2s-Axis Dead Zone = %d %%\n", axisName, settings->deadZones[axisNum]);
|
||||||
if (common == NULL || settings->axisMaxVals[axisNum] != common->axisMaxVals[axisNum])
|
printf(" %-2s-Axis Saturation = %d %%\n", axisName, settings->saturations[axisNum]);
|
||||||
printf(" %-2s-Axis Max Value = %d\n", axisName, settings->axisMaxVals[axisNum]);
|
|
||||||
if (common == NULL || settings->deadZones[axisNum] != common->deadZones[axisNum])
|
|
||||||
printf(" %-2s-Axis Dead Zone = %d %%\n", axisName, settings->deadZones[axisNum]);
|
|
||||||
if (common == NULL || settings->saturations[axisNum] != common->saturations[axisNum])
|
|
||||||
printf(" %-2s-Axis Saturation = %d %%\n", axisName, settings->saturations[axisNum]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1588,33 +1543,57 @@ void CInputSystem::PrintSettings()
|
||||||
puts("");
|
puts("");
|
||||||
|
|
||||||
// Print all key settings for attached keyboards
|
// Print all key settings for attached keyboards
|
||||||
KeySettings *keySettings = GetKeySettings(ANY_KEYBOARD, true);
|
KeySettings *keySettings;
|
||||||
PrintKeySettings(keySettings);
|
if (m_numKbds == ANY_KEYBOARD)
|
||||||
for (int kbdNum = 0; kbdNum < m_numKbds; kbdNum++)
|
|
||||||
{
|
{
|
||||||
keySettings = GetKeySettings(kbdNum, false);
|
puts("Common Keyboard Settings:");
|
||||||
if (keySettings != NULL)
|
keySettings = GetKeySettings(ANY_KEYBOARD, true);
|
||||||
PrintKeySettings(keySettings);
|
PrintKeySettings(ANY_KEYBOARD, keySettings);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (int kbdNum = 0; kbdNum < m_numKbds; kbdNum++)
|
||||||
|
{
|
||||||
|
printf("Keyboard %d Settings:\n", kbdNum + 1);
|
||||||
|
keySettings = GetKeySettings(kbdNum, true);
|
||||||
|
PrintKeySettings(kbdNum, keySettings);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Print all mouse settings for attached mice
|
// Print all mouse settings for attached mice
|
||||||
MouseSettings *mseSettings = GetMouseSettings(ANY_MOUSE, true);
|
MouseSettings *mseSettings;
|
||||||
PrintMouseSettings(mseSettings);
|
if (m_numMice == ANY_MOUSE)
|
||||||
for (int mseNum = 0; mseNum < m_numMice; mseNum++)
|
|
||||||
{
|
{
|
||||||
mseSettings = GetMouseSettings(mseNum, false);
|
puts("Common Mouse Settings:");
|
||||||
if (mseSettings != NULL)
|
mseSettings = GetMouseSettings(ANY_MOUSE, true);
|
||||||
PrintMouseSettings(mseSettings);
|
PrintMouseSettings(ANY_MOUSE, mseSettings);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (int mseNum = 0; mseNum < m_numMice; mseNum++)
|
||||||
|
{
|
||||||
|
printf("Mouse %d Settings:\n", mseNum + 1);
|
||||||
|
mseSettings = GetMouseSettings(mseNum, true);
|
||||||
|
PrintMouseSettings(mseNum, mseSettings);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Print all joystick settings for attached joysticks
|
// Print all joystick settings for attached joysticks
|
||||||
JoySettings *joySettings = GetJoySettings(ANY_JOYSTICK, true);
|
JoySettings *joySettings;
|
||||||
PrintJoySettings(joySettings);
|
if (m_numJoys == ANY_JOYSTICK)
|
||||||
for (int joyNum = 0; joyNum < m_numJoys; joyNum++)
|
|
||||||
{
|
{
|
||||||
joySettings = GetJoySettings(joyNum, false);
|
puts("Common Joystick Settings:");
|
||||||
if (joySettings != NULL)
|
joySettings = GetJoySettings(ANY_JOYSTICK, true);
|
||||||
PrintJoySettings(joySettings);
|
PrintJoySettings(ANY_JOYSTICK, joySettings);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (int joyNum = 0; joyNum < m_numJoys; joyNum++)
|
||||||
|
{
|
||||||
|
printf("Joystick %d Settings:\n", joyNum + 1);
|
||||||
|
joySettings = GetJoySettings(joyNum, true);
|
||||||
|
PrintJoySettings(joyNum, joySettings);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
puts("");
|
puts("");
|
||||||
|
@ -1677,6 +1656,7 @@ void CInputSystem::WriteToINIFile(CINIFile *ini, const char *section)
|
||||||
bool CInputSystem::ReadMapping(char *buffer, unsigned bufSize, bool fullAxisOnly, unsigned readFlags, const char *escapeMapping)
|
bool CInputSystem::ReadMapping(char *buffer, unsigned bufSize, bool fullAxisOnly, unsigned readFlags, const char *escapeMapping)
|
||||||
{
|
{
|
||||||
// Map given escape mapping to an input source
|
// Map given escape mapping to an input source
|
||||||
|
bool cancelled = false;
|
||||||
CInputSource *escape = ParseSource(escapeMapping);
|
CInputSource *escape = ParseSource(escapeMapping);
|
||||||
if (escape)
|
if (escape)
|
||||||
escape->Acquire();
|
escape->Acquire();
|
||||||
|
@ -1686,15 +1666,11 @@ bool CInputSystem::ReadMapping(char *buffer, unsigned bufSize, bool fullAxisOnly
|
||||||
vector<CInputSource*> badSources;
|
vector<CInputSource*> badSources;
|
||||||
vector<CInputSource*> sources;
|
vector<CInputSource*> sources;
|
||||||
bool mseCentered = false;
|
bool mseCentered = false;
|
||||||
bool cancelled = false;
|
|
||||||
|
|
||||||
// See which sources activated to begin with and from here on ignore these (this stops badly calibrated axes that are constantly "active"
|
// See which sources activated to begin with and from here on ignore these (this stops badly calibrated axes that are constantly "active"
|
||||||
// from preventing the user from exiting read loop)
|
// from preventing the user from exiting read loop)
|
||||||
if (!Poll())
|
if (!Poll())
|
||||||
{
|
goto Cancelled;
|
||||||
cancelled = true;
|
|
||||||
goto Finish;
|
|
||||||
}
|
|
||||||
|
|
||||||
CheckAllSources(readFlags, fullAxisOnly, mseCentered, badSources, badMapping, sources);
|
CheckAllSources(readFlags, fullAxisOnly, mseCentered, badSources, badMapping, sources);
|
||||||
|
|
||||||
|
@ -1703,10 +1679,7 @@ bool CInputSystem::ReadMapping(char *buffer, unsigned bufSize, bool fullAxisOnly
|
||||||
{
|
{
|
||||||
// Poll inputs
|
// Poll inputs
|
||||||
if (!Poll())
|
if (!Poll())
|
||||||
{
|
goto Cancelled;
|
||||||
cancelled = true;
|
|
||||||
goto Finish;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if escape source was triggered
|
// Check if escape source was triggered
|
||||||
if (escape && escape->IsActive())
|
if (escape && escape->IsActive())
|
||||||
|
@ -1715,14 +1688,10 @@ bool CInputSystem::ReadMapping(char *buffer, unsigned bufSize, bool fullAxisOnly
|
||||||
while (escape->IsActive())
|
while (escape->IsActive())
|
||||||
{
|
{
|
||||||
if (!Poll())
|
if (!Poll())
|
||||||
{
|
goto Cancelled;
|
||||||
cancelled = true;
|
|
||||||
goto Finish;
|
|
||||||
}
|
|
||||||
Wait(1000/60);
|
Wait(1000/60);
|
||||||
}
|
}
|
||||||
cancelled = true;
|
goto Cancelled;
|
||||||
goto Finish;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check all active sources
|
// Check all active sources
|
||||||
|
@ -1761,7 +1730,11 @@ bool CInputSystem::ReadMapping(char *buffer, unsigned bufSize, bool fullAxisOnly
|
||||||
// Copy mapping to buffer and return
|
// Copy mapping to buffer and return
|
||||||
strncpy(buffer, mapping.c_str(), bufSize - 1);
|
strncpy(buffer, mapping.c_str(), bufSize - 1);
|
||||||
buffer[bufSize - 1] = '\0';
|
buffer[bufSize - 1] = '\0';
|
||||||
|
goto Finish;
|
||||||
|
|
||||||
|
Cancelled:
|
||||||
|
cancelled = true;
|
||||||
|
|
||||||
Finish:
|
Finish:
|
||||||
if (escape)
|
if (escape)
|
||||||
escape->Release();
|
escape->Release();
|
||||||
|
@ -1789,16 +1762,126 @@ bool CInputSystem::SendForceFeedbackCmd(int joyNum, int axisNum, ForceFeedbackCm
|
||||||
return ProcessForceFeedbackCmd(joyNum, axisNum, ffCmd);
|
return ProcessForceFeedbackCmd(joyNum, axisNum, ffCmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CInputSystem::DetectJoystickAxis(unsigned joyNum, unsigned &axisNum, const char *escapeMapping, const char *confirmMapping)
|
||||||
|
{
|
||||||
|
const JoyDetails *joyDetails = GetJoyDetails(joyNum);
|
||||||
|
if (joyDetails == NULL)
|
||||||
|
{
|
||||||
|
puts("No such joystick!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Map given escape & confirm mappings to input sources
|
||||||
|
bool cancelled = false;
|
||||||
|
CInputSource *escape = ParseSource(escapeMapping);
|
||||||
|
CInputSource *confirm = ParseSource(confirmMapping);
|
||||||
|
if (escape)
|
||||||
|
escape->Acquire();
|
||||||
|
if (confirm)
|
||||||
|
confirm->Acquire();
|
||||||
|
|
||||||
|
printf("Move axis around and then press Return (or press Esc to cancel): ");
|
||||||
|
|
||||||
|
int minVals[NUM_JOY_AXES];
|
||||||
|
int maxVals[NUM_JOY_AXES];
|
||||||
|
for (unsigned loopAxisNum = 0; loopAxisNum < NUM_JOY_AXES; loopAxisNum++)
|
||||||
|
{
|
||||||
|
if (!joyDetails->hasAxis[loopAxisNum])
|
||||||
|
continue;
|
||||||
|
int joyVal = GetJoyAxisValue(joyNum, loopAxisNum);
|
||||||
|
minVals[loopAxisNum] = joyVal;
|
||||||
|
maxVals[loopAxisNum] = joyVal;
|
||||||
|
}
|
||||||
|
for (;;)
|
||||||
|
{
|
||||||
|
if (!Poll())
|
||||||
|
goto Cancelled;
|
||||||
|
|
||||||
|
// Check if escape source was triggered
|
||||||
|
if (escape && escape->IsActive())
|
||||||
|
{
|
||||||
|
// If so, wait until source no longer active and then exit
|
||||||
|
while (escape->IsActive())
|
||||||
|
{
|
||||||
|
if (!Poll())
|
||||||
|
goto Cancelled;
|
||||||
|
Wait(1000/60);
|
||||||
|
}
|
||||||
|
goto Cancelled;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if confirm source was triggered
|
||||||
|
if (confirm && confirm->IsActive())
|
||||||
|
{
|
||||||
|
// If so, wait until source no longer active and then exit
|
||||||
|
while (confirm->IsActive())
|
||||||
|
{
|
||||||
|
if (!Poll())
|
||||||
|
goto Cancelled;
|
||||||
|
Wait(1000/60);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (unsigned loopAxisNum = 0; loopAxisNum < NUM_JOY_AXES; loopAxisNum++)
|
||||||
|
{
|
||||||
|
if (!joyDetails->hasAxis[loopAxisNum])
|
||||||
|
continue;
|
||||||
|
int joyVal = GetJoyAxisValue(joyNum, loopAxisNum);
|
||||||
|
minVals[loopAxisNum] = min<int>(joyVal, minVals[loopAxisNum]);
|
||||||
|
maxVals[loopAxisNum] = max<int>(joyVal, maxVals[loopAxisNum]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Don't poll continuously
|
||||||
|
Wait(1000/60);
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned maxRange = 0;
|
||||||
|
unsigned maxAxisNum = 0;
|
||||||
|
for (unsigned loopAxisNum = 0; loopAxisNum < NUM_JOY_AXES; loopAxisNum++)
|
||||||
|
{
|
||||||
|
if (!joyDetails->hasAxis[loopAxisNum])
|
||||||
|
continue;
|
||||||
|
unsigned range = maxVals[loopAxisNum] - minVals[loopAxisNum];
|
||||||
|
if (range > maxRange)
|
||||||
|
{
|
||||||
|
maxRange = range;
|
||||||
|
axisNum = loopAxisNum;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (maxRange > 3000)
|
||||||
|
printf("Detected\n", joyDetails->axisName[axisNum]);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cancelled = true;
|
||||||
|
puts("Not Detected");
|
||||||
|
}
|
||||||
|
goto Finish;
|
||||||
|
|
||||||
|
Cancelled:
|
||||||
|
puts("[Cancelled]");
|
||||||
|
cancelled = true;
|
||||||
|
|
||||||
|
Finish:
|
||||||
|
if (escape)
|
||||||
|
escape->Release();
|
||||||
|
if (confirm)
|
||||||
|
confirm->Release();
|
||||||
|
return !cancelled;
|
||||||
|
}
|
||||||
|
|
||||||
bool CInputSystem::CalibrateJoystickAxis(unsigned joyNum, unsigned axisNum, const char *escapeMapping, const char *confirmMapping)
|
bool CInputSystem::CalibrateJoystickAxis(unsigned joyNum, unsigned axisNum, const char *escapeMapping, const char *confirmMapping)
|
||||||
{
|
{
|
||||||
const JoyDetails *joyDetails = GetJoyDetails(joyNum);
|
const JoyDetails *joyDetails = GetJoyDetails(joyNum);
|
||||||
if (joyDetails == NULL || axisNum >= NUM_JOY_AXES || !joyDetails->hasAxis[axisNum])
|
if (joyDetails == NULL || axisNum >= NUM_JOY_AXES || !joyDetails->hasAxis[axisNum])
|
||||||
{
|
{
|
||||||
printf("No such axis or joystick");
|
puts("No such axis or joystick!");
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Map given escape mapping to input source
|
// Map given escape mapping to input source
|
||||||
|
bool cancelled = false;
|
||||||
CInputSource *escape = ParseSource(escapeMapping);
|
CInputSource *escape = ParseSource(escapeMapping);
|
||||||
CInputSource *output = ParseSource("KEY_SHIFT");
|
CInputSource *output = ParseSource("KEY_SHIFT");
|
||||||
if (escape)
|
if (escape)
|
||||||
|
@ -1822,7 +1905,6 @@ Repeat:
|
||||||
unsigned posOffRange;
|
unsigned posOffRange;
|
||||||
unsigned negOffRange;
|
unsigned negOffRange;
|
||||||
char mapping[50];
|
char mapping[50];
|
||||||
bool cancelled = false;
|
|
||||||
for (unsigned step = 0; step < 3; step++)
|
for (unsigned step = 0; step < 3; step++)
|
||||||
{
|
{
|
||||||
switch (step)
|
switch (step)
|
||||||
|
@ -1831,9 +1913,9 @@ Repeat:
|
||||||
puts("Step 1:");
|
puts("Step 1:");
|
||||||
puts(" Move axis now to its furthest positive/'on' position and hold, ie:");
|
puts(" Move axis now to its furthest positive/'on' position and hold, ie:");
|
||||||
if (axisNum == AXIS_X || axisNum == AXIS_RX || axisNum == AXIS_Z || axisNum == AXIS_RZ)
|
if (axisNum == AXIS_X || axisNum == AXIS_RX || axisNum == AXIS_Z || axisNum == AXIS_RZ)
|
||||||
puts(" - for a joystick X-Axis, push it all the way to the right.");
|
puts(" - for a horizontal joystick axis, push it all the way to the right.");
|
||||||
if (axisNum == AXIS_Y || axisNum == AXIS_RY || axisNum == AXIS_Z || axisNum == AXIS_RZ)
|
if (axisNum == AXIS_Y || axisNum == AXIS_RY || axisNum == AXIS_Z || axisNum == AXIS_RZ)
|
||||||
puts(" - for a joystick Y-Axis, push it all the way downwards.");
|
puts(" - for a vertical joystick axis, push it all the way downwards.");
|
||||||
puts(" - for a steering wheel, turn it all the way to the right.");
|
puts(" - for a steering wheel, turn it all the way to the right.");
|
||||||
puts(" - for a pedal, press it all the way to the floor.");
|
puts(" - for a pedal, press it all the way to the floor.");
|
||||||
break;
|
break;
|
||||||
|
@ -1841,31 +1923,29 @@ Repeat:
|
||||||
puts("Step 2:");
|
puts("Step 2:");
|
||||||
puts(" Move axis the other way to its furthest negative position and hold, ie:");
|
puts(" Move axis the other way to its furthest negative position and hold, ie:");
|
||||||
if (axisNum == AXIS_X || axisNum == AXIS_RX || axisNum == AXIS_Z || axisNum == AXIS_RZ)
|
if (axisNum == AXIS_X || axisNum == AXIS_RX || axisNum == AXIS_Z || axisNum == AXIS_RZ)
|
||||||
puts(" - for a joystick X-Axis, push it all the way to the left.");
|
puts(" - for a horizontal joystick axis, push it all the way to the left.");
|
||||||
if (axisNum == AXIS_Y || axisNum == AXIS_RY || axisNum == AXIS_Z || axisNum == AXIS_RZ)
|
if (axisNum == AXIS_Y || axisNum == AXIS_RY || axisNum == AXIS_Z || axisNum == AXIS_RZ)
|
||||||
puts(" - for a joystick Y-Axis, push it all the way updwards.");
|
puts(" - for a vertical joystick axis, push it all the way updwards.");
|
||||||
puts(" - for a steering wheel, turn it all the way to the left.");
|
puts(" - for a steering wheel, turn it all the way to the left.");
|
||||||
puts(" - for a pedal, let go of the pedal completely. If there is another pedal");
|
puts(" - for a pedal, let go of the pedal completely. If there is another pedal");
|
||||||
puts(" that shares the same axis then press that one all the way to the floor.");
|
puts(" that shares the same axis then press that one all the way to the floor.");
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
puts("Step 3:");
|
puts("Step 3:");
|
||||||
puts(" Return axis to its center/'off' position and hold, ie:");
|
puts(" Return axis to its central/'off' position and hold, ie:");
|
||||||
puts(" - for a joystick axis, let it return to the middle.");
|
puts(" - for a joystick axis, let it return to the middle.");
|
||||||
puts(" - for a steering weel, turn it back to its central position.");
|
puts(" - for a steering weel, turn it back to the center.");
|
||||||
puts(" - for a pedal, let go of all pedals completely.");
|
puts(" - for a pedal, let go of pedal completely. Likewise for any other pedal");
|
||||||
|
puts(" that shares the same axis.");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
printf("\nPress Return when ready (or press Esc to cancel): ");
|
printf("\nPress Return when done (or press Esc to cancel): ");
|
||||||
|
|
||||||
// Loop until user confirms or aborts
|
// Loop until user confirms or aborts
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
if (!ReadMapping(mapping, 50, false, READ_KEYBOARD|READ_MERGE, escapeMapping))
|
if (!ReadMapping(mapping, 50, false, READ_KEYBOARD|READ_MERGE, escapeMapping))
|
||||||
{
|
goto Cancelled;
|
||||||
cancelled = true;
|
|
||||||
goto Finish;
|
|
||||||
}
|
|
||||||
if (stricmp(mapping, confirmMapping) == 0)
|
if (stricmp(mapping, confirmMapping) == 0)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1880,10 +1960,7 @@ Repeat:
|
||||||
for (unsigned frames = 0; frames < 3 * 60; frames++)
|
for (unsigned frames = 0; frames < 3 * 60; frames++)
|
||||||
{
|
{
|
||||||
if (!Poll())
|
if (!Poll())
|
||||||
{
|
goto Cancelled;
|
||||||
cancelled = true;
|
|
||||||
goto Finish;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if escape source was triggered
|
// Check if escape source was triggered
|
||||||
if (escape && escape->IsActive())
|
if (escape && escape->IsActive())
|
||||||
|
@ -1892,14 +1969,10 @@ Repeat:
|
||||||
while (escape->IsActive())
|
while (escape->IsActive())
|
||||||
{
|
{
|
||||||
if (!Poll())
|
if (!Poll())
|
||||||
{
|
goto Cancelled;
|
||||||
cancelled = true;
|
|
||||||
goto Finish;
|
|
||||||
}
|
|
||||||
Wait(1000/60);
|
Wait(1000/60);
|
||||||
}
|
}
|
||||||
cancelled = true;
|
goto Cancelled;
|
||||||
goto Finish;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
joyVal = GetJoyAxisValue(joyNum, axisNum);
|
joyVal = GetJoyAxisValue(joyNum, axisNum);
|
||||||
|
@ -1907,7 +1980,7 @@ Repeat:
|
||||||
maxVal = max<int>(maxVal, joyVal);
|
maxVal = max<int>(maxVal, joyVal);
|
||||||
|
|
||||||
// Check if output source is triggered, and if so output value for debugging
|
// Check if output source is triggered, and if so output value for debugging
|
||||||
if (output != NULL && output->IsActive())
|
if (output && output->IsActive())
|
||||||
{
|
{
|
||||||
if (firstOut)
|
if (firstOut)
|
||||||
puts("");
|
puts("");
|
||||||
|
@ -1988,7 +2061,7 @@ Repeat:
|
||||||
goto Finish;
|
goto Finish;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cancelled = true;
|
goto Cancelled;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -2007,12 +2080,14 @@ Repeat:
|
||||||
goto Repeat;
|
goto Repeat;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cancelled = true;
|
goto Cancelled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Cancelled:
|
||||||
|
puts("[Cancelled]");
|
||||||
|
cancelled = true;
|
||||||
|
|
||||||
Finish:
|
Finish:
|
||||||
if (cancelled)
|
|
||||||
puts("[Cancelled]");
|
|
||||||
if (escape)
|
if (escape)
|
||||||
escape->Release();
|
escape->Release();
|
||||||
if (output)
|
if (output)
|
||||||
|
|
|
@ -461,7 +461,7 @@ private:
|
||||||
/*
|
/*
|
||||||
* Prints the given key settings to stdout.
|
* Prints the given key settings to stdout.
|
||||||
*/
|
*/
|
||||||
void PrintKeySettings(KeySettings *settings);
|
void PrintKeySettings(int kbdNum, KeySettings *settings);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Reads key settings from an INI file for the given keyboard number, or common settings if ANY_KEYBOARD specified.
|
* Reads key settings from an INI file for the given keyboard number, or common settings if ANY_KEYBOARD specified.
|
||||||
|
@ -477,7 +477,7 @@ private:
|
||||||
/*
|
/*
|
||||||
* Prints the given mouse settings to stdout.
|
* Prints the given mouse settings to stdout.
|
||||||
*/
|
*/
|
||||||
void PrintMouseSettings(MouseSettings *settings);
|
void PrintMouseSettings(int mseNum, MouseSettings *settings);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Reads mouse settings from an INI file for the given mouse number, or common settings if ANY_MOUSE specified.
|
* Reads mouse settings from an INI file for the given mouse number, or common settings if ANY_MOUSE specified.
|
||||||
|
@ -493,7 +493,7 @@ private:
|
||||||
/*
|
/*
|
||||||
* Prints the given joystick settings to stdout.
|
* Prints the given joystick settings to stdout.
|
||||||
*/
|
*/
|
||||||
void PrintJoySettings(JoySettings *settings);
|
void PrintJoySettings(int joyNum, JoySettings *settings);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Reads joystick settings from an INI file for the given joystick number, or common settings if ANY_JOYSTICK specified.
|
* Reads joystick settings from an INI file for the given joystick number, or common settings if ANY_JOYSTICK specified.
|
||||||
|
@ -843,6 +843,8 @@ public:
|
||||||
|
|
||||||
virtual bool SendForceFeedbackCmd(int joyNum, int axisNum, ForceFeedbackCmd ffCmd);
|
virtual bool SendForceFeedbackCmd(int joyNum, int axisNum, ForceFeedbackCmd ffCmd);
|
||||||
|
|
||||||
|
bool DetectJoystickAxis(unsigned joyNum, unsigned &axisNum, const char *escapeMapping = "KEY_ESCAPE", const char *confirmMapping = "KEY_RETURN");
|
||||||
|
|
||||||
bool CalibrateJoystickAxis(unsigned joyNum, unsigned axisNum, const char *escapeMapping = "KEY_ESCAPE", const char *confirmMapping = "KEY_RETURN");
|
bool CalibrateJoystickAxis(unsigned joyNum, unsigned axisNum, const char *escapeMapping = "KEY_ESCAPE", const char *confirmMapping = "KEY_RETURN");
|
||||||
|
|
||||||
void PrintDevices();
|
void PrintDevices();
|
||||||
|
|
|
@ -441,7 +441,7 @@ Redisplay:
|
||||||
else if (stricmp(mapping, "KEY_A") == 0)
|
else if (stricmp(mapping, "KEY_A") == 0)
|
||||||
{
|
{
|
||||||
// Append to the input mapping(s)
|
// Append to the input mapping(s)
|
||||||
printf("Appending...");
|
printf("Appending... ");
|
||||||
fflush(stdout); // required on terminals that use buffering
|
fflush(stdout); // required on terminals that use buffering
|
||||||
if (input->Configure(true, uiExit->GetMapping()))
|
if (input->Configure(true, uiExit->GetMapping()))
|
||||||
puts(input->GetMapping());
|
puts(input->GetMapping());
|
||||||
|
@ -570,7 +570,7 @@ void CInputs::CalibrateJoystick(int joyNum)
|
||||||
const JoyDetails *joyDetails = m_system->GetJoyDetails(joyNum);
|
const JoyDetails *joyDetails = m_system->GetJoyDetails(joyNum);
|
||||||
if (joyDetails == NULL || joyDetails->numAxes == 0)
|
if (joyDetails == NULL || joyDetails->numAxes == 0)
|
||||||
{
|
{
|
||||||
printf("No axes available to calibrate on joystick!");
|
puts("No axes available to calibrate on joystick!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -585,19 +585,30 @@ void CInputs::CalibrateJoystick(int joyNum)
|
||||||
axisNumList.push_back(axisNum);
|
axisNumList.push_back(axisNum);
|
||||||
printf(" %u: %s\n", axisNumList.size(), joyDetails->axisName[axisNum]);
|
printf(" %u: %s\n", axisNumList.size(), joyDetails->axisName[axisNum]);
|
||||||
}
|
}
|
||||||
|
printf(" 0: Unsure - help me choose...\n");
|
||||||
|
|
||||||
char mapping[50];
|
char mapping[50];
|
||||||
while (m_system->ReadMapping(mapping, 50, false, READ_KEYBOARD|READ_MERGE, uiExit->GetMapping()))
|
while (m_system->ReadMapping(mapping, 50, false, READ_KEYBOARD|READ_MERGE, uiExit->GetMapping()))
|
||||||
{
|
{
|
||||||
if (strlen(mapping) != 5 || strncmp(mapping, "KEY_", 4) != 0)
|
unsigned axisNum;
|
||||||
continue;
|
if (stricmp(mapping, "KEY_0") == 0)
|
||||||
char c = mapping[4];
|
{
|
||||||
if (!isdigit(c))
|
puts("");
|
||||||
continue;
|
if (!m_system->DetectJoystickAxis(joyNum, axisNum))
|
||||||
unsigned optNum = c - '0';
|
return;
|
||||||
if (optNum == 0 || optNum > axisNumList.size())
|
}
|
||||||
continue;
|
else
|
||||||
unsigned axisNum = axisNumList[optNum - 1];
|
{
|
||||||
|
if (strlen(mapping) != 5 || strncmp(mapping, "KEY_", 4) != 0)
|
||||||
|
continue;
|
||||||
|
char c = mapping[4];
|
||||||
|
if (!isdigit(c))
|
||||||
|
continue;
|
||||||
|
unsigned optNum = c - '0';
|
||||||
|
if (optNum == 0 || optNum > axisNumList.size())
|
||||||
|
continue;
|
||||||
|
axisNum = axisNumList[optNum - 1];
|
||||||
|
}
|
||||||
puts("");
|
puts("");
|
||||||
if (m_system->CalibrateJoystickAxis(joyNum, axisNum))
|
if (m_system->CalibrateJoystickAxis(joyNum, axisNum))
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue