Fix XInput hotplug

This commit is contained in:
erorcun 2021-02-12 19:50:26 +03:00
parent a44d7d86cb
commit 6689b0be02
2 changed files with 10 additions and 5 deletions

View File

@ -333,11 +333,8 @@ wchar* DetectJoystickDraw(bool* disabled, bool userHovering) {
}
}
if (found != -1 && CPad::XInputJoy1 != found) {
if (CPad::XInputJoy1 != -1 && CPad::XInputJoy1 != found)
CPad::XInputJoy2 = CPad::XInputJoy1;
else
CPad::XInputJoy2 = -1;
// We should never leave pads -1, so we can process them when they're connected and kinda support hotplug.
CPad::XInputJoy2 = (CPad::XInputJoy1 == -1 ? (found + 1) % 4 : CPad::XInputJoy1);
CPad::XInputJoy1 = found;
cachedButtonNum = 0; // fake too, because xinput bypass CControllerConfig
}

View File

@ -336,6 +336,14 @@ void LoadINIControllerSettings()
CPad::XInputJoy2 = i;
}
}
// There is no plug event on XInput, so let's leave XInputJoy1/2 as 0/1 respectively, and hotplug will be possible.
if (CPad::XInputJoy1 == -1) {
CPad::XInputJoy1 = 0;
CPad::XInputJoy2 = 1;
} else if (CPad::XInputJoy2 == -1) {
CPad::XInputJoy2 = (CPad::XInputJoy1 + 1) % 4;
}
}
#else
ReadIniIfExists("Controller", "JoystickName", gSelectedJoystickName, 128);