Skip to content

Commit 43c07c9

Browse files
authored
Stop reporting "Unknown" as SupportedKey (#487)
1 parent 639a234 commit 43c07c9

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/Input/Silk.NET.Input.Glfw/GlfwKeyboard.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ namespace Silk.NET.Input.Glfw
1010
{
1111
internal class GlfwKeyboard : IKeyboard, IGlfwSubscriber
1212
{
13-
private static readonly Key[] _keys = ((Keys[]) Enum.GetValues(typeof(Keys))).Select(ConvertKey).ToArray();
13+
private static readonly Key[] _keys = ((Keys[]) Enum.GetValues(typeof(Keys))).Select
14+
(ConvertKey)
15+
.Where(static x => x != Key.Unknown)
16+
.Distinct()
17+
.ToArray();
1418
private unsafe WindowHandle* _handle;
1519
private GlfwCallbacks.CharCallback? _char;
1620
private GlfwCallbacks.KeyCallback? _key;

src/Input/Silk.NET.Input.Sdl/SdlKeyboard.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Linq;
34
using Silk.NET.Input.Internals;
45
using Silk.NET.SDL;
56

@@ -18,7 +19,9 @@ public SdlKeyboard(SdlInputContext ctx)
1819
public string Name { get; } = "Silk.NET Keyboard (via SDL)";
1920
public int Index { get; } = 0;
2021
public bool IsConnected { get; } = true;
21-
public IReadOnlyList<Key> SupportedKeys { get; } = new ReadOnlyCollectionListAdapter<Key>(_keyMap.Values);
22+
23+
public IReadOnlyList<Key> SupportedKeys { get; } =
24+
_keyMap.Values.Where(static x => x != Key.Unknown).Distinct().ToArray();
2225
public bool IsKeyPressed(Key key) => _keysDown.Contains(key);
2326
public event Action<IKeyboard, Key, int>? KeyDown;
2427
public event Action<IKeyboard, Key, int>? KeyUp;

0 commit comments

Comments
 (0)