Exemple #1
0
        public static void CreateGluedJoycon()
        {
            Console.WriteLine("Applying some glue...");
            NintendoController leftJoycon    = null;
            NintendoController rightJoycon   = null;
            NintendoController proController = null;

            foreach (NintendoController controller in controllers)
            {
                HardwareInterface hardware = controller.GetHardware();
                hardware.SetReportMode(0x30); // 60hz update mode
                hardware.SetVibration(true);
                hardware.SetIMU(true);
                hardware.SetPlayerLights(PlayerLightState.Player1);
                HomeLEDInterface homeLED = controller.GetHomeLED();
                homeLED.SendPattern(HomeLEDInterface.GetHeartbeatPattern());

                switch (hardware.GetControllerType())
                {
                case ControllerType.LeftJoycon:
                    Console.WriteLine("Left Joycon detected.");
                    leftJoycon = controller;
                    break;

                case ControllerType.RightJoycon:
                    Console.WriteLine("Right Joycon detected.");
                    rightJoycon = controller;
                    break;

                case ControllerType.ProController:
                    Console.WriteLine("Pro Controller detected.");
                    proController = controller;
                    break;

                default:
                    Console.WriteLine("Unrecognized device.");
                    break;
                }
            }

            if (proController != null)
            {
                controller = proController.GetController().GetJoystick();
            }
            else
            {
                controller = leftJoycon.GetController().CombineWith(rightJoycon);
            }
        }