// Update is called once per frame
    void Update()
    {
        if (!text)
        {
            return;
        }

        DllConst.Capture();

        //
        string ShowText = "";

        for (int DeviceIndex = 0; DeviceIndex < InputConst.XUSER_MAX_COUNT; DeviceIndex++)
        {
            int Buttons = DllConst.GetButtons(DeviceIndex);

            // デバイス番号
            ShowText += string.Format("Device : {0} {1}\n", DeviceIndex, DllConst.IsConnected(DeviceIndex));

            // 方向(デジタル)
            ShowText += string.Format("LRUD : {0} {1} {2} {3}\n",
                                      (((Buttons & InputConst.XINPUT_GAMEPAD_DPAD_LEFT) != 0) ? 1 : 0),
                                      (((Buttons & InputConst.XINPUT_GAMEPAD_DPAD_RIGHT) != 0) ? 1 : 0),
                                      (((Buttons & InputConst.XINPUT_GAMEPAD_DPAD_UP) != 0) ? 1 : 0),
                                      (((Buttons & InputConst.XINPUT_GAMEPAD_DPAD_DOWN) != 0) ? 1 : 0));

            // ABXYボタン
            ShowText += string.Format("ABXY : {0} {1} {2} {3}\n",
                                      (((Buttons & InputConst.XINPUT_GAMEPAD_A) != 0) ? 1 : 0),
                                      (((Buttons & InputConst.XINPUT_GAMEPAD_B) != 0) ? 1 : 0),
                                      (((Buttons & InputConst.XINPUT_GAMEPAD_X) != 0) ? 1 : 0),
                                      (((Buttons & InputConst.XINPUT_GAMEPAD_Y) != 0) ? 1 : 0));

            // トリガー
            ShowText += string.Format("TriggerLR : {0} {1}\n",
                                      DllConst.GetLeftTrigger(DeviceIndex),
                                      DllConst.GetRightTrigger(DeviceIndex));

            // 軸(アナログ)
            ShowText += string.Format("Thumb {0}, {1}, {2}, {3}\n",
                                      DllConst.GetThumbLX(DeviceIndex),
                                      DllConst.GetThumbLY(DeviceIndex),
                                      DllConst.GetThumbRX(DeviceIndex),
                                      DllConst.GetThumbRX(DeviceIndex));

            //
            ShowText += "\n";
        }

        //
        text.text = ShowText;
    }
Example #2
0
        private void UpdateTriggerAsButtons()
        {
            int  right       = DllConst.GetRightTrigger(deviceNumber);
            bool isRightDown = (right > triggerDownThreshold);

            if (_isRightTriggerDown != isRightDown)
            {
                _isRightTriggerDown = isRightDown;
                _buttonSubject.OnNext(new GamepadKeyData(GamepadKey.RTrigger, isRightDown));
            }

            int  left       = DllConst.GetLeftTrigger(deviceNumber);
            bool isLeftDown = (left > triggerDownThreshold);

            if (_isLeftTriggerDown != isLeftDown)
            {
                _isLeftTriggerDown = isLeftDown;
                _buttonSubject.OnNext(new GamepadKeyData(GamepadKey.LTrigger, isLeftDown));
            }
        }
Example #3
0
    void Update()
    {
        DllConst.Capture();
        int Buttons = DllConst.GetButtons(DeviceNumber);

        // 方向(デジタル)
        if ((Buttons & InputConst.XINPUT_GAMEPAD_DPAD_LEFT) != 0)
        {
            Debug.Log("Left");
        }
        if ((Buttons & InputConst.XINPUT_GAMEPAD_DPAD_RIGHT) != 0)
        {
            Debug.Log("Right");
        }
        if ((Buttons & InputConst.XINPUT_GAMEPAD_DPAD_UP) != 0)
        {
            Debug.Log("Up");
        }
        if ((Buttons & InputConst.XINPUT_GAMEPAD_DPAD_DOWN) != 0)
        {
            Debug.Log("Down");
        }

        // ABXYボタン
        if ((Buttons & InputConst.XINPUT_GAMEPAD_A) != 0)
        {
            Debug.Log("A");
        }
        if ((Buttons & InputConst.XINPUT_GAMEPAD_B) != 0)
        {
            Debug.Log("B");
        }
        if ((Buttons & InputConst.XINPUT_GAMEPAD_X) != 0)
        {
            Debug.Log("X");
        }
        if ((Buttons & InputConst.XINPUT_GAMEPAD_Y) != 0)
        {
            Debug.Log("Y");
        }

        // トリガー
        if (DllConst.GetLeftTrigger(DeviceNumber) != 0)
        {
            Debug.Log("LeftTriger : " + DllConst.GetLeftTrigger(DeviceNumber));
        }
        if (DllConst.GetRightTrigger(DeviceNumber) != 0)
        {
            Debug.Log("RightTriger : " + DllConst.GetRightTrigger(DeviceNumber));
        }

        // 軸(アナログ)
        if ((DllConst.GetThumbLX(DeviceNumber)) != 0)
        {
            Debug.Log("ThumbLX : " + DllConst.GetThumbLX(DeviceNumber));
        }
        if ((DllConst.GetThumbLY(DeviceNumber)) != 0)
        {
            Debug.Log("ThumbLY : " + DllConst.GetThumbLY(DeviceNumber));
        }
        if (DllConst.GetThumbRX(DeviceNumber) != 0)
        {
            Debug.Log("ThumbRX : " + DllConst.GetThumbRX(DeviceNumber));
        }
        if (DllConst.GetThumbRX(DeviceNumber) != 0)
        {
            Debug.Log("ThumbRY : " + DllConst.GetThumbRX(DeviceNumber));
        }
    }