Java 类org.lwjgl.glfw.GLFWJoystickCallback 实例源码

项目:SilenceEngine    文件:GLFW3.java   
/**
 * Initializes the GLFW3 library. If you are not using the built-in Game class of the SilenceEngine, you should call
 * this method as soon as you can after loading the LWJGL3 natives.
 *
 * @return True if initialised successful, or else False.
 */
public static boolean init()
{
    if (isInitialized())
        return true;

    boolean state = glfwInit();

    // Return immediately in case of error
    if (!state)
        return initialized = false;

    // Error callback that does nothing
    setErrorCallback(null);
    glfwErrorCallback = GLFWErrorCallback.create((error, description) ->
            errorCallback.invoke(error, MemoryUtil.memUTF8(description)));

    // Joystick callback that does nothing
    setJoystickCallback(null);
    glfwJoystickCallback = GLFWJoystickCallback.create((joy, event) ->
            joystickCallback.invoke(joy, event == GLFW_CONNECTED));

    // Register the callback
    glfwSetErrorCallback(glfwErrorCallback);

    return initialized = true;
}