void OnControllerConnected(ControllerStatusChangedEventArgs args) { if (args.controllerType != ControllerType.Joystick) { return; } foreach (Player p in ReInput.players.Players) { if (p.controllers.ContainsController(args.controllerType, args.controllerId)) { manager.ActivatePlayer(p.id); manager.RouteActivationInput(p.id); } } }
// Update is called once per frame void Update() { Controller controller = player.controllers.GetLastActiveController(); if (controller != null && controller.type == ControllerType.Keyboard && !keyboardPlayer) { keyboardPlayer = true; return; } var moveX = Math.Sign(player.GetAxis("UIHorizontal")); if (moveX != 0 && joystickAcceptingInput) { joystickAcceptingInput = false; manager.RouteInputAxis(playerNumber - 1, moveX); StartCoroutine(ReactivateAfterDelay()); } if (player.GetButtonDown("UISubmit")) { manager.RouteInputA(playerNumber - 1, playerColor); } if (player.GetButtonDown("UICancel")) { manager.RouteInputB(playerNumber - 1); } if (player.GetButton("UICancel")) { manager.RouteInputAltB(playerNumber - 1); } if (player.GetAnyButtonDown()) { manager.RouteActivationInput(playerNumber - 1); } }