From 85bc98e15007334c0e21f5362ee6c31a9b4a06c9 Mon Sep 17 00:00:00 2001 From: minenice55 Date: Fri, 5 Jan 2024 21:43:58 -0500 Subject: [PATCH] using mouse on title screen selects keyboard instead default to keyboard for invalid controllers --- Assets/Scripts/TitleManager.cs | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/Assets/Scripts/TitleManager.cs b/Assets/Scripts/TitleManager.cs index ad392d580..5de732692 100644 --- a/Assets/Scripts/TitleManager.cs +++ b/Assets/Scripts/TitleManager.cs @@ -141,14 +141,26 @@ namespace HeavenStudio pressAnyKeyAnim.Play("PressKeyFadeOut", 0, 0); SoundByte.PlayOneShot("ui/UIEnter"); + var nextController = newController; + + if (newController is InputMouse) + { + Debug.Log("Mouse used, selecting keyboard instead"); + nextController = controllers[0]; + } Debug.Log("Assigning controller: " + newController.GetDeviceName()); var lastController = PlayerInput.GetInputController(1); - if (lastController != newController) + if (lastController != nextController) { + if (nextController == null) + { + Debug.Log("invalid controller, using keyboard"); + nextController = controllers[0]; + } lastController.SetPlayer(null); - newController.SetPlayer(1); - PlayerInput.CurrentControlStyle = newController.GetDefaultStyle(); + nextController.SetPlayer(1); + PlayerInput.CurrentControlStyle = nextController.GetDefaultStyle(); usingMouse = PlayerInput.CurrentControlStyle == InputController.ControlStyles.Touch; selectedDisplayIcon.SetActive(!usingMouse); @@ -157,10 +169,10 @@ namespace HeavenStudio (lastController as InputJoyshock)?.UnAssignOtherHalf(); } - if ((newController as InputJoyshock) != null) + if ((nextController as InputJoyshock) != null) { - newController.OnSelected(); - (newController as InputJoyshock)?.UnAssignOtherHalf(); + nextController.OnSelected(); + (nextController as InputJoyshock)?.UnAssignOtherHalf(); } } }