Class GLFWRenderModuleMouseInput
java.lang.Object
io.codetoil.curved_spacetime.render.glfw.GLFWRenderModuleMouseInput
- All Implemented Interfaces:
RenderModuleMouseInput
Mouse input backed by GLFW.
Position and button state arrive through GLFW callbacks; the deltas are computed in
poll() by differencing against the previous frame's position. Movement is only
accumulated while the cursor is inside the window, so re-entering does not produce a large
spurious delta from wherever the cursor left.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected floatThe cursor's current x position, or-1.0fbefore the first movement.protected floatThe cursor's current y position, or-1.0fbefore the first movement.protected floatHorizontal movement since the previouspoll().protected floatVertical movement since the previouspoll().protected booleanWhether the cursor is currently inside the window.protected booleanWhether the left button is held.protected booleanWhether the middle button is held.protected floatThe cursor's x position at the previouspoll().protected floatThe cursor's y position at the previouspoll().protected booleanWhether the right button is held.protected final GLFWRenderModuleWindowThe window this input reads from. -
Constructor Summary
ConstructorsConstructorDescriptionAttaches mouse handling to the given window. -
Method Summary
Modifier and TypeMethodDescriptionfloatReturns the cursor's horizontal position within the window.floatReturns the cursor's vertical position within the window.floatReturns how far the cursor moved horizontally since the previous sample.floatReturns how far the cursor moved vertically since the previous sample.booleanReturns whether the left button is held down.booleanReturns whether the middle button is held down.booleanReturns whether the right button is held down.voidpoll()Samples the mouse, refreshing position, deltas, and button state.window()Returns the window this input reads from.
-
Field Details
-
window
The window this input reads from. -
currentX
protected float currentXThe cursor's current x position, or-1.0fbefore the first movement. -
currentY
protected float currentYThe cursor's current y position, or-1.0fbefore the first movement. -
deltaX
protected float deltaXHorizontal movement since the previouspoll(). -
deltaY
protected float deltaYVertical movement since the previouspoll(). -
previousX
protected float previousXThe cursor's x position at the previouspoll(). -
previousY
protected float previousYThe cursor's y position at the previouspoll(). -
inWindow
protected boolean inWindowWhether the cursor is currently inside the window. -
leftButtonPressed
protected boolean leftButtonPressedWhether the left button is held. -
rightButtonPressed
protected boolean rightButtonPressedWhether the right button is held. -
middleButtonPressed
protected boolean middleButtonPressedWhether the middle button is held.
-
-
Constructor Details
-
GLFWRenderModuleMouseInput
Attaches mouse handling to the given window.Installs GLFW cursor position, cursor enter, and mouse button callbacks, replacing any previously set on that window.
- Parameters:
window- the window to read mouse input from
-
-
Method Details
-
window
Description copied from interface:RenderModuleMouseInputReturns the window this input reads from.- Specified by:
windowin interfaceRenderModuleMouseInput- Returns:
- the owning window
-
poll
public void poll()Description copied from interface:RenderModuleMouseInputSamples the mouse, refreshing position, deltas, and button state.Called once per frame by the owning window.
- Specified by:
pollin interfaceRenderModuleMouseInput
-
getCurrentX
public float getCurrentX()Description copied from interface:RenderModuleMouseInputReturns the cursor's horizontal position within the window.- Specified by:
getCurrentXin interfaceRenderModuleMouseInput- Returns:
- the current x coordinate in pixels from the left edge
-
getCurrentY
public float getCurrentY()Description copied from interface:RenderModuleMouseInputReturns the cursor's vertical position within the window.- Specified by:
getCurrentYin interfaceRenderModuleMouseInput- Returns:
- the current y coordinate in pixels from the top edge
-
getDeltaX
public float getDeltaX()Description copied from interface:RenderModuleMouseInputReturns how far the cursor moved horizontally since the previous sample.- Specified by:
getDeltaXin interfaceRenderModuleMouseInput- Returns:
- the change in x since the last
RenderModuleMouseInput.poll(), in pixels
-
getDeltaY
public float getDeltaY()Description copied from interface:RenderModuleMouseInputReturns how far the cursor moved vertically since the previous sample.- Specified by:
getDeltaYin interfaceRenderModuleMouseInput- Returns:
- the change in y since the last
RenderModuleMouseInput.poll(), in pixels
-
isLeftButtonPressed
public boolean isLeftButtonPressed()Description copied from interface:RenderModuleMouseInputReturns whether the left button is held down.- Specified by:
isLeftButtonPressedin interfaceRenderModuleMouseInput- Returns:
truewhile the left button is held
-
isRightButtonPressed
public boolean isRightButtonPressed()Description copied from interface:RenderModuleMouseInputReturns whether the right button is held down.- Specified by:
isRightButtonPressedin interfaceRenderModuleMouseInput- Returns:
truewhile the right button is held
-
isMiddleButtonPressed
public boolean isMiddleButtonPressed()Description copied from interface:RenderModuleMouseInputReturns whether the middle button is held down.- Specified by:
isMiddleButtonPressedin interfaceRenderModuleMouseInput- Returns:
truewhile the middle button is held
-