Forum rules - please read before posting.

Touch Screen and controller rather than keyboard mouse? - Nintendo Switch

So my dev kit is in the mail, but I have the game up running in a virtual environment.

And I realized that when this thing is plugged in people would have to use the joy controllers and also when they are holding the system they might not want to rely on the touch screen. Which seems like a pretty easy fix, just have the controller move the cursor around like in the original MacVenture NES Ports (since this is a MacVenture style game).

However, the options are Touchscreen, Controller Keyboard, or Mouse and Keyboard. Is there a way to do Touchscreen and joystick? I'm sure if I dig around a bit more tomorrow I'll figure something out, but on the off chance this issue has already been addressed/wheel invented I figured I'd ask here.

I've spent several hours googling and searching the forums and haven't found this exact question asked, so I figured I'd throw it up here and see if anyone has a solution.

I did search the Nintendo Dev forums, but to no avail sadly.

Comments

  • Moved to Technical Q&A.

    It's possible to override inputs with your own system (see the Manual's "Remapping inputs" chapter), but you may be able to get by simply by changing the "Input method" dynamically between "Touch Screen" and "Keyboard Or Controller" based on what kind of input was last received.

    All Manager fields can be changed at runtime - just right click the field's label to get an API reference to it. In the case of the Input method, it's:

    AC.KickStarter.settingsManager.inputMethod
    

    I'm not sure exactly how well this would translate to the Switch platform, but a quick-and-dirty way to do this would be something along the lines of:

    using AC;
    using UnityEngine;
    
    public class DetectInputMethod : MonoBehaviour
    {
    
        private void Update ()
        {
            if (Input.touchCount > 0)
            {
                SetInputMethod (InputMethod.TouchScreen);
                return;
            }
    
            for (int i = 0; i < 20; i++)
            {
                if(Input.GetKeyDown ("joystick 1 button " +i))
                {
                    SetInputMethod (InputMethod.KeyboardOrController);   
                }
            }
        }
    
        private void SetInputMethod(InputMethod inputMethod)
        {
            if (KickStarter.settingsManager.inputMethod != inputMethod)
            {
                KickStarter.settingsManager.inputMethod = inputMethod;
                // Plus anything else you may want/need to do when changing input
            }
        }
    }
    
  • Just wanted to say thank you for the above. Got buried at work last week and then I got notice that my Dev kit is delayed in transit so I can't test it out just yet. But I promise to let you know how it goes as soon as the device is in my hands :)

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.