Skip to content

Media key solution ArrayIndexOutOfBounds #3

@bandit045

Description

@bandit045

Media key on keyboard can throw exeption ArrayIndexOutOfBoundsException

P.S this is my first PR and issue(interaction) with GitHub

We can solve it by surround like this in KeyListener keyCallback method:
public static void keyCallback(long window, int key, int scancode, int action, int mods){
System.out.println(key);
System.out.println(scancode);
System.out.println(action);
if (key > 0 && key < get().keyPressed.length) {
if (action == GLFW_PRESS) {
get().keyPressed[key] = true;
} else if (action == GLFW_RELEASE) {
get().keyPressed[key] = false;
}
}
}

Almost all media key shown: key '-1' , scancode '256' , and for press and relase 0 and 1.
We can just add it so, wont crash game :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions