本文整理汇总了C#中InControl.InputDevice类的典型用法代码示例。如果您正苦于以下问题:C# InputDevice类的具体用法?C# InputDevice怎么用?C# InputDevice使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
InputDevice类属于InControl命名空间,在下文中一共展示了InputDevice类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
示例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 );
}
示例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;
}
示例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);
}
}
示例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 );
}
示例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;
}
示例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;
}
示例9: GetState
public override bool GetState( InputDevice inputDevice )
{
if (inputDevice == null)
{
return false;
}
return inputDevice.GetControl( Control ).State;
}
示例10: GetValue
public override float GetValue( InputDevice inputDevice )
{
if (inputDevice == null)
{
return 0.0f;
}
return inputDevice.GetControl( Control ).Value;
}
示例11: GetState
public override bool GetState( InputDevice device )
{
if (device == null)
{
return false;
}
return Utility.IsNotZero( GetValue( device ) );
}
示例12: GetState
public bool GetState( InputDevice inputDevice )
{
for (int i = 0; i < KeyCodeList.Length; i++)
{
if (!Input.GetKey( KeyCodeList[i] ))
{
return false;
}
}
return true;
}
示例13: GetState
public override bool GetState( InputDevice inputDevice )
{
foreach(InputControlSource source in sources)
{
if(source.GetState( inputDevice ))
{
return true;
}
}
return false;
}
示例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 );
}
示例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;
}