@Override public void setCursorVisible(boolean visible) { cursorVisible = visible; if (!context.isRenderable()) { return; } if (cursorVisible) { glfwSetInputMode(context.getWindowHandle(), GLFW_CURSOR, GLFW_CURSOR_NORMAL); } else { glfwSetInputMode(context.getWindowHandle(), GLFW_CURSOR, GLFW_CURSOR_DISABLED); } }
glfwSetKeyCallback(context.getWindowHandle(), keyCallback = new GLFWKeyCallback() { @Override public void invoke(final long window, final int key, final int scancode, final int action, final int mods) { glfwSetCharCallback(context.getWindowHandle(), charCallback = new GLFWCharCallback() { @Override public void invoke(final long window, final int codepoint) {
@Override public void setNativeCursor(final JmeCursor jmeCursor) { if (jmeCursor != null) { final long[] glfwCursor = jmeToGlfwCursorMap.computeIfAbsent(jmeCursor, GlfwMouseInput::createGlfwCursor); currentCursorFrame = 0; currentCursor = glfwCursor; currentCursorDelays = null; currentCursorFrameStartTime = glfwGetTime(); if (jmeCursor.getImagesDelay() != null) { currentCursorDelays = jmeCursor.getImagesDelay(); } glfwSetCursor(context.getWindowHandle(), glfwCursor[currentCursorFrame]); } else { currentCursor = null; currentCursorDelays = null; glfwSetCursor(context.getWindowHandle(), MemoryUtil.NULL); } }
@Override public void update() { // Manage cursor animation if (currentCursor != null && currentCursor.length > 1) { double now = glfwGetTime(); double frameTime = (glfwGetTime() - currentCursorFrameStartTime) * 1000; if (currentCursorDelays == null || frameTime >= currentCursorDelays.get(currentCursorFrame)) { currentCursorFrame = ++currentCursorFrame % currentCursor.length; currentCursorFrameStartTime = now; glfwSetCursor(context.getWindowHandle(), currentCursor[currentCursorFrame]); } } // Process events while (!mouseMotionEvents.isEmpty()) { listener.onMouseMotionEvent(mouseMotionEvents.poll()); } while (!mouseButtonEvents.isEmpty()) { listener.onMouseButtonEvent(mouseButtonEvents.poll()); } }
@Override public void initialize() { final long window = context.getWindowHandle();
int origWidth = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDisplayMode().getWidth(); int origHeight = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDisplayMode().getHeight(); long window = ((LwjglWindow)environment.getApplication().getContext()).getWindowHandle(); Vector2f windowSize = new Vector2f(); ((OSVR)environment.getVRHardware()).getRenderSize(windowSize);
GLFW.glfwSetInputMode(((LwjglWindow)environment.getApplication().getContext()).getWindowHandle(), GLFW.GLFW_CURSOR, GLFW.GLFW_CURSOR_DISABLED);
@Override public void setCursorVisible(boolean visible) { cursorVisible = visible; if (!context.isRenderable()) { return; } if (cursorVisible) { glfwSetInputMode(context.getWindowHandle(), GLFW_CURSOR, GLFW_CURSOR_NORMAL); } else { glfwSetInputMode(context.getWindowHandle(), GLFW_CURSOR, GLFW_CURSOR_DISABLED); } }
@Override public void initialize() { glfwSetCursorPosCallback(context.getWindowHandle(), cursorPosCallback = new GLFWCursorPosCallback() { @Override public void invoke(long window, double xpos, double ypos) { glfwSetScrollCallback(context.getWindowHandle(), scrollCallback = new GLFWScrollCallback() { @Override public void invoke(final long window, final double xOffset, final double yOffset) { glfwSetMouseButtonCallback(context.getWindowHandle(), mouseButtonCallback = new GLFWMouseButtonCallback() { @Override public void invoke(final long window, final int button, final int action, final int mods) {
@Override public void update() { // Manage cursor animation if (currentCursor != null && currentCursor.length > 1) { double now = glfwGetTime(); double frameTime = (glfwGetTime() - currentCursorFrameStartTime) * 1000; if (currentCursorDelays == null || frameTime >= currentCursorDelays.get(currentCursorFrame)) { currentCursorFrame = ++currentCursorFrame % currentCursor.length; currentCursorFrameStartTime = now; glfwSetCursor(context.getWindowHandle(), currentCursor[currentCursorFrame]); } } // Process events while (!mouseMotionEvents.isEmpty()) { listener.onMouseMotionEvent(mouseMotionEvents.poll()); } while (!mouseButtonEvents.isEmpty()) { listener.onMouseButtonEvent(mouseButtonEvents.poll()); } }
glfwSetKeyCallback(context.getWindowHandle(), keyCallback = new GLFWKeyCallback() { @Override public void invoke(long window, int key, int scancode, int action, int mods) { glfwSetCharCallback(context.getWindowHandle(), charCallback = new GLFWCharCallback() {
@Override public void setNativeCursor(JmeCursor jmeCursor) { if (jmeCursor != null) { long[] glfwCursor = jmeToGlfwCursorMap.get(jmeCursor); if (glfwCursor == null) { glfwCursor = createGlfwCursor(jmeCursor); jmeToGlfwCursorMap.put(jmeCursor, glfwCursor); } currentCursorFrame = 0; currentCursor = glfwCursor; currentCursorDelays = null; currentCursorFrameStartTime = glfwGetTime(); if (jmeCursor.getImagesDelay() != null) { currentCursorDelays = jmeCursor.getImagesDelay(); } glfwSetCursor(context.getWindowHandle(), glfwCursor[currentCursorFrame]); } else { currentCursor = null; currentCursorDelays = null; glfwSetCursor(context.getWindowHandle(), MemoryUtil.NULL); } }