Java Code Examples for org.lwjgl.input.Keyboard#isRepeatEvent()

The following examples show how to use org.lwjgl.input.Keyboard#isRepeatEvent() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PauseOverlay.java    From opsu-dance with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void keyPressed(KeyEvent e)
{
	e.consume();
	if (e.keyCode == KEY_S && input.isControlDown()) {
		gameState.saveCheckpoint();
	} else if (e.keyCode == KEY_SUBTRACT || e.keyCode == KEY_MINUS || e.chr == '-') {
		gameState.adjustLocalMusicOffset(-5);
	} else if (e.keyCode == KEY_EQUALS || e.keyCode == KEY_ADD || e.chr == '+') {
		gameState.adjustLocalMusicOffset(5);
	}

	if (!Keyboard.isRepeatEvent()) {
		if (e.keyCode == OPTION_KEY_LEFT.keycode ||
			e.keyCode == OPTION_KEY_RIGHT.keycode)
		{
			if (this.readyToResume) {
				this.resumeIfClickedInPausedPosition(e, mouseX, mouseY);
			} else {
				this.checkButtonClick(mouseX, mouseY);
			}
		}
	}
}
 
Example 2
Source File: Game.java    From FEMultiPlayer-V2 with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Gets the input.
 *
 * @return the input
 */
public static void getInput() {
	Keyboard.poll();
	keys.clear();
	while(Keyboard.next()) {
		KeyboardEvent ke = new KeyboardEvent(Keyboard.getEventKey(), Keyboard.getEventCharacter(),
        Keyboard.isRepeatEvent(), Keyboard.getEventKeyState(), KeyboardEvent.generateModifiers());
		keys.add(ke);
	}
	Mouse.poll();
	mouseEvents.clear();
	while(Mouse.next()) {
		MouseEvent me = new MouseEvent(
				Mouse.getEventX(),
				Mouse.getEventY(),
				Mouse.getEventDWheel(),
				Mouse.getEventButton(),
				Mouse.getEventButtonState());
		mouseEvents.add(me);
	}
}
 
Example 3
Source File: LwjglKeyInput.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
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);
    }
}
 
Example 4
Source File: Game.java    From FEMultiplayer with GNU General Public License v3.0 6 votes vote down vote up
public static void getInput() {
	Keyboard.poll();
	keys.clear();
	while(Keyboard.next()) {
		KeyboardEvent ke = new KeyboardEvent(
				Keyboard.getEventKey(),
				Keyboard.getEventCharacter(),
				Keyboard.isRepeatEvent(),
				Keyboard.getEventKeyState());
		keys.add(ke);
	}
	Mouse.poll();
	mouseEvents.clear();
	while(Mouse.next()) {
		MouseEvent me = new MouseEvent(
				Mouse.getEventX(),
				Mouse.getEventY(),
				Mouse.getEventDWheel(),
				Mouse.getEventButton(),
				Mouse.getEventButtonState());
		mouseEvents.add(me);
	}
}
 
Example 5
Source File: GuiCapture.java    From OpenPeripheral-Addons with MIT License 6 votes vote down vote up
@Override
public void handleKeyboardInput() {
	final int key = Keyboard.getEventKey();

	if (key == Keyboard.KEY_ESCAPE) {
		this.mc.displayGuiScreen(null);
		this.mc.setIngameFocus();
	} else {
		final boolean state = Keyboard.getEventKeyState();
		if (state) {
			final char ch = sanitizeKeyChar(Keyboard.getEventCharacter());

			final boolean isRepeat = Keyboard.isRepeatEvent();
			new GlassesKeyDownEvent(guid, ch, key, isRepeat).sendToServer();
		} else {
			new GlassesKeyUpEvent(guid, key).sendToServer();
		}
	}

	// looks like twitch controls
	super.handleKeyboardInput();
}
 
Example 6
Source File: LwjglKeyInput.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 6 votes vote down vote up
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);
    }
}
 
Example 7
Source File: HyperiumMinecraft.java    From Hyperium with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void runTickKeyboard() {
    int key = Keyboard.getEventKey();
    boolean repeat = Keyboard.isRepeatEvent();
    boolean press = Keyboard.getEventKeyState();
    EventBus.INSTANCE.post(press ? new KeyPressEvent(key, repeat) : new KeyReleaseEvent(key, repeat));
}
 
