예제 #1
0
		public InputControl AddControl( InputControlType target, string handle )
		{
			var controlIndex = (int) target;
			var inputControl = new InputControl( handle, target );
			Controls[controlIndex] = inputControl;
			return inputControl;
		}
예제 #2
0
		public InputDevice( string name )
		{
			Name = name;
			Meta = "";

			LastChangeTick = 0;

			const int numInputControlTypes = (int) InputControlType.Count + 1;
			Controls = new InputControl[numInputControlTypes];

			LeftStickX = new OneAxisInputControl();
			LeftStickY = new OneAxisInputControl();
			LeftStick = new TwoAxisInputControl();
			LeftStick.LowerDeadZone = 0.2f;

			RightStickX = new OneAxisInputControl();
			RightStickY = new OneAxisInputControl();
			RightStick = new TwoAxisInputControl();
			RightStick.LowerDeadZone = 0.2f;

			DPadX = new OneAxisInputControl();
			DPadY = new OneAxisInputControl();
			DPad = new TwoAxisInputControl();
			DPad.LowerDeadZone = 0.2f;

			Command = AddControl( InputControlType.Command, "Command" );
		}
		internal void CommitWithSides( InputControl negativeSide, InputControl positiveSide, ulong updateTick, float deltaTime )
		{
			LowerDeadZone = Mathf.Max( negativeSide.LowerDeadZone, positiveSide.LowerDeadZone );
			UpperDeadZone = Mathf.Min( negativeSide.UpperDeadZone, positiveSide.UpperDeadZone );
			Raw = negativeSide.Raw || positiveSide.Raw;
			var value = Utility.ValueFromSides( negativeSide.RawValue, positiveSide.RawValue );
			CommitWithValue( value, updateTick, deltaTime );
		}
예제 #4
0
		internal void CommitWithSides( InputControl negativeSide, InputControl positiveSide, ulong updateTick, float deltaTime, bool invertSides )
		{
			if (invertSides)
			{
				CommitWithSides( positiveSide, negativeSide, updateTick, deltaTime );
			}
			else
			{
				CommitWithSides( negativeSide, positiveSide, updateTick, deltaTime );
			}
		}
예제 #5
0
        public InputDevice( string name, int analogCount = 0, int buttonCount = 0 )
        {
            Name = name;
            Meta = "";

            Analogs = new InputControl[ analogCount ];
            Buttons = new InputControl[ buttonCount ];

            LastChangeTime = 0.0f;

            const int numInputControlTypes = (int) InputControlType.Count + 1;
            controlTable = new InputControl[ numInputControlTypes ];
        }
예제 #6
0
 public static void CheckButtonEvents(IC.InputControlType type,
                                      IC.InputDevice device,
                                      GameObject player,
                                      Message?pressedEvent  = null,
                                      Message?releasedEvent = null)
 {
     if (device != null)
     {
         IC.InputControl button = device.GetControl(type);
         SendButtonEvent(button.WasPressed, button.WasReleased,
                         player, pressedEvent, releasedEvent);
     }
 }
예제 #7
0
        public InputDevice( string name )
        {
            Name = name;
            Meta = "";

            LastChangeTick = 0;

            const int numInputControlTypes = (int) InputControlType.Count + 1;
            Controls = new InputControl[numInputControlTypes];

            LeftStick = new TwoAxisInputControl();
            RightStick = new TwoAxisInputControl();
            DPad = new TwoAxisInputControl();
        }
예제 #8
0
        public InputDevice(string name)
        {
            Name = name;
            Meta = "";

            LastChangeTick = 0;

            int numInputControlTypes = Enum.GetValues(typeof(InputControlTarget)).Length;
            Controls = new InputControl[numInputControlTypes];

            LeftStick = new TwoAxisInputControl();
            RightStick = new TwoAxisInputControl();
            DPad = new TwoAxisInputControl();
        }
예제 #9
0
		public InputControl AddControl( InputControlType inputControlType, string handle )
		{
			var inputControl = new InputControl( handle, inputControlType );
			Controls[(int) inputControlType] = inputControl;
			return inputControl;
		}
예제 #10
0
 public void SetButtonControl( int i, Enum target, string handle = "" )
 {
     Buttons[i] = new InputControl( handle, target.ToString() );
     var controlIndex = Convert.ToInt32( target );
     controlTable[controlIndex] = Buttons[i];
 }
예제 #11
0
        public InputControl GetControl(InputControlType controlType)
        {
            InputControl inputControl = ControlsByTarget[(int)controlType];

            return(inputControl ?? InputControl.Null);
        }
		bool IsPressed( InputControl control )
		{
			return Utility.AbsoluteIsOverThreshold( control.Value, 0.5f );
		}
예제 #13
0
        void Initialize( string name, int analogCount, int buttonCount )
        {
            Name = name;
            Meta = "";

            Analogs = new InputControl[analogCount];
            Buttons = new InputControl[buttonCount];

            LastChangeTime = 0.0f;

            const int numInputControlTypes = (int) InputControlType.Count + 1;
            controlTable = new InputControl[numInputControlTypes];
        }
예제 #14
0
 public void SetAnalogControl( int i, Enum target, string handle )
 {
     Analogs[i] = new InputControl( handle, target.ToString() );
     var controlIndex = Convert.ToInt32( target );
     controlTable[controlIndex] = Analogs[i];
 }
예제 #15
0
		float ProcessAnalogControlValue( InputControl control, float deltaTime )
		{
			var analogValue = control.PreValue.Value;

			var obverseTarget = control.Obverse;
			if (obverseTarget.HasValue)
			{
				var obverseControl = GetControl( obverseTarget );
				analogValue = ApplyCircularDeadZone( analogValue, obverseControl.PreValue.Value, control.LowerDeadZone, control.UpperDeadZone );
			}
			else
			{
				analogValue = ApplyDeadZone( analogValue, control.LowerDeadZone, control.UpperDeadZone );
			}

			return ApplySmoothing( analogValue, control.LastValue, deltaTime, control.Sensitivity );
		}
예제 #16
0
 public InputControl AddControl(InputControlTarget inputControlTarget, string handle)
 {
     var inputControl = new InputControl(handle, inputControlTarget);
     Controls[(int) inputControlTarget] = inputControl;
     return inputControl;
 }
예제 #17
0
	public InputControl AddControl( InputControlType target, string handle, int player = -1 ) {
		var inputControl = new InputControl( handle, target, player );
		Controls.Add(inputControl);
		return inputControl;
	}