• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# InControl.InputDevice类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中InControl.InputDevice的典型用法代码示例。如果您正苦于以下问题:C# InputDevice类的具体用法?C# InputDevice怎么用?C# InputDevice使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



InputDevice类属于InControl命名空间,在下文中一共展示了InputDevice类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: GetValue

		public override float GetValue( InputDevice inputDevice )
		{
			var scale = 0.2f;

			switch (Control)
			{
				case Mouse.LeftButton:
					return Input.GetMouseButton( 0 ) ? 1.0f : 0.0f;
				case Mouse.RightButton:
					return Input.GetMouseButton( 1 ) ? 1.0f : 0.0f;
				case Mouse.MiddleButton:
					return Input.GetMouseButton( 2 ) ? 1.0f : 0.0f;
				case Mouse.NegativeX:
					return -Mathf.Min( Input.GetAxisRaw( "mouse x" ) * scale, 0.0f );
				case Mouse.PositiveX:
					return Mathf.Max( 0.0f, Input.GetAxisRaw( "mouse x" ) * scale );
				case Mouse.NegativeY:
					return -Mathf.Min( Input.GetAxisRaw( "mouse y" ) * scale, 0.0f );
				case Mouse.PositiveY:
					return Mathf.Max( 0.0f, Input.GetAxisRaw( "mouse y" ) * scale );
				case Mouse.NegativeScrollWheel:
					return -Mathf.Min( Input.GetAxisRaw( "mouse z" ) * scale, 0.0f );
				case Mouse.PositiveScrollWheel:
					return Mathf.Max( 0.0f, Input.GetAxisRaw( "mouse z" ) * scale );
			}

			return 0.0f;
		}
开发者ID:ForsakenGS,项目名称:LostKids,代码行数:28,代码来源:MouseBindingSource.cs


示例2: ListenForControl

		InputControlType ListenForControl( BindingListenOptions listenOptions, InputDevice device )
		{
			if (device.IsKnown)
			{
				var controlCount = device.Controls.Length;
				for (int i = 0; i < controlCount; i++)
				{
					var control = device.Controls[i];
					if (control != null && IsPressed( control ))
					{
						if (listenOptions.IncludeNonStandardControls || control.IsStandard)
						{
							var target = control.Target;
							if (target == InputControlType.Command && listenOptions.IncludeNonStandardControls)
							{
								continue;
							}
							return target;
						}
					}
				}
			}

			return InputControlType.None;
		}
开发者ID:DarrenTsung,项目名称:simple-clicker,代码行数:25,代码来源:DeviceBindingSourceListener.cs


示例3: UpdateCubeWithInputDevice

		void UpdateCubeWithInputDevice( InputDevice inputDevice )
		{
			// Set object material color based on which action is pressed.
			if (inputDevice.Action1)
			{
				GetComponent<Renderer>().material.color = Color.green;
			}
			else
			if (inputDevice.Action2)
			{
				GetComponent<Renderer>().material.color = Color.red;
			}
			else
			if (inputDevice.Action3)
			{
				GetComponent<Renderer>().material.color = Color.blue;
			}
			else
			if (inputDevice.Action4)
			{
				GetComponent<Renderer>().material.color = Color.yellow;
			}
			else
			{
				GetComponent<Renderer>().material.color = Color.white;
			}
			
			// Rotate target object with both sticks and d-pad.
			transform.Rotate( Vector3.down,  500.0f * Time.deltaTime * inputDevice.Direction.X, Space.World );
			transform.Rotate( Vector3.right, 500.0f * Time.deltaTime * inputDevice.Direction.Y, Space.World );
			transform.Rotate( Vector3.down,  500.0f * Time.deltaTime * inputDevice.RightStickX, Space.World );
			transform.Rotate( Vector3.right, 500.0f * Time.deltaTime * inputDevice.RightStickY, Space.World );
		}
开发者ID:ForsakenGS,项目名称:LostKids,代码行数:33,代码来源:CubeController.cs


示例4: GetValue

		public override float GetValue( InputDevice inputDevice )
		{
			var button = buttonTable[(int) Control];
			if (button >= 0)
			{
				return Input.GetMouseButton( button ) ? 1.0f : 0.0f;
			}

			switch (Control)
			{
				case Mouse.NegativeX:
					return -Mathf.Min( Input.GetAxisRaw( "mouse x" ) * ScaleX, 0.0f );
				case Mouse.PositiveX:
					return Mathf.Max( 0.0f, Input.GetAxisRaw( "mouse x" ) * ScaleX );

				case Mouse.NegativeY:
					return -Mathf.Min( Input.GetAxisRaw( "mouse y" ) * ScaleY, 0.0f );
				case Mouse.PositiveY:
					return Mathf.Max( 0.0f, Input.GetAxisRaw( "mouse y" ) * ScaleY );

				case Mouse.NegativeScrollWheel:
					return -Mathf.Min( Input.GetAxisRaw( "mouse z" ) * ScaleZ, 0.0f );
				case Mouse.PositiveScrollWheel:
					return Mathf.Max( 0.0f, Input.GetAxisRaw( "mouse z" ) * ScaleZ );
			}

			return 0.0f;
		}
开发者ID:pencilking2002,项目名称:TOF_Movement_Protype,代码行数:28,代码来源:MouseBindingSource.cs


示例5: TryRegisterDevice

        public void TryRegisterDevice(InputDevice device)
        {
            if (IsDeviceAdded(device))
            {
                return;
            }

            int playerId = -1;
            if (isXInputDevice(device))
            {
                XInputDevice xInputDevice = device as XInputDevice;
                playerId = xInputDevice.DeviceIndex;
            }
            else
            {
                playerId = NextId;
            }

            if (playerId >= 0)
            {
                PlayerDevice newPlayer = new PlayerDevice()
                {
                    id = playerId,
                    InControlDevice = device
                };
                AddPlayer(newPlayer);
            }
        }
开发者ID:paulkelly,项目名称:GGJ2016,代码行数:28,代码来源:MultiInputManager.cs


示例6: VirtualControlInputDeviceManager

        public VirtualControlInputDeviceManager()
        {
            device = new InputDevice( "VirtualControlInputDevice", 2, 2 );
            device.AddAnalogControl( InputControlType.LeftStickX, "Virtual Stick" );
            device.AddAnalogControl( InputControlType.LeftStickY, "Virtual Stick" );
            device.AddButtonControl( InputControlType.Action1, "Virtual Button 1" );
            device.AddButtonControl( InputControlType.Action2, "Virtual Button 2" );
            InputManager.AttachDevice( device );

            var virtualStick = new VirtualControlStick( InputControlType.LeftStickX, InputControlType.LeftStickY );
            Node.AddChild( virtualStick );
            virtualControls.Add( virtualStick );

            var buttonPosition1 = new Vector2( Futile.screen.halfWidth - 128, -Futile.screen.halfHeight + 64 );
            var virtualButton1 = new VirtualControlButton( InputControlType.Action1, "VirtualInput/ButtonA", buttonPosition1 );
            Node.AddChild( virtualButton1 );
            virtualControls.Add( virtualButton1 );

            var buttonPosition2 = new Vector2( Futile.screen.halfWidth - 64, -Futile.screen.halfHeight + 128 );
            var virtualButton2 = new VirtualControlButton( InputControlType.Action2, "VirtualInput/ButtonB", buttonPosition2 );
            Node.AddChild( virtualButton2 );
            virtualControls.Add( virtualButton2 );

            Futile.touchManager.AddMultiTouchTarget( this );
        }
开发者ID:hiyijia,项目名称:InControl,代码行数:25,代码来源:VirtualControlInputDeviceManager.cs


示例7: GetColorFromActionButtons

        Color GetColorFromActionButtons( InputDevice inputDevice )
        {
            if (inputDevice.Action1)
            {
                return Color.green;
            }

            if (inputDevice.Action2)
            {
                return Color.red;
            }

            if (inputDevice.Action3)
            {
                return Color.blue;
            }

            if (inputDevice.Action4)
            {
                return Color.yellow;
            }

            // Test for a combo keypress, mapped to left bumper.
            if (inputDevice.LeftBumper)
            {
                return Color.magenta;
            }

            return Color.white;
        }
开发者ID:HouraiTeahouse,项目名称:HouraiInput,代码行数:30,代码来源:CubeController.cs


示例8: CreatePlayer

        Player CreatePlayer( InputDevice inputDevice )
        {
            if (players.Count < maxPlayers)
            {
                // Pop a position off the list. We'll add it back if the player is removed.
                var playerPosition = playerPositions[0];
                playerPositions.RemoveAt( 0 );

                var gameObject = (GameObject) Instantiate( playerPrefab, playerPosition, Quaternion.identity );
                var player = gameObject.GetComponent<Player>();

                if (inputDevice == null)
                {
                    // We could create a new instance, but might as well reuse the one we have
                    // and it lets us easily find the keyboard player.
                    player.Actions = keyboardListener;
                }
                else
                {
                    // Create a new instance and specifically set it to listen to the
                    // given input device (joystick).
                    var actions = PlayerActions.CreateWithJoystickBindings();
                    actions.Device = inputDevice;

                    player.Actions = actions;
                }

                players.Add( player );

                return player;
            }

            return null;
        }
开发者ID:matiasfr,项目名称:Hattrick,代码行数:34,代码来源:PlayerManager.cs


示例9: GetState

		public override bool GetState( InputDevice inputDevice )
		{
			if (inputDevice == null)
			{
				return false;
			}

			return inputDevice.GetControl( Control ).State;
		}
开发者ID:DarrenTsung,项目名称:simple-clicker,代码行数:9,代码来源:DeviceBindingSource.cs


示例10: GetValue

		public override float GetValue( InputDevice inputDevice )
		{
			if (inputDevice == null)
			{
				return 0.0f;
			}

			return inputDevice.GetControl( Control ).Value;
		}
