Exemplo n.º 1
0
 private void CreateDevice()
 {
     device = new TouchInputDevice();
     device.AddControl(InputControlType.LeftStickLeft, "LeftStickLeft");
     device.AddControl(InputControlType.LeftStickRight, "LeftStickRight");
     device.AddControl(InputControlType.LeftStickUp, "LeftStickUp");
     device.AddControl(InputControlType.LeftStickDown, "LeftStickDown");
     device.AddControl(InputControlType.RightStickLeft, "RightStickLeft");
     device.AddControl(InputControlType.RightStickRight, "RightStickRight");
     device.AddControl(InputControlType.RightStickUp, "RightStickUp");
     device.AddControl(InputControlType.RightStickDown, "RightStickDown");
     device.AddControl(InputControlType.DPadUp, "DPadUp");
     device.AddControl(InputControlType.DPadDown, "DPadDown");
     device.AddControl(InputControlType.DPadLeft, "DPadLeft");
     device.AddControl(InputControlType.DPadRight, "DPadRight");
     device.AddControl(InputControlType.LeftTrigger, "LeftTrigger");
     device.AddControl(InputControlType.RightTrigger, "RightTrigger");
     device.AddControl(InputControlType.LeftBumper, "LeftBumper");
     device.AddControl(InputControlType.RightBumper, "RightBumper");
     for (InputControlType inputControlType = InputControlType.Action1; inputControlType <= InputControlType.Action4; inputControlType++)
     {
         device.AddControl(inputControlType, inputControlType.ToString());
     }
     device.AddControl(InputControlType.Menu, "Menu");
     for (InputControlType inputControlType2 = InputControlType.Button0; inputControlType2 <= InputControlType.Button19; inputControlType2++)
     {
         device.AddControl(inputControlType2, inputControlType2.ToString());
     }
     InputManager.AttachDevice(device);
 }
Exemplo n.º 2
0
 public KeyCode GetControl(InputControlType action)
 {
     if (actions.ContainsKey(action))
     {
         return(actions[action]);
     }
     Debug.LogWarning("No associated keycode found for " + action.ToString());
     return(KeyCode.None);
 }
Exemplo n.º 3
0
    // Update is called once per frame
    void OnGUI()
    {
        if (_keySetting == null)
        {
            return;
        }
        if (mKeyCheckBox.isChecked && _keySetting._keyLock)
        {
            mKeyCheckBox.isChecked = false;
        }
        if (mCtrlCheckBox.isChecked && _keySetting._joyLock)
        {
            mCtrlCheckBox.isChecked = false;
        }
        if (mLockSpr.enabled == false && _keySetting._keyLock)
        {
            mLockSpr.enabled = true;
        }

        if (_keySettingName != 0)
        {
            mFunctionContent.text = PELocalization.GetString(_keySettingName);
        }
        //mKeyContent.text = _keySetting._key.ToStr().Replace("Button","").Replace("Alpha","");
        //mCtrlContent.text = _keySetting._joy.ToStr().Replace("Button","").Replace("Alpha","");

        if (mCtrlCheckBox.isChecked || mKeyCheckBox.isChecked)
        {
            KeyCode curKey = _ctrlKeyDown;
            if (Event.current != null)
            {
                if (Event.current.type == EventType.KeyDown)
                {
                    curKey = Event.current.keyCode;
                }
                else if (Event.current.type == EventType.MouseDown && _bHover)
                {
                    curKey = KeyCode.Mouse0 + Event.current.button;
                }
            }

            if (mCtrlCheckBox.isChecked)
            {
                for (InputControlType type = InputControlType.Action1; type < InputControlType.Options; ++type)
                {
                    if (InputManager.ActiveDevice.GetControl(type).WasPressed)
                    {
                        _joyToSet         = type;
                        mCtrlContent.text = _joyToSet.ToString();
                        break;
                    }
                }
                //mCtrlCheckBox.isChecked = false; // Uncheck to confirm because we want to support cimbination-key
            }
            else if (mKeyCheckBox.isChecked && curKey != KeyCode.None && curKey > KeyCode.Escape && curKey < KeyCode.JoystickButton0)
            {
                _keyToSet = curKey;
                if (Event.current.alt && curKey != KeyCode.LeftAlt && curKey != KeyCode.RightAlt)
                {
                    _keyToSet = PeInput.AltKey(_keyToSet);
                }
                if (Event.current.shift && curKey != KeyCode.LeftShift && curKey != KeyCode.RightShift)
                {
                    _keyToSet = PeInput.ShiftKey(_keyToSet);
                }
                if (Event.current.control && curKey != KeyCode.LeftControl && curKey != KeyCode.RightControl)
                {
                    _keyToSet = PeInput.CtrlKey(_keyToSet);
                }

                mKeyContent.text = _keyToSet.ToStr();
                //mKeyCheckBox.isChecked = false; // Uncheck to confirm because we want to support cimbination-key
            }
        }
    }
