Пример #1
0
        public NintendoSwitchInputDeviceManager()
        {
            DebugPad.Initialize();
            CreateDebugDevice();

            Npad.Initialize();

            // NpadJoy.SetHoldType only affects how controllers behave when using a system applet.
            // NpadJoyHoldType.Vertical is the default setting, but most games would want to use
            // NpadJoyHoldType.Horizontal as it can support all controller styles.
            //
            // If you do use NpadJoyHoldType.Vertical, Npad.SetSupportedStyleSet must only list
            // controller types supported by NpadJoyHoldType.Vertical. If you don't, the controller
            // applet will fail to load.
            //
            // Supported types for NpadJoyHoldType.Vertical are:
            // NpadStyle.FullKey, NpadStyle.JoyLeft and NpadStyle.JoyRight
            NpadJoy.SetHoldType(NpadJoyHoldType.Horizontal);

            // Handheld = Joy-Con docked with the console.
            // FullKey  = Pro Controller.
            // JoyDual  = Two Joy-Con used together as one controller.
            // JoyLeft  = Left Joy-Con used by itself.
            // JoyRight = Left Joy-Con used by itself.
            Npad.SetSupportedStyleSet(NpadStyle.Handheld | NpadStyle.FullKey | NpadStyle.JoyDual | NpadStyle.JoyLeft | NpadStyle.JoyRight);

            // Both controllers must be docked for handheld mode.
            NpadJoy.SetHandheldActivationMode(NpadHandheldActivationMode.Dual);

            // You must call Npad.SetSupportedIdType for all supported controllers.
            // Not calling this may lead to crashes in some circumstances.
            var nPadIds = new NpadId[] {
                NpadId.Handheld,
                NpadId.No1,
                NpadId.No2,
                NpadId.No3,
                NpadId.No4,
                NpadId.No5,
                NpadId.No6,
                NpadId.No7,
                NpadId.No8
            };

            Npad.SetSupportedIdType(nPadIds);

            // Create InControl devices for all NpadIds regardless of how many we request from NintendoSDK.
            CreateDevice(NpadId.Handheld);
            CreateDevice(NpadId.No1);
            CreateDevice(NpadId.No2);
            CreateDevice(NpadId.No3);
            CreateDevice(NpadId.No4);
            CreateDevice(NpadId.No5);
            CreateDevice(NpadId.No6);
            CreateDevice(NpadId.No7);
            CreateDevice(NpadId.No8);

            UpdateInternal(0, 0);

            ShowControllerSupportForSinglePlayer(false);

            InputManager.OnDeviceAttached += inputDevice =>
            {
                if (!Gunhouse.AppEntry.HasAppStarted())
                {
                    UnityEngine.Debug.Log("<color=red>we're not in it yet. don't pop the controller applet</color>");
                    return;
                }
                else
                {
                    UnityEngine.Debug.Log("<color=blue>it's ok to pop the applet.</color>");
                }
                UnityEngine.Debug.Log("Attached: " + inputDevice.Name);
                ShowControllerSupportForSinglePlayer(false);
            };

            /*InputManager.OnDeviceDetached += inputDevice =>
             * {
             *  UnityEngine.Debug.Log("Detached: " + inputDevice.Name);
             *  ShowControllerSupportForSinglePlayer(false);
             * };
             * InputManager.OnActiveDeviceChanged += inputDevice =>
             * {
             *  UnityEngine.Debug.Log("Switched: " + inputDevice.Name);
             *  ShowControllerSupportForSinglePlayer(false);
             * };*/
        }
Пример #2
0
 public void UpdateInternalState()
 {
     DebugPad.GetState(ref state);
     IsPresent = (state.attributes & DebugPadAttribute.IsConnected) != 0;
 }