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
Loading
Please register or sign in to comment