Skip to content

Commit 3fa6668

Browse files
devvoidPerksey
authored andcommitted
Document Input.Common (#19)
* Start of Input.ComCommon documentation * Start of Input.Common documentation * Document most structs * Remove mention of d-pad * Change some key names for parity with input * Make Position2D powers of two * Document enums * Document interfaces and Deadzone * Correct template mistake * Document Thumbstick * Update src/Input/Silk.NET.Input.Common/Enums/DeadzoneMethod.cs Co-Authored-By: Dylan Perks <dylanperks23@gmail.com> * Update src/Input/Silk.NET.Input.Common/Enums/DeadzoneMethod.cs Co-Authored-By: Dylan Perks <dylanperks23@gmail.com> * Update src/Input/Silk.NET.Input.Common/Enums/DeadzoneMethod.cs Co-Authored-By: Dylan Perks <dylanperks23@gmail.com> * Update src/Input/Silk.NET.Input.Common/Enums/Key.cs Co-Authored-By: Dylan Perks <dylanperks23@gmail.com> * Update src/Input/Silk.NET.Input.Common/Interfaces/IGamepad.cs Co-Authored-By: Dylan Perks <dylanperks23@gmail.com> * Update src/Input/Silk.NET.Input.Common/Interfaces/IJoystick.cs Co-Authored-By: Dylan Perks <dylanperks23@gmail.com> * Update src/Input/Silk.NET.Input.Common/Interfaces/IGamepad.cs Co-Authored-By: Dylan Perks <dylanperks23@gmail.com> * Update src/Input/Silk.NET.Input.Common/Interfaces/IJoystick.cs Co-Authored-By: Dylan Perks <dylanperks23@gmail.com> * Update src/Input/Silk.NET.Input.Common/Interfaces/IJoystick.cs Co-Authored-By: Dylan Perks <dylanperks23@gmail.com> * Update src/Input/Silk.NET.Input.Common/Interfaces/IInputPlatform.cs Co-Authored-By: Dylan Perks <dylanperks23@gmail.com> * Update src/Input/Silk.NET.Input.Common/Interfaces/IJoystick.cs Co-Authored-By: Dylan Perks <dylanperks23@gmail.com> * Update src/Input/Silk.NET.Input.Common/Interfaces/IJoystick.cs Co-Authored-By: Dylan Perks <dylanperks23@gmail.com> * Update IMouse.cs
1 parent 6951f04 commit 3fa6668

File tree

21 files changed

+396
-41
lines changed

21 files changed

+396
-41
lines changed

documentation/proposals/Proposal - Input.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public interface IGamepad : IInputDevice
4949
event Action<IGamepad, Button> ButtonDown;
5050
event Action<IGamepad, Button> ButtonUp;
5151
event Action<IGamepad, Thumbstick> ThumbstickMoved;
52-
event Action<IGamepad, Thumbstick> TriggerMoved;
52+
event Action<IGamepad, Trigger> TriggerMoved;
5353
}
5454
```
5555

src/Input/Silk.NET.Input.Common/Axis.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,26 @@
55

66
namespace Silk.NET.Input.Common
77
{
8+
/// <summary>
9+
/// Represents an axis on a joystick.
10+
/// </summary>
811
public struct Axis
912
{
13+
/// <summary>
14+
/// The index of this axis, used to determine which axis it is.
15+
/// </summary>
1016
public int Index { get; }
17+
18+
/// <summary>
19+
/// The position of this axis.
20+
/// </summary>
1121
public float Position { get; }
1222

23+
/// <summary>
24+
/// Creates a new instance of the Axis struct.
25+
/// </summary>
26+
/// <param name="index">The index of the new axis.</param>
27+
/// <param name="position">The position of the new axis.</param>
1328
public Axis(int index, float position)
1429
{
1530
Index = index;

src/Input/Silk.NET.Input.Common/Button.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,24 @@
55

66
namespace Silk.NET.Input.Common
77
{
8+
/// <summary>
9+
/// Represents a joystick button.
10+
/// </summary>
811
public struct Button
912
{
13+
/// <summary>
14+
/// The name of this button. Only guaranteed to be valid if this comes from an <see cref="IGamepad"/>.
15+
/// </summary>
1016
public ButtonName Name { get; }
17+
18+
/// <summary>
19+
/// The index of this button. Use this if this button comes from an <see cref="IJoystick"/>.
20+
/// </summary>
1121
public int Index { get; }
22+
23+
/// <summary>
24+
/// Whether or not this button is currently pressed.
25+
/// </summary>
1226
public bool Pressed { get; }
1327

1428
public Button(ButtonName name, int index, bool pressed)

src/Input/Silk.NET.Input.Common/Deadzone.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,26 @@
55

66
namespace Silk.NET.Input.Common
77
{
8+
/// <summary>
9+
/// The deadzone to use for a joystick/gamepad's sticks.
10+
/// </summary>
811
public struct Deadzone
912
{
13+
/// <summary>
14+
/// The size of the deadzone to use.
15+
/// </summary>
1016
public float Value { get; }
17+
18+
/// <summary>
19+
/// The deadzone method to use.
20+
/// </summary>
1121
public DeadzoneMethod Method { get; }
1222

23+
/// <summary>
24+
/// Creates a new instance of the Deadzone struct.
25+
/// </summary>
26+
/// <param name="value">The deadzone size.</param>
27+
/// <param name="method">The deadzone method.</param>
1328
public Deadzone(float value, DeadzoneMethod method)
1429
{
1530
Value = value;

src/Input/Silk.NET.Input.Common/Enums/ButtonName.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55

66
namespace Silk.NET.Input.Common
77
{
8+
/// <summary>
9+
/// The different names a <see cref="Button"/> can have.
10+
/// </summary>
811
public enum ButtonName
912
{
1013
A,

src/Input/Silk.NET.Input.Common/Enums/DeadzoneMethod.cs

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,36 @@
55

66
namespace Silk.NET.Input.Common
77
{
8+
/// <summary>
9+
/// Available methods to control the deadzone of a control stick.
10+
/// </summary>
811
public enum DeadzoneMethod
912
{
10-
// y = x except where |x| is between 0 and d (the deadzone value)
13+
/// <summary>
14+
/// The traditional deadzone method, where the reported value is directly proportional with the actual value until the actual value is within the deadzone - the reported value will be 0 in this case.
15+
/// </summary>
16+
/// <remarks>
17+
/// <para>
18+
/// y = x except where |x| is between 0 and d
19+
/// </para>
20+
/// <para>
21+
/// y is the output, x is the raw value, and d is the deadzone value.
22+
/// </para>
23+
/// </remarks>
1124
Traditional,
12-
// y = (1 - d)x + (d * sgn(x))
25+
26+
/// <summary>
27+
/// A deadzone method where the reported value adapts to the range of the deadzone. If the value is within the deadzone, the reported value is 0.
28+
/// After exiting the deadzone, the reported value increases from 0 (when the actual value first exits the deadzone) to 1 (when the actual value is 1).
29+
/// </summary>
30+
/// <remarks>
31+
/// <para>
32+
/// y = (1 - d)x + (d * sgn(x))
33+
/// </para>
34+
/// <para>
35+
/// y is the output, x is the raw value, and d is the deadzone value.
36+
/// </para>
37+
/// </remarks>
1338
AdaptiveGradient
1439
}
15-
}
40+
}

src/Input/Silk.NET.Input.Common/Enums/Key.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@
55

66
namespace Silk.NET.Input.Common
77
{
8+
/// <summary>
9+
/// Represents the keys on a keyboard.
10+
/// </summary>
11+
/// <remarks>
12+
/// <para>
13+
/// When using some backends, only a certain number of function keys may be available. For example, if the backend only supports up to F12, events regarding F13 through F35 will never be raised.
14+
/// </para>
15+
/// </remarks>
816
public enum Key
917
{
1018
Unknown = 0,
@@ -155,4 +163,4 @@ public enum Key
155163
NonUSBackSlash,
156164
LastKey
157165
}
158-
}
166+
}

src/Input/Silk.NET.Input.Common/Enums/MouseButton.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@
55

66
namespace Silk.NET.Input.Common
77
{
8+
/// <summary>
9+
/// Represents the indices of the mouse buttons.
10+
/// </summary>
11+
/// <remarks>
12+
/// <para>
13+
/// The number of buttons provided depends on the input backend currently being used.
14+
/// </para>
15+
/// </remarks>
816
public enum MouseButton
917
{
1018
Left,

src/Input/Silk.NET.Input.Common/Enums/Position2D.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,16 @@
77

88
namespace Silk.NET.Input.Common
99
{
10+
/// <summary>
11+
/// Represents the position of a joystick <see cref="Hat"/>
12+
/// </summary>
1013
[Flags]
1114
public enum Position2D
1215
{
13-
Up,
14-
Down,
15-
Left,
16-
Right,
16+
Up = 1,
17+
Down = 2,
18+
Left = 4,
19+
Right = 8,
1720

1821
UpLeft = Up | Left,
1922
UpRight = Up | Right,

src/Input/Silk.NET.Input.Common/Hat.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,26 @@
55

66
namespace Silk.NET.Input.Common
77
{
8+
/// <summary>
9+
/// Represents a joystick hat.
10+
/// </summary>
811
public struct Hat
912
{
13+
/// <summary>
14+
/// The index of this hat.
15+
/// </summary>
1016
public int Index { get; }
17+
18+
/// <summary>
19+
/// The position of this hat.
20+
/// </summary>
1121
public Position2D Position { get; }
1222

23+
/// <summary>
24+
/// Creates a new instance of the Hat struct.
25+
/// </summary>
26+
/// <param name="index">The index of the hat.</param>
27+
/// <param name="position">The position of the hat.</param>
1328
public Hat(int index, Position2D position)
1429
{
1530
Index = index;

0 commit comments

Comments
 (0)