[579] Add simulated input lag option (#1438)

* [579] Add simulated input lag option

* Continue to clear buffer when inputs are blocked

* Changes from feedback
This commit is contained in:
Garrett Cox 2022-09-19 21:49:13 -05:00 committed by GitHub
commit f712068a17
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 49 additions and 29 deletions

View file

@ -504,6 +504,11 @@ namespace GameMenuBar {
UIWidgets::EnhancementSliderFloat("Input Scale: %.1f", "##Input", "gInputScale", 1.0f, 3.0f, "", 1.0f, false);
UIWidgets::Tooltip("Sets the on screen size of the displayed inputs from the Show Inputs setting");
ImGui::PopItemWidth();
UIWidgets::Spacer(0);
ImGui::PushItemWidth(ImGui::GetWindowSize().x - 20.0f);
UIWidgets::EnhancementSliderInt("Simulated Input Lag: %d frames", "##SimulatedInputLag", "gSimulatedInputLag", 0, 6, "", 0, false);
UIWidgets::Tooltip("Buffers your inputs to be executed a specified amount of frames later");
ImGui::PopItemWidth();
ImGui::EndMenu();
}

View file

@ -483,10 +483,7 @@ static void RunFrame()
Graph_StartFrame();
// TODO: Workaround for rumble being too long. Implement os thread functions.
for (int i = 0; i < 3; i++) {
PadMgr_ThreadEntry(&gPadMgr);
}
PadMgr_ThreadEntry(&gPadMgr);
Graph_Update(&runFrameContext.gfxCtx, runFrameContext.gameState);
ticksB = GetPerfCounter();

View file

@ -331,16 +331,20 @@ void PadMgr_HandleRetraceMsg(PadMgr* padMgr) {
}
padMgr->validCtrlrsMask = mask;
/* if (gFaultStruct.msgId) {
PadMgr_RumbleStop(padMgr);
} else */ if (padMgr->rumbleOffFrames > 0) {
--padMgr->rumbleOffFrames;
PadMgr_RumbleStop(padMgr);
} else if (padMgr->rumbleOnFrames == 0) {
PadMgr_RumbleStop(padMgr);
} else if (!padMgr->preNMIShutdown) {
PadMgr_RumbleControl(padMgr);
--padMgr->rumbleOnFrames;
// TODO: Workaround for rumble being too long. Implement os thread functions.
// Game logic runs at 20hz but input thread runs at 60 hertz, so we call this 3 times
for (i = 0; i < 3; i++) {
/* if (gFaultStruct.msgId) {
PadMgr_RumbleStop(padMgr);
} else */ if (padMgr->rumbleOffFrames > 0) {
--padMgr->rumbleOffFrames;
PadMgr_RumbleStop(padMgr);
} else if (padMgr->rumbleOnFrames == 0) {
PadMgr_RumbleStop(padMgr);
} else if (!padMgr->preNMIShutdown) {
PadMgr_RumbleControl(padMgr);
--padMgr->rumbleOnFrames;
}
}
}