private void Initialize()
    {
        gamepad = GetComponent <Fyo.SocketGamepad>();

        // Find the controller we want to manage
        Player player = ReInput.players.GetPlayer(playerId);                                    // get the player

        controller = player.controllers.GetControllerWithTag <CustomController>(controllerTag); // get the controller

        if (controller == null)
        {
            Debug.LogError("A matching controller was not found for tag \"" + controllerTag + "\"");
        }

        // Callback Update Method:
        // Set callbacks to retrieve current element values.
        // This is a different way of updating the element values in the controller.
        // You set an update function for axes and buttons and these functions will be called
        // to retrieve the current source element values on every update loop in which input is updated.
        if (controller != null)
        {
            controller.SetAxisUpdateCallback(GetAxisValueCallback);
            controller.SetButtonUpdateCallback(GetButtonValueCallback);
        }

        initialized = true;
    }
示例#2
0
    void Start()
    {
        player = ReInput.players.GetPlayer(playerId);

        for (int i = 0; i < player.controllers.customControllerCount; i++)
        {
            CustomController controller = player.controllers.CustomControllers[i];
            if (controller.hardwareName == controllerId)
            {
                controller.SetAxisUpdateCallback(GetAxisInfo);
                controller.SetButtonUpdateCallback(GetButtonInfo);
            }
        }
    }
示例#3
0
        private void Initialize()
        {
            // Subscribe to the input source update event so we can update our source element data before controllers are updated
            ReInput.InputSourceUpdateEvent += OnInputSourceUpdate;

            // Get the touch controls
            joysticks = GetComponentsInChildren <TouchJoystickExample>();
            buttons   = GetComponentsInChildren <TouchButtonExample>();

            // Get expected element counts
            axisCount   = joysticks.Length * 2; // 2 axes per stick
            buttonCount = buttons.Length;

            // Set up arrays to store our current source element values
            axisValues   = new float[axisCount];
            buttonValues = new bool[buttonCount];

            // Find the controller we want to manage
            Player player = ReInput.players.GetPlayer(playerId);                                    // get the player

            controller = player.controllers.GetControllerWithTag <CustomController>(controllerTag); // get the controller

            if (controller == null)
            {
                Debug.LogError("A matching controller was not found for tag \"" + controllerTag + "\"");
            }

            // Verify controller has the number of elements we're expecting
            if (controller.buttonCount != buttonValues.Length || controller.axisCount != axisValues.Length)
            {
                // controller has wrong number of elements
                Debug.LogError("Controller has wrong number of elements!");
            }

            // Callback Update Method:
            // Set callbacks to retrieve current element values.
            // This is a different way of updating the element values in the controller.
            // You set an update function for axes and buttons and these functions will be called
            // to retrieve the current source element values on every update loop in which input is updated.
            if (useUpdateCallbacks && controller != null)
            {
                controller.SetAxisUpdateCallback(GetAxisValueCallback);
                controller.SetButtonUpdateCallback(GetButtonValueCallback);
            }

            initialized = true;
        }
        private void Initialize() {
            // Subscribe to the input source update event so we can update our source element data before controllers are updated
            ReInput.InputSourceUpdateEvent += OnInputSourceUpdate;

            // Get the touch controller
            touchController = GetComponent<Demos.TouchControllerExample>();

            // Get expected element counts
            axisCount = touchController.joysticks.Length * 2; // 2 axes per stick
            buttonCount = touchController.buttons.Length;

            // Set up arrays to store our current source element values
            axisValues = new float[axisCount];
            buttonValues = new bool[buttonCount];

            // Find the controller we want to manage
            Player player = ReInput.players.GetPlayer(playerId); // get the player
            controller = player.controllers.GetControllerWithTag<CustomController>(controllerTag); // get the controller

            if(controller == null) {
                Debug.LogError("A matching controller was not found for tag \"" + controllerTag + "\"");
            }

            // Verify controller has the number of elements we're expecting
            if(controller.buttonCount != buttonValues.Length || controller.axisCount != axisValues.Length) { // controller has wrong number of elements
                Debug.LogError("Controller has wrong number of elements!");
            }

            // Callback Update Method:
            // Set callbacks to retrieve current element values.
            // This is a different way of updating the element values in the controller.
            // You set an update function for axes and buttons and these functions will be called
            // to retrieve the current source element values on every update loop in which input is updated.
            if(useUpdateCallbacks && controller != null) {
                controller.SetAxisUpdateCallback(GetAxisValueCallback);
                controller.SetButtonUpdateCallback(GetButtonValueCallback);
            }

            initialized = true;
        }
示例#5
0
    void Start()
    {
        if (ReInput.players == null || ReInput.players.playerCount <= 0)
        {
            return;
        }
        player = ReInput.players.GetPlayer(playerId);

        if (player == null)
        {
            return;
        }
        for (int i = 0; i < player.controllers.customControllerCount; i++)
        {
            CustomController controller = player.controllers.CustomControllers[i];
            // Debug.Log("Controller:"+ controller.hardwareName);
            if (controller.hardwareName == controllerId)
            {
                controller.SetAxisUpdateCallback(GetAxisInfo);
                controller.SetButtonUpdateCallback(GetButtonInfo);
                //   Debug.Log("Hey mon ami");
            }
        }
    }