Exemplo n.º 1
0
		public InputControl AddControl( InputControlType target, string handle )
		{
			var controlIndex = (int) target;
			var inputControl = new InputControl( handle, target );
			Controls[controlIndex] = inputControl;
			return inputControl;
		}
Exemplo n.º 2
0
		public InputControl( string handle, InputControlType target ) : base()
		{
			Handle = handle;
			Target = target;

			IsButton = Utility.TargetIsButton( target );
			IsAnalog = !IsButton;
		}
Exemplo n.º 3
0
		public InputControl( string handle, InputControlType target )
		{
			Handle = handle;
			Target = target;

			IsButton = (target >= InputControlType.Action1 && target <= InputControlType.Action4) ||
					   (target >= InputControlType.Button0 && target <= InputControlType.Button19);
		}
Exemplo n.º 4
0
        void RemoveControl(InputControlType controlType)
        {
            var inputControl = ControlsByTarget[(int)controlType];

            if (inputControl != null)
            {
                ControlsByTarget[(int)controlType] = null;
                controls.Remove(inputControl);
                ExpireControlCache();
            }
        }
Exemplo n.º 5
0
        public InputControl GetControl(Enum inputControlType, int player = -1)
        {
            InputControlType controlType = (InputControlType)inputControlType;
            var control = Controls.Find(c => c.Target == controlType && c.player == player);

            if (control == null)
            {
                control = Controls.Find(c => c.Target == controlType);
            }
            return(control ?? InputControl.Null);
        }
Exemplo n.º 6
0
    /* INITIALIZATION */
    public MiniGameYoga(int pPlayerIndex, float pTimeToComplete) : base(pPlayerIndex, pTimeToComplete)
    {
        _instructions   = "Watch your timing!";
        _timeToScale    = 0f;
        _timer          = 0f;
        _minTime        = 0f;
        _maxTime        = 0f;
        _currentControl = InputControlType.None;
        _controlPool    = new List <InputControlType>();

        InitTask();
    }
 public void GetBinding()
 {
     this.SetupRefs();
     if (this.actionSet != null)
     {
         this.currentBinding = this.playerAction.GetControllerButtonBinding();
     }
     else
     {
         orig_GetBinding();
     }
 }
Exemplo n.º 8
0
    public bool IsButtonFree(int index, InputControlType button)
    {
        for (int i = 0; i < playerMaps[index].controlType.Length; i++)
        {
            if (playerMaps[index].controlType[i] == button)
            {
                return(false);
            }
        }

        return(true);
    }
