azurite-engine / Azurite

Azurite Game Engine is a 2D Java game engine built on top of LWJGL.
https://azurite-engine.github.io
MIT License
42 stars 20 forks source link

Errors on unidentified key code. #83

Open aemogie opened 2 years ago

aemogie commented 2 years ago

Throws an ArrayIndexOutOfBoundsException when any key that GLFW does not support is pressed. i.e. when keycode -1 is sent, it's still being used to index into the keystateBitfields array.

Steps to reproduce

  1. Open any scene
  2. On windows, hit a function key without the fn key, so that it does the action, such as increasing/decreasing volume/brightness.

What you expected would happen

For the key to be ignored.

What actually happens

An ArrayIndexOutOfBoundsException is thrown

Error logs

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index -1 out of bounds for length 400
    at input.Keyboard.resetKeyDownBit(Keyboard.java:64)
    at input.Keyboard.lambda$setupCallbacks$0(Keyboard.java:41)
    at org.lwjgl.glfw.GLFWKeyCallbackI.callback(GLFWKeyCallbackI.java:44)
    at org.lwjgl.system.JNI.invokeV(Native Method)
    at org.lwjgl.glfw.GLFW.glfwPollEvents(GLFW.java:3397)
    at graphics.Window.showWindow(Window.java:205)
    at util.Engine.showWindow(Engine.java:55)
    at scenes.AudioDemo.main(AudioDemo.java:21)