コード例 #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);
                }
            }
        }
コード例 #2
0
 Mouse ListenForControl()
 {
     for (var control = Mouse.None; control <= Mouse.Button9; control++)
     {
         if (MouseBindingSource.ButtonIsPressed(control))
         {
             return(control);
         }
     }
     return(Mouse.None);
 }
コード例 #3
0
        public override bool Equals(object other)
        {
            if (other == null)
            {
                return(false);
            }
            MouseBindingSource mouseBindingSource = other as MouseBindingSource;

            if (mouseBindingSource != null)
            {
                return(Control == mouseBindingSource.Control);
            }
            return(false);
        }
コード例 #4
0
        public BindingSource Listen(BindingListenOptions listenOptions, InputDevice device)
        {
            if (!listenOptions.IncludeMouseButtons)
            {
                return(null);
            }

            if (detectFound != Mouse.None)
            {
                if (!IsPressed(detectFound))
                {
                    if (detectPhase == 2)
                    {
                        var bindingSource = new MouseBindingSource(detectFound);
                        Reset();
                        return(bindingSource);
                    }
                }
            }

            var control = ListenForControl();

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

            return(null);
        }
コード例 #5
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);
            }
        }
コード例 #6
0
		public BindingSource Listen( BindingListenOptions listenOptions, InputDevice device )
		{
			if (!listenOptions.IncludeMouseButtons)
			{
				return null;
			}

			if (detectFound != Mouse.None)
			{
				if (!MouseBindingSource.ButtonIsPressed( detectFound ))
				{
					if (detectPhase == 2)
					{
						var bindingSource = new MouseBindingSource( detectFound );
						Reset();
						return bindingSource;
					}
				}
			}

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

			return null;
		}
コード例 #7
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);
            }
        }
コード例 #8
0
ファイル: PlayerAction.cs プロジェクト: ForsakenGS/LostKids
		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 );
				}
			}
		}
コード例 #9
0
ファイル: PlayerAction.cs プロジェクト: n0dens/ggj16
		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 );
			}
		}