Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Skip to content
Commit b88c93ef authored by Nathaniel R. Lewis's avatar Nathaniel R. Lewis Committed by Chris Ye
Browse files

InputManager: Support amplitude control for InputDeviceVibrator

Add support for sending vibration amplitude(s) from OneShot and
Waveform VibrationEffects to the native layer to support variable
amplitude vibration motors in input devices such as gamepads.

Fix bug with vibration API. In N, the VibrationEffect method which
takes both timings and amplitudes states that each timing/amplitude
pair makes the vibration last for the specified duration with the
specified amplitude, 0 meaning the motor is off. If this method
is used with an input device vibrator, it turns off for every even
numbered element, regardless of the amplitude value. The method
which takes only timing values works as expected.

Test: Connect a gamepad whose driver supports FF_RUMBLE, find it
      with the android input framework, and do something like this:

      // waveform where rumble magnitude doubles every 2 seconds
      VibrationEffect effect = VibrationEffect.createWaveform(
              new long[] { 2000L, 2000L, 2000L, 2000L, 2000L },
              new int[] { 16, 32, 64, 128, 255 },
              -1);
      inputDevice.getVibrator().vibrate(effect);

Bug: 136215622
Bug: 38511270
Change-Id: I06afd374e30d63b49aa79fa2b68e2a236b5347b2
parent 53c5d870
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment