Skip to content

Commit

Permalink
Android: vibrate one by one
Browse files Browse the repository at this point in the history
  • Loading branch information
weihuoya committed Jan 4, 2019
1 parent fc68b83 commit b87b303
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@

public class Rumble
{
private static long lastRumbleTime;
private static Vibrator phoneVibrator;
private static SparseArray<Vibrator> emuVibrators;

public static void initRumble(EmulationActivity activity)
{
lastRumbleTime = System.currentTimeMillis();

if (activity.deviceHasTouchScreen() &&
PreferenceManager.getDefaultSharedPreferences(activity)
.getBoolean("phoneRumble", true))
Expand Down Expand Up @@ -73,6 +76,12 @@ public static void clear()

public static void checkRumble(int padId, double state)
{
// vibrate one by one
long currentTime = System.currentTimeMillis();
if (currentTime - lastRumbleTime < 100)
return;
lastRumbleTime = currentTime;

if (phoneVibrator != null)
doRumble(phoneVibrator);

Expand Down

0 comments on commit b87b303

Please sign in to comment.