Page 1 of 1

Game doesn't select input method on launch

Posted: Tue Jan 18, 2022 6:49 am
by rykaan
Hi Tony,

Yesterday I was trying to solve an annoying problem I've had for ages where a connected Playstation controller would fight mouse control if the mouse is clicked during gameplay (issue didn't occur with Xbox controller). I eventually removed the 'Joystick axes to check' fields and it solved the problem. I am using the InControl support and figured that the axes detection might be messing with it. It worked fine and I thought that was then end of it.

But starting the project up this morning, the game isn't defaulting to any control scheme at all. The game starts with no focused menu option, and no button press on the controller (either Playstation or Xbox) selects one. After clicking the mouse then hovering over an option the controller navigation kicks in. I tried adding back in the Joystick axes fields I had removed making it identical to yesterday and still no luck. Here's a screen of the settings:
Input Device Manager.jpg
Input Device Manager.jpg (149.29 KiB) Viewed 1068 times
Input device is still set to joystick, auto-focus and detect mouse control are active. I checked an earlier version of the project and the settings here are the same as they were months ago. Fiddling with it yesterday just seems to have broken it today somehow :S. I don't think the Joystick keycodes do anything either to be honest, and the input manager is massively populated by the InControl settings so they aren't really useful anymore.

Hope this boils down to something I've forgotten to tick box somewhere.
Cheers in advance,
Rob

Re: Game doesn't select input method on launch

Posted: Tue Jan 18, 2022 8:44 am
by Tony Li
Hi,

Always Auto Focus should keep a UI button focused, as long as:

1. The UI buttons are children of a UIPanel or a subclass of UIPanel such as StandardUISubtitlePanel.

2. The UIPanel's Focus Check Frequency is non-zero (e.g., 0.2). Also try setting Refresh Selectables Frequency to a non-zero value such as 0.5.

Since you're using InControl, you can clear the Joystick Axes to Check and Joystick & Key Buttons To Check fields, as well as the Back Buttons and Submit Button. If you want the Input Device Manager to read InControl inputs for these, you can assign methods to InputDeviceManager.GetButtonDown(), GetButtonUp(), and GetAxis() that read from InControl instead of Unity's built-in input manager.

Re: Game doesn't select input method on launch

Posted: Tue Jan 18, 2022 9:36 am
by rykaan
I think there's already code in place telling the input manager to use inControl methods, unless I am misunderstanding the InControl support script.

Code: Select all

private void Start()
        {
            if (InputDeviceManager.instance == null) Debug.LogWarning("The scene is missing an Input Device Manager. Can't set up InputDeviceManagerInControl.", this);

            // Tell Dialogue System to use InControl to check button and axis input:
            InputDeviceManager.instance.GetButtonDown = InControlGetButtonDown;
            InputDeviceManager.instance.GetButtonUp = InControlGetButtonUp;
            InputDeviceManager.instance.GetInputAxis = InControlGetAxis;
            playerActions = new PlayerActions();
        }

        public bool InControlGetButtonDown(string buttonName)
        {
            return playerActions.GetPlayerActionByName(buttonName).WasPressed;
        }

        public bool InControlGetButtonUp(string buttonName)
        {
            return playerActions.GetPlayerActionByName(buttonName).WasReleased;
        }

        public float InControlGetAxis(string axisName)
        {
            switch (axisName)
            {                
                case "Brother Horizontal": return playerActions.BrotherHorizontal.Value;
                case "Brother Vertical": return playerActions.BrotherVertical.Value;
                case "Dash": return playerActions.Dash.Value;
                case "Sister Horizontal": return playerActions.SisterHorizontal.Value;
                case "Sister Vertical": return playerActions.SisterVertical.Value;
                case "Use Power": return playerActions.UsePower.Value;
                case "Change Power": return playerActions.ChangePower.Value;
            }
            return playerActions.GetPlayerActionByName(axisName).Value;
        }
    }
Do I need to add the additional delegated methods in addition to this? It just seems weird since yesterday it was working fine.

Cheers,
Rob

Re: Game doesn't select input method on launch

Posted: Tue Jan 18, 2022 11:10 am
by Tony Li
Hi,

That code looks fine to me. That's the correct way to tie InControl to the Dialogue System's Input Device Manager.

Are there any errors or warnings in the Console?

Is some other script perhaps unticking the Always Auto Focus checkbox?

Which UI(s) are failing to keep a UI button selected so you can navigate them?

Re: Game doesn't select input method on launch

Posted: Tue Jan 18, 2022 11:51 am
by rykaan
Hi Tony,

Sorry about this thread, the issue was somewhere else entirely. I had a Coroutine with a slight delay in it before selecting the main menu button, just to wait for the scene to finish loading or some such. I have no idea why but the delay now causes the problem rather than fixing it. Delay gone, it works fine. Really sorry for wasting your time, the modification to the input detection was the only thread of an idea I had for what I could have broken it.

I also added social media links to the main menu yesterday so maybe something changed because of that, regardless problem solved as far as I know.

Edit: I hadn't looked at that script in months, so I just can't understand why it became a problem between closing down last night and booting up this morning.

Cheers,
Rob

Re: Game doesn't select input method on launch

Posted: Tue Jan 18, 2022 11:55 am
by Tony Li
Hi Rob,

I'm glad you got to the bottom of it!