本文整理汇总了Java中org.lwjgl.glfw.GLFW.glfwSetKeyCallback方法的典型用法代码示例。如果您正苦于以下问题:Java GLFW.glfwSetKeyCallback方法的具体用法?Java GLFW.glfwSetKeyCallback怎么用?Java GLFW.glfwSetKeyCallback使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.lwjgl.glfw.GLFW
的用法示例。
在下文中一共展示了GLFW.glfwSetKeyCallback方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: KeyboardHandler
import org.lwjgl.glfw.GLFW; //导入方法依赖的package包/类
public KeyboardHandler(long windowID) {
this.keyCallback = new KeyboardKeyCallback(windowID);
this.charCallback = new KeyboardCharCallback(windowID);
this.modCallback = new KeyboardCharModsCallback(windowID);
this.windowID = windowID;
//Register the callbacks with GLFW
GLFW.glfwSetKeyCallback(windowID, this.keyCallback);
GLFW.glfwSetCharCallback(windowID, this.charCallback);
GLFW.glfwSetCharModsCallback(windowID, this.modCallback);
}
示例2: setKeyCallback
import org.lwjgl.glfw.GLFW; //导入方法依赖的package包/类
/**
* Sets the key callback for the window
* @param callback The callback that will receive keyboard input
*/
public void setKeyCallback(GLFWKeyCallback callback) throws IllegalStateException {
if(handle == 0) {
throw new IllegalStateException("handle is NULL");
}
GLFW.glfwSetKeyCallback(handle, callback);
}
示例3: KeyboardHandler
import org.lwjgl.glfw.GLFW; //导入方法依赖的package包/类
KeyboardHandler(Window window)
{
this.window = window;
GLFWKeyCallbackI keyCallback = null;
try
{
keyCallback = GLFW.glfwSetKeyCallback(this.window.handle(),
(handle, key, scancode, action, mods) ->
{
ButtonInput input = this.getButton(key);
if (input != null)
{
if (action == GLFW.GLFW_RELEASE)
{
input.release();
}
else if (action == GLFW.GLFW_PRESS)
{
input.press();
}
else
{
//Ignore repeating input...
}
}
});
if (keyCallback != null)
{
throw new IllegalStateException("another keyboard handler is already registered!");
}
}
catch (Exception e)
{
//Reset to previous state
GLFW.glfwSetKeyCallback(this.window.handle(), keyCallback);
throw e;
}
}