From 50bd58fc29a49775a50084abb33d9e1ebfd74f0f Mon Sep 17 00:00:00 2001 From: Tom Lint Date: Mon, 18 Aug 2014 15:05:32 +0200 Subject: [PATCH] Implemented GamePad vibration --- .../Microsoft/Xna/Framework/Input/GamePad.java | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/Input/GamePad.java b/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/Input/GamePad.java index 1a67c17..8ae177e 100644 --- a/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/Input/GamePad.java +++ b/Microsoft.Xna.Framework/src/Microsoft/Xna/Framework/Input/GamePad.java @@ -92,12 +92,24 @@ public class GamePad * @return * true if successful, false otherwise. */ - public static boolean SetVibration(PlayerIndex playerIndex, float leftMotor, float rightMotor) + public synchronized static boolean SetVibration(PlayerIndex playerIndex, float leftMotor, float rightMotor) { Controller ctrl = Controllers.getController(playerIndex.ordinal()); - //TODO: Implement + int rumblrCount = ctrl.getRumblerCount(); - return true; + if (rumblrCount > 0) + { + ctrl.setRumblerStrength(0, leftMotor); + + if (rumblrCount > 1) + { + ctrl.setRumblerStrength(1, rightMotor); + } + + return true; + } + + return false; } }