-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
force rewired to fallback to unity input system
- Loading branch information
Showing
4 changed files
with
51 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
UniTAS/Patcher/Implementations/RewiredFix/FallbackToUnityInput.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using System; | ||
using HarmonyLib; | ||
using UniTAS.Patcher.Interfaces.DependencyInjection; | ||
using UniTAS.Patcher.Services.InputSystemOverride; | ||
|
||
namespace UniTAS.Patcher.Implementations.RewiredFix; | ||
|
||
[Singleton] | ||
[ForceInstantiate] | ||
public class FallbackToUnityInput | ||
{ | ||
public FallbackToUnityInput(IInputSystemState inputSystemState) | ||
{ | ||
if (!inputSystemState.HasRewired) return; | ||
|
||
var reInput = AccessTools.TypeByName("Rewired.ReInput"); | ||
|
||
if (reInput == null) | ||
{ | ||
throw new Exception("failed to find Rewired.ReInput type, cannot apply fix"); | ||
} | ||
|
||
var configuration = AccessTools.Property(reInput, "configuration")?.GetValue(null, null); | ||
|
||
if (configuration == null) | ||
{ | ||
throw new Exception("failed to find Rewired.ReInput.configuration property, cannot apply fix"); | ||
} | ||
|
||
var alwaysUseUnityInput = AccessTools.Property(configuration.GetType(), "alwaysUseUnityInput"); | ||
|
||
if (alwaysUseUnityInput == null) | ||
{ | ||
throw new Exception( | ||
"failed to find Rewired.ReInput.configuration.alwaysUseUnityInput property, cannot apply fix"); | ||
} | ||
|
||
alwaysUseUnityInput.SetValue(configuration, true, null); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters