예제 #1
0
        private void Update()
        {
            if (!_updateEnabled)
            {
                return;
            }

            if (_preferDirectInput)
            {
                //DirectInputの読み取り機能で更新
                _directInputAlternative.Update();
                UpdateByState(_directInputAlternative.CurrentState);
            }
            else
            {
                //普通にXInputの読み取り
                DllConst.Capture();
                int buttonFlags = DllConst.GetButtons(deviceNumber);
                foreach (var button in _buttons)
                {
                    button.UpdatePressedState(buttonFlags);
                }
                UpdateRightStick();
                UpdateLeftStick();
                UpdateTriggerAsButtons();
            }
        }
예제 #2
0
    // 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;
    }
예제 #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));
        }
    }