using mouse on title screen selects keyboard instead

default to keyboard for invalid controllers
This commit is contained in:
minenice55 2024-01-05 21:43:58 -05:00
parent 207c2ace3f
commit 85bc98e150

View file

@ -141,14 +141,26 @@ namespace HeavenStudio
pressAnyKeyAnim.Play("PressKeyFadeOut", 0, 0); pressAnyKeyAnim.Play("PressKeyFadeOut", 0, 0);
SoundByte.PlayOneShot("ui/UIEnter"); 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()); Debug.Log("Assigning controller: " + newController.GetDeviceName());
var lastController = PlayerInput.GetInputController(1); 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); lastController.SetPlayer(null);
newController.SetPlayer(1); nextController.SetPlayer(1);
PlayerInput.CurrentControlStyle = newController.GetDefaultStyle(); PlayerInput.CurrentControlStyle = nextController.GetDefaultStyle();
usingMouse = PlayerInput.CurrentControlStyle == InputController.ControlStyles.Touch; usingMouse = PlayerInput.CurrentControlStyle == InputController.ControlStyles.Touch;
selectedDisplayIcon.SetActive(!usingMouse); selectedDisplayIcon.SetActive(!usingMouse);
@ -157,10 +169,10 @@ namespace HeavenStudio
(lastController as InputJoyshock)?.UnAssignOtherHalf(); (lastController as InputJoyshock)?.UnAssignOtherHalf();
} }
if ((newController as InputJoyshock) != null) if ((nextController as InputJoyshock) != null)
{ {
newController.OnSelected(); nextController.OnSelected();
(newController as InputJoyshock)?.UnAssignOtherHalf(); (nextController as InputJoyshock)?.UnAssignOtherHalf();
} }
} }
} }