Skip to content

Commit f17ca05

Browse files
authored
An input implementation using GLFW (#21)
* Start of the GLFW Input implementation * A start I guess, it's messy and all over the place * Additional work on GLFW input (#26) * Move ApplyDeadzone to Deadzone struct * Add test program, move ConnectionChanged to IInputContext * Add functionality to test program * More input work * Add an .editorconfig * ThumbstickCollection * ButtonCollection * Hat and Trigger collection * Update collections * joystick axis cache * Update cached axis * Update GlfwJoystick.cs * Joystick cache * AxisCollection * GamePad and Joystick cache * GamepadFix * GamePad Updates * Bracket fix * work * Thumbstick update * Gamepad implementation * nitpick * update test program * Update dispatcher * Only show window when running * Fix context not being passed to enumerator * Fix a marshalling bug * Apply deadzone * Enumerate over the disconnected joysticks too. * Update the test app. * Controller events fix * wip * Use indexers on the pointers * Fix mismatched enumerant names in GLFW * Destroy window when we're done * Fix wrong enum values in GLFW * Make properties update initialOptions, and only invoke GLFW if running * Window is immovable when only 1 thread is used, investigate WindowUpdate * Fix `Get` methods (#30) * Fix the abominations that were `Get()` methods * Remove Get methods entirely * Fully implement mice, fix deadlock issues * This is GLFW input. * Update GlfwInputContext.cs * Update Silk.NET.Input.Desktop.csproj * Update GlfwInputContext.cs * Update InputHandler.cs * Update GlfwInputContext.cs
1 parent e3ae842 commit f17ca05

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+2303
-407
lines changed

.editorconfig

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
2+
[*]
3+
charset=utf-8
4+
end_of_line=crlf
5+
trim_trailing_whitespace=false
6+
insert_final_newline=false
7+
indent_style=space
8+
indent_size=4
9+
10+
# Microsoft .NET properties
11+
csharp_new_line_before_members_in_object_initializers=false
12+
csharp_preferred_modifier_order=public, private, protected, internal, new, abstract, virtual, sealed, override, static, readonly, extern, unsafe, volatile, async:suggestion
13+
csharp_style_var_elsewhere=true:hint
14+
csharp_style_var_for_built_in_types=true:hint
15+
csharp_style_var_when_type_is_apparent=true:hint
16+
dotnet_style_predefined_type_for_locals_parameters_members=true:hint
17+
dotnet_style_predefined_type_for_member_access=true:hint
18+
dotnet_style_qualification_for_event=false:warning
19+
dotnet_style_qualification_for_field=false:warning
20+
dotnet_style_qualification_for_method=false:warning
21+
dotnet_style_qualification_for_property=false:warning
22+
dotnet_style_require_accessibility_modifiers=for_non_interface_members:hint
23+
24+
# ReSharper properties
25+
resharper_autodetect_indent_settings=true
26+
resharper_braces_for_for=required
27+
resharper_braces_for_foreach=required
28+
resharper_braces_for_ifelse=required
29+
resharper_braces_for_while=required
30+
resharper_csharp_insert_final_newline=true
31+
resharper_csharp_wrap_before_declaration_lpar=true
32+
resharper_csharp_wrap_before_invocation_lpar=true
33+
resharper_csharp_wrap_extends_list_style=chop_if_long
34+
resharper_csharp_wrap_parameters_style=chop_if_long
35+
resharper_use_indent_from_vs=false
36+
resharper_wrap_after_declaration_lpar=true
37+
resharper_wrap_after_invocation_lpar=true
38+
resharper_wrap_before_declaration_rpar=true
39+
resharper_wrap_before_invocation_rpar=true
40+
resharper_wrap_chained_method_calls=chop_if_long
41+
resharper_xmldoc_indent_child_elements=DoNotTouch
42+
resharper_xmldoc_indent_text=DoNotTouch
43+
44+
# ReSharper inspection severities
45+
resharper_invert_if_highlighting=none
46+
resharper_web_config_module_not_resolved_highlighting=warning
47+
resharper_web_config_type_not_resolved_highlighting=warning
48+
resharper_web_config_wrong_module_highlighting=warning
49+
50+
[*.{appxmanifest,asax,ascx,aspx,build,config,cs,cshtml,csproj,dbml,discomap,dtd,fs,fsi,fsscript,fsx,htm,html,jsproj,lsproj,master,ml,mli,njsproj,nuspec,proj,props,razor,resw,resx,skin,StyleCop,targets,tasks,vb,vbproj,xaml,xamlx,xml,xoml,xsd}]
51+
indent_style=space
52+
indent_size=4
53+
tab_width=4

Silk.NET.sln

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Core", "Core", "{0651C5EF-5
167167
EndProject
168168
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Triangle", "examples\Triangle\Triangle.csproj", "{3478F392-7055-4ECC-B388-7F115AA7EA5A}"
169169
EndProject
170+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Silk.NET.Input.Desktop", "src\Input\Silk.NET.Input.Desktop\Silk.NET.Input.Desktop.csproj", "{3908DEF6-7403-49F5-B8EC-5B3B12C325D4}"
171+
EndProject
172+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Silk.NET.Input", "src\Input\Silk.NET.Input\Silk.NET.Input.csproj", "{020A8E88-B607-4281-BA0D-5ED03484A201}"
173+
EndProject
174+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "InputTest", "examples\InputTest\InputTest.csproj", "{3E744E54-F450-4051-8919-04D9B591688E}"
175+
EndProject
170176
Global
171177
GlobalSection(SolutionConfigurationPlatforms) = preSolution
172178
Debug|Any CPU = Debug|Any CPU
@@ -1044,6 +1050,42 @@ Global
10441050
{3478F392-7055-4ECC-B388-7F115AA7EA5A}.Release|x64.Build.0 = Release|Any CPU
10451051
{3478F392-7055-4ECC-B388-7F115AA7EA5A}.Release|x86.ActiveCfg = Release|Any CPU
10461052
{3478F392-7055-4ECC-B388-7F115AA7EA5A}.Release|x86.Build.0 = Release|Any CPU
1053+
{3908DEF6-7403-49F5-B8EC-5B3B12C325D4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
1054+
{3908DEF6-7403-49F5-B8EC-5B3B12C325D4}.Debug|Any CPU.Build.0 = Debug|Any CPU
1055+
{3908DEF6-7403-49F5-B8EC-5B3B12C325D4}.Debug|x64.ActiveCfg = Debug|Any CPU
1056+
{3908DEF6-7403-49F5-B8EC-5B3B12C325D4}.Debug|x64.Build.0 = Debug|Any CPU
1057+
{3908DEF6-7403-49F5-B8EC-5B3B12C325D4}.Debug|x86.ActiveCfg = Debug|Any CPU
1058+
{3908DEF6-7403-49F5-B8EC-5B3B12C325D4}.Debug|x86.Build.0 = Debug|Any CPU
1059+
{3908DEF6-7403-49F5-B8EC-5B3B12C325D4}.Release|Any CPU.ActiveCfg = Release|Any CPU
1060+
{3908DEF6-7403-49F5-B8EC-5B3B12C325D4}.Release|Any CPU.Build.0 = Release|Any CPU
1061+
{3908DEF6-7403-49F5-B8EC-5B3B12C325D4}.Release|x64.ActiveCfg = Release|Any CPU
1062+
{3908DEF6-7403-49F5-B8EC-5B3B12C325D4}.Release|x64.Build.0 = Release|Any CPU
1063+
{3908DEF6-7403-49F5-B8EC-5B3B12C325D4}.Release|x86.ActiveCfg = Release|Any CPU
1064+
{3908DEF6-7403-49F5-B8EC-5B3B12C325D4}.Release|x86.Build.0 = Release|Any CPU
1065+
{020A8E88-B607-4281-BA0D-5ED03484A201}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
1066+
{020A8E88-B607-4281-BA0D-5ED03484A201}.Debug|Any CPU.Build.0 = Debug|Any CPU
1067+
{020A8E88-B607-4281-BA0D-5ED03484A201}.Debug|x64.ActiveCfg = Debug|Any CPU
1068+
{020A8E88-B607-4281-BA0D-5ED03484A201}.Debug|x64.Build.0 = Debug|Any CPU
1069+
{020A8E88-B607-4281-BA0D-5ED03484A201}.Debug|x86.ActiveCfg = Debug|Any CPU
1070+
{020A8E88-B607-4281-BA0D-5ED03484A201}.Debug|x86.Build.0 = Debug|Any CPU
1071+
{020A8E88-B607-4281-BA0D-5ED03484A201}.Release|Any CPU.ActiveCfg = Release|Any CPU
1072+
{020A8E88-B607-4281-BA0D-5ED03484A201}.Release|Any CPU.Build.0 = Release|Any CPU
1073+
{020A8E88-B607-4281-BA0D-5ED03484A201}.Release|x64.ActiveCfg = Release|Any CPU
1074+
{020A8E88-B607-4281-BA0D-5ED03484A201}.Release|x64.Build.0 = Release|Any CPU
1075+
{020A8E88-B607-4281-BA0D-5ED03484A201}.Release|x86.ActiveCfg = Release|Any CPU
1076+
{020A8E88-B607-4281-BA0D-5ED03484A201}.Release|x86.Build.0 = Release|Any CPU
1077+
{3E744E54-F450-4051-8919-04D9B591688E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
1078+
{3E744E54-F450-4051-8919-04D9B591688E}.Debug|Any CPU.Build.0 = Debug|Any CPU
1079+
{3E744E54-F450-4051-8919-04D9B591688E}.Debug|x64.ActiveCfg = Debug|Any CPU
1080+
{3E744E54-F450-4051-8919-04D9B591688E}.Debug|x64.Build.0 = Debug|Any CPU
1081+
{3E744E54-F450-4051-8919-04D9B591688E}.Debug|x86.ActiveCfg = Debug|Any CPU
1082+
{3E744E54-F450-4051-8919-04D9B591688E}.Debug|x86.Build.0 = Debug|Any CPU
1083+
{3E744E54-F450-4051-8919-04D9B591688E}.Release|Any CPU.ActiveCfg = Release|Any CPU
1084+
{3E744E54-F450-4051-8919-04D9B591688E}.Release|Any CPU.Build.0 = Release|Any CPU
1085+
{3E744E54-F450-4051-8919-04D9B591688E}.Release|x64.ActiveCfg = Release|Any CPU
1086+
{3E744E54-F450-4051-8919-04D9B591688E}.Release|x64.Build.0 = Release|Any CPU
1087+
{3E744E54-F450-4051-8919-04D9B591688E}.Release|x86.ActiveCfg = Release|Any CPU
1088+
{3E744E54-F450-4051-8919-04D9B591688E}.Release|x86.Build.0 = Release|Any CPU
10471089
EndGlobalSection
10481090
GlobalSection(NestedProjects) = preSolution
10491091
{BFE429EB-4C2E-4BF3-A302-C9C5A2FDA6D7} = {23324041-2076-477C-A4BF-B385B8066C6C}
@@ -1119,5 +1161,8 @@ Global
11191161
{FD24E9FF-1097-4777-A418-F2D88C558665} = {0651C5EF-50AA-4598-8D9C-8F210ADD8490}
11201162
{136C6154-D300-4B82-80D3-17B637841A2B} = {0651C5EF-50AA-4598-8D9C-8F210ADD8490}
11211163
{3478F392-7055-4ECC-B388-7F115AA7EA5A} = {E1F91563-7277-4E9B-A3B7-8D5FD9802A4A}
1164+
{3908DEF6-7403-49F5-B8EC-5B3B12C325D4} = {FA9D1C95-5585-4DEC-B226-1447A486C376}
1165+
{020A8E88-B607-4281-BA0D-5ED03484A201} = {FA9D1C95-5585-4DEC-B226-1447A486C376}
1166+
{3E744E54-F450-4051-8919-04D9B591688E} = {E1F91563-7277-4E9B-A3B7-8D5FD9802A4A}
11221167
EndGlobalSection
11231168
EndGlobal

documentation/proposals/Proposal - Input.md

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Summary
1+
# Summary
22
Proposal API for Input via keyboards, mice, and controllers.
33

44
# Contributors
@@ -27,9 +27,9 @@ Proposal API for Input via keyboards, mice, and controllers.
2727
```cs
2828
public interface IJoystick : IInputDevice
2929
{
30-
IReadOnlyCollection<Axis> Axes { get; }
31-
IReadOnlyCollection<Button> Buttons { get; }
32-
IReadOnlyCollection<Hat> Hats { get; }
30+
IReadOnlyList<Axis> Axes { get; }
31+
IReadOnlyList<Button> Buttons { get; }
32+
IReadOnlyList<Hat> Hats { get; }
3333
Deadzone Deadzone { get; set; }
3434
event Action<IJoystick, Button> ButtonDown;
3535
event Action<IJoystick, Button> ButtonUp;
@@ -42,9 +42,9 @@ public interface IJoystick : IInputDevice
4242
```cs
4343
public interface IGamepad : IInputDevice
4444
{
45-
IReadOnlyCollection<Button> Buttons { get; }
46-
IReadOnlyCollection<Thumbstick> Thumbsticks { get; }
47-
IReadOnlyCollection<Trigger> Triggers { get; }
45+
IReadOnlyList<Button> Buttons { get; }
46+
IReadOnlyList<Thumbstick> Thumbsticks { get; }
47+
IReadOnlyList<Trigger> Triggers { get; }
4848
Deadzone Deadzone { get; set; }
4949
event Action<IGamepad, Button> ButtonDown;
5050
event Action<IGamepad, Button> ButtonUp;
@@ -57,7 +57,7 @@ public interface IGamepad : IInputDevice
5757
```cs
5858
public interface IKeyboard : IInputDevice
5959
{
60-
IReadOnlyCollection<Key> SupportedKeys { get; }
60+
IReadOnlyList<Key> SupportedKeys { get; }
6161
bool IsKeyPressed(Key key);
6262
bool IsKeyPressed(uint scancode);
6363
event Action<IKeyboard, Key> KeyDown;
@@ -69,8 +69,8 @@ public interface IKeyboard : IInputDevice
6969
```cs
7070
public interface IMouse : IInputDevice
7171
{
72-
IReadOnlyCollection<MouseButton> SupportedButtons { get; }
73-
IReadOnlyCollection<ScrollWheel> ScrollWheels { get; }
72+
IReadOnlyList<MouseButton> SupportedButtons { get; }
73+
IReadOnlyList<ScrollWheel> ScrollWheels { get; }
7474
bool IsButtonPressed(MouseButton btn);
7575
event Action<IMouse, MouseButton> MouseDown;
7676
event Action<IMouse, MouseButton> MouseUp;
@@ -94,11 +94,11 @@ public interface IInputDevice
9494
public interface IInputContext : IDisposable
9595
{
9696
IntPtr Handle { get; }
97-
IReadOnlyCollection<IGamepad> Gamepads { get; }
98-
IReadOnlyCollection<IJoystick> Joysticks { get; }
99-
IReadOnlyCollection<IKeyboard> Keyboards { get; }
100-
IReadOnlyCollection<IMouse> Mice { get; }
101-
IReadOnlyCollection<IInputDevice> OtherDevices { get; }
97+
IReadOnlyList<IGamepad> Gamepads { get; }
98+
IReadOnlyList<IJoystick> Joysticks { get; }
99+
IReadOnlyList<IKeyboard> Keyboards { get; }
100+
IReadOnlyList<IMouse> Mice { get; }
101+
IReadOnlyList<IInputDevice> OtherDevices { get; }
102102
}
103103
```
104104

@@ -162,7 +162,9 @@ public struct Axis
162162
```cs
163163
public struct Thumbstick
164164
{
165-
public int Index { get; }
165+
public int Index { get; }
166+
public float X { get; }
167+
public float Y { get; }
166168
public float Position { get; }
167169
public float Direction { get; }
168170

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>netcoreapp2.1</TargetFramework>
6+
</PropertyGroup>
7+
8+
<ItemGroup>
9+
<ProjectReference Include="..\..\src\Input\Silk.NET.Input.Desktop\Silk.NET.Input.Desktop.csproj" />
10+
<ProjectReference Include="..\..\src\Input\Silk.NET.Input\Silk.NET.Input.csproj" />
11+
<ProjectReference Include="..\..\src\Windowing\Silk.NET.Windowing\Silk.NET.Windowing.csproj" />
12+
</ItemGroup>
13+
14+
</Project>

0 commit comments

Comments
 (0)