org.lwjgl.input.Keyboard.isRepeatEvent()方法的使用及代码示例

x33g5p2x  于2022-01-23 转载在 其他  
字(3.4k)|赞(0)|评价(0)|浏览(123)

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

Keyboard.isRepeatEvent介绍

暂无

代码示例

代码示例来源:origin: MovingBlocks/Terasology

@Override
  public Queue<KeyboardAction> getInputQueue() {
    Queue<KeyboardAction> result = Queues.newArrayDeque();

    while (Keyboard.next()) {
      ButtonState state;
      if (Keyboard.isRepeatEvent()) {
        state = ButtonState.REPEAT;
      } else {
        state = (Keyboard.getEventKeyState()) ? ButtonState.DOWN : ButtonState.UP;
      }
      Input input = InputType.KEY.getInput(Keyboard.getEventKey());
      result.add(new KeyboardAction(input, state, Keyboard.getEventCharacter()));
    }

    return result;
  }
}

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

public void update() {
  if (!context.isRenderable())
    return;
  
  Keyboard.poll();
  while (Keyboard.next()){
    int keyCode = Keyboard.getEventKey();
    char keyChar = Keyboard.getEventCharacter();
    boolean pressed = Keyboard.getEventKeyState();
    boolean down = Keyboard.isRepeatEvent();
    long time = Keyboard.getEventNanoseconds();
    KeyInputEvent evt = new KeyInputEvent(keyCode, keyChar, pressed, down);
    evt.setTime(time);
    listener.onKeyEvent(evt);
  }
}

代码示例来源:origin: Vazkii/Botania

@SubscribeEvent
public static void buttonPressed(KeyboardInputEvent.Post event) {
  Minecraft mc = Minecraft.getMinecraft();
  if(mc.world == null || !supportedGuiFilter.test(mc.currentScreen)
      || Keyboard.getEventKey() != ClientProxy.CORPOREA_REQUEST.getKeyCode()
      || !Keyboard.getEventKeyState()
      || Keyboard.isRepeatEvent()
      || TileCorporeaIndex.InputHandler.getNearbyIndexes(mc.player).isEmpty())
    return;
  ItemStack stack = getStackUnderMouse();
  if(stack != null && !stack.isEmpty()) {
    int count = 1;
    int max = stack.getMaxStackSize();
    if(GuiScreen.isShiftKeyDown()) {
      count = max;
      if(GuiScreen.isCtrlKeyDown())
        count /= 4;
    } else if(GuiScreen.isCtrlKeyDown())
      count = max / 2;
    if(count > 0) {
      String name = CorporeaHelper.stripControlCodes(stack.getDisplayName());
      String full = count + " " + name;
      mc.ingameGUI.getChatGUI().addToSentMessages(full);
      mc.player.sendChatMessage(full);
      event.setCanceled(true);
    }
  }
}

代码示例来源:origin: Mine-and-blade-admin/Battlegear2

@SubscribeEvent
public void keyDown(InputEvent.KeyInputEvent event) {
  if (Keyboard.getEventKeyState() && !Keyboard.isRepeatEvent()) {
    doKey(Keyboard.getEventKey());
  }
}

代码示例来源:origin: SquidDev-CC/plethora

@SubscribeEvent
@SideOnly(Side.CLIENT)
public void onInputEvent(InputEvent.KeyInputEvent event) {
  if (!listen) {
    // If we're not listening then clear the lookup of keys which are down and exit.
    keysDown.clear();
    return;
  }
  if (Keyboard.getEventKeyState()) {
    char ch = Keyboard.getEventCharacter();
    int key = Keyboard.getEventKey();
    boolean repeat = Keyboard.isRepeatEvent();
    ch = ch >= 32 && ch <= 126 || ch >= 160 && ch <= 255 ? ch : '\0';
    if (key > 0 || ch != '\0') {
      keyPresses.add(new KeyPress(key, repeat, ch));
      boolean found = false;
      for (KeyDown down : keysDown) {
        if (down.key == key) {
          down.lastTime = Minecraft.getSystemTime();
          found = true;
          break;
        }
      }
      if (!found) keysDown.add(new KeyDown(key, ch));
    }
  }
}

代码示例来源:origin: us.ihmc.thirdparty.jme/jme3-lwjgl

public void update() {
  if (!context.isRenderable())
    return;
  
  Keyboard.poll();
  while (Keyboard.next()){
    int keyCode = Keyboard.getEventKey();
    char keyChar = Keyboard.getEventCharacter();
    boolean pressed = Keyboard.getEventKeyState();
    boolean down = Keyboard.isRepeatEvent();
    long time = Keyboard.getEventNanoseconds();
    KeyInputEvent evt = new KeyInputEvent(keyCode, keyChar, pressed, down);
    evt.setTime(time);
    listener.onKeyEvent(evt);
  }
}

相关文章