1/*
2 * Copyright (c) 2022-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 a driver for upper-layer vibrator services.
21 *
22 * After obtaining a driver object or agent, a vibrator service get vibrator ability or
23 * set the vibrator effect using the functions provided by the driver object or agent.
24 *
25 * @since 3.2
26 */
27
28/**
29 * @file VibratorTypes.idl
30 *
31 * @brief Declares common APIs in the vibrator module. The APIs canObtains information about all the vibrator
32 * that support setting intensity and Start the vibrator according to the incoming vibration effect.
33 *
34 * @since 3.2
35 * @version 1.1
36 */
37
38package ohos.hdi.vibrator.v1_1;
39
40import ohos.hdi.vibrator.v1_1.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    /**
85     * @brief Obtains information about all the vibrator that support setting intensity and frequency in the system.
86     *
87     * @param vibratorInfo Indicates the pointer to the vibration effect, For details, see {@link HdfVibratorInfo}.
88     *
89     * @return Returns <b>0</b> if the operation is successful.
90     * @return Returns negative value if the get failed.
91     *
92     * @since 3.2
93     * @version 1.1
94     */
95    GetVibratorInfo([out] struct HdfVibratorInfo[] vibratorInfo);
96    /**
97     * @brief Start the vibrator according to the incoming vibration effect.
98     *
99     * @param duration Indicates the duration that the vibration lasts, in milliseconds.
100     *
101     * @param intensity Indicates vibrator intensity in a vibration period.
102     *
103     * @param frequency Indicates vibrator frequency in a vibration period.
104     *
105     * @return Returns <b>0</b> if the operation is successful.
106     * @return Returns <b>-1</b> if the vibrationPeriod setting is not supported.
107     * @return Returns <b>-2</b> if the intensity setting is not supported.
108     * @return Returns <b>-3</b> if the frequency setting is not supported.
109     *
110     * @since 3.2
111     * @version 1.1
112     */
113    EnableVibratorModulation([in] unsigned int duration, [in] unsigned short intensity, [in] short frequency);
114    /**
115     * @brief Controls the vibrator to perform a periodic vibration with the custom composite effect.
116     *
117     * @param effect Indicates the pointer to the custom composite effect type. For details,
118     * see {@link HdfCompositeEffect}.
119     *
120     * @return Returns <b>0</b> if the operation is successful; returns a negative value otherwise.
121     *
122     * @since 3.2
123     * @version 1.1
124     */
125    EnableCompositeEffect([in] struct HdfCompositeEffect effect);
126    /**
127     * @brief Obtains the vibration effect information with the specified effect type.
128     *
129     * @param effectType Indicates the pointer to the preset effect type. It is recommended that the
130     * maximum length be 64 bytes.
131     *
132     * @param effectInfo Indicates the pointer to the vibration effect information. For details,
133     * see {@link HdfEffectInfo}.
134     *
135     * @return Returns <b>0</b> if the operation is successful.
136     * @return Returns negative value if the get failed.
137     *
138     * @since 3.2
139     * @version 1.1
140     */
141    GetEffectInfo([in] String effectType, [out] struct HdfEffectInfo effectInfo);
142    /**
143     * @brief Obtains whether the vibrator is currently vibrating.
144     *
145     * @param state Indicates current vibration state of the vibrator.
146     *
147     * @return Returns <b>0</b> if the operation is successful.
148     * @return Returns negative value if the get failed.
149     *
150     * @since 3.2
151     * @version 1.1
152     */
153    IsVibratorRunning([out] boolean state);
154}