private void sendItemWidgetClicked(final int mouseX, final int mouseY, final int mouseButton) { for (int index = 0; index < this.widgetCount; ++index) { WidgetAEItem currentWidget = this.itemWidgets.get(index); if (currentWidget.isMouseOverWidget(mouseX, mouseY)) { IAEItemStack widgetStack = currentWidget.getItemStack(); if (widgetStack != null) { if (widgetStack.getStackSize() == 0) { if (widgetStack.isCraftable()) { // new PacketChiselingTerminalServer().createRequestAutoCraft( this.player, // widgetStack ).sendPacketToServer(); } } else { boolean isShiftHeld = Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT); new PacketChiselingTerminalServer() .createRequestExtract(this.entityPlayer, widgetStack, mouseButton, isShiftHeld) .sendPacketToServer(); } } return; } } }
/** Called each tick so GUIs can handle their input. */ @Override public void handleInput() throws IOException { if (Mouse.isCreated()) { while (Mouse.next()) { if (!MinecraftForge.EVENT_BUS.post( new net.minecraftforge.client.event.GuiScreenEvent.MouseInputEvent.Pre(this))) { this.handleMouseInput(); if (this.equals(this.mc.currentScreen)) { MinecraftForge.EVENT_BUS.post( new net.minecraftforge.client.event.GuiScreenEvent.MouseInputEvent.Post(this)); } } } } if (Keyboard.isCreated()) { while (Keyboard.next()) { if (!MinecraftForge.EVENT_BUS.post( new net.minecraftforge.client.event.GuiScreenEvent.KeyboardInputEvent.Pre(this))) { this.handleKeyboardInput(); if (this.equals(this.mc.currentScreen)) { MinecraftForge.EVENT_BUS.post( new net.minecraftforge.client.event.GuiScreenEvent.KeyboardInputEvent.Post(this)); } } } } }
@Override @SideOnly(Side.CLIENT) public void addInformation( ItemStack itemStack, EntityPlayer entityPlayer, List descriptionList, boolean noClueWhatThisEvenDoes) { if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) { descriptionList.add(OUtil.colorString("&&dSteve not included.&&7")); switch (itemStack.getItemDamage()) { case 0: descriptionList.add(OUtil.colorString("A boat made of &&esturdy planks&&7.")); descriptionList.add("Doubt it will last long."); break; case 1: descriptionList.add(OUtil.colorString("A boat made of &&fIron&&7, should")); descriptionList.add("last a while."); break; case 2: descriptionList.add(OUtil.colorString("Made of purely &&6Atlantium&&7,")); descriptionList.add("almost indestructable."); } } else { descriptionList.add(OUtil.colorString("Hold &&9SHIFT &&7for more information")); } }
@Override public void handleKeyboardInput() { super.handleKeyboardInput(); if (Keyboard.getEventKeyState()) { int key = Keyboard.getEventKey(); if (key == Keyboard.KEY_UP) { navigateMap(0, navigateStep); } else if (key == Keyboard.KEY_DOWN) { navigateMap(0, -navigateStep); } else if (key == Keyboard.KEY_LEFT) { navigateMap(navigateStep, 0); } else if (key == Keyboard.KEY_RIGHT) { navigateMap(-navigateStep, 0); } else if (key == Keyboard.KEY_ADD || key == Keyboard.KEY_EQUALS) { setMapScale(mapScale * 2); } else if (key == Keyboard.KEY_SUBTRACT || key == Keyboard.KEY_MINUS) { setMapScale(mapScale / 2); } // Close the GUI if a hotbar key is pressed else { KeyBinding[] hotbarKeys = mc.gameSettings.keyBindsHotbar; for (KeyBinding bind : hotbarKeys) { if (key == bind.getKeyCode()) { close(); break; } } } } }
/** Run the main game loop. */ public void run() { while (gameRunning) { // reset drawCount mapCount = 0; drawCount = 0; // clear screen gameWindow.clearScreen(); // get delta timer.update(); long delta = timer.getDelta(); // update state stateManager.input(delta); stateManager.update(delta); stateManager.draw(); // draw DebugHUD debugHUD.draw(); // if escape has been pressed, stop the game if ((Display.isCloseRequested() || Keyboard.isKeyDown(Keyboard.KEY_ESCAPE) && Keyboard.isKeyDown(Keyboard.KEY_LSHIFT))) { gameRunning = false; } // update window contents gameWindow.update(); } }
@SideOnly(Side.CLIENT) @Override public void addInformation( ItemStack itemStack, EntityPlayer player, List list, boolean whatIsThis) { super.addInformation(itemStack, player, list, whatIsThis); NBTTagCompound tagCompound = itemStack.getTagCompound(); int channel = -1; if (tagCompound != null) { channel = tagCompound.getInteger("channel"); } if (channel != -1) { list.add(EnumChatFormatting.YELLOW + "Channel: " + channel); } else { list.add(EnumChatFormatting.YELLOW + "Channel is not set!"); } if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) { list.add(EnumChatFormatting.WHITE + "Sneak right-click on a space chamber controller"); list.add(EnumChatFormatting.WHITE + "to set the channel for this card."); list.add(EnumChatFormatting.WHITE + "Right-click in the air to show an overview of"); list.add(EnumChatFormatting.WHITE + "the area contents."); list.add(EnumChatFormatting.WHITE + "Insert it in a builder to copy/move the"); list.add(EnumChatFormatting.WHITE + "linked area"); } else { list.add(EnumChatFormatting.WHITE + RFTools.SHIFT_MESSAGE); } }
private void keyboardHandler() { while (Keyboard.next()) { if (Keyboard.isKeyDown(Keyboard.KEY_RETURN)) { openConsole(); } } }
public void isEscapePressed() { while (Keyboard.next()) { if (Keyboard.getEventKey() == Keyboard.KEY_ESCAPE) { shutdown = true; } } }
private static void initControls() { // Automatically create mouse, keyboard and controller if (!getPrivilegedBoolean("org.lwjgl.opengl.Display.noinput")) { if (!Mouse.isCreated() && !getPrivilegedBoolean("org.lwjgl.opengl.Display.nomouse")) { try { Mouse.create(); } catch (LWJGLException e) { if (LWJGLUtil.DEBUG) { e.printStackTrace(System.err); } else { LWJGLUtil.log("Failed to create Mouse: " + e); } } } if (!Keyboard.isCreated() && !getPrivilegedBoolean("org.lwjgl.opengl.Display.nokeyboard")) { try { Keyboard.create(); } catch (LWJGLException e) { if (LWJGLUtil.DEBUG) { e.printStackTrace(System.err); } else { LWJGLUtil.log("Failed to create Keyboard: " + e); } } } } }
/** Handles keyboard input. */ public void handleKeyboardInput() throws IOException { if (Keyboard.getEventKeyState()) { this.keyTyped(Keyboard.getEventCharacter(), Keyboard.getEventKey()); } this.mc.dispatchKeypresses(); }
private void handleKeyboardInputs() { // Kedboard.poll() checks for keyboard input, buffered Keyboard.poll(); while (Keyboard.next()) { // only consider KeyDown Events if (!Keyboard.getEventKeyState()) { continue; } switch (Keyboard.getEventKey()) { case Keyboard.KEY_ESCAPE: running = false; break; case Keyboard.KEY_S: gameView.drawSightRange = !gameView.drawSightRange; break; case Keyboard.KEY_M: gameView.drawMessages = !gameView.drawMessages; break; case Keyboard.KEY_PERIOD: ticksPerSecond *= 1.3; resetReferenceValues(); break; case Keyboard.KEY_COMMA: ticksPerSecond /= 1.3; resetReferenceValues(); break; case Keyboard.KEY_P: paused = !paused; break; } } }
@Override protected void update() { while (Keyboard.next()) { if (Keyboard.getEventKeyState()) { switch (Keyboard.getEventKey()) { case Keyboard.KEY_S: useFakeHallway = !useFakeHallway; if (useFakeHallway) { System.out.printf("Fake Hallway.\n"); } else { System.out.printf("Real Hallway.\n"); } break; case Keyboard.KEY_P: useSmoothInterpolation = !useSmoothInterpolation; if (useSmoothInterpolation) { System.out.printf("Perspective correct interpolation.\n"); } else { System.out.printf("Just linear interpolation.\n"); } break; case Keyboard.KEY_ESCAPE: leaveMainLoop(); break; } } } }
public void beginStep() { List<KeyboardEvent> keys = Game.getKeys(); if (Keyboard.isKeyDown(Keyboard.KEY_LEFT) && repeatTimers[2] == 0) { repeatTimers[2] = 0.12f; yesHover = !yesHover; AudioPlayer.playAudio("cursor2", 1, 1); } if (Keyboard.isKeyDown(Keyboard.KEY_RIGHT) && repeatTimers[3] == 0) { repeatTimers[3] = 0.12f; yesHover = !yesHover; AudioPlayer.playAudio("cursor2", 1, 1); } for (KeyboardEvent ke : keys) { if (ke.state) { if (ke.key == Keyboard.KEY_RETURN || ke.key == Keyboard.KEY_Z) { AudioPlayer.playAudio("select", 1, 1); if (yesHover) confirm(); else cancel(); destroy(); } if (ke.key == Keyboard.KEY_X) { AudioPlayer.playAudio("cancel", 1, 1); cancel(); destroy(); } } } for (int i = 0; i < repeatTimers.length; i++) { if (repeatTimers[i] > 0) { repeatTimers[i] -= Game.getDeltaSeconds(); if (repeatTimers[i] < 0) repeatTimers[i] = 0; } } }
private void onKeyPressed(Player player, Keyboard key, boolean pressed, char ch) { final PlayerKeyEvent event = Spout.getEventManager().callEvent(new PlayerKeyEvent(player, key, pressed, ch)); if (event.isCancelled()) { return; } if (Spout.debugMode()) { Spout.log("Key " + key + " was " + (pressed ? "pressed" : "released")); } // SHIFT + TAB changes the focus index Screen in = getInputScreen(); if (key == FOCUS_KEY && pressed) { if (in != null) { if (org.lwjgl.input.Keyboard.isKeyDown(Keyboard.KEY_LSHIFT.getId()) || org.lwjgl.input.Keyboard.isKeyDown(Keyboard.KEY_RSHIFT.getId())) { in.previousFocus(FocusReason.KEYBOARD_TAB); } else { in.nextFocus(FocusReason.KEYBOARD_TAB); } } } // send event to the focused widget if (in != null) { Widget w = in.getFocusedWidget(); if (w != null) { w.onKey(event); } } executeBindings(getKeyBindingsFor(key), player, pressed); }
/** Creates the cell tooltip. */ @Override public void addInformation( final ItemStack essentiaCell, final EntityPlayer player, final List displayList, final boolean advancedItemTooltips) { // Get the contents of the cell IMEInventoryHandler<IAEFluidStack> handler = AEApi.instance() .registries() .cell() .getCellInventory(essentiaCell, null, StorageChannel.FLUIDS); // Ensure we have a cell inventory handler if (!(handler instanceof HandlerItemEssentiaCell)) { return; } // Cast to cell inventory handler HandlerItemEssentiaCell cellHandler = (HandlerItemEssentiaCell) handler; // Create the bytes tooltip String bytesTip = String.format( ThEStrings.Tooltip_CellBytes.getLocalized(), cellHandler.getUsedBytes(), cellHandler.getTotalBytes()); // Create the types tooltip String typesTip = String.format( ThEStrings.Tooltip_CellTypes.getLocalized(), cellHandler.getUsedTypes(), cellHandler.getTotalTypes()); // Add the tooltips displayList.add(bytesTip); displayList.add(typesTip); // Is the cell pre-formated? if (cellHandler.isPartitioned()) { displayList.add(GuiText.Partitioned.getLocal()); } // Does the cell have anything stored? if (cellHandler.getUsedTypes() > 0) { // Is shift being held? if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || (Keyboard.isKeyDown(Keyboard.KEY_RSHIFT))) { // Add information about the essentia types in the cell this.addContentsToCellDescription(cellHandler, displayList, player); } else { // Let the user know they can hold shift displayList.add( EnumChatFormatting.WHITE.toString() + EnumChatFormatting.ITALIC.toString() + ThEStrings.Tooltip_ItemStackDetails.getLocalized()); } } }
/* */ public synchronized void pollDevice() throws IOException { /* 76 */ if (!org.lwjgl.input.Keyboard.isCreated()) /* 77 */ return; /* 78 */ org.lwjgl.input.Keyboard.poll(); /* 79 */ for (Component component : getComponents()) { /* 80 */ Key key = (Key) component; /* 81 */ key.update(); /* */ } /* */ }
public void handleInput() { if (Keyboard.isKeyDown(Keyboard.KEY_SPACE)) { System.out.println("PAUSE"); } if (Keyboard.isKeyDown(Keyboard.KEY_ESCAPE)) { Display.destroy(); } }
private void doKeys() { while (Keyboard.next()) { char eventChar = Keyboard.getEventCharacter(); int eventKey = Keyboard.getEventKey(); long eventTick = Keyboard.getEventNanoseconds(); boolean eventState = Keyboard.getEventKeyState(); // System.out.println("doKeys("+eventKey+")"); if (eventKey == Keyboard.KEY_LSHIFT) { if (eventState) { mModifiers |= KeyEvent.VK_SHIFT; } else { mModifiers &= ~KeyEvent.VK_SHIFT; } } else if (eventKey == Keyboard.KEY_RSHIFT) { if (eventState) { mModifiers |= KeyEvent.VK_SHIFT; } else { mModifiers &= ~KeyEvent.VK_SHIFT; } } else if (eventKey == Keyboard.KEY_LCONTROL) { if (eventState) { mModifiers |= KeyEvent.VK_CONTROL; } else { mModifiers &= ~KeyEvent.VK_CONTROL; } } else if (eventKey == Keyboard.KEY_RCONTROL) { if (eventState) { mModifiers |= KeyEvent.VK_CONTROL; } else { mModifiers &= ~KeyEvent.VK_CONTROL; } } else if (eventKey == Keyboard.KEY_LMENU) { if (eventState) { mModifiers |= KeyEvent.VK_ALT; } else { mModifiers &= ~KeyEvent.VK_ALT; } } else if (eventKey == Keyboard.KEY_RMENU) { if (eventState) { mModifiers |= KeyEvent.VK_ALT; } else { mModifiers &= ~KeyEvent.VK_ALT; } } if (KEY_LWJGL_TO_AWT.containsKey(eventKey)) { eventKey = KEY_LWJGL_TO_AWT.get(eventKey); } KeyEvent e = new KeyEvent( this, eventState ? KeyEvent.KEY_PRESSED : KeyEvent.KEY_RELEASED, eventTick, mModifiers, eventKey, eventChar); fireKeyEvent(e); } }
private void input() { if (Keyboard.isKeyDown(Keyboard.KEY_UP)) { bat.setDY(-.2); } else if (Keyboard.isKeyDown(Keyboard.KEY_DOWN)) { bat.setDY(.2); } else { bat.setDY(0); } }
private void keyConfigSequence() { while (loop) { GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); try { menuTheme .getFont() .glDrawText( "\\c#FFFFFFKey Bindings", (Main.SCREEN_WIDTH - menuTheme.getFont().getStringWidth("Key Bindings")) / 2 + 2, 50); } catch (InvalidEscapeSequenceException e) { e.printStackTrace(); } Input.poll(); mouseEvents = Input.getMouseEvents(); keyEvents = Input.getKeyEvents(); try { drawKeyConfigText(margin, 75, 30); } catch (InvalidEscapeSequenceException e) { } for (GLUIComponent t : keyConfigTextField) { t.processKeyEvents(keyEvents); t.processMouseEvents(mouseEvents); t.update(0); t.renderGL(); } Display.update(); if (Display.isCloseRequested()) { Game.GAME_STATE = Game.GAME_STATE_QUIT; menu = false; loop = false; } else if (Keyboard.isKeyDown(Keyboard.KEY_ESCAPE)) { loop = false; } } for (GLUIComponent t : keyConfigTextField) { if (t instanceof GLTextField) { ((GLTextField) t).setText(((GLTextField) t).getText().toUpperCase()); KeyBindings.valueOf(t.getContext().toString()) .setUserKey(Keyboard.getKeyIndex(((GLTextField) t).getText())); } } }
public void func_569_f() { if (Keyboard.getEventKeyState()) { if (Keyboard.getEventKey() == 87) { this.field_945_b.func_6270_h(); return; } this.func_580_a(Keyboard.getEventCharacter(), Keyboard.getEventKey()); } }
/** * ************************************************************************************************************************************************************************************************* * Checks if key is pressed or mouse is moved etc. * ************************************************************************************************************************************************************************************************ */ private void checkInput() { if (Keyboard.next() && Keyboard.getEventKeyState()) { if (Keyboard.getEventKey() == Keyboard.KEY_ESCAPE) closeRequested = true; } if (Display.isCloseRequested()) { closeRequested = true; } }
private void frameFunction() { if (Keyboard.isKeyDown(Keyboard.KEY_F)) { try { physEngine.update(16); } catch (Exception e) { physEngine.stepBack(); } } else if (Keyboard.isKeyDown(Keyboard.KEY_R)) { physEngine.stepBack(); } }
public static void loop() { while (CSGame.state == States.ThreeDeeTest) { // Clear the screen of its filthy contents glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Push the screen inwards at the amount of speed glTranslatef(0, 0, speed); // Begin drawing points glBegin(GL_POINTS); // Iterate of every point for (Point p : points) { // Draw the point at its coordinates glColor3f(0.0f, 1f, 0f); glVertex3f(p.x, p.y, p.z); } // Stop drawing points glEnd(); // If we're pressing the "up" key increase our speed if (Keyboard.isKeyDown(Keyboard.KEY_UP)) { speed += 0.01f; } // If we're pressing the "down" key decrease our speed if (Keyboard.isKeyDown(Keyboard.KEY_DOWN)) { speed -= 0.01f; } // Iterate over keyboard input events while (Keyboard.next()) { // If we're pressing the "space-bar" key reset our speed to zero if (Keyboard.isKeyDown(Keyboard.KEY_SPACE)) { speed = 0f; } // If we're pressing the "c" key reset our speed to zero and reset our position if (Keyboard.isKeyDown(Keyboard.KEY_C)) { speed = 0; glLoadIdentity(); } } if (Display.isCloseRequested()) { CSGame.state = States.Closing; break; } Debug.debugLoop(); // Update the display Display.update(); // Wait until the frame-rate is 60fps Display.sync(60); } }
@Override public void addInformation( ItemStack essentiaCell, EntityPlayer player, List displayList, boolean advancedItemTooltips) { // TODO: Save provider?? // Get the contents of the cell IMEInventoryHandler<IAEFluidStack> handler = AEApi.instance() .registries() .cell() .getCellInventory(essentiaCell, null, StorageChannel.FLUIDS); // Ensure we have a cell inventory handler if (!(handler instanceof HandlerItemEssentiaCell)) { return; } // Cast to cell inventory handler HandlerItemEssentiaCell cellHandler = (HandlerItemEssentiaCell) handler; // Create the bytes tooltip String bytesTip = String.format( StatCollector.translateToLocal( ThaumicEnergistics.MOD_ID + ".tooltip.essentia.cell.bytes"), new Object[] { cellHandler.usedBytes() / ItemEssentiaCell.CONVERSION_SIZE, cellHandler.totalBytes() / ItemEssentiaCell.CONVERSION_SIZE }); // Create the types tooltip String typesTip = String.format( StatCollector.translateToLocal( ThaumicEnergistics.MOD_ID + ".tooltip.essentia.cell.types"), new Object[] {cellHandler.usedTypes(), cellHandler.totalTypes()}); // Add the tooltips displayList.add(bytesTip); displayList.add(typesTip); // Is the cell pre-formated? if (cellHandler.isPreformatted()) { displayList.add( StatCollector.translateToLocal("Appeng.GuiITooltip.Partitioned") + " - " + StatCollector.translateToLocal("Appeng.GuiITooltip.Precise")); } // Is shift being held? if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || (Keyboard.isKeyDown(Keyboard.KEY_RSHIFT))) { // Add information about the essentia types in the cell this.addContentsToCellDescription(cellHandler, displayList, player); } }
@Override public void handleKeyboardInput() { ControlsBasicItem item = model.getEditingItem(); if (item != null) { this.keyTyped( org.lwjgl.input.Keyboard.getEventCharacter(), org.lwjgl.input.Keyboard.getEventKey(), org.lwjgl.input.Keyboard.getEventKeyState()); } else { super.handleKeyboardInput(); } }
public void getInput() { if (Keyboard.isKeyDown(Keyboard.KEY_Z)) { if (!pressed) { robot.path(); pressed = true; } } if (Keyboard.isKeyDown(Keyboard.KEY_P)) { pressed = false; } player.getInput(); }
@Override @SideOnly(Side.CLIENT) public void addInformation( ItemStack itemStack, EntityPlayer player, List list, boolean whatIsThis) { super.addInformation(itemStack, player, list, whatIsThis); if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) { list.add("This machine smelts resonating ore and produces liquid"); list.add("crystal in a tank placed on top of this."); list.add("Below the smelter place a tank about half-filled with lava"); } else { list.add(EnumChatFormatting.WHITE + ClientHandler.getShiftMessage()); } }
/* */ protected synchronized boolean getNextDeviceEvent(Event event) throws IOException { /* 86 */ if (!org.lwjgl.input.Keyboard.isCreated()) /* 87 */ return false; /* 88 */ if (!org.lwjgl.input.Keyboard.next()) /* 89 */ return false; /* 90 */ int lwjgl_key = org.lwjgl.input.Keyboard.getEventKey(); /* 91 */ if (lwjgl_key == 0) /* 92 */ return false; /* 93 */ Component.Identifier.Key key_id = KeyMap.map(lwjgl_key); /* 94 */ if (key_id == null) /* 95 */ return false; /* 96 */ Component key = getComponent(key_id); /* 97 */ if (key == null) /* 98 */ return false; /* 99 */ float value = org.lwjgl.input.Keyboard.getEventKeyState() ? 1.0F : 0.0F; /* 100 */ event.set(key, value, org.lwjgl.input.Keyboard.getEventNanoseconds()); /* 101 */ return true; /* */ }
public void pollKeyboard() { while (Keyboard.next()) { if (Keyboard.getEventKeyState()) { switch (Keyboard.getEventKey()) { // Quit the game case Keyboard.KEY_ESCAPE: System.exit(0); break; } } } }