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
-
Method Summary
Modifier and TypeMethodDescriptionboolean
fling
(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 handlersboolean
keyDown
(int keycode) Iterates over registered input handlers in descending priority and stops as soon as the input is processed.boolean
keyTyped
(char character) Iterates over registered input handlers in descending priority and stops as soon as the input is processedboolean
keyUp
(int keycode) Iterates over registered input handlers in descending priority and stops as soon as the input is processedboolean
longPress
(float x, float y) Iterates over registered input handlers in descending priority and stops as soon as the input is processedboolean
mouseMoved
(int screenX, int screenY) Iterates over registered input handlers in descending priority and stops as soon as the input is processedboolean
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 processedboolean
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 processedboolean
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 processedvoid
Iterates over registered input handlers in descending priority and stops as soon as the input is processedvoid
register
(InputComponent inputHandler) Register an input handler based on its priority and reorder inputHandlers.boolean
scrolled
(float amountX, float amountY) Iterates over registered input handlers in descending priority and stops as soon as the input is processedboolean
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 processedboolean
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 processedboolean
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 processedboolean
touchDragged
(int screenX, int screenY, int pointer) Iterates over registered input handlers in descending priority and stops as soon as the input is processedboolean
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 processedvoid
unregister
(InputComponent inputHandler) Unregister an input handlerboolean
zoom
(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
-
getEngineerInput
-
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:
keyDown
in 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:
keyTyped
in 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:
keyUp
in 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:
mouseMoved
in 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:
scrolled
in 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:
touchDown
in 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:
touchDragged
in 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:
touchUp
in 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:
fling
in 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:
longPress
in 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:
pan
in 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:
panStop
in 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:
pinch
in 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:
pinchStop
in 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:
tap
in 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:
touchDown
in 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:
zoom
in interfacecom.badlogic.gdx.input.GestureDetector.GestureListener
- Returns:
- whether the input was processed
- See Also:
-
GestureDetector.GestureListener.zoom(float, float)
-