开发者ID:DarrenTsung,项目名称:simple-clicker,代码行数:9,代码来源:DeviceBindingSource.cs


示例11: GetState

		public override bool GetState( InputDevice device )
		{
			if (device == null)
			{
				return false;
			}

			return Utility.IsNotZero( GetValue( device ) );
		}
开发者ID:DarrenTsung,项目名称:simple-clicker,代码行数:9,代码来源:UnknownDeviceBindingSource.cs


示例12: GetState

		public bool GetState( InputDevice inputDevice )
		{
			for (int i = 0; i < KeyCodeList.Length; i++)
			{
				if (!Input.GetKey( KeyCodeList[i] ))
				{
					return false;
				}
			}
			return true;
		}
开发者ID:DarrenTsung,项目名称:simple-clicker,代码行数:11,代码来源:UnityKeyCodeComboSource.cs


示例13: GetState

        public override bool GetState( InputDevice inputDevice )
        {
            foreach(InputControlSource source in sources)
            {
                if(source.GetState( inputDevice ))
                {
                    return true;
                }
            }

            return false;
        }
开发者ID:nihilocrat,项目名称:InControl,代码行数:12,代码来源:MultiSource.cs


示例14: Update

        public void Update( IEnumerable<FTouch> touches, InputDevice device, float updateTime )
        {
            value = 0.0f;

            foreach (var touch in touches)
            {
                UpdateWithTouch( touch );
            }

            device.GetControl( controlType ).UpdateWithValue( value, updateTime );

            alpha = Mathf.MoveTowards( alpha, value > 0.0f ? 1.0f : 0.5f, 1.0f / 15.0f );
        }
开发者ID:hiyijia,项目名称:InControl,代码行数:13,代码来源:VirtualControlButton.cs


示例15: FindPlayerUsingDevice

        GolfPlayerController FindPlayerUsingDevice( InputDevice inputDevice )
        {
            var playerCount = players.Count;
            for (int i = 0; i < playerCount; i++)
            {
                var player = players[i];
                if (player.device == inputDevice)
                {
                    return player;
                }
            }

            return null;
        }
开发者ID:SuperActionSports,项目名称:maingame,代码行数:14,代码来源:PlayerManager.cs


示例16: Update

        public void Update( IEnumerable<FTouch> touches, InputDevice device, float updateTime )
        {
            foreach (var touch in touches)
            {
                UpdateWithTouch( touch );
            }

            device.GetControl( xAxis ).UpdateWithValue( value.x, updateTime );
            device.GetControl( yAxis ).UpdateWithValue( value.y, updateTime );

            alpha = Mathf.MoveTowards( alpha, touchId == -1 ? 0.5f : 1.0f, 1.0f / 15.0f );

            headSprite.SetPosition( delta );
        }
开发者ID:hiyijia,项目名称:InControl,代码行数:14,代码来源:VirtualControlStick.cs


示例17: FindPlayerUsingJoystick

        Player FindPlayerUsingJoystick( InputDevice inputDevice )
        {
            var playerCount = players.Count;
            for (int i = 0; i < playerCount; i++)
            {
                var player = players[i];
                if (player.Actions.Device == inputDevice)
                {
                    return player;
                }
            }

            return null;
        }
开发者ID:matiasfr,项目名称:Hattrick,代码行数:14,代码来源:PlayerManager.cs


示例18: GetValue

		public override float GetValue( InputDevice inputDevice )
		{
			int axisValue = 0;
			
			if (Input.GetKey( negativeKeyCode ))
			{
				axisValue--;
			}
			
			if (Input.GetKey( positiveKeyCode ))
			{
				axisValue++;
			}
			
			return axisValue;
		}
开发者ID:Cyberbanan,项目名称:LD29,代码行数:16,代码来源:UnityKeyCodeAxisSource.cs


示例19: GetValue

        public override float GetValue( InputDevice inputDevice )
        {
            // CAVEAT: multiple input sources could be giving values, but we only want one
            //   thus, we'll take the first one in the list
            //   so the user can control priority simply by ordering the list
            foreach(InputControlSource source in sources)
            {
                var thisValue = source.GetValue( inputDevice );
                if(thisValue != 0f)
                {
                    return thisValue;
                }
            }

            return 0f;
        }
开发者ID:nihilocrat,项目名称:InControl,代码行数:16,代码来源:MultiSource.cs


示例20: GetValue

		public float GetValue( InputDevice inputDevice )
		{
			int axisValue = 0;
			
			if (Input.GetKey( NegativeKeyCode ))
			{
				axisValue--;
			}
			
			if (Input.GetKey( PositiveKeyCode ))
			{
				axisValue++;
			}
			
			return axisValue;
		}
开发者ID:ForsakenGS,项目名称:LostKids,代码行数:16,代码来源:UnityKeyCodeAxisSource.cs



注:本文中的InControl.InputDevice类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Sockets.BluetoothClient类代码示例发布时间:2022-05-26
下一篇:
C# Impl.AccountEndpoint类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap