diff --git a/CommunityBugFixCollection/SteamVrFocusResolutionScale.cs b/CommunityBugFixCollection/SteamVrFocusResolutionScale.cs new file mode 100644 index 0000000..d252f11 --- /dev/null +++ b/CommunityBugFixCollection/SteamVrFocusResolutionScale.cs @@ -0,0 +1,31 @@ +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; + + // 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) + { + // 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 (Enabled && !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)