Java Code Examples for org.lwjgl.input.Mouse#getEventX()
The following examples show how to use
org.lwjgl.input.Mouse#getEventX() .
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: Game.java From FEMultiPlayer-V2 with GNU General Public License v3.0 | 6 votes |
/** * 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 2
Source File: GuiEnderUtilities.java From enderutilities with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void handleMouseInput() throws IOException { int dWheel = Mouse.getEventDWheel(); if (dWheel != 0) { int mouseX = Mouse.getEventX() * this.width / this.mc.displayWidth; int mouseY = this.height - Mouse.getEventY() * this.height / this.mc.displayHeight - 1; for (int i = 0; i < this.buttonList.size(); i++) { GuiButton button = this.buttonList.get(i); if (button.mousePressed(this.mc, mouseX, mouseY)) { this.actionPerformedWithButton(button, 10 + dWheel / 120); break; } } } else { super.handleMouseInput(); } }
Example 3
Source File: GuiJSU.java From enderutilities with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void handleMouseInput() throws IOException { int mouseX = Mouse.getEventX() * this.width / this.mc.displayWidth - this.guiLeft; int mouseY = this.height - Mouse.getEventY() * this.height / this.mc.displayHeight - 1 - this.guiTop; if (Mouse.getEventDWheel() != 0 && this.areaInventory.isMouseOver(mouseX, mouseY)) { this.scrollBar.handleMouseInput(mouseX, mouseY); } else if ((Mouse.getEventButton() != 0 && Mouse.isButtonDown(0) == false) || this.scrollBar.handleMouseInput(mouseX, mouseY) == false) { super.handleMouseInput(); } }
Example 4
Source File: GuiSoundBlock.java From enderutilities with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void handleMouseInput() throws IOException { int mouseX = Mouse.getEventX() * this.width / this.mc.displayWidth - this.guiLeft; int mouseY = this.height - Mouse.getEventY() * this.height / this.mc.displayHeight - 1 - this.guiTop; if (Mouse.getEventDWheel() != 0 && (this.areaSoundList.isMouseOver(mouseX, mouseY) || this.scrollBar.isMouseOver(mouseX, mouseY))) { this.scrollBar.handleMouseInput(mouseX, mouseY); } else if ((Mouse.getEventButton() != 0 && Mouse.isButtonDown(0) == false) || this.scrollBar.handleMouseInput(mouseX, mouseY) == false) { super.handleMouseInput(); } }
Example 5
Source File: Game.java From FEMultiplayer with GNU General Public License v3.0 | 6 votes |
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 6
Source File: ModularUIGui.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void handleMouseInput() throws IOException { super.handleMouseInput(); int wheelMovement = Mouse.getEventDWheel(); if (wheelMovement != 0) { int mouseX = Mouse.getEventX() * this.width / this.mc.displayWidth; int mouseY = this.height - Mouse.getEventY() * this.height / this.mc.displayHeight - 1; mouseWheelMove(mouseX - guiLeft, mouseY, wheelMovement); } }
Example 7
Source File: EditBlockListScreen.java From ForgeWurst with GNU General Public License v3.0 | 5 votes |
@Override public void handleMouseInput() throws IOException { super.handleMouseInput(); int mouseX = Mouse.getEventX() * width / mc.displayWidth; int mouseY = height - Mouse.getEventY() * height / mc.displayHeight - 1; listGui.handleMouseInput(mouseX, mouseY); }
Example 8
Source File: GuiSoundBlock.java From enderutilities with GNU Lesser General Public License v3.0 | 5 votes |
@Override protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException { // Clear the field on right click if (mouseButton == 1 && mouseX >= this.guiLeft + this.searchField.x && mouseX < this.guiLeft + this.searchField.x + this.searchField.width && mouseY >= this.guiTop + this.searchField.y && mouseY < this.guiTop + this.searchField.y + this.searchField.height) { this.searchField.setText(""); this.searchField.mouseClicked(mouseX - this.guiLeft, mouseY - this.guiTop, mouseButton); this.applyFilterString(); } else { int mouseXA = Mouse.getEventX() * this.width / this.mc.displayWidth - this.guiLeft; int mouseYA = this.height - Mouse.getEventY() * this.height / this.mc.displayHeight - 1 - this.guiTop; if (this.areaSoundList.isMouseOver(mouseXA, mouseYA)) { this.handleClickOnListEntry(mouseXA, mouseYA); } else { super.mouseClicked(mouseX, mouseY, mouseButton); this.searchField.mouseClicked(mouseX - this.guiLeft, mouseY - this.guiTop, mouseButton); } } }
Example 9
Source File: GuiCustomizeWorld.java From YUNoMakeGoodMap with Apache License 2.0 | 5 votes |
@Override public void handleMouseInput() throws IOException { int mouseX = Mouse.getEventX() * this.width / this.mc.displayWidth; int mouseY = this.height - Mouse.getEventY() * this.height / this.mc.displayHeight - 1; super.handleMouseInput(); this.list.handleMouseInput(mouseX, mouseY); if (this.info != null) this.info.handleMouseInput(mouseX, mouseY); }
Example 10
Source File: GuiContainerScreen.java From WearableBackpacks with MIT License | 5 votes |
@Override public void handleMouseInput() throws IOException { super.handleMouseInput(); int mouseX = Mouse.getEventX() * width / mc.displayWidth; int mouseY = height - Mouse.getEventY() * height / mc.displayHeight - 1; int scroll = Integer.signum(Mouse.getEventDWheel()); if (scroll != 0) container.onMouseScroll(scroll, mouseX, mouseY); }
Example 11
Source File: GuiCapture.java From OpenPeripheral-Addons with MIT License | 5 votes |
@Override public void handleMouseInput() { super.handleMouseInput(); final int button = Mouse.getEventButton(); final int wheel = Mouse.getEventDWheel(); final int mx = Mouse.getEventX(); final int my = Mouse.getEventY(); final float scaleX = (float)this.width / this.mc.displayWidth; final float scaleY = (float)this.height / this.mc.displayHeight; final float x = mx * scaleX; final float y = this.height - my * scaleY; if (button != -1 || wheel != 0) { final ScaledResolution resolution = new ScaledResolution(this.mc, this.mc.displayWidth, this.mc.displayHeight); final DrawableHitInfo hit = TerminalManagerClient.instance.findDrawableHit(guid, resolution, x, y); if (button != -1) { final boolean state = Mouse.getEventButtonState(); createMouseButtonEvent(button, state, hit).sendToServer(); final boolean draggingStarted = updateButtonCounter(state); if (draggingStarted) resetDraggingLimiter(x, y); } if (wheel != 0) createMouseWheelEvent(wheel, hit).sendToServer(); } { final float dx = (x - lastDragX); final float dy = (y - lastDragY); if (canSendDragEvent(dx, dy)) { createDragEvent(dx, dy).sendToServer(); resetDraggingLimiter(x, y); } } }
Example 12
Source File: MwGui.java From mapwriter with MIT License | 5 votes |
@Override public void handleMouseInput() { if (MwAPI.getCurrentDataProvider() != null && MwAPI.getCurrentDataProvider().onMouseInput(this.mapView, this.mapMode)) return; int x = Mouse.getEventX() * this.width / this.mc.displayWidth; int y = this.height - Mouse.getEventY() * this.height / this.mc.displayHeight - 1; int direction = Mouse.getEventDWheel(); if (direction != 0) { this.mouseDWheelScrolled(x, y, direction); } super.handleMouseInput(); }
Example 13
Source File: GuiPearlSwap.java From Wizardry with GNU Lesser General Public License v3.0 | 4 votes |
@Override protected void mouseClicked(int x, int y, int mouseButton) throws IOException { super.mouseClicked(x, y, mouseButton); if (mouseButton != 0 || lock) return; EntityPlayer player = Minecraft.getMinecraft().player; ItemStack heldItem = player.getHeldItemMainhand(); ItemStack stack = getStorageHolderStack(); if (stack.isEmpty()) return; IPearlStorageHolder holder = (IPearlStorageHolder) stack.getItem(); IItemHandler handler = holder.getPearls(stack); if (handler == null) return; double mouseX = Mouse.getEventX() - mc.displayWidth / 2.0; double mouseY = (Mouse.getEventY() - mc.displayHeight / 2.0) * -1; Vec2d vec = new Vec2d(mouseX, mouseY); if (vec.length() <= componentCentralCircle.getSize().getX() * new ScaledResolution(Minecraft.getMinecraft()).getScaleFactor()) { if (heldItem.getItem() instanceof IPearlStorageHolder) { succPearlsToBelt(); } return; } double relativeMX = (Mouse.getEventX() / (double) this.mc.displayWidth) / 0.5 - 1; double relativeMY = ((Mouse.getEventY() / (double) this.mc.displayHeight) / 0.5 - 1) * -1; if (mc.displayWidth > mc.displayHeight) { relativeMY *= this.mc.displayHeight / (double) this.mc.displayWidth; } else if (mc.displayHeight > mc.displayWidth) { relativeMX *= mc.displayWidth / (double) mc.displayHeight; } double pointerAngle = (Math.atan2(relativeMY, relativeMX) + (PI * 2)) % (PI * 2.0); int pearlCount = Math.max(holder.getPearlCount(stack), 0); if (pearlCount != 0) { double anglePerColor = 2.0 * PI / (double) pearlCount; int pointerIndex = (int) (pointerAngle / anglePerColor); if (heldItem.getItem() instanceof IPearlStorageHolder) { popPearlFromBelt(pointerIndex); } else if (heldItem.getItem() instanceof IPearlSwappable) { swapPearl(pointerIndex); } } }
Example 14
Source File: GuiScreenPlus.java From Chisel with GNU General Public License v2.0 | 4 votes |
@Override public void handleMouseInput() { mouseEvent.handled = false; mouseEvent.x = Mouse.getEventX() * width / mc.displayWidth - this.screenX; mouseEvent.y = height - Mouse.getEventY() * height / mc.displayHeight - 1 - this.screenY; if(oldX == -1) { oldX = mouseEvent.x; oldY = mouseEvent.y; } mouseEvent.dx = mouseEvent.x - oldX; mouseEvent.dy = mouseEvent.y - oldY; oldX = mouseEvent.x; oldY = mouseEvent.y; mouseEvent.down = Mouse.getEventButtonState(); mouseEvent.button = Mouse.getEventButton(); mouseEvent.wheel = Mouse.getEventDWheel(); if(mouseEvent.wheel != 0) { if(mouseEvent.wheel < 0) { mouseEvent.wheel = -1; } else { mouseEvent.wheel = 1; } root.mouseWheel(mouseEvent); } else if(mouseEvent.button >= 0 && mouseEvent.button < downButtons.length) { if(downButtons[mouseEvent.button] != mouseEvent.down) { downButtons[mouseEvent.button] = mouseEvent.down; if(mouseEvent.down) { root.mouseDown(mouseEvent); } else { root.mouseUp(mouseEvent); } } else if(mouseEvent.dx != 0 || mouseEvent.dy != 0) { root.mouseMove(mouseEvent); } } else if(mouseEvent.dx != 0 || mouseEvent.dy != 0) { root.mouseMove(mouseEvent); } if(!mouseEvent.handled) { super.handleMouseInput(); } }
Example 15
Source File: InputUtil.java From CraftingKeys with MIT License | 2 votes |
/** * Returns a calculated Mouse Position for getSlotAtMousePosition(). * * @param guiContainer the GuiContainer to work with * @return The relative Mouse-Position */ private static int getMouseX(GuiContainer guiContainer) { return (Mouse.getEventX() * guiContainer.width) / Util.client.displayWidth; }