FlixelGamepadDevice
View sourceclass
org.flixelgdx.input.gamepad.FlixelGamepadDevice
Optional per-slot facade for gamepad queries. Instances are created only when the game calls FlixelGamepadInputManager.ensureDevice(int); FlixelGamepadInputManager.getById(int) stays null until then.
Methods
getId()
Slot index for this device (stable while the controller stays at the same list index in the backend).
Returns: Gamepad id between 0 and FlixelGamepadInputManager.MAX_GAMEPADS exclusive.
isConnected()
Whether this slot currently maps to a connected controller.
Returns: true when connected.
getConnected()
Returns whether this gamepad slot currently maps to a connected controller.
getModel()
Model detected for this slot the last time the slot was (re)bound.
Returns: Detected model, or FlixelGamepadModel.UNKNOWN when out of range.
pressed(int)
Returns true when this controller is currently pressing the given button.
Parameters:
| Name | Description |
|---|---|
logicalButton | A logical button constant from FlixelGamepadButton. |
Returns: true when the button is held this frame.
justPressed(int)
Returns true when this controller first pressed the button this frame.
Parameters:
| Name | Description |
|---|---|
logicalButton | A logical button constant from FlixelGamepadButton. |
Returns: true on the first frame the button is pressed.
justReleased(int)
Returns true when this controller released the button this frame.
Parameters:
| Name | Description |
|---|---|
logicalButton | A logical button constant from FlixelGamepadButton. |
Returns: true on the first frame the button is no longer pressed.
canVibrate()
Returns whether this controller reports vibration support.
Returns: true when connected and the hardware supports vibration.
vibrate(float)
Vibrates this controller at full intensity on both motors for the given duration.
Parameters:
| Name | Description |
|---|---|
durationSecs | How long to vibrate in seconds. |
vibrate(float, float)
Vibrates this controller at the given intensity on both motors.
Parameters:
| Name | Description |
|---|---|
intensity | Motor strength in the range [0, 1]. |
durationSecs | How long to vibrate in seconds. |
vibrate(float, float, float)
Vibrates this controller with independent left and right motor intensities.
Parameters:
| Name | Description |
|---|---|
leftIntensity | Strength for the left (low-frequency) motor, in the range [0, 1]. |
rightIntensity | Strength for the right (high-frequency) motor, in the range [0, 1]. |
durationSecs | How long to vibrate in seconds. |
stopVibration()
Stops any active vibration on this controller immediately.
getAxis(int)
Returns the current value of a logical axis on this controller, after dead-zone processing.
Parameters:
| Name | Description |
|---|---|
logicalAxis | A logical axis constant from FlixelGamepadButton. |
Returns: Axis value in the range [-1, 1], or 0f when inactive or within the dead zone.
getXAxis()
Shorthand for the left stick horizontal axis (FlixelGamepadButton.AXIS_LEFT_X).
Returns: Horizontal axis value in the range [-1, 1].
getYAxis()
Shorthand for the left stick vertical axis (FlixelGamepadButton.AXIS_LEFT_Y).
Returns: Vertical axis value in the range [-1, 1].
getTriggerL()
Analog pressure of the left trigger (L2), in the range [0, 1], after dead-zone processing.
On Jamepad/SDL desktop, triggers are axes; this reads the trigger axis directly. On web (TeaVM/W3C Gamepad API), triggers are digital buttons and this always returns 0; because of this, use FlixelGamepadDevice.pressed(int) with FlixelGamepadButton.L2 there instead.
Returns: Trigger pressure in [0, 1], or 0f within the dead zone.
getTriggerR()
Analog pressure of the right trigger (R2), in the range [0, 1], after dead-zone processing.
On Jamepad/SDL desktop, triggers are axes; this reads the trigger axis directly. On web (TeaVM/W3C Gamepad API), triggers are digital buttons and this always returns 0; because of this, use FlixelGamepadDevice.pressed(int) with FlixelGamepadButton.R2 there instead.
Returns: Trigger pressure in [0, 1], or 0f within the dead zone.