Example 8
Source File: OptionsOverlay.java    From opsu-dance with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void keyPressed(KeyEvent e)
{
	e.consume();

	if (keyEntryRight) {
		if (Utils.isValidGameKey(e.keyCode)) {
			OPTION_KEY_RIGHT.setKeycode(e.keyCode);
		}
		keyEntryRight = false;
		return;
	}

	if (keyEntryLeft) {
		if (Utils.isValidGameKey(e.keyCode)) {
			OPTION_KEY_LEFT.setKeycode(e.keyCode);
		}
		keyEntryLeft = false;
		return;
	}

	if (e.keyCode == Keyboard.KEY_ESCAPE) {
		if (isAdjustingSlider) {
			cancelAdjustingSlider();
		}
		if (lastSearchText.length() != 0) {
			resetSearch();
			updateHoverOption(
				prevMouseX,
				prevMouseY,
				displayContainer.suppressHover
			);
			return;
		}
		this.exit();
		return;
	}

	if ((e.keyCode == Keyboard.KEY_RSHIFT || e.keyCode == Keyboard.KEY_LSHIFT) &&
		!Keyboard.isRepeatEvent() &&
		this.isAdjustingSlider)
	{
		this.sliderOptionPrecisionStartX = mouseX;
	}

	searchField.keyPressed(e);
	if (!searchField.getText().equals(lastSearchText)) {
		String newSearchText = searchField.getText().toLowerCase();
		if (!hasSearchResults(newSearchText)) {
			searchField.setText(lastSearchText);
			invalidSearchAnimationProgress = INVALID_SEARCH_ANIMATION_TIME;
			Random rand = new Random();
			invalidSearchImgRotation = 10 + rand.nextInt(10);
			invalidSearchTextRotation = 10 + rand.nextInt(10);
			if (rand.nextBoolean()) {
				invalidSearchImgRotation = -invalidSearchImgRotation;
			}
			if (rand.nextBoolean()) {
				invalidSearchTextRotation = -invalidSearchTextRotation;
			}
		} else {
			lastSearchText = newSearchText;
			updateSearch();
		}
	}
}
 
Example 9
Source File: GamePauseMenu.java    From opsu with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void keyPressed(int key, char c) {
	if (UI.globalKeyPressed(key))
		return;

	// game keys
	if (!Keyboard.isRepeatEvent()) {
		if (key == Options.getGameKeyLeft())
			mousePressed(Input.MOUSE_LEFT_BUTTON, input.getMouseX(), input.getMouseY());
		else if (key == Options.getGameKeyRight())
			mousePressed(Input.MOUSE_RIGHT_BUTTON, input.getMouseX(), input.getMouseY());
	}

	switch (key) {
	case Input.KEY_ESCAPE:
		// 'esc' will normally unpause, but will return to song menu if health is zero
		if (gameState.getPlayState() == Game.PlayState.LOSE) {
			SoundController.playSound(SoundEffect.MENUBACK);
			((SongMenu) game.getState(Opsu.STATE_SONGMENU)).resetGameDataOnLoad();
			MusicController.playAt(MusicController.getBeatmap().previewTime, true);
			if (UI.getCursor().isBeatmapSkinned())
				UI.getCursor().reset();
			game.enterState(Opsu.STATE_SONGMENU, new EasedFadeOutTransition(), new FadeInTransition());
		} else {
			if (!Options.isGameplaySoundDisabled())
				SoundController.playSound(SoundEffect.MENUBACK);
			gameState.setPlayState(Game.PlayState.NORMAL);
			game.enterState(Opsu.STATE_GAME);
		}
		break;
	case Input.KEY_R:
		// restart
		if (input.isKeyDown(Input.KEY_RCONTROL) || input.isKeyDown(Input.KEY_LCONTROL)) {
			gameState.setPlayState(Game.PlayState.RETRY);
			game.enterState(Opsu.STATE_GAME);
		}
		break;
	case Input.KEY_EQUALS:
	case Input.KEY_ADD:
	case Input.KEY_MINUS:
	case Input.KEY_SUBTRACT:
		UI.getNotificationManager().sendBarNotification("Offset can only be changed while game is not paused.");
		break;
	}
}