Allow XInput joysticks to work while the game is unfocused
This commit is contained in:
parent
01e7859e1f
commit
1655f7e3b7
10 changed files with 114 additions and 6 deletions
|
|
@ -120,16 +120,30 @@ bool M_LoadJoystickConfig(IJoystickConfig *joy)
|
|||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
assert(GameConfig);
|
||||
|
||||
value = GameConfig->GetValueForKey("Enabled");
|
||||
if (value != NULL)
|
||||
if (value)
|
||||
{
|
||||
joy->SetEnabled((bool)atoi(value));
|
||||
}
|
||||
|
||||
if(joy->AllowsEnabledInBackground())
|
||||
{
|
||||
value = GameConfig->GetValueForKey("EnabledInBackground");
|
||||
if (value)
|
||||
{
|
||||
joy->SetEnabledInBackground((bool)atoi(value));
|
||||
}
|
||||
}
|
||||
|
||||
value = GameConfig->GetValueForKey("Sensitivity");
|
||||
if (value != NULL)
|
||||
if (value)
|
||||
{
|
||||
joy->SetSensitivity((float)atof(value));
|
||||
}
|
||||
|
||||
numaxes = joy->GetNumAxes();
|
||||
for (int i = 0; i < numaxes; ++i)
|
||||
{
|
||||
|
|
@ -137,21 +151,21 @@ bool M_LoadJoystickConfig(IJoystickConfig *joy)
|
|||
|
||||
mysnprintf(key + axislen, countof(key) - axislen, "deadzone");
|
||||
value = GameConfig->GetValueForKey(key);
|
||||
if (value != NULL)
|
||||
if (value)
|
||||
{
|
||||
joy->SetAxisDeadZone(i, (float)atof(value));
|
||||
}
|
||||
|
||||
mysnprintf(key + axislen, countof(key) - axislen, "scale");
|
||||
value = GameConfig->GetValueForKey(key);
|
||||
if (value != NULL)
|
||||
if (value)
|
||||
{
|
||||
joy->SetAxisScale(i, (float)atof(value));
|
||||
}
|
||||
|
||||
mysnprintf(key + axislen, countof(key) - axislen, "map");
|
||||
value = GameConfig->GetValueForKey(key);
|
||||
if (value != NULL)
|
||||
if (value)
|
||||
{
|
||||
EJoyAxis gameaxis = (EJoyAxis)atoi(value);
|
||||
if (gameaxis < JOYAXIS_None || gameaxis >= NUM_JOYAXIS)
|
||||
|
|
@ -185,6 +199,12 @@ void M_SaveJoystickConfig(IJoystickConfig *joy)
|
|||
{
|
||||
GameConfig->SetValueForKey("Enabled", "0");
|
||||
}
|
||||
|
||||
if (!joy->AllowsEnabledInBackground() && joy->GetEnabledInBackground())
|
||||
{
|
||||
GameConfig->SetValueForKey("EnabledInBackground", "1");
|
||||
}
|
||||
|
||||
if (!joy->IsSensitivityDefault())
|
||||
{
|
||||
mysnprintf(value, countof(value), "%g", joy->GetSensitivity());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue