• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2024 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 #ifndef VIBRATOR_AGENT_TYPE_H
17 #define VIBRATOR_AGENT_TYPE_H
18 
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
22 
23 /**
24  * @brief Describes the vibration effect of the vibrator when a user adjusts the timer.
25  *
26  * @since 1
27  */
28 inline const char *VIBRATOR_TYPE_CLOCK_TIMER = "haptic.clock.timer";
29 
30 /**
31  * @brief Describes the vibration effect of the vibrator when authentication fails.
32  *
33  * @since 11
34  */
35 inline const char *VIBRATOR_TYPE_FAIL = "haptic.notice.fail";
36 
37 /**
38  * @brief Describes the vibration effect of the vibrator when charging.
39  *
40  * @since 11
41  */
42 inline const char *VIBRATOR_TYPE_CHARGING = "haptic.calib.charge";
43 
44 /**
45  * @brief Describes the vibration effect of the vibrator when long pressed.
46  *
47  * @since 11
48  */
49 inline const char *VIBRATOR_TYPE_LONG_PRESS_LIGHT = "haptic.long_press_light";
50 
51 /**
52  * @brief Describes the vibration effect of the vibrator when long pressed.
53  *
54  * @since 11
55  */
56 inline const char *VIBRATOR_TYPE_LONG_PRESS_MEDIUM = "haptic.long_press_medium";
57 
58 /**
59  * @brief Describes the vibration effect of the vibrator when long pressed.
60  *
61  * @since 11
62  */
63 inline const char *VIBRATOR_TYPE_LONG_PRESS_HEAVY = "haptic.long_press_medium";
64 
65 /**
66  * @brief Describes the vibration effect of the vibrator when slide.
67  *
68  * @since 11
69  */
70 inline const char *VIBRATOR_TYPE_SLIDE_LIGHT = "haptic.slide";
71 
72 /**
73  * @brief Describes the vibration effect of the vibrator when the threshold is reached.
74  *
75  * @since 11
76  */
77 inline const char *VIBRATOR_TYPE_THRESHOID = "haptic.common.threshold";
78 
79 /**
80  * @brief Describes the hard vibration effect of the vibrator.
81  *
82  * @since 12
83  */
84 inline const char *VIBRATOR_TYPE_HARD = "haptic.effect.hard";
85 
86 /**
87  * @brief Describes the soft vibration effect of the vibrator.
88  *
89  * @since 12
90  */
91 inline const char *VIBRATOR_TYPE_SOFT = "haptic.effect.soft";
92 
93 /**
94  * @brief Describes the sharp vibration effect of the vibrator.
95  *
96  * @since 12
97  */
98 inline const char *VIBRATOR_TYPE_SHARP = "haptic.effect.sharp";
99 
100 /**
101  * @brief Describes the vibration effect of the vibrator when slide.
102  *
103  * @since 12
104  */
105 inline const char *VIBRATOR_TYPE_SLIDE = "haptic.slide";
106 
107 /**
108  * @brief Describes the vibration effect of the succeed notice.
109  *
110  * @since 16
111  */
112 inline const char *VIBRATOR_TYPE_NOTICE_SUCCESS = "haptic.notice.success";
113 
114 /**
115  * @brief Describes the vibration effect of the failed notice.
116  *
117  * @since 16
118  */
119 inline const char *VIBRATOR_TYPE_NOTICE_FAILURE = "haptic.notice.fail";
120 
121 /**
122  * @brief Describes the vibration effect of the warning notice.
123  *
124  * @since 16
125  */
126 inline const char *VIBRATOR_TYPE_NOTICE_WARNING = "haptic.notice.warning";
127 
128 /**
129  * @brief Enumerates vibration usages.
130  *
131  * @since 9
132  */
133 typedef enum VibratorUsage {
134     USAGE_UNKNOWN = 0,            /**< Vibration is used for unknown, lowest priority */
135     USAGE_ALARM = 1,              /**< Vibration is used for alarm */
136     USAGE_RING = 2,               /**< Vibration is used for ring */
137     USAGE_NOTIFICATION = 3,       /**< Vibration is used for notification */
138     USAGE_COMMUNICATION = 4,      /**< Vibration is used for communication */
139     USAGE_TOUCH = 5,              /**< Vibration is used for touch */
140     USAGE_MEDIA = 6,              /**< Vibration is used for media */
141     USAGE_PHYSICAL_FEEDBACK = 7,  /**< Vibration is used for physical feedback */
142     USAGE_SIMULATE_REALITY = 8,   /**< Vibration is used for simulate reality */
143     USAGE_MAX
144 } VibratorUsage;
145 
146 /**
147  * @brief Vibration effect description file.
148  *
149  * @since 11
150  */
151 typedef struct VibratorFileDescription {
152     int32_t fd = -1;
153     int64_t offset = -1;
154     int64_t length = -1;
155 } VibratorFileDescription;
156 
157 /**
158  * @brief The type of vibration event.
159  *
160  * @since 11
161  */
162 typedef enum VibratorEventType {
163     EVENT_TYPE_UNKNOWN = -1, /**< Unknown vibration event type */
164     EVENT_TYPE_CONTINUOUS = 0, /**< Continuous vibration event type */
165     EVENT_TYPE_TRANSIENT = 1, /**< Transient vibration event type */
166 } VibratorEventType;
167 
168 /**
169  * @brief Vibration curve adjustment point.
170  *
171  * @since 11
172  */
173 typedef struct VibratorCurvePoint {
174     int32_t time = -1;
175     int32_t intensity = -1;
176     int32_t frequency = -1;
177 } VibratorCurvePoint;
178 
179 /**
180  * @brief The vibration event.
181  *
182  * @since 11
183  */
184 typedef struct VibratorEvent {
185     VibratorEventType type = EVENT_TYPE_UNKNOWN;
186     int32_t time = -1;
187     int32_t duration = -1;
188     int32_t intensity = -1;
189     int32_t frequency = -1;
190     int32_t index = 0; // 0:both 1:left 2:right
191     int32_t pointNum = 0;
192     VibratorCurvePoint *points = nullptr;
193 } VibratorEvent;
194 
195 /**
196  * @brief Describe the vibration pattern, including the vibration event sequence.
197  *
198  * @since 11
199  */
200 typedef struct VibratorPattern {
201     int32_t time = -1;
202     int32_t eventNum = 0;
203     int32_t patternDuration = 0;
204     VibratorEvent *events = nullptr;
205 } VibratorPattern;
206 
207 /**
208  * @brief Describes the vibration package structure, including the vibration pattern sequence.
209  *
210  * @since 11
211  */
212 typedef struct VibratorPackage {
213     int32_t patternNum = 0; // pattern
214     int32_t packageDuration = 0;
215     VibratorPattern *patterns = nullptr;
216 } VibratorPackage;
217 
218 /**
219  * @brief Vibration effect adjustment parameters.
220  *
221  * @since 11
222  */
223 typedef struct VibratorParameter {
224     int32_t intensity = 100;  // from 0 to 100
225     int32_t frequency = 0;    // from -100 to 100
226     int32_t reserved = 0;
227 } VibratorParameter;
228 /** @} */
229 #ifdef __cplusplus
230 };
231 #endif
232 
233 #endif  // endif VIBRATOR_AGENT_TYPE_H