From 1a5d5452fe265e600cfe3d22294d4dd6fc881b88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Wed, 27 Sep 2023 17:22:11 +0200 Subject: [PATCH] Batch axis events to the VR code --- Common/UI/Screen.cpp | 2 +- Common/VR/PPSSPPVR.cpp | 11 +++++++---- Common/VR/PPSSPPVR.h | 2 +- UI/NativeApp.cpp | 14 +++++--------- 4 files changed, 14 insertions(+), 15 deletions(-) diff --git a/Common/UI/Screen.cpp b/Common/UI/Screen.cpp index 7c7a46f8e4..e6ba293659 100644 --- a/Common/UI/Screen.cpp +++ b/Common/UI/Screen.cpp @@ -117,7 +117,7 @@ bool ScreenManager::key(const KeyInput &key) { return result; } -void ScreenManager::axis(const AxisInput &axis) { +void ScreenManager::axis(const AxisInput *axis, size_t count) { std::lock_guard guard(inputLock_); stack_.back().screen->UnsyncAxis(axis); } diff --git a/Common/VR/PPSSPPVR.cpp b/Common/VR/PPSSPPVR.cpp index bf07b9e68e..83486dded8 100644 --- a/Common/VR/PPSSPPVR.cpp +++ b/Common/VR/PPSSPPVR.cpp @@ -473,11 +473,14 @@ void UpdateVRInput(bool haptics, float dp_xscale, float dp_yscale) { } } -bool UpdateVRAxis(const AxisInput &axis) { - if (pspAxis.find(axis.deviceId) == pspAxis.end()) { - pspAxis[axis.deviceId] = std::map(); +bool UpdateVRAxis(const AxisInput *axes, size_t count) { + for (size_t i = 0; i < count; i++) { + const AxisInput &axis = axes[i]; + if (pspAxis.find(axis.deviceId) == pspAxis.end()) { + pspAxis[axis.deviceId] = std::map(); + } + pspAxis[axis.deviceId][axis.axisId] = axis.value; } - pspAxis[axis.deviceId][axis.axisId] = axis.value; return !pspKeys[VIRTKEY_VR_CAMERA_ADJUST]; } diff --git a/Common/VR/PPSSPPVR.h b/Common/VR/PPSSPPVR.h index 489e70bdd7..b78000e4e1 100644 --- a/Common/VR/PPSSPPVR.h +++ b/Common/VR/PPSSPPVR.h @@ -37,7 +37,7 @@ void SetVRCallbacks(void(*axis)(const AxisInput *axis, size_t count), bool(*key) // VR input integration void SetVRAppMode(VRAppMode mode); void UpdateVRInput(bool haptics, float dp_xscale, float dp_yscale); -bool UpdateVRAxis(const AxisInput &axis); +bool UpdateVRAxis(const AxisInput *axes, size_t count); bool UpdateVRKeys(const KeyInput &key); // VR games compatibility diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index f4056c10b3..6b37bd728c 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -1319,9 +1319,9 @@ bool NativeKey(const KeyInput &key) { return retval; } -static void ProcessOneAxisEvent(const AxisInput &axis) { +void NativeAxis(const AxisInput *axes, size_t count) { // VR actions - if (IsVREnabled() && !UpdateVRAxis(axis)) { + if (IsVREnabled() && !UpdateVRAxis(axes, count)) { return; } @@ -1330,14 +1330,10 @@ static void ProcessOneAxisEvent(const AxisInput &axis) { return; } - // only do special handling of tilt events if tilt is enabled. - HLEPlugins::PluginDataAxis[axis.axisId] = axis.value; - g_screenManager->axis(axis); -} - -void NativeAxis(const AxisInput *axes, size_t count) { for (size_t i = 0; i < count; i++) { - ProcessOneAxisEvent(axes[i]); + const AxisInput &axis = axes[i]; + g_screenManager->axis(axis); + HLEPlugins::PluginDataAxis[axis.axisId] = axis.value; } }