001 package net.minecraft.src; 002 003 import cpw.mods.fml.common.Side; 004 import cpw.mods.fml.common.asm.SideOnly; 005 import java.awt.Component; 006 import org.lwjgl.input.Mouse; 007 008 @SideOnly(Side.CLIENT) 009 public class MouseHelper 010 { 011 private final Component windowComponent; 012 private final GameSettings field_85184_d; 013 014 /** Mouse delta X this frame */ 015 public int deltaX; 016 017 /** Mouse delta Y this frame */ 018 public int deltaY; 019 020 public MouseHelper(Component par1Component, GameSettings par2GameSettings) 021 { 022 this.windowComponent = par1Component; 023 this.field_85184_d = par2GameSettings; 024 } 025 026 /** 027 * Grabs the mouse cursor it doesn't move and isn't seen. 028 */ 029 public void grabMouseCursor() 030 { 031 if (!this.field_85184_d.field_85185_A) 032 { 033 Mouse.setGrabbed(true); 034 } 035 036 this.deltaX = 0; 037 this.deltaY = 0; 038 } 039 040 /** 041 * Ungrabs the mouse cursor so it can be moved and set it to the center of the screen 042 */ 043 public void ungrabMouseCursor() 044 { 045 Mouse.setCursorPosition(this.windowComponent.getWidth() / 2, this.windowComponent.getHeight() / 2); 046 Mouse.setGrabbed(false); 047 } 048 049 public void mouseXYChange() 050 { 051 this.deltaX = Mouse.getDX(); 052 this.deltaY = Mouse.getDY(); 053 } 054 }