mirror of
https://github.com/mkxp-z/mkxp-z.git
synced 2025-03-28 14:56:22 +01:00
update Input.repeat
timing on each Graphics.update
Instead of updating the `Input.repeat?` frame timing every time `Graphics.frame_rate=` is called, automatically set it to the current average framerate (or close to it)
This commit is contained in:
parent
b1065a5533
commit
c9378cfaba
1 changed files with 10 additions and 1 deletions
|
@ -1152,6 +1152,15 @@ void Graphics::update(bool checkForShutdown) {
|
|||
p->threadData->rqWindowAdjust.wait();
|
||||
p->last_update = shState->runTime();
|
||||
|
||||
// update Input.repeat timing, rounding the framerate to the nearest 2
|
||||
{
|
||||
static const double mult = 2.0;
|
||||
double afr = std::abs(averageFrameRate()); // abs shouldn't be necessary but that's ok
|
||||
afr += mult / 2;
|
||||
afr -= std::fmod(afr, mult);
|
||||
shState->input().recalcRepeat(std::floor(afr));
|
||||
}
|
||||
|
||||
if (checkForShutdown)
|
||||
p->checkShutDownReset();
|
||||
|
||||
|
@ -1315,7 +1324,7 @@ void Graphics::setFrameRate(int value) {
|
|||
return;
|
||||
|
||||
p->fpsLimiter.setDesiredFPS(p->frameRate);
|
||||
shState->input().recalcRepeat((unsigned int)p->frameRate);
|
||||
//shState->input().recalcRepeat((unsigned int)p->frameRate);
|
||||
}
|
||||
|
||||
double Graphics::averageFrameRate() {
|
||||
|
|
Loading…
Add table
Reference in a new issue