Package com.csse3200.game.input
Class InputService
java.lang.Object
com.csse3200.game.input.InputService
- All Implemented Interfaces:
com.badlogic.gdx.input.GestureDetector.GestureListener,com.badlogic.gdx.InputProcessor
public class InputService
extends Object
implements com.badlogic.gdx.InputProcessor, com.badlogic.gdx.input.GestureDetector.GestureListener
Provides a global access point for handling user input and creating input handlers. All active
input handlers should be registered here.
When an input is received, it is passed to registered input handlers in descending priority order and stops as soon as the input is handled.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanfling(float velocityX, float velocityY, int button) Iterates over registered input handlers in descending priority and stops as soon as the input is processedGet the input factory to create input handlersbooleankeyDown(int keycode) Iterates over registered input handlers in descending priority and stops as soon as the input is processed.booleankeyTyped(char character) Iterates over registered input handlers in descending priority and stops as soon as the input is processedbooleankeyUp(int keycode) Iterates over registered input handlers in descending priority and stops as soon as the input is processedbooleanlongPress(float x, float y) Iterates over registered input handlers in descending priority and stops as soon as the input is processedbooleanmouseMoved(int screenX, int screenY) Iterates over registered input handlers in descending priority and stops as soon as the input is processedbooleanpan(float x, float y, float deltaX, float deltaY) Iterates over registered input handlers in descending priority and stops as soon as the input is processedbooleanpanStop(float x, float y, int pointer, int button) Iterates over registered input handlers in descending priority and stops as soon as the input is processedbooleanpinch(com.badlogic.gdx.math.Vector2 initialPointer1, com.badlogic.gdx.math.Vector2 initialPointer2, com.badlogic.gdx.math.Vector2 pointer1, com.badlogic.gdx.math.Vector2 pointer2) Iterates over registered input handlers in descending priority and stops as soon as the input is processedvoidIterates over registered input handlers in descending priority and stops as soon as the input is processedvoidregister(InputComponent inputHandler) Register an input handler based on its priority and reorder inputHandlers.booleanscrolled(float amountX, float amountY) Iterates over registered input handlers in descending priority and stops as soon as the input is processedbooleantap(float x, float y, int count, int button) Iterates over registered input handlers in descending priority and stops as soon as the input is processedbooleantouchDown(float x, float y, int pointer, int button) Iterates over registered input handlers in descending priority and stops as soon as the input is processedbooleantouchDown(int screenX, int screenY, int pointer, int button) Iterates over registered input handlers in descending priority and stops as soon as the input is processedbooleantouchDragged(int screenX, int screenY, int pointer) Iterates over registered input handlers in descending priority and stops as soon as the input is processedbooleantouchUp(int screenX, int screenY, int pointer, int button) Iterates over registered input handlers in descending priority and stops as soon as the input is processedvoidunregister(InputComponent inputHandler) Unregister an input handlerbooleanzoom(float initialDistance, float distance) Iterates over registered input handlers in descending priority and stops as soon as the input is processed
-
Constructor Details
-
InputService
public InputService() -
InputService
-
-
Method Details
-
getInputFactory
Get the input factory to create input handlers- Returns:
- input factory
-
register
Register an input handler based on its priority and reorder inputHandlers.- Parameters:
inputHandler- input handler
-
unregister
Unregister an input handler- Parameters:
inputHandler- input handler
-
keyDown
public boolean keyDown(int keycode) Iterates over registered input handlers in descending priority and stops as soon as the input is processed.- Specified by:
keyDownin interfacecom.badlogic.gdx.InputProcessor- Returns:
- whether the input was processed
- See Also:
-
InputProcessor.keyDown(int)
-
keyTyped
public boolean keyTyped(char character) Iterates over registered input handlers in descending priority and stops as soon as the input is processed- Specified by:
keyTypedin interfacecom.badlogic.gdx.InputProcessor- Returns:
- whether the input was processed
- See Also:
-
InputProcessor.keyTyped(char)
-
keyUp
public boolean keyUp(int keycode) Iterates over registered input handlers in descending priority and stops as soon as the input is processed- Specified by:
keyUpin interfacecom.badlogic.gdx.InputProcessor- Returns:
- whether the input was processed
- See Also:
-
InputProcessor.keyUp(int)
-
mouseMoved
public boolean mouseMoved(int screenX, int screenY) Iterates over registered input handlers in descending priority and stops as soon as the input is processed- Specified by:
mouseMovedin interfacecom.badlogic.gdx.InputProcessor- Returns:
- whether the input was processed
- See Also:
-
InputProcessor.mouseMoved(int, int)
-
scrolled
public boolean scrolled(float amountX, float amountY) Iterates over registered input handlers in descending priority and stops as soon as the input is processed- Specified by:
scrolledin interfacecom.badlogic.gdx.InputProcessor- Returns:
- whether the input was processed
- See Also:
-
InputProcessor.scrolled(float, float)
-
touchDown
public boolean touchDown(int screenX, int screenY, int pointer, int button) Iterates over registered input handlers in descending priority and stops as soon as the input is processed- Specified by:
touchDownin interfacecom.badlogic.gdx.InputProcessor- Returns:
- whether the input was processed
- See Also:
-
InputProcessor.touchDown(int, int, int, int)
-
touchDragged
public boolean touchDragged(int screenX, int screenY, int pointer) Iterates over registered input handlers in descending priority and stops as soon as the input is processed- Specified by:
touchDraggedin interfacecom.badlogic.gdx.InputProcessor- Returns:
- whether the input was processed
- See Also:
-
InputProcessor.touchDragged(int, int, int)
-
touchUp
public boolean touchUp(int screenX, int screenY, int pointer, int button) Iterates over registered input handlers in descending priority and stops as soon as the input is processed- Specified by:
touchUpin interfacecom.badlogic.gdx.InputProcessor- Returns:
- whether the input was processed
- See Also:
-
InputProcessor.touchUp(int, int, int, int)
-
fling
public boolean fling(float velocityX, float velocityY, int button) Iterates over registered input handlers in descending priority and stops as soon as the input is processed- Specified by:
flingin interfacecom.badlogic.gdx.input.GestureDetector.GestureListener- Returns:
- whether the input was processed
- See Also:
-
GestureDetector.GestureListener.fling(float, float, int)
-
longPress
public boolean longPress(float x, float y) Iterates over registered input handlers in descending priority and stops as soon as the input is processed- Specified by:
longPressin interfacecom.badlogic.gdx.input.GestureDetector.GestureListener- Returns:
- whether the input was processed
- See Also:
-
GestureDetector.GestureListener.longPress(float, float)
-
pan
public boolean pan(float x, float y, float deltaX, float deltaY) Iterates over registered input handlers in descending priority and stops as soon as the input is processed- Specified by:
panin interfacecom.badlogic.gdx.input.GestureDetector.GestureListener- Returns:
- whether the input was processed
- See Also:
-
GestureDetector.GestureListener.pan(float, float, float, float)
-
panStop
public boolean panStop(float x, float y, int pointer, int button) Iterates over registered input handlers in descending priority and stops as soon as the input is processed- Specified by:
panStopin interfacecom.badlogic.gdx.input.GestureDetector.GestureListener- Returns:
- whether the input was processed
- See Also:
-
GestureDetector.GestureListener.panStop(float, float, int, int)
-
pinch
public boolean pinch(com.badlogic.gdx.math.Vector2 initialPointer1, com.badlogic.gdx.math.Vector2 initialPointer2, com.badlogic.gdx.math.Vector2 pointer1, com.badlogic.gdx.math.Vector2 pointer2) Iterates over registered input handlers in descending priority and stops as soon as the input is processed- Specified by:
pinchin interfacecom.badlogic.gdx.input.GestureDetector.GestureListener- Returns:
- whether the input was processed
- See Also:
-
GestureDetector.GestureListener.pinch(Vector2, Vector2, Vector2, Vector2)
-
pinchStop
public void pinchStop()Iterates over registered input handlers in descending priority and stops as soon as the input is processed- Specified by:
pinchStopin interfacecom.badlogic.gdx.input.GestureDetector.GestureListener- See Also:
-
GestureDetector.GestureListener.pinchStop()
-
tap
public boolean tap(float x, float y, int count, int button) Iterates over registered input handlers in descending priority and stops as soon as the input is processed- Specified by:
tapin interfacecom.badlogic.gdx.input.GestureDetector.GestureListener- Returns:
- whether the input was processed
- See Also:
-
GestureDetector.GestureListener.tap(float, float, int, int)
-
touchDown
public boolean touchDown(float x, float y, int pointer, int button) Iterates over registered input handlers in descending priority and stops as soon as the input is processed- Specified by:
touchDownin interfacecom.badlogic.gdx.input.GestureDetector.GestureListener- Returns:
- whether the input was processed
- See Also:
-
GestureDetector.GestureListener.touchDown(float, float, int, int)
-
zoom
public boolean zoom(float initialDistance, float distance) Iterates over registered input handlers in descending priority and stops as soon as the input is processed- Specified by:
zoomin interfacecom.badlogic.gdx.input.GestureDetector.GestureListener- Returns:
- whether the input was processed
- See Also:
-
GestureDetector.GestureListener.zoom(float, float)
-