From e28be76afe6ab34bc4c1db5c1e0d481405c96dc5 Mon Sep 17 00:00:00 2001 From: vaporvee Date: Sun, 27 Nov 2022 04:10:31 +0100 Subject: [PATCH] now checks if you are using keyboard or gamepad (very badly) --- src/main.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main.cs b/src/main.cs index 7750a89..445714b 100644 --- a/src/main.cs +++ b/src/main.cs @@ -8,12 +8,21 @@ public partial class main : Node2D public override void _Ready() { + GD.Print(Input.GetConnectedJoypads()); } public override void _Process(double delta) { //CHANGE INPUT FOR NINTENDO CONTROLLER - //TODO: set currentController to keyboard if keyboard for UI purposes and more - currentController = Input.GetJoyName(0); + //Checks if using Keyboard or controller and giving out current controller + if(Input.IsMouseButtonPressed(MouseButton.Left) || Input.IsMouseButtonPressed(MouseButton.Right))//this is a terrible way of doing this will be reworked + { + currentController = "PC"; + } + if (Input.IsJoyButtonPressed(0, JoyButton.A) || Input.IsJoyButtonPressed(0, JoyButton.B)) + { + currentController = Input.GetJoyName(0); + } + if (currentController.StartsWith("Nintendo")) { InputMap.ActionAddEvent("ui_accept", new InputEventJoypadButton() { ButtonIndex = JoyButton.B});