Skip to content

Commit 644f0dd

Browse files
committed
Support games with disabled Input class
1 parent eb6dd0d commit 644f0dd

File tree

4 files changed

+16
-8
lines changed

4 files changed

+16
-8
lines changed

ConfigurationManager/ConfigurationManager.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,15 +263,15 @@ private void OnGUI()
263263
SetUnlockCursor(0, true);
264264

265265
if (GUI.Button(_screenRect, string.Empty, GUI.skin.box) &&
266-
!SettingWindowRect.Contains(Input.mousePosition))
266+
!SettingWindowRect.Contains(UnityInput.Current.mousePosition))
267267
DisplayingWindow = false;
268268

269269
GUI.Box(SettingWindowRect, GUIContent.none, new GUIStyle { normal = new GUIStyleState { background = WindowBackground } });
270270

271271
GUILayout.Window(WindowId, SettingWindowRect, SettingsWindow, "Plugin / mod settings");
272272

273273
if (!SettingFieldDrawer.SettingKeyboardShortcut)
274-
Input.ResetInputAxes();
274+
UnityInput.Current.ResetInputAxes();
275275
}
276276
}
277277

ConfigurationManager/ConfigurationManager.csproj

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,16 @@
3434
<DocumentationFile>..\bin\BepInEx\plugins\ConfigurationManager.xml</DocumentationFile>
3535
</PropertyGroup>
3636
<ItemGroup>
37-
<Reference Include="BepInEx, Version=5.4.15.0, Culture=neutral, processorArchitecture=MSIL">
38-
<HintPath>..\packages\BepInEx.BaseLib.5.4.15\lib\net35\BepInEx.dll</HintPath>
37+
<Reference Include="BepInEx, Version=5.4.20.0, Culture=neutral, processorArchitecture=MSIL">
38+
<HintPath>..\packages\BepInEx.BaseLib.5.4.20\lib\net35\BepInEx.dll</HintPath>
3939
<Private>False</Private>
4040
</Reference>
4141
<Reference Include="System" />
4242
<Reference Include="System.Core" />
43+
<Reference Include="Unity.InputSystem, Version=1.5.0.0, Culture=neutral, processorArchitecture=MSIL">
44+
<HintPath>..\packages\Unity.InputSystem.1.5.0\lib\net35\Unity.InputSystem.dll</HintPath>
45+
<Private>False</Private>
46+
</Reference>
4347
<Reference Include="UnityEngine, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
4448
<HintPath>..\packages\UnityEngine.5.6.1\lib\net35\UnityEngine.dll</HintPath>
4549
<Private>False</Private>

ConfigurationManager/SettingFieldDrawer.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@
88
using System.ComponentModel;
99
using System.Globalization;
1010
using System.Linq;
11+
using BepInEx;
1112
using UnityEngine;
1213

1314
namespace ConfigurationManager
1415
{
1516
internal class SettingFieldDrawer
1617
{
17-
private static readonly IEnumerable<KeyCode> _keysToCheck = BepInEx.Configuration.KeyboardShortcut.AllKeyCodes.Except(new[] { KeyCode.Mouse0, KeyCode.None }).ToArray();
18+
private static IEnumerable<KeyCode> _keysToCheck;
1819

1920
public static Dictionary<Type, Action<SettingEntryBase>> SettingDrawHandlers { get; }
2021

@@ -337,11 +338,13 @@ private static void DrawKeyboardShortcut(SettingEntryBase setting)
337338
GUILayout.Label("Press any key combination", GUILayout.ExpandWidth(true));
338339
GUIUtility.keyboardControl = -1;
339340

341+
var input = UnityInput.Current;
342+
if (_keysToCheck == null) _keysToCheck = input.SupportedKeyCodes.Except(new[] { KeyCode.Mouse0, KeyCode.None }).ToArray();
340343
foreach (var key in _keysToCheck)
341344
{
342-
if (Input.GetKeyUp(key))
345+
if (input.GetKeyUp(key))
343346
{
344-
setting.Set(new BepInEx.Configuration.KeyboardShortcut(key, _keysToCheck.Where(Input.GetKey).ToArray()));
347+
setting.Set(new BepInEx.Configuration.KeyboardShortcut(key, _keysToCheck.Where(input.GetKey).ToArray()));
345348
_currentKeyboardShortcutToSet = null;
346349
break;
347350
}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
33
<package id="BepInEx.Analyzers" version="1.0.8" targetFramework="net35" developmentDependency="true" />
4-
<package id="BepInEx.BaseLib" version="5.4.15" targetFramework="net35" developmentDependency="true" />
4+
<package id="BepInEx.BaseLib" version="5.4.20" targetFramework="net35" developmentDependency="true" />
5+
<package id="Unity.InputSystem" version="1.5.0" targetFramework="net35" />
56
<package id="UnityEngine" version="5.6.1" targetFramework="net35" developmentDependency="true" />
67
</packages>

0 commit comments

Comments
 (0)