From 5670500460f28b801dd513264945c49f40bdd6c5 Mon Sep 17 00:00:00 2001 From: goaaats Date: Wed, 2 Jul 2025 14:44:46 +0200 Subject: [PATCH 1/3] Add patch for broken SteamVR focus handling https://github.com/Yellow-Dog-Man/Resonite-Issues/issues/2337 --- .../SteamVrFocusResolutionScale.cs | 30 +++++++++++++++++++ README.md | 1 + 2 files changed, 31 insertions(+) create mode 100644 CommunityBugFixCollection/SteamVrFocusResolutionScale.cs diff --git a/CommunityBugFixCollection/SteamVrFocusResolutionScale.cs b/CommunityBugFixCollection/SteamVrFocusResolutionScale.cs new file mode 100644 index 0000000..eeaa5c4 --- /dev/null +++ b/CommunityBugFixCollection/SteamVrFocusResolutionScale.cs @@ -0,0 +1,30 @@ +using HarmonyLib; +using MonkeyLoader.Resonite; +using System.Collections.Generic; + +namespace CommunityBugFixCollection +{ + [HarmonyPatchCategory(nameof(SteamVrFocusResolutionScale))] + [HarmonyPatch("Valve.VR.SteamVR_Render", "OnInputFocus")] + internal sealed class SteamVrFocusResolutionScale : ResoniteBugFixMonkey + { + public override IEnumerable Authors => Contributors.Goat; + + private static bool _lastInputFocus = false; + + public static bool Prefix(bool hasFocus) + { + // Work around some broken logic in SteamVR focus handling + // https://github.com/Yellow-Dog-Man/Resonite-Issues/issues/2337#issuecomment-3025681468 + // https://github.com/ValveSoftware/steamvr_unity_plugin/blob/056c82369d78f253af8cefcae9b289efd69bd960/Assets/SteamVR/Scripts/SteamVR_Render.cs#L237-L262 + if (_lastInputFocus == hasFocus && !_lastInputFocus) + { + Logger.Trace(() => "Dropping redundant OnInputFocus call"); + return false; + } + + _lastInputFocus = hasFocus; + return true; + } + } +} \ No newline at end of file diff --git a/README.md b/README.md index c383a4d..8037385 100644 --- a/README.md +++ b/README.md @@ -54,6 +54,7 @@ just disable them in the settings in the meantime. * FlipAtUser component does not respect view position (https://github.com/Yellow-Dog-Man/Resonite-Issues/issues/1335) * ColorX From HexCode (ProtoFlux node) defaults to Linear profile (https://github.com/Yellow-Dog-Man/Resonite-Issues/issues/1404) * ProtoFlux value casts from byte to other values converting incorrectly (mono / graphical client only) (https://github.com/Yellow-Dog-Man/Resonite-Issues/issues/2257) +* Resolution scale may get stuck at 0.5 when opening and closing the SteamVR dashboard while the game is hitching (https://github.com/Yellow-Dog-Man/Resonite-Issues/issues/2337) * `ValueMod` node crashes the game when B input is set to zero or disconnected. (https://github.com/Yellow-Dog-Man/Resonite-Issues/issues/2746) * Grid World grid being off-center (https://github.com/Yellow-Dog-Man/Resonite-Issues/issues/2754) * Animators updating all associated fields every frame while enabled but not playing (https://github.com/Yellow-Dog-Man/Resonite-Issues/issues/3480) From 30b058ca7ac3040f1168b6847756fba7c2ffe0fd Mon Sep 17 00:00:00 2001 From: goaaats Date: Wed, 2 Jul 2025 14:49:05 +0200 Subject: [PATCH 2/3] Add note about singleton --- CommunityBugFixCollection/SteamVrFocusResolutionScale.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/CommunityBugFixCollection/SteamVrFocusResolutionScale.cs b/CommunityBugFixCollection/SteamVrFocusResolutionScale.cs index eeaa5c4..1eec5de 100644 --- a/CommunityBugFixCollection/SteamVrFocusResolutionScale.cs +++ b/CommunityBugFixCollection/SteamVrFocusResolutionScale.cs @@ -10,6 +10,7 @@ internal sealed class SteamVrFocusResolutionScale : ResoniteBugFixMonkey Authors => Contributors.Goat; + // SteamVR_Render is treated as a singleton in SteamVR and initialized once from SteamVRDriver through SteamVR.Initialize() private static bool _lastInputFocus = false; public static bool Prefix(bool hasFocus) From a60b1571bbafd4d2fd7ad99739461b6ed8d1b515 Mon Sep 17 00:00:00 2001 From: goaaats Date: Wed, 2 Jul 2025 14:57:16 +0200 Subject: [PATCH 3/3] Check for Enabled condition --- CommunityBugFixCollection/SteamVrFocusResolutionScale.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CommunityBugFixCollection/SteamVrFocusResolutionScale.cs b/CommunityBugFixCollection/SteamVrFocusResolutionScale.cs index 1eec5de..d252f11 100644 --- a/CommunityBugFixCollection/SteamVrFocusResolutionScale.cs +++ b/CommunityBugFixCollection/SteamVrFocusResolutionScale.cs @@ -18,7 +18,7 @@ public static bool Prefix(bool hasFocus) // Work around some broken logic in SteamVR focus handling // https://github.com/Yellow-Dog-Man/Resonite-Issues/issues/2337#issuecomment-3025681468 // https://github.com/ValveSoftware/steamvr_unity_plugin/blob/056c82369d78f253af8cefcae9b289efd69bd960/Assets/SteamVR/Scripts/SteamVR_Render.cs#L237-L262 - if (_lastInputFocus == hasFocus && !_lastInputFocus) + if (Enabled && !hasFocus && !_lastInputFocus) { Logger.Trace(() => "Dropping redundant OnInputFocus call"); return false;