Skip to content

Commit def40a3

Browse files
authored
Add patch for broken SteamVR focus handling (#62)
* Add patch for broken SteamVR focus handling Yellow-Dog-Man/Resonite-Issues#2337 * Add note about singleton * Check for Enabled condition
1 parent 38eb445 commit def40a3

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using HarmonyLib;
2+
using MonkeyLoader.Resonite;
3+
using System.Collections.Generic;
4+
5+
namespace CommunityBugFixCollection
6+
{
7+
[HarmonyPatchCategory(nameof(SteamVrFocusResolutionScale))]
8+
[HarmonyPatch("Valve.VR.SteamVR_Render", "OnInputFocus")]
9+
internal sealed class SteamVrFocusResolutionScale : ResoniteBugFixMonkey<SteamVrFocusResolutionScale>
10+
{
11+
public override IEnumerable<string> Authors => Contributors.Goat;
12+
13+
// SteamVR_Render is treated as a singleton in SteamVR and initialized once from SteamVRDriver through SteamVR.Initialize()
14+
private static bool _lastInputFocus = false;
15+
16+
public static bool Prefix(bool hasFocus)
17+
{
18+
// Work around some broken logic in SteamVR focus handling
19+
// https://github.com/Yellow-Dog-Man/Resonite-Issues/issues/2337#issuecomment-3025681468
20+
// https://github.com/ValveSoftware/steamvr_unity_plugin/blob/056c82369d78f253af8cefcae9b289efd69bd960/Assets/SteamVR/Scripts/SteamVR_Render.cs#L237-L262
21+
if (Enabled && !hasFocus && !_lastInputFocus)
22+
{
23+
Logger.Trace(() => "Dropping redundant OnInputFocus call");
24+
return false;
25+
}
26+
27+
_lastInputFocus = hasFocus;
28+
return true;
29+
}
30+
}
31+
}

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ just disable them in the settings in the meantime.
5454
* FlipAtUser component does not respect view position (https://github.com/Yellow-Dog-Man/Resonite-Issues/issues/1335)
5555
* ColorX From HexCode (ProtoFlux node) defaults to Linear profile (https://github.com/Yellow-Dog-Man/Resonite-Issues/issues/1404)
5656
* ProtoFlux value casts from byte to other values converting incorrectly (mono / graphical client only) (https://github.com/Yellow-Dog-Man/Resonite-Issues/issues/2257)
57+
* 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)
5758
* `ValueMod<Decimal>` node crashes the game when B input is set to zero or disconnected. (https://github.com/Yellow-Dog-Man/Resonite-Issues/issues/2746)
5859
* Grid World grid being off-center (https://github.com/Yellow-Dog-Man/Resonite-Issues/issues/2754)
5960
* Animators updating all associated fields every frame while enabled but not playing (https://github.com/Yellow-Dog-Man/Resonite-Issues/issues/3480)

0 commit comments

Comments
 (0)