Java Code Examples for org.lwjgl.input.Keyboard#isCreated()
The following examples show how to use
org.lwjgl.input.Keyboard#isCreated() .
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: ItemFairyBell.java From Wizardry with GNU Lesser General Public License v3.0 | 6 votes |
@SubscribeEvent @SideOnly(Side.CLIENT) public static void onScroll(MouseEvent event) { EntityPlayer player = Minecraft.getMinecraft().player; if (player == null) return; if (Keyboard.isCreated() && event.getDwheel() != 0) { for (EnumHand hand : EnumHand.values()) { ItemStack stack = player.getHeldItem(hand); if (stack.getItem() != ModItems.FAIRY_BELL) continue; IMiscCapability cap = MiscCapabilityProvider.getCap(Minecraft.getMinecraft().player); if (cap == null) continue; cap.setSelectedFairy(null); PacketHandler.NETWORK.sendToServer(new PacketUpdateMiscCapToServer(cap.serializeNBT())); } } }
Example 2
Source File: LwjglCanvas.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
private void pauseCanvas(){ if (Mouse.isCreated()){ if (Mouse.isGrabbed()){ Mouse.setGrabbed(false); mouseWasGrabbed = true; } mouseWasCreated = true; Mouse.destroy(); } if (Keyboard.isCreated()){ keyboardWasCreated = true; Keyboard.destroy(); } renderable.set(false); destroyContext(); }
Example 3
Source File: LwjglCanvas.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 6 votes |
private void pauseCanvas(){ if (Mouse.isCreated()){ if (Mouse.isGrabbed()){ Mouse.setGrabbed(false); mouseWasGrabbed = true; } mouseWasCreated = true; Mouse.destroy(); } if (Keyboard.isCreated()){ keyboardWasCreated = true; Keyboard.destroy(); } renderable.set(false); destroyContext(); }
Example 4
Source File: ModKeybinds.java From Wizardry with GNU Lesser General Public License v3.0 | 5 votes |
@SideOnly(Side.CLIENT) @SubscribeEvent public static void onKey(InputEvent.KeyInputEvent event) { if (!Keyboard.isCreated()) return; EntityPlayer player = Minecraft.getMinecraft().player; if (player == null) return; if (pearlSwapping.isKeyDown() && player.getHeldItemMainhand().getItem() instanceof IPearlSwappable && !BaublesSupport.getItem(player, IPearlStorageHolder.class).isEmpty()) { player.openGui(Wizardry.instance, 1, player.world, (int) player.posX, (int) player.posY, (int) player.posZ); } }
Example 5
Source File: KeyboardInput.java From tribaltrouble with GNU General Public License v2.0 | 4 votes |
public final static void reset() { while (Keyboard.isCreated() && Keyboard.next()) ; }
Example 6
Source File: LwjglKeyInput.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public boolean isInitialized() { return Keyboard.isCreated(); }
Example 7
Source File: LwjglCanvas.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 4 votes |
/** * This is called: * 1) When the context thread ends * 2) Any time the canvas becomes non-displayable */ @Override protected void destroyContext(){ try { // invalidate the state so renderer can resume operation if (!USE_SHARED_CONTEXT){ renderer.cleanup(); } if (Display.isCreated()){ /* FIXES: * org.lwjgl.LWJGLException: X Error * BadWindow (invalid Window parameter) request_code: 2 minor_code: 0 * * Destroying keyboard early prevents the error above, triggered * by destroying keyboard in by Display.destroy() or Display.setParent(null). * Therefore Keyboard.destroy() should precede any of these calls. */ if (Keyboard.isCreated()){ // Should only happen if called in // LwjglAbstractDisplay.deinitInThread(). Keyboard.destroy(); } //try { // NOTE: On Windows XP, not calling setParent(null) // freezes the application. // On Mac it freezes the application. // On Linux it fixes a crash with X Window System. if (JmeSystem.getPlatform() == Platform.Windows32 || JmeSystem.getPlatform() == Platform.Windows64){ //Display.setParent(null); } //} catch (LWJGLException ex) { // logger.log(Level.SEVERE, "Encountered exception when setting parent to null", ex); //} Display.destroy(); } // The canvas is no longer visible, // but the context thread is still running. if (!needClose.get()){ // MUST make sure there's still a context current here .. // Display is dead, make pbuffer available to the system makePbufferAvailable(); renderer.invalidateState(); }else{ // The context thread is no longer running. // Destroy pbuffer. destroyPbuffer(); } } catch (LWJGLException ex) { listener.handleError("Failed make pbuffer available", ex); } }
Example 8
Source File: LwjglKeyInput.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 4 votes |
public boolean isInitialized() { return Keyboard.isCreated(); }
Example 9
Source File: LwjglCanvas.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 4 votes |
/** * This is called: * 1) When the context thread ends * 2) Any time the canvas becomes non-displayable */ protected void destroyContext(){ try { // invalidate the state so renderer can resume operation if (!USE_SHARED_CONTEXT){ renderer.cleanup(); } if (Display.isCreated()){ /* FIXES: * org.lwjgl.LWJGLException: X Error * BadWindow (invalid Window parameter) request_code: 2 minor_code: 0 * * Destroying keyboard early prevents the error above, triggered * by destroying keyboard in by Display.destroy() or Display.setParent(null). * Therefore Keyboard.destroy() should precede any of these calls. */ if (Keyboard.isCreated()){ // Should only happen if called in // LwjglAbstractDisplay.deinitInThread(). Keyboard.destroy(); } //try { // NOTE: On Windows XP, not calling setParent(null) // freezes the application. // On Mac it freezes the application. // On Linux it fixes a crash with X Window System. if (JmeSystem.getPlatform() == Platform.Windows32 || JmeSystem.getPlatform() == Platform.Windows64){ //Display.setParent(null); } //} catch (LWJGLException ex) { // logger.log(Level.SEVERE, "Encountered exception when setting parent to null", ex); //} Display.destroy(); } // The canvas is no longer visible, // but the context thread is still running. if (!needClose.get()){ // MUST make sure there's still a context current here .. // Display is dead, make pbuffer available to the system makePbufferAvailable(); renderer.invalidateState(); }else{ // The context thread is no longer running. // Destroy pbuffer. destroyPbuffer(); } } catch (LWJGLException ex) { listener.handleError("Failed make pbuffer available", ex); } }