1/*
2 * Copyright (c) 2022 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 a driver for upper-layer vibrator services.
21 *
22 * After obtaining a driver object or agent, a vibrator service starts or stops the vibrator
23 * using the functions provided by the driver object or agent.
24 *
25 * @since 2.2
26 */
27
28/**
29 * @file VibratorTypes.idl
30 *
31 * @brief Declares common APIs in the vibrator module. The APIs can be used to control
32 * the vibrator to perform a one-shot or periodic vibration.
33 *
34 * @since 2.2
35 * @version 1.0
36 */
37
38package ohos.hdi.vibrator.v1_0;
39
40import ohos.hdi.vibrator.v1_0.VibratorTypes;
41
42interface IVibratorInterface {
43    /**
44     * @brief Controls the vibrator to perform a one-shot vibration that lasts for a given duration.
45     *
46     * One-shot vibration is mutually exclusive with periodic vibration. Before using one-shot vibration,
47     * exit periodic vibration.
48     *
49     * @param duration Indicates the duration that the one-shot vibration lasts, in milliseconds.
50      * @return Returns <b>0</b> if the operation is successful; returns a negative value otherwise.
51     *
52     * @since 2.2
53     * @version 1.0
54     */
55    StartOnce([in] unsigned int duration);
56    /**
57     * @brief Controls the vibrator to perform a periodic vibration with the preset effect.
58     *
59     * One-shot vibration is mutually exclusive with periodic vibration. Before using periodic vibration,
60     * exit one-shot vibration.
61     *
62     * @param effectType Indicates the pointer to the preset effect type. It is recommended that the
63     * maximum length be 64 bytes.
64      * @return Returns <b>0</b> if the operation is successful; returns a negative value otherwise.
65     *
66     * @since 2.2
67     * @version 1.0
68     */
69    Start([in] String effectType);
70    /**
71     * @brief Stops the vibration.
72     *
73     * Before the vibrator starts, it must stop vibrating in any mode. This function can be used during
74     * and after the vibrating process.
75     *
76     * @param mode Indicates the vibration mode, which can be one-shot or periodic. For details,
77     * see {@link HdfVibratorMode}.
78      * @return Returns <b>0</b> if the operation is successful; returns a negative value otherwise.
79     *
80     * @since 2.2
81     * @version 1.0
82     */
83    Stop([in] enum HdfVibratorMode mode);
84}