Ejemplo n.º 1
0
        internal void Load(BinaryReader reader)
        {
            ClearBindings();

            var bindingCount = reader.ReadInt32();

            for (int i = 0; i < bindingCount; i++)
            {
                var bindingSourceType = (BindingSourceType)reader.ReadInt32();

                if (bindingSourceType == BindingSourceType.DeviceBindingSource)
                {
                    var binding = new DeviceBindingSource();
                    binding.Load(reader);
                    AddBinding(binding);
                }

                if (bindingSourceType == BindingSourceType.KeyBindingSource)
                {
                    var binding = new KeyBindingSource();
                    binding.Load(reader);
                    AddBinding(binding);
                }

                if (bindingSourceType == BindingSourceType.MouseBindingSource)
                {
                    var binding = new MouseBindingSource();
                    binding.Load(reader);
                    AddBinding(binding);
                }
            }
        }
        public override bool Equals(BindingSource other)
        {
            if (other == null)
            {
                return(false);
            }
            DeviceBindingSource deviceBindingSource = other as DeviceBindingSource;

            if (deviceBindingSource != null)
            {
                return(Control == deviceBindingSource.Control);
            }
            return(false);
        }
Ejemplo n.º 3
0
        internal void Load(BinaryReader reader)
        {
            ClearBindings();

            var bindingCount = reader.ReadInt32();

            for (var i = 0; i < bindingCount; i++)
            {
                var           bindingSourceType = (BindingSourceType)reader.ReadInt32();
                BindingSource bindingSource;

                switch (bindingSourceType)
                {
                case BindingSourceType.None:
                    continue;

                case BindingSourceType.DeviceBindingSource:
                    bindingSource = new DeviceBindingSource();
                    break;

                case BindingSourceType.KeyBindingSource:
                    bindingSource = new KeyBindingSource();
                    break;

                case BindingSourceType.MouseBindingSource:
                    bindingSource = new MouseBindingSource();
                    break;

                case BindingSourceType.UnknownDeviceBindingSource:
                    bindingSource = new UnknownDeviceBindingSource();
                    break;

                default:
                    throw new InControlException("Don't know how to load BindingSourceType: " + bindingSourceType);
                }

                bindingSource.Load(reader);
                AddBinding(bindingSource);
            }
        }
        public BindingSource Listen(BindingListenOptions listenOptions, InputDevice device)
        {
            if (!listenOptions.IncludeControllers)
            {
                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;
		}
Ejemplo n.º 6
0
        internal void Load(BinaryReader reader, ushort dataFormatVersion)
        {
            ClearBindings();
            int num = reader.ReadInt32();

            for (int i = 0; i < num; i++)
            {
                BindingSourceType bindingSourceType = (BindingSourceType)reader.ReadInt32();
                BindingSource     bindingSource;
                switch (bindingSourceType)
                {
                case BindingSourceType.DeviceBindingSource:
                    bindingSource = new DeviceBindingSource();
                    break;

                case BindingSourceType.KeyBindingSource:
                    bindingSource = new KeyBindingSource();
                    break;

                case BindingSourceType.MouseBindingSource:
                    bindingSource = new MouseBindingSource();
                    break;

                case BindingSourceType.UnknownDeviceBindingSource:
                    bindingSource = new UnknownDeviceBindingSource();
                    break;

                default:
                    throw new InControlException("Don't know how to load BindingSourceType: " + bindingSourceType);

                case BindingSourceType.None:
                    continue;
                }
                bindingSource.Load(reader, dataFormatVersion);
                AddBinding(bindingSource);
            }
        }
Ejemplo n.º 7
0
		internal void Load( BinaryReader reader )
		{
			ClearBindings();

			var bindingCount = reader.ReadInt32();
			for (int i = 0; i < bindingCount; i++)
			{
				var bindingSourceType = (BindingSourceType) reader.ReadInt32();

				if (bindingSourceType == BindingSourceType.DeviceBindingSource)
				{
					var binding = new DeviceBindingSource();
					binding.Load( reader );
					AddBinding( binding );
				}

				if (bindingSourceType == BindingSourceType.KeyBindingSource)
				{
					var binding = new KeyBindingSource();
					binding.Load( reader );
					AddBinding( binding );
				}

				if (bindingSourceType == BindingSourceType.MouseBindingSource)
				{
					var binding = new MouseBindingSource();
					binding.Load( reader );
					AddBinding( binding );
				}
			}
		}
Ejemplo n.º 8
0
		internal void Load( BinaryReader reader )
		{
			ClearBindings();

			var bindingCount = reader.ReadInt32();
			for (int i = 0; i < bindingCount; i++)
			{
				var bindingSourceType = (BindingSourceType) reader.ReadInt32();
				BindingSource bindingSource;

				switch (bindingSourceType)
				{
					case BindingSourceType.DeviceBindingSource:
						bindingSource = new DeviceBindingSource();
						break;

					case BindingSourceType.KeyBindingSource:
						bindingSource = new KeyBindingSource();
						break;

					case BindingSourceType.MouseBindingSource:
						bindingSource = new MouseBindingSource();
						break;
					
					case BindingSourceType.UnknownDeviceBindingSource:
						bindingSource = new UnknownDeviceBindingSource();
						break;

					default:
						throw new InControlException( "Don't know how to load BindingSourceType: " + bindingSourceType );
				}

				bindingSource.Load( reader );
				AddBinding( bindingSource );
			}
		}