Exemplo n.º 4
0
 public void Set(KeySettingItem item, InputControlType keyToSet)
 {
     item._keySetting._joy  = keyToSet;
     item.mCtrlContent.text = keyToSet.ToString();
 }
 override public string ToString()
 {
     return(string.Format("UnknownDeviceControl( {0}, {1} )", Control.ToString(), SourceRange.ToString()));
 }
 public override string ToString()
 {
     return($"UnknownDeviceControl( {Control.ToString()}, {SourceRange.ToString()} )");
 }
Exemplo n.º 7
0
        public bool SetControl(InputControlType control, string description, string spriteSuffix)
        {
            //Debug.Log("Set control: " + control.ToString() + " in " + name);
            Reset();

            bool result = true;

            switch (control)
            {
            case InputControlType.Action1:
            case InputControlType.Action2:
            case InputControlType.Action3:
            case InputControlType.Action4:
                ControllerButtonSprite.enabled    = true;
                ControllerButtonSprite.spriteName = control.ToString() + "_" + spriteSuffix;
                break;

            case InputControlType.LeftStickButton:
                LStickSprite.enabled = true;
                break;

            case InputControlType.RightStickButton:
                RStickSprite.enabled = true;
                break;

            case InputControlType.LeftBumper:
                LBumperSprite.enabled = true;
                break;

            case InputControlType.RightBumper:
                RBumperSprite.enabled = true;
                break;

            case InputControlType.LeftTrigger:
                LTriggerSprite.enabled = true;
                break;

            case InputControlType.RightTrigger:
                RTriggerSprite.enabled = true;
                break;

            case InputControlType.DPadLeft:
                ControllerDPadSprite.enabled = true;
                ControllerDPadLeft.enabled   = true;
                if (IncludeOpposingAxisByDefault)
                {
                    ControllerDPadRight.enabled = true;
                }
                break;

            case InputControlType.DPadRight:
                ControllerDPadSprite.enabled = true;
                ControllerDPadRight.enabled  = true;
                if (IncludeOpposingAxisByDefault)
                {
                    ControllerDPadLeft.enabled = true;
                }
                break;

            case InputControlType.DPadUp:
                ControllerDPadSprite.enabled = true;
                ControllerDPadUp.enabled     = true;
                if (IncludeOpposingAxisByDefault)
                {
                    ControllerDPadDown.enabled = true;
                }
                break;

            case InputControlType.DPadDown:
                ControllerDPadSprite.enabled = true;
                ControllerDPadDown.enabled   = true;
                if (IncludeOpposingAxisByDefault)
                {
                    ControllerDPadUp.enabled = true;
                }
                break;

            case InputControlType.DPadX:
                ControllerDPadSprite.enabled = true;
                ControllerDPadLeft.enabled   = true;
                ControllerDPadRight.enabled  = true;
                if (IncludeOpposingAxisByDefault)
                {
                    ControllerDPadUp.enabled   = true;
                    ControllerDPadDown.enabled = true;
                }
                break;

            case InputControlType.DPadY:
                ControllerDPadSprite.enabled = true;
                ControllerDPadUp.enabled     = true;
                ControllerDPadDown.enabled   = true;
                if (IncludeOpposingAxisByDefault)
                {
                    ControllerDPadLeft.enabled  = true;
                    ControllerDPadRight.enabled = true;
                }
                break;

            case InputControlType.LeftStickX:
                LStickSprite.enabled = true;
                ControllerArrowsHorizontal.enabled = true;
                if (IncludeOpposingAxisByDefault)
                {
                    ControllerArrowsVertical.enabled = true;
                }
                break;

            case InputControlType.LeftStickY:
                LStickSprite.enabled             = true;
                ControllerArrowsVertical.enabled = true;
                if (IncludeOpposingAxisByDefault)
                {
                    ControllerArrowsHorizontal.enabled = true;
                }
                break;

            case InputControlType.RightStickX:
                RStickSprite.enabled = true;
                ControllerArrowsHorizontal.enabled = true;
                if (IncludeOpposingAxisByDefault)
                {
                    ControllerArrowsVertical.enabled = true;
                }
                break;

            case InputControlType.RightStickY:
                RStickSprite.enabled             = true;
                ControllerArrowsVertical.enabled = true;
                if (IncludeOpposingAxisByDefault)
                {
                    ControllerArrowsHorizontal.enabled = true;
                }
                break;

            case InputControlType.Start:
                StartButtonSprite.enabled = true;
                break;

            case InputControlType.Back:
                BackButtonSprite.enabled = true;
                break;

            default:
                result = false;
                break;
            }

            DescriptionLabel.enabled = true;
            DescriptionLabel.text    = description;

            return(result);
        }