Skip to content

Commit 1e47481

Browse files
committed
Fix speed settings
1 parent 7bf23d1 commit 1e47481

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

libretro/libretro.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "ppsspp_config.h"
2+
#include <algorithm>
23
#include <cstring>
34
#include <cassert>
45
#include <thread>
@@ -477,12 +478,39 @@ static std::string map_psp_language_to_i18n_locale(int val)
477478
}
478479

479480
static void check_dynamic_variables(CoreParameter &coreParam) {
481+
#ifdef __EMSCRIPTEN__
482+
struct retro_throttle_state throttle = { RETRO_THROTTLE_NONE, 0.0f };
483+
if (environ_cb(RETRO_ENVIRONMENT_GET_THROTTLE_STATE, &throttle)) {
484+
switch (throttle.mode) {
485+
case RETRO_THROTTLE_FAST_FORWARD:
486+
if (throttle.rate > 0.0f) {
487+
coreParam.fpsLimit = FPSLimit::ANALOG;
488+
coreParam.analogFpsLimit = (int)(throttle.rate + 0.5f);
489+
coreParam.fastForward = false;
490+
} else {
491+
coreParam.fpsLimit = FPSLimit::NORMAL;
492+
coreParam.fastForward = true;
493+
}
494+
break;
495+
case RETRO_THROTTLE_SLOW_MOTION:
496+
coreParam.fpsLimit = FPSLimit::ANALOG;
497+
coreParam.analogFpsLimit = std::max(1, (int)(throttle.rate + 0.5f));
498+
coreParam.fastForward = false;
499+
break;
500+
default:
501+
coreParam.fpsLimit = FPSLimit::NORMAL;
502+
coreParam.fastForward = false;
503+
break;
504+
}
505+
}
506+
#else
480507
if (g_Config.bForceLagSync)
481508
{
482509
bool isFastForwarding;
483510
if (environ_cb(RETRO_ENVIRONMENT_GET_FASTFORWARDING, &isFastForwarding))
484511
coreParam.fastForward = isFastForwarding;
485512
}
513+
#endif
486514
}
487515

488516
static void check_variables(CoreParameter &coreParam)

0 commit comments

Comments
 (0)