Exemplo n.º 9
0
    void UpdateActionMapScript()
    {
        ActionMap     original  = (ActionMap)serializedObject.targetObject;
        string        className = GetCamelCaseString(original.name, true);
        StringBuilder str       = new StringBuilder();

        str.AppendFormat(@"using UnityEngine;
using UnityEngine.InputNew;

// GENERATED FILE - DO NOT EDIT MANUALLY
public class {0} : ActionMapInput {{
	public {0} (ActionMap actionMap) : base (actionMap) {{ }}
	
", className);

        for (int i = 0; i < m_ActionMapEditCopy.actions.Count; i++)
        {
            InputControlType controlType = m_ActionMapEditCopy.actions[i].controlData.controlType;
            string           typeStr     = string.Empty;
            switch (controlType)
            {
            case InputControlType.Button:
                typeStr = "ButtonInputControl";
                break;

            case InputControlType.AbsoluteAxis:
            case InputControlType.RelativeAxis:
                typeStr = "AxisInputControl";
                break;

            case InputControlType.Vector2:
                typeStr = "Vector2InputControl";
                break;

            case InputControlType.Vector3:
                typeStr = "Vector3InputControl";
                break;
            }

            str.AppendFormat("	public {2} @{0} {{ get {{ return ({2})this[{1}]; }} }}\n", GetCamelCaseString(m_ActionMapEditCopy.actions[i].name, false), i, typeStr);
        }

        str.AppendLine(@"}");

        string path = AssetDatabase.GetAssetPath(original);

        path = path.Substring(0, path.Length - Path.GetExtension(path).Length) + ".cs";
        File.WriteAllText(path, str.ToString());
        AssetDatabase.ImportAsset(path);

        original.SetMapTypeName(className + ", " + "Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null");
    }
Exemplo n.º 10
0
        public NewUnityInputDevice(UnityInput.Gamepad unityGamepad)
        {
            UnityGamepad = unityGamepad;

            SortOrder = unityGamepad.deviceId;

            DeviceClass = InputDeviceClass.Controller;
            DeviceStyle = DetectDeviceStyle(unityGamepad);

            leftCommandControl  = DeviceStyle.LeftCommandControl();
            rightCommandControl = DeviceStyle.RightCommandControl();

            Name = unityGamepad.displayName;
            Meta = unityGamepad.displayName;

            AddControl(InputControlType.LeftStickLeft, "Left Stick Left", lowerDeadZone, upperDeadZone);
            AddControl(InputControlType.LeftStickRight, "Left Stick Right", lowerDeadZone, upperDeadZone);
            AddControl(InputControlType.LeftStickUp, "Left Stick Up", lowerDeadZone, upperDeadZone);
            AddControl(InputControlType.LeftStickDown, "Left Stick Down", lowerDeadZone, upperDeadZone);

            AddControl(InputControlType.RightStickLeft, "Right Stick Left", lowerDeadZone, upperDeadZone);
            AddControl(InputControlType.RightStickRight, "Right Stick Right", lowerDeadZone, upperDeadZone);
            AddControl(InputControlType.RightStickUp, "Right Stick Up", lowerDeadZone, upperDeadZone);
            AddControl(InputControlType.RightStickDown, "Right Stick Down", lowerDeadZone, upperDeadZone);

            AddControl(InputControlType.LeftTrigger, unityGamepad.leftTrigger.displayName, lowerDeadZone, upperDeadZone);
            AddControl(InputControlType.RightTrigger, unityGamepad.rightTrigger.displayName, lowerDeadZone, upperDeadZone);

            AddControl(InputControlType.DPadUp, "DPad Up", lowerDeadZone, upperDeadZone);
            AddControl(InputControlType.DPadDown, "DPad Down", lowerDeadZone, upperDeadZone);
            AddControl(InputControlType.DPadLeft, "DPad Left", lowerDeadZone, upperDeadZone);
            AddControl(InputControlType.DPadRight, "DPad Right", lowerDeadZone, upperDeadZone);

            AddControl(InputControlType.Action1, unityGamepad.buttonWest.displayName);
            AddControl(InputControlType.Action2, unityGamepad.buttonNorth.displayName);
            AddControl(InputControlType.Action3, unityGamepad.buttonEast.displayName);
            AddControl(InputControlType.Action4, unityGamepad.buttonSouth.displayName);

            AddControl(InputControlType.LeftBumper, unityGamepad.leftShoulder.displayName);
            AddControl(InputControlType.RightBumper, unityGamepad.rightShoulder.displayName);

            AddControl(InputControlType.LeftStickButton, unityGamepad.leftStickButton.displayName);
            AddControl(InputControlType.RightStickButton, unityGamepad.rightStickButton.displayName);

            AddControl(leftCommandControl, unityGamepad.selectButton.displayName);
            AddControl(rightCommandControl, unityGamepad.startButton.displayName);

            // foreach (var control in unityGamepad.allControls)
            // {
            //  Debug.Log( $"{control.displayName}, {control.shortDisplayName}" );
            // }
        }
Exemplo n.º 11
0
        public InputControl AddControl(InputControlType controlType, string handle)
        {
            var inputControl = ControlsByTarget[(int)controlType];

            if (inputControl == null)
            {
                inputControl = new InputControl(handle, controlType);
                ControlsByTarget[(int)controlType] = inputControl;
                controls.Add(inputControl);
                ExpireControlCache();
            }
            return(inputControl);
        }
Exemplo n.º 12
0
        public int FindInArray(KeySettingItem[] items, InputControlType key)
        {
            int n = items.Length;

            for (int i = 0; i < n; i++)
            {
                if (items[i]._keySetting._joy == key)
                {
                    return(items[i]._keySetting._joyLock ? -(i + 1) : (i + 1));
                }
            }
            return(0);
        }
Exemplo n.º 13
0
        public VirtualControlButton( InputControlType controlType, string elementName, Vector2 position )
        {
            this.controlType = controlType;

            value = 0.0f;
            touchId = -1;
            alpha = 0.5f;

            sprite = new FSprite( elementName );
            sprite.SetAnchor( new Vector2( 0.5f, 0.5f ) );
            AddChild( sprite );

            SetPosition( position );
        }
Exemplo n.º 14
0
        public VirtualControlButton(InputControlType controlType, string elementName, Vector2 position)
        {
            this.controlType = controlType;

            value   = 0.0f;
            touchId = -1;
            alpha   = 0.5f;

            sprite = new FSprite(elementName);
            sprite.SetAnchor(new Vector2(0.5f, 0.5f));
            AddChild(sprite);

            SetPosition(position);
        }
Exemplo n.º 15
0
        private static void Postfix(PlayerAction __instance, InputControlType control)
        {
            try
            {
                if (!(Instance.Target is EmulateControllerWithKeyboard emulate))
                {
                    return;
                }

                foreach (var source in emulate.ActionsToLink.GetValues(control))
                {
                    InputLinker.Link(source, __instance);
                }
            }
            catch (Exception exception) { Main.Logger.Exception(exception); }
        }
Exemplo n.º 16
0
        public static bool GetAnyControllerButtonWasPressed(InputControlType control)
        {
            bool result = false;

            for (int i = 0; i < devices.Count; ++i)
            {
                result |= devices[i].GetControl(control).WasPressed;

                if (result)
                {
                    break;
                }
            }

            return(result);
        }
Exemplo n.º 17
0
    private InputControlType CompareLeftOrRight(PlayerStateMgr target, InputControlType ctlType)
    {
        if (target.PlyDisplay.IsFlipX)
        {
            if (ctlType == InputControlType.left)
            {
                return(InputControlType.right);
            }
            else if (ctlType == InputControlType.right)
            {
                return(InputControlType.left);
            }
        }

        return(ctlType);
    }
    private static void CreateControl(ActionMap actionMap, string name, InputControlType controlType, params ControlBinding[] bindingsPerControlScheme)
    {
        var action = new InputAction();

        action.controlData = new InputControlData
        {
            name        = name,
            controlType = controlType
        };
        actionMap.actions.Add(action);
        for (int i = 0; i < actionMap.controlSchemes.Count; i++)
        {
            var binding = (i >= bindingsPerControlScheme.Length ? null : bindingsPerControlScheme[i]);
            actionMap.controlSchemes[i].bindings.Add(binding);
        }
    }
Exemplo n.º 19
0
    public static bool GetInput(InputControlType input, TimeType timeType)
    {
        InputDevice device = InputManager.ActiveDevice;

        switch (timeType)
        {
        case TimeType.UP:
            return(device.GetControl(input).WasReleased);

        case TimeType.DOWN:
            return(device.GetControl(input).WasPressed);

        case TimeType.ALWAYS:
            return(device.GetControl(input).IsPressed);
        }
        return(false);
    }
Exemplo n.º 20
0
    public bool CheckGameComplete()
    {
        _taskActions.Dequeue();

        if (_taskActions.Count == 0)
        {
            Debug.Log("[YOGA] - GAME COMPLETE!");
            return(true);
        }
        else
        {
            Debug.Log("[YOGA] - MOVING ON!!");
            _currentControl = _taskActions.Peek().controlType;
            _timer          = 0f;
            return(false);
        }
    }
    private static void CreateControlComposite(ActionMap actionMap, string name, InputControlType controlType, int[] indices)
    {
        var action = new InputAction();

        action.controlData = new InputControlData
        {
            name                    = name,
            controlType             = controlType,
            componentControlIndices = indices
        };
        actionMap.actions.Add(action);
        // We have to create dummy bindings for now to make the indices match up.
        for (int i = 0; i < actionMap.controlSchemes.Count; i++)
        {
            actionMap.controlSchemes[i].bindings.Add(new ControlBinding());
        }
    }
Exemplo n.º 22
0
        void AddAliasControls()
        {
            RemoveAliasControls();

            if (IsKnown)
            {
                LeftStick  = new TwoAxisInputControl();
                RightStick = new TwoAxisInputControl();

                DPad = new TwoAxisInputControl();
                DPad.DeadZoneFunc = DeadZone.Separate;

                AddControl(InputControlType.LeftStickX, "Left Stick X");
                AddControl(InputControlType.LeftStickY, "Left Stick Y");
                AddControl(InputControlType.RightStickX, "Right Stick X");
                AddControl(InputControlType.RightStickY, "Right Stick Y");
                AddControl(InputControlType.DPadX, "DPad X");
                AddControl(InputControlType.DPadY, "DPad Y");

                                #if UNITY_PS4
                AddControl(InputControlType.Command, "OPTIONS button");
                                #else
                AddControl(InputControlType.Command, "Command");
                                #endif

                LeftCommandControl    = DeviceStyle.LeftCommandControl();
                leftCommandSource     = GetControl(LeftCommandControl);
                hasLeftCommandControl = !leftCommandSource.IsNullControl;
                if (hasLeftCommandControl)
                {
                    AddControl(InputControlType.LeftCommand, leftCommandSource.Handle);
                }

                RightCommandControl    = DeviceStyle.RightCommandControl();
                rightCommandSource     = GetControl(RightCommandControl);
                hasRightCommandControl = !rightCommandSource.IsNullControl;
                if (hasRightCommandControl)
                {
                    AddControl(InputControlType.RightCommand, rightCommandSource.Handle);
                }

                ExpireControlCache();
            }
        }
Exemplo n.º 23
0
        public string GetAppleGlyphNameForControl(InputControlType controlType)
        {
            if (InputManager.NativeInputEnableMFi && Info.vendorID == 0xffff)
            {
                var controlSource = controlSourceByTarget[(int)controlType];
                if (controlSource.SourceType != InputControlSourceType.None)
                {
                    IntPtr data;
                    UInt32 size;

                    // ReSharper disable once SwitchStatementMissingSomeEnumCasesNoDefault
                    // ReSharper disable once SwitchStatementHandlesSomeKnownEnumValuesWithDefault
                    switch (controlSource.SourceType)
                    {
                    case InputControlSourceType.Button:
                        size = Native.GetButtonGlyphName(Handle, (UInt32)controlSource.Index, out data);
                        break;

                    case InputControlSourceType.Analog:
                        size = Native.GetAnalogGlyphName(Handle, (UInt32)controlSource.Index, out data);
                        break;

                    default:
                        data = IntPtr.Zero;
                        size = 0;
                        break;
                    }

                    if (size > 0)
                    {
                        glyphName.Clear();
                        for (var i = 0; i < size; i++)
                        {
                            glyphName.Append((char)Marshal.ReadByte(data, i));
                        }

                        return(glyphName.ToString());
                    }
                }
            }

            return(defaultGlyphName);
        }
Exemplo n.º 24
0
	public void Initialize(Sprite sprite, InventoryPower power, int boardIndex){
		keyLabel = GetComponentInChildren<UILabel>();
		keyLabel.enabled = true;
		keyLabel.text = boardIndex.ToString();
		ActivationKey = boardIndex.ToString();

		associatedPower = power;
		powerIcon = GetComponent<UI2DSprite>();
		powerIcon.sprite2D = sprite;

		if(boardIndex == 1)
		{
			activationButton = InputControlType.LeftBumper;
		}
		else 
		{
			activationButton = InputControlType.RightBumper;
		}
	}
Exemplo n.º 25
0
        protected virtual void UpdateListeners()
        {
            foreach (KeyValuePair <InputControlType, HashSet <Action <InputDevice> > > pair in _listenersForInputTypes)
            {
                InputControlType type = pair.Key;

                foreach (InputDevice device in InputManager.Devices)
                {
                    if (device.GetControl(type).WasPressed)
                    {
                        // invoke callbacks
                        foreach (Action <InputDevice> a in pair.Value)
                        {
                            a(device);
                        }
                        break;
                    }
                }
            }
        }
 private InputControlType ListenForControl(BindingListenOptions listenOptions, InputDevice device)
 {
     if (device.IsKnown)
     {
         int count = device.Controls.Count;
         for (int i = 0; i < count; i++)
         {
             InputControl inputControl = device.Controls[i];
             if (inputControl != null && IsPressed(inputControl) && (listenOptions.IncludeNonStandardControls || inputControl.IsStandard))
             {
                 InputControlType target = inputControl.Target;
                 if (target != InputControlType.Command || !listenOptions.IncludeNonStandardControls)
                 {
                     return(target);
                 }
             }
         }
     }
     return(InputControlType.None);
 }
Exemplo n.º 27
0
        public VirtualControlStick( InputControlType xAxis, InputControlType yAxis )
        {
            this.xAxis = xAxis;
            this.yAxis = yAxis;

            delta = Vector2.zero;
            value = Vector2.zero;
            touchId = -1;
            alpha = 0.5f;

            baseSprite = new FSprite( "VirtualInput/StickBase" );
            baseSprite.SetAnchor( new Vector2( 0.5f, 0.5f ) );
            AddChild( baseSprite );

            headSprite = new FSprite( "VirtualInput/StickHead" );
            headSprite.SetAnchor( new Vector2( 0.5f, 0.5f ) );
            AddChild( headSprite );

            SetPosition( -Futile.screen.halfWidth + 96, -Futile.screen.halfHeight + 96 );
        }
Exemplo n.º 28
0
        public VirtualControlStick(InputControlType xAxis, InputControlType yAxis)
        {
            this.xAxis = xAxis;
            this.yAxis = yAxis;

            delta   = Vector2.zero;
            value   = Vector2.zero;
            touchId = -1;
            alpha   = 0.5f;

            baseSprite = new FSprite("VirtualInput/StickBase");
            baseSprite.SetAnchor(new Vector2(0.5f, 0.5f));
            AddChild(baseSprite);

            headSprite = new FSprite("VirtualInput/StickHead");
            headSprite.SetAnchor(new Vector2(0.5f, 0.5f));
            AddChild(headSprite);

            SetPosition(-Futile.screen.halfWidth + 96, -Futile.screen.halfHeight + 96);
        }
Exemplo n.º 29
0
    private bool IsPress(PlayerStateMgr target, InputControlType ctlType)
    {
        if (target == null || ctlType == InputControlType.none)
        {
            return(false);
        }
        var player = target.PlyDisplay;

        if (player == null)
        {
            return(false);
        }

        var plyType = player.PlyType;

        if (plyType == InputPlayerType.none)
        {
            return(false);
        }
        return(PlayerControls.GetInstance().InputCtl.GetKeyPress(player.PlyType, ctlType));
    }
Exemplo n.º 30
0
        public BindingSource Listen(BindingListenOptions listenOptions, InputDevice device)
        {
            if (!listenOptions.IncludeControllers || device.IsUnknown)
            {
                return(null);
            }

            if (detectFound != InputControlType.None)
            {
                if (!IsPressed(detectFound, device))
                {
                    if (detectPhase == 2)
                    {
                        var bindingSource = new DeviceBindingSource(detectFound);
                        Reset();
                        return(bindingSource);
                    }
                }
            }

            var control = ListenForControl(listenOptions, device);

            if (control != InputControlType.None)
            {
                if (detectPhase == 1)
                {
                    detectFound = control;
                    detectPhase = 2; // Wait for release.
                }
            }
            else
            {
                if (detectPhase == 0)
                {
                    detectPhase = 1; // Wait for press.
                }
            }

            return(null);
        }
		public BindingSource Listen( BindingListenOptions listenOptions, InputDevice device )
		{
			if (!listenOptions.IncludeControllers || device.IsUnknown)
			{
				return null;
			}

			if (detectFound != InputControlType.None)
			{
				if (!IsPressed( detectFound, device ))
				{
					if (detectPhase == 2)
					{
						var bindingSource = new DeviceBindingSource( detectFound );
						Reset();
						return bindingSource;
					}
				}
			}

			var control = ListenForControl( listenOptions, device );
			if (control != InputControlType.None)
			{
				if (detectPhase == 1)
				{
					detectFound = control;
					detectPhase = 2; // Wait for release.
				}
			}
			else
			{
				if (detectPhase == 0)
				{
					detectPhase = 1; // Wait for press.
				}
			}

			return null;
		}
Exemplo n.º 32
0
    public bool GetKeyPress(InputPlayerType playerType, InputControlType ctlype)
    {
        if (playerType == InputPlayerType.none || ctlype == InputControlType.none)
        {
            return(false);
        }
        var iter = m_KeyControlMap.GetEnumerator();

        while (iter.MoveNext())
        {
            if (GetPlayerType(iter.Current.Value) == playerType)
            {
                if (GetControlType(iter.Current.Value) == ctlype)
                {
                    KeyCode key = (KeyCode)iter.Current.Key;
                    return(Input.GetKey(key));
                }
            }
        }
        iter.Dispose();
        return(false);
    }
Exemplo n.º 33
0
    private static bool GetInput(InputControlType input, InputStateEnum timeType, InputDevice inputDevice = null)
    {
        InputDevice device = InputManager.ActiveDevice;

        if (inputDevice != null)
        {
            device = inputDevice;
        }

        switch (timeType)
        {
        case InputStateEnum.UP:
            return(device.GetControl(input).WasReleased);

        case InputStateEnum.DOWN:
            return(device.GetControl(input).WasPressed);

        case InputStateEnum.HOLD:
            return(device.GetControl(input).IsPressed);
        }
        return(false);
    }
Exemplo n.º 34
0
    void Start()
    {
        mKeyCheckBox.radioButtonRoot  = transform.parent;
        mCtrlCheckBox.radioButtonRoot = transform.parent;
        _keyToSet = KeyCode.None;
        _joyToSet = InputControlType.None;
        _bHover   = false;
        _bApply   = false;
        mKeyCheckBox.onStateChange  += SetKey;
        mCtrlCheckBox.onStateChange += SetJoy;

        this.mKeyCheckBox.IsUseSelfOnClick  = false;
        this.mCtrlCheckBox.IsUseSelfOnClick = false;
        UIEventListener.Get(this.mKeyCheckBox.gameObject).onClick   = (go) => this.OnClick(mKeyCheckBox);
        UIEventListener.Get(this.mCtrlCheckBox.gameObject).onClick  = (go) => this.OnClick(mCtrlCheckBox);
        UIEventListener.Get(this.m_ApplyKeyBtn.gameObject).onClick  = (go) => this.ApplyKeyChange();
        UIEventListener.Get(this.m_CancelKeyBtn.gameObject).onClick = (go) => this.CancelKeyChange();
        //lz-2016.12.07 添加手柄修改按键操作
        UIEventListener.Get(this.m_ApplyCtrlBtn.gameObject).onClick  = (go) => this.ApplyCtrlChange();
        UIEventListener.Get(this.m_CancelCtrlBtn.gameObject).onClick = (go) => this.CancelCtrlChange();
        UIEventListener.Get(this.mKeyCheckBox.gameObject).onHover    = (go, bHover) => _bHover = bHover;
    }
		// PRAGMA MARK - Public Interface
		public PlayerRegistrationGameSection(InputControlType registerControlType, 
																				 InputControlType finishRegistrationControlType) {
			_registerControlType = registerControlType;
			_finishRegistrationControlType = finishRegistrationControlType;
		}
Exemplo n.º 36
0
		/// <summary>
		/// A convenience method for adding a DeviceBindingSource to the default bindings.
		/// </summary>
		/// <param name="control">The InputControlType to add.</param>
		public void AddDefaultBinding( InputControlType control )
		{
			AddDefaultBinding( new DeviceBindingSource( control ) );
		}
Exemplo n.º 37
0
    bool GetControlUp(InputControlType controlType) {
        InputControl control = InputManager.ActiveDevice.GetControl(controlType);

        return control.WasReleased;
    }
Exemplo n.º 38
0
		public InputControl AddControl( InputControlType inputControlType, string handle )
		{
			var inputControl = new InputControl( handle, inputControlType );
			Controls[(int) inputControlType] = inputControl;
			return inputControl;
		}
Exemplo n.º 39
0
 bool GetControl(InputControlType controlType) {
     return (InputManager.ActiveDevice.GetControl(controlType).IsPressed);
 }
Exemplo n.º 40
0
		internal static bool TargetIsStandard( InputControlType target )
		{
			return target >= InputControlType.LeftStickUp && target <= InputControlType.RightBumper;
		}
		public DeviceBindingSource( InputControlType control )
		{
			Control = control;
		}
Exemplo n.º 42
0
		public void UpdateWithState( InputControlType inputControlType, bool state, ulong updateTick )
		{
			GetControl( inputControlType ).UpdateWithState( state, updateTick );
		}
 // Creates a Default binding on an action for both keyboard and controller inputs
 private void bindDefault( PlayerAction action, Key keyInput, InputControlType controllerInput )
 {
     action.AddDefaultBinding( keyInput );
     action.AddDefaultBinding( controllerInput );
 }
Exemplo n.º 44
0
    bool GetControlDown(InputControlType controlType) {
        InputControl control = InputManager.ActiveDevice.GetControl(controlType);

        return control.WasPressed;
    }
		bool IsPressed( InputControlType control, InputDevice device )
		{
			return IsPressed( device.GetControl( control ) );
		}
		public void Reset()
		{
			detectFound = InputControlType.None;
			detectPhase = 0; // Wait for release.
		}
Exemplo n.º 47
0
 public InputControl( string handle, InputControlType target, int player)
 {
     Handle = handle;
     Target = target;
     this.player = player;
 }
Exemplo n.º 48
0
 public InputControl( string handle, InputControlType target )
 {
     Handle = handle;
     Target = target;
 }
Exemplo n.º 49
0
		public void UpdateWithValue( InputControlType inputControlType, float value, ulong updateTick )
		{
			GetControl( inputControlType ).UpdateWithValue( value, updateTick );
		}
 internal override void Load( BinaryReader reader )
 {
     control = (InputControlType) reader.ReadInt32();
 }
Exemplo n.º 51
0
		internal static bool TargetIsButton( InputControlType target )
		{
			return (target >= InputControlType.Action1 && target <= InputControlType.Action4) || (target >= InputControlType.Button0 && target <= InputControlType.Button19);
		}
Exemplo n.º 52
0
		public InputControl AddControl( InputControlType inputControlType, string handle, float lowerDeadZone, float upperDeadZone )
		{
			var inputControl = AddControl( inputControlType, handle );
			inputControl.LowerDeadZone = lowerDeadZone;
			inputControl.UpperDeadZone = upperDeadZone;
			return inputControl;
		}
		internal DeviceBindingSource()
		{
			Control = InputControlType.None;
		}
Exemplo n.º 54
0
		internal void UpdateWithState( InputControlType inputControlType, bool state, ulong updateTick, float deltaTime )
		{
			GetControl( inputControlType ).UpdateWithState( state, updateTick, deltaTime );
		}
Exemplo n.º 55
0
 void CancelCtrlChange()
 {
     _joyToSet = _keySetting._joy;
     mCtrlCheckBox.isChecked = false;
 }
Exemplo n.º 56
0
		internal void UpdateWithValue( InputControlType inputControlType, float value, ulong updateTick, float deltaTime )
		{
			GetControl( inputControlType ).UpdateWithValue( value, updateTick, deltaTime );
		}
Exemplo n.º 57
0
 public void Set(KeySettingItem item, InputControlType keyToSet)
 {
     item._keySetting._joy  = keyToSet;
     item.mCtrlContent.text = keyToSet.ToString();
 }
Exemplo n.º 58
0
		public bool HasControl( InputControlType inputControlType )
		{
			return Controls[(int) inputControlType] != null;
		}
Exemplo n.º 59
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.º 60
0
		public InputControl GetControl( InputControlType inputControlType )
		{
			var control = Controls[(int) inputControlType];
			return control ?? InputControl.Null;
		}