1c5e268c6Sopenharmony_ci/* 2c5e268c6Sopenharmony_ci * Copyright (c) 2022 Huawei Device Co., Ltd. 3c5e268c6Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4c5e268c6Sopenharmony_ci * you may not use this file except in compliance with the License. 5c5e268c6Sopenharmony_ci * You may obtain a copy of the License at 6c5e268c6Sopenharmony_ci * 7c5e268c6Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8c5e268c6Sopenharmony_ci * 9c5e268c6Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10c5e268c6Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11c5e268c6Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12c5e268c6Sopenharmony_ci * See the License for the specific language governing permissions and 13c5e268c6Sopenharmony_ci * limitations under the License. 14c5e268c6Sopenharmony_ci */ 15c5e268c6Sopenharmony_ci 16c5e268c6Sopenharmony_ci/** 17c5e268c6Sopenharmony_ci * @addtogroup Vibrator 18c5e268c6Sopenharmony_ci * @{ 19c5e268c6Sopenharmony_ci * 20c5e268c6Sopenharmony_ci * @brief Provides a driver for upper-layer vibrator services. 21c5e268c6Sopenharmony_ci * 22c5e268c6Sopenharmony_ci * After obtaining a driver object or agent, a vibrator service starts or stops the vibrator 23c5e268c6Sopenharmony_ci * using the functions provided by the driver object or agent. 24c5e268c6Sopenharmony_ci * 25c5e268c6Sopenharmony_ci * @since 2.2 26c5e268c6Sopenharmony_ci */ 27c5e268c6Sopenharmony_ci 28c5e268c6Sopenharmony_ci/** 29c5e268c6Sopenharmony_ci * @file VibratorTypes.idl 30c5e268c6Sopenharmony_ci * 31c5e268c6Sopenharmony_ci * @brief Declares common APIs in the vibrator module. The APIs can be used to control 32c5e268c6Sopenharmony_ci * the vibrator to perform a one-shot or periodic vibration. 33c5e268c6Sopenharmony_ci * 34c5e268c6Sopenharmony_ci * @since 2.2 35c5e268c6Sopenharmony_ci * @version 1.0 36c5e268c6Sopenharmony_ci */ 37c5e268c6Sopenharmony_ci 38c5e268c6Sopenharmony_cipackage ohos.hdi.vibrator.v1_0; 39c5e268c6Sopenharmony_ci 40c5e268c6Sopenharmony_ciimport ohos.hdi.vibrator.v1_0.VibratorTypes; 41c5e268c6Sopenharmony_ci 42c5e268c6Sopenharmony_ciinterface IVibratorInterface { 43c5e268c6Sopenharmony_ci /** 44c5e268c6Sopenharmony_ci * @brief Controls the vibrator to perform a one-shot vibration that lasts for a given duration. 45c5e268c6Sopenharmony_ci * 46c5e268c6Sopenharmony_ci * One-shot vibration is mutually exclusive with periodic vibration. Before using one-shot vibration, 47c5e268c6Sopenharmony_ci * exit periodic vibration. 48c5e268c6Sopenharmony_ci * 49c5e268c6Sopenharmony_ci * @param duration Indicates the duration that the one-shot vibration lasts, in milliseconds. 50c5e268c6Sopenharmony_ci * @return Returns <b>0</b> if the operation is successful; returns a negative value otherwise. 51c5e268c6Sopenharmony_ci * 52c5e268c6Sopenharmony_ci * @since 2.2 53c5e268c6Sopenharmony_ci * @version 1.0 54c5e268c6Sopenharmony_ci */ 55c5e268c6Sopenharmony_ci StartOnce([in] unsigned int duration); 56c5e268c6Sopenharmony_ci /** 57c5e268c6Sopenharmony_ci * @brief Controls the vibrator to perform a periodic vibration with the preset effect. 58c5e268c6Sopenharmony_ci * 59c5e268c6Sopenharmony_ci * One-shot vibration is mutually exclusive with periodic vibration. Before using periodic vibration, 60c5e268c6Sopenharmony_ci * exit one-shot vibration. 61c5e268c6Sopenharmony_ci * 62c5e268c6Sopenharmony_ci * @param effectType Indicates the pointer to the preset effect type. It is recommended that the 63c5e268c6Sopenharmony_ci * maximum length be 64 bytes. 64c5e268c6Sopenharmony_ci * @return Returns <b>0</b> if the operation is successful; returns a negative value otherwise. 65c5e268c6Sopenharmony_ci * 66c5e268c6Sopenharmony_ci * @since 2.2 67c5e268c6Sopenharmony_ci * @version 1.0 68c5e268c6Sopenharmony_ci */ 69c5e268c6Sopenharmony_ci Start([in] String effectType); 70c5e268c6Sopenharmony_ci /** 71c5e268c6Sopenharmony_ci * @brief Stops the vibration. 72c5e268c6Sopenharmony_ci * 73c5e268c6Sopenharmony_ci * Before the vibrator starts, it must stop vibrating in any mode. This function can be used during 74c5e268c6Sopenharmony_ci * and after the vibrating process. 75c5e268c6Sopenharmony_ci * 76c5e268c6Sopenharmony_ci * @param mode Indicates the vibration mode, which can be one-shot or periodic. For details, 77c5e268c6Sopenharmony_ci * see {@link HdfVibratorMode}. 78c5e268c6Sopenharmony_ci * @return Returns <b>0</b> if the operation is successful; returns a negative value otherwise. 79c5e268c6Sopenharmony_ci * 80c5e268c6Sopenharmony_ci * @since 2.2 81c5e268c6Sopenharmony_ci * @version 1.0 82c5e268c6Sopenharmony_ci */ 83c5e268c6Sopenharmony_ci Stop([in] enum HdfVibratorMode mode); 84c5e268c6Sopenharmony_ci}