From 664d55e7a9dbe69db0746364267a1084f488170d Mon Sep 17 00:00:00 2001 From: minenice55 Date: Tue, 30 Jan 2024 21:25:05 -0500 Subject: [PATCH] *don't* cause a stack overflow when polling split controller --- .../ControllerTypes/InputJoyshock.cs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/Assets/Scripts/InputSystem/ControllerTypes/InputJoyshock.cs b/Assets/Scripts/InputSystem/ControllerTypes/InputJoyshock.cs index 5dd63bff2..921307980 100644 --- a/Assets/Scripts/InputSystem/ControllerTypes/InputJoyshock.cs +++ b/Assets/Scripts/InputSystem/ControllerTypes/InputJoyshock.cs @@ -659,7 +659,13 @@ namespace HeavenStudio.InputSystem } if (otherHalf != null) { - return otherHalf.GetLastActionDown(); + for (int i = 0; i < otherHalf.actionStates.Length; i++) + { + if (otherHalf.actionStates[i].pressed && otherHalf.actionStates[i].isDelta) + { + return i; + } + } } return -1; } @@ -677,9 +683,10 @@ namespace HeavenStudio.InputSystem public override bool GetActionDown(ControlStyles style, int button, out double dt) { if (button == -1) { dt = 0; return false; } - if (otherHalf != null && otherHalf.GetActionDown(style, button, out dt)) + if (otherHalf != null) { - return true; + dt = otherHalf.actionStates[button].dt; + return otherHalf.actionStates[button].pressed && otherHalf.actionStates[button].isDelta; } dt = actionStates[button].dt; return actionStates[button].pressed && actionStates[button].isDelta; @@ -688,9 +695,10 @@ namespace HeavenStudio.InputSystem public override bool GetActionUp(ControlStyles style, int button, out double dt) { if (button == -1) { dt = 0; return false; } - if (otherHalf != null && otherHalf.GetActionUp(style, button, out dt)) + if (otherHalf != null) { - return true; + dt = otherHalf.actionStates[button].dt; + return !otherHalf.actionStates[button].pressed && otherHalf.actionStates[button].isDelta; } dt = actionStates[button].dt; return !actionStates[button].pressed && actionStates[button].isDelta;