fix[glfw]: Fix IndexOOB when requesting GLFW_KEY_LAST (#15)

This commit is contained in:
Eva Isabella Luna 2025-06-19 15:31:53 -06:00 committed by GitHub
commit 331b588b75
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 4 additions and 1 deletions

View File

@ -1 +1 @@
4903cfc8d3afd63918f59caf0a146efc2d837069
349d027673855ffded0bb7471a5b662a63b438bd

View File

@ -1159,6 +1159,9 @@ public class GLFW
}
public static int glfwGetKey(@NativeType("GLFWwindow *") long window, int key) {
// This is jank, anything asking for int 348 results in an IndexOutOfBounds because idk.
// Probably an off-by-one error. This is the 'fix'
if (key == GLFW_KEY_LAST){return GLFW_KEY_LAST;}
return keyDownBuffer.get(Math.max(0, key-31));
}