Repository: dotnet/Silk.NET

Issue #2372: ImGuiController throws a NotImplementedException when a key event with Silk.NET.Input.Key.Unknown is fired.
Created: 2024-11-30T12:03:09Z
Summary
In the Silk.NET app using ImGui, when I press the key which Silk.NET detects as Silk.NET.Input.Key.Unknown, app throws an unhandled NotImplementedException with below stacktrace:
Unhandled exception. System.NotImplementedException: The method or operation is not implemented.
   at Silk.NET.OpenGL.Extensions.ImGui.ImGuiController.TranslateInputKeyToImGuiKey(Key key)
   at Silk.NET.OpenGL.Extensions.ImGui.ImGuiController.OnKeyEvent(IKeyboard keyboard, Key keycode, Int32 scancode, Boolean down)
   at Silk.NET.OpenGL.Extensions.ImGui.ImGuiController.OnKeyDown(IKeyboard keyboard, Key keycode, Int32 scancode)
   at Silk.NET.Input.Glfw.GlfwKeyboard.<Subscribe>b__33_1(WindowHandle* _, Keys key, Int32 code, InputAction action, KeyModifiers mods)
   at Silk.NET.Input.Glfw.GlfwEvents.<.ctor>b__0_1(WindowHandle* a, Keys b, Int32 c, InputAction d, KeyModifiers e)
   at Silk.NET.Windowing.Internals.ViewImplementationBase.Silk.NET.Windowing.IView.DoEvents()
   at Silk.NET.Windowing.Internals.ViewImplementationBase.Run(Action onFrame)
   at Silk.NET.Windowing.Glfw.GlfwWindow.Run(Action onFrame)
   at Silk.NET.Windowing.WindowExtensions.Run(IView view)
   ...

Steps to reproduce

Platform: Desktop
Framework Version: .NET 8, Windows 11
API: OpenGL
API Version: OpenGL 3.3


Run https://github.com/prometeapp/SilkNetImGuiInputErrorTest
Press Unknown key

Comments
Some example of keys Silk.NET detects as Silk.NET.Input.Key.Unknown:

[￥] key on Japanese OADG 109A
[＼] key on Japanese OADG 109A

If you know how to fix this issue, please submit a pull request instead!

Duplicate issue #2407: Exception thrown with auxiliary keyboard keys and knobs
Created: 2024-12-31T17:36:55Z
Summary
When using auxiliary keys or knobs on a keyboard, the application crashes.  At first, I thought it was something in my library Velaptor, but after some investigation, I discovered that an InvalidOperationException is being thrown from the Reset() method in the ViewImplementationBase abstract class in the Silk.NET.Windowing.Internals namespace.
I know this is because I looked into the internal exception being thrown in Velaptor, and the exception message is You cannot call 'Reset' inside of the render loop!.  I found this by searching in the Silk source code for tag v2.22.0.
When I say 'auxiliary', I mean custom keyboard keys and knobs that are used for volume, mute, skipping songs, etc.
I have a mechanical keyboard and my laptop keyboard, which have some aux keys and/or knobs that cause the exception to be thrown.
Since Velaptor is open source, you can run the VelaptorTesting project.  Once the window is displayed, adjust the audio knob on a keyboard that has one, and it should crash. I attempted to see if the problem would occur in the Imgui sample project, but I had issues with errors being thrown by nuke.  I am confident you can reproduce the issue with the Silk example projects.
I subscribe to a keyboard key-down event of an IInputContext instance.  I set a breakpoint in my event handler, but it is not invoked.  It simply immediately throws an exception.
Steps to reproduce

Platform: Desktop
Framework Version: dotnet 9.0
API: OpenGL
API Version: OpenGL 4.5 Core


Open the solution for the latest version tag of Velaptor or a Silk sample project.
Run the VelaptorTesting project or a Silk sample project
Adjust the volume knob or hit an aux key on a keyboard that has a this functionality.
Observe that an exception is thrown.

Comments
The screenshots below are the knobs and keys that are causing the exception:


More Info:

MONTECH Mechanical Keyboard
[Asus ROG Zephyrus G16 Laptop](I know this is because I looked into the internal exception being thrown in Velaptor, and the exception message is You cannot call 'Reset' inside of the render loop!.  I found this by searching in the Silk source code for tag v2.22.0.)

NoteThis is not just a volume knob.  It can be used for other functions on the keyboard, such as the lighting.
Hitting the volume up and down on my laptop keyboard causes the same issue.

If you need more information or testing, let me know, and I would be glad to help. Thanks!!
If you know how to fix this issue, please submit a pull request instead!

Closing comment (2025-02-07T08:41:21Z): Ah okay, in which case this is a duplicate of #2372 which is awaiting contributions. Nice work figuring it out :)

Ah ok.   It's good to know something is out there for it.  Thx for taking the time!  😊