From 87a91c1dc694592ded5b3a599ca8523e8dede7a5 Mon Sep 17 00:00:00 2001 From: vaporvee Date: Mon, 28 Nov 2022 19:41:47 +0100 Subject: [PATCH] current controller now gets recognized better on the go --- src/essential.cs | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/essential.cs b/src/essential.cs index 3b052e8..0910547 100644 --- a/src/essential.cs +++ b/src/essential.cs @@ -3,22 +3,18 @@ using System; public partial class essential : Node { - [Export] public string currentController = Input.GetJoyName(0); - public override void _Ready() + public override void _Input(InputEvent @event) { - GD.Print(Input.GetConnectedJoypads()); + //Checks if using Keyboard or controller and giving out current controller + if (@event is InputEventKey || @event is InputEventMouseButton || currentController == "") + currentController = "PC"; + if (@event is InputEventJoypadButton) + currentController = Input.GetJoyName(0); } public override void _Process(double delta) { - //Checks if using Keyboard or controller and giving out current controller - //this is a terrible way of doing this and will be reworked - if (Input.IsMouseButtonPressed(MouseButton.Left) || currentController == "" || currentController == null) - currentController = "PC"; - if (Input.IsJoyButtonPressed(0, JoyButton.A) || Input.IsJoyButtonPressed(0, JoyButton.B)) - currentController = Input.GetJoyName(0); - //CHANGE INPUT FOR NINTENDO CONTROLLER InputEventJoypadButton JoyButtonA = new InputEventJoypadButton() { ButtonIndex = JoyButton.A }; InputEventJoypadButton JoyButtonB = new InputEventJoypadButton() { ButtonIndex = JoyButton.B };