1*4d7e907cSAndroid Build Coastguard Worker/* 2*4d7e907cSAndroid Build Coastguard Worker * Copyright (C) 2016 The Android Open Source Project 3*4d7e907cSAndroid Build Coastguard Worker * 4*4d7e907cSAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License"); 5*4d7e907cSAndroid Build Coastguard Worker * you may not use this file except in compliance with the License. 6*4d7e907cSAndroid Build Coastguard Worker * You may obtain a copy of the License at 7*4d7e907cSAndroid Build Coastguard Worker * 8*4d7e907cSAndroid Build Coastguard Worker * http://www.apache.org/licenses/LICENSE-2.0 9*4d7e907cSAndroid Build Coastguard Worker * 10*4d7e907cSAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software 11*4d7e907cSAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS, 12*4d7e907cSAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13*4d7e907cSAndroid Build Coastguard Worker * See the License for the specific language governing permissions and 14*4d7e907cSAndroid Build Coastguard Worker * limitations under the License. 15*4d7e907cSAndroid Build Coastguard Worker */ 16*4d7e907cSAndroid Build Coastguard Worker 17*4d7e907cSAndroid Build Coastguard Workerpackage [email protected]; 18*4d7e907cSAndroid Build Coastguard Worker 19*4d7e907cSAndroid Build Coastguard Workerinterface IVibrator { 20*4d7e907cSAndroid Build Coastguard Worker /** 21*4d7e907cSAndroid Build Coastguard Worker * Turn on vibrator 22*4d7e907cSAndroid Build Coastguard Worker * 23*4d7e907cSAndroid Build Coastguard Worker * This function must only be called after the previous timeout has expired or 24*4d7e907cSAndroid Build Coastguard Worker * was canceled (through off()). 25*4d7e907cSAndroid Build Coastguard Worker * @param timeout_ms number of milliseconds to vibrate. 26*4d7e907cSAndroid Build Coastguard Worker * @return vibratorOnRet whether vibrator command was successful or not. 27*4d7e907cSAndroid Build Coastguard Worker */ 28*4d7e907cSAndroid Build Coastguard Worker on(uint32_t timeoutMs) generates (Status vibratorOnRet); 29*4d7e907cSAndroid Build Coastguard Worker 30*4d7e907cSAndroid Build Coastguard Worker /** 31*4d7e907cSAndroid Build Coastguard Worker * Turn off vibrator 32*4d7e907cSAndroid Build Coastguard Worker * 33*4d7e907cSAndroid Build Coastguard Worker * Cancel a previously-started vibration, if any. 34*4d7e907cSAndroid Build Coastguard Worker * @return vibratorOffRet whether vibrator command was successful or not. 35*4d7e907cSAndroid Build Coastguard Worker */ 36*4d7e907cSAndroid Build Coastguard Worker off() generates (Status vibratorOffRet); 37*4d7e907cSAndroid Build Coastguard Worker 38*4d7e907cSAndroid Build Coastguard Worker /** 39*4d7e907cSAndroid Build Coastguard Worker * Returns whether the vibrator supports changes to its vibrational amplitude. 40*4d7e907cSAndroid Build Coastguard Worker */ 41*4d7e907cSAndroid Build Coastguard Worker supportsAmplitudeControl() generates (bool supports); 42*4d7e907cSAndroid Build Coastguard Worker 43*4d7e907cSAndroid Build Coastguard Worker /** 44*4d7e907cSAndroid Build Coastguard Worker * Sets the motor's vibrational amplitude. 45*4d7e907cSAndroid Build Coastguard Worker * 46*4d7e907cSAndroid Build Coastguard Worker * Changes the force being produced by the underlying motor. 47*4d7e907cSAndroid Build Coastguard Worker * 48*4d7e907cSAndroid Build Coastguard Worker * @param amplitude The unitless force setting. Note that this number must 49*4d7e907cSAndroid Build Coastguard Worker * be between 1 and 255, inclusive. If the motor does not 50*4d7e907cSAndroid Build Coastguard Worker * have exactly 255 steps, it must do it's best to map it 51*4d7e907cSAndroid Build Coastguard Worker * onto the number of steps it does have. 52*4d7e907cSAndroid Build Coastguard Worker * @return status Whether the command was successful or not. Must return 53*4d7e907cSAndroid Build Coastguard Worker * Status::UNSUPPORTED_OPERATION if setting the amplitude is 54*4d7e907cSAndroid Build Coastguard Worker * not supported by the device. 55*4d7e907cSAndroid Build Coastguard Worker */ 56*4d7e907cSAndroid Build Coastguard Worker setAmplitude(uint8_t amplitude) generates (Status status); 57*4d7e907cSAndroid Build Coastguard Worker 58*4d7e907cSAndroid Build Coastguard Worker /** 59*4d7e907cSAndroid Build Coastguard Worker * Fire off a predefined haptic event. 60*4d7e907cSAndroid Build Coastguard Worker * 61*4d7e907cSAndroid Build Coastguard Worker * @param event The type of haptic event to trigger. 62*4d7e907cSAndroid Build Coastguard Worker * @return status Whether the effect was successfully performed or not. Must 63*4d7e907cSAndroid Build Coastguard Worker * return Status::UNSUPPORTED_OPERATION is the effect is not 64*4d7e907cSAndroid Build Coastguard Worker * supported. 65*4d7e907cSAndroid Build Coastguard Worker * @return lengthMs The length of time the event is expected to take in 66*4d7e907cSAndroid Build Coastguard Worker * milliseconds. This doesn't need to be perfectly accurate, 67*4d7e907cSAndroid Build Coastguard Worker * but should be a reasonable approximation. Should be a 68*4d7e907cSAndroid Build Coastguard Worker * positive, non-zero value if the returned status is 69*4d7e907cSAndroid Build Coastguard Worker * Status::OK, and set to 0 otherwise. 70*4d7e907cSAndroid Build Coastguard Worker */ 71*4d7e907cSAndroid Build Coastguard Worker perform(Effect effect, EffectStrength strength) generates (Status status, uint32_t lengthMs); 72*4d7e907cSAndroid Build Coastguard Worker}; 73