fix: joypad drift threshold + move InputDevice enum inside class
This commit is contained in:
@@ -2,10 +2,9 @@ using Godot;
|
||||
|
||||
namespace Mr.BrickAdventures.Autoloads;
|
||||
|
||||
public enum InputDevice { Mouse, Keyboard, Gamepad }
|
||||
|
||||
public partial class InputDeviceManager : Node
|
||||
{
|
||||
public enum InputDevice { Mouse, Keyboard, Gamepad }
|
||||
public static InputDeviceManager Instance { get; private set; }
|
||||
|
||||
public InputDevice CurrentDevice { get; private set; } = InputDevice.Mouse;
|
||||
@@ -33,8 +32,13 @@ public partial class InputDeviceManager : Node
|
||||
detected = InputDevice.Mouse;
|
||||
else if (@event is InputEventKey)
|
||||
detected = InputDevice.Keyboard;
|
||||
else if (@event is InputEventJoypadButton or InputEventJoypadMotion)
|
||||
else if (@event is InputEventJoypadButton)
|
||||
detected = InputDevice.Gamepad;
|
||||
else if (@event is InputEventJoypadMotion joyEvent)
|
||||
{
|
||||
if (Mathf.Abs(joyEvent.AxisValue) <= 0.15f) return;
|
||||
detected = InputDevice.Gamepad;
|
||||
}
|
||||
else
|
||||
return;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user