Interface to the input facilities. This allows polling the state of the keyboard, the touch screen and the accelerometer. On some backends (desktop, gwt, etc) the touch screen is replaced by mouse input. The accelerometer is of course not available on all backends.
Instead of polling for events, one can process all input events with an InputProcessor. You can set the InputProcessor
via the setInputProcessor(InputProcessor) method. It will be called before the ApplicationListener#render()
method in each frame.
Keyboard keys are translated to the constants in Keys transparently on all systems. Do not use system specific key
constants.
The class also offers methods to use (and test for the presence of) other input systems like vibration, compass, on-screen keyboards, and cursor capture. Support for simple input dialogs is also provided.
| Modifier and Type | Class and Description |
|---|---|
| public static class | Input.
Mouse buttons. |
| public static interface | |
| public static interface | |
| public static class | Input.
Keys. |
| public static enum | |
| public static enum | |
| public static enum | Input.
Enumeration of potentially available peripherals. |
| public static interface | Input.
Callback interface for |
| public static enum |
| Modifier and Type | Method and Description |
|---|---|
| public default void | closeTextInputField(boolean
Whether the closing can be considered confirmative. Will be passed to the
isConfirmative)NativeInputCloseCallbackCloses the native input field and applies the result to the input wrapper. |
| public default void | closeTextInputField(boolean
Whether the closing can be considered confirmative. Will be passed to the
isConfirmative, NativeInputConfiguration.NativeInputCloseCallbackAn optional callback to also run, when the close was processed. Will be called on the main thread. Will be
called after callbackNativeInputCloseCallbackCloses the native input field and applies the result to the input wrapper. |
| public float | getAccelerometerX()
Returns: The acceleration force in m/s^2 applied to the device in the X axis, including the force of gravity |
| public float | getAccelerometerY()
Returns: The acceleration force in m/s^2 applied to the device in the Y axis, including the force of gravity |
| public float | getAccelerometerZ()
Returns: The acceleration force in m/s^2 applied to the device in the Z axis, including the force of gravity |
| public float | Returns: the azimuth in degreesThe azimuth is the angle of the device's orientation around the z-axis. |
| public long | |
| public int | getDeltaX()
Returns: the different between the current pointer location and the last pointer location on the x-axis. |
| public int | getDeltaX(int pointer)
Returns: the different between the current pointer location and the last pointer location on the x-axis. |
| public int | getDeltaY()
Returns: the different between the current pointer location and the last pointer location on the y-axis. |
| public int | getDeltaY(int pointer)
Returns: the different between the current pointer location and the last pointer location on the y-axis. |
| public float | |
| public float | |
| public float | |
| public InputProcessor | |
| public int | |
| public Input. | |
| public float | Returns: the pitch in degreesThe pitch is the angle of the device's orientation around the x-axis. |
| public float | |
| public float | Returns: the pressurethe pointer id. pointer)Returns the pressure of the given pointer, where 0 is untouched. |
| public float | Returns: the roll in degreesThe roll is the angle of the device's orientation around the y-axis. |
| public int | |
| public void | getRotationMatrix(float[] matrix)
Returns the rotation matrix describing the devices rotation as per SensorManager#getRotationMatrix(float[], float[], float[], float[]). |
| public void | getTextInput(Input.
The TextInputListener. listener,The title of the text input dialog. title, String The message presented to the user. text, String hint)System dependent method to input a string of text. |
| public void | getTextInput(Input.
The TextInputListener. listener,The title of the text input dialog. title, String The message presented to the user. text, String hint, Input.which type of keyboard we wish to display typeSystem dependent method to input a string of text. |
| public int | getX()
Returns: The x coordinate of the last touch on touch screen devices and the current mouse position on desktop for the first pointer in screen coordinates. |
| public int | Returns: the x coordinatethe pointer id. pointer)Returns the x coordinate in screen coordinates of the given pointer. |
| public int | getY()
Returns: The y coordinate of the last touch on touch screen devices and the current mouse position on desktop for the first pointer in screen coordinates. |
| public int | Returns: the y coordinatethe pointer id. pointer)Returns the y coordinate in screen coordinates of the given pointer. |
| public boolean | Returns: true or false.the button to check. button)Returns whether a given button has just been pressed. |
| public boolean | Returns: whether the button is down or not.the button to check. button)Whether a given button is pressed or not. |
| public boolean | isCatchKey(int
keycode to check if caught keycode)Returns: true if the given keycode is configured to be caught |
| public boolean | |
| public boolean | Returns: true or false.The key code as found in key)Input..Returns whether the key has just been pressed. |
| public boolean | Returns: true or false.The key code as found in key)Input..Returns whether the key is pressed. |
| public boolean | Returns: whether the peripheral is available or not.the peripheralPeripheralQueries whether a |
| public default boolean | |
| public boolean | |
| public boolean | Returns: whether the screen is touched by the pointerthe pointer pointer)Whether the screen is currently touched by the pointer with the given index. |
| public boolean | |
| public void | openTextInputField(NativeInputConfiguration
The configuration for the native input field configuration)Sets the on-screen keyboard visible if available. |
| public void | setCatchKey(int
keycode to catch keycode, boolean whether to catch the given keycode catchKey)Sets whether the given key on Android or GWT should be caught. |
| public void | setCursorCatched(boolean
whether to catch or not to catch the mouse cursor catched)Only viable on the desktop. |
| public void | |
| public void | setInputProcessor(InputProcessor
the InputProcessor processor)Sets the |
| public void | setKeyboardHeightObserver(Input.
This will set a keyboard height callback. |
| public void | setOnscreenKeyboardVisible(boolean
visible or not visible)Sets the on-screen keyboard visible if available. |
| public void | setOnscreenKeyboardVisible(boolean
visible or not visible, Input.which type of keyboard we wish to display. Can be null when hiding typeSets the on-screen keyboard visible if available. |
| public void | vibrate(int
the number of milliseconds to vibrate. milliseconds)Generates a simple haptic effect of a given duration or a vibration effect on devices without haptic capabilities. |
| public void | vibrate(int
the duration of the haptics effect milliseconds, boolean whether to use non-haptic vibrator on devices without haptics capabilities (or haptics disabled). Fallback
non-haptic vibrations may ignore length parameter in some backends. fallback)Generates a simple haptic effect of a given duration and default amplitude. |
| public void | vibrate(int
the duration of the haptics effect milliseconds, int the amplitude/strength of the haptics effect. Valid values in the range [0, 255]. amplitude, boolean whether to use non-haptic vibrator on devices without haptics capabilities (or haptics disabled). Fallback
non-haptic vibrations may ignore length and/or amplitude parameters in some backends. fallback)Generates a simple haptic effect of a given duration and amplitude. |
| public void | vibrate(Input.
the type of vibration vibrationTypeGenerates a simple haptic effect of a type. |