Skip to content

Add Input.Common #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Jul 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions Silk.NET.sln
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Silk.NET.OpenAL.Extensions.
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Silk.NET.OpenAL.Extensions.Soft.DeferredUpdates", "src\OpenAL\Extensions\Silk.NET.OpenAL.Extensions.Soft.DeferredUpdates\Silk.NET.OpenAL.Extensions.Soft.DeferredUpdates.csproj", "{50987EDD-9F49-4981-ADAE-98F01F4A4FBA}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Input", "Input", "{AE36230C-E8F4-4332-9F50-9253E6511FED}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Silk.NET.Input.Common", "src\Input\Silk.NET.Input.Common\Silk.NET.Input.Common.csproj", "{8FFF49D6-B029-400B-8510-19088868DFA6}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -360,6 +364,18 @@ Global
{50987EDD-9F49-4981-ADAE-98F01F4A4FBA}.Release|x64.Build.0 = Release|Any CPU
{50987EDD-9F49-4981-ADAE-98F01F4A4FBA}.Release|x86.ActiveCfg = Release|Any CPU
{50987EDD-9F49-4981-ADAE-98F01F4A4FBA}.Release|x86.Build.0 = Release|Any CPU
{8FFF49D6-B029-400B-8510-19088868DFA6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8FFF49D6-B029-400B-8510-19088868DFA6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8FFF49D6-B029-400B-8510-19088868DFA6}.Debug|x64.ActiveCfg = Debug|Any CPU
{8FFF49D6-B029-400B-8510-19088868DFA6}.Debug|x64.Build.0 = Debug|Any CPU
{8FFF49D6-B029-400B-8510-19088868DFA6}.Debug|x86.ActiveCfg = Debug|Any CPU
{8FFF49D6-B029-400B-8510-19088868DFA6}.Debug|x86.Build.0 = Debug|Any CPU
{8FFF49D6-B029-400B-8510-19088868DFA6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8FFF49D6-B029-400B-8510-19088868DFA6}.Release|Any CPU.Build.0 = Release|Any CPU
{8FFF49D6-B029-400B-8510-19088868DFA6}.Release|x64.ActiveCfg = Release|Any CPU
{8FFF49D6-B029-400B-8510-19088868DFA6}.Release|x64.Build.0 = Release|Any CPU
{8FFF49D6-B029-400B-8510-19088868DFA6}.Release|x86.ActiveCfg = Release|Any CPU
{8FFF49D6-B029-400B-8510-19088868DFA6}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{BFE429EB-4C2E-4BF3-A302-C9C5A2FDA6D7} = {23324041-2076-477C-A4BF-B385B8066C6C}
Expand All @@ -385,5 +401,6 @@ Global
{4EE697B8-E6AA-47EF-B9E3-C4F9FFBCA4E7} = {896B1A79-FEC8-4B7A-8A9C-0CC8EDA2CCFC}
{94D7D3A3-3640-4791-BE19-CA50C59187C6} = {896B1A79-FEC8-4B7A-8A9C-0CC8EDA2CCFC}
{50987EDD-9F49-4981-ADAE-98F01F4A4FBA} = {896B1A79-FEC8-4B7A-8A9C-0CC8EDA2CCFC}
{8FFF49D6-B029-400B-8510-19088868DFA6} = {AE36230C-E8F4-4332-9F50-9253E6511FED}
EndGlobalSection
EndGlobal
38 changes: 36 additions & 2 deletions documentation/proposals/Proposal - Input.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# Summary
# Summary
Proposal API for Input via keyboards, mice, and controllers.

# Contributors
- Dylan Perks, Ultz Limited
- Aaron Pearson, Ultz Limited
- Vassalware, Silk.NET Contributors
- Void, Silk.NET codeowners

# Current Status
- [x] Proposed
Expand Down Expand Up @@ -117,7 +118,7 @@ public interface IInputPlatform
public static class InputWindowExtensions
{
public static void RegisterInputPlatform(IInputPlatform platform);
public static void DeregisterInputPlatform(IInputPlatform platform);
public static void UnregisterInputPlatform(IInputPlatform platform);
public static IInputContext GetInput(this IWindow window);
}
```
Expand All @@ -129,6 +130,8 @@ public struct ScrollWheel
{
public float X { get; }
public float Y { get; }

public ScrollWheel(float x, float y);
}
```

