InputMapController

An InputProcessor that handles Key, GameButton, and GameAxis inputs and converts them into a single input signal to be used similarly as Input except with a custom InputSignal type.

Bindings can be added to addBinding for multiple input sources. These bindings then can be added as an axis or a vector. The input signal can then be checked like Input normally would be using input methods this class provides. Additionally, the strength, distances, and angles of each input can be calculated.

Author

Colt Daily

See also

Parameters

input

the current input of the context

Constructors

Link copied to clipboard

Types

Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
fun addAxis(type: InputSignal, positive: InputSignal, negative: InputSignal)

Create an axis from two InputSignal bindings. In order to have a proper axis, the two signals must have been bound in addBinding. The axis is calculated as follows: positive - negative. Note: this will replace any existing axis if it exists.

Link copied to clipboard
fun addBinding(type: InputSignal, keys: List<Key> = emptyList(), keyModifiers: List<InputMapController.KeyModifier> = emptyList(), buttons: List<GameButton> = emptyList(), axes: List<GameAxis> = emptyList(), pointers: List<Pointer> = emptyList())

Create a binding of multiple keys and buttons into a single InputSignal.

Link copied to clipboard
Link copied to clipboard
fun addVector(type: InputSignal, positiveX: InputSignal, positiveY: InputSignal, negativeX: InputSignal, negativeY: InputSignal)

Create a vector from four InputSignal bindings. Think of it as two axes in as a single result. In order to have a proper vector, the four signals must have been bound in addBinding. The vector is calculated as follows: positiveX - negativeX and positiveY - negativeY. Note: this will replace any existing vector if it exists.

Link copied to clipboard
fun angle(vector: InputSignal, deadZone: Float = axisDeadZone): Float

Calculates the angle of a vector InputSignal. Requires a vector to have been added with the specified vector.

fun angle(xAxis: InputSignal, yAxis: InputSignal, deadZone: Float = axisDeadZone): Float

Calculates the angle between both InputSignal axes. Requires the axes to have been added with the specified axis and yAxis.

Link copied to clipboard
fun axis(type: InputSignal, deadZone: Float = axisDeadZone): Float

Returns the strength of this InputSignal as an axis. This will take the positive axis and subtract it by the negative axis. This is the same as doing strength(positive) - strength(negative). Requires an axis to have been added with the specified type.

Link copied to clipboard
open override fun charTyped(character: Char): Boolean

Invoked when a Key is pressed and a Char is associated with that key.

Link copied to clipboard
fun dist(type: InputSignal, deadZone: Float = axisDeadZone): Float

Takes the absolute value of the strength of this InputSignal

fun dist(xAxis: InputSignal, yAxis: InputSignal, deadZone: Float = axisDeadZone): Float

Calculates the distance between each axes InputSignal and returns the highest distance.

Link copied to clipboard
fun distV(vector: InputSignal, deadZone: Float = axisDeadZone): Float

Calculates the distance between each axes in this vector InputSignal and returns the highest distance.

Link copied to clipboard

Checks to see if the InputSignal is currently down for all inputs. This does not trigger for GameAxis.

Link copied to clipboard
open override fun gamepadButtonPressed(button: GameButton, pressure: Float, gamepad: Int): Boolean

Invoked when a GameButton is initially pressed on a GamepadInfo.

Link copied to clipboard
open override fun gamepadButtonReleased(button: GameButton, gamepad: Int): Boolean

Invoked when a GameButton is released on a GamepadInfo.

Link copied to clipboard
open fun gamepadJoystickMoved(stick: GameStick, xAxis: Float, yAxis: Float, gamepad: Int): Boolean

Invoked when a GameStick is moved on a GamepadInfo.

Link copied to clipboard
open override fun gamepadTriggerChanged(button: GameButton, pressure: Float, gamepad: Int): Boolean

Invoked when a GameButton that is considered a trigger is changed / moved.

Link copied to clipboard
open override fun keyDown(key: Key): Boolean

Invoked when a Key is initially pressed down.

Link copied to clipboard
open override fun keyRepeat(key: Key): Boolean

Invoked when a Key is pressed and held down.

Link copied to clipboard
open override fun keyUp(key: Key): Boolean

Invoked when a Key is released.

Link copied to clipboard
open fun mouseMoved(screenX: Float, screenY: Float): Boolean

Invoked when the mouse is moved.

Link copied to clipboard

Checks to see if the InputSignal is just pressed for all inputs. This does not trigger for GameAxis.

Link copied to clipboard

Checks to see if the InputSignal is just released for all inputs. This does not trigger for GameAxis.

Link copied to clipboard
open fun scrolled(amountX: Float, amountY: Float): Boolean

Invoked when the mouse is scrolled.

Link copied to clipboard
fun strength(type: InputSignal, deadZone: Float = axisDeadZone): Float

Returns the strength of this InputSignal. GameButton and Key will return as either -1, 0, or 1. A GameAxis will return anything between -1 to 1.

Link copied to clipboard
open override fun touchDown(screenX: Float, screenY: Float, pointer: Pointer): Boolean

Invoked when a Pointer is initially touched or clicked. This includes mouse and touch.

Link copied to clipboard
open fun touchDragged(screenX: Float, screenY: Float, pointer: Pointer): Boolean

Invoked when a Pointer is pressed/clicked and dragged. This includes mouse and touch.

Link copied to clipboard
open override fun touchUp(screenX: Float, screenY: Float, pointer: Pointer): Boolean

Invoked when a Pointer is released. This includes mouse and touch.

Link copied to clipboard
fun vector(type: InputSignal, deadZone: Float = axisDeadZone): Vec2f

Returns the strength of this InputSignal as a vector. This will take the positive X and Y axes and subtract it by the negative X and Y axes. Requires a vector to have been added with the specified type.

Properties

Link copied to clipboard
var axisDeadZone: Float = 0.3f
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Extensions