Example usage for android.view InputDevice getVibrator

List of usage examples for android.view InputDevice getVibrator

Introduction

In this page you can find the example usage for android.view InputDevice getVibrator.

Prototype

public Vibrator getVibrator() 

Source Link

Document

Gets the vibrator service associated with the device, if there is one.

Usage

From source file:info.bartowski.easteregg.MLand.java

private void thump(int playerIndex, long ms) {
    if (mAudioManager.getRingerMode() == AudioManager.RINGER_MODE_SILENT) {
        // No interruptions. Not even game haptics.
        return;//from ww  w.j av  a 2 s  . co m
    }
    if (playerIndex < mGameControllers.size()) {
        int controllerId = mGameControllers.get(playerIndex);
        InputDevice dev = InputDevice.getDevice(controllerId);
        if (dev != null && dev.getVibrator().hasVibrator()) {
            Utility.compatVibrate(dev.getVibrator(), (long) (ms * CONTROLLER_VIBRATION_MULTIPLIER));
            return;
        }
    }
    Utility.compatVibrate(mVibrator, (long) (ms * CONTROLLER_VIBRATION_MULTIPLIER));
}