Skip to content

Commit 4255641

Browse files
committed
Temporary fix to InputManager so that it uses only the new input system
1 parent 9c814af commit 4255641

2 files changed

Lines changed: 13 additions & 7 deletions

File tree

Runtime/Prefabs/VideoPlayer/VideoControl.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,14 @@ protected override void AwakeOverride() { }
4040
protected TaskCompletionSource<bool> videoFinished;
4141

4242
protected void Update() {
43-
if (Input.GetKeyDown(pauseToggleKey)) {
43+
if (InputManager.Instance.GetKeyDown(pauseToggleKey)) {
4444
if (videoPlayer.isPlaying) {
4545
videoPlayer.Pause();
4646
} else {
4747
videoPlayer.Play();
4848
}
4949
}
50-
if (skippable && Input.GetKeyDown(deactivateKey)) {
50+
if (skippable && InputManager.Instance.GetKeyDown(deactivateKey)) {
5151
videoPlayer.Stop();
5252
OnLoopPointReached(videoPlayer);
5353
}

Runtime/Scripts/Core/InputManager.cs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
using PsyForge.Threading;
1818
using System.Linq;
19+
using PsyForge.Utilities;
1920

2021
namespace PsyForge {
2122

@@ -30,7 +31,8 @@ public bool GetKeyDown(KeyCode key, bool unpausable = false) {
3031
}
3132
protected Bool GetKeyDownHelper(KeyCode key, Bool unpausable) {
3233
if (!unpausable && Time.timeScale == 0) { return false; }
33-
return Input.GetKeyDown(key);
34+
var newKey = KeyCodeConversions.KeyCodeToKey(GetLocalizedKey(key));
35+
return Keyboard.current[newKey].wasPressedThisFrame;
3436
}
3537
public KeyCode GetKeyDown(KeyCode[] keys, bool unpausable = false) {
3638
return DoGet<KeyCode[], Bool, KeyCode>(GetKeyDownHelper, keys, unpausable);
@@ -39,7 +41,8 @@ public KeyCode GetKeyDownHelper(KeyCode[] keys, Bool unpausable) {
3941
if (!unpausable && Time.timeScale == 0) { return KeyCode.None; }
4042

4143
foreach (KeyCode key in keys) {
42-
if (Input.GetKeyDown(GetLocalizedKey(key))) {
44+
var newKey = KeyCodeConversions.KeyCodeToKey(GetLocalizedKey(key));
45+
if (Keyboard.current[newKey].wasPressedThisFrame) {
4346
return GetLocalizedKey(key);
4447
}
4548
}
@@ -51,7 +54,8 @@ public bool GetKey(KeyCode key, bool unpausable = false) {
5154
}
5255
protected Bool GetKeyHelper(KeyCode key, Bool unpausable) {
5356
if (!unpausable && Time.timeScale == 0) { return false; }
54-
return Input.GetKey(key);
57+
var newKey = KeyCodeConversions.KeyCodeToKey(GetLocalizedKey(key));
58+
return Keyboard.current[newKey].isPressed;
5559
}
5660
public KeyCode GetKey(List<KeyCode> keys, bool unpausable = false) {
5761
return DoGet<KeyCode[], Bool, KeyCode>(GetKeyHelper, keys.ToArray(), unpausable);
@@ -63,7 +67,8 @@ public KeyCode GetKeyHelper(KeyCode[] keys, Bool unpausable) {
6367
if (!unpausable && Time.timeScale == 0) { return KeyCode.None; }
6468

6569
foreach (KeyCode key in keys) {
66-
if (Input.GetKey(GetLocalizedKey(key))) {
70+
var newKey = KeyCodeConversions.KeyCodeToKey(GetLocalizedKey(key));
71+
if (Keyboard.current[newKey].isPressed) {
6772
return GetLocalizedKey(key);
6873
}
6974
}
@@ -81,7 +86,8 @@ protected async Task<KeyCode> WaitForKeyHelper(Bool unpausable, CancellationToke
8186
await Awaitable.NextFrameAsync();
8287
if (unpausable || Time.timeScale != 0) {
8388
foreach (KeyCode vKey in Enum.GetValues(typeof(KeyCode))) {
84-
if (Input.GetKeyDown(GetLocalizedKey(vKey))) {
89+
var newKey = KeyCodeConversions.KeyCodeToKey(GetLocalizedKey(vKey));
90+
if (Keyboard.current[newKey].wasPressedThisFrame) {
8591
return GetLocalizedKey(vKey);
8692
};
8793
}

0 commit comments

Comments
 (0)