diff --git a/gdx-controllers-desktop/src/main/java/com/badlogic/gdx/controllers/desktop/support/JamepadController.java b/gdx-controllers-desktop/src/main/java/com/badlogic/gdx/controllers/desktop/support/JamepadController.java index d4f3011..8104f35 100644 --- a/gdx-controllers-desktop/src/main/java/com/badlogic/gdx/controllers/desktop/support/JamepadController.java +++ b/gdx-controllers-desktop/src/main/java/com/badlogic/gdx/controllers/desktop/support/JamepadController.java @@ -34,6 +34,7 @@ public class JamepadController implements Controller { private final IntMap axisState = new IntMap<>(); private final String uuid; private boolean connected = true; + private boolean canVibrate = true; private long vibrationEndMs; public JamepadController(ControllerIndex controllerIndex) { @@ -158,7 +159,7 @@ private void initializeState() { @Override public boolean canVibrate() { - return true; + return canVibrate; } @Override @@ -169,8 +170,12 @@ public boolean isVibrating() { @Override public void startVibration(int duration, float strength) { try { - controllerIndex.doVibration(strength, strength, duration); - vibrationEndMs = TimeUtils.millis() + duration; + if (controllerIndex.doVibration(strength, strength, duration)) { + vibrationEndMs = TimeUtils.millis() + duration; + canVibrate = true; + } else { + canVibrate = false; + } } catch (ControllerUnpluggedException e) { setDisconnected(); }