1 /* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 /** 17 * @addtogroup Vibrator 18 * @{ 19 * 20 * @brief Provides APIs for vibrator services to access the vibrator driver. 21 * @since 11 22 */ 23 24 /** 25 * @file vibrator.h 26 * @kit SensorServiceKit 27 * @brief Declares the APIs for starting or stopping vibration. 28 * @library libohvibrator.z.so 29 * @syscap SystemCapability.Sensors.MiscDevice 30 * @since 11 31 */ 32 33 #ifndef VIBRATOR_H 34 #define VIBRATOR_H 35 36 #include "vibrator_type.h" 37 38 #ifdef __cplusplus 39 extern "C" { 40 #endif 41 42 /** 43 * @brief Controls the vibrator to vibrate continuously for a given duration. 44 * 45 * @param duration - Vibration duration, in milliseconds. 46 * @param attribute - Vibration attribute. For details, see {@link Vibrator_Attribute}. 47 * @return Returns <b>0</b> if the operation is successful; returns a non-zero value otherwise. 48 * For details, see {@link Vibrator_ErrorCode}. 49 * @permission ohos.permission.VIBRATE 50 * 51 * @since 11 52 */ 53 int32_t OH_Vibrator_PlayVibration(int32_t duration, Vibrator_Attribute attribute); 54 55 /** 56 * @brief Controls the vibrator to vibrate with the custom sequence. 57 * 58 * @param fileDescription - File descriptor of the custom vibration effect. 59 * For details, see {@link Vibrator_FileDescription}. 60 * @param vibrateAttribute - Vibration attribute. For details, see {@link Vibrator_Attribute}. 61 * @return Returns <b>0</b> if the operation is successful; returns a non-zero value otherwise. 62 * For details, see {@link Vibrator_ErrorCode}. 63 * @permission ohos.permission.VIBRATE 64 * 65 * @since 11 66 */ 67 int32_t OH_Vibrator_PlayVibrationCustom(Vibrator_FileDescription fileDescription, 68 Vibrator_Attribute vibrateAttribute); 69 70 /** 71 * @brief Stop the motor vibration according to the input mode. 72 * 73 * @permission ohos.permission.VIBRATE 74 * @return Returns <b>0</b> if the operation is successful; returns a non-zero value otherwise. 75 * For details, see {@link Vibrator_ErrorCode}. 76 * @permission ohos.permission.VIBRATE 77 * 78 * @since 11 79 */ 80 int32_t OH_Vibrator_Cancel(); 81 #ifdef __cplusplus 82 } 83 #endif 84 /** @} */ 85 #endif // endif VIBRATOR_H