diff --git a/Core/ControlMapper.cpp b/Core/ControlMapper.cpp index 86455c26f2..8b0e4759d9 100644 --- a/Core/ControlMapper.cpp +++ b/Core/ControlMapper.cpp @@ -651,8 +651,11 @@ void ControlMapper::Axis(const AxisInput *axes, size_t count) { KeyMap::UnlockMappings(); } -void ControlMapper::Update(const DisplayLayoutConfig &config, double now) { +void ControlMapper::UpdateConfig(const DisplayLayoutConfig &config) { iInternalScreenRotationCached_ = config.bRotateControlsWithScreen ? config.iInternalScreenRotation : ROTATION_LOCKED_HORIZONTAL; +} + +void ControlMapper::UpdateAutoMovements(double now) { if (autoRotatingAnalogCW_) { // Clamp to a square float x = std::min(1.0f, std::max(-1.0f, 1.42f * (float)cos(now * -g_Config.fAnalogAutoRotSpeed))); diff --git a/Core/ControlMapper.h b/Core/ControlMapper.h index 848cc49050..9f496eeaed 100644 --- a/Core/ControlMapper.h +++ b/Core/ControlMapper.h @@ -25,7 +25,8 @@ public: // Main use is of course from EmuScreen.cpp, but also useful from control settings etc. class ControlMapper { public: - void Update(const DisplayLayoutConfig &config, double now); + void UpdateConfig(const DisplayLayoutConfig &config); + void UpdateAutoMovements(double now); // Inputs to the table-based mapping // These functions are free-threaded. diff --git a/Core/HLE/sceDisplay.cpp b/Core/HLE/sceDisplay.cpp index 5fbcf4543e..2eff81d0b6 100644 --- a/Core/HLE/sceDisplay.cpp +++ b/Core/HLE/sceDisplay.cpp @@ -53,6 +53,7 @@ #include "Core/HW/Display.h" #include "Core/Util/PPGeDraw.h" #include "Core/RetroAchievements.h" +#include "Core/ControlMapper.h" #include "GPU/GPU.h" #include "GPU/GPUState.h" @@ -541,6 +542,9 @@ void hleEnterVblank(u64 userdata, int cyclesLate) { __KernelReSchedule("entered vblank"); } + // We use the emulation timebase here, for auto movements to be smooth as seen from the game. + g_controlMapper.UpdateAutoMovements(CoreTiming::GetGlobalTimeUs() / 1000000.0); + numVBlanksSinceFlip++; // TODO: Should this be done here or in hleLeaveVblank? diff --git a/UI/ControlMappingScreen.cpp b/UI/ControlMappingScreen.cpp index 3185fcb034..41729763da 100644 --- a/UI/ControlMappingScreen.cpp +++ b/UI/ControlMappingScreen.cpp @@ -501,7 +501,7 @@ void AnalogCalibrationScreen::SetRawAnalog(int stick, float x, float y) { } void AnalogCalibrationScreen::update() { - g_controlMapper.Update(g_Config.GetDisplayLayoutConfig(GetDeviceOrientation()), time_now_d()); + g_controlMapper.UpdateConfig(g_Config.GetDisplayLayoutConfig(GetDeviceOrientation())); // We ignore the secondary stick for now and just use the two views // for raw and psp input. if (stickView_[0]) { diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index 067fb70916..dbc9ef62a5 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -1495,7 +1495,7 @@ void EmuScreen::update() { double now = time_now_d(); DisplayLayoutConfig &config = g_Config.GetDisplayLayoutConfig(GetDeviceOrientation()); - g_controlMapper.Update(config, now); + g_controlMapper.UpdateConfig(config); if (saveStatePreview_ && !bootPending_) { int currentSlot = SaveState::GetCurrentSlot();