org.lwjgl.glfw.GLFW.glfwSetInputMode()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(6.1k)|赞(0)|评价(0)|浏览(372)

本文整理了Java中org.lwjgl.glfw.GLFW.glfwSetInputMode()方法的一些代码示例,展示了GLFW.glfwSetInputMode()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。GLFW.glfwSetInputMode()方法的具体详情如下:
包路径:org.lwjgl.glfw.GLFW
类名称:GLFW
方法名:glfwSetInputMode

GLFW.glfwSetInputMode介绍

[英]Sets an input option for the specified window.

If mode is #GLFW_CURSOR, the value must be one of the following cursor modes:

  • #GLFW_CURSOR_NORMAL makes the cursor visible and behaving normally.
  • #GLFW_CURSOR_HIDDEN makes the cursor invisible when it is over the client area of the window but does not restrict the cursor from leaving.
  • #GLFW_CURSOR_DISABLED hides and grabs the cursor, providing virtual and unlimited cursor movement. This is useful for implementing for example 3D camera controls.

If mode is #GLFW_STICKY_KEYS, the value must be either #GLFW_TRUE to enable sticky keys, or #GLFW_FALSE to disable it. If sticky keys are enabled, a key press will ensure that #glfwGetKey returns #GLFW_PRESS the next time it is called even if the key had been released before the call. This is useful when you are only interested in whether keys have been pressed but not when or in which order.

If mode is #GLFW_STICKY_MOUSE_BUTTONS, the value must be either #GLFW_TRUE to enable sticky mouse buttons, or #GLFW_FALSE to disable it. If sticky mouse buttons are enabled, a mouse button press will ensure that #glfwGetMouseButton returns #GLFW_PRESS the next time it is called even if the mouse button had been released before the call. This is useful when you are only interested in whether mouse buttons have been pressed but not when or in which order.

If mode is #GLFW_LOCK_KEY_MODS, the value must be either #GLFW_TRUE to enable lock key modifier bits, or #GLFW_FALSE to disable them. If enabled, callbacks that receive modifier bits will also have the #GLFW_MOD_CAPS_LOCK bit set when the event was generated with Caps Lock on, and the #GLFW_MOD_NUM_LOCK bit when Num Lock was on.

This function must only be called from the main thread.
[中]设置指定窗口的输入选项。
如果模式为#GLFW_光标,则该值必须为以下光标模式之一:
*#GLFW_CURSOR_NORMAL使光标可见并正常运行。
*#GLFW_CURSOR_HIDDEN当光标位于窗口的客户端区域上时,使光标不可见,但不限制光标离开。
*#GLFW_CURSOR_DISABLED隐藏并抓取光标,提供虚拟且无限制的光标移动。这对于实现例如3D摄影机控件非常有用。
如果模式为#GLFW_STICKY_KEYS,则该值必须为#GLFW_TRUE以启用粘滞键,或为#GLFW_FALSE以禁用粘滞键。如果启用了粘滞键,则按键将确保#glfwGetKey在下次调用时返回#GLFW#U按,即使在调用前已释放该键。当您只关心按键是否已按下,而不关心按键的时间或顺序时,此功能非常有用。
如果模式为#GLFW_STICKY_MOUSE_BUTTONS,则该值必须为#GLFW_TRUE以启用粘滞鼠标按钮,或者为#GLFW_FALSE以禁用它。如果启用了粘性鼠标按钮,则按下鼠标按钮将确保#glfwGetMouseButton返回#GLFW#在下次调用时按下鼠标按钮,即使在调用之前已释放鼠标按钮。当您只关心鼠标按钮是否已按下,而不关心鼠标按钮按下的时间或顺序时,此功能非常有用。
如果模式为#GLFW_LOCK_KEY_MODS,则该值必须为#GLFW_TRUE以启用锁定键修改器位,或者为#GLFW_FALSE以禁用它们。如果启用,接收修饰符位的回调在CAPS LOCK打开时生成事件时也将设置#GLFW_MOD_CAPS_LOCK位,在NUM LOCK打开时设置#GLFW_MOD_NUM_LOCK位。
只能从主线程调用此函数。

代码示例

代码示例来源:origin: libgdx/libgdx

@Override
public void setCursorCatched(boolean catched) {
  GLFW.glfwSetInputMode(window.getWindowHandle(), GLFW.GLFW_CURSOR, catched ? GLFW.GLFW_CURSOR_DISABLED : GLFW.GLFW_CURSOR_NORMAL);
}

代码示例来源:origin: libgdx/libgdx

@Override
public void setCursorCatched(boolean catched) {
  GLFW.glfwSetInputMode(window.getWindowHandle(), GLFW.GLFW_CURSOR, catched ? GLFW.GLFW_CURSOR_DISABLED : GLFW.GLFW_CURSOR_NORMAL);
}

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

@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);
  }
}

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

@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);
  }
}

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

/**
 * Hide the active cursor within the display.
 */
public void hideActiveCursor() {
  if (!context.isRenderable()) {
    return;
  }
  if (cursorVisible) {
    glfwSetInputMode(context.getWindowHandle(), GLFW_CURSOR, GLFW_CURSOR_HIDDEN);            
  }
}

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

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.");
}

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

GLFW.glfwSetInputMode(((LwjglWindow)environment.getApplication().getContext()).getWindowHandle(), GLFW.GLFW_CURSOR, GLFW.GLFW_CURSOR_DISABLED);

代码示例来源:origin: playn/playn

@Override public void setMouseLocked(boolean locked) {
 glfwSetInputMode(window, GLFW_CURSOR, locked ? GLFW_CURSOR_DISABLED : GLFW_CURSOR_NORMAL);
}

代码示例来源:origin: sriharshachilakapati/SilenceEngine

glfwSetInputMode(handle, mode, value);

代码示例来源:origin: Renanse/Ardor3D

@Override
public void setGrabbed(final GrabbedState grabbedState) {
  _grabbedState = grabbedState;
  GLFW.glfwSetInputMode(_canvas.getWindowId(), GLFW.GLFW_CURSOR,
      grabbedState == GrabbedState.GRABBED ? GLFW.GLFW_CURSOR_DISABLED : GLFW.GLFW_CURSOR_NORMAL);
}

代码示例来源:origin: com.badlogicgames.gdx/gdx-backend-lwjgl3

@Override
public void setCursorCatched(boolean catched) {
  GLFW.glfwSetInputMode(window.getWindowHandle(), GLFW.GLFW_CURSOR, catched ? GLFW.GLFW_CURSOR_DISABLED : GLFW.GLFW_CURSOR_NORMAL);
}

代码示例来源:origin: org.jmonkeyengine/jme3-lwjgl3

@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);
  }
}

代码示例来源:origin: FedUni/caliko

glfwSetInputMode(mWindowId, GLFW_CURSOR, GLFW_CURSOR_DISABLED);
break;
glfwSetInputMode(windowId, GLFW_CURSOR, GLFW_CURSOR_NORMAL);
CalikoDemo3D.camera.resetLastCursorPosition();
break;

相关文章

GLFW类方法