From 5fcdfb06ff4ceab3d69f90f2cb17f2381cd19b88 Mon Sep 17 00:00:00 2001 From: void Date: Wed, 10 Jul 2019 13:55:11 -0500 Subject: [PATCH 01/10] Start of Input.Common --- Silk.NET.sln | 17 +++++++++++++++++ src/Input/Silk.NET.Input.Common/Class1.cs | 8 ++++++++ .../Silk.NET.Input.Common.csproj | 7 +++++++ 3 files changed, 32 insertions(+) create mode 100644 src/Input/Silk.NET.Input.Common/Class1.cs create mode 100644 src/Input/Silk.NET.Input.Common/Silk.NET.Input.Common.csproj diff --git a/Silk.NET.sln b/Silk.NET.sln index 3298c81bf4..81164fbe62 100644 --- a/Silk.NET.sln +++ b/Silk.NET.sln @@ -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 @@ -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} @@ -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 diff --git a/src/Input/Silk.NET.Input.Common/Class1.cs b/src/Input/Silk.NET.Input.Common/Class1.cs new file mode 100644 index 0000000000..448e0a0036 --- /dev/null +++ b/src/Input/Silk.NET.Input.Common/Class1.cs @@ -0,0 +1,8 @@ +using System; + +namespace Silk.NET.Input.Common +{ + public class Class1 + { + } +} \ No newline at end of file diff --git a/src/Input/Silk.NET.Input.Common/Silk.NET.Input.Common.csproj b/src/Input/Silk.NET.Input.Common/Silk.NET.Input.Common.csproj new file mode 100644 index 0000000000..27560206de --- /dev/null +++ b/src/Input/Silk.NET.Input.Common/Silk.NET.Input.Common.csproj @@ -0,0 +1,7 @@ + + + + netstandard2.0 + + + From 752aee99f655ce4f395b6101ee2036dba622553e Mon Sep 17 00:00:00 2001 From: void Date: Wed, 10 Jul 2019 14:14:54 -0500 Subject: [PATCH 02/10] Initial commit of Input --- src/Input/Silk.NET.Input.Common/Axis.cs | 13 ++ src/Input/Silk.NET.Input.Common/Button.cs | 14 ++ src/Input/Silk.NET.Input.Common/Class1.cs | 8 - src/Input/Silk.NET.Input.Common/Deadzone.cs | 12 ++ .../Silk.NET.Input.Common/Enums/ButtonName.cs | 28 ++++ .../Enums/DeadzoneMethod.cs | 15 ++ src/Input/Silk.NET.Input.Common/Enums/Key.cs | 158 ++++++++++++++++++ .../Silk.NET.Input.Common/Enums/Position2D.cs | 23 +++ src/Input/Silk.NET.Input.Common/Hat.cs | 13 ++ .../InputWindowExtensions.cs | 28 ++++ .../Interfaces/IGamepad.cs | 22 +++ .../Interfaces/IInputContext.cs | 20 +++ .../Interfaces/IInputDevice.cs | 17 ++ .../Interfaces/IInputPlatform.cs | 15 ++ .../Interfaces/IJoystick.cs | 22 +++ .../Interfaces/IKeyboard.cs | 19 +++ .../Interfaces/IMouse.cs | 20 +++ .../Silk.NET.Input.Common/ScrollWheel.cs | 13 ++ .../Silk.NET.Input.Common.csproj | 6 +- src/Input/Silk.NET.Input.Common/Thumbstick.cs | 14 ++ src/Input/Silk.NET.Input.Common/Trigger.cs | 13 ++ 21 files changed, 484 insertions(+), 9 deletions(-) create mode 100644 src/Input/Silk.NET.Input.Common/Axis.cs create mode 100644 src/Input/Silk.NET.Input.Common/Button.cs delete mode 100644 src/Input/Silk.NET.Input.Common/Class1.cs create mode 100644 src/Input/Silk.NET.Input.Common/Deadzone.cs create mode 100644 src/Input/Silk.NET.Input.Common/Enums/ButtonName.cs create mode 100644 src/Input/Silk.NET.Input.Common/Enums/DeadzoneMethod.cs create mode 100644 src/Input/Silk.NET.Input.Common/Enums/Key.cs create mode 100644 src/Input/Silk.NET.Input.Common/Enums/Position2D.cs create mode 100644 src/Input/Silk.NET.Input.Common/Hat.cs create mode 100644 src/Input/Silk.NET.Input.Common/InputWindowExtensions.cs create mode 100644 src/Input/Silk.NET.Input.Common/Interfaces/IGamepad.cs create mode 100644 src/Input/Silk.NET.Input.Common/Interfaces/IInputContext.cs create mode 100644 src/Input/Silk.NET.Input.Common/Interfaces/IInputDevice.cs create mode 100644 src/Input/Silk.NET.Input.Common/Interfaces/IInputPlatform.cs create mode 100644 src/Input/Silk.NET.Input.Common/Interfaces/IJoystick.cs create mode 100644 src/Input/Silk.NET.Input.Common/Interfaces/IKeyboard.cs create mode 100644 src/Input/Silk.NET.Input.Common/Interfaces/IMouse.cs create mode 100644 src/Input/Silk.NET.Input.Common/ScrollWheel.cs create mode 100644 src/Input/Silk.NET.Input.Common/Thumbstick.cs create mode 100644 src/Input/Silk.NET.Input.Common/Trigger.cs diff --git a/src/Input/Silk.NET.Input.Common/Axis.cs b/src/Input/Silk.NET.Input.Common/Axis.cs new file mode 100644 index 0000000000..37741b1c14 --- /dev/null +++ b/src/Input/Silk.NET.Input.Common/Axis.cs @@ -0,0 +1,13 @@ +// 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; } + } +} \ No newline at end of file diff --git a/src/Input/Silk.NET.Input.Common/Button.cs b/src/Input/Silk.NET.Input.Common/Button.cs new file mode 100644 index 0000000000..f6cbeb99ca --- /dev/null +++ b/src/Input/Silk.NET.Input.Common/Button.cs @@ -0,0 +1,14 @@ +// 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; } + } +} \ No newline at end of file diff --git a/src/Input/Silk.NET.Input.Common/Class1.cs b/src/Input/Silk.NET.Input.Common/Class1.cs deleted file mode 100644 index 448e0a0036..0000000000 --- a/src/Input/Silk.NET.Input.Common/Class1.cs +++ /dev/null @@ -1,8 +0,0 @@ -using System; - -namespace Silk.NET.Input.Common -{ - public class Class1 - { - } -} \ No newline at end of file diff --git a/src/Input/Silk.NET.Input.Common/Deadzone.cs b/src/Input/Silk.NET.Input.Common/Deadzone.cs new file mode 100644 index 0000000000..6b32575441 --- /dev/null +++ b/src/Input/Silk.NET.Input.Common/Deadzone.cs @@ -0,0 +1,12 @@ +// 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 + { + + } +} \ No newline at end of file diff --git a/src/Input/Silk.NET.Input.Common/Enums/ButtonName.cs b/src/Input/Silk.NET.Input.Common/Enums/ButtonName.cs new file mode 100644 index 0000000000..39a7680dd2 --- /dev/null +++ b/src/Input/Silk.NET.Input.Common/Enums/ButtonName.cs @@ -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 + } +} \ No newline at end of file diff --git a/src/Input/Silk.NET.Input.Common/Enums/DeadzoneMethod.cs b/src/Input/Silk.NET.Input.Common/Enums/DeadzoneMethod.cs new file mode 100644 index 0000000000..cac6bfca41 --- /dev/null +++ b/src/Input/Silk.NET.Input.Common/Enums/DeadzoneMethod.cs @@ -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 + } +} \ No newline at end of file diff --git a/src/Input/Silk.NET.Input.Common/Enums/Key.cs b/src/Input/Silk.NET.Input.Common/Enums/Key.cs new file mode 100644 index 0000000000..1f4840d6c1 --- /dev/null +++ b/src/Input/Silk.NET.Input.Common/Enums/Key.cs @@ -0,0 +1,158 @@ +// 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 Key + { + Unknown = 0, + ShiftLeft, + LShift = ShiftLeft, + ShiftRight, + RShift = ShiftRight, + ControlLeft, + LControl = ControlLeft, + ControlRight, + RControl = ControlRight, + AltLeft, + LAlt = AltLeft, + AltRight, + RAlt = AltRight, + WinLeft, + LWin = WinLeft, + WinRight, + RWin = WinRight, + Menu, + F1, + F2, + F3, + F4, + F5, + F6, + F7, + F8, + F9, + F10, + F11, + F12, + F13, + F14, + F15, + F16, + F17, + F18, + F19, + F20, + F21, + F22, + F23, + F24, + F25, + F26, + F27, + F28, + F29, + F30, + F31, + F32, + F33, + F34, + F35, + Up, + Down, + Left, + Right, + Enter, + Escape, + Space, + Tab, + BackSpace, + Back = BackSpace, + Insert, + Delete, + PageUp, + PageDown, + Home, + End, + CapsLock, + ScrollLock, + PrintScreen, + Pause, + NumLock, + Clear, + Sleep, + Keypad0, + Keypad1, + Keypad2, + Keypad3, + Keypad4, + Keypad5, + Keypad6, + Keypad7, + Keypad8, + Keypad9, + KeypadDivide, + KeypadMultiply, + KeypadSubtract, + KeypadMinus = KeypadSubtract, + KeypadAdd, + KeypadPlus = KeypadAdd, + KeypadDecimal, + KeypadPeriod = KeypadDecimal, + KeypadEnter, + A, + B, + C, + D, + E, + F, + G, + H, + I, + J, + K, + L, + M, + N, + O, + P, + Q, + R, + S, + T, + U, + V, + W, + X, + Y, + Z, + Number0, + Number1, + Number2, + Number3, + Number4, + Number5, + Number6, + Number7, + Number8, + Number9, + Tilde, + Grave = Tilde, + Minus, + Plus, + BracketLeft, + LBracket = BracketLeft, + BracketRight, + RBracket = BracketRight, + Semicolon, + Quote, + Comma, + Period, + Slash, + BackSlash, + NonUSBackSlash, + LastKey + } +} \ No newline at end of file diff --git a/src/Input/Silk.NET.Input.Common/Enums/Position2D.cs b/src/Input/Silk.NET.Input.Common/Enums/Position2D.cs new file mode 100644 index 0000000000..1a8d6e0da0 --- /dev/null +++ b/src/Input/Silk.NET.Input.Common/Enums/Position2D.cs @@ -0,0 +1,23 @@ +// 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. + +using System; + +namespace Silk.NET.Input.Common +{ + [Flags] + public enum Position2D + { + Up, + Down, + Left, + Right, + + UpLeft = Up | Left, + UpRight = Up | Right, + DownLeft = Down | Left, + DownRight = Down | Right + } +} \ No newline at end of file diff --git a/src/Input/Silk.NET.Input.Common/Hat.cs b/src/Input/Silk.NET.Input.Common/Hat.cs new file mode 100644 index 0000000000..e63d9e9d78 --- /dev/null +++ b/src/Input/Silk.NET.Input.Common/Hat.cs @@ -0,0 +1,13 @@ +// 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 Hat + { + public int Index { get; } + public Position2D Position { get; } + } +} \ No newline at end of file diff --git a/src/Input/Silk.NET.Input.Common/InputWindowExtensions.cs b/src/Input/Silk.NET.Input.Common/InputWindowExtensions.cs new file mode 100644 index 0000000000..f651c6ca14 --- /dev/null +++ b/src/Input/Silk.NET.Input.Common/InputWindowExtensions.cs @@ -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. + +using System; +using Silk.NET.Windowing.Common; + +namespace Silk.NET.Input.Common +{ + public static class InputWindowExtensions + { + public static void RegisterInputPlatform(IInputPlatform platform) + { + throw new NotImplementedException(); + } + + public static void DeregisterInputPlatform(IInputPlatform platform) + { + throw new NotImplementedException(); + } + + public static IInputContext GetInput(this IWindow window) + { + throw new NotImplementedException(); + } + } +} \ No newline at end of file diff --git a/src/Input/Silk.NET.Input.Common/Interfaces/IGamepad.cs b/src/Input/Silk.NET.Input.Common/Interfaces/IGamepad.cs new file mode 100644 index 0000000000..e798a64f82 --- /dev/null +++ b/src/Input/Silk.NET.Input.Common/Interfaces/IGamepad.cs @@ -0,0 +1,22 @@ +// 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. + +using System; +using System.Collections.Generic; + +namespace Silk.NET.Input.Common +{ + public interface IGamepad : IInputDevice + { + IReadOnlyCollection