Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
VirtualButtonTwoWay.cs
Go to the documentation of this file.
1 // Copyright (c) 2014 Silicon Studio Corp. (http://siliconstudio.co.jp)
2 // This file is distributed under GPL v3. See LICENSE.md for details.
3 namespace SiliconStudio.Paradox.Input
4 {
5  /// <summary>
6  /// Describes a <see cref="IVirtualButton"/> using the sum of a negative and positive button.
7  /// </summary>
8  /// <remarks>
9  /// This virtual button is for example useful to bind a key to a negative value (key 'left')
10  /// and another key to a positive value (key 'right') thus simulating an axis button.
11  /// The result of this virtual
12  /// <code>Result = PositiveButton.GetValue - NegativeButton.GetValue;</code>
13  /// </remarks>
15  {
16  /// <summary>
17  /// Initializes a new instance of the <see cref="VirtualButtonTwoWay" /> class.
18  /// </summary>
20  {
21  }
22 
23  /// <summary>
24  /// Initializes a new instance of the <see cref="VirtualButtonTwoWay" /> class.
25  /// </summary>
26  /// <param name="negativeButton">The negative button.</param>
27  /// <param name="positiveButton">The positive button.</param>
28  public VirtualButtonTwoWay(IVirtualButton negativeButton, IVirtualButton positiveButton)
29  {
30  NegativeButton = negativeButton;
31  PositiveButton = positiveButton;
32  }
33 
34  /// <summary>
35  /// Gets or sets the negative button that will generate a 'negative' value if it is pressed.
36  /// </summary>
37  /// <value>The negative button.</value>
38  public IVirtualButton NegativeButton { get; set; }
39 
40  /// <summary>
41  /// Gets or sets the positive button that will generate a 'positive' value if it is pressed.
42  /// </summary>
43  /// <value>The positive button.</value>
44  public IVirtualButton PositiveButton { get; set; }
45 
46  public virtual float GetValue(InputManagerBase manager)
47  {
48  float negativeValue = ((NegativeButton != null) ? NegativeButton.GetValue(manager) : 0.0f);
49  float positiveValue = (PositiveButton != null) ? PositiveButton.GetValue(manager) : 0.0f;
50  return positiveValue - negativeValue;
51  }
52 
53  public override string ToString()
54  {
55  return string.Format("<{0} , {1}>", NegativeButton, PositiveButton);
56  }
57  }
58 }
VirtualButtonTwoWay(IVirtualButton negativeButton, IVirtualButton positiveButton)
Initializes a new instance of the VirtualButtonTwoWay class.
Interface for input management system, including keyboard, mouse, gamepads and touch.
Describes a IVirtualButton using the sum of a negative and positive button.
VirtualButtonTwoWay()
Initializes a new instance of the VirtualButtonTwoWay class.
virtual float GetValue(InputManagerBase manager)
Gets the value associated with this virtual button from an input manager.
A combination of IVirtualButton, by default evaluated as the operator '&&' to produce a value if all ...