Expand All @@ -139,6 +142,8 @@ public struct Button
public ButtonName Name { get; }
public int Index { get; }
public bool Pressed { get; }

public Button(ButtonName name, int index, bool pressed);
}
```

Expand All @@ -148,6 +153,8 @@ public struct Axis
{
public int Index { get; }
public float Position { get; }

public Axis(int index, float position);
}
```

Expand All @@ -158,6 +165,8 @@ public struct Thumbstick
public int Index { get; }
public float Position { get; }
public float Direction { get; }

public Thumbstick(int index, float position, float direction);
}
```

Expand All @@ -167,6 +176,8 @@ public struct Trigger
{
public int Index { get; }
public float Position { get; }

public Trigger(int index, float position);
}
```

Expand All @@ -176,6 +187,8 @@ public struct Hat
{
public int Index { get; }
public Position2D Position { get; }

public Hat(int index, Position2D position);
}
```

Expand All @@ -185,6 +198,8 @@ public struct Deadzone
{
public float Value { get; }
public DeadzoneMethod Method { get; }

public Deadzone(float value, DeadzoneMethod method);
}
```

Expand Down Expand Up @@ -389,3 +404,22 @@ public enum Key
LastKey
}
```

### MouseButton
```cs
public enum MouseButton
{
Left,
Middle,
Right,
Button4,
Button5,
Button6,
Button7,
Button8,
Button9,
Button10,
Button11,
Button12
}
```
19 changes: 19 additions & 0 deletions src/Input/Silk.NET.Input.Common/Axis.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// This file is part of Silk.NET.
//
// You may modify and distribute Silk.NET under the terms
// of the MIT license. See the LICENSE file for details.

namespace Silk.NET.Input.Common
{
public struct Axis
{
public int Index { get; }
public float Position { get; }

public Axis(int index, float position)
{
Index = index;
Position = position;
}
}
}
21 changes: 21 additions & 0 deletions src/Input/Silk.NET.Input.Common/Button.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// This file is part of Silk.NET.
//
// You may modify and distribute Silk.NET under the terms
// of the MIT license. See the LICENSE file for details.

namespace Silk.NET.Input.Common
{
public struct Button
{
public ButtonName Name { get; }
public int Index { get; }
public bool Pressed { get; }

public Button(ButtonName name, int index, bool pressed)
{
Name = name;
Index = index;
Pressed = pressed;
}
}
}
19 changes: 19 additions & 0 deletions src/Input/Silk.NET.Input.Common/Deadzone.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// This file is part of Silk.NET.
//
// You may modify and distribute Silk.NET under the terms
// of the MIT license. See the LICENSE file for details.

namespace Silk.NET.Input.Common
{
public struct Deadzone
{
public float Value { get; }
public DeadzoneMethod Method { get; }

public Deadzone(float value, DeadzoneMethod method)
{
Value = value;
Method = method;
}
}
}
28 changes: 28 additions & 0 deletions src/Input/Silk.NET.Input.Common/Enums/ButtonName.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// This file is part of Silk.NET.
//
// You may modify and distribute Silk.NET under the terms
// of the MIT license. See the LICENSE file for details.

namespace Silk.NET.Input.Common
{
public enum ButtonName
{
A,
B,
X,
Y,
Back,
Home,
DPadUp,
DPadDown,
DPadLeft,
DPadRight,
LeftBumper,
LeftStick,
LeftTrigger,
RightBumper,
RightStick,
RightTrigger,
Start
}
}
15 changes: 15 additions & 0 deletions src/Input/Silk.NET.Input.Common/Enums/DeadzoneMethod.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// This file is part of Silk.NET.
//
// You may modify and distribute Silk.NET under the terms
// of the MIT license. See the LICENSE file for details.

namespace Silk.NET.Input.Common
{
public enum DeadzoneMethod
{
// y = x except where |x| is between 0 and d (the deadzone value)
Traditional,
// y = (1 - d)x + (d * sgn(x))
AdaptiveGradient
}
}
Loading