FlixelHapticsProvider
View sourceinterface
org.flixelgdx.input.gamepad.FlixelHapticsProvider
Pluggable vibration backend for FlixelGamepadInputManager.
The built-in implementation, FlixelDefaultHapticsProvider, delegates to gdx-controllers' Controller.startVibration and works on desktop (SDL via gdx-controllers-desktop) and web (W3C Gamepad API via gdx-controllers-teavm) without any extra setup. For platform-specific features such as dual-motor channels, haptic patterns, or DualSense adaptive triggers, supply a custom implementation via FlixelGamepadInputManager.setHapticsProvider(FlixelHapticsProvider).
Intensity values
All intensity parameters are normalized to the range [0, 1], where 0f means no vibration and 1f means full motor strength. Implementations should clamp values outside this range rather than letting them reach the hardware unchecked.
Slot indices
Each method receives the same slot id used throughout FlixelGamepadInputManager. The manager already validates that the slot is in range and that the gamepad system is enabled before calling the provider, so implementations do not need to repeat those checks.
Methods
vibrate(int, float, float, float)
Vibrates the controller in the given slot.
The built-in providers for desktop and web honor both motor channels independently. Implementations targeting single-motor hardware may collapse the two intensities to a single value, typically the larger of the two.
Parameters:
| Name | Description |
|---|---|
slot | Slot index between 0 and FlixelGamepadInputManager.MAX_GAMEPADS exclusive. |
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(int)
Stops any active vibration on the controller in the given slot immediately.
Parameters:
| Name | Description |
|---|---|
slot | Slot index. |
canVibrate(int)
Returns whether the controller in the given slot reports haptics support.
Parameters:
| Name | Description |
|---|---|
slot | Slot index. |
Returns: true when the slot is connected and the hardware supports vibration.