public WindowInputHandler setWindow(Window window) {
   if (this.window != null) {
     this.window.setKeyCallback(null);
   }
   this.window = window;
   if (window != null) {
     ByteBuffer buf = BufferUtils.createByteBuffer(16);
     buf.limit(8);
     ByteBuffer bufX = buf.slice();
     buf.limit(16);
     buf.position(8);
     ByteBuffer bufY = buf.slice();
     window.getCursorPos(bufX.asDoubleBuffer(), bufY.asDoubleBuffer());
     mouseX = bufX.getDouble();
     mouseY = window.getViewport().getHeight() - bufY.getDouble();
     setImmediateMode(immediateMode);
   }
   return this;
 }
 public WindowInputHandler setImmediateMode(boolean immediateMode) {
   this.immediateMode = immediateMode;
   if (immediateMode) {
     keyControlSet.clear();
     mouseControlSet.clear();
     if (window != null) {
       window.setKeyCallback(new ImmediateKeyCallback());
       window.setMouseButtonCallback(new ImmediateMouseCallback());
       window.setCursorPosCallback(new ImmediateCursorPosCallback());
     }
   } else {
     mouseDX = 0;
     mouseDY = 0;
     if (window != null) {
       window.setKeyCallback(new BufferedKeyCallback());
       window.setMouseButtonCallback(new BufferedMouseCallback());
       window.setCursorPosCallback(new BufferedCursorPosCallback());
     }
   }
   return this;
 }
 public int getMouseButton(int button) {
   return window.getMouseButton(button);
 }
 public int getKey(int key) {
   return window.getKey(key);
 }
 public boolean isMouseGrabbed() {
   return window.isMouseGrabbed();
 }
 public void setMouseGrabbed(boolean grabbed) {
   window.setMouseGrabbed(grabbed);
 }
 public void setDefaultCursor() {
   window.setDefaultCursor();
 }
 public void setStandardCursor(int shape) {
   window.setStandardCursor(shape);
 }
 public boolean isDefaultCursor() {
   return window.isDefaultCursor();
 }