public void setNativeCursor(JmeCursor jmeCursor) { if (jmeCursor != null) { Long glfwCursor = jmeToGlfwCursorMap.get(jmeCursor); if (glfwCursor == null) { glfwCursor = createGlfwCursor(jmeCursor); jmeToGlfwCursorMap.put(jmeCursor, glfwCursor); } glfwSetCursor(context.getWindowHandle(), glfwCursor); } else { glfwSetCursor(context.getWindowHandle(), MemoryUtil.NULL); } }
@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); } }
/** * Hide the active cursor within the display. */ public void hideActiveCursor() { if (!context.isRenderable()) { return; } if (cursorVisible) { glfwSetInputMode(context.getWindowHandle(), GLFW_CURSOR, GLFW_CURSOR_HIDDEN); } }
/** * Set the position of the cursor on the display. * @param x the x position of the cursor (pixel). * @param y the y position of the cursor (pixel). */ public void setCursorPosition(int x, int y) { if (!context.isRenderable()) { return; } glfwSetCursorPos(context.getWindowHandle(), x, y); }
public void initialize() { glfwSetCursorPosCallback(context.getWindowHandle(), cursorPosCallback = new GLFWCursorPosCallback() { @Override public void invoke(long window, double xpos, double ypos) { onCursorPos(window, xpos, ypos); } }); glfwSetScrollCallback(context.getWindowHandle(), scrollCallback = new GLFWScrollCallback() { @Override public void invoke(final long window, final double xOffset, final double yOffset) { onWheelScroll(window, xOffset, yOffset * WHEEL_SCALE); } }); glfwSetMouseButtonCallback(context.getWindowHandle(), mouseButtonCallback = new GLFWMouseButtonCallback() { @Override public void invoke(final long window, final int button, final int action, final int mods) { onMouseButton(window, button, action, mods); } }); setCursorVisible(cursorVisible); logger.fine("Mouse created."); initialized = true; }
public void initialize() { if (!context.isRenderable()) { return; } glfwSetKeyCallback(context.getWindowHandle(), keyCallback = new GLFWKeyCallback() { @Override public void invoke(long window, int key, int scancode, int action, int mods) { scancode = GlfwKeyMap.toJmeKeyCode(key); if( key == GLFW_KEY_LEFT_SHIFT || key == GLFW_KEY_RIGHT_SHIFT ) { shift_pressed = (action == GLFW_PRESS); } else if( key >= 'A' && key <= 'Z' && !shift_pressed ) { key += 32; // make lowercase } else if( key >= 'a' && key <= 'z' && shift_pressed ) { key -= 32; // make uppercase } final KeyInputEvent evt = new KeyInputEvent(scancode, (char) key, GLFW_PRESS == action, GLFW_REPEAT == action); evt.setTime(getInputTimeNanos()); keyInputEvents.add(evt); } }); glfwSetInputMode(context.getWindowHandle(), GLFW_STICKY_KEYS, 1); initialized = true; logger.fine("Keyboard created."); }